NFT Swap API

On this page you can check the endpoints for the Fanbase NFT Swap API which facilitates ERC20-ERC1155 swaps. The protocol compares Fanbase Swap and Niftyswap prices to provide you the best value.

sellToken

Exchange NFT to Currency

POST https://agg1155.fanbase.io/v1/sellToken

This endpoint is to get the created transaction data to sell NFT

Request Body

Name
Type
Description

chainId*

Number

Network ID e.g.:137

tokenAddress*

String

ERC-1155 NFT Address e.g.: 0x631998e91476DA5B870D741192fc5Cbc55F5a52E

tokenId*

String

NFT Token ID e.g.: 65549

recipient*

String

Operator Address e.g.: The wallet that performs the swap.

tokenAmount*

Number

Amount to sell. Format:number * 10 ** NFT token decimals e.g.: 100

exchangeAddress*

String

Exchange instance address e.g.: 0x8bb759bb68995343ff1e9d57ac85ff5c5fb79334

{
    "statusCode": 200,
    "message": "Successfully",
    "data": [
        {
            "data": string,
            "to": string
        }
    ]
}

buyToken

Exchange Currency to NFT

POST https://agg1155.fanbase.io/v1/buyToken

This endpoint is to get the created transaction data to buy NFT

Request Body

Name
Type
Description

chainId*

Number

Network ID e.g.:137

currencyAddress*

String

ERC-20 Address e.g.: 0x2791bca1f2de4661ed88a30c99a7a9449aa84174

tokenId*

String

NFT Token ID e.g.: 65549

recipient*

String

Operator Address e.g.: The wallet that performs the swap.

currencyAmount*

String

Max ERC-20 amount to spend. Should have a tiny margin to be able to pass the transaction.

exchangeAddress*

String

Exchange instance address e.g.: 0x8bb759bb68995343ff1e9d57ac85ff5c5fb79334

buyAmount*

String

Amount to sell. Format: number * 10 ** NFT token decimals e.g.: 100

feeRecipient

String

Fee Receiver Address

feeAmount

Number

Fee Amount

{
    "statusCode": 200,
    "message": "Successfully",
    "data": [
        { // First object needs to be executed to "approve" the swap
            "data": string,
            "to": string
        },
        { // After that this object needs to be executed to perform the swap
            "data": string,
            "to": string
        }
    ]
}

getPairList

Get list of exchange pairs

GET https://agg1155.fanbase.io/v1/getPairList

This endpoint is to get the list of existing pairs for given ERC-1155 NFT token and ERC-20 currency token

Query Parameters

Name
Type
Description

chainId*

String

Network ID e.g.:137

tokenAddress*

String

ERC-1155 NFT Address e.g.: 0x631998e91476DA5B870D741192fc5Cbc55F5a52E

currencyAddress*

String

ERC-20 Address e.g.: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174

{
    "statusCode": 200,
    "message": "Successfully",
    "data": [
        "0x6f5c06d4f90e30F0ea3Deb5bF760b2aa97643f55",
	"0x8BB759Bb68995343FF1e9D57Ac85Ff5c5Fb79334",
	"0x967c902d4Ea61B167fc56b27a36a546b266aC0FB"
    ]
}

createNftExchangeInstance

Create Exchange Instance

POST https://agg1155.fanbase.io/v1/createNftExchangeInstance

This endpoint is to get the created transaction data to create exchange instance by factory

Request Body

Name
Type
Description

chainId*

Number

Network ID to trade NFT on

tokenAddress*

String

NFT address

currencyAddress*

String

ERC-20 token address

lpFee*

Number

Liquidity Fee

{
    "data": {
        // Transaction Data
    },
    "status": 200
}

tokensToExchange

Get exchange instance address from token addresses

GET https://agg1155.fanbase.io/v1/tokensToExchange

This endpoint is to get the exchange instance address from ERC-20 and ERC-1155 token address that consist the pair

Query Parameters

Name
Type
Description

chainId*

Number

Network ID to trade on

tokenAddress*

String

NFT address

currencyAddress*

String

ERC-20 token address

lpFee*

Number

Liquidity Fee

instance*

Number

Exchange Instance ID returned that returned when instance created

{
    "status": 200,
    "data": //instance id
}

getCurrencyReserves

Get reserved currency amount for NFT in exchange instance

GET https://agg1155.fanbase.io/v1/getCurrencyReserves

This endpoint is to get the whole amount of ERC-20 currency token that reserved in liquidity

Query Parameters

Name
Type
Description

chainId*

Number

Network ID to trade on

tokenId*

Number

NFT token ID

exchangeAddress*

String

Exchange Instance Address

{
    "status": 200,
    "data": {
        type: BigNumber,
        value: "0x0000"
    }
}

getTokenReserves

Get reserved NFT token amount in exchange instance

GET https://agg1155.fanbase.io/v1/getTokenReserves

This endpoint is to get the whole amount of ERC-1155 NFT token that reserved in liquidity

Query Parameters

Name
Type
Description

chainId*

Number

Network ID to trade on

tokenId*

Number

NFT token ID

exchangeAddress*

String

Exchange Instance Address

{
    "status": 200,
    "data": {
        type: BigNumber,
        value: "0x0000"
    }
}

getCurrencyToTokenPrice

Get expected NFT token amount from ERC20 currency token amount

GET https://agg1155.fanbase.io/v1/getCurrencyToTokenPrice

This endpoint is to get ERC-1155 NFT token amount from ERC-20 currency token amount

Query Parameters

Name
Type
Description

chainId*

Number

Network ID to trade on

tokenId*

Number

NFT Token ID

exchangeAddress*

String

Exchange Instance Address

tokenAmount*

BigNumber

ERC-20 Token Amount

{
    "status": 200,
    "data": {
        type: BigNumber,
        value: "0x0000"
    }
}

getTokenToCurrencyPrice

Get NFT token price from amount

GET https://agg1155.fanbase.io/v1/getTokenToCurrencyPrice

This endpoint is to get amount of ERC-20 token amount from ERC-1155 NFT token amount

Query Parameters

Name
Type
Description

chainId*

Number

Network ID to trade on

tokenId*

Number

NFT Token ID

tokenAmount*

Number

NFT Token Amount

exchangeAddress*

String

Exchange Instance Address

{
    "status": 200,
    "data": {
        type: BigNumber,
        value: "0x0000"
    }
}

addLiquidityToNftDex

Create transaction array to add liquidity in exchange instance

POST https://agg1155.fanbase.io/v1/addLiquidityToNftDex

This endpoint is to get transaction data to execute for swap operation

Request Body

Name
Type
Description

chainId*

Number

Network ID to trade on

tokenAddress*

String

NFT Token Address

currencyAddress*

String

ERC-20 Token Address

erc1155Amount*

Number

NFT Token Amount

erc20Amount*

BigNumber

ERC-20 Token Amount

tokenId*

Number

NFT Token ID

exchangeAddress*

String

Exchange Instance Address

ownerAddress*

String

Operator Address

{
    "status": 200,
    "data": [
        {
            // tx1
        },
        {
            // tx2
        }
    ]
}

removeLiquidityFromNftDex

Create transaction array to remove liquidity from exchange instance

POST https://agg1155.fanbase.io/v1/removeLiquidityFromNftDex

This endpoint is to get transaction data to execute for swap operation

Request Body

Name
Type
Description

chainId*

Number

Network ID to trade on

exchangeAddress*

String

Exchange Instance Address

erc1155Amount*

Number

NFT Token Amount

erc20Amount*

BigNumber

ERC-20 Token Amount

tokenId*

Number

NFT Token ID

ownerAddress*

String

Operator Address

{
    "status": 200,
    "data": [
        {
            // tx1
        },
        {
            // tx2
        }
    ]
}

Last updated