diff --git a/classes/LiquidityModule.html b/classes/LiquidityModule.html index ef2f093..937b4c8 100644 --- a/classes/LiquidityModule.html +++ b/classes/LiquidityModule.html @@ -1 +1 @@ -LiquidityModule | @pontem/liquidswap-sdk
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • LiquidityModule

Implements

  • IModule

Index

Constructors

Properties

_sdk: SDK

Accessors

Methods

  • calculateOutputBurn(params: ICalculateBurnLiquidityParams): Promise<undefined | { withoutSlippage: { x: string; y: string }; x: string; y: string }>
  • Parameters

    • params: ICalculateBurnLiquidityParams

    Returns Promise<undefined | { withoutSlippage: { x: string; y: string }; x: string; y: string }>

  • calculateRateAndMinReceivedLP(params: ICalculateRatesParams): Promise<{ rate: string; receiveLp: string }>
  • calculateSupply(params: ICalculateSupplyParams): string
  • checkPoolExistence(params: TGetResourcesPayload): Promise<boolean>
  • createAddLiquidityPayload(params: TCreateLiquidityPoolTXPayloadParams): Promise<TxPayloadCallFunction>
  • createBurnLiquidityPayload(params: ICreateBurnLiquidityPayload): Promise<{ arguments: string[]; function: string; type: string; type_arguments: string[] }>
  • Parameters

    • params: ICreateBurnLiquidityPayload

    Returns Promise<{ arguments: string[]; function: string; type: string; type_arguments: string[] }>

  • getAmountIn(params: Omit<ICalculateRatesParams, "interactiveToken">): Promise<string>
  • getAmountOut(params: Omit<ICalculateRatesParams, "interactiveToken">): Promise<string>
  • getLiquidityPoolResource(params: TGetResourcesPayload): Promise<{ liquidityPoolResource: undefined | AptosResource<AptosPoolResource> }>
  • Parameters

    • params: TGetResourcesPayload

    Returns Promise<{ liquidityPoolResource: undefined | AptosResource<AptosPoolResource> }>

  • getLiquiditySupplyResource(params: TGetResourcesPayload): Promise<{ liquidityPoolResource: undefined | AptosResource<AptosCoinInfoResource> }>
  • Parameters

    • params: TGetResourcesPayload

    Returns Promise<{ liquidityPoolResource: undefined | AptosResource<AptosCoinInfoResource> }>

Generated using TypeDoc

\ No newline at end of file +LiquidityModule | @pontem/liquidswap-sdk
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • LiquidityModule

Implements

  • IModule

Index

Constructors

Properties

_sdk: SDK

Accessors

Methods

  • calculateOutputBurn(params: ICalculateBurnLiquidityParams): Promise<undefined | { withoutSlippage: { x: string; y: string }; x: string; y: string }>
  • Parameters

    • params: ICalculateBurnLiquidityParams

    Returns Promise<undefined | { withoutSlippage: { x: string; y: string }; x: string; y: string }>

  • calculateRateAndMinReceivedLP(params: ICalculateRatesParams): Promise<{ rate: string; receiveLp: string }>
  • calculateSupply(params: ICalculateSupplyParams): string
  • checkPoolExistence(params: TGetResourcesPayload): Promise<boolean>
  • createAddLiquidityPayload(params: TCreateLiquidityPoolTXPayloadParams): Promise<TxPayloadCallFunction>
  • createBurnLiquidityPayload(params: ICreateBurnLiquidityPayload): Promise<{ arguments: string[]; function: string; type: string; type_arguments: string[] }>
  • Parameters

    • params: ICreateBurnLiquidityPayload

    Returns Promise<{ arguments: string[]; function: string; type: string; type_arguments: string[] }>

  • getAmountIn(params: Omit<ICalculateRatesParams, "interactiveToken">): Promise<string>
  • getAmountOut(params: Omit<ICalculateRatesParams, "interactiveToken">): Promise<string>
  • getLiquidityPoolResource(params: TGetResourcesPayload): Promise<{ liquidityPoolResource: undefined | AptosResource<AptosPoolResource> }>
  • Parameters

    • params: TGetResourcesPayload

    Returns Promise<{ liquidityPoolResource: undefined | AptosResource<AptosPoolResource> }>

  • getLiquiditySupplyResource(params: TGetResourcesPayload): Promise<{ liquidityPoolResource: undefined | AptosResource<AptosCoinInfoResource> }>
  • Parameters

    • params: TGetResourcesPayload

    Returns Promise<{ liquidityPoolResource: undefined | AptosResource<AptosCoinInfoResource> }>

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/ResourcesModule.html b/classes/ResourcesModule.html index 42f826c..dcd484b 100644 --- a/classes/ResourcesModule.html +++ b/classes/ResourcesModule.html @@ -1 +1 @@ -ResourcesModule | @pontem/liquidswap-sdk
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ResourcesModule

Implements

  • IModule

Index

Constructors

Properties

Accessors

Methods

Constructors

Properties

_sdk: SDK

Accessors

Methods

  • fetchAccountResource<T>(accountAddress: string, resourceType: string): Promise<undefined | AptosResource<T>>
  • Type parameters

    • T = unknown

    Parameters

    • accountAddress: string
    • resourceType: string

    Returns Promise<undefined | AptosResource<T>>

Generated using TypeDoc

\ No newline at end of file +ResourcesModule | @pontem/liquidswap-sdk
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ResourcesModule

Implements

  • IModule

Index

Constructors

Properties

Accessors

Methods

Constructors

Properties

_sdk: SDK

Accessors

Methods

  • fetchAccountResource<T>(accountAddress: string, resourceType: string): Promise<undefined | AptosResource<T>>
  • Type parameters

    • T = unknown

    Parameters

    • accountAddress: string
    • resourceType: string

    Returns Promise<undefined | AptosResource<T>>

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/SDK.html b/classes/SDK.html index deb1c3f..606d674 100644 --- a/classes/SDK.html +++ b/classes/SDK.html @@ -1 +1 @@ -SDK | @pontem/liquidswap-sdk
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SDK

Index

Constructors

Properties

_client: AptosClient
_curves: ICurves
_liquidity: LiquidityModule
_networkOptions: Required<INetworkOptions>
_resources: ResourcesModule
_swap: SwapModule

Accessors

  • get client(): AptosClient
  • get curves(): ICurves
  • get networkOptions(): Required<INetworkOptions>
  • Returns Required<INetworkOptions>

Generated using TypeDoc

\ No newline at end of file +SDK | @pontem/liquidswap-sdk
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SDK

Index

Constructors

Properties

_client: AptosClient
_curves: ICurves
_liquidity: LiquidityModule
_networkOptions: Required<INetworkOptions>
_resources: ResourcesModule
_swap: SwapModule

Accessors

  • get client(): AptosClient
  • get curves(): ICurves
  • get networkOptions(): Required<INetworkOptions>
  • Returns Required<INetworkOptions>

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/SwapModule.html b/classes/SwapModule.html index 9006fcc..02bad83 100644 --- a/classes/SwapModule.html +++ b/classes/SwapModule.html @@ -1 +1 @@ -SwapModule | @pontem/liquidswap-sdk
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SwapModule

Implements

  • IModule

Index

Constructors

Properties

_sdk: SDK

Accessors

Methods

  • getLiquidityPoolResource(params: GetLiquidityPoolResourceParams): Promise<{ liquidityPoolResource: undefined | AptosResource<AptosPoolResource>; liquidityPoolType: string }>
  • Parameters

    • params: GetLiquidityPoolResourceParams

    Returns Promise<{ liquidityPoolResource: undefined | AptosResource<AptosPoolResource>; liquidityPoolType: string }>

Generated using TypeDoc

\ No newline at end of file +SwapModule | @pontem/liquidswap-sdk
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SwapModule

Implements

  • IModule

Index

Constructors

Properties

_sdk: SDK

Accessors

Methods

  • getLiquidityPoolResource(params: GetLiquidityPoolResourceParams): Promise<{ liquidityPoolResource: undefined | AptosResource<AptosPoolResource>; liquidityPoolType: string }>
  • Parameters

    • params: GetLiquidityPoolResourceParams

    Returns Promise<{ liquidityPoolResource: undefined | AptosResource<AptosPoolResource>; liquidityPoolType: string }>

Generated using TypeDoc

\ No newline at end of file diff --git a/index.html b/index.html index 6c5e2e4..7e59128 100644 --- a/index.html +++ b/index.html @@ -56,35 +56,35 @@

Usage

Swap EXACTLY 1 APTOS to SLIPPAGED layerzero USDT amount -
(async () => {
// Get USDT amount
try {
const output = await sdk.Swap.calculateRates({
fromToken: '0x1::aptos_coin::AptosCoin', // full 'from' token address
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT', // full 'to' token address layerzero USDT
amount: 100000000, // 1 APTOS, or you can use convertValueToDecimal(1, 8)
curveType: 'uncorrelated', // can be 'uncorrelated' or 'stable'
interactiveToken: 'from', // which token is 'base' to calculate other token rate.
})
console.log(output) // '4304638' (4.304638 USDT)

// Generate TX payload for swap 1 APTOS to maximum 4.304638 USDT
// and minimum 4.283115 USDT (with slippage -0.5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT', // layerzero USDT
fromAmount: 100000000, // 1 APTOS, or you can use convertValueToDecimal(1, 8)
toAmount: 4304638, // 4.304638 USDT, or you can use convertValueToDecimal(4.304638, 6)
interactiveToken: 'from',
slippage: 0.005, // 0.5% (1 - 100%, 0 - 0%)
stableSwapType: 'high',
curveType: 'uncorrelated',
})
console.log(txPayload);
} catch(e) {
console.log(e)
}

/**
Output:
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::swap',
type_arguments: [
'0x1::aptos_coin::AptosCoin',
'0xae478ff7d83ed072dbc5e264250e67ef58f57c99d89b447efd8a0a2e8b2be76e::coin::T',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Uncorrelated'
],
arguments: [ '100000000', '4283115' ]
}

*/
})() +
(async () => {
// Get USDT amount
try {
const output = await sdk.Swap.calculateRates({
fromToken: '0x1::aptos_coin::AptosCoin', // full 'from' token address
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT', // full 'to' token address layerzero USDT
amount: 100000000, // 1 APTOS, or you can use convertValueToDecimal(1, 8)
curveType: 'uncorrelated', // can be 'uncorrelated' or 'stable'
interactiveToken: 'from', // which token is 'base' to calculate other token rate.
version: 0
})
console.log(output) // '4304638' (4.304638 USDT)

// Generate TX payload for swap 1 APTOS to maximum 4.304638 USDT
// and minimum 4.283115 USDT (with slippage -0.5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT', // layerzero USDT
fromAmount: 100000000, // 1 APTOS, or you can use convertValueToDecimal(1, 8)
toAmount: 4304638, // 4.304638 USDT, or you can use convertValueToDecimal(4.304638, 6)
interactiveToken: 'from',
slippage: 0.005, // 0.5% (1 - 100%, 0 - 0%)
stableSwapType: 'high',
curveType: 'uncorrelated',
version: 0
})
console.log(txPayload);
} catch(e) {
console.log(e)
}

/**
Output:
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::swap',
type_arguments: [
'0x1::aptos_coin::AptosCoin',
'0xae478ff7d83ed072dbc5e264250e67ef58f57c99d89b447efd8a0a2e8b2be76e::coin::T',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Uncorrelated'
],
arguments: [ '100000000', '4283115' ]
}

*/
})()
Get EXACTLY 1 USDT and send SLIPPAGED APTOS amount -
(async () => {
// Get APTOS amount
try {
const amount = await sdk.Swap.calculateRates({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT',
amount: 1000000, // 1 layerzero USDT
interactiveToken: 'to',
curveType: 'uncorrelated',
})
console.log(amount) // '23211815' ('0.23211815' APTOS)

// Generate TX payload for get EXACTLY 1 USDT
// and minimum send 0.23327874 (with slippage +0.5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT',
fromAmount: convertValueToDecimal(0.23211815, 8), // 0.23211815 APTOS,
toAmount: convertValueToDecimal(1, 6), // 1 layerzero USDT,
interactiveToken: 'to',
slippage: 0.005, // 0.5% (1 - 100%, 0 - 0%)
stableSwapType: 'hign',
curveType: 'uncorrelated',
})
console.log(txPayload);
} catch (e) {
console.log(e);
}

/**
Output:
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::swap_into',
type_arguments: [
'0x1::aptos_coin::AptosCoin',
'0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Uncorrelated'
],
arguments: [ '23327874', '1000000' ]
}
*/
})() +
(async () => {
// Get APTOS amount
try {
const amount = await sdk.Swap.calculateRates({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT',
amount: 1000000, // 1 layerzero USDT
interactiveToken: 'to',
curveType: 'uncorrelated',
version: 0
})
console.log(amount) // '23211815' ('0.23211815' APTOS)

// Generate TX payload for get EXACTLY 1 USDT
// and minimum send 0.23327874 (with slippage +0.5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT',
fromAmount: convertValueToDecimal(0.23211815, 8), // 0.23211815 APTOS,
toAmount: convertValueToDecimal(1, 6), // 1 layerzero USDT,
interactiveToken: 'to',
slippage: 0.005, // 0.5% (1 - 100%, 0 - 0%)
stableSwapType: 'hign',
curveType: 'uncorrelated',
version: 0
})
console.log(txPayload);
} catch (e) {
console.log(e);
}

/**
Output:
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::swap_into',
type_arguments: [
'0x1::aptos_coin::AptosCoin',
'0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Uncorrelated'
],
arguments: [ '23327874', '1000000' ]
}
*/
})()
Swap EXACTLY 1 APTOS to wormhole WETH with curve - 'stable', stableSwapType - 'normal' and 0.5% slippage -
(async () => {
// Get WETH amount
try {
const amount = await sdk.Swap.calculateRates({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xcc8a89c8dce9693d354449f1f73e60e14e347417854f029db5bc8e7454008abb::coin::T', // wormhole WETH (whWETH)
amount: 100000000, // 1 APTOS
interactiveToken: 'from',
curveType: 'stable',
})
console.log(amount) // '175257' ('0.00175257' whWETH)

// Generate TX payload to swap 1 APTOS to
// and minimum send 0.00174381 (with slippage -0.5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT',
fromAmount: convertValueToDecimal(1, 8), // 1 Aptos
toAmount: convertValueToDecimal(0.00175257, 8), // 0.00175257 whWETH,
interactiveToken: 'from',
slippage: 0.005, // 0.5% (1 - 100%, 0 - 0%)
stableSwapType: 'normal',
curveType: 'stable',
})
console.log(txPayload);
} catch (e) {
console.log(e);
}

/**
Output:
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::swap_unchecked',
type_arguments: [
'0x1::aptos_coin::AptosCoin',
'0xcc8a89c8dce9693d354449f1f73e60e14e347417854f029db5bc8e7454008abb::coin::T',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Stable'
],
arguments: [ '100000000', '174381' ]
}
*/
})() +
(async () => {
// Get WETH amount
try {
const amount = await sdk.Swap.calculateRates({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xcc8a89c8dce9693d354449f1f73e60e14e347417854f029db5bc8e7454008abb::coin::T', // wormhole WETH (whWETH)
amount: 100000000, // 1 APTOS
interactiveToken: 'from',
curveType: 'stable',
version: 0
})
console.log(amount) // '175257' ('0.00175257' whWETH)

// Generate TX payload to swap 1 APTOS to
// and minimum send 0.00174381 (with slippage -0.5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT',
fromAmount: convertValueToDecimal(1, 8), // 1 Aptos
toAmount: convertValueToDecimal(0.00175257, 8), // 0.00175257 whWETH,
interactiveToken: 'from',
slippage: 0.005, // 0.5% (1 - 100%, 0 - 0%)
stableSwapType: 'normal',
curveType: 'stable',
version: 0
})
console.log(txPayload);
} catch (e) {
console.log(e);
}

/**
Output:
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::swap_unchecked',
type_arguments: [
'0x1::aptos_coin::AptosCoin',
'0xcc8a89c8dce9693d354449f1f73e60e14e347417854f029db5bc8e7454008abb::coin::T',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Stable'
],
arguments: [ '100000000', '174381' ]
}
*/
})()
Get EXACTLY 1 USDA and send SLIPPAGED APTOS amount with curve - 'stable', stableSwapType - 'high' and 0.5% slippage -
(async () => {
// Get APTOS amount
try {
const amount = await sdk.Swap.calculateRates({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0x1000000fa32d122c18a6a31c009ce5e71674f22d06a581bb0a15575e6addadcc::usda::USDA', // USDA
amount: 1000000, // 1 USDA
interactiveToken: 'to',
curveType: 'stable',
})
console.log(amount) // '12356861' ('0.12356861' APTOS)

// Generate TX payload to swap 1 APTOS to
// and minimum send 0.12418645 (with slippage +0.5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0x1000000fa32d122c18a6a31c009ce5e71674f22d06a581bb0a15575e6addadcc::usda::USDA',
fromAmount: convertValueToDecimal(0.12356861, 8), // 0.12356861 APTOS
toAmount: convertValueToDecimal(1, 6), // 1 USDA,
interactiveToken: 'to',
slippage: 0.005, // 0.5% (1 - 100%, 0 - 0%)
stableSwapType: 'high',
curveType: 'stable',
})
console.log(txPayload);
} catch (e) {
console.log(e);
}

/**
Output:
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::swap_into',
type_arguments: [
'0x1::aptos_coin::AptosCoin',
'0x1000000fa32d122c18a6a31c009ce5e71674f22d06a581bb0a15575e6addadcc::usda::USDA',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Stable'
],
arguments: [ '12418645', '1000000' ]
}
*/
})() +
(async () => {
// Get APTOS amount
try {
const amount = await sdk.Swap.calculateRates({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0x1000000fa32d122c18a6a31c009ce5e71674f22d06a581bb0a15575e6addadcc::usda::USDA', // USDA
amount: 1000000, // 1 USDA
interactiveToken: 'to',
curveType: 'stable',
version: 0
})
console.log(amount) // '12356861' ('0.12356861' APTOS)

// Generate TX payload to swap 1 APTOS to
// and minimum send 0.12418645 (with slippage +0.5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::aptos_coin::AptosCoin',
toToken: '0x1000000fa32d122c18a6a31c009ce5e71674f22d06a581bb0a15575e6addadcc::usda::USDA',
fromAmount: convertValueToDecimal(0.12356861, 8), // 0.12356861 APTOS
toAmount: convertValueToDecimal(1, 6), // 1 USDA,
interactiveToken: 'to',
slippage: 0.005, // 0.5% (1 - 100%, 0 - 0%)
stableSwapType: 'high',
curveType: 'stable',
version: 0
})
console.log(txPayload);
} catch (e) {
console.log(e);
}

/**
Output:
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::swap_into',
type_arguments: [
'0x1::aptos_coin::AptosCoin',
'0x1000000fa32d122c18a6a31c009ce5e71674f22d06a581bb0a15575e6addadcc::usda::USDA',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Stable'
],
arguments: [ '12418645', '1000000' ]
}
*/
})()
Check Pool Existence -
(async() => {
const output = await sdk.Liquidity.checkPoolExistence({
fromToken: "0x1::aptos_coin::AptosCoin",
toToken: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
curveType: 'uncorrelated',
});

console.log(output); // true
}) +
(async() => {
const output = await sdk.Liquidity.checkPoolExistence({
fromToken: "0x1::aptos_coin::AptosCoin",
toToken: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
curveType: 'uncorrelated',
version: 0
});

console.log(output); // true
})
@@ -98,21 +98,21 @@

Usage

Creating Liquidity Pool for pair APTOS / lzUSDC -
(async () => {
//get USDC amount
const { rate, receiveLp } = await sdk.Liquidity.calculateRateAndMinReceivedLP({
fromToken: TokensMapping.APTOS,
toToken: TokensMapping.USDC,
amount: 100000000, // 1 APTOS
curveType: 'uncorrelated',
interactiveToken: 'from',
slippage: 0.005,
});
console.log(rate) // '4472498' ('4.472498' USDC)
console.log(receiveLp) // '19703137' ('19.703137' Minimum Received LP)

const payload = await sdk.Liquidity.createAddLiquidityPayload({
fromToken: TokensMapping.APTOS,
toToken: TokensMapping.USDC,
fromAmount: 100000000, // 1 APTOS
toAmount: 4472498, // '4.472498' USDC)
interactiveToken: 'from',
slippage: 0.005,
stableSwapType: 'normal',
curveType: 'uncorrelated',
})

console.log(payload);
/**
* {
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::add_liquidity',
type_arguments: [
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
"0x1::aptos_coin::AptosCoin",
"0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Uncorrelated",
],
arguments: ['100000000', '99500000', '4472498', '4450136'],
}
* */
}) +
(async () => {
//get USDC amount
const { rate, receiveLp } = await sdk.Liquidity.calculateRateAndMinReceivedLP({
fromToken: TokensMapping.APTOS,
toToken: TokensMapping.USDC,
amount: 100000000, // 1 APTOS
curveType: 'uncorrelated',
interactiveToken: 'from',
slippage: 0.005,
version: 0
});
console.log(rate) // '4472498' ('4.472498' USDC)
console.log(receiveLp) // '19703137' ('19.703137' Minimum Received LP)

const payload = await sdk.Liquidity.createAddLiquidityPayload({
fromToken: TokensMapping.APTOS,
toToken: TokensMapping.USDC,
fromAmount: 100000000, // 1 APTOS
toAmount: 4472498, // '4.472498' USDC)
interactiveToken: 'from',
slippage: 0.005,
stableSwapType: 'normal',
curveType: 'uncorrelated',
version: 0
})

console.log(payload);
/**
* {
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::add_liquidity',
type_arguments: [
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
"0x1::aptos_coin::AptosCoin",
"0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Uncorrelated",
],
arguments: ['100000000', '99500000', '4472498', '4450136'],
}
* */
})
Calculate Output Burn for x and y coin with slippage and without slippage -
(async()=> {
const output = await sdk.Liquidity.calculateOutputBurn({
fromToken: "0x1::aptos_coin::AptosCoin",
toToken: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
slippage: 0.005,
curveType: 'uncorrelated',
burnAmount: 100000,
});

console.log(output);
/**
* {
* x: '504061',
y: '22430',
withoutSlippage: {
x: '506594',
y: '22543'
}
}
* */
}) +
(async()=> {
const output = await sdk.Liquidity.calculateOutputBurn({
fromToken: "0x1::aptos_coin::AptosCoin",
toToken: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
slippage: 0.005,
curveType: 'uncorrelated',
burnAmount: 100000,
version: 0
});

console.log(output);
/**
* {
* x: '504061',
y: '22430',
withoutSlippage: {
x: '506594',
y: '22543'
}
}
* */
})
Create Burn Liquidity payload -
(async() => {
const output = await sdk.Liquidity.createBurnLiquidityPayload({
fromToken: "0x1::aptos_coin::AptosCoin",
toToken: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
slippage: 0.005,
curveType: 'uncorrelated',
burnAmount: 100000,
});

console.log(output);

/**
*
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::remove_liquidity',
type_arguments: [
'0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC',
'0x1::aptos_coin::AptosCoin',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Uncorrelated'
],
arguments: [ '100000', '22411', '504489' ]
}
* */
}) +
(async() => {
const output = await sdk.Liquidity.createBurnLiquidityPayload({
fromToken: "0x1::aptos_coin::AptosCoin",
toToken: "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
slippage: 0.005,
curveType: 'uncorrelated',
burnAmount: 100000,
version: 0
});

console.log(output);

/**
*
{
type: 'entry_function_payload',
function: '0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::scripts_v2::remove_liquidity',
type_arguments: [
'0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC',
'0x1::aptos_coin::AptosCoin',
'0x190d44266241744264b964a37b8f09863167a12d3e70cda39376cfb4e3561e12::curves::Uncorrelated'
],
arguments: [ '100000', '22411', '504489' ]
}
* */
})
@@ -137,6 +137,7 @@

Roadmap

  • Pools: check pool / create pool
  • Examples with Aptos SDK
  • Staking: stake / harvest / unstake
  • +
  • Concentrated Liquidity: swap, add, burn
  • See the open issues for a full list of proposed features (and known issues).

    (back to top)

    diff --git a/interfaces/SdkOptions.html b/interfaces/SdkOptions.html index 9835c9f..69d638d 100644 --- a/interfaces/SdkOptions.html +++ b/interfaces/SdkOptions.html @@ -1 +1 @@ -SdkOptions | @pontem/liquidswap-sdk
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Hierarchy

    • SdkOptions

    Index

    Properties

    networkOptions?: INetworkOptions
    nodeUrl: string

    Legend

    • Constructor
    • Method
    • Property
    • Protected property

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +SdkOptions | @pontem/liquidswap-sdk
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Hierarchy

    • SdkOptions

    Index

    Properties

    networkOptions?: INetworkOptions
    nodeUrl: string

    Legend

    • Constructor
    • Method
    • Property
    • Protected property

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file diff --git a/modules.html b/modules.html index 4e996c0..75307cb 100644 --- a/modules.html +++ b/modules.html @@ -1,4 +1,4 @@ -@pontem/liquidswap-sdk
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    @pontem/liquidswap-sdk

    Index

    References

    Renames and re-exports SDK

    Type aliases

    CalculateRatesParams: { amount: Decimal | number; curveType: CurveType; fromToken: AptosResourceType; interactiveToken: "from" | "to"; toToken: AptosResourceType; version?: typeof VERSION_0 | typeof VERSION_0_5 }

    Type declaration

    • amount: Decimal | number
    • curveType: CurveType
    • fromToken: AptosResourceType
    • interactiveToken: "from" | "to"
    • toToken: AptosResourceType
    • Optional version?: typeof VERSION_0 | typeof VERSION_0_5
    CreateTXPayloadParams: { curveType: CurveType; fromAmount: Decimal | number; fromToken: AptosResourceType; interactiveToken: "from" | "to"; slippage: number; stableSwapType: "high" | "normal"; toAmount: Decimal | number; toToken: AptosResourceType; version?: typeof VERSION_0 | typeof VERSION_0_5 }

    Type declaration

    • curveType: CurveType
    • fromAmount: Decimal | number
    • fromToken: AptosResourceType
    • interactiveToken: "from" | "to"
    • slippage: number
    • stableSwapType: "high" | "normal"
    • toAmount: Decimal | number
    • toToken: AptosResourceType
    • Optional version?: typeof VERSION_0 | typeof VERSION_0_5

    Functions

    • convertDecimalToFixedString(value: Decimal, decimals: number): string
    • convertValueToDecimal(value: string | number, decimals?: undefined | number): Decimal
    • Parameters

      • value: string | number
      • decimals: undefined | number = 0

      Returns Decimal

    • getCoinInWithFees(coinOutVal: Decimal, reserveOutSize: Decimal, reserveInSize: Decimal, fee: Decimal): Decimal
    • +@pontem/liquidswap-sdk
      Options
      All
      • Public
      • Public/Protected
      • All
      Menu

      @pontem/liquidswap-sdk

      Index

      References

      Renames and re-exports SDK

      Type aliases

      CalculateRatesParams: { amount: Decimal | number; curveType: CurveType; fromToken: AptosResourceType; interactiveToken: "from" | "to"; toToken: AptosResourceType; version?: typeof VERSION_0 | typeof VERSION_0_5 }

      Type declaration

      • amount: Decimal | number
      • curveType: CurveType
      • fromToken: AptosResourceType
      • interactiveToken: "from" | "to"
      • toToken: AptosResourceType
      • Optional version?: typeof VERSION_0 | typeof VERSION_0_5
      CreateTXPayloadParams: { curveType: CurveType; fromAmount: Decimal | number; fromToken: AptosResourceType; interactiveToken: "from" | "to"; slippage: number; stableSwapType: "high" | "normal"; toAmount: Decimal | number; toToken: AptosResourceType; version?: typeof VERSION_0 | typeof VERSION_0_5 }

      Type declaration

      • curveType: CurveType
      • fromAmount: Decimal | number
      • fromToken: AptosResourceType
      • interactiveToken: "from" | "to"
      • slippage: number
      • stableSwapType: "high" | "normal"
      • toAmount: Decimal | number
      • toToken: AptosResourceType
      • Optional version?: typeof VERSION_0 | typeof VERSION_0_5

      Functions

      • convertDecimalToFixedString(value: Decimal, decimals: number): string
      • convertValueToDecimal(value: string | number, decimals?: undefined | number): Decimal
      • Parameters

        • value: string | number
        • decimals: undefined | number = 0

        Returns Decimal

      • getCoinInWithFees(coinOutVal: Decimal, reserveOutSize: Decimal, reserveInSize: Decimal, fee: Decimal): Decimal
      • Calculates rate with uncorrelated curve for 'from' input based on 'to' input

        Parameters

        • coinOutVal: Decimal

          amount of second('to') token

          @@ -8,7 +8,7 @@

          amount of reserves for first('from') token

        • fee: Decimal

          amount of fee

          -

        Returns Decimal

      • getCoinOutWithFees(coinInVal: Decimal, reserveInSize: Decimal, reserveOutSize: Decimal, fee: Decimal): Decimal

      Returns Decimal

    • getCoinOutWithFees(coinInVal: Decimal, reserveInSize: Decimal, reserveOutSize: Decimal, fee: Decimal): Decimal
    • Calculates rate with uncorrelated curve for 'to' input based on 'from' input

      Parameters

      • coinInVal: Decimal

        amount of first('from') token

        @@ -18,7 +18,7 @@

        amount of reserves for second('to') token

      • fee: Decimal

        amount of fee

        -

      Returns Decimal

    • getCoinsInWithFeesStable(coinOut: Decimal, reserveOut: Decimal, reserveIn: Decimal, scaleOut: Decimal, scaleIn: Decimal, fee: Decimal): Decimal

    Returns Decimal

    • getCoinsInWithFeesStable(coinOut: Decimal, reserveOut: Decimal, reserveIn: Decimal, scaleOut: Decimal, scaleIn: Decimal, fee: Decimal): Decimal
    • Calculates rate with stable curve for 'from' input based on 'to' input

      Parameters

      • coinOut: Decimal

        amount of second('to') token

        @@ -32,7 +32,7 @@

        precision for the ('from')token in decimal places

      • fee: Decimal

        amount of fee

        -

      Returns Decimal

    • getCoinsOutWithFeesStable(coinIn: Decimal, reserveIn: Decimal, reserveOut: Decimal, scaleIn: Decimal, scaleOut: Decimal, fee: Decimal): Decimal

    Returns Decimal

    • getCoinsOutWithFeesStable(coinIn: Decimal, reserveIn: Decimal, reserveOut: Decimal, scaleIn: Decimal, scaleOut: Decimal, fee: Decimal): Decimal
    • Calculates rate with stable curve for 'from' input based on 'to' input

      Parameters

      • coinIn: Decimal

        amount of first('from') token