@pontem/liquidswap-sdk
Advanced tools
Comparing version 0.6.1 to 0.7.0
@@ -26,4 +26,5 @@ "use strict"; | ||
WETH: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::WETH', | ||
USDC: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC', // layerzero USDC | ||
USDC: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC', | ||
amAPT: '0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a::amapt_token::AmnisApt' // Amnis APT | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -6,2 +6,3 @@ import Decimal from 'decimal.js'; | ||
import { CreateTXPayloadParams } from './SwapModule'; | ||
import { VERSION_0, VERSION_0_5 } from "../constants"; | ||
interface ICreateBurnLiquidityPayload { | ||
@@ -13,2 +14,3 @@ fromToken: AptosResourceType; | ||
curveType: CurveType; | ||
version?: typeof VERSION_0 | typeof VERSION_0_5; | ||
} | ||
@@ -22,4 +24,5 @@ interface ICalculateRatesParams { | ||
slippage: number; | ||
version?: typeof VERSION_0 | typeof VERSION_0_5; | ||
} | ||
interface ICalculateSupplyParams extends Pick<ICalculateRatesParams, 'slippage'> { | ||
interface ICalculateSupplyParams extends Pick<ICalculateRatesParams, 'slippage' | 'version'> { | ||
toAmount: Decimal | number; | ||
@@ -38,2 +41,3 @@ fromAmount: Decimal | number; | ||
curveType: CurveType; | ||
version?: typeof VERSION_0 | typeof VERSION_0_5; | ||
} | ||
@@ -40,0 +44,0 @@ declare type TGetResourcesPayload = Omit<ICalculateRatesParams, 'amount' | 'slippage' | 'interactiveToken'>; |
@@ -6,2 +6,4 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
const constants_1 = require("../constants"); | ||
const contracts_1 = require("../utils/contracts"); | ||
class LiquidityModule { | ||
@@ -16,9 +18,12 @@ constructor(sdk) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { moduleAccount, resourceAccount } = this.sdk.networkOptions; | ||
const { moduleAccount, resourceAccount, moduleAccountV05, resourceAccountV05 } = this.sdk.networkOptions; | ||
const curves = this.sdk.curves; | ||
const modulesLiquidityPool = (0, utils_1.composeType)(moduleAccount, 'liquidity_pool', 'LiquidityPool'); | ||
const curve = curves[params.curveType]; | ||
const { version = constants_1.VERSION_0 } = params; | ||
const moduleAcc = version === constants_1.VERSION_0_5 ? moduleAccountV05 : moduleAccount; | ||
const resourceAcc = version === constants_1.VERSION_0_5 ? resourceAccountV05 : resourceAccount; | ||
const modulesLiquidityPool = (0, utils_1.composeType)(moduleAcc, 'liquidity_pool', 'LiquidityPool'); | ||
const curve = (0, contracts_1.getCurve)(params.curveType, curves, version); | ||
const liquidityPoolType = (0, utils_1.getPoolStr)(params.fromToken, params.toToken, curve, modulesLiquidityPool); | ||
try { | ||
const liquidityPoolResource = yield this.sdk.Resources.fetchAccountResource(resourceAccount, liquidityPoolType); | ||
const liquidityPoolResource = yield this.sdk.Resources.fetchAccountResource(resourceAcc, liquidityPoolType); | ||
return Boolean(liquidityPoolResource === null || liquidityPoolResource === void 0 ? void 0 : liquidityPoolResource.type); | ||
@@ -33,6 +38,9 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { moduleAccount, resourceAccount } = this.sdk.networkOptions; | ||
const { moduleAccount, resourceAccount, moduleAccountV05, resourceAccountV05 } = this.sdk.networkOptions; | ||
const curves = this.sdk.curves; | ||
const modulesLiquidityPool = (0, utils_1.composeType)(moduleAccount, 'liquidity_pool', 'LiquidityPool'); | ||
const curve = curves[params.curveType]; | ||
const { version = constants_1.VERSION_0 } = params; | ||
const moduleAcc = version === constants_1.VERSION_0_5 ? moduleAccountV05 : moduleAccount; | ||
const resourceAcc = version === constants_1.VERSION_0_5 ? resourceAccountV05 : resourceAccount; | ||
const curve = (0, contracts_1.getCurve)(params.curveType, curves, version); | ||
const modulesLiquidityPool = (0, utils_1.composeType)(moduleAcc, 'liquidity_pool', 'LiquidityPool'); | ||
const liquidityPoolType = (0, utils_1.getPoolStr)(params.fromToken, params.toToken, curve, modulesLiquidityPool); | ||
@@ -42,3 +50,3 @@ let liquidityPoolResource; | ||
liquidityPoolResource = | ||
yield this.sdk.Resources.fetchAccountResource(resourceAccount, liquidityPoolType); | ||
yield this.sdk.Resources.fetchAccountResource(resourceAcc, liquidityPoolType); | ||
} | ||
@@ -54,4 +62,6 @@ catch (e) { | ||
const curves = this.sdk.curves; | ||
const { modules, resourceAccount } = this.sdk.networkOptions; | ||
const curve = curves[params.curveType]; | ||
const { modules, resourceAccount, resourceAccountV05 } = this.sdk.networkOptions; | ||
const { version = constants_1.VERSION_0 } = params; | ||
const curve = (0, contracts_1.getCurve)(params.curveType, curves, version); | ||
const resourceAcc = version === constants_1.VERSION_0_5 ? resourceAccountV05 : resourceAccount; | ||
function getPoolLpStr(coinX, coinY, curve) { | ||
@@ -61,5 +71,3 @@ const [sortedX, sortedY] = (0, utils_1.is_sorted)(coinX, coinY) | ||
: [coinY, coinX]; | ||
return (0, utils_1.composeType)( | ||
// | ||
resourceAccount, 'lp_coin', 'LP', [sortedX, sortedY, curve]); | ||
return (0, utils_1.composeType)(resourceAcc, 'lp_coin', 'LP', [sortedX, sortedY, curve]); | ||
} | ||
@@ -70,3 +78,3 @@ const lpString = getPoolLpStr(params.fromToken, params.toToken, curve); | ||
liquidityPoolResource = | ||
yield this.sdk.Resources.fetchAccountResource(resourceAccount, (0, utils_1.composeType)(modules.CoinInfo, [lpString])); | ||
yield this.sdk.Resources.fetchAccountResource(resourceAcc, (0, utils_1.composeType)(modules.CoinInfo, [lpString])); | ||
} | ||
@@ -173,6 +181,9 @@ catch (e) { | ||
const isPoolExisted = yield this.checkPoolExistence(params); | ||
const { modules } = this.sdk.networkOptions; | ||
const { version = constants_1.VERSION_0 } = params; | ||
const { moduleAccountV05, moduleAccount } = this.sdk.networkOptions; | ||
const moduleAcc = version === constants_1.VERSION_0_5 ? moduleAccountV05 : moduleAccount; | ||
const curves = this.sdk.curves; | ||
const functionName = (0, utils_1.composeType)(modules.Scripts, isPoolExisted ? 'add_liquidity' : 'register_pool_and_add_liquidity'); | ||
const curve = curves[params.curveType]; | ||
const scriptsVersion = (0, contracts_1.getScriptsFor)(version); | ||
const functionName = (0, utils_1.composeType)(moduleAcc, scriptsVersion, isPoolExisted ? 'add_liquidity' : 'register_pool_and_add_liquidity'); | ||
const curve = (0, contracts_1.getCurve)(params.curveType, curves, version); | ||
const isSorted = (0, utils_1.is_sorted)(params.fromToken, params.toToken); | ||
@@ -212,5 +223,7 @@ const typeArguments = isSorted | ||
} | ||
const { version = constants_1.VERSION_0 } = params; | ||
const curves = this.sdk.curves; | ||
const curve = curves[params.curveType]; | ||
const { modules } = this.sdk.networkOptions; | ||
const curve = (0, contracts_1.getCurve)(params.curveType, curves, version); | ||
const { moduleAccountV05, moduleAccount } = this.sdk.networkOptions; | ||
const moduleAcc = version === constants_1.VERSION_0_5 ? moduleAccountV05 : moduleAccount; | ||
const output = yield this.calculateOutputBurn(params); | ||
@@ -223,3 +236,4 @@ const xOutput = (_a = output === null || output === void 0 ? void 0 : output.x) !== null && _a !== void 0 ? _a : '0'; | ||
: [params.burnAmount.toString(), yOutput, xOutput]; | ||
const functionName = (0, utils_1.composeType)(modules.Scripts, 'remove_liquidity'); | ||
const scriptsVersion = (0, contracts_1.getScriptsFor)(version); | ||
const functionName = (0, utils_1.composeType)(moduleAcc, scriptsVersion, 'remove_liquidity'); | ||
const typeArguments = isSorted | ||
@@ -226,0 +240,0 @@ ? [params.fromToken, params.toToken, curve] |
{ | ||
"name": "@pontem/liquidswap-sdk", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "SDK to use LiquidSwap functions", | ||
@@ -5,0 +5,0 @@ "author": "Igor Demko <igor@pontem.network>", |
@@ -94,2 +94,3 @@ <a name="readme-top"></a> | ||
interactiveToken: 'from', // which token is 'base' to calculate other token rate. | ||
version: 0 | ||
}) | ||
@@ -109,2 +110,3 @@ console.log(output) // '4304638' (4.304638 USDT) | ||
curveType: 'uncorrelated', | ||
version: 0 | ||
}) | ||
@@ -147,2 +149,3 @@ console.log(txPayload); | ||
curveType: 'uncorrelated', | ||
version: 0 | ||
}) | ||
@@ -162,2 +165,3 @@ console.log(amount) // '23211815' ('0.23211815' APTOS) | ||
curveType: 'uncorrelated', | ||
version: 0 | ||
}) | ||
@@ -199,2 +203,3 @@ console.log(txPayload); | ||
curveType: 'stable', | ||
version: 0 | ||
}) | ||
@@ -214,2 +219,3 @@ console.log(amount) // '175257' ('0.00175257' whWETH) | ||
curveType: 'stable', | ||
version: 0 | ||
}) | ||
@@ -251,2 +257,3 @@ console.log(txPayload); | ||
curveType: 'stable', | ||
version: 0 | ||
}) | ||
@@ -266,2 +273,3 @@ console.log(amount) // '12356861' ('0.12356861' APTOS) | ||
curveType: 'stable', | ||
version: 0 | ||
}) | ||
@@ -299,2 +307,3 @@ console.log(txPayload); | ||
curveType: 'uncorrelated', | ||
version: 0 | ||
}); | ||
@@ -375,2 +384,3 @@ | ||
slippage: 0.005, | ||
version: 0 | ||
}); | ||
@@ -389,2 +399,3 @@ console.log(rate) // '4472498' ('4.472498' USDC) | ||
curveType: 'uncorrelated', | ||
version: 0 | ||
}) | ||
@@ -420,2 +431,3 @@ | ||
burnAmount: 100000, | ||
version: 0 | ||
}); | ||
@@ -449,2 +461,3 @@ | ||
burnAmount: 100000, | ||
version: 0 | ||
}); | ||
@@ -489,2 +502,3 @@ | ||
- [ ] Staking: stake / harvest / unstake | ||
- [ ] Concentrated Liquidity: swap, add, burn | ||
@@ -491,0 +505,0 @@ See the [open issues](https://github.com/pontem-network/liquidswap-sdk/issues) for a full list of proposed features (and known issues). |
@@ -28,2 +28,3 @@ export const MODULES_ACCOUNT = '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12'; | ||
USDC: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC', // layerzero USDC | ||
amAPT: '0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a::amapt_token::AmnisApt' // Amnis APT | ||
}; |
@@ -27,2 +27,4 @@ import Decimal from 'decimal.js'; | ||
import { CreateTXPayloadParams } from './SwapModule'; | ||
import {VERSION_0, VERSION_0_5} from "../constants"; | ||
import {getCurve, getScriptsFor} from "../utils/contracts"; | ||
@@ -35,2 +37,3 @@ interface ICreateBurnLiquidityPayload { | ||
curveType: CurveType; | ||
version?: typeof VERSION_0 | typeof VERSION_0_5; | ||
} | ||
@@ -45,6 +48,7 @@ | ||
slippage: number; | ||
version?: typeof VERSION_0 | typeof VERSION_0_5; | ||
} | ||
interface ICalculateSupplyParams | ||
extends Pick<ICalculateRatesParams, 'slippage'> { | ||
extends Pick<ICalculateRatesParams, 'slippage' | 'version'> { | ||
toAmount: Decimal | number; | ||
@@ -64,2 +68,3 @@ fromAmount: Decimal | number; | ||
curveType: CurveType; | ||
version?: typeof VERSION_0 | typeof VERSION_0_5; | ||
} | ||
@@ -86,6 +91,11 @@ | ||
async checkPoolExistence(params: TGetResourcesPayload): Promise<boolean> { | ||
const { moduleAccount, resourceAccount } = this.sdk.networkOptions; | ||
const { moduleAccount, resourceAccount, moduleAccountV05, resourceAccountV05 } = this.sdk.networkOptions; | ||
const curves = this.sdk.curves; | ||
const { version = VERSION_0 } = params; | ||
const moduleAcc = version === VERSION_0_5 ? moduleAccountV05 : moduleAccount; | ||
const resourceAcc = version === VERSION_0_5 ? resourceAccountV05 : resourceAccount; | ||
const modulesLiquidityPool = composeType( | ||
moduleAccount, | ||
moduleAcc, | ||
'liquidity_pool', | ||
@@ -95,3 +105,4 @@ 'LiquidityPool', | ||
const curve = curves[params.curveType]; | ||
const curve = getCurve(params.curveType, curves, version); | ||
const liquidityPoolType = getPoolStr( | ||
@@ -107,3 +118,3 @@ params.fromToken, | ||
await this.sdk.Resources.fetchAccountResource<AptosResource>( | ||
resourceAccount, | ||
resourceAcc, | ||
liquidityPoolType, | ||
@@ -118,10 +129,15 @@ ); | ||
async getLiquidityPoolResource(params: TGetResourcesPayload) { | ||
const { moduleAccount, resourceAccount } = this.sdk.networkOptions; | ||
const { moduleAccount, resourceAccount, moduleAccountV05, resourceAccountV05 } = this.sdk.networkOptions; | ||
const curves = this.sdk.curves; | ||
const { version = VERSION_0 } = params; | ||
const moduleAcc = version === VERSION_0_5 ? moduleAccountV05 : moduleAccount; | ||
const resourceAcc = version === VERSION_0_5 ? resourceAccountV05 : resourceAccount; | ||
const curve = getCurve(params.curveType, curves, version); | ||
const modulesLiquidityPool = composeType( | ||
moduleAccount, | ||
moduleAcc, | ||
'liquidity_pool', | ||
'LiquidityPool', | ||
); | ||
const curve = curves[params.curveType]; | ||
@@ -140,3 +156,3 @@ const liquidityPoolType = getPoolStr( | ||
await this.sdk.Resources.fetchAccountResource<AptosPoolResource>( | ||
resourceAccount, | ||
resourceAcc, | ||
liquidityPoolType, | ||
@@ -152,5 +168,7 @@ ); | ||
const curves = this.sdk.curves; | ||
const { modules, resourceAccount } = this.sdk.networkOptions; | ||
const { modules, resourceAccount, resourceAccountV05 } = this.sdk.networkOptions; | ||
const { version = VERSION_0 } = params; | ||
const curve = curves[params.curveType]; | ||
const curve = getCurve(params.curveType, curves, version); | ||
const resourceAcc = version === VERSION_0_5 ? resourceAccountV05 : resourceAccount; | ||
@@ -166,4 +184,3 @@ function getPoolLpStr( | ||
return composeType( | ||
// | ||
resourceAccount, | ||
resourceAcc, | ||
'lp_coin', | ||
@@ -182,3 +199,3 @@ 'LP', | ||
await this.sdk.Resources.fetchAccountResource<AptosCoinInfoResource>( | ||
resourceAccount, | ||
resourceAcc, | ||
composeType(modules.CoinInfo, [lpString]), | ||
@@ -322,13 +339,17 @@ ); | ||
const isPoolExisted = await this.checkPoolExistence(params); | ||
const { version = VERSION_0 } = params; | ||
const { modules } = this.sdk.networkOptions; | ||
const { moduleAccountV05, moduleAccount } = this.sdk.networkOptions; | ||
const moduleAcc = version === VERSION_0_5 ? moduleAccountV05 : moduleAccount; | ||
const curves = this.sdk.curves; | ||
const scriptsVersion = getScriptsFor(version); | ||
const functionName = composeType( | ||
modules.Scripts, | ||
moduleAcc, | ||
scriptsVersion, | ||
isPoolExisted ? 'add_liquidity' : 'register_pool_and_add_liquidity', | ||
); | ||
const curve = curves[params.curveType]; | ||
const curve = getCurve(params.curveType, curves, version); | ||
const isSorted = is_sorted(params.fromToken, params.toToken); | ||
@@ -382,6 +403,9 @@ | ||
const { version = VERSION_0 } = params; | ||
const curves = this.sdk.curves; | ||
const curve = curves[params.curveType]; | ||
const curve = getCurve(params.curveType, curves, version); | ||
const { modules } = this.sdk.networkOptions; | ||
const { moduleAccountV05, moduleAccount } = this.sdk.networkOptions; | ||
const moduleAcc = version === VERSION_0_5 ? moduleAccountV05 : moduleAccount; | ||
@@ -399,4 +423,6 @@ const output = await this.calculateOutputBurn(params); | ||
const functionName = composeType(modules.Scripts, 'remove_liquidity'); | ||
const scriptsVersion = getScriptsFor(version); | ||
const functionName = composeType(moduleAcc, scriptsVersion, 'remove_liquidity'); | ||
const typeArguments = isSorted | ||
@@ -403,0 +429,0 @@ ? [params.fromToken, params.toToken, curve] |
@@ -1,2 +0,10 @@ | ||
import { MODULES_ACCOUNT, RESOURCES_ACCOUNT, TOKENS_MAPPING } from '../constants'; | ||
import { | ||
MODULES_ACCOUNT, | ||
MODULES_V05_ACCOUNT, | ||
RESOURCES_ACCOUNT, | ||
RESOURCES_V05_ACCOUNT, | ||
TOKENS_MAPPING, | ||
VERSION_0, | ||
VERSION_0_5, | ||
} from '../constants'; | ||
import SDK from '../main'; | ||
@@ -10,3 +18,5 @@ | ||
resourceAccount: RESOURCES_ACCOUNT, | ||
moduleAccount: MODULES_ACCOUNT | ||
moduleAccount: MODULES_ACCOUNT, | ||
resourceAccountV05: RESOURCES_V05_ACCOUNT, | ||
moduleAccountV05: MODULES_V05_ACCOUNT | ||
} | ||
@@ -17,3 +27,3 @@ }); | ||
test('calculateLiquidityRates (from mode), uncorrelated', async () => { | ||
test('calculateLiquidityRates (from mode), uncorrelated, v0', async () => { | ||
const output = await sdk.Liquidity.calculateRateAndMinReceivedLP({ | ||
@@ -26,2 +36,3 @@ fromToken: TOKENS_MAPPING.APTOS, | ||
slippage: 0.005, | ||
version: VERSION_0 | ||
}); | ||
@@ -37,3 +48,3 @@ | ||
test('calculateLiquidityRates (to mode), uncorrelated', async () => { | ||
test('calculateLiquidityRates (to mode), uncorrelated, v0', async () => { | ||
const output = await sdk.Liquidity.calculateRateAndMinReceivedLP({ | ||
@@ -46,2 +57,3 @@ fromToken: TOKENS_MAPPING.APTOS, | ||
slippage: 0.005, | ||
version: VERSION_0 | ||
}); | ||
@@ -57,3 +69,3 @@ | ||
test('calculateLiquidityRates (from mode), stable', async () => { | ||
test('calculateLiquidityRates (from mode), stable, v0', async () => { | ||
const output = await sdk.Liquidity.calculateRateAndMinReceivedLP({ | ||
@@ -66,2 +78,3 @@ fromToken: TOKENS_MAPPING.USDC, | ||
slippage: 0.005, | ||
version: VERSION_0 | ||
}); | ||
@@ -77,3 +90,3 @@ | ||
test('calculateLiquidityRates (to mode), stable', async () => { | ||
test('calculateLiquidityRates (to mode), stable, v0', async () => { | ||
const output = await sdk.Liquidity.calculateRateAndMinReceivedLP({ | ||
@@ -86,2 +99,3 @@ fromToken: TOKENS_MAPPING.USDC, | ||
slippage: 0.005, | ||
version: VERSION_0 | ||
}); | ||
@@ -97,3 +111,79 @@ | ||
test('createAddLiquidityPayload (uncorrelated from mode)', async () => { | ||
test('calculateLiquidityRates (from mode), uncorrelated, v0.5', async () => { | ||
try { | ||
await sdk.Liquidity.calculateRateAndMinReceivedLP({ | ||
fromToken: TOKENS_MAPPING.APTOS, | ||
toToken: TOKENS_MAPPING.USDC, | ||
amount: 100000000, // 1 APTOS | ||
curveType: 'uncorrelated', | ||
interactiveToken: 'from', | ||
slippage: 0.005, | ||
version: VERSION_0_5 | ||
}); | ||
} catch (e) { | ||
expect(e).toMatchObject( | ||
new Error('LiquidityPool not existed'), | ||
); | ||
} | ||
}); | ||
test('calculateLiquidityRates (to mode), uncorrelated, v0.5', async () => { | ||
try { | ||
await sdk.Liquidity.calculateRateAndMinReceivedLP({ | ||
fromToken: TOKENS_MAPPING.APTOS, | ||
toToken: TOKENS_MAPPING.USDC, | ||
amount: 1000000, // 1 USDC | ||
curveType: 'uncorrelated', | ||
interactiveToken: 'to', | ||
slippage: 0.005, | ||
version: VERSION_0_5 | ||
}); | ||
} catch(e) { | ||
expect(e).toMatchObject( | ||
new Error('LiquidityPool not existed'), | ||
); | ||
} | ||
}); | ||
test('calculateLiquidityRates (from mode), stable, v0.5', async () => { | ||
const output = await sdk.Liquidity.calculateRateAndMinReceivedLP({ | ||
fromToken: TOKENS_MAPPING.USDC, | ||
toToken: TOKENS_MAPPING.USDT, | ||
amount: 2000000, // 2 USDC | ||
curveType: 'stable', | ||
interactiveToken: 'from', | ||
slippage: 0.005, | ||
version: VERSION_0_5 | ||
}); | ||
console.log( | ||
`2000000 USDC → ${output.rate} USDT && receiveLp ${output.receiveLp}`, | ||
); | ||
expect(typeof output).toBe('object'); | ||
expect(output.rate.length).toBeGreaterThan(0); | ||
}); | ||
test('calculateLiquidityRates (to mode), stable, v0.5', async () => { | ||
const output = await sdk.Liquidity.calculateRateAndMinReceivedLP({ | ||
fromToken: TOKENS_MAPPING.USDC, | ||
toToken: TOKENS_MAPPING.USDT, | ||
amount: 2000000, // 2 USDT | ||
curveType: 'stable', | ||
interactiveToken: 'to', | ||
slippage: 0.005, | ||
version: VERSION_0_5 | ||
}); | ||
console.log( | ||
`2000000 USDT → ${output.rate} USDC && receiveLp ${output.receiveLp}`, | ||
); | ||
expect(typeof output).toBe('object'); | ||
expect(output.rate.length).toBeGreaterThan(0); | ||
}); | ||
test('createAddLiquidityPayload (uncorrelated from mode), v0', async () => { | ||
const output = await sdk.Liquidity.createAddLiquidityPayload({ | ||
@@ -107,2 +197,3 @@ fromToken: TOKENS_MAPPING.APTOS, | ||
curveType: 'uncorrelated', | ||
version: VERSION_0 | ||
}); | ||
@@ -123,3 +214,3 @@ | ||
test('createAddLiquidityPayload (uncorrelated to mode)', async () => { | ||
test('createAddLiquidityPayload (uncorrelated to mode), v0', async () => { | ||
const output = await sdk.Liquidity.createAddLiquidityPayload({ | ||
@@ -133,2 +224,3 @@ fromToken: TOKENS_MAPPING.APTOS, | ||
curveType: 'uncorrelated', | ||
version: VERSION_0 | ||
}); | ||
@@ -149,3 +241,3 @@ | ||
test('createAddLiquidityPayload (uncorrelated from mode)', async () => { | ||
test('createAddLiquidityPayload (uncorrelated from mode), v0', async () => { | ||
const output = await sdk.Liquidity.createAddLiquidityPayload({ | ||
@@ -161,2 +253,3 @@ fromToken: | ||
curveType: 'uncorrelated', | ||
version: VERSION_0 | ||
}); | ||
@@ -177,3 +270,3 @@ | ||
test('createBurnLiquidityPayload (uncorrelated)', async () => { | ||
test('createBurnLiquidityPayload (uncorrelated), v0', async () => { | ||
const output = await sdk.Liquidity.createBurnLiquidityPayload({ | ||
@@ -185,2 +278,3 @@ fromToken: TOKENS_MAPPING.APTOS, | ||
burnAmount: 100000, | ||
version: VERSION_0 | ||
}); | ||
@@ -203,3 +297,53 @@ | ||
test('calculateOutputBurn', async () => { | ||
test('createAddLiquidityPayload (stable from mode), v0.5', async () => { | ||
const output = await sdk.Liquidity.createAddLiquidityPayload({ | ||
fromToken: TOKENS_MAPPING.amAPT, | ||
toToken: TOKENS_MAPPING.APTOS, | ||
fromAmount: 100000, // 0.001 amAPT | ||
toAmount: 89158, // 0.00089158 APTOS | ||
interactiveToken: 'from', | ||
slippage: 0.005, | ||
curveType: 'stable', | ||
version: VERSION_0_5 | ||
}); | ||
expect(output).toStrictEqual({ | ||
type: 'entry_function_payload', | ||
function: | ||
'0x163df34fccbf003ce219d3f1d9e70d140b60622cb9dd47599c25fb2f797ba6e::scripts::add_liquidity', | ||
type_arguments: [ | ||
TOKENS_MAPPING.amAPT, | ||
TOKENS_MAPPING.APTOS, | ||
curves.stableV05, | ||
], | ||
arguments: ["100000", "99500", "89158", "88712"] | ||
}); | ||
}); | ||
test('createBurnLiquidityPayload (stable), v0.5', async () => { | ||
const output = await sdk.Liquidity.createBurnLiquidityPayload({ | ||
fromToken: TOKENS_MAPPING.amAPT, | ||
toToken: TOKENS_MAPPING.APTOS, | ||
slippage: 0.005, | ||
curveType: 'stable', | ||
burnAmount: 389490, | ||
version: VERSION_0_5 | ||
}); | ||
console.log('createBurnLiquidityPayload', output); | ||
expect(output).toEqual({ | ||
type: 'entry_function_payload', | ||
function: | ||
'0x163df34fccbf003ce219d3f1d9e70d140b60622cb9dd47599c25fb2f797ba6e::scripts::remove_liquidity', | ||
type_arguments: [ | ||
TOKENS_MAPPING.amAPT, | ||
TOKENS_MAPPING.APTOS, | ||
curves.stableV05, | ||
], | ||
arguments: ['389490', expect.any(String), expect.any(String)], | ||
}); | ||
}); | ||
test('calculateOutputBurn, v0', async () => { | ||
const output = await sdk.Liquidity.calculateOutputBurn({ | ||
@@ -211,2 +355,3 @@ fromToken: TOKENS_MAPPING.APTOS, | ||
burnAmount: 100000, | ||
version: VERSION_0 | ||
}); | ||
@@ -224,3 +369,3 @@ | ||
test('Check Pool Existence ', async () => { | ||
test('Check Pool Existence, v0', async () => { | ||
const output = await sdk.Liquidity.checkPoolExistence({ | ||
@@ -230,2 +375,3 @@ fromToken: TOKENS_MAPPING.APTOS, | ||
curveType: 'uncorrelated', | ||
version: VERSION_0, | ||
}); | ||
@@ -235,3 +381,3 @@ | ||
}); | ||
test('Check Pool Existence ', async () => { | ||
test('Check Pool Existence, v0 ', async () => { | ||
const output = await sdk.Liquidity.checkPoolExistence({ | ||
@@ -243,2 +389,3 @@ fromToken: | ||
curveType: 'uncorrelated', | ||
version: VERSION_0, | ||
}); | ||
@@ -249,3 +396,3 @@ | ||
test('getAmountIn', async () => { | ||
test('getAmountIn, v0', async () => { | ||
const output = await sdk.Liquidity.getAmountIn({ | ||
@@ -257,2 +404,3 @@ fromToken: TOKENS_MAPPING.APTOS, | ||
slippage: 0.005, | ||
version: VERSION_0, | ||
}); | ||
@@ -268,3 +416,3 @@ | ||
test('getAmountOut', async () => { | ||
test('getAmountOut, v0', async () => { | ||
const output = await sdk.Liquidity.getAmountOut({ | ||
@@ -276,2 +424,3 @@ fromToken: TOKENS_MAPPING.APTOS, | ||
slippage: 0.005, | ||
version: VERSION_0, | ||
}); | ||
@@ -278,0 +427,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
248626
3969
533