Skip to content

SDK for zapping between assets through DolomiteMargin ⚡

License

Notifications You must be signed in to change notification settings

dolomite-exchange/zap-sdk

Repository files navigation

Dolomite Logo

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

Overview

About

SDK for zapping between assets through DolomiteMargin ⚡

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages