@curvefi/api 2.28.1 → 2.28.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,3 @@
1
- export declare const BTC_COINS_ETHEREUM: {
2
- [index: string]: string;
3
- };
4
- export declare const ETH_COINS_ETHEREUM: {
5
- [index: string]: string;
6
- };
7
- export declare const LINK_COINS_ETHEREUM: {
8
- [index: string]: string;
9
- };
10
- export declare const EUR_COINS_ETHEREUM: {
11
- [index: string]: string;
12
- };
13
- export declare const USD_COINS_ETHEREUM: {
14
- [index: string]: string;
15
- };
16
1
  export declare const COINS_ETHEREUM: {
17
2
  [index: string]: string;
18
3
  };
@@ -1,50 +1,11 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.aTokensEthereum = exports.ycTokensEthereum = exports.yTokensEthereum = exports.cTokensEthereum = exports.COINS_ETHEREUM = exports.USD_COINS_ETHEREUM = exports.EUR_COINS_ETHEREUM = exports.LINK_COINS_ETHEREUM = exports.ETH_COINS_ETHEREUM = exports.BTC_COINS_ETHEREUM = void 0;
3
+ exports.aTokensEthereum = exports.ycTokensEthereum = exports.yTokensEthereum = exports.cTokensEthereum = exports.COINS_ETHEREUM = void 0;
15
4
  var utils_1 = require("../utils");
16
- exports.BTC_COINS_ETHEREUM = {
17
- sbtccrv: "0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3",
18
- hbtc: "0x0316EB71485b0Ab14103307bf65a021042c6d380",
19
- renbtc: "0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D",
20
- wbtc: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
21
- tbtc: "0x8dAEBADE922dF735c38C80C7eBD708Af50815fAa",
22
- pbtc: "0x5228a22e72ccC52d415EcFd199F99D0665E7733b",
23
- bbtc: "0x9be89d2a4cd102d8fecc6bf9da793be995c22541",
24
- obtc: "0x8064d9Ae6cDf087b1bcd5BDf3531bD5d8C537a68",
25
- sbtc: "0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6", // sBTC
26
- };
27
- exports.ETH_COINS_ETHEREUM = {
28
- steth: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
29
- eth: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
30
- ankreth: "0xE95A203B1a91a908F9B9CE46459d101078c2c3cb",
31
- seth: "0x5e74c9036fb86bd7ecdcb084a0673efc32ea31cb",
32
- reth: "0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593",
33
- weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
34
- frxeth: "0x5E8422345238F34275888049021821E8E08CAa1f",
35
- xaut: "0x68749665ff8d2d112fa859aa293f07a622782f38", // XAUt TODO move to GOLD
36
- };
37
- exports.LINK_COINS_ETHEREUM = {
38
- link: "0x514910771AF9Ca656af840dff83E8264EcF986CA",
39
- slink: "0xbBC455cb4F1B9e4bFC4B73970d360c8f032EfEE6", // sLINK
40
- };
41
- exports.EUR_COINS_ETHEREUM = {
42
- eurs: "0xdB25f211AB05b1c97D595516F45794528a807ad8",
43
- seur: "0xD71eCFF9342A5Ced620049e616c5035F1dB98620",
44
- eurt: "0xC581b735A1688071A1746c968e0798D642EDE491",
45
- euroc: "0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",
46
- };
47
- exports.USD_COINS_ETHEREUM = {
5
+ exports.COINS_ETHEREUM = (0, utils_1.lowerCaseValues)({
6
+ crv: "0xD533a949740bb3306d119CC777fa900bA034cd52",
7
+ // --- USD ---
8
+ '3crv': "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490",
48
9
  ycdai: "0x99d1Fa417f94dcD62BfE781a1213c092a47041Bc",
49
10
  ycusdc: "0x9777d7E2b60bB01759D0E2f8be2095df444cb07E",
50
11
  ycusdt: "0x1bE5d71F2dA660BFdee8012dDc58D024448A0A59",
@@ -87,96 +48,40 @@ exports.USD_COINS_ETHEREUM = {
87
48
  mim: "0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3",
88
49
  rai: "0x03ab458634910aad20ef5f1c8ee96f1d6ac54919",
89
50
  wormholeust: "0xa693B19d2931d498c5B318dF961919BB4aee87a5",
90
- '3crv': "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490",
91
- crv: "0xD533a949740bb3306d119CC777fa900bA034cd52",
92
- cvx: "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", // CVX
93
- };
94
- exports.COINS_ETHEREUM = (0, utils_1.lowerCaseValues)(__assign(__assign(__assign(__assign(__assign(__assign({}, exports.BTC_COINS_ETHEREUM), exports.ETH_COINS_ETHEREUM), exports.LINK_COINS_ETHEREUM), exports.EUR_COINS_ETHEREUM), exports.USD_COINS_ETHEREUM), { snx: "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f", spell: "0x090185f2135308bad17527004364ebcc2d37e5f6", t: "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5" }));
95
- var DECIMALS_ETHEREUM = {
96
- "0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3": 18,
97
- "0x0316EB71485b0Ab14103307bf65a021042c6d380": 18,
98
- "0x99d1Fa417f94dcD62BfE781a1213c092a47041Bc": 18,
99
- "0x9777d7E2b60bB01759D0E2f8be2095df444cb07E": 6,
100
- "0x1bE5d71F2dA660BFdee8012dDc58D024448A0A59": 6,
101
- "0x8E870D67F660D95d5be530380D0eC0bd388289E1": 18,
102
- "0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D": 8,
103
- "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599": 8,
104
- "0x8dAEBADE922dF735c38C80C7eBD708Af50815fAa": 18,
105
- "0x5228a22e72ccC52d415EcFd199F99D0665E7733b": 18,
106
- "0x9be89d2a4cd102d8fecc6bf9da793be995c22541": 8,
107
- "0x8064d9Ae6cDf087b1bcd5BDf3531bD5d8C537a68": 18,
108
- "0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6": 18,
109
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84": 18,
110
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE": 18,
111
- "0xE95A203B1a91a908F9B9CE46459d101078c2c3cb": 18,
112
- "0x5e74c9036fb86bd7ecdcb084a0673efc32ea31cb": 18,
113
- "0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593": 18,
114
- "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": 18,
115
- "0xdB25f211AB05b1c97D595516F45794528a807ad8": 2,
116
- "0xD71eCFF9342A5Ced620049e616c5035F1dB98620": 18,
117
- "0xC581b735A1688071A1746c968e0798D642EDE491": 6,
118
- "0x514910771AF9Ca656af840dff83E8264EcF986CA": 18,
119
- "0xbBC455cb4F1B9e4bFC4B73970d360c8f032EfEE6": 18,
120
- "0x028171bCA77440897B824Ca71D1c56caC55b68A3": 18,
121
- "0xBcca60bB61934080951369a648Fb03DF4F96263C": 6,
122
- "0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811": 6,
123
- "0x6c5024cd4f8a59110119c56f8933403a539555eb": 18,
124
- "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643": 8,
125
- "0x39AA39c021dfbaE8faC545936693aC917d5E7563": 8,
126
- "0x8e595470ed749b85c6f7669de83eae304c2ec68f": 8,
127
- "0x76eb2fe28b36b3ee97f3adae0c69606eedb2a37c": 8,
128
- "0x48759f220ed983db51fa7a8c0d2aab8f3ce4166a": 8,
129
- "0xC2cB1040220768554cf699b0d863A3cd4324ce32": 18,
130
- "0x26EA744E5B887E5205727f55dFBE8685e3b21951": 6,
131
- "0xE6354ed5bC4b393a5Aad09f21c46E101e692d447": 6,
132
- "0x04bC0Ab673d88aE9dbC9DA2380cB6B79C4BCa9aE": 18,
133
- "0x16de59092dAE5CcF4A1E6439D611fd0653f0Bd01": 18,
134
- "0xd6aD7a6750A7593E092a9B218d66C0A814a3436e": 6,
135
- "0x83f798e925BcD4017Eb265844FDDAbb448f1707D": 6,
136
- "0x73a052500105205d34Daf004eAb301916DA8190f": 18,
137
- "0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd": 2,
138
- "0xdF574c24545E5FfEcb9a659c229253D4111d87e1": 8,
139
- "0x1c48f86ae57291F7686349F12601910BD8D470bb": 18,
140
- "0xe2f2a5C287993345a840Db3B0845fbC70f5935a5": 18,
141
- "0x196f4727526eA7FB1e17b2071B3d8eAA38486988": 18,
142
- "0x5BC25f649fc4e26069dDF4cF4010F9f706c23831": 18,
143
- "0xa47c8bf37f92abed4a126bda807a7b7498661acd": 18,
144
- "0x1456688345527bE1f37E9e627DA0837D6f08C925": 18,
145
- "0x674C6Ad92Fd080e4004b2312b45f796a192D27a0": 18,
146
- "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f": 18,
147
- "0x6B175474E89094C44Da98b954EedeAC495271d0F": 18,
148
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": 6,
149
- "0xdAC17F958D2ee523a2206206994597C13D831ec7": 6,
150
- "0x57Ab1ec28D129707052df4dF418D58a2D46d5f51": 18,
151
- "0x0000000000085d4780B73119b644AE5ecd22b376": 18,
152
- "0x853d955acef822db058eb8505911ed77f175b99e": 18,
153
- "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0": 18,
154
- "0x4Fabb145d64652a948d72533023f6E7A623C7C53": 18,
155
- "0xbc6da0fe9ad5f3b0d58160288917aa56653660e9": 18,
156
- "0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3": 18,
157
- "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490": 18,
158
- "0xD533a949740bb3306d119CC777fa900bA034cd52": 18,
159
- "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b": 18,
160
- "0x68749665ff8d2d112fa859aa293f07a622782f38": 6,
161
- "0x090185f2135308bad17527004364ebcc2d37e5f6": 18,
162
- "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5": 18,
163
- "0xa693B19d2931d498c5B318dF961919BB4aee87a5": 6,
164
- "0x03ab458634910aad20ef5f1c8ee96f1d6ac54919": 18,
165
- // --- REWARD TOKENS ---
166
- "0xa3BeD4E1c75D00fa6f4E5E6922DB7261B5E9AcD2": 18,
167
- "0x8762db106B2c2A0bccB3A80d1Ed41273552616E8": 18,
168
- "0x20c36f062a31865bED8a5B1e512D9a1A20AA333A": 18,
169
- "0x89Ab32156e46F46D02ade3FEcbe5Fc4243B9AAeD": 18,
170
- "0x3c9d6c1C73b31c837832c72E04D3152f051fc1A9": 18,
171
- "0x4da27a545c0c5b758a6ba100e3a049001de870f5": 18,
172
- "0x5a98fcbea516cf06857215779fd812ca3bef1b32": 18,
173
- "0xe0ad1806fd3e7edf6ff52fdb822432e847411033": 18,
174
- "0x8290333cef9e6d528dd5618fb97a76f268f3edd4": 18,
175
- "0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0": 18,
176
- "0x6dea81c8171d0ba574754ef6f8b412f2ed88c54d": 18,
177
- "0xef3a930e1ffffacd2fc13434ac81bd278b0ecc8d": 18,
178
- "0xdbdb4d16eda451d0503b854cf79d55697f90c8df": 18, // ALCX
179
- };
51
+ // --- ETH ---
52
+ steth: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84",
53
+ eth: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
54
+ ankreth: "0xE95A203B1a91a908F9B9CE46459d101078c2c3cb",
55
+ seth: "0x5e74c9036fb86bd7ecdcb084a0673efc32ea31cb",
56
+ reth: "0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593",
57
+ weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
58
+ frxeth: "0x5E8422345238F34275888049021821E8E08CAa1f",
59
+ // --- BTC ---
60
+ sbtccrv: "0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3",
61
+ hbtc: "0x0316EB71485b0Ab14103307bf65a021042c6d380",
62
+ renbtc: "0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D",
63
+ wbtc: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
64
+ tbtc: "0x8dAEBADE922dF735c38C80C7eBD708Af50815fAa",
65
+ pbtc: "0x5228a22e72ccC52d415EcFd199F99D0665E7733b",
66
+ bbtc: "0x9be89d2a4cd102d8fecc6bf9da793be995c22541",
67
+ obtc: "0x8064d9Ae6cDf087b1bcd5BDf3531bD5d8C537a68",
68
+ sbtc: "0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6",
69
+ // --- EUR ---
70
+ eurs: "0xdB25f211AB05b1c97D595516F45794528a807ad8",
71
+ seur: "0xD71eCFF9342A5Ced620049e616c5035F1dB98620",
72
+ eurt: "0xC581b735A1688071A1746c968e0798D642EDE491",
73
+ euroc: "0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",
74
+ // --- LINK ---
75
+ link: "0x514910771AF9Ca656af840dff83E8264EcF986CA",
76
+ slink: "0xbBC455cb4F1B9e4bFC4B73970d360c8f032EfEE6",
77
+ // --- OTHER ---
78
+ cvx: "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b",
79
+ cvxcrv: "0x62b9c7356a2dc64a1969e19c23e4f579f9810aa7",
80
+ snx: "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f",
81
+ spell: "0x090185f2135308bad17527004364ebcc2d37e5f6",
82
+ t: "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5",
83
+ xaut: "0x68749665ff8d2d112fa859aa293f07a622782f38", // XAUt
84
+ });
180
85
  exports.cTokensEthereum = [
181
86
  '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643',
182
87
  '0x39AA39c021dfbaE8faC545936693aC917d5E7563',
@@ -1,15 +1,3 @@
1
- export declare const BTC_COINS_POLYGON: {
2
- [index: string]: string;
3
- };
4
- export declare const ETH_COINS_POLYGON: {
5
- [index: string]: string;
6
- };
7
- export declare const EUR_COINS_POLYGON: {
8
- [index: string]: string;
9
- };
10
- export declare const USD_COINS_POLYGON: {
11
- [index: string]: string;
12
- };
13
1
  export declare const COINS_POLYGON: {
14
2
  [index: string]: string;
15
3
  };
@@ -1,57 +1,30 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.aTokensPolygon = exports.ycTokensPolygon = exports.yTokensPolygon = exports.cTokensPolygon = exports.COINS_POLYGON = exports.USD_COINS_POLYGON = exports.EUR_COINS_POLYGON = exports.ETH_COINS_POLYGON = exports.BTC_COINS_POLYGON = void 0;
3
+ exports.aTokensPolygon = exports.ycTokensPolygon = exports.yTokensPolygon = exports.cTokensPolygon = exports.COINS_POLYGON = void 0;
15
4
  var utils_1 = require("../utils");
16
- exports.BTC_COINS_POLYGON = {
17
- wbtc: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
18
- renbtc: "0xDBf31dF14B66535aF65AaC99C32e9eA844e14501",
19
- amwbtc: "0x5c2ed810328349100A66B82b78a1791B101C9D61", // amWBTC
20
- };
21
- exports.ETH_COINS_POLYGON = {
22
- weth: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
23
- amweth: "0x28424507fefb6f7f8E9D3860F56504E4e5f5f390", // amWETH
24
- };
25
- exports.EUR_COINS_POLYGON = {
26
- eurt: "0x7BDF330f423Ea880FF95fC41A280fD5eCFD3D09f", // EURT
27
- };
28
- exports.USD_COINS_POLYGON = {
5
+ exports.COINS_POLYGON = (0, utils_1.lowerCaseValues)({
6
+ crv: "0x172370d5cd63279efa6d502dab29171933a610af",
7
+ // -- USD ---
29
8
  dai: "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063",
30
9
  usdc: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
31
10
  usdt: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
32
11
  amdai: "0x27F8D03b3a2196956ED754baDc28D73be8830A6e",
33
12
  amusdc: "0x1a13F4Ca1d028320A707D99520AbFefca3998b7F",
34
13
  amusdt: "0x60D55F02A771d515e077c9C2403a1ef324885CeC",
35
- am3crv: "0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171", // am3CRV
36
- };
37
- exports.COINS_POLYGON = (0, utils_1.lowerCaseValues)(__assign(__assign(__assign(__assign(__assign({}, exports.BTC_COINS_POLYGON), exports.ETH_COINS_POLYGON), exports.EUR_COINS_POLYGON), exports.USD_COINS_POLYGON), { crv: "0x172370d5cd63279efa6d502dab29171933a610af", matic: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", wmatic: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270" }));
38
- var DECIMALS_POLYGON = {
39
- "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063": 18,
40
- "0x2791bca1f2de4661ed88a30c99a7a9449aa84174": 6,
41
- "0xc2132d05d31c914a87c6611c10748aeb04b58e8f": 6,
42
- "0x27F8D03b3a2196956ED754baDc28D73be8830A6e": 18,
43
- "0x1a13F4Ca1d028320A707D99520AbFefca3998b7F": 6,
44
- "0x60D55F02A771d515e077c9C2403a1ef324885CeC": 6,
45
- "0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171": 18,
46
- "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6": 8,
47
- "0xDBf31dF14B66535aF65AaC99C32e9eA844e14501": 8,
48
- "0x5c2ed810328349100A66B82b78a1791B101C9D61": 8,
49
- "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619": 18,
50
- "0x28424507fefb6f7f8E9D3860F56504E4e5f5f390": 18,
51
- "0x7BDF330f423Ea880FF95fC41A280fD5eCFD3D09f": 6,
52
- "0x172370d5cd63279efa6d502dab29171933a610af": 18,
53
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE": 18, // MATIC
54
- };
14
+ am3crv: "0xE7a24EF0C5e95Ffb0f6684b813A78F2a3AD7D171",
15
+ // --- ETH ---
16
+ weth: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
17
+ amweth: "0x28424507fefb6f7f8E9D3860F56504E4e5f5f390",
18
+ // --- BTC ---
19
+ wbtc: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
20
+ renbtc: "0xDBf31dF14B66535aF65AaC99C32e9eA844e14501",
21
+ amwbtc: "0x5c2ed810328349100A66B82b78a1791B101C9D61",
22
+ // --- MATIC ---
23
+ matic: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
24
+ wmatic: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
25
+ // --- EUR ---
26
+ eurt: "0x7BDF330f423Ea880FF95fC41A280fD5eCFD3D09f", // EURT
27
+ });
55
28
  exports.cTokensPolygon = []; //.map((a) => a.toLowerCase());
56
29
  exports.yTokensPolygon = []; //.map((a) => a.toLowerCase());
57
30
  exports.ycTokensPolygon = []; //.map((a) => a.toLowerCase());
@@ -54,6 +54,8 @@ exports.implementationABIDictEthereum = (0, utils_1.lowerCaseKeys)({
54
54
  "0x24D937143d3F5cF04c72bA112735151A8CAE2262": Plain2Balances_json_1.default,
55
55
  "0x6326DEbBAa15bCFE603d831e7D75f4fc10d9B43E": Plain2ETH_json_1.default,
56
56
  "0x4A4d7868390EF5CaC51cDA262888f34bD3025C3F": Plain2Optimized_json_1.default,
57
+ "0xc629a01eC23AB04E1050500A3717A2a5c0701497": Plain2Basic_json_1.default,
58
+ "0x94b4DFd9Ba5865Cc931195c99A2db42F3fc5d45B": Plain2ETH_json_1.default,
57
59
  "0x9B52F13DF69D79Ec5aAB6D1aCe3157d29B409cC3": Plain3Basic_json_1.default,
58
60
  "0x50b085f2e5958C4A87baf93A8AB79F6bec068494": Plain3Balances_json_1.default,
59
61
  "0x8c1aB78601c259E1B43F19816923609dC7d7de9B": Plain3ETH_json_1.default,
package/lib/index.d.ts CHANGED
@@ -117,7 +117,7 @@ declare const curve: {
117
117
  };
118
118
  router: {
119
119
  getBestRouteAndOutput: (inputCoin: string, outputCoin: string, amount: string | number) => Promise<{
120
- route: import("./interfaces").IRouteStep[];
120
+ route: import("./interfaces").IRoute;
121
121
  output: string;
122
122
  }>;
123
123
  expected: (inputCoin: string, outputCoin: string, amount: string | number) => Promise<string>;
@@ -137,13 +137,14 @@ export interface IRouteStep {
137
137
  swapType: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
138
138
  swapAddress: string;
139
139
  }
140
- export interface IRoute_ {
141
- steps: IRouteStep[];
140
+ export type IRoute = IRouteStep[];
141
+ export interface IRouteTvl {
142
+ route: IRoute;
142
143
  minTvl: number;
143
144
  totalTvl: number;
144
145
  }
145
- export interface IRoute {
146
- steps: IRouteStep[];
146
+ export interface IRouteOutputAndCost {
147
+ route: IRoute;
147
148
  _output: ethers.BigNumber;
148
149
  outputUsd: number;
149
150
  txCostUsd: number;
package/lib/router.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ethers } from "ethers";
2
- import { IRouteStep } from "./interfaces";
2
+ import { IRoute } from "./interfaces";
3
3
  export declare const getBestRouteAndOutput: (inputCoin: string, outputCoin: string, amount: number | string) => Promise<{
4
- route: IRouteStep[];
4
+ route: IRoute;
5
5
  output: string;
6
6
  }>;
7
7
  export declare const swapExpected: (inputCoin: string, outputCoin: string, amount: number | string) => Promise<string>;
package/lib/router.js CHANGED
@@ -67,38 +67,38 @@ var curve_1 = require("./curve");
67
67
  var utils_1 = require("./utils");
68
68
  var pools_1 = require("./pools");
69
69
  var utils_2 = require("./pools/utils");
70
- var getNewRoute = function (route, poolId, poolAddress, inputCoinAddress, outputCoinAddress, i, j, swapType, swapAddress, tvl) {
71
- var routePoolIds = route.steps.map(function (s) { return s.poolId; });
70
+ var getNewRoute = function (routeTvl, poolId, poolAddress, inputCoinAddress, outputCoinAddress, i, j, swapType, swapAddress, tvl) {
71
+ var routePoolIds = routeTvl.route.map(function (s) { return s.poolId; });
72
72
  // Steps <= 4
73
73
  if (routePoolIds.length >= 4)
74
- return { steps: [], minTvl: Infinity, totalTvl: 0 };
74
+ return { route: [], minTvl: Infinity, totalTvl: 0 };
75
75
  // Exclude such cases as cvxeth -> tricrypto2 -> tricrypto2 -> susd
76
76
  if (routePoolIds.includes(poolId))
77
- return { steps: [], minTvl: Infinity, totalTvl: 0 };
77
+ return { route: [], minTvl: Infinity, totalTvl: 0 };
78
78
  return {
79
- steps: __spreadArray(__spreadArray([], route.steps, true), [{ poolId: poolId, poolAddress: poolAddress, inputCoinAddress: inputCoinAddress, outputCoinAddress: outputCoinAddress, i: i, j: j, swapType: swapType, swapAddress: swapAddress }], false),
80
- minTvl: Math.min(tvl, route.minTvl),
81
- totalTvl: route.totalTvl + tvl,
79
+ route: __spreadArray(__spreadArray([], routeTvl.route, true), [{ poolId: poolId, poolAddress: poolAddress, inputCoinAddress: inputCoinAddress, outputCoinAddress: outputCoinAddress, i: i, j: j, swapType: swapType, swapAddress: swapAddress }], false),
80
+ minTvl: Math.min(tvl, routeTvl.minTvl),
81
+ totalTvl: routeTvl.totalTvl + tvl,
82
82
  };
83
83
  };
84
84
  var MAX_ROUTES_FOR_ONE_COIN = 3;
85
85
  var filterRoutes = function (routes, inputCoinAddress, sortFn) {
86
86
  return routes
87
- .filter(function (r) { return r.steps.length > 0; })
88
- .filter(function (r) { return r.steps[0].inputCoinAddress === inputCoinAddress; }) // Truncated routes
87
+ .filter(function (r) { return r.route.length > 0; })
88
+ .filter(function (r) { return r.route[0].inputCoinAddress === inputCoinAddress; }) // Truncated routes
89
89
  .filter(function (r, i, _routes) {
90
- var routesByPoolIds = _routes.map(function (r) { return r.steps.map(function (s) { return s.poolId; }).toString(); });
91
- return routesByPoolIds.indexOf(r.steps.map(function (s) { return s.poolId; }).toString()) === i;
90
+ var routesByPoolIds = _routes.map(function (r) { return r.route.map(function (s) { return s.poolId; }).toString(); });
91
+ return routesByPoolIds.indexOf(r.route.map(function (s) { return s.poolId; }).toString()) === i;
92
92
  }) // Route duplications
93
93
  .sort(sortFn).slice(0, MAX_ROUTES_FOR_ONE_COIN);
94
94
  };
95
- var sortByTvl = function (a, b) { return b.minTvl - a.minTvl || b.totalTvl - a.totalTvl || a.steps.length - b.steps.length; };
96
- var sortByLength = function (a, b) { return a.steps.length - b.steps.length || b.minTvl - a.minTvl || b.totalTvl - a.totalTvl; };
95
+ var sortByTvl = function (a, b) { return b.minTvl - a.minTvl || b.totalTvl - a.totalTvl || a.route.length - b.route.length; };
96
+ var sortByLength = function (a, b) { return a.route.length - b.route.length || b.minTvl - a.minTvl || b.totalTvl - a.totalTvl; };
97
97
  // TODO REMOVE IT!!!
98
98
  var filterMaticFactory83Route = function (routes) {
99
99
  return routes
100
100
  .filter(function (r) {
101
- return !(r.steps.length === 1 && r.steps[0].poolId === "factory-crypto-83" && r.steps[0].inputCoinAddress === curve_1.curve.constants.NATIVE_TOKEN.address);
101
+ return !(r.route.length === 1 && r.route[0].poolId === "factory-crypto-83" && r.route[0].inputCoinAddress === curve_1.curve.constants.NATIVE_TOKEN.address);
102
102
  });
103
103
  };
104
104
  // Inspired by Dijkstra's algorithm
@@ -118,10 +118,10 @@ var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __a
118
118
  curCoins = [inputCoinAddress];
119
119
  nextCoins = new Set();
120
120
  routesByTvl = (_a = {},
121
- _a[inputCoinAddress] = [{ steps: [], minTvl: Infinity, totalTvl: 0 }],
121
+ _a[inputCoinAddress] = [{ route: [], minTvl: Infinity, totalTvl: 0 }],
122
122
  _a);
123
123
  routesByLength = (_b = {},
124
- _b[inputCoinAddress] = [{ steps: [], minTvl: Infinity, totalTvl: 0 }],
124
+ _b[inputCoinAddress] = [{ route: [], minTvl: Infinity, totalTvl: 0 }],
125
125
  _b);
126
126
  step = 0;
127
127
  _s.label = 2;
@@ -337,26 +337,28 @@ var _findAllRoutes = function (inputCoinAddress, outputCoinAddress) { return __a
337
337
  // TODO REMOVE IT!!!
338
338
  if (curve_1.curve.chainId === 137)
339
339
  routes = filterMaticFactory83Route(routes);
340
- return [2 /*return*/, routes.map(function (r) { return r.steps; })];
340
+ return [2 /*return*/, routes.map(function (r) { return r.route; })];
341
341
  }
342
342
  });
343
343
  }); };
344
344
  var _getRouteKey = function (route, inputCoinAddress, outputCoinAddress) {
345
345
  var sortedCoins = [inputCoinAddress, outputCoinAddress].sort();
346
346
  var key = "".concat(sortedCoins[0], "-->");
347
- for (var _i = 0, _a = route.steps; _i < _a.length; _i++) {
348
- var routeStep = _a[_i];
347
+ for (var _i = 0, route_1 = route; _i < route_1.length; _i++) {
348
+ var routeStep = route_1[_i];
349
349
  key += "".concat(routeStep.poolId, "-->");
350
350
  }
351
351
  key += sortedCoins[1];
352
352
  return key;
353
353
  };
354
- var _getExchangeMultipleArgs = function (inputCoinAddress, route) {
355
- var _route = [inputCoinAddress];
354
+ var _getExchangeMultipleArgs = function (route) {
355
+ var _route = [];
356
+ if (route.length > 0)
357
+ _route.push(route[0].inputCoinAddress);
356
358
  var _swapParams = [];
357
359
  var _factorySwapAddresses = [];
358
- for (var _i = 0, _a = route.steps; _i < _a.length; _i++) {
359
- var routeStep = _a[_i];
360
+ for (var _i = 0, route_2 = route; _i < route_2.length; _i++) {
361
+ var routeStep = route_2[_i];
360
362
  _route.push(routeStep.poolAddress, routeStep.outputCoinAddress);
361
363
  _swapParams.push([routeStep.i, routeStep.j, routeStep.swapType]);
362
364
  _factorySwapAddresses.push(routeStep.swapAddress);
@@ -382,7 +384,7 @@ var _estimateGasForDifferentRoutes = function (routes, inputCoinAddress, outputC
382
384
  route = routes_1[_i];
383
385
  routeKey = _getRouteKey(route, inputCoinAddress, outputCoinAddress);
384
386
  gasPromise = void 0;
385
- _a = _getExchangeMultipleArgs(inputCoinAddress, route), _route = _a._route, _swapParams = _a._swapParams, _factorySwapAddresses = _a._factorySwapAddresses;
387
+ _a = _getExchangeMultipleArgs(route), _route = _a._route, _swapParams = _a._swapParams, _factorySwapAddresses = _a._factorySwapAddresses;
386
388
  if ((((_b = _estimatedGasForDifferentRoutesCache[routeKey]) === null || _b === void 0 ? void 0 : _b.time) || 0) + 3600000 < Date.now()) {
387
389
  gasPromise = contract.estimateGas.exchange_multiple(_route, _swapParams, _amount, 0, _factorySwapAddresses, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }));
388
390
  }
@@ -409,23 +411,18 @@ var _estimateGasForDifferentRoutes = function (routes, inputCoinAddress, outputC
409
411
  }
410
412
  });
411
413
  }); };
412
- var _getBestRouteAndOutput = (0, memoizee_1.default)(function (inputCoinAddress, outputCoinAddress, amount) { return __awaiter(void 0, void 0, void 0, function () {
413
- var _a, inputCoinDecimals, outputCoinDecimals, _amount, routesRaw, routes, calls, multicallContract, _i, routesRaw_1, route, _b, _route, _swapParams, _factorySwapAddresses, _outputAmounts, i, err_2, promises, contract, _c, routesRaw_2, route, _d, _route, _swapParams, _factorySwapAddresses, res, i, _e, gasAmounts, outputCoinUsdRate, gasData, ethUsdRate, gasPrice, expectedAmounts, expectedAmountsUsd, txCostsUsd;
414
+ var _getBestRoute = (0, memoizee_1.default)(function (inputCoinAddress, outputCoinAddress, amount) { return __awaiter(void 0, void 0, void 0, function () {
415
+ var _a, inputCoinDecimals, outputCoinDecimals, _amount, routesRaw, routes, calls, multicallContract, _i, routesRaw_1, r, _b, _route, _swapParams, _factorySwapAddresses, _outputAmounts, i, err_2, promises, contract, _c, routesRaw_2, r, _d, _route, _swapParams, _factorySwapAddresses, res, i, _e, gasAmounts, outputCoinUsdRate, gasData, ethUsdRate, gasPrice, expectedAmounts, expectedAmountsUsd, txCostsUsd;
414
416
  return __generator(this, function (_f) {
415
417
  switch (_f.label) {
416
418
  case 0:
417
419
  _a = (0, utils_1._getCoinDecimals)(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _a[0], outputCoinDecimals = _a[1];
418
420
  _amount = (0, utils_1.parseUnits)(amount, inputCoinDecimals);
419
421
  if (_amount.eq(0))
420
- return [2 /*return*/, {
421
- steps: [],
422
- _output: ethers_1.ethers.BigNumber.from(0),
423
- outputUsd: 0,
424
- txCostUsd: 0,
425
- }];
422
+ return [2 /*return*/, []];
426
423
  return [4 /*yield*/, _findAllRoutes(inputCoinAddress, outputCoinAddress)];
427
424
  case 1:
428
- routesRaw = (_f.sent()).map(function (steps) { return ({ steps: steps, _output: ethers_1.ethers.BigNumber.from(0), outputUsd: 0, txCostUsd: 0 }); });
425
+ routesRaw = (_f.sent()).map(function (route) { return ({ route: route, _output: ethers_1.ethers.BigNumber.from(0), outputUsd: 0, txCostUsd: 0 }); });
429
426
  routes = [];
430
427
  _f.label = 2;
431
428
  case 2:
@@ -433,8 +430,8 @@ var _getBestRouteAndOutput = (0, memoizee_1.default)(function (inputCoinAddress,
433
430
  calls = [];
434
431
  multicallContract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.registry_exchange].multicallContract;
435
432
  for (_i = 0, routesRaw_1 = routesRaw; _i < routesRaw_1.length; _i++) {
436
- route = routesRaw_1[_i];
437
- _b = _getExchangeMultipleArgs(inputCoinAddress, route), _route = _b._route, _swapParams = _b._swapParams, _factorySwapAddresses = _b._factorySwapAddresses;
433
+ r = routesRaw_1[_i];
434
+ _b = _getExchangeMultipleArgs(r.route), _route = _b._route, _swapParams = _b._swapParams, _factorySwapAddresses = _b._factorySwapAddresses;
438
435
  calls.push(multicallContract.get_exchange_multiple_amount(_route, _swapParams, _amount, _factorySwapAddresses));
439
436
  }
440
437
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(calls)];
@@ -450,8 +447,8 @@ var _getBestRouteAndOutput = (0, memoizee_1.default)(function (inputCoinAddress,
450
447
  promises = [];
451
448
  contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.registry_exchange].contract;
452
449
  for (_c = 0, routesRaw_2 = routesRaw; _c < routesRaw_2.length; _c++) {
453
- route = routesRaw_2[_c];
454
- _d = _getExchangeMultipleArgs(inputCoinAddress, route), _route = _d._route, _swapParams = _d._swapParams, _factorySwapAddresses = _d._factorySwapAddresses;
450
+ r = routesRaw_2[_c];
451
+ _d = _getExchangeMultipleArgs(r.route), _route = _d._route, _swapParams = _d._swapParams, _factorySwapAddresses = _d._factorySwapAddresses;
455
452
  promises.push(contract.get_exchange_multiple_amount(_route, _swapParams, _amount, _factorySwapAddresses, curve_1.curve.constantOptions));
456
453
  }
457
454
  return [4 /*yield*/, Promise.allSettled(promises)];
@@ -459,7 +456,7 @@ var _getBestRouteAndOutput = (0, memoizee_1.default)(function (inputCoinAddress,
459
456
  res = _f.sent();
460
457
  for (i = 0; i < res.length; i++) {
461
458
  if (res[i].status === 'rejected') {
462
- console.log("Route ".concat((routesRaw[i].steps.map(function (s) { return s.poolId; })).join(" --> "), " is unavailable"));
459
+ console.log("Route ".concat((routesRaw[i].route.map(function (s) { return s.poolId; })).join(" --> "), " is unavailable"));
463
460
  continue;
464
461
  }
465
462
  routesRaw[i]._output = res[i].value;
@@ -467,18 +464,12 @@ var _getBestRouteAndOutput = (0, memoizee_1.default)(function (inputCoinAddress,
467
464
  }
468
465
  return [3 /*break*/, 6];
469
466
  case 6:
470
- if (routes.length === 0) {
471
- return [2 /*return*/, {
472
- steps: [],
473
- _output: ethers_1.ethers.BigNumber.from(0),
474
- outputUsd: 0,
475
- txCostUsd: 0,
476
- }];
477
- }
467
+ if (routes.length === 0)
468
+ return [2 /*return*/, []];
478
469
  if (routes.length === 1)
479
- return [2 /*return*/, routes[0]];
470
+ return [2 /*return*/, routes[0].route];
480
471
  return [4 /*yield*/, Promise.all([
481
- _estimateGasForDifferentRoutes(routes, inputCoinAddress, outputCoinAddress, _amount),
472
+ _estimateGasForDifferentRoutes(routes.map(function (r) { return r.route; }), inputCoinAddress, outputCoinAddress, _amount),
482
473
  (0, utils_1._getUsdRate)(outputCoinAddress),
483
474
  axios_1.default.get("https://api.curve.fi/api/getGas"),
484
475
  (0, utils_1._getUsdRate)(utils_1.ETH_ADDRESS),
@@ -497,27 +488,45 @@ var _getBestRouteAndOutput = (0, memoizee_1.default)(function (inputCoinAddress,
497
488
  var diff = (route1.outputUsd - route1.txCostUsd) - (route2.outputUsd - route2.txCostUsd);
498
489
  if (diff > 0)
499
490
  return route1;
500
- if (diff === 0 && route1.steps.length < route2.steps.length)
491
+ if (diff === 0 && route1.route.length < route2.route.length)
501
492
  return route1;
502
493
  return route2;
503
- })];
494
+ }).route];
504
495
  }
505
496
  });
506
497
  }); }, {
507
498
  promise: true,
508
499
  maxAge: 5 * 60 * 1000, // 5m
509
500
  });
501
+ var _getOutputForRoute = (0, memoizee_1.default)(function (route, _amount) { return __awaiter(void 0, void 0, void 0, function () {
502
+ var contract, _a, _route, _swapParams, _factorySwapAddresses;
503
+ return __generator(this, function (_b) {
504
+ switch (_b.label) {
505
+ case 0:
506
+ contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.registry_exchange].contract;
507
+ _a = _getExchangeMultipleArgs(route), _route = _a._route, _swapParams = _a._swapParams, _factorySwapAddresses = _a._factorySwapAddresses;
508
+ return [4 /*yield*/, contract.get_exchange_multiple_amount(_route, _swapParams, _amount, _factorySwapAddresses, curve_1.curve.constantOptions)];
509
+ case 1: return [2 /*return*/, _b.sent()];
510
+ }
511
+ });
512
+ }); }, {
513
+ promise: true,
514
+ maxAge: 15 * 1000, // 15s
515
+ });
510
516
  var getBestRouteAndOutput = function (inputCoin, outputCoin, amount) { return __awaiter(void 0, void 0, void 0, function () {
511
- var _a, inputCoinAddress, outputCoinAddress, outputCoinDecimals, _b, steps, _output;
517
+ var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, route, _output;
512
518
  return __generator(this, function (_c) {
513
519
  switch (_c.label) {
514
520
  case 0:
515
521
  _a = (0, utils_1._getCoinAddresses)(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
516
- outputCoinDecimals = (0, utils_1._getCoinDecimals)(outputCoinAddress)[0];
517
- return [4 /*yield*/, _getBestRouteAndOutput(inputCoinAddress, outputCoinAddress, amount)];
522
+ _b = (0, utils_1._getCoinDecimals)(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _b[0], outputCoinDecimals = _b[1];
523
+ return [4 /*yield*/, _getBestRoute(inputCoinAddress, outputCoinAddress, amount)];
518
524
  case 1:
519
- _b = _c.sent(), steps = _b.steps, _output = _b._output;
520
- return [2 /*return*/, { route: steps, output: ethers_1.ethers.utils.formatUnits(_output, outputCoinDecimals) }];
525
+ route = _c.sent();
526
+ return [4 /*yield*/, _getOutputForRoute(route, (0, utils_1.parseUnits)(amount, inputCoinDecimals))];
527
+ case 2:
528
+ _output = _c.sent();
529
+ return [2 /*return*/, { route: route, output: ethers_1.ethers.utils.formatUnits(_output, outputCoinDecimals) }];
521
530
  }
522
531
  });
523
532
  }); };
@@ -532,37 +541,37 @@ var swapExpected = function (inputCoin, outputCoin, amount) { return __awaiter(v
532
541
  }); };
533
542
  exports.swapExpected = swapExpected;
534
543
  var swapPriceImpact = function (inputCoin, outputCoin, amount) { return __awaiter(void 0, void 0, void 0, function () {
535
- var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, route, _amount, _output, smallAmountIntBN, amountIntBN, contract, _smallAmount, _c, _route, _swapParams, _factorySwapAddresses, _smallOutput, e_1, priceImpactBN;
536
- return __generator(this, function (_d) {
537
- switch (_d.label) {
544
+ var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, _c, route, output, _amount, _output, smallAmountIntBN, amountIntBN, contract, _smallAmount, _d, _route, _swapParams, _factorySwapAddresses, _smallOutput, e_1, priceImpactBN;
545
+ return __generator(this, function (_e) {
546
+ switch (_e.label) {
538
547
  case 0:
539
548
  _a = (0, utils_1._getCoinAddresses)(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
540
549
  _b = (0, utils_1._getCoinDecimals)(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _b[0], outputCoinDecimals = _b[1];
541
- return [4 /*yield*/, _getBestRouteAndOutput(inputCoinAddress, outputCoinAddress, amount)];
550
+ return [4 /*yield*/, (0, exports.getBestRouteAndOutput)(inputCoinAddress, outputCoinAddress, amount)];
542
551
  case 1:
543
- route = _d.sent();
552
+ _c = _e.sent(), route = _c.route, output = _c.output;
544
553
  _amount = (0, utils_1.parseUnits)(amount, inputCoinDecimals);
545
- _output = route._output;
554
+ _output = (0, utils_1.parseUnits)(output, outputCoinDecimals);
546
555
  smallAmountIntBN = (0, utils_1._get_small_x)(_amount, _output, inputCoinDecimals, outputCoinDecimals);
547
556
  amountIntBN = (0, utils_1.toBN)(_amount, 0);
548
557
  if (smallAmountIntBN.gte(amountIntBN))
549
558
  return [2 /*return*/, 0];
550
559
  contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.registry_exchange].contract;
551
560
  _smallAmount = (0, utils_1.fromBN)(smallAmountIntBN.div(Math.pow(10, inputCoinDecimals)), inputCoinDecimals);
552
- _c = _getExchangeMultipleArgs(inputCoinAddress, route), _route = _c._route, _swapParams = _c._swapParams, _factorySwapAddresses = _c._factorySwapAddresses;
553
- _d.label = 2;
561
+ _d = _getExchangeMultipleArgs(route), _route = _d._route, _swapParams = _d._swapParams, _factorySwapAddresses = _d._factorySwapAddresses;
562
+ _e.label = 2;
554
563
  case 2:
555
- _d.trys.push([2, 4, , 6]);
564
+ _e.trys.push([2, 4, , 6]);
556
565
  return [4 /*yield*/, contract.get_exchange_multiple_amount(_route, _swapParams, _smallAmount, _factorySwapAddresses, curve_1.curve.constantOptions)];
557
566
  case 3:
558
- _smallOutput = _d.sent();
567
+ _smallOutput = _e.sent();
559
568
  return [3 /*break*/, 6];
560
569
  case 4:
561
- e_1 = _d.sent();
570
+ e_1 = _e.sent();
562
571
  _smallAmount = ethers_1.ethers.utils.parseUnits("1", inputCoinDecimals); // Dirty hack
563
572
  return [4 /*yield*/, contract.get_exchange_multiple_amount(_route, _swapParams, _smallAmount, _factorySwapAddresses, curve_1.curve.constantOptions)];
564
573
  case 5:
565
- _smallOutput = _d.sent();
574
+ _smallOutput = _e.sent();
566
575
  return [3 /*break*/, 6];
567
576
  case 6:
568
577
  priceImpactBN = (0, utils_1._get_price_impact)(_amount, _output, _smallAmount, _smallOutput, inputCoinDecimals, outputCoinDecimals);
@@ -605,10 +614,10 @@ var swapEstimateGas = function (inputCoin, outputCoin, amount) { return __awaite
605
614
  case 0:
606
615
  _a = (0, utils_1._getCoinAddresses)(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
607
616
  inputCoinDecimals = (0, utils_1._getCoinDecimals)(inputCoinAddress, outputCoinAddress)[0];
608
- return [4 /*yield*/, _getBestRouteAndOutput(inputCoinAddress, outputCoinAddress, amount)];
617
+ return [4 /*yield*/, (0, exports.getBestRouteAndOutput)(inputCoinAddress, outputCoinAddress, amount)];
609
618
  case 1:
610
- route = _b.sent();
611
- if (route.steps.length === 0)
619
+ route = (_b.sent()).route;
620
+ if (route.length === 0)
612
621
  return [2 /*return*/, 0];
613
622
  _amount = (0, utils_1.parseUnits)(amount, inputCoinDecimals);
614
623
  return [4 /*yield*/, _estimateGasForDifferentRoutes([route], inputCoinAddress, outputCoinAddress, _amount)];
@@ -622,35 +631,35 @@ exports.swapEstimateGas = swapEstimateGas;
622
631
  var swap = function (inputCoin, outputCoin, amount, slippage) {
623
632
  if (slippage === void 0) { slippage = 0.5; }
624
633
  return __awaiter(void 0, void 0, void 0, function () {
625
- var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, route, _c, _route, _swapParams, _factorySwapAddresses, _amount, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit;
626
- return __generator(this, function (_d) {
627
- switch (_d.label) {
634
+ var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, _c, route, output, _d, _route, _swapParams, _factorySwapAddresses, _amount, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit;
635
+ return __generator(this, function (_e) {
636
+ switch (_e.label) {
628
637
  case 0:
629
638
  _a = (0, utils_1._getCoinAddresses)(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
630
639
  _b = (0, utils_1._getCoinDecimals)(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _b[0], outputCoinDecimals = _b[1];
631
640
  return [4 /*yield*/, (0, exports.swapApprove)(inputCoin, amount)];
632
641
  case 1:
633
- _d.sent();
634
- return [4 /*yield*/, _getBestRouteAndOutput(inputCoinAddress, outputCoinAddress, amount)];
642
+ _e.sent();
643
+ return [4 /*yield*/, (0, exports.getBestRouteAndOutput)(inputCoinAddress, outputCoinAddress, amount)];
635
644
  case 2:
636
- route = _d.sent();
637
- if (route.steps.length === 0) {
645
+ _c = _e.sent(), route = _c.route, output = _c.output;
646
+ if (route.length === 0) {
638
647
  throw new Error("This pair can't be exchanged");
639
648
  }
640
- _c = _getExchangeMultipleArgs(inputCoinAddress, route), _route = _c._route, _swapParams = _c._swapParams, _factorySwapAddresses = _c._factorySwapAddresses;
649
+ _d = _getExchangeMultipleArgs(route), _route = _d._route, _swapParams = _d._swapParams, _factorySwapAddresses = _d._factorySwapAddresses;
641
650
  _amount = (0, utils_1.parseUnits)(amount, inputCoinDecimals);
642
- minRecvAmountBN = (0, utils_1.toBN)(route._output, outputCoinDecimals).times(100 - slippage).div(100);
651
+ minRecvAmountBN = (0, utils_1.BN)(output).times(100 - slippage).div(100);
643
652
  _minRecvAmount = (0, utils_1.fromBN)(minRecvAmountBN, outputCoinDecimals);
644
653
  contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.registry_exchange].contract;
645
654
  value = (0, utils_1.isEth)(inputCoinAddress) ? _amount : ethers_1.ethers.BigNumber.from(0);
646
655
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
647
656
  case 3:
648
- _d.sent();
657
+ _e.sent();
649
658
  return [4 /*yield*/, contract.estimateGas.exchange_multiple(_route, _swapParams, _amount, _minRecvAmount, _factorySwapAddresses, __assign(__assign({}, curve_1.curve.constantOptions), { value: value }))];
650
659
  case 4:
651
- gasLimit = (_d.sent()).mul(curve_1.curve.chainId === 1 ? 130 : 160).div(100);
660
+ gasLimit = (_e.sent()).mul(curve_1.curve.chainId === 1 ? 130 : 160).div(100);
652
661
  return [4 /*yield*/, contract.exchange_multiple(_route, _swapParams, _amount, _minRecvAmount, _factorySwapAddresses, __assign(__assign({}, curve_1.curve.options), { value: value, gasLimit: gasLimit }))];
653
- case 5: return [2 /*return*/, _d.sent()];
662
+ case 5: return [2 /*return*/, _e.sent()];
654
663
  }
655
664
  });
656
665
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.28.1",
3
+ "version": "2.28.3",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",