@curvefi/api 1.17.2 → 1.18.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 (38) hide show
  1. package/README.md +37 -0
  2. package/lib/constants/abis/abis-ethereum.js +6 -6
  3. package/lib/constants/abis/json/factory-v2/DepositZapMetaBtcPolygon.json +197 -0
  4. package/lib/constants/abis/json/factory-v2/DepositZapMetaUsdPolygon.json +197 -0
  5. package/lib/constants/abis/json/factory-v2/MetaBTC.json +919 -0
  6. package/lib/constants/abis/json/factory-v2/MetaBTCBalances.json +932 -0
  7. package/lib/constants/abis/json/factory-v2/MetaBTCBalancesRen.json +932 -0
  8. package/lib/constants/abis/json/factory-v2/MetaBTCRen.json +919 -0
  9. package/lib/constants/abis/json/factory-v2/MetaUSD.json +919 -0
  10. package/lib/constants/abis/json/factory-v2/MetaUSDBalances.json +932 -0
  11. package/lib/constants/abis/json/factory-v2/Plain2Balances.json +845 -0
  12. package/lib/constants/abis/json/factory-v2/Plain2Basic.json +845 -0
  13. package/lib/constants/abis/json/factory-v2/Plain2ETH.json +845 -0
  14. package/lib/constants/abis/json/factory-v2/Plain2Optimized.json +844 -0
  15. package/lib/constants/abis/json/factory-v2/Plain3Balances.json +845 -0
  16. package/lib/constants/abis/json/factory-v2/Plain3Basic.json +845 -0
  17. package/lib/constants/abis/json/factory-v2/Plain3ETH.json +845 -0
  18. package/lib/constants/abis/json/factory-v2/Plain3Optimized.json +845 -0
  19. package/lib/constants/abis/json/factory-v2/Plain4Balances.json +845 -0
  20. package/lib/constants/abis/json/factory-v2/Plain4Basic.json +845 -0
  21. package/lib/constants/abis/json/factory-v2/Plain4ETH.json +845 -0
  22. package/lib/constants/abis/json/factory-v2/Plain4Optimized.json +845 -0
  23. package/lib/constants/abis/json/factory.json +1063 -0
  24. package/lib/constants/aliases.d.ts +2 -0
  25. package/lib/constants/aliases.js +2 -0
  26. package/lib/constants/coins-polygon.js +3 -2
  27. package/lib/curve.d.ts +3 -0
  28. package/lib/curve.js +34 -0
  29. package/lib/factory.d.ts +32 -0
  30. package/lib/factory.js +607 -0
  31. package/lib/index.d.ts +3 -0
  32. package/lib/index.js +14 -0
  33. package/lib/interfaces.d.ts +15 -1
  34. package/lib/pools.d.ts +3 -0
  35. package/lib/pools.js +149 -62
  36. package/lib/utils.d.ts +7 -1
  37. package/lib/utils.js +109 -8
  38. package/package.json +4 -2
@@ -6,6 +6,7 @@ export declare const ALIASES_ETHEREUM: {
6
6
  address_provider: string;
7
7
  router: string;
8
8
  deposit_and_stake: string;
9
+ factory: string;
9
10
  registry_exchange: string;
10
11
  };
11
12
  export declare const ALIASES_POLYGON: {
@@ -16,5 +17,6 @@ export declare const ALIASES_POLYGON: {
16
17
  address_provider: string;
17
18
  router: string;
18
19
  deposit_and_stake: string;
20
+ factory: string;
19
21
  registry_exchange: string;
20
22
  };
@@ -9,6 +9,7 @@ exports.ALIASES_ETHEREUM = {
9
9
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
10
10
  "router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
11
11
  "deposit_and_stake": "0x271fbE8aB7f1fB262f81C77Ea5303F03DA9d3d6A",
12
+ "factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
12
13
  "registry_exchange": "",
13
14
  };
14
15
  exports.ALIASES_POLYGON = {
@@ -19,5 +20,6 @@ exports.ALIASES_POLYGON = {
19
20
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
20
21
  "router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
21
22
  "deposit_and_stake": "0x43FF7b96808988C9d19C1d05Ef19658B03e8a143",
23
+ "factory": '0x722272d36ef0da72ff51c5a65db7b870e2e8d4ee',
22
24
  "registry_exchange": "",
23
25
  };
@@ -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(__assign({}, exports.BTC_COINS_POLYGON), exports.ETH_COINS_POLYGON), exports.LINK_COINS_POLYGON), exports.EUR_COINS_POLYGON), exports.USD_COINS_POLYGON), { crv: "0x172370d5cd63279efa6d502dab29171933a610af" });
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", matic: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" });
48
48
  exports.DECIMALS_POLYGON = {
49
49
  "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063": 18,
50
50
  "0x2791bca1f2de4661ed88a30c99a7a9449aa84174": 6,
@@ -59,7 +59,8 @@ exports.DECIMALS_POLYGON = {
59
59
  "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619": 18,
60
60
  "0x28424507fefb6f7f8E9D3860F56504E4e5f5f390": 18,
61
61
  "0x7BDF330f423Ea880FF95fC41A280fD5eCFD3D09f": 6,
62
- "0x172370d5cd63279efa6d502dab29171933a610af": 18, // CRV
62
+ "0x172370d5cd63279efa6d502dab29171933a610af": 18,
63
+ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE": 18, // MATIC
63
64
  };
64
65
  // @ts-ignore
65
66
  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
@@ -28,6 +28,7 @@ export declare let ALIASES: {
28
28
  address_provider: string;
29
29
  router: string;
30
30
  deposit_and_stake: string;
31
+ factory: string;
31
32
  registry_exchange: string;
32
33
  };
33
34
  declare class Curve {
@@ -55,6 +56,7 @@ declare class Curve {
55
56
  maxFeePerGas?: number | ethers.BigNumber;
56
57
  maxPriorityFeePerGas?: number | ethers.BigNumber;
57
58
  };
59
+ constants: DictInterface<any>;
58
60
  constructor();
59
61
  init(providerType: 'JsonRpc' | 'Web3' | 'Infura' | 'Alchemy', providerSettings: {
60
62
  url?: string;
@@ -70,6 +72,7 @@ declare class Curve {
70
72
  maxPriorityFeePerGas?: number;
71
73
  chainId?: number;
72
74
  }): Promise<void>;
75
+ fetchFactoryPools(): Promise<void>;
73
76
  setCustomFeeData(customFeeData: {
74
77
  gasPrice?: number;
75
78
  maxFeePerGas?: number;
package/lib/curve.js CHANGED
@@ -62,6 +62,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
62
62
  exports.curve = exports.ALIASES = exports.DECIMALS_LOWER_CASE = exports.DECIMALS = exports.COINS = exports.USD_COINS_LOWER_CASE = exports.USD_COINS = exports.EUR_COINS_LOWER_CASE = exports.EUR_COINS = exports.LINK_COINS_LOWER_CASE = exports.LINK_COINS = exports.ETH_COINS_LOWER_CASE = exports.ETH_COINS = exports.BTC_COINS_LOWER_CASE = exports.BTC_COINS = exports.GAUGES = exports.LP_TOKENS = exports.POOLS_DATA = void 0;
63
63
  var ethers_1 = require("ethers");
64
64
  var ethcall_1 = require("ethcall");
65
+ var factory_1 = require("./factory");
65
66
  var ERC20_json_1 = __importDefault(require("./constants/abis/json/ERC20.json"));
66
67
  var cERC20_json_1 = __importDefault(require("./constants/abis/json/cERC20.json"));
67
68
  var yERC20_json_1 = __importDefault(require("./constants/abis/json/yERC20.json"));
@@ -73,6 +74,7 @@ var router_json_1 = __importDefault(require("./constants/abis/json/router.json")
73
74
  var deposit_and_stake_json_1 = __importDefault(require("./constants/abis/json/deposit_and_stake.json"));
74
75
  var registry_exchange_json_1 = __importDefault(require("./constants/abis/json/registry_exchange.json"));
75
76
  var streamer_json_1 = __importDefault(require("./constants/abis/json/streamer.json"));
77
+ var factory_json_1 = __importDefault(require("./constants/abis/json/factory.json"));
76
78
  var abis_ethereum_1 = require("./constants/abis/abis-ethereum");
77
79
  var abis_polygon_1 = require("./constants/abis/abis-polygon");
78
80
  var coins_ethereum_1 = require("./constants/coins-ethereum");
@@ -86,6 +88,7 @@ exports.ALIASES = {
86
88
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
87
89
  "router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
88
90
  "deposit_and_stake": "0x271fbE8aB7f1fB262f81C77Ea5303F03DA9d3d6A",
91
+ "factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
89
92
  "registry_exchange": "",
90
93
  };
91
94
  var Curve = /** @class */ (function () {
@@ -102,6 +105,7 @@ var Curve = /** @class */ (function () {
102
105
  this.feeData = {};
103
106
  this.constantOptions = { gasLimit: 12000000 };
104
107
  this.options = {};
108
+ this.constants = {};
105
109
  }
106
110
  Curve.prototype.init = function (providerType, providerSettings, options // gasPrice in Gwei
107
111
  ) {
@@ -409,6 +413,36 @@ var Curve = /** @class */ (function () {
409
413
  contract: new ethers_1.Contract(exports.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default, this.signer || this.provider),
410
414
  multicallContract: new ethcall_1.Contract(exports.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default),
411
415
  };
416
+ this.contracts[exports.ALIASES.factory] = {
417
+ contract: new ethers_1.Contract(exports.ALIASES.factory, factory_json_1.default, this.signer || this.provider),
418
+ multicallContract: new ethcall_1.Contract(exports.ALIASES.factory, factory_json_1.default),
419
+ };
420
+ this.contracts[exports.ALIASES.factory.toLowerCase()] = {
421
+ contract: new ethers_1.Contract(exports.ALIASES.factory, factory_json_1.default, this.signer || this.provider),
422
+ multicallContract: new ethcall_1.Contract(exports.ALIASES.factory, factory_json_1.default),
423
+ };
424
+ return [2 /*return*/];
425
+ }
426
+ });
427
+ });
428
+ };
429
+ Curve.prototype.fetchFactoryPools = function () {
430
+ return __awaiter(this, void 0, void 0, function () {
431
+ var _a;
432
+ return __generator(this, function (_b) {
433
+ switch (_b.label) {
434
+ case 0:
435
+ this.constants = {
436
+ ALIASES: exports.ALIASES,
437
+ POOLS_DATA: exports.POOLS_DATA,
438
+ DECIMALS_LOWER_CASE: exports.DECIMALS_LOWER_CASE,
439
+ LP_TOKENS: exports.LP_TOKENS,
440
+ GAUGES: exports.GAUGES,
441
+ };
442
+ _a = this.constants;
443
+ return [4 /*yield*/, factory_1.getFactoryPoolData.call(this)];
444
+ case 1:
445
+ _a.FACTORY_POOLS_DATA = _b.sent();
412
446
  return [2 /*return*/];
413
447
  }
414
448
  });
@@ -0,0 +1,32 @@
1
+ import { Contract, ethers } from "ethers";
2
+ import { Contract as MulticallContract, Provider as MulticallProvider } from "ethcall";
3
+ import { DictInterface, PoolDataInterface } from "./interfaces";
4
+ interface CurveInterface {
5
+ provider: ethers.providers.Web3Provider | ethers.providers.JsonRpcProvider;
6
+ multicallProvider: MulticallProvider;
7
+ signer: ethers.Signer;
8
+ signerAddress: string;
9
+ chainId: number;
10
+ contracts: {
11
+ [index: string]: {
12
+ contract: Contract;
13
+ multicallContract: MulticallContract;
14
+ };
15
+ };
16
+ feeData: {
17
+ gasPrice?: number;
18
+ maxFeePerGas?: number;
19
+ maxPriorityFeePerGas?: number;
20
+ };
21
+ constantOptions: {
22
+ gasLimit: number;
23
+ };
24
+ options: {
25
+ gasPrice?: number | ethers.BigNumber;
26
+ maxFeePerGas?: number | ethers.BigNumber;
27
+ maxPriorityFeePerGas?: number | ethers.BigNumber;
28
+ };
29
+ constants: DictInterface<any>;
30
+ }
31
+ export declare function getFactoryPoolData(this: CurveInterface): Promise<DictInterface<PoolDataInterface>>;
32
+ export {};