test-tcv-platform-sdk
v0.0.23
Published
- [Table of contents](#table-of-contents) - [TCV PLATFORM SDK](#tcv-platform-sdk) - [TCV](#tcv) - [getPoolTCV](#get-pool-tcv) - [getInfoVaultToken](#get-info-vault-token) - [getInfoVaultManager](#get-info-vault-manager) - [getInfoVaultRa
Downloads
36
Readme
Table of contents
TCV PLATFORM SDK
import {TCV} from "tcv-platform-sdk"
Information about one vault
TCV
const tcv = new TCV(_wallet, _TCVAddress);
get pool TCV
const poolsInVault = await tcv.getPoolTCV();
get info vault token
const token0AndToken1InVault = await tcv.getInfoVaultToken();
get info vault manager
const manager = await tcv.getInfoVaultManager();
get info vault ranges
const rangesSetInVault = await tcv.getInfoVaultRanges();
TCV Factory
Information about vaults have been deployed
const tcvFactory = new TCVFactory( _wallet, _chainId );
deploy vault
const deployVault = await tcvFactory.deployVault(
feeTier,
token0,
token1,
owner,
init0,
init1,
manager,
routers,
isBeacon
)
get vaults
const getVaults = await tcvFactory.getVaults(startIndex, endIndex);
get num vaults
const numVaults = await tcvFactory.getNumVaults();
UniswapV3
Get info Vault when addLiqudity or removeLiquidity in a pool in uniswap v3 Function amountsForAddLiquidity return amount of token0 and token1 when addLiquidity ( display amount when adding )
Function liquidityForAmounts will return amount of liquidity when add with amount of token0, and token1
Function getPoolAddress to get address the pool which vault add liquidity
Functon getPosition get liquidity, token0Owed, token1Owed in pool address with positionId is id of vault with range
Function getAmountInOther return amount of token1 in token0 when token0 is base Assest( ust or wbnb) ( for example meaning 1 cake = 10 usdt )
Function PriceInOther wil get price of token1 in token0(base Assest token (usdt, wbnb))
Function getPriceLp => get price of lp token in usdt
Function get getTVL => get amount tvl in usdt
Function get amountsForRemoveLiquidity when proving amountMin0, amountMin1 it will return the amount liquidity to burn and amount0, amount1
=> if funcitons require lowertick, uppertick, feetier, you need to get information about range in funciton getInfoVaultRanges, if range is a array all this do with for loop
const uniswapv3 = new UniswapV3(_wallet, _chainId );
amounts for add liquidity
Get amount0, amount1 when provide amount of one token
const amountReturn = await uniswapv3.amountsForAddLiquidity(
slippage: number,
zeroToOne: boolean, // mean what token input first
amountMax: uint256,
token0: EthAddress,
token1: EthAddress,
lowerTick: uint256,
upperTick: uint256,
feeTier: uint256
)
get position
const getTVLTokens = await uniswapv3.getPosition(
addressPool: EthAddress,
addressTCVVault: EthAddress,
lowerTick: uint256,
upperTick: uint256)
get pool address
const poolAddress = await uniswapv3.getPoolAddress( token0, token1, feeTier);
liquidity for amounts
Function return amount of liquidity, token0, token1, feeTier, lowerTick, upperTick, you can get from vault info amount0, amount1 is return of funciton amountsForAddLiquidity
const amount = await uniswapv3.liquidityForAmounts(
token0: EthAddress,
token1: EthAddress,
feeTier: uint256,
lowerTick: uint256,
upperTick: uint256,
amount0: uint256,
amount1: uint256)
get amount in other
input token0 is base assest token wanted to change token1 into token0
const amount = await uniswap.getAmountInOther(
amountIn: uint256,
slippage: number,
token0: EthAddress,
token1: EthAddress,
feeTier: uint256)
get price in other
input token0 is base assest token wanted to change token1 into token0
const price = await uniswap.getPriceInOther(
slippage: number,
token0: EthAddress,
token1: EthAddress,
feeTier: uint256)
get price LP
const priceLP = await uniswap.getPriceLP(
tcvVault:EthAddress,
feeTier: uint256,
lowerTick:uint256,
upperTick: uint256)
get TVL
const tvl = await uniswap.getTVL(
tcvVault:EthAddress,
feeTier: uint256,
lowerTick:uint256,
upperTick: uint256)
amounts for remove liquidity
return amount of liquidity to remove with provide of amount0Min, amount1Min
const amountBurn = await uniswap.(
amount0Min: uint256,
amount1Min: uint256,
token0: EthAddress,
token1: EthAddress,
lowerTick: uint256,
upperTick: uint256,
feeTier: uint256)
TCV Router
Router for user to add liquidity, remove liquidity receiver address is zero_address if you won't stake to vault if stake, it will be address of vault stake
Function removeLiquidity provide amountBurn, this amount you need to get in first element of array from function amountsForRemoveLiquidity in uniswap
const tcvRouter = new TCVRouter( _wallet, _chainId);
add liquidity
const addLiqudity = tcvRouter.addLiquidity(
amount0Max:uint256,
amount1Max:uint256,
vaultAddress:EthAddress,
receiver:EthAddress
)
remove liquidity
const removeLiqudity = tcvRouter.removeLiquidity(
amountBurn:uint256,
amount0Min:EthAddress,
amount1Min:EthAddress,
vaultAddress:EthAddress,
receiver:EthAddress
)