0.0.63 • Published 8 months ago

tcv-platform-sdk v0.0.63

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

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
    )
0.0.63

8 months ago

0.0.62

8 months ago

0.0.61

8 months ago

0.0.40

1 year ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.45

12 months ago

0.0.46

12 months ago

0.0.47

12 months ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.60

10 months ago

0.0.59

10 months ago

0.0.51

12 months ago

0.0.52

12 months ago

0.0.53

11 months ago

0.0.54

11 months ago

0.0.55

11 months ago

0.0.56

11 months ago

0.0.57

10 months ago

0.0.58

10 months ago

0.0.50

12 months ago

0.0.48

12 months ago

0.0.49

12 months ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.20

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.30

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago