UNPKG

@bluefin-exchange/bluefin7k-aggregator-sdk

Version:
36 lines (35 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AfterMathContract = void 0; const base_1 = require("../base"); const token_1 = require("../../../utils/token"); class AfterMathContract extends base_1.BaseContract { async swap(tx) { const poolId = this.swapInfo.poolId; const returnAmount = this.swapInfo.returnAmount; const coinInType = (0, token_1.normalizeTokenType)(this.swapInfo.assetIn); const coinOutType = (0, token_1.normalizeTokenType)(this.swapInfo.assetOut); const inputCoinObject = this.inputCoinObject; const [lpCoinType] = this.getTypeParams(); if (!lpCoinType) throw new Error("lpCoinType is not defined"); const config = this.config.aftermath; const [tokenOut] = tx.moveCall({ target: `${config.package}::swap::swap_exact_in`, typeArguments: [lpCoinType, coinInType, coinOutType], arguments: [ tx.object(poolId), tx.object(config.poolRegistry), tx.object(config.protocolFeeVault), tx.object(config.treasury), tx.object(config.insuranceFund), tx.object(config.referralVault), inputCoinObject, tx.pure.u64(returnAmount), tx.pure.u64("1000000000000000000"), // slippage ], }); return tokenOut; } } exports.AfterMathContract = AfterMathContract;