Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
liquidswap-sdk
Advanced tools
The typescript SDK for Liquidswap.
import { SDK } from '@pontem/liquidswap-sdk';
const sdk = new SDK({
nodeUrl: 'https://fullnode.devnet.aptoslabs.com', // Node URL
networkOptions: {
nativeToken: '0x1::test_coin::TestCoin', // Type of Native network token
modules: {
Scripts:
'0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::scripts', // This module is used for Swap
CoinInfo: '0x1::coin::CoinInfo', // Type of base CoinInfo module
CoinStore: '0x1::coin::CoinStore', // Type of base CoinStore module
},
}
})
(async () => {
// Get BTC amount
const amount = await sdk.Swap.calculateRates({
fromToken: '0x1::test_coin::TestCoin',
toToken: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC',
amount: 1000000, // 1 APTOS
interactiveToken: 'from',
pool: {
address: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
moduleAddress: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
lpToken: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::lp::LP<0x1::test_coin::TestCoin, 0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC>'
}
})
console.log(amount) // 1584723 (0.01584723 BTC)
// Generate TX payload for swap 1 APTOS to maximum 0.01584723 BTC
// and minimum 0.01584723 BTC - 5% (with slippage 5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::test_coin::TestCoin',
toToken: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC',
fromAmount: 1000000, // 1 APTOS,
toAmount: 1584723, // 0.01584723 BTC,
interactiveToken: 'from',
slippage: 0.05, // 5% (1 - 100%, 0 - 0%)
pool: {
address: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
moduleAddress: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
lpToken: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::lp::LP<0x1::test_coin::TestCoin, 0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC>'
}
})
console.log(txPayload);
/**
Output:
{
type: 'script_function_payload',
function: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::scripts::swap',
typeArguments: [
'0x1::test_coin::TestCoin',
'0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC',
'0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::lp::LP<0x1::test_coin::TestCoin, 0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC>'
],
arguments: [
'0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
'1000000',
'1505487'
]
}
*/
})()
(async () => {
// Get APTOS amount
const amount = await sdk.Swap.calculateRates({
fromToken: '0x1::test_coin::TestCoin',
toToken: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC',
amount: 100000, // 0.001 BTC
interactiveToken: 'to', // from - calculate TO amount, to - calculate FROM amount
pool: {
address: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
moduleAddress: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
lpToken: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::lp::LP<0x1::test_coin::TestCoin, 0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC>'
}
})
console.log(amount) // 116831 (0.116831 APTOS)
// Generate TX payload for get EXACTLY 0.001 BTC
// and minimum send 0.116831 + 5% (with slippage 5%)
const txPayload = sdk.Swap.createSwapTransactionPayload({
fromToken: '0x1::test_coin::TestCoin',
toToken: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC',
fromAmount: 116831, // 0.116831 APTOS,
toAmount: 100000, // 0.001 BTC,
interactiveToken: 'to',
slippage: 0.05, // 5% (1 - 100%, 0 - 0%)
pool: {
address: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
moduleAddress: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
lpToken: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::lp::LP<0x1::test_coin::TestCoin, 0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC>'
}
})
console.log(txPayload);
/**
Output:
{
type: 'script_function_payload',
function: '0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::scripts::swap_into',
typeArguments: [
'0x1::test_coin::TestCoin',
'0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC',
'0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::lp::LP<0x1::test_coin::TestCoin, 0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9::coins::BTC>'
],
arguments: [
'0x43417434fd869edee76cca2a4d2301e528a1551b1d719b75c350c3c97d15b8b9',
'110989',
'100000'
]
}
*/
})()
FAQs
SDK for use any functions of LiquidSwap
The npm package liquidswap-sdk receives a total of 0 weekly downloads. As such, liquidswap-sdk popularity was classified as not popular.
We found that liquidswap-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.