import{Web3Provider}from'@ethersproject/providers';import{isToken0Approved}from'@defiedge/sdk';constweb3Provider=newWeb3Provider(YOUR_WEB3_PROVIDER);conststrategyAddress="0xc3ad...72bf9eb"constaccountAddress="0xaaaa...aaaaaa"constamount=100constisToken0Approved: boolean=awaitisStrategyTokenApproved(accountAddress,0,// token idx can be 0 or 1amount,strategyAddress,web3Provider)
import{Web3Provider}from'@ethersproject/providers';import{approveStrategyToken}from'@defiedge/sdk';constweb3Provider=newWeb3Provider(YOUR_WEB3_PROVIDER);conststrategyAddress="0xc3ad...72bf9eb"constaccountAddress="0xaaaa...aaaaaa"constamount=100consttxnDetails=awaitapproveStrategyToken(accountAddress,0,// token idx can be 0 or 1strategyAddress,provider,amount// (optional));awaittxnDetails.wait();// can now deposit token0 // ...
import{Web3Provider}from'@ethersproject/providers';import{getLiquidityRatio}from'@defiedge/sdk';constprovider=newWeb3Provider(YOUR_WEB3_PROVIDER);conststrategyAddress="0xc3ad...72bf9eb"constaccountAddress="0xaaaa...aaaaaa"constratio=awaitgetLiquidityRatio(strategyAddress,web3Provider)constamount0=100constamount1=amount0*ratio// - or - constamount1=100constamount0=amount1*1/ratio
import{Web3Provider}from'@ethersproject/providers';import{depositLP}from'@defiedge/sdk';constweb3Provider=newWeb3Provider(YOUR_WEB3_PROVIDER);conststrategyAddress="0xc3ad...72bf9eb"constaccountAddress="0xaaaa...aaaaaa"constamount0=100constamount1=amount0*ratio// getLiquidityRatio()consttxnDetails=awaitdepositLP(accountAddress,amount0,// can be 0 when only depositing amount1amount1,// can be 0 when only depositing amount0strategyAddress,web3Provider)
import{Web3Provider}from'@ethersproject/providers';import{removeLP,getUserDeshareBalance}from'@defiedge/sdk';constweb3Provider=newWeb3Provider(YOUR_WEB3_PROVIDER);conststrategyAddress="0xc3ad...72bf9eb"constaccountAddress="0xaaaa...aaaaaa"consttotalUserShare: string=getUserDeshareBalance(accountAddress,strategyAddress,web3Provider)letshares=Number(totalUserShare)*0.5// 50% of user deshare balanceconsttxnDetails=awaitremoveLP(accountAddress,shares,// de sharesstrategyAddress,web3Provider)
This version of @defiedge/sdk is still in beta, so unfortunately documentation is pretty sparse at the moment. Comments and the source code itself are the best ways to get an idea of what's going on. More thorough documentation is a priority as development continues!