@curvefi/api 2.46.1 → 2.46.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.
- package/README.md +17 -1
- package/lib/constants/abis/gauge_factory.json +1 -879
- package/lib/constants/abis/{minter_child.json → gauge_factory_sidechain.json} +0 -21
- package/lib/constants/aliases.js +13 -13
- package/lib/curve.js +6 -6
- package/lib/factory/deploy.d.ts +4 -0
- package/lib/factory/deploy.js +73 -1
- package/lib/factory/factory-crypto.js +64 -9
- package/lib/factory/factory-tricrypto.js +32 -4
- package/lib/factory/factory.js +33 -10
- package/lib/index.d.ts +12 -0
- package/lib/index.js +37 -1
- package/lib/pools/PoolTemplate.js +2 -1
- package/lib/pools/utils.js +2 -0
- package/lib/utils.js +2 -1
- package/package.json +1 -1
- package/lib/constants/abis/minter.json +0 -165
|
@@ -181,27 +181,6 @@
|
|
|
181
181
|
],
|
|
182
182
|
"outputs": []
|
|
183
183
|
},
|
|
184
|
-
{
|
|
185
|
-
"stateMutability": "nonpayable",
|
|
186
|
-
"type": "function",
|
|
187
|
-
"name": "deploy_gauge",
|
|
188
|
-
"inputs": [
|
|
189
|
-
{
|
|
190
|
-
"name": "_lp_token",
|
|
191
|
-
"type": "address"
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
"name": "_salt",
|
|
195
|
-
"type": "bytes32"
|
|
196
|
-
}
|
|
197
|
-
],
|
|
198
|
-
"outputs": [
|
|
199
|
-
{
|
|
200
|
-
"name": "",
|
|
201
|
-
"type": "address"
|
|
202
|
-
}
|
|
203
|
-
]
|
|
204
|
-
},
|
|
205
184
|
{
|
|
206
185
|
"stateMutability": "nonpayable",
|
|
207
186
|
"type": "function",
|
package/lib/constants/aliases.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { lowerCaseValues } from "./utils.js";
|
|
2
2
|
export var ALIASES_ETHEREUM = lowerCaseValues({
|
|
3
3
|
"crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
|
|
4
|
-
"
|
|
4
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
5
5
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
6
6
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
7
7
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -20,7 +20,7 @@ export var ALIASES_ETHEREUM = lowerCaseValues({
|
|
|
20
20
|
});
|
|
21
21
|
export var ALIASES_POLYGON = lowerCaseValues({
|
|
22
22
|
"crv": "0x172370d5cd63279efa6d502dab29171933a610af",
|
|
23
|
-
"
|
|
23
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
24
24
|
"voting_escrow": "0xb5acc710aede048600e10eedcefdf98d4abf4b1e",
|
|
25
25
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
26
26
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -39,7 +39,7 @@ export var ALIASES_POLYGON = lowerCaseValues({
|
|
|
39
39
|
});
|
|
40
40
|
export var ALIASES_FANTOM = lowerCaseValues({
|
|
41
41
|
"crv": "0x1E4F97b9f9F913c46F1632781732927B9019C68b",
|
|
42
|
-
"
|
|
42
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
43
43
|
"voting_escrow": "0xb75dca485e21a77e1b433ecacb74475fc67e259c",
|
|
44
44
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
45
45
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -58,7 +58,7 @@ export var ALIASES_FANTOM = lowerCaseValues({
|
|
|
58
58
|
});
|
|
59
59
|
export var ALIASES_AVALANCHE = lowerCaseValues({
|
|
60
60
|
"crv": "0x47536F17F4fF30e64A96a7555826b8f9e66ec468",
|
|
61
|
-
"
|
|
61
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
62
62
|
"voting_escrow": "0xc55837710bc500f1e3c7bb9dd1d51f7c5647e657",
|
|
63
63
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
64
64
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -77,7 +77,7 @@ export var ALIASES_AVALANCHE = lowerCaseValues({
|
|
|
77
77
|
});
|
|
78
78
|
export var ALIASES_ARBITRUM = lowerCaseValues({
|
|
79
79
|
"crv": "0x11cDb42B0EB46D95f990BeDD4695A6e3fA034978",
|
|
80
|
-
"
|
|
80
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
81
81
|
"voting_escrow": "0x98c80fa823759b642c3e02f40533c164f40727ae",
|
|
82
82
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
83
83
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -96,7 +96,7 @@ export var ALIASES_ARBITRUM = lowerCaseValues({
|
|
|
96
96
|
});
|
|
97
97
|
export var ALIASES_OPTIMISM = lowerCaseValues({
|
|
98
98
|
"crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
|
|
99
|
-
"
|
|
99
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
100
100
|
"voting_escrow": "0x65a0b01756e837e6670634816e4f5b3a3ff21107",
|
|
101
101
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
102
102
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -115,7 +115,7 @@ export var ALIASES_OPTIMISM = lowerCaseValues({
|
|
|
115
115
|
});
|
|
116
116
|
export var ALIASES_XDAI = lowerCaseValues({
|
|
117
117
|
"crv": "0x712b3d230f3c1c19db860d80619288b1f0bdd0bd",
|
|
118
|
-
"
|
|
118
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
119
119
|
"voting_escrow": "0xefde221f306152971d8e9f181bfe998447975810",
|
|
120
120
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
121
121
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -134,7 +134,7 @@ export var ALIASES_XDAI = lowerCaseValues({
|
|
|
134
134
|
});
|
|
135
135
|
export var ALIASES_MOONBEAM = lowerCaseValues({
|
|
136
136
|
"crv": "0x7C598c96D02398d89FbCb9d41Eab3DF0C16F227D",
|
|
137
|
-
"
|
|
137
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
138
138
|
"voting_escrow": "0x0000000000000000000000000000000000000000",
|
|
139
139
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
140
140
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -153,7 +153,7 @@ export var ALIASES_MOONBEAM = lowerCaseValues({
|
|
|
153
153
|
});
|
|
154
154
|
export var ALIASES_AURORA = lowerCaseValues({
|
|
155
155
|
"crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
|
|
156
|
-
"
|
|
156
|
+
"gauge_factory": "0x0000000000000000000000000000000000000000",
|
|
157
157
|
"voting_escrow": "0x0000000000000000000000000000000000000000",
|
|
158
158
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
159
159
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -172,7 +172,7 @@ export var ALIASES_AURORA = lowerCaseValues({
|
|
|
172
172
|
});
|
|
173
173
|
export var ALIASES_KAVA = lowerCaseValues({
|
|
174
174
|
"crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
|
|
175
|
-
"
|
|
175
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
176
176
|
"voting_escrow": "0x0000000000000000000000000000000000000000",
|
|
177
177
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
178
178
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -191,7 +191,7 @@ export var ALIASES_KAVA = lowerCaseValues({
|
|
|
191
191
|
});
|
|
192
192
|
export var ALIASES_CELO = lowerCaseValues({
|
|
193
193
|
"crv": "0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB",
|
|
194
|
-
"
|
|
194
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
195
195
|
"voting_escrow": "0x0000000000000000000000000000000000000000",
|
|
196
196
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
197
197
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -210,7 +210,7 @@ export var ALIASES_CELO = lowerCaseValues({
|
|
|
210
210
|
});
|
|
211
211
|
export var ALIASES_ZKSYNC = lowerCaseValues({
|
|
212
212
|
"crv": "0x0a7432cF27F1aE3825c313F3C81e7D3efD7639aB",
|
|
213
|
-
"
|
|
213
|
+
"gauge_factory": "0x0000000000000000000000000000000000000000",
|
|
214
214
|
"voting_escrow": "0x0000000000000000000000000000000000000000",
|
|
215
215
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
216
216
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -229,7 +229,7 @@ export var ALIASES_ZKSYNC = lowerCaseValues({
|
|
|
229
229
|
});
|
|
230
230
|
export var ALIASES_BASE = lowerCaseValues({
|
|
231
231
|
"crv": "0x8Ee73c484A26e0A5df2Ee2a4960B789967dd0415",
|
|
232
|
-
"
|
|
232
|
+
"gauge_factory": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
233
233
|
"voting_escrow": "0x0000000000000000000000000000000000000000",
|
|
234
234
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
235
235
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
package/lib/curve.js
CHANGED
|
@@ -63,8 +63,8 @@ import { getTricryptoFactoryPoolData } from "./factory/factory-tricrypto.js";
|
|
|
63
63
|
import ERC20Abi from './constants/abis/ERC20.json' assert { type: 'json' };
|
|
64
64
|
import cERC20Abi from './constants/abis/cERC20.json' assert { type: 'json' };
|
|
65
65
|
import yERC20Abi from './constants/abis/yERC20.json' assert { type: 'json' };
|
|
66
|
-
import
|
|
67
|
-
import
|
|
66
|
+
import gaugeFactoryABI from './constants/abis/gauge_factory.json' assert { type: 'json' };
|
|
67
|
+
import gaugeFactorySidechainABI from './constants/abis/gauge_factory_sidechain.json' assert { type: 'json' };
|
|
68
68
|
import votingEscrowABI from './constants/abis/votingescrow.json' assert { type: 'json' };
|
|
69
69
|
import anycallABI from './constants/abis/anycall.json' assert { type: 'json' };
|
|
70
70
|
import votingEscrowOracleABI from './constants/abis/voting_escrow_oracle.json' assert { type: 'json' };
|
|
@@ -539,7 +539,7 @@ var Curve = /** @class */ (function () {
|
|
|
539
539
|
case 8:
|
|
540
540
|
_h = this.constants.FACTORY_GAUGE_IMPLEMENTATIONS;
|
|
541
541
|
_j = "factory-tricrypto";
|
|
542
|
-
return [4 /*yield*/, this.contracts[this.constants.ALIASES.
|
|
542
|
+
return [4 /*yield*/, this.contracts[this.constants.ALIASES.gauge_factory].contract.get_implementation(this.constantOptions)];
|
|
543
543
|
case 9:
|
|
544
544
|
_h[_j] =
|
|
545
545
|
_k.sent();
|
|
@@ -701,7 +701,7 @@ var Curve = /** @class */ (function () {
|
|
|
701
701
|
var _a;
|
|
702
702
|
if (options === void 0) { options = {}; }
|
|
703
703
|
return __awaiter(this, void 0, void 0, function () {
|
|
704
|
-
var jsonRpcApiProviderOptions, _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,
|
|
704
|
+
var jsonRpcApiProviderOptions, _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, _gaugeFactoryABI, addressProviderContract, _o, factoryContract, _p;
|
|
705
705
|
return __generator(this, function (_q) {
|
|
706
706
|
switch (_q.label) {
|
|
707
707
|
case 0:
|
|
@@ -891,8 +891,8 @@ var Curve = /** @class */ (function () {
|
|
|
891
891
|
this.setContract(this.constants.NATIVE_TOKEN.wrappedAddress, ERC20Abi);
|
|
892
892
|
this.setContract(this.constants.ALIASES.crv, ERC20Abi);
|
|
893
893
|
this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
|
|
894
|
-
|
|
895
|
-
this.setContract(this.constants.ALIASES.
|
|
894
|
+
_gaugeFactoryABI = this.chainId === 1 ? gaugeFactoryABI : gaugeFactorySidechainABI;
|
|
895
|
+
this.setContract(this.constants.ALIASES.gauge_factory, _gaugeFactoryABI);
|
|
896
896
|
this.setContract(this.constants.ALIASES.voting_escrow, votingEscrowABI);
|
|
897
897
|
this.setContract(this.constants.ALIASES.fee_distributor, feeDistributorABI);
|
|
898
898
|
this.setContract(this.constants.ALIASES.address_provider, addressProviderABI);
|
package/lib/factory/deploy.d.ts
CHANGED
|
@@ -16,4 +16,8 @@ export declare const deployTricryptoPool: (name: string, symbol: string, coins:
|
|
|
16
16
|
export declare const getDeployedTricryptoPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
|
|
17
17
|
export declare const deployGaugeEstimateGas: (pool: string, factory: string) => Promise<number>;
|
|
18
18
|
export declare const deployGauge: (pool: string, factory: string) => Promise<ethers.ContractTransactionResponse>;
|
|
19
|
+
export declare const deployGaugeSidechainEstimateGas: (pool: string, salt: string) => Promise<number>;
|
|
20
|
+
export declare const deployGaugeSidechain: (pool: string, salt: string) => Promise<ethers.ContractTransactionResponse>;
|
|
21
|
+
export declare const deployGaugeMirrorEstimateGas: (chainId: number, salt: string) => Promise<number>;
|
|
22
|
+
export declare const deployGaugeMirror: (chainId: number, salt: string) => Promise<ethers.ContractTransactionResponse>;
|
|
19
23
|
export declare const getDeployedGaugeAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
|
package/lib/factory/deploy.js
CHANGED
|
@@ -54,7 +54,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
54
54
|
}
|
|
55
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
56
|
};
|
|
57
|
-
import { ethers, Contract } from "ethers";
|
|
57
|
+
import { ethers, Contract, Typed } from "ethers";
|
|
58
58
|
import { curve } from "../curve.js";
|
|
59
59
|
import { getPool } from "../pools/index.js";
|
|
60
60
|
import { parseUnits, BN, mulBy1_3, getPoolIdBySwapAddress } from "../utils.js";
|
|
@@ -532,6 +532,8 @@ var _deployGauge = function (pool, factory, estimateGas) { return __awaiter(void
|
|
|
532
532
|
return __generator(this, function (_a) {
|
|
533
533
|
switch (_a.label) {
|
|
534
534
|
case 0:
|
|
535
|
+
if (curve.chainId !== 1)
|
|
536
|
+
throw Error("There is no deployGauge method on sidechain network");
|
|
535
537
|
contract = curve.contracts[factory].contract;
|
|
536
538
|
return [4 /*yield*/, contract.deploy_gauge.estimateGas(pool, curve.constantOptions)];
|
|
537
539
|
case 1:
|
|
@@ -547,6 +549,52 @@ var _deployGauge = function (pool, factory, estimateGas) { return __awaiter(void
|
|
|
547
549
|
}
|
|
548
550
|
});
|
|
549
551
|
}); };
|
|
552
|
+
var _deployGaugeSidechain = function (pool, salt, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
|
|
553
|
+
var contract, _salt, gas, gasLimit;
|
|
554
|
+
return __generator(this, function (_a) {
|
|
555
|
+
switch (_a.label) {
|
|
556
|
+
case 0:
|
|
557
|
+
if (curve.chainId === 1)
|
|
558
|
+
throw Error("There is no deployGaugeSidechain method on ethereum network");
|
|
559
|
+
contract = curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
|
|
560
|
+
_salt = ethers.encodeBytes32String(salt);
|
|
561
|
+
return [4 /*yield*/, contract.deploy_gauge.estimateGas(pool, Typed.bytes32(_salt), curve.signerAddress, curve.constantOptions)];
|
|
562
|
+
case 1:
|
|
563
|
+
gas = _a.sent();
|
|
564
|
+
if (estimateGas)
|
|
565
|
+
return [2 /*return*/, Number(gas)];
|
|
566
|
+
gasLimit = mulBy1_3(gas);
|
|
567
|
+
return [4 /*yield*/, curve.updateFeeData()];
|
|
568
|
+
case 2:
|
|
569
|
+
_a.sent();
|
|
570
|
+
return [4 /*yield*/, contract.deploy_gauge(pool, Typed.bytes32(_salt), curve.signerAddress, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
571
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
}); };
|
|
575
|
+
var _deployGaugeMirror = function (chainId, salt, estimateGas) { return __awaiter(void 0, void 0, void 0, function () {
|
|
576
|
+
var contract, _salt, gas, gasLimit;
|
|
577
|
+
return __generator(this, function (_a) {
|
|
578
|
+
switch (_a.label) {
|
|
579
|
+
case 0:
|
|
580
|
+
if (curve.chainId !== 1)
|
|
581
|
+
throw Error("There is no deployGaugeMirror method on sidechain network");
|
|
582
|
+
contract = curve.contracts[curve.constants.ALIASES.gauge_factory].contract;
|
|
583
|
+
_salt = ethers.encodeBytes32String(salt);
|
|
584
|
+
return [4 /*yield*/, contract.deploy_gauge.estimateGas(chainId, Typed.bytes32(_salt), curve.constantOptions)];
|
|
585
|
+
case 1:
|
|
586
|
+
gas = _a.sent();
|
|
587
|
+
if (estimateGas)
|
|
588
|
+
return [2 /*return*/, Number(gas)];
|
|
589
|
+
gasLimit = mulBy1_3(gas);
|
|
590
|
+
return [4 /*yield*/, curve.updateFeeData()];
|
|
591
|
+
case 2:
|
|
592
|
+
_a.sent();
|
|
593
|
+
return [4 /*yield*/, contract.deploy_gauge(chainId, Typed.bytes32(_salt), __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
594
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}); };
|
|
550
598
|
export var deployGaugeEstimateGas = function (pool, factory) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
551
599
|
switch (_a.label) {
|
|
552
600
|
case 0: return [4 /*yield*/, _deployGauge(pool, factory, true)];
|
|
@@ -559,6 +607,30 @@ export var deployGauge = function (pool, factory) { return __awaiter(void 0, voi
|
|
|
559
607
|
case 1: return [2 /*return*/, _a.sent()];
|
|
560
608
|
}
|
|
561
609
|
}); }); };
|
|
610
|
+
export var deployGaugeSidechainEstimateGas = function (pool, salt) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
611
|
+
switch (_a.label) {
|
|
612
|
+
case 0: return [4 /*yield*/, _deployGaugeSidechain(pool, salt, true)];
|
|
613
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
614
|
+
}
|
|
615
|
+
}); }); };
|
|
616
|
+
export var deployGaugeSidechain = function (pool, salt) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
617
|
+
switch (_a.label) {
|
|
618
|
+
case 0: return [4 /*yield*/, _deployGaugeSidechain(pool, salt, false)];
|
|
619
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
620
|
+
}
|
|
621
|
+
}); }); };
|
|
622
|
+
export var deployGaugeMirrorEstimateGas = function (chainId, salt) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
623
|
+
switch (_a.label) {
|
|
624
|
+
case 0: return [4 /*yield*/, _deployGaugeMirror(chainId, salt, true)];
|
|
625
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
626
|
+
}
|
|
627
|
+
}); }); };
|
|
628
|
+
export var deployGaugeMirror = function (chainId, salt) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
629
|
+
switch (_a.label) {
|
|
630
|
+
case 0: return [4 /*yield*/, _deployGaugeMirror(chainId, salt, false)];
|
|
631
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
632
|
+
}
|
|
633
|
+
}); }); };
|
|
562
634
|
export var getDeployedGaugeAddress = function (tx) { return __awaiter(void 0, void 0, void 0, function () {
|
|
563
635
|
var txInfo;
|
|
564
636
|
return __generator(this, function (_a) {
|
|
@@ -126,27 +126,82 @@ function _handleCoinAddresses(coinAddresses) {
|
|
|
126
126
|
var _this = this;
|
|
127
127
|
return coinAddresses.map(function (addresses) { return addresses.map(function (addr) { return _this.chainId === 137 && addr === "0x0000000000000000000000000000000000001010" ? _this.constants.NATIVE_TOKEN.wrappedAddress : addr.toLowerCase(); }); });
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function _getLpTokenMap(factorySwapAddresses) {
|
|
130
130
|
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
-
var factoryMulticallContract,
|
|
131
|
+
var factoryMulticallContract, LpTokenMap, getLpTokenCalls, _i, factorySwapAddresses_1, addr, lpTokens;
|
|
132
132
|
return __generator(this, function (_a) {
|
|
133
133
|
switch (_a.label) {
|
|
134
134
|
case 0:
|
|
135
135
|
factoryMulticallContract = this.contracts[this.constants.ALIASES.crypto_factory].multicallContract;
|
|
136
|
-
|
|
136
|
+
LpTokenMap = {};
|
|
137
|
+
getLpTokenCalls = [];
|
|
137
138
|
for (_i = 0, factorySwapAddresses_1 = factorySwapAddresses; _i < factorySwapAddresses_1.length; _i++) {
|
|
138
139
|
addr = factorySwapAddresses_1[_i];
|
|
140
|
+
getLpTokenCalls.push(factoryMulticallContract.get_token(addr));
|
|
141
|
+
}
|
|
142
|
+
return [4 /*yield*/, this.multicallProvider.all(getLpTokenCalls)];
|
|
143
|
+
case 1:
|
|
144
|
+
lpTokens = _a.sent();
|
|
145
|
+
lpTokens.forEach(function (item, index) {
|
|
146
|
+
if (typeof item === "string") {
|
|
147
|
+
LpTokenMap[factorySwapAddresses[index]] = item;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
throw Error("Lp token is not string");
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return [2 /*return*/, LpTokenMap];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function getPoolsData(factorySwapAddresses) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
+
var factoryMulticallContract, isfactoryGaugeNull, calls, _i, factorySwapAddresses_2, addr, factoryMulticallGaugeContract, LpTokenMap, _a, factorySwapAddresses_3, addr, res, tokenAddresses, coinAddresses, gaugeAddresses, tokenAddresses, gaugeAddresses, coinAddresses;
|
|
161
|
+
return __generator(this, function (_b) {
|
|
162
|
+
switch (_b.label) {
|
|
163
|
+
case 0:
|
|
164
|
+
factoryMulticallContract = this.contracts[this.constants.ALIASES.crypto_factory].multicallContract;
|
|
165
|
+
isfactoryGaugeNull = this.constants.ALIASES.gauge_factory === '0x0000000000000000000000000000000000000000';
|
|
166
|
+
calls = [];
|
|
167
|
+
if (!(this.chainId === 1)) return [3 /*break*/, 1];
|
|
168
|
+
for (_i = 0, factorySwapAddresses_2 = factorySwapAddresses; _i < factorySwapAddresses_2.length; _i++) {
|
|
169
|
+
addr = factorySwapAddresses_2[_i];
|
|
139
170
|
calls.push(factoryMulticallContract.get_token(addr));
|
|
140
171
|
calls.push(factoryMulticallContract.get_gauge(addr));
|
|
141
172
|
calls.push(factoryMulticallContract.get_coins(addr));
|
|
142
173
|
}
|
|
143
|
-
return [
|
|
174
|
+
return [3 /*break*/, 3];
|
|
144
175
|
case 1:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
176
|
+
factoryMulticallGaugeContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
177
|
+
return [4 /*yield*/, _getLpTokenMap.call(this, factorySwapAddresses)];
|
|
178
|
+
case 2:
|
|
179
|
+
LpTokenMap = _b.sent();
|
|
180
|
+
for (_a = 0, factorySwapAddresses_3 = factorySwapAddresses; _a < factorySwapAddresses_3.length; _a++) {
|
|
181
|
+
addr = factorySwapAddresses_3[_a];
|
|
182
|
+
calls.push(factoryMulticallContract.get_token(addr));
|
|
183
|
+
if (!isfactoryGaugeNull) {
|
|
184
|
+
calls.push(factoryMulticallGaugeContract.get_gauge_from_lp_token(LpTokenMap[addr]));
|
|
185
|
+
}
|
|
186
|
+
calls.push(factoryMulticallContract.get_coins(addr));
|
|
187
|
+
}
|
|
188
|
+
_b.label = 3;
|
|
189
|
+
case 3: return [4 /*yield*/, this.multicallProvider.all(calls)];
|
|
190
|
+
case 4:
|
|
191
|
+
res = _b.sent();
|
|
192
|
+
if (isfactoryGaugeNull) {
|
|
193
|
+
tokenAddresses = res.filter(function (a, i) { return i % 3 == 0; }).map(function (a) { return a.toLowerCase(); });
|
|
194
|
+
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 3 == 1; }));
|
|
195
|
+
gaugeAddresses = Array.from(Array(factorySwapAddresses.length)).map(function () { return '0x0000000000000000000000000000000000000000'; });
|
|
196
|
+
return [2 /*return*/, [tokenAddresses, gaugeAddresses, coinAddresses]];
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
tokenAddresses = res.filter(function (a, i) { return i % 3 == 0; }).map(function (a) { return a.toLowerCase(); });
|
|
200
|
+
gaugeAddresses = res.filter(function (a, i) { return i % 3 == 1; }).map(function (a) { return a.toLowerCase(); });
|
|
201
|
+
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 3 == 2; }));
|
|
202
|
+
return [2 /*return*/, [tokenAddresses, gaugeAddresses, coinAddresses]];
|
|
203
|
+
}
|
|
204
|
+
return [2 /*return*/];
|
|
150
205
|
}
|
|
151
206
|
});
|
|
152
207
|
});
|
|
@@ -115,10 +115,11 @@ function _handleCoinAddresses(coinAddresses) {
|
|
|
115
115
|
}
|
|
116
116
|
function getPoolsData(factorySwapAddresses) {
|
|
117
117
|
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
var factoryMulticallContract, calls, _i, factorySwapAddresses_1, addr, res, gaugeAddresses, coinAddresses;
|
|
119
|
-
return __generator(this, function (
|
|
120
|
-
switch (
|
|
118
|
+
var factoryMulticallContract, calls, _i, factorySwapAddresses_1, addr, res, gaugeAddresses, coinAddresses, factoryMulticallContract, isFactoryGaugeNull, factoryMulticallGaugeContract, calls, _a, factorySwapAddresses_2, addr, res, gaugeAddresses, coinAddresses, coinAddresses, gaugeAddresses;
|
|
119
|
+
return __generator(this, function (_b) {
|
|
120
|
+
switch (_b.label) {
|
|
121
121
|
case 0:
|
|
122
|
+
if (!(this.chainId === 1)) return [3 /*break*/, 2];
|
|
122
123
|
factoryMulticallContract = this.contracts[this.constants.ALIASES.tricrypto_factory].multicallContract;
|
|
123
124
|
calls = [];
|
|
124
125
|
for (_i = 0, factorySwapAddresses_1 = factorySwapAddresses; _i < factorySwapAddresses_1.length; _i++) {
|
|
@@ -128,10 +129,37 @@ function getPoolsData(factorySwapAddresses) {
|
|
|
128
129
|
}
|
|
129
130
|
return [4 /*yield*/, this.multicallProvider.all(calls)];
|
|
130
131
|
case 1:
|
|
131
|
-
res =
|
|
132
|
+
res = _b.sent();
|
|
132
133
|
gaugeAddresses = res.filter(function (a, i) { return i % 2 == 0; }).map(function (a) { return a.toLowerCase(); });
|
|
133
134
|
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 2 == 1; }));
|
|
134
135
|
return [2 /*return*/, [gaugeAddresses, coinAddresses]];
|
|
136
|
+
case 2:
|
|
137
|
+
factoryMulticallContract = this.contracts[this.constants.ALIASES.tricrypto_factory].multicallContract;
|
|
138
|
+
isFactoryGaugeNull = this.constants.ALIASES.gauge_factory === '0x0000000000000000000000000000000000000000';
|
|
139
|
+
factoryMulticallGaugeContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
140
|
+
calls = [];
|
|
141
|
+
for (_a = 0, factorySwapAddresses_2 = factorySwapAddresses; _a < factorySwapAddresses_2.length; _a++) {
|
|
142
|
+
addr = factorySwapAddresses_2[_a];
|
|
143
|
+
if (!isFactoryGaugeNull) {
|
|
144
|
+
calls.push(factoryMulticallGaugeContract.get_gauge_from_lp_token(addr));
|
|
145
|
+
}
|
|
146
|
+
calls.push(factoryMulticallContract.get_coins(addr));
|
|
147
|
+
}
|
|
148
|
+
return [4 /*yield*/, this.multicallProvider.all(calls)];
|
|
149
|
+
case 3:
|
|
150
|
+
res = _b.sent();
|
|
151
|
+
if (!isFactoryGaugeNull) {
|
|
152
|
+
gaugeAddresses = res.filter(function (a, i) { return i % 2 == 0; }).map(function (a) { return a.toLowerCase(); });
|
|
153
|
+
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 2 == 1; }));
|
|
154
|
+
return [2 /*return*/, [gaugeAddresses, coinAddresses]];
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 2 == 0; }));
|
|
158
|
+
gaugeAddresses = Array.from(Array(factorySwapAddresses.length)).map(function () { return '0x0000000000000000000000000000000000000000'; });
|
|
159
|
+
return [2 /*return*/, [gaugeAddresses, coinAddresses]];
|
|
160
|
+
}
|
|
161
|
+
_b.label = 4;
|
|
162
|
+
case 4: return [2 /*return*/];
|
|
135
163
|
}
|
|
136
164
|
});
|
|
137
165
|
});
|
package/lib/factory/factory.js
CHANGED
|
@@ -71,6 +71,9 @@ export var BLACK_LIST = {
|
|
|
71
71
|
"0xe4199bc5c5c1f63dba47b56b6db7144c51cf0bf8",
|
|
72
72
|
"0x88c4d6534165510b2e2caf0a130d4f70aa4b6d71",
|
|
73
73
|
],
|
|
74
|
+
42161: [
|
|
75
|
+
"0xd7bb79aee866672419999a0496d99c54741d67b5"
|
|
76
|
+
]
|
|
74
77
|
};
|
|
75
78
|
var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
|
|
76
79
|
function getRecentlyCreatedPoolId(swapAddress) {
|
|
@@ -154,17 +157,24 @@ function _handleCoinAddresses(coinAddresses) {
|
|
|
154
157
|
}
|
|
155
158
|
function getPoolsData(factorySwapAddresses, factoryAddress) {
|
|
156
159
|
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
-
var factoryMulticallContract, calls, _i, factorySwapAddresses_1, addr, tempSwapContract, res, implememntationAddresses, gaugeAddresses, referenceAssets, symbols, names, isMeta, coinAddresses;
|
|
160
|
+
var factoryMulticallContract, isFactoryGaugeNull, factoryGaugeContract, calls, _i, factorySwapAddresses_1, addr, tempSwapContract, res, implememntationAddresses, gaugeAddresses, referenceAssets, symbols, names, isMeta, coinAddresses, implememntationAddresses, referenceAssets, symbols, names, isMeta, coinAddresses, gaugeAddresses;
|
|
158
161
|
return __generator(this, function (_a) {
|
|
159
162
|
switch (_a.label) {
|
|
160
163
|
case 0:
|
|
161
164
|
factoryMulticallContract = this.contracts[factoryAddress].multicallContract;
|
|
165
|
+
isFactoryGaugeNull = this.constants.ALIASES.gauge_factory === '0x0000000000000000000000000000000000000000';
|
|
166
|
+
factoryGaugeContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
162
167
|
calls = [];
|
|
163
168
|
for (_i = 0, factorySwapAddresses_1 = factorySwapAddresses; _i < factorySwapAddresses_1.length; _i++) {
|
|
164
169
|
addr = factorySwapAddresses_1[_i];
|
|
165
170
|
tempSwapContract = new MulticallContract(addr, ERC20ABI);
|
|
166
171
|
calls.push(factoryMulticallContract.get_implementation_address(addr));
|
|
167
|
-
|
|
172
|
+
if (this.chainId === 1) {
|
|
173
|
+
calls.push(factoryMulticallContract.get_gauge(addr));
|
|
174
|
+
}
|
|
175
|
+
else if (!isFactoryGaugeNull) {
|
|
176
|
+
calls.push(factoryGaugeContract.get_gauge_from_lp_token(addr));
|
|
177
|
+
}
|
|
168
178
|
calls.push(factoryMulticallContract.get_pool_asset_type(addr));
|
|
169
179
|
calls.push(tempSwapContract.symbol());
|
|
170
180
|
calls.push(tempSwapContract.name());
|
|
@@ -174,14 +184,27 @@ function getPoolsData(factorySwapAddresses, factoryAddress) {
|
|
|
174
184
|
return [4 /*yield*/, this.multicallProvider.all(calls)];
|
|
175
185
|
case 1:
|
|
176
186
|
res = _a.sent();
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
if (!isFactoryGaugeNull) {
|
|
188
|
+
implememntationAddresses = res.filter(function (a, i) { return i % 7 == 0; }).map(function (a) { return a.toLowerCase(); });
|
|
189
|
+
gaugeAddresses = res.filter(function (a, i) { return i % 7 == 1; }).map(function (a) { return a.toLowerCase(); });
|
|
190
|
+
referenceAssets = _handleReferenceAssets(res.filter(function (a, i) { return i % 7 == 2; }));
|
|
191
|
+
symbols = res.filter(function (a, i) { return i % 7 == 3; });
|
|
192
|
+
names = res.filter(function (a, i) { return i % 7 == 4; });
|
|
193
|
+
isMeta = res.filter(function (a, i) { return i % 7 == 5; });
|
|
194
|
+
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 7 == 6; }));
|
|
195
|
+
return [2 /*return*/, [implememntationAddresses, gaugeAddresses, referenceAssets, symbols, names, isMeta, coinAddresses]];
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
implememntationAddresses = res.filter(function (a, i) { return i % 7 == 0; }).map(function (a) { return a.toLowerCase(); });
|
|
199
|
+
referenceAssets = _handleReferenceAssets(res.filter(function (a, i) { return i % 7 == 1; }));
|
|
200
|
+
symbols = res.filter(function (a, i) { return i % 7 == 2; });
|
|
201
|
+
names = res.filter(function (a, i) { return i % 7 == 3; });
|
|
202
|
+
isMeta = res.filter(function (a, i) { return i % 7 == 4; });
|
|
203
|
+
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 7 == 5; }));
|
|
204
|
+
gaugeAddresses = Array.from(Array(factorySwapAddresses.length)).map(function () { return '0x0000000000000000000000000000000000000000'; });
|
|
205
|
+
return [2 /*return*/, [implememntationAddresses, gaugeAddresses, referenceAssets, symbols, names, isMeta, coinAddresses]];
|
|
206
|
+
}
|
|
207
|
+
return [2 /*return*/];
|
|
185
208
|
}
|
|
186
209
|
});
|
|
187
210
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ declare const curve: {
|
|
|
63
63
|
setOracle: (poolAddress: string, oracleAddress?: string, methodName?: string) => Promise<ethers.ContractTransactionResponse>;
|
|
64
64
|
deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: string | number, fee: string | number, implementationIdx: 0 | 1) => Promise<ethers.ContractTransactionResponse>;
|
|
65
65
|
deployGauge: (poolAddress: string) => Promise<ethers.ContractTransactionResponse>;
|
|
66
|
+
deployGaugeSidechain: (poolAddress: string, salt: string) => Promise<ethers.ContractTransactionResponse>;
|
|
67
|
+
deployGaugeMirror: (chainId: number, salt: string) => Promise<ethers.ContractTransactionResponse>;
|
|
66
68
|
getDeployedPlainPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
|
|
67
69
|
getDeployedMetaPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
|
|
68
70
|
getDeployedGaugeAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
|
|
@@ -73,6 +75,8 @@ declare const curve: {
|
|
|
73
75
|
setOracle: (poolAddress: string, oracleAddress?: string, methodName?: string) => Promise<number>;
|
|
74
76
|
deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: string | number, fee: string | number, implementationIdx: 0 | 1) => Promise<number>;
|
|
75
77
|
deployGauge: (poolAddress: string) => Promise<number>;
|
|
78
|
+
deployGaugeSidechain: (poolAddress: string, salt: string) => Promise<number>;
|
|
79
|
+
deployGaugeMirror: (chainId: number, salt: string) => Promise<number>;
|
|
76
80
|
};
|
|
77
81
|
};
|
|
78
82
|
crvUSDFactory: {
|
|
@@ -89,6 +93,8 @@ declare const curve: {
|
|
|
89
93
|
getPoolList: () => string[];
|
|
90
94
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number) => Promise<ethers.ContractTransactionResponse>;
|
|
91
95
|
deployGauge: (poolAddress: string) => Promise<ethers.ContractTransactionResponse>;
|
|
96
|
+
deployGaugeSidechain: (poolAddress: string, salt: string) => Promise<ethers.ContractTransactionResponse>;
|
|
97
|
+
deployGaugeMirror: (chainId: number, salt: string) => Promise<ethers.ContractTransactionResponse>;
|
|
92
98
|
getDeployedPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
|
|
93
99
|
getDeployedGaugeAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
|
|
94
100
|
fetchRecentlyDeployedPool: (poolAddress: string) => Promise<string>;
|
|
@@ -96,6 +102,8 @@ declare const curve: {
|
|
|
96
102
|
estimateGas: {
|
|
97
103
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: number, initialPrice: string | number) => Promise<number>;
|
|
98
104
|
deployGauge: (poolAddress: string) => Promise<number>;
|
|
105
|
+
deployGaugeSidechain: (poolAddress: string, salt: string) => Promise<number>;
|
|
106
|
+
deployGaugeMirror: (chainId: number, salt: string) => Promise<number>;
|
|
99
107
|
};
|
|
100
108
|
};
|
|
101
109
|
tricryptoFactory: {
|
|
@@ -104,6 +112,8 @@ declare const curve: {
|
|
|
104
112
|
getPoolList: () => string[];
|
|
105
113
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, emaTime: number, initialPrices: (string | number)[]) => Promise<ethers.ContractTransactionResponse>;
|
|
106
114
|
deployGauge: (poolAddress: string) => Promise<ethers.ContractTransactionResponse>;
|
|
115
|
+
deployGaugeSidechain: (poolAddress: string, salt: string) => Promise<ethers.ContractTransactionResponse>;
|
|
116
|
+
deployGaugeMirror: (chainId: number, salt: string) => Promise<ethers.ContractTransactionResponse>;
|
|
107
117
|
getDeployedPoolAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
|
|
108
118
|
getDeployedGaugeAddress: (tx: ethers.ContractTransactionResponse) => Promise<string>;
|
|
109
119
|
fetchRecentlyDeployedPool: (poolAddress: string) => Promise<string>;
|
|
@@ -111,6 +121,8 @@ declare const curve: {
|
|
|
111
121
|
estimateGas: {
|
|
112
122
|
deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, emaTime: number, initialPrices: (string | number)[]) => Promise<number>;
|
|
113
123
|
deployGauge: (poolAddress: string) => Promise<number>;
|
|
124
|
+
deployGaugeSidechain: (poolAddress: string, salt: string) => Promise<number>;
|
|
125
|
+
deployGaugeMirror: (chainId: number, salt: string) => Promise<number>;
|
|
114
126
|
};
|
|
115
127
|
};
|
|
116
128
|
estimateGas: {
|