Class: WardenBestRate

Warden Best Rate for getting quote and swapping.

Constructors

constructor

new WardenBestRate(provider, networkName, options?)

Create new instance of WardenBestRate

Parameters

NameTypeDescription

provider

Provider

ethersjs' Provider instance

networkName

"bsc" | "arbitrum" | "polygon" | "ethereum" | "avalanche" | "optimism"

Chain name (supported by WardenSwap), arbitrum will be supported soon

options

WardenBestRateOption

Options

Methods

approve

approve(signer, src, allowedAmount?, overrides?): Promise<ContractTransaction>

Set Allowance of a token to be spendable by WardenSwap contract

Parameters

NameTypeDefault valueDescription

signer

Signer

undefined

ethers' Signer

src

string

undefined

Token to be approved

allowedAmount

BigNumberish

ethers.constants.MaxUint256

Allowed amount to be spendable by WardenSwap contract

overrides

PayableOverrides

{}

ethers' overrides

Returns

Promise<ContractTransaction>

ethers' contract transaction (no wait)


getDepositAddresses

getDepositAddresses(srcDestRouteTuples, dexManager?): string[]

Get deposit addresses indicating the first hop to be used for starting the trade. This information is required by Wardenswap contract

Parameters

NameTypeDescription

srcDestRouteTuples

{ dest: string ; routeAddress: string ; src: string }[]

tuples of src, dest, and routeAddress

dexManager?

DexManager

-

Returns

string[]

a list of deposit addresses with the same order as the input


getQuote

getQuote(src, dest, amountIn, gasPrice, opts?): Promise<QuoteResult>

Get the best rate of a token pair with given amount

Parameters

NameTypeDescription

src

string

Address of src asset

dest

string

Address of dest asset

amountIn

BigNumberish

Amount of src asset to be traded

gasPrice

BigNumberish

Amount of gas price per unit in native currency (18 decimals) e.g. BSC = BNB, Polygon = MATIC, Ethereum = ETH. For L2 chains, this is Ethereum (L1) gas price.

opts

GetQuoteOption

Options for getting quote

Returns

Promise<QuoteResult>

Trading routes which provide the best rate


swap

swap(signer, src, dest, amountIn, minDestAmount, quoteResult, partnerId?, metaData?, receiver?, overrides?): Promise<ContractTransaction>

Send a swap transaction to WardenSwap based on given quote

Parameters

NameTypeDefault valueDescription

signer

Signer

undefined

ethers' Signer

src

string

undefined

Source token

dest

string

undefined

Destination token

amountIn

BigNumberish

undefined

Amount of source token

minDestAmount

BigNumberish

undefined

Minimum amount of destination token

quoteResult

QuoteResult

undefined

Best rate quote got from getQuote method

partnerId

BigNumberish

0

Warden's partner ID

metaData

BigNumberish

0

MetaWarden ID

receiver?

string

undefined

Wallet to receive destination token, default to tx sender

overrides

PayableOverrides

{}

ethers' transaction overrides

Returns

Promise<ContractTransaction>

ethers' contract transaction (no wait)

Last updated