Intent Execution API (Trading & DeFi)
Overview
The Intent Execution API helps streamline onchain trading and DeFi interactions (e.g., entering LP positions) by using professional solvers and market makers. It aggregates the best available quotes and provides the necessary data for execution.
Endpoint Details
URL:
https://metasolvertest.velvetdao.xyz/best-quotes
Method:
POST
Request Details
Headers
Ensure to include the following header in your request:
Content-Type:
application/json
Body Parameters
The request body should be a JSON object containing the following fields:
amount
string
Yes
The amount of tokens to swap or deposit, specified in the smallest units of the token (e.g., "1000000"
for 1 token with 6 decimals).
chainId
integer
Yes
The unique identifier of the blockchain network (e.g., 8453
for the Base network).
receiver
string
Yes
The Ethereum address of the recipient. Must be a valid wallet address (e.g., "0x3C96e2Fc58332746fbBAB5eC44f01572F99033ed"
).
sender
string
Yes
The Ethereum address of the sender. Must be a valid wallet address.
slippage
string
Yes
Acceptable slippage percentage for the transaction (e.g., "1"
for 1%).
tokenIn
string
Yes
The contract address of the input (source) ERC-20 token.
tokenOut
string
Yes
The contract address of the output (destination) ERC-20 token or LP token in case of DeFi interactions.
skipSimulation
boolean
Yes
Whether to skip simulation of the transaction (true
or false
).
Sample Request
Response Details
The API responds with a JSON object containing the best quotes from solvers and market makers, along with the necessary data to execute the intended trade or DeFi interaction.
Sample Response
Response Parameters
quotes: An array of quote objects from different solvers and market makers, sorted in descending order of
amountOut
.
Each quote object contains:
protocol
string
Name of the protocol providing the quote (e.g., "enso"
, "barter"
).
to
string
The address to which the transaction data should be sent.
data
string
The calldata required to execute the transaction (trade or DeFi interaction).
value
string
The amount of Ether to send with the transaction (usually "0"
for token swaps).
amountOut
string
The expected amount of output tokens or LP tokens from the interaction, in smallest units.
minAmountOut
string
The minimum acceptable amount of output tokens after accounting for slippage.
gasEstimate
integer
Estimated gas units required to execute the transaction.
simulationStatus
boolean
Indicates if the transaction simulation was successful (true
or false
).
priceImpactPercentage
string
or number
The percentage price impact of the transaction (e.g., "0.05"
).
approvalAddress: The address to which the input token (
tokenIn
) must be approved for the transaction to execute.
Approval Process
Before executing the transaction, you must approve the approvalAddress
to spend the input tokens (tokenIn
) on your behalf.
Sample Approval Code (JavaScript)
Parameters:
response.approvalAddress
: The approval address returned in the API response.approvalAmount
: The amount of tokens to approve (usually the same asamount
in the request).userAddress
: Your wallet address (must matchsender
in the request).gasAmount
: The gas limit for the approval transaction.gasPrice
: The gas price for the transaction.
Executing the Intent
After approval, you can execute the transaction using the data
and to
fields from the best quote. This can be a trade or a DeFi interaction, such as adding liquidity to a pool.
Sample Execution Code (JavaScript with ethers.js)
Parameters:
signer
: An instance of an ethers.js Signer connected to your wallet.data.to
: The address to send the transaction to.data.data
: The calldata for the transaction.data.value
: The amount of Ether to send (usually zero).data.gasEstimate
: Estimated gas units (multiplied by 1.5 for safety).
Error Handling
The API may return the following error responses:
400 Bad Request: The request is malformed or missing required parameters.
Example response:
404 Not Found: The requested resource cannot be found.
Example response:
Ensure that all required fields are included and valid in your request.
Additional Resources
For more detailed information, refer to the Swagger API documentation: https://metasolvertest.velvetdao.xyz/api-docs/#/default/post_best_quotes
API URL (Base Network):
https://metasolvertest.velvetdao.xyz
Endpoints
/best-quotes
Method:
POST
Description: Retrieves the best quotes with transaction data from solvers and market makers for trades and DeFi interactions.
Required Body Parameters:
Same as in the Request Details section.
/best-amount-out
Method:
POST
Description: Retrieves the best
amountOut
value from solvers and market makers without transaction data.Required Body Parameters:
amount
,tokenIn
,tokenOut
,sender
,receiver
,chainId
/swap-data
Method:
POST
Description: Retrieves transaction data for a specific protocol.
Required Body Parameters:
slippage
,amount
,tokenIn
,tokenOut
,sender
,amountOut
,protocol
,receiver
,chainId
Conclusion
The Intent Execution API streamlines the process of obtaining and executing the best quotes from solvers and market makers for both trading and DeFi interactions, such as entering liquidity pools. By following the steps outlined in this documentation, traders can integrate the API into their workflow to optimize trading strategies and enhance execution efficiency.
For any issues or further assistance, please refer to the Swagger API documentation or contact support.
Last updated