diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c16dcea Binary files /dev/null and b/.DS_Store differ diff --git a/.env.sample b/env.sample similarity index 67% rename from .env.sample rename to env.sample index 4023e03..df040b0 100644 --- a/.env.sample +++ b/env.sample @@ -1,4 +1,4 @@ PK_MAINNET= PK_POLYGON= HTTP_PROVIDER_MAINNET= -HTTP_PROVIDER_POLYGON= +HTTP_PROVIDER_POLYGON= \ No newline at end of file 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}`, ); } }