Aggregate Swap API

On this page you can check the endpoints for the Fanbase Aggregate ERC20 Swap API which delivers you the best price from a variety of decentralized swaps.

tokens

Get a list of tokens

GET https://agg20.fanbase.io/v1/tokens

The Fanbase API can perform swaps on any token that follows the ERC-20 standard and has liquidity on any of the supported networks. This list is an optional choice to get a sample of tokens with their logos.

Query Parameters

Name
Type
Description

chainId*

String

1

{
  "tokens": {
    "0x0327112423f3a68efdf1fcf402f6c5cb9f7c33fd": {
      "symbol": "BTC++",
      "name": "PieDAO BTC++",
      "decimals": 18,
      "address": "0x0327112423f3a68efdf1fcf402f6c5cb9f7c33fd",
      "logoURI": "https://tokens.1inch.io/0x0327112423f3a68efdf1fcf402f6c5cb9f7c33fd.png",
      "tags": [
        "tokens",
        "PEG:BTC"
      ]
    },
  // ...
}

quotes

Fetch Quotes

GET https://agg20.fanbase.io/v1/quotes

Get quotes of a pair from available exchanges. In case of getting quotes between Native Coin (e.g. Ethereum) pass asinputAddress or outputAddress the following: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE.

Query Parameters

Name
Type
Description

chainId*

String

Network ID e.g.:1

inputAddress*

String

Contract address of a token to sell e.g.: 0xdAC17F958D2ee523a2206206994597C13D831ec7

outputAddress*

String

Contract address of a token to buy e.g.: 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984

inputAmount*

Big Number

Amount of input token to sell, in WEI e.g.: 1000000000000000000

[
    {
        "fromToken": {
            "name": string,
            "symbol": string,
            "decimals": number
        },
        "toToken": {
            "name": string,
            "symbol": string,
            "decimals": number
        },
        "fromTokenAmount": string - amoun in WEI,
        "toTokenAmount": BigNumber,
        "dexName": string
    },
    ...
]

approve

Generate Approve Data

POST https://agg20.fanbase.io/v1/approve

In order for the Fanbase Aggregation protocol to access the tokens in your wallet, you need to create an approve transaction. This specifies that the fanbase router can exchange a specific amount of the chosen token. Only available when swapping Token -> Token or Token -> Native. Native -> Token does NOT need approval.

Request Body

Name
Type
Description

chainId*

Number

Network ID e.g.:1

inputAddress*

String

Contract address of a token to sell e.g.: 0xdAC17F958D2ee523a2206206994597C13D831ec7

outputAddress*

String

Contract address of a token to buy e.g.: 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984

dexName*

String

Name of DEX e.g.: UNISWAP_V2, UNISWAP_V3, PANCAKESWAP, SUSHISWAP, VOLTAGE, SPIRITSWAP, SPOOKYSWAP, 1INCH, FANBASE

inputAmount*

Big Number

Amount of input token to sell, in WEI e.g.: 1000000000000000000

JSON Object

{
    "statusCode": 200,
    "message": "Successfully",
    "data": {
        "data": string,
        "to": string,
        // Following are returned when "dexName" is "1INCH"
        "gasPrice": string,
        "vvalue": string
    }
}

approve/allowance

Check Allowance

POST https://agg20.fanbase.io/v1/approve/allowance

Check if a token spending is already approved. Only available when swapping Token -> Token or Token -> Native.

Request Body

Name
Type
Description

chainId*

Number

Network ID e.g.:1

inputAddress*

String

Contract address of a token to check allowance e.g.: 0xdAC17F958D2ee523a2206206994597C13D831ec7

dexName*

String

Name of DEX e.g.: UNISWAP_V2

fromAddress*

String

Operator address e.g.: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

JSON Object

{
    "statusCode": 200,
    "message": "Successfully",
    "data": {
        "allowance": BigNumber
    }
}

swap

Generate Swap Data

POST https://agg20.fanbase.io/v1/swap

Swap a pair of tokens. In case of Native -> Token there's no need for an /approve to happen before /swap. In any other case it's required.

Request Body

Name
Type
Description

chainId*

Number

Network ID e.g.:1

inputAddress*

String

Contract address of a token to sell e.g.: 0xdAC17F958D2ee523a2206206994597C13D831ec7

outputAddress*

String

Contract address of a token to buy e.g.: 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984

slippage*

Number

slippage tolerance eg: 1

inputAmount*

Big Number

Amount of input token to sell, in WEI e.g.: 1000000000000000000

fromAddress*

String

Operator address e.g.: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

dexName*

String

Name of DEX e.g.: UNISWAP_V2

JSON Object

{
    "statusCode": 200,
    "message": "Successfully",
    "data": {
        "data": string,
        "to": string,
        // BigNumber is not returned when "dexName" is "1INCH"
        "gasLimit": BigNumber,
        // Following are returned when "dexName" is "1INCH"
        "value": string,
        "from": string,
        "gas": number,
        "gasPrice": string
    }
}

addLiquidity

Add Liquidity

POST https://agg20.fanbase.io/v1/addLiquidity

Not functional - Soon

Request Body

Name
Type
Description

chainId*

number

Network ID

amountB*

big number

token B amount

amountA*

big number

token A amount

fromAddress*

string

operator address

tokenB*

string

token B address

tokenA*

string

token A address

Last updated