Class: WardenBestRate
Warden Best Rate for getting quote and swapping.
Last updated
Warden Best Rate for getting quote and swapping.
Last updated
▸ new WardenBestRate(provider
, networkName
, options?
)
Create new instance of WardenBestRate
Parameters
Name | Type | Description |
---|---|---|
▸ approve(signer
, src
, allowedAmount?
, overrides?
): Promise
<ContractTransaction
>
Set Allowance of a token to be spendable by WardenSwap contract
Parameters
Name | Type | Default value | Description |
---|---|---|---|
Returns
Promise
<ContractTransaction
>
ethers' contract transaction (no wait)
▸ 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
Returns
string
[]
a list of deposit addresses with the same order as the input
▸ getQuote(src
, dest
, amountIn
, gasPrice
, opts?
): Promise
<QuoteResult
>
Get the best rate of a token pair with given amount
Parameters
Returns
Promise
<QuoteResult
>
Trading routes which provide the best rate
▸ swap(signer
, src
, dest
, amountIn
, minDestAmount
, quoteResult
, partnerId?
, metaData?
, receiver?
, overrides?
): Promise
<ContractTransaction
>
Send a swap transaction to WardenSwap based on given quote
Parameters
Returns
Promise
<ContractTransaction
>
ethers' contract transaction (no wait)
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Default value | Description |
---|---|---|---|
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
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
srcDestRouteTuples
{ dest
: string
; routeAddress
: string
; src
: string
}[]
tuples of src, dest, and routeAddress
dexManager?
DexManager
-
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
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