@curvefi/api 1.11.0 → 1.15.0

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.
Files changed (52) hide show
  1. package/README.md +68 -0
  2. package/lib/constants/abis/abis-ethereum.js +144 -16
  3. package/lib/constants/abis/abis-polygon.js +17 -1
  4. package/lib/constants/abis/json/aave/rewards.json +107 -0
  5. package/lib/constants/abis/json/atricrypto3/swap.json +63 -63
  6. package/lib/constants/abis/json/atricrypto3/zap.json +8 -8
  7. package/lib/constants/abis/json/busd/deposit.json +5 -10
  8. package/lib/constants/abis/json/busd/swap.json +18 -36
  9. package/lib/constants/abis/json/compound/deposit.json +5 -10
  10. package/lib/constants/abis/json/compound/migration.json +1 -2
  11. package/lib/constants/abis/json/compound/oldSwap.json +16 -32
  12. package/lib/constants/abis/json/compound/swap.json +18 -36
  13. package/lib/constants/abis/json/crveth/swap.json +61 -61
  14. package/lib/constants/abis/json/eurt/swap.json +29 -29
  15. package/lib/constants/abis/json/eurtusd/deposit.json +13 -13
  16. package/lib/constants/abis/json/eurtusd/swap.json +59 -59
  17. package/lib/constants/abis/json/gauge.json +1 -1
  18. package/lib/constants/abis/json/gauge_factory.json +879 -0
  19. package/lib/constants/abis/json/gauge_rewards_only.json +649 -0
  20. package/lib/constants/abis/json/gauge_synthetix.json +590 -0
  21. package/lib/constants/abis/json/gauge_v2.json +942 -0
  22. package/lib/constants/abis/json/gauge_v3.json +954 -0
  23. package/lib/constants/abis/json/gauge_v4.json +913 -0
  24. package/lib/constants/abis/json/iearn/deposit.json +5 -10
  25. package/lib/constants/abis/json/iearn/swap.json +18 -36
  26. package/lib/constants/abis/json/minter.json +165 -0
  27. package/lib/constants/abis/json/pax/deposit.json +5 -10
  28. package/lib/constants/abis/json/pax/swap.json +19 -38
  29. package/lib/constants/abis/json/ren/swap.json +19 -38
  30. package/lib/constants/abis/json/ren-polygon/swap.json +46 -46
  31. package/lib/constants/abis/json/reth/swap.json +38 -38
  32. package/lib/constants/abis/json/sbtc/swap.json +19 -38
  33. package/lib/constants/abis/json/streamer.json +257 -0
  34. package/lib/constants/abis/json/susdv2/deposit.json +5 -10
  35. package/lib/constants/abis/json/susdv2/swap.json +16 -32
  36. package/lib/constants/abis/json/tricrypto2/deposit.json +3 -3
  37. package/lib/constants/abis/json/tricrypto2/swap.json +60 -60
  38. package/lib/constants/abis/json/usdt/deposit.json +5 -10
  39. package/lib/constants/abis/json/usdt/swap.json +19 -37
  40. package/lib/constants/aliases.d.ts +2 -0
  41. package/lib/constants/aliases.js +3 -1
  42. package/lib/constants/coins-ethereum.js +4 -2
  43. package/lib/constants/coins-polygon.js +3 -2
  44. package/lib/curve.d.ts +2 -1
  45. package/lib/curve.js +73 -30
  46. package/lib/index.d.ts +1 -1
  47. package/lib/interfaces.d.ts +8 -0
  48. package/lib/pools.d.ts +36 -5
  49. package/lib/pools.js +313 -52
  50. package/lib/utils.d.ts +1 -1
  51. package/lib/utils.js +40 -29
  52. package/package.json +1 -1
@@ -267,12 +267,11 @@
267
267
  "outputs": [
268
268
  {
269
269
  "type": "uint256",
270
- "name": "out"
270
+ "name": ""
271
271
  }
272
272
  ],
273
273
  "inputs": [],
274
- "constant": true,
275
- "payable": false,
274
+ "stateMutability": "view",
276
275
  "type": "function",
277
276
  "gas": "1327351"
278
277
  },
@@ -294,8 +293,7 @@
294
293
  "name": "deposit"
295
294
  }
296
295
  ],
297
- "constant": true,
298
- "payable": false,
296
+ "stateMutability": "view",
299
297
  "type": "function",
300
298
  "gas": "5171741"
301
299
  },
@@ -339,8 +337,7 @@
339
337
  "name": "dx"
340
338
  }
341
339
  ],
342
- "constant": true,
343
- "payable": false,
340
+ "stateMutability": "view",
344
341
  "type": "function",
345
342
  "gas": "3016651"
346
343
  },
@@ -366,8 +363,7 @@
366
363
  "name": "dy"
367
364
  }
368
365
  ],
369
- "constant": true,
370
- "payable": false,
366
+ "stateMutability": "view",
371
367
  "type": "function",
372
368
  "gas": "3016657"
373
369
  },
@@ -393,8 +389,7 @@
393
389
  "name": "dx"
394
390
  }
395
391
  ],
396
- "constant": true,
397
- "payable": false,
392
+ "stateMutability": "view",
398
393
  "type": "function",
399
394
  "gas": "3016494"
400
395
  },
@@ -420,8 +415,7 @@
420
415
  "name": "dy"
421
416
  }
422
417
  ],
423
- "constant": true,
424
- "payable": false,
418
+ "stateMutability": "view",
425
419
  "type": "function",
426
420
  "gas": "3016500"
427
421
  },
@@ -626,8 +620,7 @@
626
620
  "name": "arg0"
627
621
  }
628
622
  ],
629
- "constant": true,
630
- "payable": false,
623
+ "stateMutability": "view",
631
624
  "type": "function",
632
625
  "gas": "2190"
633
626
  },
@@ -645,8 +638,7 @@
645
638
  "name": "arg0"
646
639
  }
647
640
  ],
648
- "constant": true,
649
- "payable": false,
641
+ "stateMutability": "view",
650
642
  "type": "function",
651
643
  "gas": "2220"
652
644
  },
@@ -677,8 +669,7 @@
677
669
  }
678
670
  ],
679
671
  "inputs": [],
680
- "constant": true,
681
- "payable": false,
672
+ "stateMutability": "view",
682
673
  "type": "function",
683
674
  "gas": "2081"
684
675
  },
@@ -691,8 +682,7 @@
691
682
  }
692
683
  ],
693
684
  "inputs": [],
694
- "constant": true,
695
- "payable": false,
685
+ "stateMutability": "view",
696
686
  "type": "function",
697
687
  "gas": "2111"
698
688
  },
@@ -705,8 +695,7 @@
705
695
  }
706
696
  ],
707
697
  "inputs": [],
708
- "constant": true,
709
- "payable": false,
698
+ "stateMutability": "view",
710
699
  "type": "function",
711
700
  "gas": "2141"
712
701
  },
@@ -719,8 +708,7 @@
719
708
  }
720
709
  ],
721
710
  "inputs": [],
722
- "constant": true,
723
- "payable": false,
711
+ "stateMutability": "view",
724
712
  "type": "function",
725
713
  "gas": "2171"
726
714
  },
@@ -734,8 +722,7 @@
734
722
  }
735
723
  ],
736
724
  "inputs": [],
737
- "constant": true,
738
- "payable": false,
725
+ "stateMutability": "view",
739
726
  "type": "function",
740
727
  "gas": "2201"
741
728
  },
@@ -749,8 +736,7 @@
749
736
  }
750
737
  ],
751
738
  "inputs": [],
752
- "constant": true,
753
- "payable": false,
739
+ "stateMutability": "view",
754
740
  "type": "function",
755
741
  "gas": "2231"
756
742
  },
@@ -763,8 +749,7 @@
763
749
  }
764
750
  ],
765
751
  "inputs": [],
766
- "constant": true,
767
- "payable": false,
752
+ "stateMutability": "view",
768
753
  "type": "function",
769
754
  "gas": "2261"
770
755
  },
@@ -777,8 +762,7 @@
777
762
  }
778
763
  ],
779
764
  "inputs": [],
780
- "constant": true,
781
- "payable": false,
765
+ "stateMutability": "view",
782
766
  "type": "function",
783
767
  "gas": "2291"
784
768
  },
@@ -791,8 +775,7 @@
791
775
  }
792
776
  ],
793
777
  "inputs": [],
794
- "constant": true,
795
- "payable": false,
778
+ "stateMutability": "view",
796
779
  "type": "function",
797
780
  "gas": "2321"
798
781
  },
@@ -805,8 +788,7 @@
805
788
  }
806
789
  ],
807
790
  "inputs": [],
808
- "constant": true,
809
- "payable": false,
791
+ "stateMutability": "view",
810
792
  "type": "function",
811
793
  "gas": "2351"
812
794
  }
@@ -1,5 +1,6 @@
1
1
  export declare const ALIASES_ETHEREUM: {
2
2
  crv: string;
3
+ minter: string;
3
4
  voting_escrow: string;
4
5
  gauge_controller: string;
5
6
  address_provider: string;
@@ -8,6 +9,7 @@ export declare const ALIASES_ETHEREUM: {
8
9
  };
9
10
  export declare const ALIASES_POLYGON: {
10
11
  crv: string;
12
+ minter: string;
11
13
  voting_escrow: string;
12
14
  gauge_controller: string;
13
15
  address_provider: string;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ALIASES_POLYGON = exports.ALIASES_ETHEREUM = void 0;
4
4
  exports.ALIASES_ETHEREUM = {
5
5
  "crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
6
+ "minter": "0xd061D61a4d941c39E5453435B6345Dc261C2fcE0",
6
7
  "voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
7
8
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
8
9
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
@@ -10,7 +11,8 @@ exports.ALIASES_ETHEREUM = {
10
11
  "registry_exchange": "",
11
12
  };
12
13
  exports.ALIASES_POLYGON = {
13
- "crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
14
+ "crv": "0x172370d5cd63279efa6d502dab29171933a610af",
15
+ "minter": "",
14
16
  "voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
15
17
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
16
18
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
@@ -90,7 +90,8 @@ exports.USD_COINS_ETHEREUM = {
90
90
  alusd: "0xbc6da0fe9ad5f3b0d58160288917aa56653660e9",
91
91
  mim: "0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3",
92
92
  '3crv': "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490",
93
- crv: "0xD533a949740bb3306d119CC777fa900bA034cd52", // CRV
93
+ crv: "0xD533a949740bb3306d119CC777fa900bA034cd52",
94
+ cvx: "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", // CVX
94
95
  };
95
96
  // @ts-ignore
96
97
  exports.USD_COINS_LOWER_CASE_ETHEREUM = Object.fromEntries(Object.entries(exports.USD_COINS_ETHEREUM).map(function (entry) { return [entry[0], entry[1].toLowerCase()]; }));
@@ -158,7 +159,8 @@ exports.DECIMALS_ETHEREUM = {
158
159
  "0xbc6da0fe9ad5f3b0d58160288917aa56653660e9": 18,
159
160
  "0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3": 18,
160
161
  "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490": 18,
161
- "0xD533a949740bb3306d119CC777fa900bA034cd52": 18, // CRV
162
+ "0xD533a949740bb3306d119CC777fa900bA034cd52": 18,
163
+ "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b": 18, // CVX
162
164
  };
163
165
  // @ts-ignore
164
166
  exports.DECIMALS_LOWER_CASE_ETHEREUM = Object.fromEntries(Object.entries(exports.DECIMALS_ETHEREUM).map(function (entry) { return [entry[0].toLowerCase(), entry[1]]; }));
@@ -44,7 +44,7 @@ exports.USD_COINS_POLYGON = {
44
44
  };
45
45
  // @ts-ignore
46
46
  exports.USD_COINS_LOWER_CASE_POLYGON = Object.fromEntries(Object.entries(exports.USD_COINS_POLYGON).map(function (entry) { return [entry[0], entry[1].toLowerCase()]; }));
47
- exports.COINS_POLYGON = __assign(__assign(__assign(__assign(__assign({}, exports.BTC_COINS_POLYGON), exports.ETH_COINS_POLYGON), exports.LINK_COINS_POLYGON), exports.EUR_COINS_POLYGON), exports.USD_COINS_POLYGON);
47
+ exports.COINS_POLYGON = __assign(__assign(__assign(__assign(__assign(__assign({}, exports.BTC_COINS_POLYGON), exports.ETH_COINS_POLYGON), exports.LINK_COINS_POLYGON), exports.EUR_COINS_POLYGON), exports.USD_COINS_POLYGON), { crv: "0x172370d5cd63279efa6d502dab29171933a610af" });
48
48
  exports.DECIMALS_POLYGON = {
49
49
  "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063": 18,
50
50
  "0x2791bca1f2de4661ed88a30c99a7a9449aa84174": 6,
@@ -58,7 +58,8 @@ exports.DECIMALS_POLYGON = {
58
58
  "0x5c2ed810328349100A66B82b78a1791B101C9D61": 8,
59
59
  "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619": 18,
60
60
  "0x28424507fefb6f7f8E9D3860F56504E4e5f5f390": 18,
61
- "0x7BDF330f423Ea880FF95fC41A280fD5eCFD3D09f": 6, // EURT
61
+ "0x7BDF330f423Ea880FF95fC41A280fD5eCFD3D09f": 6,
62
+ "0x172370d5cd63279efa6d502dab29171933a610af": 18, // CRV
62
63
  };
63
64
  // @ts-ignore
64
65
  exports.DECIMALS_LOWER_CASE_POLYGON = Object.fromEntries(Object.entries(exports.DECIMALS_POLYGON).map(function (entry) { return [entry[0].toLowerCase(), entry[1]]; }));
package/lib/curve.d.ts CHANGED
@@ -22,6 +22,7 @@ export declare let DECIMALS: DictInterface<number>;
22
22
  export declare let DECIMALS_LOWER_CASE: DictInterface<number>;
23
23
  export declare let ALIASES: {
24
24
  crv: string;
25
+ minter: string;
25
26
  voting_escrow: string;
26
27
  gauge_controller: string;
27
28
  address_provider: string;
@@ -54,7 +55,7 @@ declare class Curve {
54
55
  maxPriorityFeePerGas?: number | ethers.BigNumber;
55
56
  };
56
57
  constructor();
57
- init(providerType: 'JsonRpc' | 'Web3' | 'Infura', providerSettings: {
58
+ init(providerType: 'JsonRpc' | 'Web3' | 'Infura' | 'Alchemy', providerSettings: {
58
59
  url?: string;
59
60
  privateKey?: string;
60
61
  } | {
package/lib/curve.js CHANGED
@@ -65,12 +65,13 @@ var ethcall_1 = require("ethcall");
65
65
  var ERC20_json_1 = __importDefault(require("./constants/abis/json/ERC20.json"));
66
66
  var cERC20_json_1 = __importDefault(require("./constants/abis/json/cERC20.json"));
67
67
  var yERC20_json_1 = __importDefault(require("./constants/abis/json/yERC20.json"));
68
- var gauge_json_1 = __importDefault(require("./constants/abis/json/gauge.json"));
68
+ var minter_json_1 = __importDefault(require("./constants/abis/json/minter.json"));
69
69
  var votingescrow_json_1 = __importDefault(require("./constants/abis/json/votingescrow.json"));
70
70
  var address_provider_json_1 = __importDefault(require("./constants/abis/json/address_provider.json"));
71
71
  var gaugecontroller_json_1 = __importDefault(require("./constants/abis/json/gaugecontroller.json"));
72
72
  var router_json_1 = __importDefault(require("./constants/abis/json/router.json"));
73
73
  var registry_exchange_json_1 = __importDefault(require("./constants/abis/json/registry_exchange.json"));
74
+ var streamer_json_1 = __importDefault(require("./constants/abis/json/streamer.json"));
74
75
  var abis_ethereum_1 = require("./constants/abis/abis-ethereum");
75
76
  var abis_polygon_1 = require("./constants/abis/abis-polygon");
76
77
  var coins_ethereum_1 = require("./constants/coins-ethereum");
@@ -78,6 +79,7 @@ var coins_polygon_1 = require("./constants/coins-polygon");
78
79
  var aliases_1 = require("./constants/aliases");
79
80
  exports.ALIASES = {
80
81
  "crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
82
+ "minter": "0xd061D61a4d941c39E5453435B6345Dc261C2fcE0",
81
83
  "voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
82
84
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
83
85
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
@@ -103,9 +105,9 @@ var Curve = /** @class */ (function () {
103
105
  ) {
104
106
  if (options === void 0) { options = {}; }
105
107
  return __awaiter(this, void 0, void 0, function () {
106
- var cTokens, yTokens, ycTokens, aTokens, network, customAbiTokens, _a, _i, _b, pool, _c, _d, coinAddr, _e, _f, coinAddr, _g, _h, coinAddr, addressProviderContract, _j;
107
- return __generator(this, function (_k) {
108
- switch (_k.label) {
108
+ var cTokens, yTokens, ycTokens, aTokens, network, _a, customAbiTokens, _b, _i, _c, pool, _d, _e, coinAddr, _f, _g, coinAddr, _h, _j, coinAddr, _k, _l, rewardTokenAddr, addressProviderContract, _m;
109
+ return __generator(this, function (_o) {
110
+ switch (_o.label) {
109
111
  case 0:
110
112
  // JsonRpc provider
111
113
  if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
@@ -134,15 +136,24 @@ var Curve = /** @class */ (function () {
134
136
  providerSettings = providerSettings;
135
137
  this.provider = new ethers_1.ethers.providers.InfuraProvider(providerSettings.network, providerSettings.apiKey);
136
138
  }
139
+ else if (providerType.toLowerCase() === 'Alchemy'.toLowerCase()) {
140
+ providerSettings = providerSettings;
141
+ this.provider = new ethers_1.ethers.providers.AlchemyProvider(providerSettings.network, providerSettings.apiKey);
142
+ }
137
143
  else {
138
144
  throw Error('Wrong providerType');
139
145
  }
146
+ _a = this.provider.network;
147
+ if (_a) return [3 /*break*/, 2];
140
148
  return [4 /*yield*/, this.provider._networkPromise];
141
149
  case 1:
142
- network = _k.sent();
150
+ _a = (_o.sent());
151
+ _o.label = 2;
152
+ case 2:
153
+ network = _a;
143
154
  console.log("CURVE-JS IS CONNECTED TO NETWORK:", network);
144
155
  this.chainId = network.chainId;
145
- if (network.chainId === 1) {
156
+ if (network.chainId === 1 || network.chainId === 1337) {
146
157
  cTokens = coins_ethereum_1.cTokensEthereum;
147
158
  yTokens = coins_ethereum_1.yTokensEthereum;
148
159
  ycTokens = coins_ethereum_1.ycTokensEthereum;
@@ -192,22 +203,25 @@ var Curve = /** @class */ (function () {
192
203
  customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
193
204
  this.multicallProvider = new ethcall_1.Provider();
194
205
  return [4 /*yield*/, this.multicallProvider.init(this.provider)];
195
- case 2:
196
- _k.sent();
197
- if (!this.signer) return [3 /*break*/, 4];
198
- _a = this;
199
- return [4 /*yield*/, this.signer.getAddress()];
200
206
  case 3:
201
- _a.signerAddress = _k.sent();
202
- _k.label = 4;
207
+ _o.sent();
208
+ if (!this.signer) return [3 /*break*/, 5];
209
+ _b = this;
210
+ return [4 /*yield*/, this.signer.getAddress()];
203
211
  case 4:
212
+ _b.signerAddress = _o.sent();
213
+ return [3 /*break*/, 6];
214
+ case 5:
215
+ this.signerAddress = '';
216
+ _o.label = 6;
217
+ case 6:
204
218
  this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
205
219
  return [4 /*yield*/, this.updateFeeData()];
206
- case 5:
207
- _k.sent();
220
+ case 7:
221
+ _o.sent();
208
222
  // TODO delete toLowerCase()
209
- for (_i = 0, _b = Object.values(exports.POOLS_DATA); _i < _b.length; _i++) {
210
- pool = _b[_i];
223
+ for (_i = 0, _c = Object.values(exports.POOLS_DATA); _i < _c.length; _i++) {
224
+ pool = _c[_i];
211
225
  this.contracts[pool.swap_address] = {
212
226
  contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
213
227
  multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
@@ -227,12 +241,12 @@ var Curve = /** @class */ (function () {
227
241
  };
228
242
  }
229
243
  this.contracts[pool.gauge_address] = {
230
- contract: new ethers_1.Contract(pool.gauge_address, gauge_json_1.default, this.signer || this.provider),
231
- multicallContract: new ethcall_1.Contract(pool.gauge_address, gauge_json_1.default),
244
+ contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
245
+ multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
232
246
  };
233
247
  this.contracts[pool.gauge_address.toLowerCase()] = {
234
- contract: new ethers_1.Contract(pool.gauge_address, gauge_json_1.default, this.signer || this.provider),
235
- multicallContract: new ethcall_1.Contract(pool.gauge_address, gauge_json_1.default),
248
+ contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
249
+ multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
236
250
  };
237
251
  if (pool.deposit_address && this.contracts[pool.deposit_address] === undefined) {
238
252
  this.contracts[pool.deposit_address] = {
@@ -244,8 +258,8 @@ var Curve = /** @class */ (function () {
244
258
  multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
245
259
  };
246
260
  }
247
- for (_c = 0, _d = pool.underlying_coin_addresses; _c < _d.length; _c++) {
248
- coinAddr = _d[_c];
261
+ for (_d = 0, _e = pool.underlying_coin_addresses; _d < _e.length; _d++) {
262
+ coinAddr = _e[_d];
249
263
  this.contracts[coinAddr] = {
250
264
  contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
251
265
  multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
@@ -255,8 +269,8 @@ var Curve = /** @class */ (function () {
255
269
  multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
256
270
  };
257
271
  }
258
- for (_e = 0, _f = pool.coin_addresses; _e < _f.length; _e++) {
259
- coinAddr = _f[_e];
272
+ for (_f = 0, _g = pool.coin_addresses; _f < _g.length; _f++) {
273
+ coinAddr = _g[_f];
260
274
  if (customAbiTokens.includes(coinAddr))
261
275
  continue;
262
276
  this.contracts[coinAddr] = {
@@ -269,8 +283,8 @@ var Curve = /** @class */ (function () {
269
283
  };
270
284
  }
271
285
  // TODO add all coins
272
- for (_g = 0, _h = pool.coin_addresses; _g < _h.length; _g++) {
273
- coinAddr = _h[_g];
286
+ for (_h = 0, _j = pool.coin_addresses; _h < _j.length; _h++) {
287
+ coinAddr = _j[_h];
274
288
  if (cTokens.includes(coinAddr)) {
275
289
  this.contracts[coinAddr] = {
276
290
  contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
@@ -302,6 +316,27 @@ var Curve = /** @class */ (function () {
302
316
  };
303
317
  }
304
318
  }
319
+ if (pool.reward_contract) {
320
+ this.contracts[pool.reward_contract] = {
321
+ contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
322
+ multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
323
+ };
324
+ this.contracts[pool.reward_contract.toLowerCase()] = {
325
+ contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
326
+ multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
327
+ };
328
+ }
329
+ for (_k = 0, _l = pool.reward_tokens || []; _k < _l.length; _k++) {
330
+ rewardTokenAddr = _l[_k];
331
+ this.contracts[rewardTokenAddr] = {
332
+ contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
333
+ multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
334
+ };
335
+ this.contracts[rewardTokenAddr.toLowerCase()] = {
336
+ contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
337
+ multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
338
+ };
339
+ }
305
340
  }
306
341
  this.contracts[exports.ALIASES.crv] = {
307
342
  contract: new ethers_1.Contract(exports.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
@@ -311,6 +346,14 @@ var Curve = /** @class */ (function () {
311
346
  contract: new ethers_1.Contract(exports.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
312
347
  multicallContract: new ethcall_1.Contract(exports.ALIASES.crv, ERC20_json_1.default),
313
348
  };
349
+ this.contracts[exports.ALIASES.minter] = {
350
+ contract: new ethers_1.Contract(exports.ALIASES.minter, minter_json_1.default, this.signer || this.provider),
351
+ multicallContract: new ethcall_1.Contract(exports.ALIASES.minter, minter_json_1.default),
352
+ };
353
+ this.contracts[exports.ALIASES.minter.toLowerCase()] = {
354
+ contract: new ethers_1.Contract(exports.ALIASES.minter, minter_json_1.default, this.signer || this.provider),
355
+ multicallContract: new ethcall_1.Contract(exports.ALIASES.minter, minter_json_1.default),
356
+ };
314
357
  this.contracts[exports.ALIASES.voting_escrow] = {
315
358
  contract: new ethers_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
316
359
  multicallContract: new ethcall_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default),
@@ -328,10 +371,10 @@ var Curve = /** @class */ (function () {
328
371
  multicallContract: new ethcall_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default),
329
372
  };
330
373
  addressProviderContract = this.contracts[exports.ALIASES.address_provider].contract;
331
- _j = exports.ALIASES;
374
+ _m = exports.ALIASES;
332
375
  return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
333
- case 6:
334
- _j.registry_exchange = _k.sent();
376
+ case 8:
377
+ _m.registry_exchange = _o.sent();
335
378
  this.contracts[exports.ALIASES.registry_exchange] = {
336
379
  contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
337
380
  multicallContract: new ethcall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ethers } from "ethers";
2
2
  import { Networkish } from "@ethersproject/networks";
3
3
  import { Pool } from "./pools";
4
- declare function init(providerType: 'JsonRpc' | 'Web3' | 'Infura', providerSettings: {
4
+ declare function init(providerType: 'JsonRpc' | 'Web3' | 'Infura' | 'Alchemy', providerSettings: {
5
5
  url?: string;
6
6
  privateKey?: string;
7
7
  } | {
@@ -2,6 +2,7 @@ export interface DictInterface<T> {
2
2
  [index: string]: T;
3
3
  }
4
4
  export interface PoolDataInterface {
5
+ reference_asset: 'USD' | 'EUR' | 'BTC' | 'ETH' | 'LINK' | 'CRYPTO';
5
6
  N_COINS: number;
6
7
  underlying_decimals: number[];
7
8
  decimals: number[];
@@ -23,6 +24,7 @@ export interface PoolDataInterface {
23
24
  underlying_coin_addresses: string[];
24
25
  coin_addresses: string[];
25
26
  swap_abi: any;
27
+ gauge_abi: any;
26
28
  deposit_abi?: any;
27
29
  old_swap_abi?: any;
28
30
  is_meta?: boolean;
@@ -48,4 +50,10 @@ export interface PoolDataInterface {
48
50
  reward_token?: string;
49
51
  reward_tokens?: string[];
50
52
  pool_type?: string;
53
+ reward_contract?: string;
54
+ }
55
+ export interface RewardsApyInterface {
56
+ token: string;
57
+ symbol: string;
58
+ apy: string;
51
59
  }
package/lib/pools.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import { ethers } from "ethers";
2
2
  import BigNumber from 'bignumber.js';
3
- import { DictInterface } from './interfaces';
3
+ import { DictInterface, RewardsApyInterface } from './interfaces';
4
4
  export declare class Pool {
5
5
  name: string;
6
+ referenceAsset: string;
6
7
  swap: string;
7
8
  zap: string | null;
8
9
  lpToken: string;
9
10
  gauge: string;
11
+ rewardContract: string | null;
10
12
  underlyingCoins: string[];
11
13
  coins: string[];
12
14
  underlyingCoinAddresses: string[];
@@ -19,6 +21,7 @@ export declare class Pool {
19
21
  isCrypto: boolean;
20
22
  basePool: string;
21
23
  isFactory: boolean;
24
+ rewardTokens: string[];
22
25
  estimateGas: {
23
26
  addLiquidityApprove: (amounts: string[]) => Promise<number>;
24
27
  addLiquidity: (amounts: string[]) => Promise<number>;
@@ -41,12 +44,33 @@ export declare class Pool {
41
44
  exchangeWrappedApprove: (inputCoin: string | number, amount: string) => Promise<number>;
42
45
  exchangeWrapped: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
43
46
  };
47
+ stats: {
48
+ getParameters: () => Promise<{
49
+ virtualPrice: string;
50
+ fee: string;
51
+ adminFee: string;
52
+ A: string;
53
+ gamma?: string;
54
+ }>;
55
+ getPoolBalances: () => Promise<string[]>;
56
+ getPoolWrappedBalances: () => Promise<string[]>;
57
+ getTotalLiquidity: () => Promise<string>;
58
+ getVolume: () => Promise<string>;
59
+ getBaseApy: () => Promise<[daily: string, weekly: string, monthly: string, total: string]>;
60
+ getTokenApy: () => Promise<[baseApy: string, boostedApy: string]>;
61
+ getRewardsApy: () => Promise<RewardsApyInterface[]>;
62
+ };
44
63
  constructor(name: string);
45
64
  calcLpTokenAmount: (amounts: string[], isDeposit?: boolean) => Promise<string>;
46
65
  calcLpTokenAmountWrapped: (amounts: string[], isDeposit?: boolean) => Promise<string>;
47
- getVirtualPrice: () => Promise<string>;
48
- getPoolBalances: () => Promise<string[]>;
49
- getPoolWrappedBalances: () => Promise<string[]>;
66
+ private getParameters;
67
+ private getPoolBalances;
68
+ private getPoolWrappedBalances;
69
+ private getTotalLiquidity;
70
+ private getVolume;
71
+ private getBaseApy;
72
+ private getTokenApy;
73
+ private getRewardsApy;
50
74
  addLiquidityExpected: (amounts: string[]) => Promise<string>;
51
75
  addLiquiditySlippage: (amounts: string[]) => Promise<string>;
52
76
  addLiquidityIsApproved: (amounts: string[]) => Promise<boolean>;
@@ -101,6 +125,14 @@ export declare class Pool {
101
125
  gaugeDeposit: (lpTokenAmount: string) => Promise<string>;
102
126
  private gaugeWithdrawEstimateGas;
103
127
  gaugeWithdraw: (lpTokenAmount: string) => Promise<string>;
128
+ gaugeClaimableTokens: (address?: string) => Promise<string>;
129
+ gaugeClaimTokens: () => Promise<string>;
130
+ gaugeClaimableRewards: (address?: string) => Promise<{
131
+ token: string;
132
+ symbol: string;
133
+ amount: string;
134
+ }[]>;
135
+ gaugeClaimRewards: () => Promise<string>;
104
136
  balances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
105
137
  lpTokenBalances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
106
138
  underlyingCoinBalances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
@@ -121,7 +153,6 @@ export declare class Pool {
121
153
  gaugeMaxBoostedDeposit: (...addresses: string[]) => Promise<DictInterface<string>>;
122
154
  gaugeOptimalDeposits: (...accounts: string[]) => Promise<DictInterface<string>>;
123
155
  boost: (address: string) => Promise<string>;
124
- getApy: () => Promise<string[]>;
125
156
  private _getCoinIdx;
126
157
  private _getRates;
127
158
  private _balances;