How add custom token to swap? Bsc

Is there way to add custom token to swap. The token that is not on 1inch list? Thanks…

You can review this thread Add/Import cusotm token on dex

But there you say that code is outdate. Is there any github example?

Correct. The code itself is outdated. You can understand how you can work with it.
I haven’t seen any github example out there, but definitely, it will depend on your needs.

Try this example, it worked for me. Add this to your dex.jsx’

// Adding custom tokens

const customTokens = {
  "0x2180F5cC1ddf117640963AE91868948bd3EF6838": {
    address: "0x2180F5cC1ddf117640963AE91868948bd3EF6838",
    decimals: 9,
    logoURI:
      "https://assets.coingecko.com/coins/images/20985/small/_VoQPDDs_400x400.jpg?1638168643",
    name: "AscensionArcade",
    symbol: "AAT",
  },
};

<DEX chain="eth" customTokens={customTokens} />;
  "0xdEfAd558272f0a22993C1ECae31550f14a428A4f": {
            address: "0xdEfAd558272f0a22993C1ECae31550f14a428A4f",
            decimals: 9,
            logoURI: "https://bscscan.com/images/gen/wolfbet_20.png",
            name: "Beryllium",
            symbol: "BER"
        },

This one is not working. One from example works

It’s missing the comma before closing brackets symbol: "BER"

Happy to help!

Uncaught (in promise) Error: Something went wrong
{
  "message": "Request failed with status code 400",
  "name": "Error",
  "stack": "Error: Request failed with status code 400\n    at createError (/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/node_modules/axios/lib/adapters/http.js:269:11)\n    at IncomingMessage.emit (events.js:326:22)\n    at endReadableNT (_stream_readable.js:1241:12)\n    at processTicksAndRejections (internal/process/task_queues.js:84:21)",
  "config": {
    "url": "https://api.1inch.exchange/v3.0/56/quote?fromTokenAddress=0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c&toTokenAddress=0xdEfAd558272f0a22993C1ECae31550f14a428A4f&amount=1000000000000000000&fee=1",
    "method": "get",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "User-Agent": "axios/0.21.4"
    },
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 0,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1,
    "maxBodyLength": -1,
    "transitional": {
      "silentJSONParsing": true,
      "forcedJSONParsing": true,
      "clarifyTimeoutError": false
    }
  }
}
    at MoralisWeb3.js:697:1
    at tryCatch (runtime.js:63:1)
    at Generator.invoke [as _invoke] (runtime.js:294:1)
    at Generator.next (runtime.js:119:1)
    at asyncGeneratorStep (asyncToGenerator.js:5:1)
    at _next (asyncToGenerator.js:27:1)

I still got this error when it’s need to calculate the value between two tokens.
Thank You

Custom tokens swap on moralis dex required a high slippage. You will need to add a slippage changer to your dex and advise buyers to increase slippage between 12-21 for swap to complete.

Hey I don’t think it’s possible, unless you added in one of the Liquidity pool aggregated by 1Inch, coz the price of a token is determined by it’s supply in existing liquidity pool, also with no liquidity of the token no swapping could be done

It work with custom token that you send, but this one dont want to calculate. I think that sending will work. But i need to calculate.

How can i do that? Did enyone have this problem?

I think the only reason is that price of token i 0. So how can i Change that? Thanks

give your token a value and increase slippage. (with or without slippage changer).

Create a liquidity pool in for your custom token in one of the existing DEX aggregated by 1inch and be an intial liquidity provider. You can set the price of the token by having 50% of the token and 50% of other token (e.g. BNB) both with the same value. Once a liquidity pool exist, a price could be calculated from that, and it’ll automatically be supported by 1inch as well :raised_hands:

Just remember the reason why these tokens have price are the supply of the token within the liquidity pool, not some data gained from website such as CMC or Coingecko because they’re separate.

2 Likes

Can someone explain a better where this code need to be pasted

// Adding custom tokens

const customTokens = {
  "0x2180F5cC1ddf117640963AE91868948bd3EF6838": {
    address: "0x2180F5cC1ddf117640963AE91868948bd3EF6838",
    decimals: 9,
    logoURI:
      "https://assets.coingecko.com/coins/images/20985/small/_VoQPDDs_400x400.jpg?1638168643",
    name: "AscensionArcade",
    symbol: "AAT",
  },
};

when I try to put code in DEX.jsx I always getting this

src/components/DEX/DEX.jsx
  Line 173:7:   Insert `··`                                                           prettier/prettier
  Line 278:23:  Insert `··`                                                           prettier/prettier
  Line 279:25:  Insert `··`                                                           prettier/prettier
  Line 280:1:   Replace `························` with `··························`  prettier/prettier
  Line 281:23:  Insert `··`                                                           prettier/prettier
  Line 282:1:   Insert `··`                                                           prettier/prettier

Thank you but this not working I dont know why

Does this code going to dex.jsx or useinchdex.js I m confused about diffrent answers…Thank you