From 3f7068d5c0ea08f76b6d0252ac52eaa1294e67f2 Mon Sep 17 00:00:00 2001 From: Adrian Lawson Date: Sat, 27 Aug 2022 00:39:19 -0700 Subject: [PATCH 1/3] migrated to apiv5 --- .DS_Store | Bin 0 -> 6148 bytes .env.sample | 4 ---- index.js | 2 +- paraswap.js | 13 +++++++------ 4 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 .DS_Store delete mode 100644 .env.sample diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..26e36fec8d2ad0d2c5981184d335fd4a9cbe3b9d GIT binary patch literal 6148 zcmeHK%}T>S5T1=eA`15CarFU&zQJ1J(NnL2Qd_E!n2PqE2k_)0_$*$;_Ygem#hc&k z3^gIPcoLNvnEiI=XLs_YWV%G;2J>;Bs7FK@lrh=B@P)9SwIhjI*y(tWV%i^`RpqP` zX@=j*0KdDG_GwBNbklx+PkT*YS>^ets7A15yN}Peug4DuZU1N5LS>xIsle*GSx0hoceN_ES=Y<@`}UjEwRG>Y`mFOi@y)uE`+!nRi~(c782IxH zpl7pWn}RkP1IBA(=L0KgRHD46qIf^)oLP^<;vfjCJ8N~+T< zhLd#Iy~YK_T2Ru-#gnm*p6v97;^OJB`xs6x2-;{27z1qv)@0e^{(rdq{@+frl`&up z{3`}rnh)~<9!Yy^=i#{5dgv*Xh2v_$MG7Xd6(g2g@eVW!?4BpUpjZpS0%# Ifgfey1GVT?Gynhq literal 0 HcmV?d00001 diff --git a/.env.sample b/.env.sample deleted file mode 100644 index 4023e03..0000000 --- a/.env.sample +++ /dev/null @@ -1,4 +0,0 @@ -PK_MAINNET= -PK_POLYGON= -HTTP_PROVIDER_MAINNET= -HTTP_PROVIDER_POLYGON= diff --git a/index.js b/index.js index cd024a5..ec6f103 100644 --- a/index.js +++ b/index.js @@ -81,7 +81,7 @@ class CrossChainArbinator { // Bot logic goes here async run() { const srcAmountFirst = this.normalise( - '0.05', + '0.035', Tokens[MAINNET_NETWORK_ID]['ETH'], ); // Get the best price for ETH -> MATIC swap in MAINNET diff --git a/paraswap.js b/paraswap.js index 108f9ac..59228f5 100644 --- a/paraswap.js +++ b/paraswap.js @@ -1,8 +1,8 @@ const axios = require('axios'); const BigNumber = require('bignumber.js'); -const ParswapURL = 'https://apiv4.paraswap.io/v2'; - +const ParswapURL = 'https://apiv5.paraswap.io'; +let requestURL; // https://developers.paraswap.network/ class Paraswap { constructor(apiURL = ParswapURL) { @@ -13,14 +13,15 @@ class Paraswap { async getPrice(from, to, srcAmount, network) { // TODO: Add error handling try { - const requestURL = - `${this.apiURL}/prices/?from=${from.address}&to=${to.address}` + - `&amount=${srcAmount}&fromDecimals=${from.decimals}&toDecimals` + + requestURL = + `${this.apiURL}/prices/?srcToken=${from.address}&destToken=${to.address}` + + `&amount=${srcAmount}&srcDecimals=${from.decimals}&destDecimals` + `=${to.decimals}&side=SELL&network=${network}`; const { data } = await axios.get(requestURL, { headers: { 'X-Partner': this.referrer, }, + }); return { price: data.priceRoute.destAmount, @@ -28,7 +29,7 @@ class Paraswap { }; } catch (e) { throw new Error( - `Paraswap unable to fetch price ${from.address} ${to.address} ${network} ${e.message}`, + `Paraswap unable to fetch price ${from.address} ${to.address} ${network} ${e.message} ${requestURL}`, ); } } From 0fe1fb267344ce17e80eee19fd3085e37599c143 Mon Sep 17 00:00:00 2001 From: Adrian Lawson Date: Sat, 27 Aug 2022 00:53:27 -0700 Subject: [PATCH 2/3] replace env.sample --- .DS_Store | Bin 6148 -> 6148 bytes env.sample | 4 ++++ index.js | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 env.sample diff --git a/.DS_Store b/.DS_Store index 26e36fec8d2ad0d2c5981184d335fd4a9cbe3b9d..c16dcea67df56efe933b686f914bb14c58fd528d 100644 GIT binary patch delta 111 zcmZoMXffEJ#uRsZ8v_Fa3xgg*IzuKyNp8N2OHxjL5>Sl8WYU?-46#QXQRP$c$`@o9 a1}Ep|76A1yFfc7(n7n~WX7d836j10oCU0Pp*}Q-$MHB#`2p!-6 diff --git a/env.sample b/env.sample new file mode 100644 index 0000000..df040b0 --- /dev/null +++ b/env.sample @@ -0,0 +1,4 @@ +PK_MAINNET= +PK_POLYGON= +HTTP_PROVIDER_MAINNET= +HTTP_PROVIDER_POLYGON= \ No newline at end of file diff --git a/index.js b/index.js index ec6f103..ba46916 100644 --- a/index.js +++ b/index.js @@ -81,7 +81,7 @@ class CrossChainArbinator { // Bot logic goes here async run() { const srcAmountFirst = this.normalise( - '0.035', + '100.0', Tokens[MAINNET_NETWORK_ID]['ETH'], ); // Get the best price for ETH -> MATIC swap in MAINNET From 98dde66b592e20442700ab681cafbb1a13dc099c Mon Sep 17 00:00:00 2001 From: Adrian Lawson Date: Sat, 27 Aug 2022 00:54:49 -0700 Subject: [PATCH 3/3] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index ba46916..ec6f103 100644 --- a/index.js +++ b/index.js @@ -81,7 +81,7 @@ class CrossChainArbinator { // Bot logic goes here async run() { const srcAmountFirst = this.normalise( - '100.0', + '0.035', Tokens[MAINNET_NETWORK_ID]['ETH'], ); // Get the best price for ETH -> MATIC swap in MAINNET