Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kyber Rates are 0 #12

Open
djarbz opened this issue Dec 2, 2020 · 13 comments
Open

Kyber Rates are 0 #12

djarbz opened this issue Dec 2, 2020 · 13 comments

Comments

@djarbz
Copy link

djarbz commented Dec 2, 2020

Kyber Rates for DAI, KNC, and LINK all return 0

Checking prices...
┌─────────┬─────────────┬──────────────┬──────────────┬────────────────────────┬────────────────────────┬───────────────────────┬─────────────────────────────┐
│ (index) │ Input Token │ Output Token │ Input Amount │     Uniswap Return     │  Kyber Expected Rate   │   Kyber Min Return    │          Timestamp          │
├─────────┼─────────────┼──────────────┼──────────────┼────────────────────────┼────────────────────────┼───────────────────────┼─────────────────────────────┤
│    0    │    'ETH'    │    'MKR'     │     '1'      │ '1.060152104433066426' │ '1.060046665374527588' │ '1.02824526541329176' │ '2020-12-02T08:09:37-06:00' │
└─────────┴─────────────┴──────────────┴──────────────┴────────────────────────┴────────────────────────┴───────────────────────┴─────────────────────────────┘
┌─────────┬─────────────┬──────────────┬──────────────┬──────────────────────────┬─────────────────────┬──────────────────┬─────────────────────────────┐
│ (index) │ Input Token │ Output Token │ Input Amount │      Uniswap Return      │ Kyber Expected Rate │ Kyber Min Return │          Timestamp          │
├─────────┼─────────────┼──────────────┼──────────────┼──────────────────────────┼─────────────────────┼──────────────────┼─────────────────────────────┤
│    0    │    'ETH'    │    'DAI'     │     '1'      │ '591.145732642784308457' │         '0'         │       '0'        │ '2020-12-02T08:09:37-06:00' │
└─────────┴─────────────┴──────────────┴──────────────┴──────────────────────────┴─────────────────────┴──────────────────┴─────────────────────────────┘
┌─────────┬─────────────┬──────────────┬──────────────┬──────────────────────────┬─────────────────────┬──────────────────┬─────────────────────────────┐
│ (index) │ Input Token │ Output Token │ Input Amount │      Uniswap Return      │ Kyber Expected Rate │ Kyber Min Return │          Timestamp          │
├─────────┼─────────────┼──────────────┼──────────────┼──────────────────────────┼─────────────────────┼──────────────────┼─────────────────────────────┤
│    0    │    'ETH'    │    'KNC'     │     '1'      │ '460.752628953645153198' │         '0'         │       '0'        │ '2020-12-02T08:09:37-06:00' │
└─────────┴─────────────┴──────────────┴──────────────┴──────────────────────────┴─────────────────────┴──────────────────┴─────────────────────────────┘
┌─────────┬─────────────┬──────────────┬──────────────┬─────────────────────────┬─────────────────────┬──────────────────┬─────────────────────────────┐
│ (index) │ Input Token │ Output Token │ Input Amount │     Uniswap Return      │ Kyber Expected Rate │ Kyber Min Return │          Timestamp          │
├─────────┼─────────────┼──────────────┼──────────────┼─────────────────────────┼─────────────────────┼──────────────────┼─────────────────────────────┤
│    0    │    'ETH'    │    'LINK'    │     '1'      │ '42.342745921953079737' │         '0'         │       '0'        │ '2020-12-02T08:09:37-06:00' │
└─────────┴─────────────┴──────────────┴──────────────┴─────────────────────────┴─────────────────────┴──────────────────┴─────────────────────────────┘
@scottmilla
Copy link

@djarbz did you ever figure this out? @gwmccubbin can you help?

@Genoux
Copy link

Genoux commented Jan 4, 2021

Same here! Any hints?

@djarbz
Copy link
Author

djarbz commented Jan 4, 2021

I haven't found a solution yet.

@jollytraders3
Copy link

I too am having the same issue. I find it very strange that the issue is specific to token and exchange combinations. If it were all the swaps on kyber I would think it to be a problem with the API or addresses for Kyber. If the tokens didn't work on both exchanges, I'd say the issue would lie in the token addresses. But strangely it's a mix of the two and I am still racking my brain for a solution.

@Genoux
Copy link

Genoux commented Jan 6, 2021

Got it to work. Just had to update the Factory Address and the ABI.
Look for KyberNetworkProxy address and I used the KyberNetworkProxy (V1) ABI

Check out the documentation for Kyber Network Address and ABI

@mohamedalichelbi
Copy link

mohamedalichelbi commented Jan 7, 2021

@Genoux thanks man, that did it for me.
(I went with the new KyberNetworkProxy, worked with some very light modifications, I did submit PR #13 for that)

@MikeCraig418
Copy link

Thanks @mohamedalichelbi -- you made it so easy.

@canberk17
Copy link

Whic ABI did you use I am getting errors when I use it

@canberk17
Copy link

specifically this error

Error: Please pass numbers as strings or BN objects to avoid precision errors.

@WhiteyWhiteman84
Copy link

WhiteyWhiteman84 commented Mar 21, 2021

Got it to work. Just had to update the Factory Address and the ABI.
Look for KyberNetworkProxy address and I used the KyberNetworkProxy (V1) ABI

Check out the documentation for Kyber Network Address and ABI

@Genoux In which file did you change the factory address and the ABI? I can't find it in index.js

@Genoux
Copy link

Genoux commented Mar 21, 2021

Got it to work. Just had to update the Factory Address and the ABI.
Look for KyberNetworkProxy address and I used the KyberNetworkProxy (V1) ABI
Check out the documentation for Kyber Network Address and ABI

@Genoux In which file did you change the factory address and the ABI? I can't find it in index.js

It's in index.js look for KYBER_RATE_ADDRESS and KYBER_RATE_ABI
Have a look at mohamedalichelbi PR

@WhiteyWhiteman84
Copy link

WhiteyWhiteman84 commented Mar 22, 2021 via email

@c-vision
Copy link

c-vision commented Jun 2, 2021

//https://developer.kyber.network/docs/API_ABI-ABI/
const KEYBER_NETWORK_PROXY_ABI = [{ "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "trader", "type": "address" }, { "indexed": false, "internalType": "contract IERC20", "name": "src", "type": "address" }, { "indexed": false, "internalType": "contract IERC20", "name": "dest", "type": "address" }, { "indexed": false, "internalType": "address", "name": "destAddress", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "actualSrcAmount", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "actualDestAmount", "type": "uint256" }, { "indexed": false, "internalType": "address", "name": "platformWallet", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "platformFeeBps", "type": "uint256" }], "name": "ExecuteTrade", "type": "event" }, { "inputs": [{ "internalType": "contract ERC20", "name": "src", "type": "address" }, { "internalType": "contract ERC20", "name": "dest", "type": "address" }, { "internalType": "uint256", "name": "srcQty", "type": "uint256" }], "name": "getExpectedRate", "outputs": [{ "internalType": "uint256", "name": "expectedRate", "type": "uint256" }, { "internalType": "uint256", "name": "worstRate", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract IERC20", "name": "src", "type": "address" }, { "internalType": "contract IERC20", "name": "dest", "type": "address" }, { "internalType": "uint256", "name": "srcQty", "type": "uint256" }, { "internalType": "uint256", "name": "platformFeeBps", "type": "uint256" }, { "internalType": "bytes", "name": "hint", "type": "bytes" }], "name": "getExpectedRateAfterFee", "outputs": [{ "internalType": "uint256", "name": "expectedRate", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract IERC20", "name": "src", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "contract IERC20", "name": "dest", "type": "address" }, { "internalType": "address payable", "name": "destAddress", "type": "address" }, { "internalType": "uint256", "name": "maxDestAmount", "type": "uint256" }, { "internalType": "uint256", "name": "minConversionRate", "type": "uint256" }, { "internalType": "address payable", "name": "platformWallet", "type": "address" }], "name": "trade", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "contract ERC20", "name": "src", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "contract ERC20", "name": "dest", "type": "address" }, { "internalType": "address payable", "name": "destAddress", "type": "address" }, { "internalType": "uint256", "name": "maxDestAmount", "type": "uint256" }, { "internalType": "uint256", "name": "minConversionRate", "type": "uint256" }, { "internalType": "address payable", "name": "walletId", "type": "address" }, { "internalType": "bytes", "name": "hint", "type": "bytes" }], "name": "tradeWithHint", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "contract IERC20", "name": "src", "type": "address" }, { "internalType": "uint256", "name": "srcAmount", "type": "uint256" }, { "internalType": "contract IERC20", "name": "dest", "type": "address" }, { "internalType": "address payable", "name": "destAddress", "type": "address" }, { "internalType": "uint256", "name": "maxDestAmount", "type": "uint256" }, { "internalType": "uint256", "name": "minConversionRate", "type": "uint256" }, { "internalType": "address payable", "name": "platformWallet", "type": "address" }, { "internalType": "uint256", "name": "platformFeeBps", "type": "uint256" }, { "internalType": "bytes", "name": "hint", "type": "bytes" }], "name": "tradeWithHintAndFee", "outputs": [{ "internalType": "uint256", "name": "destAmount", "type": "uint256" }], "stateMutability": "payable", "type": "function" }]
//https://developer.kyber.network/docs/Addresses-Mainnet/
const KYBER_NETWORK_PROXY_ADDRESS = '0x9AAb3f75489902f3a48495025729a0AF77d4b11e'
const kyberRateContract = new web3.eth.Contract(KEYBER_NETWORK_PROXY_ABI, KYBER_NETWORK_PROXY_ADDRESS)

then replace keyber call by

    kyberResult = await kyberRateContract.methods.getExpectedRate(inputTokenAddress, outputTokenAddress, inputAmount).call()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants