- Table of contents
- TRAVA STATION SDK
- TRAVA SIMULATION ROUTE
- Approve token
import {actions} from "trava-station-sdk"
Với các actions:
const pull_token_action = new actions.basic.PullTokenAction(
token: String,
from: String,
amount: uint256
)
const send_token_action = new actions.basic.SendTokenAction(
token: String,
to: String,
amount: uint256
)
const pull_token_action = new actions.basic.PullTokenAction()
const wrap_token_action = new actions.basic.WrapBnbAction(
amount: uint256
)
const unwrap_token_action = new actions.basic.UnwrapBnbAction(
amount: uin256,
to: String
)
const swapUtil = new SwapUtil(web3);
const info = new await swapUtil.getInformationFromInput(tokenAddr1, tokenAddr2, slipparage, amount);
const minimumReceive = info.minimumReceive
const priceImpact = info.priceImpact;
const path = info.path;
const swap_token_action = new actions.pancakeswap.PancakeSwapV2(
amountIn: uint256,
amountOutMin: 0,
path: path,
to: _to address,
deadline: timestamp + 30 * 60 * 1000
from: _from address
)
const trava_supply_action = new actions.trava.TravaSupply(
market: address of lending pool,
token: address of token selected,
amount: uint256,
to: _from address,
onBehalfOf: address of proxy,
enableAsColl: true
)
const trava_borrow_action = new actions.trava.TravaBorrow(
market,
token,
amount,
to: _to_ address,
onBehalfOf: proxy
)
const trava_repay_action = new actions.trava.TravaRepay(
market,
token,
amount,
from,
onBehalfOf: proxy
)
const trava_withdraw_action = new actions.trava.TravaWithdraw(
market,
token,
amount,
to
)
asset = await getListTDTokenRewardsAddress(appState);
amount = MAX_UINT256;
const trava_withdraw_action = new actions.trava.TravaClaimRewards(
asset,
amount,
to,
contractAddress
)
amount = MAX_UINT256;
const trava_withdraw_action = new actions.trava.TravaConvertRewards(
from,
amount,
to,
contractAddress
)
const trava_staking_stake_action = new actions.trava.TravaStakingStake(
stakingPoolAddress,
smartWalletAddress,
amount,
contractAddress
)
const trava_staking_redeem_action = new actions.trava.TravaStakingRedeem(
stakingPoolAddress,
to,
amount,
contractAddress
)
const trava_staking_claim_action = new actions.trava.TravaStakingClaimRewards(
stakingPoolAddress,
to,
MAX_UINT256,
contractAddress
)
const trava_nft_ve_trava_buy = new actions.trava.TravaNFTVeTravaBuy(
tokenId,
price,
option,
from,
to,
contractAddress
)
const trava_nft_ve_trava_create_sale = new actions.trava.TravaNFTVeTravaCreateSale(
tokenId,
price,
option,
from,
contractAddress
)
const trava_nft_ve_trava_cancel_sale = new actions.trava.TravaNFTVeTravaCancelSale(
tokenId,
to,
contractAddress
)
const trava_nft_buy_action = new actions.trava.TravaNFTBuy(
tokenId,
price,
from,
to
)
const trava_nft_create_sale_action = new actions.trava.TravaNFTCreateSale(
tokenId,
to
)
const trava_nft_cancel_sale_action = new actions.trava.TravaNFTCancelSale(
tokenId,
to
)
const trava_nft_auction_create_action = new actions.trava.TravaNFTAuctionCreateAuction(
tokenId,
startingBid,
duration (s),
ceilingPrice,
method
)
const trava_nft_auction_cancel_action = new actions.trava.TravaNFTAuctionCancelAuction(
tokenId,
to
)
const trava_nft_auction_make_bid = new actions.trava.TravaNFTAuctionMakeBid(
tokenId,
bidPrice,
from
)
const trava_nft_auction_eidt_action_price = new actions.trava.TravaNFTAuctionEditAuctionPrice(
tokenId,
startingBid
)
const trava_nft_auction_finalize_action = new actions.trava.TravaNFTAuctionFinalizeAuction(
tokenId,
to
)
const trava_nft_heuristic_farming_stake = new actions.trava.TravaNFTHeuristicFarmingStake(
heuristic farming address,
array<collection_id>,
level,
fromAddress,
contractAddress
)
const trava_nft_heuristic_farming_withdraw = new actions.trava.TravaNFTheuristicFarmingWithdraw(
heuristic farming address,
array<collection_id>,
level,
to address
)
const trava_nft_heuristic_farming_claimRewards = new actions.trava.TravaNFTHeuristicFarmingClaimReward(
heuristic farming address,
array<collection_id>,
level,
contractAddress
)
const trava_nft_expedition_abandon = new actions.trava.TravaNFTExpeditionAbandon(
expedition address,
tokenId,
toAddress,
contractAddress
)
const trava_nft_heuristic_farming_polish = new actions.trava.TravaNFTheuristicFarmingPolish(
heuristic farming address,
array<collection_id>,
level
)
const trava_nft_expedition_deploy = new actions.trava.TravaNFTExpeditionDeploy(
expedition address,
tokenId,
array<buffWinRateTickets>,
array<buffExpTickets>,
fromKnightAddress,
fromTokenAddress,
contractAddress
)
const trava_nft_expedtion_withdraw = new actions.trava.TravaNFTExpeditionWithdraw(
expedition address,
tokenId,
toKnight,
toToken,
contractAddress
)
const trava_nft_transfer_armoury_action = new actions.trava.TravaNFTTransfer(
from,
to,
tokenId,
nftCore: address of TravaNFTCore
)
const trava_nft_transfer_Collection_action = new actions.trava.TravaNFTTransfer(
from,
to,
tokenId,
nftCore: address of TravaNFT Collection
)
const swapUtil = new SwapUtil(web3); const info = new await swapUtil.getInformationFromInput(tokenAddr1, tokenAddr2, slipparage, amount); const minimumReceive = info.minimumReceive const priceImpact = info.priceImpact; const path = info.path;
const trava_liquidity_campaign_buy_token = new actions.trava.LiquidityCampaignBuyToken(
buy_token_with_reference address,
amountIn,
amountOutIn,
path,
to,
deadline,
referred,
from,
liquidity campaign buy token address
)
const swapUtil = new SwapUtil(web3); const info = new await swapUtil.getInformationFromInput(tokenAddr1, tokenAddr2, slipparage, amount); const minimumReceive = info.minimumReceive const priceImpact = info.priceImpact; const path = info.path;
const trava_liquidity_campaign_buy_token_gateway = new actions.trava.LiquidityCampaignBuyTokenGateway(
buy_token_with_reference address,
amountIn,
amountOutIn,
path,
to,
deadline,
referred,
from,
liquidity campaign buy token gateway action address
)
const trava_liquidity_campaign_stake = new actions.trava.LiquidityCampaignStake(
vault address,
address smart wallet,
amount,
from address,
liquidity campaign stake action address
)
const trava_liquidity_campaign_claim_rewards = new actions.trava.LiquidityCampaignClaimRewards(
vault address,
to address,
amount,
liquidity campaign claim rewards action address
)
const trava_liquidity_campaign_redeem = new actions.trava.LiquidityCampaignRedeem(
vault address,
to address,
amount,
liquidity campaign redeem action address
)
const granary_supply_action = new actions.granary.GranarySupply(
market: address of lending pool,
token: address of token selected,
amount: uint256,
from: _from address,
onBehalfOf: address of proxy,
enableAsColl: false,
action granary supply address
)
const granary_withdraw_action = new actions.granary.GranaryWithdraw(
market: address of lending pool,
token: address of token selected,
amount: uint256,
to: _from address,
action granary withdraw address
)
const granary_borrow_action = new actions.granary.GranaryBorrow(
market: address of lending pool,
token: address of token selected,
amount: uint256,
rateMode = 2,
to: _from address,
onBehalfOf: address of proxy,
action granary borrow address
)
const granary_repay_action = new actions.granary.GranaryRepay(
market: address of lending pool,
token: address of token selected,
amount: uint256,
rateMode = 2,
from: _from address,
onBehalfOf: address of proxy,
action granary repay address
)
const radiant_supply_action = new actions.radiant.RadiantSupply(
market: address of lending pool,
token: address of token selected,
amount: uint256,
from: _from address,
onBehalfOf: address of proxy,
enableAsColl: false,
action radiant supply address
)
const radiant_withdraw_action = new actions.radiant.RadiantWithdraw(
market: address of lending pool,
token: address of token selected,
amount: uint256,
to: _from address,
action radiant withdraw address
)
const radiant_borrow_action = new actions.radiant.RadiantBorrow(
market: address of lending pool,
token: address of token selected,
amount: uint256,
rateMode = 2,
to: _from address,
onBehalfOf: address of proxy,
action radiant borrow address
)
const radiant_repay_action = new actions.radiant.RadiantRepay(
market: address of lending pool,
token: address of token selected,
amount: uint256,
rateMode = 2,
from: _from address,
onBehalfOf: address of proxy,
action radiant repay address
)
const venus_collateral_action = new actions.venus.VenusSupply(
list cTokenAddress,
list EnableAsCol,
action venus collateral address
)
const venus_supply_action = new actions.venus.VenusSupply(
cTokenAddress,
from,
amount,
enableAsColl: false,
action venus supply address
)
const venus_withdraw_action = new actions.venus.VenusWithdraw(
cTokenAddress,
amount,
to,
action venus withdraw address
)
const venus_borrow_action = new actions.venus.VenusBorrow(
cTokenAddress,
amount,
to,
action venus borrow address
)
const venus_repay_action = new actions.venus.VenusRepay(
cTokenAddress,
amount,
from,
smart wallet address
action venus repay address
)
const cream_collateral_action = new actions.cream.VenusSupply(
list cTokenAddress,
list EnableAsCol,
action cream collateral address
)
const cream_supply_action = new actions.cream.CreamSupply(
cTokenAddress,
from,
amount,
enableAsColl: false,
action cream supply address
)
const cream_withdraw_action = new actions.cream.CreamWithdraw(
cTokenAddress,
amount,
to,
action cream withdraw address
)
const cream_borrow_action = new actions.cream.CreamBorrow(
cTokenAddress,
amount,
to,
action cream borrow address
)
const cream_repay_action = new actions.cream.CreamRepay(
cTokenAddress,
amount,
from,
smart wallet address
action cream repay address
)
const liqee_supply_action = new actions.liqee.LiqeeSupply(
cTokenAddress,
from,
amount,
enableAsColl: false,
action liqee supply address
)
const liqee_withdraw_action = new actions.liqee.LiqeeWithdraw(
cTokenAddress,
amount,
to,
action liqee withdraw address
)
const liqee_borrow_action = new actions.liqee.LiqeeBorrow(
cTokenAddress,
amount,
to,
action liqee borrow address
)
const liqee_repay_action = new actions.liqee.LiqeeRepay(
cTokenAddress,
amount,
from,
smart wallet address
action liqee repay address
)
const wepiggy_collateral_action = new actions.wepiggy.VenusSupply(
list cTokenAddress,
list EnableAsCol,
action wepiggy collateral address
)
const wepiggy_supply_action = new actions.wepiggy.WepiggySupply(
cTokenAddress,
from,
amount,
enableAsColl: false,
action wepiggy supply address
)
const wepiggy_withdraw_action = new actions.wepiggy.WepiggyWithdraw(
cTokenAddress,
amount,
to,
action wepiggy withdraw address
)
const wepiggy_borrow_action = new actions.wepiggy.WepiggyBorrow(
cTokenAddress,
amount,
to,
action wepiggy borrow address
)
const wepiggy_repay_action = new actions.wepiggy.WepiggyRepay(
cTokenAddress,
amount,
from,
smart wallet address
action wepiggy repay address
)
Sau khi có được các action xong, để execute Freight giả sử kết hợp action supply và borrow, repay và withdraw
import {Recipe} from "trava-station-sdk";
const recipe = new Recipe(
"ten action = address user + timestamp",
[
trava_supply_action,
trava_borrow_action,
trava_repay_action,
trava_withdraw_action
]
)
const encoded = recipe.encodeForDsProxyCall();
sau đó dùng contract Proxy để execute (abi e để dưới), address của contract này là proxy của người dùng
await proxyContract.execute(encoded[0], encoded[1])
[
{
"inputs": [
{
"internalType": "address",
"name": "_target",
"type": "address"
},
{
"internalType": "bytes",
"name": "_data",
"type": "bytes"
}
],
"name": "execute",
"outputs": [
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_cacheAddr",
"type": "address"
}
],
"name": "setCache",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "payable",
"type": "function"
}
]