@curvefi/api 2.36.1 → 2.37.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.
@@ -13,6 +13,7 @@ export var ALIASES_ETHEREUM = lowerCaseValues({
13
13
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
14
14
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
15
15
  "registry_exchange": "",
16
+ "factory_admin": "",
16
17
  });
17
18
  export var ALIASES_POLYGON = lowerCaseValues({
18
19
  "crv": "0x172370d5cd63279efa6d502dab29171933a610af",
@@ -28,6 +29,7 @@ export var ALIASES_POLYGON = lowerCaseValues({
28
29
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
29
30
  "crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
30
31
  "registry_exchange": "",
32
+ "factory_admin": "",
31
33
  });
32
34
  export var ALIASES_FANTOM = lowerCaseValues({
33
35
  "crv": "0x1E4F97b9f9F913c46F1632781732927B9019C68b",
@@ -43,6 +45,7 @@ export var ALIASES_FANTOM = lowerCaseValues({
43
45
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
44
46
  "crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
45
47
  "registry_exchange": "",
48
+ "factory_admin": "",
46
49
  });
47
50
  export var ALIASES_AVALANCHE = lowerCaseValues({
48
51
  "crv": "0x47536F17F4fF30e64A96a7555826b8f9e66ec468",
@@ -58,6 +61,7 @@ export var ALIASES_AVALANCHE = lowerCaseValues({
58
61
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
59
62
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
60
63
  "registry_exchange": "",
64
+ "factory_admin": "",
61
65
  });
62
66
  export var ALIASES_ARBITRUM = lowerCaseValues({
63
67
  "crv": "0x11cDb42B0EB46D95f990BeDD4695A6e3fA034978",
@@ -73,6 +77,7 @@ export var ALIASES_ARBITRUM = lowerCaseValues({
73
77
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
74
78
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
75
79
  "registry_exchange": "",
80
+ "factory_admin": "",
76
81
  });
77
82
  export var ALIASES_OPTIMISM = lowerCaseValues({
78
83
  "crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
@@ -88,6 +93,7 @@ export var ALIASES_OPTIMISM = lowerCaseValues({
88
93
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
89
94
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
90
95
  "registry_exchange": "",
96
+ "factory_admin": "",
91
97
  });
92
98
  export var ALIASES_XDAI = lowerCaseValues({
93
99
  "crv": "0x712b3d230f3c1c19db860d80619288b1f0bdd0bd",
@@ -103,6 +109,7 @@ export var ALIASES_XDAI = lowerCaseValues({
103
109
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
104
110
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
105
111
  "registry_exchange": "",
112
+ "factory_admin": "",
106
113
  });
107
114
  export var ALIASES_MOONBEAM = lowerCaseValues({
108
115
  "crv": "0x7C598c96D02398d89FbCb9d41Eab3DF0C16F227D",
@@ -118,6 +125,7 @@ export var ALIASES_MOONBEAM = lowerCaseValues({
118
125
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
119
126
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
120
127
  "registry_exchange": "",
128
+ "factory_admin": "",
121
129
  });
122
130
  export var ALIASES_AURORA = lowerCaseValues({
123
131
  "crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
@@ -133,6 +141,7 @@ export var ALIASES_AURORA = lowerCaseValues({
133
141
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
134
142
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
135
143
  "registry_exchange": "",
144
+ "factory_admin": "",
136
145
  });
137
146
  export var ALIASES_KAVA = lowerCaseValues({
138
147
  "crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
@@ -148,6 +157,7 @@ export var ALIASES_KAVA = lowerCaseValues({
148
157
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
149
158
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
150
159
  "registry_exchange": "",
160
+ "factory_admin": "",
151
161
  });
152
162
  export var ALIASES_CELO = lowerCaseValues({
153
163
  "crv": "0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB",
@@ -163,4 +173,5 @@ export var ALIASES_CELO = lowerCaseValues({
163
173
  "crvusd_factory": '0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d',
164
174
  "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
165
175
  "registry_exchange": "",
176
+ "factory_admin": "",
166
177
  });
@@ -54,6 +54,7 @@ export var COINS_ETHEREUM = lowerCaseValues({
54
54
  weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
55
55
  frxeth: "0x5E8422345238F34275888049021821E8E08CAa1f",
56
56
  sfrxeth: "0xac3E018457B222d93114458476f3E3416Abbe38F",
57
+ wbeth: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
57
58
  // --- BTC ---
58
59
  sbtccrv: "0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3",
59
60
  hbtc: "0x0316EB71485b0Ab14103307bf65a021042c6d380",
@@ -6,6 +6,7 @@ export var COINS_OPTIMISM = lowerCaseValues({
6
6
  'usdc': '0x7f5c764cbc14f9669b88837ca1490cca17c31607',
7
7
  'usdt': '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58',
8
8
  'susd': '0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9',
9
+ 'mim': '0xb153fb3d196a8eb25522705560ac152eeec57901',
9
10
  '3crv': '0x1337BedC9D22ecbe766dF105c9623922A27963EC',
10
11
  // --- ETH ---
11
12
  'eth': '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
package/lib/curve.js CHANGED
@@ -75,6 +75,7 @@ import StableCalcZapABI from './constants/abis/stable_calc.json' assert { type:
75
75
  import registryExchangeABI from './constants/abis/registry_exchange.json' assert { type: 'json' };
76
76
  import streamerABI from './constants/abis/streamer.json' assert { type: 'json' };
77
77
  import factoryABI from './constants/abis/factory.json' assert { type: 'json' };
78
+ import factoryAdminABI from './constants/abis/factory-admin.json' assert { type: 'json' };
78
79
  import cryptoFactoryABI from './constants/abis/factory-crypto.json' assert { type: 'json' };
79
80
  import { POOLS_DATA_ETHEREUM, LLAMMAS_DATA_ETHEREUM, POOLS_DATA_POLYGON, POOLS_DATA_FANTOM, POOLS_DATA_AVALANCHE, POOLS_DATA_ARBITRUM, POOLS_DATA_OPTIMISM, POOLS_DATA_XDAI, POOLS_DATA_MOONBEAM, POOLS_DATA_AURORA, POOLS_DATA_KAVA, POOLS_DATA_CELO, } from './constants/pools/index.js';
80
81
  import { ALIASES_ETHEREUM, ALIASES_OPTIMISM, ALIASES_POLYGON, ALIASES_FANTOM, ALIASES_AVALANCHE, ALIASES_ARBITRUM, ALIASES_XDAI, ALIASES_MOONBEAM, ALIASES_AURORA, ALIASES_KAVA, ALIASES_CELO, } from "./constants/aliases.js";
@@ -516,9 +517,9 @@ var Curve = /** @class */ (function () {
516
517
  var _a;
517
518
  if (options === void 0) { options = {}; }
518
519
  return __awaiter(this, void 0, void 0, function () {
519
- var _b, e_1, _c, network, poolId, _d, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _e, err_1, _i, _f, pool, _g, _h, coinAddr, _j, _k, coinAddr, _l, _m, coinAddr, _minterABI, addressProviderContract, _o;
520
- return __generator(this, function (_p) {
521
- switch (_p.label) {
520
+ var _b, e_1, _c, network, poolId, _d, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _e, err_1, _i, _f, pool, _g, _h, coinAddr, _j, _k, coinAddr, _l, _m, coinAddr, _minterABI, addressProviderContract, _o, factoryContract, _p;
521
+ return __generator(this, function (_q) {
522
+ switch (_q.label) {
522
523
  case 0:
523
524
  // @ts-ignore
524
525
  this.provider = null;
@@ -559,16 +560,16 @@ var Curve = /** @class */ (function () {
559
560
  return [3 /*break*/, 5];
560
561
  case 1:
561
562
  if (!!((_a = providerSettings.url) === null || _a === void 0 ? void 0 : _a.startsWith("https://rpc.gnosischain.com"))) return [3 /*break*/, 5];
562
- _p.label = 2;
563
+ _q.label = 2;
563
564
  case 2:
564
- _p.trys.push([2, 4, , 5]);
565
+ _q.trys.push([2, 4, , 5]);
565
566
  _b = this;
566
567
  return [4 /*yield*/, this.provider.getSigner()];
567
568
  case 3:
568
- _b.signer = _p.sent();
569
+ _b.signer = _q.sent();
569
570
  return [3 /*break*/, 5];
570
571
  case 4:
571
- e_1 = _p.sent();
572
+ e_1 = _q.sent();
572
573
  this.signer = null;
573
574
  return [3 /*break*/, 5];
574
575
  case 5: return [3 /*break*/, 9];
@@ -579,7 +580,7 @@ var Curve = /** @class */ (function () {
579
580
  _c = this;
580
581
  return [4 /*yield*/, this.provider.getSigner()];
581
582
  case 7:
582
- _c.signer = _p.sent();
583
+ _c.signer = _q.sent();
583
584
  return [3 /*break*/, 9];
584
585
  case 8:
585
586
  if (providerType.toLowerCase() === 'Infura'.toLowerCase()) {
@@ -596,10 +597,10 @@ var Curve = /** @class */ (function () {
596
597
  else {
597
598
  throw Error('Wrong providerType');
598
599
  }
599
- _p.label = 9;
600
+ _q.label = 9;
600
601
  case 9: return [4 /*yield*/, this.provider.getNetwork()];
601
602
  case 10:
602
- network = _p.sent();
603
+ network = _q.sent();
603
604
  console.log("CURVE-JS IS CONNECTED TO NETWORK:", { name: network.name.toUpperCase(), chainId: Number(network.chainId) });
604
605
  this.chainId = Number(network.chainId) === 1337 ? 1 : Number(network.chainId);
605
606
  this.constants.NATIVE_TOKEN = NATIVE_TOKENS[this.chainId];
@@ -624,30 +625,30 @@ var Curve = /** @class */ (function () {
624
625
  customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
625
626
  return [4 /*yield*/, _killGauges(this.constants.POOLS_DATA)];
626
627
  case 11:
627
- _p.sent();
628
+ _q.sent();
628
629
  this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
629
630
  if (!this.signer) return [3 /*break*/, 16];
630
- _p.label = 12;
631
+ _q.label = 12;
631
632
  case 12:
632
- _p.trys.push([12, 14, , 15]);
633
+ _q.trys.push([12, 14, , 15]);
633
634
  _e = this;
634
635
  return [4 /*yield*/, this.signer.getAddress()];
635
636
  case 13:
636
- _e.signerAddress = _p.sent();
637
+ _e.signerAddress = _q.sent();
637
638
  return [3 /*break*/, 15];
638
639
  case 14:
639
- err_1 = _p.sent();
640
+ err_1 = _q.sent();
640
641
  this.signer = null;
641
642
  return [3 /*break*/, 15];
642
643
  case 15: return [3 /*break*/, 17];
643
644
  case 16:
644
645
  this.signerAddress = '';
645
- _p.label = 17;
646
+ _q.label = 17;
646
647
  case 17:
647
648
  this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
648
649
  return [4 /*yield*/, this.updateFeeData()];
649
650
  case 18:
650
- _p.sent();
651
+ _q.sent();
651
652
  for (_i = 0, _f = Object.values(__assign(__assign({}, this.constants.POOLS_DATA), this.constants.LLAMMAS_DATA)); _i < _f.length; _i++) {
652
653
  pool = _f[_i];
653
654
  this.setContract(pool.swap_address, pool.swap_abi);
@@ -704,7 +705,7 @@ var Curve = /** @class */ (function () {
704
705
  _o = this.constants.ALIASES;
705
706
  return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
706
707
  case 19:
707
- _o.registry_exchange = (_p.sent()).toLowerCase();
708
+ _o.registry_exchange = (_q.sent()).toLowerCase();
708
709
  this.setContract(this.constants.ALIASES.registry_exchange, registryExchangeABI);
709
710
  this.setContract(this.constants.ALIASES.gauge_controller, gaugeControllerABI);
710
711
  this.setContract(this.constants.ALIASES.router, routerABI);
@@ -716,6 +717,15 @@ var Curve = /** @class */ (function () {
716
717
  }
717
718
  this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
718
719
  this.setContract(this.constants.ALIASES.factory, factoryABI);
720
+ if (!(this.chainId !== 1313161554)) return [3 /*break*/, 21];
721
+ factoryContract = this.contracts[this.constants.ALIASES.factory].contract;
722
+ _p = this.constants.ALIASES;
723
+ return [4 /*yield*/, factoryContract.admin(this.constantOptions)];
724
+ case 20:
725
+ _p.factory_admin = (_q.sent()).toLowerCase();
726
+ this.setContract(this.constants.ALIASES.factory_admin, factoryAdminABI);
727
+ _q.label = 21;
728
+ case 21:
719
729
  this.setContract(this.constants.ALIASES.crvusd_factory, factoryABI);
720
730
  this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
721
731
  return [2 /*return*/];
@@ -13,6 +13,7 @@ import MetaUSDGeistABI from "../constants/abis/factory-v2/MetaUSDGeist.json" ass
13
13
  import Plain2BasicABI from "../constants/abis/factory-v2/Plain2Basic.json" assert { type: 'json' };
14
14
  import Plain2BalancesABI from "../constants/abis/factory-v2/Plain2Balances.json" assert { type: 'json' };
15
15
  import Plain2ETHABI from "../constants/abis/factory-v2/Plain2ETH.json" assert { type: 'json' };
16
+ import Plain2ETHOracleABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" assert { type: 'json' };
16
17
  import Plain2OptimizedABI from "../constants/abis/factory-v2/Plain2Optimized.json" assert { type: 'json' };
17
18
  import Plain3BasicABI from "../constants/abis/factory-v2/Plain3Basic.json" assert { type: 'json' };
18
19
  import Plain3BalancesABI from "../constants/abis/factory-v2/Plain3Balances.json" assert { type: 'json' };
@@ -51,8 +52,8 @@ export var implementationABIDictEthereum = lowerCaseKeys({
51
52
  "0x6326DEbBAa15bCFE603d831e7D75f4fc10d9B43E": Plain2ETHABI,
52
53
  "0x4A4d7868390EF5CaC51cDA262888f34bD3025C3F": Plain2OptimizedABI,
53
54
  "0xc629a01eC23AB04E1050500A3717A2a5c0701497": Plain2BasicABI,
55
+ "0x847ee1227A9900B73aEeb3a47fAc92c52FD54ed9": Plain2ETHOracleABI,
54
56
  "0x94b4DFd9Ba5865Cc931195c99A2db42F3fc5d45B": Plain2ETHABI,
55
- "0x847ee1227A9900B73aEeb3a47fAc92c52FD54ed9": Plain2ETHABI,
56
57
  "0x67fe41A94e779CcFa22cff02cc2957DC9C0e4286": Plain2BasicABI,
57
58
  "0x9B52F13DF69D79Ec5aAB6D1aCe3157d29B409cC3": Plain3BasicABI,
58
59
  "0x50b085f2e5958C4A87baf93A8AB79F6bec068494": Plain3BalancesABI,
@@ -127,8 +128,10 @@ export var implementationABIDictArbitrum = lowerCaseKeys({
127
128
  "0x8DEb66a4A40E370355bEe35f12E55Fe9c755d686": MetaFraxUSDABI,
128
129
  "0x3edE9b145F82e9e46C03f8A8F67B77aEE847b632": MetaFraxUSDBalancesABI,
129
130
  "0x54e8A25d0Ac0E4945b697C80b8372445FEA17A62": Plain2BasicABI,
131
+ "0x73Ec37618683C274D0bBf5f5726aA856B2BDAB81": Plain2BasicABI,
130
132
  "0xD68970e266cE1A015953897C7055a5E0bC657Af8": Plain2BalancesABI,
131
133
  "0x7DA64233Fefb352f8F501B357c018158ED8aA455": Plain2ETHABI,
134
+ "0x6F9fb833501f46CBE6f6A4b6Cf32C834E5A5e8C5": Plain2ETHOracleABI,
132
135
  "0x0100fBf414071977B19fC38e6fc7c32FE444F5C9": Plain2OptimizedABI,
133
136
  "0xe381C25de995d62b453aF8B931aAc84fcCaa7A62": Plain3BasicABI,
134
137
  "0xc379bA7b8e1c6C48D64e1cf9dD602C97c9fD0F40": Plain3BalancesABI,
@@ -145,8 +148,10 @@ export var implementationABIDictOptimism = lowerCaseKeys({
145
148
  "0xe8269B33E47761f552E1a3070119560d5fa8bBD6": MetaFraxUSDABI,
146
149
  "0x114C4042B11a2b16F58Fe1BFe847589a122F678a": MetaFraxUSDBalancesABI,
147
150
  "0xC2b1DF84112619D190193E48148000e3990Bf627": Plain2BasicABI,
151
+ "0x73Ec37618683C274D0bBf5f5726aA856B2BDAB81": Plain2BasicABI,
148
152
  "0x16a7DA911A4DD1d83F3fF066fE28F3C792C50d90": Plain2BalancesABI,
149
153
  "0x4f3E8F405CF5aFC05D68142F3783bDfE13811522": Plain2ETHABI,
154
+ "0x6F9fb833501f46CBE6f6A4b6Cf32C834E5A5e8C5": Plain2ETHOracleABI,
150
155
  "0x0f9cb53Ebe405d49A0bbdBD291A65Ff571bC83e1": Plain2OptimizedABI,
151
156
  "0x78D0fC2B9D5AE65512DB242e424a9c683F18c243": Plain3BasicABI,
152
157
  "0x35796DAc54f144DFBAD1441Ec7C32313A7c29F39": Plain3BalancesABI,
@@ -1,7 +1,10 @@
1
1
  import { ethers } from "ethers";
2
- export declare const deployStablePlainPoolEstimateGas: (name: string, symbol: string, coins: string[], A: number | string, fee: number | string, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5) => Promise<number>;
3
- export declare const deployStablePlainPool: (name: string, symbol: string, coins: string[], A: number | string, fee: number | string, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5) => Promise<ethers.ContractTransactionResponse>;
2
+ export declare const deployStablePlainPoolEstimateGas: (name: string, symbol: string, coins: string[], A: number | string, fee: number | string, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5, emaTime?: number, oracleAddress?: string, methodName?: string) => Promise<number>;
3
+ export declare const deployStablePlainPool: (name: string, symbol: string, coins: string[], A: number | string, fee: number | string, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5, emaTime?: number, oracleAddress?: string, methodName?: string) => Promise<ethers.ContractTransactionResponse>;
4
4
  export declare const getDeployedStablePlainPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
5
+ export declare const _setOracle: (poolAddress: string, oracleAddress: string, methodName: string, estimateGas: boolean) => Promise<ethers.ContractTransactionResponse | number>;
6
+ export declare const setOracleEstimateGas: (poolAddress: string, oracleAddress?: string, methodName?: string) => Promise<number>;
7
+ export declare const setOracle: (poolAddress: string, oracleAddress?: string, methodName?: string) => Promise<ethers.ContractTransactionResponse>;
5
8
  export declare const deployStableMetaPoolEstimateGas: (basePool: string, name: string, symbol: string, coin: string, A: number | string, fee: number | string, implementationIdx: 0 | 1) => Promise<number>;
6
9
  export declare const deployStableMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: number | string, fee: number | string, implementationIdx: 0 | 1) => Promise<ethers.ContractTransactionResponse>;
7
10
  export declare const getDeployedStableMetaPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
@@ -45,16 +45,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
- import { Contract } from "ethers";
48
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
+ if (ar || !(i in from)) {
51
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
+ ar[i] = from[i];
53
+ }
54
+ }
55
+ return to.concat(ar || Array.prototype.slice.call(from));
56
+ };
57
+ import { ethers, Contract } from "ethers";
49
58
  import { curve } from "../curve.js";
50
- import { parseUnits, BN, mulBy1_3 } from "../utils.js";
59
+ import { getPool } from "../pools/index.js";
60
+ import { parseUnits, BN, mulBy1_3, getPoolIdBySwapAddress } from "../utils.js";
51
61
  import CurveLpTokenV5ABI from "../constants/abis/curve_lp_token_v5.json" assert { type: 'json' };
62
+ import Plain2ETHOracleABIABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" assert { type: 'json' };
52
63
  // ------- STABLE PLAIN POOLS -------
53
64
  var _deployStablePlainPool = function (name, symbol, coins, A, fee, // %
54
- assetType, implementationIdx, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
55
- var _A, _fee, _coins, contract, gas, gasLimit;
56
- return __generator(this, function (_a) {
57
- switch (_a.label) {
65
+ assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
66
+ implementationIdx, emaTime, // seconds
67
+ oracleAddress, methodName, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
68
+ var _A, _fee, _coins, useProxy, setOracle, contractAddress, contract, args, methodId, methodToCall, gas, gasLimit;
69
+ var _a;
70
+ return __generator(this, function (_b) {
71
+ switch (_b.label) {
58
72
  case 0:
59
73
  if (name.length > 32)
60
74
  throw Error("Max name length = 32");
@@ -76,42 +90,71 @@ assetType, implementationIdx, estimateGas) { return __awaiter(void 0, void 0, vo
76
90
  if (![0, 1, 2, 3, 4, 5].includes(implementationIdx))
77
91
  throw Error("Invalid implementationIdx. Must be one 0, 1, 2, 3, 4 or 5");
78
92
  }
93
+ if (emaTime <= 0)
94
+ throw Error("emaTime must be > 0. Passed emaTime = ".concat(emaTime));
79
95
  _A = parseUnits(A, 0);
80
96
  _fee = parseUnits(fee, 8);
81
97
  _coins = coins.concat(Array(4 - coins.length).fill(curve.constants.ZERO_ADDRESS));
82
- contract = curve.contracts[curve.constants.ALIASES.factory].contract;
83
- return [4 /*yield*/, contract.deploy_plain_pool.estimateGas(name, symbol, _coins, _A, _fee, assetType, implementationIdx, curve.constantOptions)];
98
+ useProxy = (curve.chainId === 1 && coins.length === 2 && implementationIdx === 4 && emaTime !== 600) ||
99
+ (curve.chainId === 1 && coins.length === 2 && implementationIdx === 5 && emaTime !== 600) ||
100
+ ((curve.chainId === 42161 || curve.chainId == 10) && coins.length === 2 && implementationIdx === 0 && emaTime !== 600);
101
+ setOracle = ((curve.chainId === 42161 || curve.chainId == 10) && coins.length === 2 && implementationIdx === 2);
102
+ contractAddress = (useProxy || setOracle) ? curve.constants.ALIASES.factory_admin : curve.constants.ALIASES.factory;
103
+ contract = curve.contracts[contractAddress].contract;
104
+ args = [name, symbol, _coins, _A, _fee, assetType, implementationIdx];
105
+ if (useProxy || setOracle)
106
+ args.push(curve.parseUnits((emaTime / Math.log(2)).toFixed(0), 0));
107
+ if (setOracle) {
108
+ methodId = methodName === "0x00000000" ? "0x00000000" : ethers.id(methodName).substring(0, 10);
109
+ args.push(methodId, oracleAddress);
110
+ }
111
+ methodToCall = setOracle ? "deploy_plain_pool_and_set_oracle" : "deploy_plain_pool";
112
+ return [4 /*yield*/, (_a = contract[methodToCall]).estimateGas.apply(_a, __spreadArray(__spreadArray([], args, false), [curve.constantOptions], false))];
84
113
  case 1:
85
- gas = _a.sent();
114
+ gas = _b.sent();
86
115
  if (estimateGas)
87
116
  return [2 /*return*/, Number(gas)];
88
117
  gasLimit = mulBy1_3(gas);
89
118
  return [4 /*yield*/, curve.updateFeeData()];
90
119
  case 2:
91
- _a.sent();
92
- return [4 /*yield*/, contract.deploy_plain_pool(name, symbol, _coins, _A, _fee, assetType, implementationIdx, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
93
- case 3: return [2 /*return*/, _a.sent()];
120
+ _b.sent();
121
+ return [4 /*yield*/, contract[methodToCall].apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit })], false))];
122
+ case 3: return [2 /*return*/, _b.sent()];
94
123
  }
95
124
  });
96
125
  }); };
97
126
  export var deployStablePlainPoolEstimateGas = function (name, symbol, coins, A, fee, // %
98
- assetType, implementationIdx) { return __awaiter(void 0, void 0, void 0, function () {
99
- return __generator(this, function (_a) {
100
- switch (_a.label) {
101
- case 0: return [4 /*yield*/, _deployStablePlainPool(name, symbol, coins, A, fee, assetType, implementationIdx, true)];
102
- case 1: return [2 /*return*/, _a.sent()];
103
- }
127
+ assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
128
+ implementationIdx, emaTime, // seconds
129
+ oracleAddress, methodName) {
130
+ if (emaTime === void 0) { emaTime = 600; }
131
+ if (oracleAddress === void 0) { oracleAddress = curve.constants.ZERO_ADDRESS; }
132
+ if (methodName === void 0) { methodName = "0x00000000"; }
133
+ return __awaiter(void 0, void 0, void 0, function () {
134
+ return __generator(this, function (_a) {
135
+ switch (_a.label) {
136
+ case 0: return [4 /*yield*/, _deployStablePlainPool(name, symbol, coins, A, fee, assetType, implementationIdx, emaTime, oracleAddress, methodName, true)];
137
+ case 1: return [2 /*return*/, _a.sent()];
138
+ }
139
+ });
104
140
  });
105
- }); };
141
+ };
106
142
  export var deployStablePlainPool = function (name, symbol, coins, A, fee, // %
107
- assetType, implementationIdx) { return __awaiter(void 0, void 0, void 0, function () {
108
- return __generator(this, function (_a) {
109
- switch (_a.label) {
110
- case 0: return [4 /*yield*/, _deployStablePlainPool(name, symbol, coins, A, fee, assetType, implementationIdx, false)];
111
- case 1: return [2 /*return*/, _a.sent()];
112
- }
143
+ assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
144
+ implementationIdx, emaTime, // seconds
145
+ oracleAddress, methodName) {
146
+ if (emaTime === void 0) { emaTime = 600; }
147
+ if (oracleAddress === void 0) { oracleAddress = curve.constants.ZERO_ADDRESS; }
148
+ if (methodName === void 0) { methodName = "0x00000000"; }
149
+ return __awaiter(void 0, void 0, void 0, function () {
150
+ return __generator(this, function (_a) {
151
+ switch (_a.label) {
152
+ case 0: return [4 /*yield*/, _deployStablePlainPool(name, symbol, coins, A, fee, assetType, implementationIdx, emaTime, oracleAddress, methodName, false)];
153
+ case 1: return [2 /*return*/, _a.sent()];
154
+ }
155
+ });
113
156
  });
114
- }); };
157
+ };
115
158
  export var getDeployedStablePlainPoolAddress = function (tx) { return __awaiter(void 0, void 0, void 0, function () {
116
159
  var txInfo;
117
160
  return __generator(this, function (_a) {
@@ -125,6 +168,52 @@ export var getDeployedStablePlainPoolAddress = function (tx) { return __awaiter(
125
168
  }
126
169
  });
127
170
  }); };
171
+ export var _setOracle = function (poolAddress, oracleAddress, methodName, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
172
+ var poolContract, methodId, _gas, gasLimit;
173
+ return __generator(this, function (_a) {
174
+ switch (_a.label) {
175
+ case 0:
176
+ curve.setContract(poolAddress, Plain2ETHOracleABIABI);
177
+ poolContract = curve.contracts[poolAddress].contract;
178
+ methodId = methodName === "0x00000000" ? "0x00000000" : ethers.id(methodName).substring(0, 10);
179
+ return [4 /*yield*/, poolContract.set_oracle.estimateGas(methodId, oracleAddress, curve.constantOptions)];
180
+ case 1:
181
+ _gas = _a.sent();
182
+ if (estimateGas)
183
+ return [2 /*return*/, Number(_gas)];
184
+ gasLimit = mulBy1_3(_gas);
185
+ return [4 /*yield*/, curve.updateFeeData()];
186
+ case 2:
187
+ _a.sent();
188
+ return [4 /*yield*/, poolContract.set_oracle(methodId, oracleAddress, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
189
+ case 3: return [2 /*return*/, _a.sent()];
190
+ }
191
+ });
192
+ }); };
193
+ export var setOracleEstimateGas = function (poolAddress, oracleAddress, methodName) {
194
+ if (oracleAddress === void 0) { oracleAddress = curve.constants.ZERO_ADDRESS; }
195
+ if (methodName === void 0) { methodName = "0x00000000"; }
196
+ return __awaiter(void 0, void 0, void 0, function () {
197
+ return __generator(this, function (_a) {
198
+ switch (_a.label) {
199
+ case 0: return [4 /*yield*/, _setOracle(poolAddress, oracleAddress, methodName, true)];
200
+ case 1: return [2 /*return*/, _a.sent()];
201
+ }
202
+ });
203
+ });
204
+ };
205
+ export var setOracle = function (poolAddress, oracleAddress, methodName) {
206
+ if (oracleAddress === void 0) { oracleAddress = curve.constants.ZERO_ADDRESS; }
207
+ if (methodName === void 0) { methodName = "0x00000000"; }
208
+ return __awaiter(void 0, void 0, void 0, function () {
209
+ return __generator(this, function (_a) {
210
+ switch (_a.label) {
211
+ case 0: return [4 /*yield*/, _setOracle(poolAddress, oracleAddress, methodName, false)];
212
+ case 1: return [2 /*return*/, _a.sent()];
213
+ }
214
+ });
215
+ });
216
+ };
128
217
  // ------- STABLE META POOLS -------
129
218
  var _deployStableMetaPool = function (basePool, name, symbol, coin, A, fee, // %
130
219
  implementationIdx, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
@@ -178,7 +267,7 @@ implementationIdx) { return __awaiter(void 0, void 0, void 0, function () {
178
267
  });
179
268
  }); };
180
269
  export var getDeployedStableMetaPoolAddress = function (tx) { return __awaiter(void 0, void 0, void 0, function () {
181
- var txInfo;
270
+ var txInfo, i, basePoolId, basePool;
182
271
  return __generator(this, function (_a) {
183
272
  switch (_a.label) {
184
273
  case 0: return [4 /*yield*/, tx.wait()];
@@ -186,7 +275,14 @@ export var getDeployedStableMetaPoolAddress = function (tx) { return __awaiter(v
186
275
  txInfo = _a.sent();
187
276
  if (!txInfo)
188
277
  throw Error("Can't get tx info");
189
- return [2 /*return*/, txInfo.logs[3].address.toLowerCase()];
278
+ for (i = txInfo.logs.length - 1; i > -1; i--) {
279
+ if ("args" in txInfo.logs[i]) {
280
+ basePoolId = getPoolIdBySwapAddress(txInfo.logs[i].args[1]);
281
+ basePool = getPool(basePoolId);
282
+ return [2 /*return*/, txInfo.logs[basePool.underlyingCoins.length].address.toLowerCase()];
283
+ }
284
+ }
285
+ throw Error("Can't get deployed metapool address");
190
286
  }
191
287
  });
192
288
  }); };
@@ -350,7 +446,7 @@ export var getDeployedGaugeAddress = function (tx) { return __awaiter(void 0, vo
350
446
  if (!txInfo)
351
447
  throw Error("Can't get tx info");
352
448
  // @ts-ignore
353
- return [2 /*return*/, txInfo.events[0].args[txInfo.events[0].args.length - 1].toLowerCase()];
449
+ return [2 /*return*/, txInfo.logs[0].args[txInfo.logs[0].args.length - 1].toLowerCase()];
354
450
  }
355
451
  });
356
452
  }); };
package/lib/index.d.ts CHANGED
@@ -58,7 +58,8 @@ declare const curve: {
58
58
  fetchPools: (useApi?: boolean) => Promise<void>;
59
59
  fetchNewPools: () => Promise<string[]>;
60
60
  getPoolList: () => string[];
61
- deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5) => Promise<ethers.ContractTransactionResponse>;
61
+ deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5, emaTime?: number, oracleAddress?: string, methodName?: string) => Promise<ethers.ContractTransactionResponse>;
62
+ setOracle: (poolAddress: string, oracleAddress?: string, methodName?: string) => Promise<ethers.ContractTransactionResponse>;
62
63
  deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: string | number, fee: string | number, implementationIdx: 0 | 1) => Promise<ethers.ContractTransactionResponse>;
63
64
  deployGauge: (poolAddress: string) => Promise<ethers.ContractTransactionResponse>;
64
65
  getDeployedPlainPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
@@ -66,7 +67,8 @@ declare const curve: {
66
67
  getDeployedGaugeAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
67
68
  fetchRecentlyDeployedPool: (poolAddress: string) => Promise<string>;
68
69
  estimateGas: {
69
- deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5) => Promise<number>;
70
+ deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3 | 4 | 5, emaTime?: number, oracleAddress?: string, methodName?: string) => Promise<number>;
71
+ setOracle: (poolAddress: string, oracleAddress?: string, methodName?: string) => Promise<number>;
70
72
  deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: string | number, fee: string | number, implementationIdx: 0 | 1) => Promise<number>;
71
73
  deployGauge: (poolAddress: string) => Promise<number>;
72
74
  };
package/lib/index.js CHANGED
@@ -40,7 +40,7 @@ import { getBestRouteAndOutput, swapExpected, swapPriceImpact, swapIsApproved, s
40
40
  import { curve as _curve } from "./curve.js";
41
41
  import { getCrv, getLockedAmountAndUnlockTime, getVeCrv, getVeCrvPct, calcUnlockTime, createLockEstimateGas, createLock, isApproved, approveEstimateGas, approve, increaseAmountEstimateGas, increaseAmount, increaseUnlockTimeEstimateGas, increaseUnlockTime, withdrawLockedCrvEstimateGas, withdrawLockedCrv, claimableFees, claimFeesEstimateGas, claimFees, } from "./boosting.js";
42
42
  import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getTVL, getCoinsData, getVolume, } from "./utils.js";
43
- import { deployStablePlainPool, deployStablePlainPoolEstimateGas, deployStableMetaPool, deployStableMetaPoolEstimateGas, deployCryptoPool, deployCryptoPoolEstimateGas, deployGauge, deployGaugeEstimateGas, getDeployedStablePlainPoolAddress, getDeployedStableMetaPoolAddress, getDeployedCryptoPoolAddress, getDeployedGaugeAddress, } from './factory/deploy.js';
43
+ import { deployStablePlainPool, deployStablePlainPoolEstimateGas, setOracle, setOracleEstimateGas, deployStableMetaPool, deployStableMetaPoolEstimateGas, deployCryptoPool, deployCryptoPoolEstimateGas, deployGauge, deployGaugeEstimateGas, getDeployedStablePlainPoolAddress, getDeployedStableMetaPoolAddress, getDeployedCryptoPoolAddress, getDeployedGaugeAddress, } from './factory/deploy.js';
44
44
  function init(providerType, providerSettings, options) {
45
45
  if (options === void 0) { options = {}; }
46
46
  return __awaiter(this, void 0, void 0, function () {
@@ -88,6 +88,7 @@ var curve = {
88
88
  fetchNewPools: _curve.fetchNewFactoryPools,
89
89
  getPoolList: _curve.getFactoryPoolList,
90
90
  deployPlainPool: deployStablePlainPool,
91
+ setOracle: setOracle,
91
92
  deployMetaPool: deployStableMetaPool,
92
93
  deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
93
94
  return [2 /*return*/, deployGauge(poolAddress, false)];
@@ -98,6 +99,7 @@ var curve = {
98
99
  fetchRecentlyDeployedPool: _curve.fetchRecentlyDeployedFactoryPool,
99
100
  estimateGas: {
100
101
  deployPlainPool: deployStablePlainPoolEstimateGas,
102
+ setOracle: setOracleEstimateGas,
101
103
  deployMetaPool: deployStableMetaPoolEstimateGas,
102
104
  deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
103
105
  return [2 /*return*/, deployGaugeEstimateGas(poolAddress, false)];
package/lib/utils.d.ts CHANGED
@@ -25,7 +25,7 @@ export declare const hasAllowance: (coins: string[], amounts: (number | string)[
25
25
  export declare const _ensureAllowance: (coins: string[], amounts: bigint[], spender: string, isMax?: boolean) => Promise<string[]>;
26
26
  export declare const ensureAllowanceEstimateGas: (coins: string[], amounts: (number | string)[], spender: string, isMax?: boolean) => Promise<number>;
27
27
  export declare const ensureAllowance: (coins: string[], amounts: (number | string)[], spender: string, isMax?: boolean) => Promise<string[]>;
28
- export declare const getPoolNameBySwapAddress: (swapAddress: string) => string;
28
+ export declare const getPoolIdBySwapAddress: (swapAddress: string) => string;
29
29
  export declare const _getUsdPricesFromApi: () => Promise<IDict<number>>;
30
30
  export declare const _getCrvApyFromApi: () => Promise<IDict<[number, number]>>;
31
31
  export declare const _getRewardsFromApi: () => Promise<IDict<IRewardFromApi[]>>;
package/lib/utils.js CHANGED
@@ -390,7 +390,7 @@ export var ensureAllowance = function (coins, amounts, spender, isMax) {
390
390
  });
391
391
  });
392
392
  };
393
- export var getPoolNameBySwapAddress = function (swapAddress) {
393
+ export var getPoolIdBySwapAddress = function (swapAddress) {
394
394
  var poolsData = __assign(__assign(__assign(__assign({}, curve.constants.POOLS_DATA), curve.constants.FACTORY_POOLS_DATA), curve.constants.CRVUSD_FACTORY_POOLS_DATA), curve.constants.CRYPTO_FACTORY_POOLS_DATA);
395
395
  return Object.entries(poolsData).filter(function (_a) {
396
396
  var _ = _a[0], poolData = _a[1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.36.1",
3
+ "version": "2.37.0",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",