ref_finance_execute_swap
Swap tokens on Ref Finance using a specific pool or optimizing for liquidity and rates. Specify input/output tokens, amounts, and swap type for efficient transactions.
Instructions
Execute a swap on Ref Finance based on two tokens and a pool id. Prioritize pools with higher liquidity and better rates for the user.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
accountId | Yes | The account id of the user doing the swap | |
amount | Yes | The amount of the input tokens to swap | |
networkId | No | mainnet | |
swapType | No | The type of estimate to get. Defaults to the ref finance smart router to find the best price over all available pools | |
tokenIn | Yes | ||
tokenOut | Yes |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"accountId": {
"description": "The account id of the user doing the swap",
"type": "string"
},
"amount": {
"description": "The amount of the input tokens to swap",
"type": [
"number",
"integer"
]
},
"networkId": {
"default": "mainnet",
"enum": [
"testnet",
"mainnet"
],
"type": "string"
},
"swapType": {
"anyOf": [
{
"additionalProperties": false,
"properties": {
"pathDepth": {
"default": 3,
"description": "The depth of the path to search for the best pool",
"type": "number"
},
"slippagePercent": {
"default": 0.001,
"description": "The slippage to use for the estimate. Only use 0.001, 0.005, or 0.01",
"type": "number"
},
"type": {
"const": "bySmartRoute",
"description": "Get an estimate using the ref finance smart router to find the best pool",
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"poolId": {
"description": "The pool id (e.g. 1)",
"type": "number"
},
"type": {
"const": "byPoolId",
"description": "Get an estimate using a specific pool id",
"type": "string"
}
},
"required": [
"type",
"poolId"
],
"type": "object"
}
],
"default": {
"type": "bySmartRoute"
},
"description": "The type of estimate to get. Defaults to the ref finance smart router to find the best price over all available pools"
},
"tokenIn": {
"additionalProperties": false,
"properties": {
"contractId": {
"description": "The contract id of the input token to be swapped",
"type": "string"
},
"symbol": {
"description": "The symbol of the input token",
"type": "string"
}
},
"required": [
"contractId",
"symbol"
],
"type": "object"
},
"tokenOut": {
"additionalProperties": false,
"properties": {
"contractId": {
"description": "The contract id of the output token to be swapped",
"type": "string"
},
"symbol": {
"description": "The symbol of the output token",
"type": "string"
}
},
"required": [
"contractId",
"symbol"
],
"type": "object"
}
},
"required": [
"accountId",
"tokenIn",
"tokenOut",
"amount"
],
"type": "object"
}