@dolomite-exchange/zap-sdk
v0.3.23
Published
SDK for zapping any asset to any asset on Dolomite.
Downloads
81
Readme
Dolomite Zap SDK
SDK for zapping any asset to any asset on Dolomite.
Usage
Installation
npm install @dolomite-exchange/zap-sdk
or if you use yarn
yarn add @dolomite-exchange/zap-sdk
Initialization
import { Network } from './ApiTypes';
import { DolomiteZap } from './DolomiteZap';
const network = Network.ARBITRUM_ONE;
const subgraphUrl = procses.env.SUBGRAPH_URL; // TODO replace with a URL to the Dolomite subgraph
const web3Provider = window.ethereum; // TODO replace with a web3 provider
const cacheSeconds = 60 * 60; // 1 hour
const zap = new DolomiteZap(
network,
subgraphUrl,
web3Provider,
cacheSeconds,
);
Zapping
import { DolomiteZap } from './DolomiteZap';
let zap: DolomiteZap;
const tokenIn = WETH_MARKET;
const tokenOut = USDC_MARKET;
const txOrigin = web3WalletAddress;
const outputParams = await zap.getSwapExactTokensForTokensParams(
tokenIn,
amountIn,
tokenOut,
minAmountOut,
txOrigin,
);
// You can now use outputParams for calling Dolomite's GenericTraderProxy or LiquidatorProxyV4 contracts