aptos-txbuilder-js
v1.0.0
Published
**TransactionBuilder()**
Readme
TransactionBuilder()
To use the TransactionBuilder
const txBuilder = new TransactionBuilder(fullnodeUrl, network);- Only supports mainnet as network at the moment.
- fullnodeUrl = your mainnet rpc url
To add a new protocol add your protocol here
export enum Protocols {
PANORA = "Panora",
} To add a new token
export const TOKENS: Record<string, Token> = {
CELLANA: {
name: "CELLANA",
symbol: "CELL",
img: "https://media.aptosfoundation.org/1720457115-project-icon_cellana-finance.png?auto=format&fit=crop&h=344&w=344",
address:
"0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
decimals: 8,
}
}To add a new Stake
export const AVAILABLE_STAKES: Record<Protocols, Stake[]> = {
[Protocols.THALASWAP]: [
{
tokens: [TOKENS.USDC, TOKENS.USDT],
rewardToken: TOKENS.THAPT,
poolAddress:
"0xc3c4cbb3efcd3ec1b6679dc0ed45851486920dba0e86e612e80a79041a6cf1a3", //if available
actions: [
Actions.ADD_LIQUIDITY,
Actions.STAKE,
Actions.UNSTAKE,
Actions.REMOVE_LIQUIDITY,
Actions.CLAIM,
],
}] }
BUILDING STAKE TXS
Args
|name | type| remarks | required|
|---------|---------|---------|---------|
|poolAddress | string| -| omit if tokens is supplied |
|tokens | string[] | array of tokens, if the pool only involves 1 token, [token]| omit if poolAddress is supplied|
|amounts | number[] | array of amounts, if the pool only involves 1 amount, [amount] | yes |
|userAddress | string | user's wallet address | yes |
|protocol | Protocol | name of the protocol - Protocols.Thalaswap | yes |
|estimatedAmounts | number[] | estimated amounts out | only for removeLiquidity |
|lptAmount | number | amount of lp tokens involved | only for removeLiquidity, stake, unstake |
Actions & Functions available, in usual flow order
txbuilder.buildAddLiquidityTransaction({})
txbuilder.buildStakeTransaction({})
txbuilder.buildUnstakeTransaction({})
txbuilder.buildWithdrawTransaction({})
txbuilder.buildClaimTransaction({})
txbuilder.buildWithdrawTransaction({}) // for amnis onlyBUILDING SWAP TXS
Args
|name | type| remarks | required|
|---------|---------|---------|---------|
|fromToken | string| -| yes |
|toToken | string| -| yes |
|userAddress | string | user's wallet address | yes |
|protocol | Protocol | name of the protocol - Protocols.Panora | yes |
|fromAmount | number | amount of fromToken to swap | yes |
txbuilder.buildSwapTransaction({})