dappuniversity / price-bot

397 stars 392 forks source link

Kyber Rates are 0 #12

Open djarbz opened 3 years ago

djarbz commented 3 years ago

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 commented 3 years ago

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

Genoux commented 3 years ago

Same here! Any hints?

djarbz commented 3 years ago

I haven't found a solution yet.

jollytraders3 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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)

yo-mike commented 3 years ago

Thanks @mohamedalichelbi -- you made it so easy.

canberk17 commented 3 years ago

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

canberk17 commented 3 years ago

specifically this error

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

WhiteyWhiteman84 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Thanks for the info.

I already changed all changes made by @mohanedalichelbi_PR, but now I am getting the error: expected 4, received 3.This is, as far as I can tell, because of line 40, where he deleted true in the methods call. Any suggestion what to do there?

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

On Sun, Mar 21, 2021 at 10:02 PM John Barry @.***> wrote:

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 https://developer.kyber.network/docs/Addresses-Intro/ and ABI https://developer.kyber.network/docs/API_ABI-ABI/

@Genoux https://github.com/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 https://github.com/mohamedalichelbi/price-bot/commit/9e6053a3930bc229e7a87bde5a14bb38ee71d006

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dappuniversity/price-bot/issues/12#issuecomment-803659420, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATKZ73OJMRY7IKG6OKGOB4TTEZNIBANCNFSM4UKRRHCA .

c-vision commented 3 years ago

//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()