Last active
May 23, 2025 16:56
-
-
Save earthchie/bc528f3bcbc1ef00b43c40ab9238cbd2 to your computer and use it in GitHub Desktop.
Revisions
-
earthchie revised this gist
May 30, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,11 +11,11 @@ let Contract = { provider.on('block', async (blockNumber) => { const pancakeReserves = await Contract.PancakePair.getReserves(); const at_pancake = pancakeReserves[1] / pancakeReserves[0]; console.log(`Pancake 1 DOP = ${at_pancake} BUSD`); const twindexReserves = await Contract.TwindexPair.getReserves(); const at_twindex = twindexReserves[1] / twindexReserves[0]; console.log(`Twindex 1 DOP = ${at_twindex} BUSD`); }); -
earthchie revised this gist
May 30, 2021 . 1 changed file with 13 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,21 @@ const ethers = require('ethers'); const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/'); // you can find pair address from Factory Contract, method getPair(token1Addr, token2Addr). let Contract = { PancakePair: new ethers.Contract('0xb694ec7C2a7C433E69200b1dA3EBc86907B4578B',['function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)'], provider), TwindexPair: new ethers.Contract('0xC789F6C658809eED4d1769a46fc7BCe5dbB8316E',['function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)'], provider) } provider.on('block', async (blockNumber) => { const pancakeReserves = await Contract.PancakePair.getReserves(); const at_pancake = Number(ethers.utils.formatUnits(pancakeReserves[1], 18)) / Number(ethers.utils.formatUnits(pancakeReserves[0], 18)); console.log(`Pancake 1 DOP = ${at_pancake} BUSD`); const twindexReserves = await Contract.TwindexPair.getReserves(); const at_twindex = Number(ethers.utils.formatUnits(twindexReserves[1], 18)) / Number(ethers.utils.formatUnits(twindexReserves[0], 18)); console.log(`Twindex 1 DOP = ${at_twindex} BUSD`); }); -
earthchie revised this gist
May 24, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,10 +17,10 @@ Contract.Dopple.on('Transfer', async (from, to, amount, event) => { let at_pancake = await Contract.PancakeRouter.getAmountsOut(One, [BEP20.DOP, BEP20.BUSD]); at_pancake = at_pancake[1].toString() / 1e18; console.log(`Pancake 1 DOP = ${at_pancake} BUSD`); let at_twindex = await Contract.TwindexRouter.getAmountsOut(One, [BEP20.DOP, BEP20.BUSD]); at_twindex = at_twindex[1].toString() / 1e18; console.log(`Twindex 1 DOP = ${at_twindex} BUSD`); }); -
earthchie revised this gist
May 24, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const Contract = { Dopple: new ethers.Contract(BEP20.DOP, ['event Transfer(address indexed from, address indexed to, uint256 value)'], provider) } Contract.Dopple.on('Transfer', async (from, to, amount, event) => { const One = ethers.utils.parseUnits('1', 18); -
earthchie revised this gist
May 24, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,10 +17,10 @@ Contract.Dopple.on('Transfer', (from, to, amount, event) => { let at_pancake = await Contract.PancakeRouter.getAmountsOut(One, [BEP20.DOP, BEP20.BUSD]); at_pancake = at_pancake[1].toString() / 1e18; console.log('Pancake 1 DOP = ${at_pancake} BUSD'); let at_twindex = await Contract.TwindexRouter.getAmountsOut(One, [BEP20.DOP, BEP20.BUSD]); at_twindex = at_twindex[1].toString() / 1e18; console.log('Twindex 1 DOP = ${at_twindex} BUSD'); }); -
earthchie created this gist
May 24, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ const ethers = require('ethers'); const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/'); const BEP20 = { BUSD: '0xe9e7cea3dedca5984780bafc599bd69add087d56', DOP: '0x844fa82f1e54824655470970f7004dd90546bb28' }; const Contract = { PancakeRouter: new ethers.Contract('0x10ED43C718714eb63d5aA57B78B54704E256024E', ['function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts)'], provider), TwindexRouter: new ethers.Contract('0xBCB41906bE2C2724A8CD0dec87512B2463535586', ['function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts)'], provider), Dopple: new ethers.Contract(BEP20.DOP, ['event Transfer(address indexed from, address indexed to, uint256 value)'], provider) } Contract.Dopple.on('Transfer', (from, to, amount, event) => { const One = ethers.utils.parseUnits('1', 18); let at_pancake = await Contract.PancakeRouter.getAmountsOut(One, [BEP20.DOP, BEP20.BUSD]); at_pancake = at_pancake[1].toString() / 1e18; console.log('Pancake 1 DOP = ${at_pancake}'); let at_twindex = await Contract.TwindexRouter.getAmountsOut(One, [BEP20.DOP, BEP20.BUSD]); at_twindex = at_twindex[1].toString() / 1e18; console.log('Twindex 1 DOP = ${at_twindex}'); });