
Company News
Jerod Santo Joins Socket as Head of Media
Allow myself to introduce... myself.
trava-simulation-route-v2
Advanced tools
import { ApplicationState } from "../State/ApplicationState";
let chainId = Number((await provider.getNetwork()).chainId);
let appState = new ApplicationState(
userAddress: String,
smartWalletAddress: String,
provider: JsonRpcProvider, // reader
chainId: chainId
);
Khi sử dụng đồng token nào, thì khởi tạo state về số dư của đồng token đó:
appState1 = await updateUserTokenBalance(
appState,
tokenAddress
)
Nếu sử dụng đồng BNB
appState2 = await updateUserEthBalance(
appState1
)
Khi sử dụng các action trong pools, thì thực hiện update state của user về pool này
appState3 = await updateTravaLPInfo(
appState2,
market
)
Khi gọi action supply và withdraw
appState31 = await updateLPtTokenInfo(
appState3,
tokenAddress
)
Khi gọi action borrow và repay
appState32 = await updateLPDebtTokenInfo(
appState3,
tokenAddress
)
Khi goi action claim rewards
appState31 = await updateLPtTokenInfo(
appState3,
tokenAddress
)
init tokenBalance of rTrava in _to address
khi goi action convert rewards
appState31 = await updateLPtTokenInfo(
appState3,
tokenAddress
)
init rTrava balacne in _from address
init trava balance in _to address
Update các armouries của main wallet
appState4 = await updateNFTBalanceFromContract(
appState3,
"walletState"
)
Update các armouries của smart wallet
appState4 = await updateNFTBalanceFromContract(
appState3,
"smartWalletState"
)
Update các Knight của main wallet
appState4 = await updateCollectionBalanceFromContract(
appState3,
"walletState"
)
Update các Knight của smart wallet
appState4 = await updateCollectionBalanceFromContract(
appState3,
"smartWalletState"
)
Update các armouries đang bán trên marketplace
appState4 = await updateSellingNFTFromContract(
appState3
)
// update nft mà user đang bán
appState41 = await updateOwnedSellingNFT(
appState4
)
Update state của trava token như trên
appState5 = await updateUserTokenBalance(
appState4,
travaTokenAddress
)
Update các armouries mà user đang bán trên marketplace
appState5 = await updateOwnedSellingNFT(
appState4
)
First, update auctioning NFT From Contract when chose any action in Auction
appState = await updateAuctioningNFTFromContract(
appState
)
When create auction,
First update Owned Auctioning NFT
appState = await updateOwnedAuctioningNFT(
appState
)
Then, update collection of from wallet
appState = await updateCollectionBalanceFromContract(
appState
)
When make bid auction,
update trava balance of from address
appState = await updateUserTokenBalance(
appState,
travaTokenAddress
)
appState = await updateUserEthBalance(
appState
)
or
appState = await updateSmartWalletTokenBalance(
appState,
travaTokenAddress
)
appState = await updateSmartWalletEthBalance(
appState
)
when edit auction price
update Owned Auctioning NFT
appState = await updateOwnedAuctioningNFT(
appState,
from wallet state
)
when cancel auction
update Owned Auctioning NFT
appState = await updateOwnedAuctioningNFT(
appState,
from wallet state
)
Then, update collection of to wallet
appState = await updateCollectionBalanceFromContract(
appState,
to wallet state
)
when finalize auction update Owned Auctioning NFT if smartWallet is nftSeller,
update Trava balance, BNB balance of to wallet
appState = await updateUserTokenBalance(
appState,
travaTokenAddress
)
or
appState = await updateSmartWalletTokenBalance(
appState,
travaTokenAddress
)
if smartWallet is bidder,
appState = await updateCollectionBalanceFromContract(
appState,
to wallet state
)
Khi chọn bất cứ action nào của veTrava NFT Marketplace, update user lock balance của from address
appState = await updateSellingVeTrava(appState);
appState = await updateTravaGovernanceState(appState)
Khi chọn action Create Sale VeTrava
appState = await updateUserLockBalance(appState, fromAddress);
Khi chon action Cancel sale VeTrava
appState = await updateUserLockBalance(appState, toAddress)
Khi chon action Buy veTrava
appState = await updateUserLockBalance(appState, toAddress)
appState = await updateTokenBalance(appState, from address, busd token address)
appState = await updateTokenBalance(appState, from address, trava token address)
Update state cua smart wallet
newAppState = await updateLiquidityCampainState(
appState
)
Khi stake: update stakedToken balance for smart wallet, update underlyingToken balance for from address
Khi withdraw: update underlyingToken balance for "to" Address and Smart Wallet Address
Khi claimReward: update Trava balance for "to" address
Update state cua Smart Wallet trong cac vault
newAppState = await updateAllAccountVault(oldAppState, address)
Khi stake: update stakedToken balance for smart wallet, update underlyingToken balance for from address
Khi withdraw: update underlyingToken balance for "to" Address and Smart Wallet Address
Khi claimReward: update Trava balance for "to" address
stakedPool = await newAppState.smartWalletState.travaLPStakingStateList.get(stakedTokenAdress.toLownerCase())
TVL = stakedPool.TVL
APR = stakedPool.APR
reward = stakedPool.claimableReward
deposited = stakedPool.deposited
Khi tham gia vào các action của expedition
appState = await updateExpeditionState(appState)
appState = await updateOwnerKnightInExpeditionState(appState, smartWalletAddress)
Trava NFT Expedition Deploy update trava balance of from address update knight balance of from address update ticket balance of from address
appState = await updateUserLockBalance(appState, fromAddress);
appState = await updateCollectionBalanceFromContract(appState, fromAddress);
appState = await updateOwnerTicketState(appState, fromAddress);
Trava NFT Expedition Abandon update knight balance of to address
appState = await updateCollectionBalanceFromContract(appState, toAddress);
Trava NFT Expedition Abandon update knight balance of to address update trava balance of to address
appState = await updateCollectionBalanceFromContract(appState, fromAddress);
appState = await updateUserLockBalance(appState, toAddress);
Khi chon bat cu action nao cua Trava Governance, update TravaGovernanceState
appState = await updateTravaGovernanceState(appState);
Khi chon action Create Lock, update Trava Governace State cua from address, to address, update bep20 balance of from address
appState = await updateUserLockBalance(appState, fromAddress)
appState = await updateUserLockBalance(appState, toAddress)
appState = /// update token balance cua from address
Khi chon action merge, update Trava Governace State cua from address
appState = await updateUserLockBalance(appState, fromAddress)
Khi chon cac action : coumpound, change unlock time, update Trava Governace State cua smart wallet address
appState = await updateUserLockBalance(appState, smartWalletAddress)
Khi chon cac action : withdraw update Trava Governace State cua smart wallet address, update trava balance va token lock balance cua to address
appState = await updateUserLockBalance(appState, smartWalletAddress)
appState = /// update trava balance cua to address
appState = /// update token locked balance cua to address
Khi chon action increase balance, Trava Governace State cua smart wallet address, update token locked balance cua from address
appState = // update token locked balance cua from address
Khi chọn bất cứ action nào của veTrava NFT Marketplace, update selling veTrava NFT
appState = await updateSellingVeTrava(appState);
Khi chọn action Create Sale
appState = await updateUserLockBalance(appState, fromAddress);
Khi chọn action veTrava Buy
appState = await updateTokenBalance(appState, _from, priceTokenAddress);
appState = await updateUserLockBalance(appState, toAddress);
Khi chọn action Cancel Sale
appState = await updateUserLockBalance(appState, toAddress);
Khi chọn action Tranfer veTrava NFT
appState = await updateUserLockBalance(appState, walletAddress);
appState = await updateUserLockBalance(appState, smartWalletAddress);
Khi chọn bất cứ action nào của Others Lending pools fork Compound
appState = await updateForkCompoundLPState(appState, entity_id);
Khi chọn bất cứ action nào của Others Lending pools fork Aave
appState = await updateForkAaveLPState(appState, entity_id);
Khi update state pancake Farm
appState = await updatePancakeFarmState(appState, smartWalletAddr)
Sau khi init state xong. Với mỗi state, các simulate khác nhau
appState6 = await simulateSendToken(
appState5,
tokenAddress,
from: wallet address
to: smart wallet address,
amount: number | string
)
appState7 = await simulateSendToken(
appState6,
tokenAddress,
from: smart wallet address
to: main wallet address,
amount: number | string
)
appState8 = await simulateWrap(
appState7,
amount: number | string
)
appState9 = await simulateUnwrap(
appState8,
amount: number | string
)
appState10 = await simulateSwap(
appState9,
fromToken: token 1 address,
toToken: token2 address,
fromAmount: amount of token 1 will swap
toAmount: amount of token 2 will receive
fromAddress,
toAddress
)
appState11 = await SimulationSupply(
appState10,
from,
tokenAddress,
amount: string
)
appState12 = await SimulationBorrow(
appState11,
to,
tokenAddress,
amount: string
)
get max amount:
maxAmount = appState.smartWalletState.detailTokenInPool[tokenAddress].dToken.balances
appState13 = await SimulationRepay(
appState12,
from,
tokenAddress,
amount: string
)
get max amount:
maxAmount = appState.smartWalletState.detailTokenInPool[tokenAddress].tToken.balances
appState14 = await SimulationWithdraw(
appState13,
to,
tokenAddress,
amount
)
get max rewards:
claimableRewards = await calculateMaxRewards(appState);
appState15 = await SimulationClaimReward(
appState14,
to,
MAX_UINT256
)
get max rTrava cua from address
maxRTrava =
app.walletState.tokenBalance.get(rTravaAddress.toLowerCase())
or
app.smartWalletState.tokenBalance.get(rTravaAddress.toLowerCase())
appState16 = await SimulationConvertReward(
appState15,
from,
to,
MAX_UINT256
)
appState15 = await simulateTravaNFTBuy(
appState14,
tokenId,
from,
to
)
appState16 = await simulateTravaNFTSell(
appState15,
tokenId,
price: numer | String,
from: String
)
appState17 = await simulateTravaNFTCancelSale(
appState16,
to,
tokenId
)
appState = await simulateTravaNFTCreateAuction(
appState,
tokenId,
startingBid,
duration (ms),
from
)
appState = await simulateTravaNFTEditAuctionPrice(
appState,
tokenId,
startingBid
)
appState = await simulateTravaNFTMakeBidAuction(
appState,
tokenId,
bidPrice,
from
)
appState = await simulateTravaNFTCancelAuction(
appState,
tokenId,
to
)
appState = await simulateTravaNFTFinalizeAuction(
appState,
tokenId,
to
)
appState2 = await simulateNFTVeTravaCreateSale(
appState,
idVeTrava,
fromAddress,
priceAmount,
addressPriceToken,
);
appState3 = await simulateNFTVeTravaCancelSale(
appState,
idVeTrava,
toAddress,
);
appState4 = await simulateNFTVeTravaBuy(
appState,
idVeTrava,
toAddress,
);
appState18 = await simulateTravaNFTTransfer(
appState17,
from: address sender,
to: address receiver,
tokenId: nummber | string
contract: NFT_CORE address
)
appState19 = await simulateTravaNFTTransfer(
appState18,
from: address sender,
to: address receiver,
tokenId: nummber | string
contract: NFT_COLLECTION address
)
appState1 = await simulateNFTVeTravaTransfer(
appState,
idVeTrava,
fromAddress,
toAddress
);
appState = await simulateExpeditionDeploy(
appState,
vaultAddress,
knightId,
buffWinRateTiket array,
buffExpTick array,
_fromAddress (from kinght),
_fromAddress (from fee),
_fromAddress (from ticket)
)
appState = await simulateExpeditionAbandon(
appState,
vaultAddress,
knightId,
toAddress
)
appState = await simulateExpeditionWithdraw(
appState,
vaultAddress,
knightId,
toAddress
)
maxAmount = fromState.getTokenBalanceOf(underlyingTokenAddress)
newAppState = await SimulationJoinLiquidity(
oldAppState,
stakedTokenAddress,
from,
amount
)
maxAmount = oldAppState.smartWalletState.liquidityCampainState.get(stakedTokenAddress.toLowerCase())!.deposited;
newAppState = await SimulationWithdrawLiquidity(
oldAppState,
stakedTokenAddress,
to,
amount
)
maxAmount = oldAppState.smartWalletState.liquidityCampainState.get(stakedTokenAddress.toLowerCase())!.claimableReward;
newAppState = await SimulationClaimRewardLiquidity(
oldAppState,
stakedTokenAddress,
to,
maxAmount
)
maxAmount = fromState.getTokenBalanceOf(underlyingTokenAddress)
newAppState = await simulateStakeStaking(
oldAppState,
stakedTokenAddress,
from,
amount
)
maxAmount = oldAppState.smartWalletState.travaLPStakingStateList.get(stakedTokenAddress.toLowerCase())!.deposited;
newAppState = await simulateStakingRedeem(
oldAppState,
stakedTokenAddress,
to,
amount
)
maxAmount = oldAppState.smartWalletState.travaLPStakingStateList.get(stakedTokenAddress.toLowerCase())!.claimableReward;
newAppState = await simulateStakingClaimRewards(
oldAppState,
stakedTokenAddress,
to,
maxAmount
)
newAppState = await simulateTravaGovernanceCreateLock(
oldAppState,
tokenId,
amount,
from,
period
)
newAppState = await simulateTravaGovernanceIncreaseBalance(
oldAppState,
tokenId,
amount,
fromAddress,
smartWalletAddress
)
newAppState = await simulateTravaGovernanceChangeUnlockTime(
oldAppState,
tokenId,
newUnlockTime
)
newAppState = await simulateTravaGovernanceCompound(
oldAppState,
tokenId
)
newAppState = await simulateTravaGovernanceWithdraw(
oldAppState,
tokenId,
to
)
newAppState = await simulateTravaGovernanceMerge(
oldAppState,
tokenId1,
tokenId2,
from
)
Sau khi init state xong. Với mỗi state, các simulate khác nhau
appState6 = await simulateSendTokenV2(
appState5,
tokenAddress,
from: wallet address
to: smart wallet address,
amount: string,
contractAddress: address of actions
)
appState7 = await simulateSendTokenV2(
appState6,
tokenAddress,
from: smart wallet address
to: main wallet address,
amount: string,
contractAddress: address of actions
)
appState8 = await simulateWrapV2(
appState7,
amount: string,
contractAddress: address of actions
)
appState9 = await simulateUnwrapV2(
appState8,
amount: string,
contractAddress: address of actions
)
appState1 = await simulateNFTVeTravaTransfer(
appState,
idVeTrava,
fromAddress,
toAddress
);
appState1 = await SimulationSupplyForkCompoundLP(
appState,
from address,
entity_id,
tokenAddress,
amount
);
appState1 = await SimulationSupplyForkAaveLP(
appState,
from address,
entity_id,
tokenAddress,
amount
);
appState1 = await SimulationBorrowForkCompoundLP(
appState,
to address,
entity_id,
tokenAddress,
amount
);
appState1 = await SimulationBorrowForkAaveLP(
appState,
to address,
entity_id,
tokenAddress,
amount
);
appState1 = await SimulationRepayForkCompoundLP(
appState,
from address,
entity_id,
tokenAddress,
amount
);
appState1 = await SimulationRepayForkAaveLP(
appState,
from address,
entity_id,
tokenAddress,
amount
);
appState1 = await SimulationWithdrawForkCompoundLP(
appState,
to address,
entity_id,
tokenAddress,
amount
);
appState1 = await SimulationWithdrawForkAaveLP(
appState,
to address,
entity_id,
tokenAddress,
amount
);
inputCollateral {
tokenAddress: EthAddress,
enableAsColl: 0|1,
}
inputCollaterals = Array<inputCollateral>
appState = await SimulationCollateral(
appState,
smart wallet address,
entity_id,
inputCollaterals
);
appState1 = await SimulationTransferTToken(
appState,
fromAddress,
toAddress,
_tokenAddress,
_amount
)
appState1 = await simulateTransferStakedToken(
appState,
_stakingPool,
fromAddress,
toAddress,
_amount
);
appState1 = await simulateNFTVeTravaTransfer(
appState,
idVeTrava,
fromAddress,
toAddress
);
appState1 = await simulatePancakeFarmStakeLP(
appState,
wrapperAddr, // in file pancakefarmconfig
from addr,
amount,
noHarvest = true
)
appState1 = await simulatePancakeFarmStakeLP(
appState,
wrapperAddr, // in file pancakefarmconfig
amount,
to addr,
noHarvest = true
)
appState1 = await simulatePancakeFarmHarvestLP(
appState,
wrapperAddr, // in file pancakefarmconfig
toAddr,
noHarvest = true
)
FAQs
# Table of contents
We found that trava-simulation-route-v2 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.

Company News
Allow myself to introduce... myself.

Research
/Security News
A Twitch browser extension on Chrome and Firefox forwards users’ live OAuth session tokens through proxies controlled by a Russian bot service.

Security News
Anthropic found biased reasoning and recklessness drove Claude Mythos 5 to publish malware on PyPI and compromise a security vendor.