🔸Quote API
Step by step guide to set up the Marswap Aggregator API
Last updated
Step by step guide to set up the Marswap Aggregator API
Last updated
GET
/v1/swap/quote
This endpoint can be used to request transaction data to submit to the blockchain for a swap between two tokens.
Name | Value |
---|---|
Parameter | Description | Required | Type |
---|---|---|---|
Parameter | Description |
---|---|
An "allowance" refers to the amount of a specific ERC-20 token that an owner has approved another Ethereum address to swap. In our case, we would like the Marswap Aggregator smart contract to trade ERC20 tokens.
To do so, we will need to give an allowance to the allowanceTarget
parameter that's returned by the API. The allowanceTarget
is the the target contract address, in our case the Marswap Aggregator smart contract address on the relevant network.
For swaps with "ETH" as sellToken, wrapping "ETH" to "WETH" or unwrapping "WETH" to "ETH" no allowance is needed.
Read more here about setting token allowances.
Marswap-Api-Key
string
sellToken
The address of the token you want to sell.
Yes
string
buyToken
The address of the token you want to buy.
Yes
string
sellAmount
The amount of sell token to swap in base units.
Yes
number
buyTokenOrSellTokenHasFees
Boolean indicating if buy or sell token has fees/taxes.
No. Default is true
boolean
slippagePercentage
Maximum slippage percentage for the swap.
Yes
number
integratorId
The integrator ID provided by the Marswap team for authentication.
Yes
string
buyTokenPercentageFee
The percentage of the buyAmount that will be sent to the feeRecipient as affiliate fees. Maximum is 1%.
No
number
feeRecipient
The wallet address that will receive affiliate fees from each trade.
No
string
gasPrice
The gas price on the network in Wei. This is required to determine the amount gas to submit with the transaction.
Yes
number
takerAddress
The address of the wallet making the swap.
Yes
string
chainId
The blockchain network ID.
price
The calculated swap price of the buy token relative to the sell token.
minimumPrice
The minimum acceptable swap price of the buy token relative to the sell token considering slippage.
value
The amount of ETH in Wei to be sent in the transaction.
buyTokenAddress
The address of the token you want to buy.
buyAmount
The calculated amount of buy token to receive in base units.
sellTokenAddress
The address of the token you want to sell.
sellAmount
The amount of sell token to swap in base units.
sellTokenToEthRate
The exchange rate of sell token to ETH. Multiply this by the USD price of ETH to get the USD value of the sell token.
buyTokenToEthRate
The exchange rate of buy token to ETH. Multiply this by the USD price of ETH to get the USD value of the buy token.
swapFeeInEth
The swap fee in ETH.
allowanceTarget
The address of the contract to grant approval allowance to for the swap.
gas
The estimated gas limit that should be used to send the transaction to ensure success. While a estimate is returned in all responses, an accurate estimate will only be returned if a takerAddress
is included in the request.
estimatedGas
The estimate for the amount of gas that will actually be used in the transaction.
gasPrice
The gas price on the network in Wei. This is required to determine the amount gas to submit with the transaction.
from
The address of the wallet making the swap.
to
The address of the contract to send transaction data to.
data
A transaction request that can be submitted to the blockchain using Ethers.js, Web3.js, etc to make the swap