@curvefi/api 2.66.30 → 2.67.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.
- package/lib/boosting.d.ts +33 -32
- package/lib/boosting.js +320 -252
- package/lib/cached.d.ts +4 -3
- package/lib/cached.js +63 -19
- package/lib/constants/coins/hyperliquid.d.ts +2 -0
- package/lib/constants/coins/hyperliquid.js +5 -0
- package/lib/constants/coins/index.d.ts +2 -1
- package/lib/constants/coins/index.js +2 -1
- package/lib/constants/factory/crypto.d.ts +5 -0
- package/lib/constants/factory/crypto.js +8 -0
- package/lib/constants/factory/stable.js +3 -0
- package/lib/constants/network_constants.js +37 -11
- package/lib/constants/pools/hyperliquid.d.ts +2 -0
- package/lib/constants/pools/hyperliquid.js +2 -0
- package/lib/constants/pools/index.d.ts +2 -1
- package/lib/constants/pools/index.js +2 -1
- package/lib/constants/utils.d.ts +14 -1
- package/lib/constants/utils.js +21 -6
- package/lib/constants/volumeNetworks.js +1 -1
- package/lib/curve.d.ts +5 -5
- package/lib/curve.js +21 -38
- package/lib/dao.d.ts +32 -31
- package/lib/dao.js +420 -350
- package/lib/external-api.d.ts +1 -1
- package/lib/external-api.js +2 -2
- package/lib/factory/common.d.ts +2 -1
- package/lib/factory/common.js +1 -1
- package/lib/factory/deploy.d.ts +46 -45
- package/lib/factory/deploy.js +630 -551
- package/lib/factory/factory-api.d.ts +3 -2
- package/lib/factory/factory-api.js +22 -23
- package/lib/factory/factory-crypto.d.ts +1 -1
- package/lib/factory/factory-crypto.js +12 -15
- package/lib/factory/factory-tricrypto.d.ts +1 -1
- package/lib/factory/factory-tricrypto.js +14 -15
- package/lib/factory/factory-twocrypto.d.ts +1 -1
- package/lib/factory/factory-twocrypto.js +12 -13
- package/lib/factory/factory.d.ts +4 -3
- package/lib/factory/factory.js +21 -24
- package/lib/index.d.ts +413 -104
- package/lib/index.js +253 -257
- package/lib/interfaces.d.ts +2 -0
- package/lib/pools/PoolTemplate.d.ts +13 -12
- package/lib/pools/PoolTemplate.js +279 -285
- package/lib/pools/mixins/common.js +2 -2
- package/lib/pools/mixins/depositBalancedAmountsMixins.d.ts +12 -4
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +1 -15
- package/lib/pools/mixins/depositMixins.d.ts +25 -5
- package/lib/pools/mixins/depositMixins.js +38 -76
- package/lib/pools/mixins/depositWrappedMixins.d.ts +10 -2
- package/lib/pools/mixins/depositWrappedMixins.js +17 -33
- package/lib/pools/mixins/poolBalancesMixin.d.ts +6 -2
- package/lib/pools/mixins/poolBalancesMixin.js +3 -5
- package/lib/pools/mixins/swapMixins.d.ts +20 -4
- package/lib/pools/mixins/swapMixins.js +36 -70
- package/lib/pools/mixins/swapWrappedMixins.d.ts +19 -4
- package/lib/pools/mixins/swapWrappedMixins.js +32 -60
- package/lib/pools/mixins/withdrawExpectedMixins.d.ts +12 -4
- package/lib/pools/mixins/withdrawExpectedMixins.js +6 -11
- package/lib/pools/mixins/withdrawImbalanceMixins.d.ts +20 -4
- package/lib/pools/mixins/withdrawImbalanceMixins.js +26 -53
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.d.ts +10 -2
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +12 -27
- package/lib/pools/mixins/withdrawMixins.d.ts +25 -5
- package/lib/pools/mixins/withdrawMixins.js +33 -67
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.d.ts +12 -4
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +8 -13
- package/lib/pools/mixins/withdrawOneCoinMixins.d.ts +25 -5
- package/lib/pools/mixins/withdrawOneCoinMixins.js +32 -66
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.d.ts +6 -2
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +4 -7
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.d.ts +10 -2
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +13 -29
- package/lib/pools/mixins/withdrawWrappedMixins.d.ts +10 -2
- package/lib/pools/mixins/withdrawWrappedMixins.js +14 -28
- package/lib/pools/poolConstructor.d.ts +2 -1
- package/lib/pools/poolConstructor.js +27 -28
- package/lib/pools/subClasses/corePool.d.ts +4 -1
- package/lib/pools/subClasses/corePool.js +5 -7
- package/lib/pools/subClasses/gaugePool.d.ts +5 -3
- package/lib/pools/subClasses/gaugePool.js +19 -18
- package/lib/pools/subClasses/statsPool.d.ts +2 -0
- package/lib/pools/subClasses/statsPool.js +22 -10
- package/lib/pools/subClasses/walletPool.d.ts +2 -1
- package/lib/pools/subClasses/walletPool.js +6 -6
- package/lib/pools/utils.d.ts +7 -6
- package/lib/pools/utils.js +316 -297
- package/lib/route-graph.worker.d.ts +2 -2
- package/lib/route-graph.worker.js +4 -6
- package/lib/router.d.ts +12 -11
- package/lib/router.js +331 -295
- package/lib/utils.d.ts +34 -33
- package/lib/utils.js +483 -435
- package/package.json +2 -2
package/lib/factory/deploy.js
CHANGED
|
@@ -7,597 +7,676 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
11
|
-
import { curve } from "../curve.js";
|
|
10
|
+
import { Contract, ethers, Typed } from "ethers";
|
|
12
11
|
import { NETWORK_CONSTANTS } from "../constants/network_constants.js";
|
|
13
12
|
import { getPool } from "../pools/index.js";
|
|
14
|
-
import {
|
|
15
|
-
import CurveLpTokenV5ABI from "../constants/abis/curve_lp_token_v5.json" with { type:
|
|
16
|
-
import Plain2ETHOracleABIABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" with { type:
|
|
13
|
+
import { BN, DIGas, getPoolIdBySwapAddress, mulBy1_3, parseUnits, smartNumber } from '../utils.js';
|
|
14
|
+
import CurveLpTokenV5ABI from "../constants/abis/curve_lp_token_v5.json" with { type: "json" };
|
|
15
|
+
import Plain2ETHOracleABIABI from "../constants/abis/factory-v2/Plain2ETHOracle.json" with { type: "json" };
|
|
17
16
|
// ------- STABLE PLAIN POOLS -------
|
|
18
|
-
|
|
17
|
+
function _deployStablePlainPool(name, symbol, coins, A, fee, // %
|
|
19
18
|
assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
|
|
20
19
|
implementationIdx, emaTime, // seconds
|
|
21
|
-
oracleAddress, methodName, estimateGas)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
throw Error("Invalid length of oracleAddresses. Must be same coins length");
|
|
112
|
-
if (coins.length !== _methodNames.length)
|
|
113
|
-
throw Error("Invalid length of methodNames. Must be same coins length");
|
|
114
|
-
assetTypes.forEach((item, index) => {
|
|
115
|
-
if (![0, 1, 2, 3].includes(item))
|
|
116
|
-
throw Error(`Invalid assetType. Must be one of: 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626 for assetTypes[${index}]`);
|
|
117
|
-
});
|
|
118
|
-
if (![0].includes(implementationIdx))
|
|
119
|
-
throw Error("Invalid implementationIdx. Must be 0");
|
|
120
|
-
if (emaTime <= 0)
|
|
121
|
-
throw Error(`emaTime must be > 0. Passed emaTime = ${emaTime}`);
|
|
122
|
-
const _A = parseUnits(A, 0);
|
|
123
|
-
const _fee = parseUnits(fee, 8);
|
|
124
|
-
const _offpegFeeMultiplier = parseUnits(offpegFeeMultiplier, 10);
|
|
125
|
-
const _coins = coins;
|
|
126
|
-
const contractAddress = curve.constants.ALIASES.stable_ng_factory;
|
|
127
|
-
const contract = curve.contracts[contractAddress].contract;
|
|
128
|
-
const methodIds = [];
|
|
129
|
-
_methodNames.forEach((item) => {
|
|
130
|
-
if (item === '0x00000000' || item === '') {
|
|
131
|
-
methodIds.push('0x00000000');
|
|
20
|
+
oracleAddress, methodName, estimateGas) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
if (name.length > 32)
|
|
23
|
+
throw Error("Max name length = 32");
|
|
24
|
+
if (symbol.length > 10)
|
|
25
|
+
throw Error("Max symbol length = 10");
|
|
26
|
+
if (![2, 3, 4].includes(coins.length))
|
|
27
|
+
throw Error("Invalid number of coins. Must be 2, 3 or 4");
|
|
28
|
+
if (BN(fee).lt(0.04))
|
|
29
|
+
throw Error(`fee must be >= 0.04%. Passed fee = ${fee}`);
|
|
30
|
+
if (BN(fee).gt(1))
|
|
31
|
+
throw Error(`fee must be <= 1%. Passed fee = ${fee}`);
|
|
32
|
+
if (![0, 1, 2, 3].includes(assetType))
|
|
33
|
+
throw Error("Invalid assetType. Must be one of: 0 = USD, 1 = ETH, 2 = BTC, 3 = Other");
|
|
34
|
+
if (this.chainId !== 1 || coins.length > 2) {
|
|
35
|
+
if (![0, 1, 2, 3].includes(implementationIdx))
|
|
36
|
+
throw Error("Invalid implementationIdx. Must be one 0, 1, 2 or 3");
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (![0, 1, 2, 3, 4, 5].includes(implementationIdx))
|
|
40
|
+
throw Error("Invalid implementationIdx. Must be one 0, 1, 2, 3, 4 or 5");
|
|
41
|
+
}
|
|
42
|
+
if (emaTime <= 0)
|
|
43
|
+
throw Error(`emaTime must be > 0. Passed emaTime = ${emaTime}`);
|
|
44
|
+
const _A = parseUnits(A, 0);
|
|
45
|
+
const _fee = parseUnits(fee, 8);
|
|
46
|
+
const _coins = coins.concat(Array(4 - coins.length).fill(this.constants.ZERO_ADDRESS));
|
|
47
|
+
const useProxy = (this.chainId === 1 && coins.length === 2 && implementationIdx === 4 && emaTime !== 600) ||
|
|
48
|
+
(this.chainId === 1 && coins.length === 2 && implementationIdx === 5 && emaTime !== 600) ||
|
|
49
|
+
((this.chainId === 42161 || this.chainId == 10) && coins.length === 2 && implementationIdx === 0 && emaTime !== 600);
|
|
50
|
+
const setOracle = ((this.chainId === 42161 || this.chainId == 10) && coins.length === 2 && implementationIdx === 2);
|
|
51
|
+
const contractAddress = (useProxy || setOracle) ? this.constants.ALIASES.factory_admin : this.constants.ALIASES.factory;
|
|
52
|
+
const contract = this.contracts[contractAddress].contract;
|
|
53
|
+
const args = [name, symbol, _coins, _A, _fee, assetType, implementationIdx];
|
|
54
|
+
if (useProxy || setOracle)
|
|
55
|
+
args.push(parseUnits(Math.floor(emaTime / Math.log(2)), 0));
|
|
56
|
+
if (setOracle) {
|
|
57
|
+
const methodId = methodName === "0x00000000" ? "0x00000000" : ethers.id(methodName).substring(0, 10);
|
|
58
|
+
args.push(methodId, oracleAddress);
|
|
59
|
+
}
|
|
60
|
+
const methodToCall = setOracle ? "deploy_plain_pool_and_set_oracle" : "deploy_plain_pool";
|
|
61
|
+
const gas = yield contract[methodToCall].estimateGas(...args, this.constantOptions);
|
|
62
|
+
if (estimateGas)
|
|
63
|
+
return smartNumber(gas);
|
|
64
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
65
|
+
yield this.updateFeeData();
|
|
66
|
+
return yield contract[methodToCall](...args, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export function deployStablePlainPoolEstimateGas(name_1, symbol_1, coins_1, A_1, fee_1, assetType_1, implementationIdx_1) {
|
|
70
|
+
return __awaiter(this, arguments, void 0, function* (name, symbol, coins, A, fee, // %
|
|
71
|
+
assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
|
|
72
|
+
implementationIdx, emaTime = 600, // seconds
|
|
73
|
+
oracleAddress = this.constants.ZERO_ADDRESS, methodName = "0x00000000") {
|
|
74
|
+
return yield _deployStablePlainPool.call(this, name, symbol, coins, A, fee, assetType, implementationIdx, emaTime, oracleAddress, methodName, true);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export function deployStablePlainPool(name_1, symbol_1, coins_1, A_1, fee_1, assetType_1, implementationIdx_1) {
|
|
78
|
+
return __awaiter(this, arguments, void 0, function* (name, symbol, coins, A, fee, // %
|
|
79
|
+
assetType, // 0 = USD, 1 = ETH, 2 = BTC, 3 = Other
|
|
80
|
+
implementationIdx, emaTime = 600, // seconds
|
|
81
|
+
oracleAddress = this.constants.ZERO_ADDRESS, methodName = "0x00000000") {
|
|
82
|
+
return yield _deployStablePlainPool.call(this, name, symbol, coins, A, fee, assetType, implementationIdx, emaTime, oracleAddress, methodName, false);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function _deployStableNgPlainPool(name_1, symbol_1, coins_1, A_1, fee_1, offpegFeeMultiplier_1, assetTypes_1, implementationIdx_1) {
|
|
86
|
+
return __awaiter(this, arguments, void 0, function* (name, symbol, coins, A, fee, // %
|
|
87
|
+
offpegFeeMultiplier, assetTypes, // 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626
|
|
88
|
+
implementationIdx, emaTime = 600, // seconds
|
|
89
|
+
oracleAddresses, methodNames, estimateGas) {
|
|
90
|
+
if (name.length > 32)
|
|
91
|
+
throw Error("Max name length = 32");
|
|
92
|
+
if (symbol.length > 10)
|
|
93
|
+
throw Error("Max symbol length = 10");
|
|
94
|
+
if (coins.length < 1)
|
|
95
|
+
throw Error("Invalid number of coins. Must be more than 1");
|
|
96
|
+
if (coins.length > 9)
|
|
97
|
+
throw Error("Invalid number of coins. Must be less than 9");
|
|
98
|
+
if (BN(fee).gt(1))
|
|
99
|
+
throw Error(`fee must be <= 1%. Passed fee = ${fee}`);
|
|
100
|
+
let _oracleAddresses;
|
|
101
|
+
if (oracleAddresses.length === 0) {
|
|
102
|
+
_oracleAddresses = new Array(coins.length).fill(this.constants.ZERO_ADDRESS);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
_oracleAddresses = oracleAddresses;
|
|
106
|
+
}
|
|
107
|
+
let _methodNames;
|
|
108
|
+
if (methodNames.length === 0) {
|
|
109
|
+
_methodNames = new Array(coins.length).fill("0x00000000");
|
|
132
110
|
}
|
|
133
111
|
else {
|
|
134
|
-
|
|
112
|
+
_methodNames = methodNames;
|
|
135
113
|
}
|
|
114
|
+
if (coins.length !== assetTypes.length)
|
|
115
|
+
throw Error("Invalid length of assetTypes. Must be same coins length");
|
|
116
|
+
if (coins.length !== _oracleAddresses.length)
|
|
117
|
+
throw Error("Invalid length of oracleAddresses. Must be same coins length");
|
|
118
|
+
if (coins.length !== _methodNames.length)
|
|
119
|
+
throw Error("Invalid length of methodNames. Must be same coins length");
|
|
120
|
+
assetTypes.forEach((item, index) => {
|
|
121
|
+
if (![0, 1, 2, 3].includes(item))
|
|
122
|
+
throw Error(`Invalid assetType. Must be one of: 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626 for assetTypes[${index}]`);
|
|
123
|
+
});
|
|
124
|
+
if (![0].includes(implementationIdx))
|
|
125
|
+
throw Error("Invalid implementationIdx. Must be 0");
|
|
126
|
+
if (emaTime <= 0)
|
|
127
|
+
throw Error(`emaTime must be > 0. Passed emaTime = ${emaTime}`);
|
|
128
|
+
const _A = parseUnits(A, 0);
|
|
129
|
+
const _fee = parseUnits(fee, 8);
|
|
130
|
+
const _offpegFeeMultiplier = parseUnits(offpegFeeMultiplier, 10);
|
|
131
|
+
const _coins = coins;
|
|
132
|
+
const contractAddress = this.constants.ALIASES.stable_ng_factory;
|
|
133
|
+
const contract = this.contracts[contractAddress].contract;
|
|
134
|
+
const methodIds = [];
|
|
135
|
+
_methodNames.forEach((item) => {
|
|
136
|
+
if (item === '0x00000000' || item === '') {
|
|
137
|
+
methodIds.push('0x00000000');
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
methodIds.push(ethers.id(item).substring(0, 10));
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const args = [name, symbol, _coins, _A, _fee, _offpegFeeMultiplier, emaTime, implementationIdx, assetTypes, methodIds, _oracleAddresses];
|
|
144
|
+
const gas = yield contract.deploy_plain_pool.estimateGas(...args, this.constantOptions);
|
|
145
|
+
if (estimateGas)
|
|
146
|
+
return smartNumber(gas);
|
|
147
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
148
|
+
yield this.updateFeeData();
|
|
149
|
+
return yield contract.deploy_plain_pool(...args, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
136
150
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (estimateGas)
|
|
140
|
-
return smartNumber(gas);
|
|
141
|
-
const gasLimit = mulBy1_3(DIGas(gas));
|
|
142
|
-
yield curve.updateFeeData();
|
|
143
|
-
return yield contract.deploy_plain_pool(...args, Object.assign(Object.assign({}, curve.options), { gasLimit }));
|
|
144
|
-
});
|
|
145
|
-
export const deployStableNgPlainPoolEstimateGas = (name, symbol, coins, A, fee, // %
|
|
151
|
+
}
|
|
152
|
+
export function deployStableNgPlainPoolEstimateGas(name, symbol, coins, A, fee, // %
|
|
146
153
|
offpegFeeMultiplier, assetTypes, // 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626
|
|
147
154
|
implementationIdx, emaTime, // seconds
|
|
148
|
-
oracleAddresses, methodNames)
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
|
|
155
|
+
oracleAddresses, methodNames) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
return yield _deployStableNgPlainPool.call(this, name, symbol, coins, A, fee, offpegFeeMultiplier, assetTypes, implementationIdx, emaTime, oracleAddresses, methodNames, true);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
export function deployStableNgPlainPool(name, symbol, coins, A, fee, // %
|
|
152
161
|
offpegFeeMultiplier, assetTypes, // 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626
|
|
153
162
|
implementationIdx, emaTime, // seconds
|
|
154
|
-
oracleAddresses, methodNames)
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
163
|
+
oracleAddresses, methodNames) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
return yield _deployStableNgPlainPool.call(this, name, symbol, coins, A, fee, offpegFeeMultiplier, assetTypes, implementationIdx, emaTime, oracleAddresses, methodNames, false);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
export function getDeployedStablePlainPoolAddress(tx) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
const txInfo = yield tx.wait();
|
|
171
|
+
if (!txInfo)
|
|
172
|
+
throw Error("Can't get tx info");
|
|
173
|
+
return txInfo.logs[0].address.toLowerCase();
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
export function _setOracle(poolAddress, oracleAddress, methodName, estimateGas) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
this.setContract(poolAddress, Plain2ETHOracleABIABI);
|
|
179
|
+
const poolContract = this.contracts[poolAddress].contract;
|
|
180
|
+
const methodId = methodName === "0x00000000" ? "0x00000000" : ethers.id(methodName).substring(0, 10);
|
|
181
|
+
const _gas = yield poolContract.set_oracle.estimateGas(methodId, oracleAddress, this.constantOptions);
|
|
182
|
+
if (estimateGas)
|
|
183
|
+
return Number(_gas);
|
|
184
|
+
const gasLimit = mulBy1_3(_gas);
|
|
185
|
+
yield this.updateFeeData();
|
|
186
|
+
return yield poolContract.set_oracle(methodId, oracleAddress, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
export function setOracleEstimateGas(poolAddress_1) {
|
|
190
|
+
return __awaiter(this, arguments, void 0, function* (poolAddress, oracleAddress = this.constants.ZERO_ADDRESS, methodName = "0x00000000") {
|
|
191
|
+
return yield _setOracle.call(this, poolAddress, oracleAddress, methodName, true);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
export function setOracle(poolAddress_1) {
|
|
195
|
+
return __awaiter(this, arguments, void 0, function* (poolAddress, oracleAddress = this.constants.ZERO_ADDRESS, methodName = "0x00000000") {
|
|
196
|
+
return yield _setOracle.call(this, poolAddress, oracleAddress, methodName, false);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
180
199
|
// ------- STABLE META POOLS -------
|
|
181
|
-
|
|
182
|
-
implementationIdx, estimateGas)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
200
|
+
function _deployStableMetaPool(basePool, name, symbol, coin, A, fee, // %
|
|
201
|
+
implementationIdx, estimateGas) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
if (name.length > 32)
|
|
204
|
+
throw Error("Max name length = 32");
|
|
205
|
+
if (symbol.length > 10)
|
|
206
|
+
throw Error("Max symbol length = 10");
|
|
207
|
+
if (BN(fee).lt(0.04))
|
|
208
|
+
throw Error(`fee must be >= 0.04%. Passed fee = ${fee}`);
|
|
209
|
+
if (BN(fee).gt(1))
|
|
210
|
+
throw Error(`fee must be <= 1%. Passed fee = ${fee}`);
|
|
211
|
+
if (![0, 1].includes(implementationIdx))
|
|
212
|
+
throw Error("Invalid implementationIdx. Must be one 0 or 1");
|
|
213
|
+
const _A = parseUnits(A, 0);
|
|
214
|
+
const _fee = parseUnits(fee, 8);
|
|
215
|
+
const contract = this.contracts[this.constants.ALIASES.factory].contract;
|
|
216
|
+
const gas = yield contract.deploy_metapool.estimateGas(basePool, name, symbol, coin, _A, _fee, implementationIdx, this.constantOptions);
|
|
217
|
+
if (estimateGas)
|
|
218
|
+
return smartNumber(gas);
|
|
219
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
220
|
+
yield this.updateFeeData();
|
|
221
|
+
return yield contract.deploy_metapool(basePool, name, symbol, coin, _A, _fee, implementationIdx, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
export function deployStableMetaPoolEstimateGas(basePool, name, symbol, coin, A, fee, // %
|
|
225
|
+
implementationIdx) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
227
|
+
return yield _deployStableMetaPool.call(this, basePool, name, symbol, coin, A, fee, implementationIdx, true);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
export function deployStableMetaPool(basePool, name, symbol, coin, A, fee, // %
|
|
231
|
+
implementationIdx) {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
return yield _deployStableMetaPool.call(this, basePool, name, symbol, coin, A, fee, implementationIdx, false);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function _deployStableNgMetaPool(basePool_1, name_1, symbol_1, coin_1, A_1, fee_1, offpegFeeMultiplier_1, assetType_1) {
|
|
237
|
+
return __awaiter(this, arguments, void 0, function* (basePool, name, symbol, coin, A, fee, // %
|
|
238
|
+
offpegFeeMultiplier, assetType, // 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626
|
|
239
|
+
emaTime = 600, // seconds
|
|
240
|
+
implementationIdx = 0, methodName = "0x00000000", oracleAddress = this.constants.ZERO_ADDRESS, estimateGas) {
|
|
241
|
+
if (name.length > 32)
|
|
242
|
+
throw Error("Max name length = 32");
|
|
243
|
+
if (symbol.length > 10)
|
|
244
|
+
throw Error("Max symbol length = 10");
|
|
245
|
+
if (BN(fee).gt(1))
|
|
246
|
+
throw Error(`fee must be <= 1%. Passed fee = ${fee}`);
|
|
247
|
+
if (![0, 1].includes(implementationIdx))
|
|
248
|
+
throw Error("Invalid implementationIdx. Must be one 0 or 1");
|
|
249
|
+
const _A = parseUnits(A, 0);
|
|
250
|
+
const _fee = parseUnits(fee, 8);
|
|
251
|
+
const _offpegFeeMultiplier = parseUnits(offpegFeeMultiplier, 10);
|
|
252
|
+
const methodId = methodName === "0x00000000" ? "0x00000000" : ethers.id(methodName).substring(0, 10);
|
|
253
|
+
const contract = this.contracts[this.constants.ALIASES.stable_ng_factory].contract;
|
|
254
|
+
const gas = yield contract.deploy_metapool.estimateGas(basePool, name, symbol, coin, _A, _fee, _offpegFeeMultiplier, emaTime, implementationIdx, assetType, methodId, oracleAddress, this.constantOptions);
|
|
255
|
+
if (estimateGas)
|
|
256
|
+
return smartNumber(gas);
|
|
257
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
258
|
+
yield this.updateFeeData();
|
|
259
|
+
return yield contract.deploy_metapool(basePool, name, symbol, coin, _A, _fee, _offpegFeeMultiplier, emaTime, implementationIdx, assetType, methodId, oracleAddress, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
export function deployStableNgMetaPoolEstimateGas(basePool, name, symbol, coin, A, fee, // %
|
|
236
263
|
offpegFeeMultiplier, assetType, // 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626
|
|
237
264
|
emaTime, // seconds
|
|
238
|
-
implementationIdx, methodName, oracleAddress)
|
|
239
|
-
return
|
|
240
|
-
|
|
241
|
-
|
|
265
|
+
implementationIdx, methodName, oracleAddress) {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
return yield _deployStableNgMetaPool.call(this, basePool, name, symbol, coin, A, fee, offpegFeeMultiplier, assetType, emaTime, implementationIdx, methodName, oracleAddress, true);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
export function deployStableNgMetaPool(basePool, name, symbol, coin, A, fee, // %
|
|
242
271
|
offpegFeeMultiplier, emaTime, // seconds
|
|
243
272
|
implementationIdx, assetType, // 0 = Standard, 1 = Oracle, 2 = Rebasing, 3 = ERC4626
|
|
244
|
-
methodName, oracleAddress)
|
|
245
|
-
return
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
273
|
+
methodName, oracleAddress) {
|
|
274
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
275
|
+
return yield _deployStableNgMetaPool.call(this, basePool, name, symbol, coin, A, fee, offpegFeeMultiplier, assetType, emaTime, implementationIdx, methodName, oracleAddress, false);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
export function getDeployedStableMetaPoolAddress(tx) {
|
|
279
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
280
|
+
const txInfo = yield tx.wait();
|
|
281
|
+
if (!txInfo)
|
|
282
|
+
throw Error("Can't get tx info");
|
|
283
|
+
for (let i = txInfo.logs.length - 1; i > -1; i--) {
|
|
284
|
+
if ("args" in txInfo.logs[i]) {
|
|
285
|
+
const basePoolId = getPoolIdBySwapAddress.call(this, txInfo.logs[i].args[1]);
|
|
286
|
+
const basePool = getPool.call(this, basePoolId);
|
|
287
|
+
return txInfo.logs[basePool.underlyingCoins.length].address.toLowerCase();
|
|
288
|
+
}
|
|
256
289
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
290
|
+
throw Error("Can't get deployed metapool address");
|
|
291
|
+
});
|
|
292
|
+
}
|
|
260
293
|
// ------- CRYPTO POOLS -------
|
|
261
|
-
|
|
294
|
+
function _deployCryptoPool(name, symbol, coins, A, gamma, midFee, // %
|
|
262
295
|
outFee, // %
|
|
263
296
|
allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, // Seconds
|
|
264
|
-
initialPrice, estimateGas)
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
});
|
|
327
|
-
|
|
297
|
+
initialPrice, estimateGas) {
|
|
298
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
299
|
+
if (name.length > 32)
|
|
300
|
+
throw Error("Max name length = 32");
|
|
301
|
+
if (symbol.length > 10)
|
|
302
|
+
throw Error("Max symbol length = 10");
|
|
303
|
+
if (coins.length !== 2)
|
|
304
|
+
throw Error("Invalid number of coins. Must be 2");
|
|
305
|
+
if (coins[0] === coins[1])
|
|
306
|
+
throw Error("Coins must be different");
|
|
307
|
+
if (BN(A).lt(4000))
|
|
308
|
+
throw Error(`A must be >= 4000. Passed A = ${A}`);
|
|
309
|
+
if (BN(A).gt(4 * (Math.pow(10, 9))))
|
|
310
|
+
throw Error(`A must be <= 4 * 10 ** 9. Passed A = ${A}`);
|
|
311
|
+
if (BN(gamma).lt(1e-8))
|
|
312
|
+
throw Error(`gamma must be >= 1e-8. Passed gamma = ${gamma}`);
|
|
313
|
+
if (BN(gamma).gt(0.02))
|
|
314
|
+
throw Error(`gamma must be <= 0.02. Passed gamma = ${gamma}`);
|
|
315
|
+
if (BN(midFee).lt(0.005))
|
|
316
|
+
throw Error(`midFee must be >= 0.005. Passed midFee = ${midFee}`);
|
|
317
|
+
if (BN(midFee).gt(100))
|
|
318
|
+
throw Error(`midFee must be <= 100. Passed midFee = ${midFee}`);
|
|
319
|
+
if (BN(outFee).lt(BN(midFee)))
|
|
320
|
+
throw Error(`outFee must be >= midFee. Passed outFee = ${outFee} < midFee = ${midFee}`);
|
|
321
|
+
if (BN(outFee).gt(100))
|
|
322
|
+
throw Error(`outFee must be <= 100. Passed outFee = ${outFee}`);
|
|
323
|
+
if (BN(allowedExtraProfit).lt(0))
|
|
324
|
+
throw Error(`allowedExtraProfit must be >= 0. Passed allowedExtraProfit = ${allowedExtraProfit}`);
|
|
325
|
+
if (BN(allowedExtraProfit).gt(0.01))
|
|
326
|
+
throw Error(`allowedExtraProfit must be <= 0.01. Passed allowedExtraProfit = ${allowedExtraProfit}`);
|
|
327
|
+
if (BN(feeGamma).lt(0))
|
|
328
|
+
throw Error(`feeGamma must be >= 0. Passed feeGamma = ${feeGamma}`);
|
|
329
|
+
if (BN(feeGamma).gt(1))
|
|
330
|
+
throw Error(`feeGamma must be <= 1. Passed feeGamma = ${feeGamma}`);
|
|
331
|
+
if (BN(adjustmentStep).lt(0))
|
|
332
|
+
throw Error(`adjustmentStep must be >= 0. Passed adjustmentStep=${adjustmentStep}`);
|
|
333
|
+
if (BN(adjustmentStep).gt(1))
|
|
334
|
+
throw Error(`adjustmentStep must be <= 1. Passed adjustmentStep=${adjustmentStep}`);
|
|
335
|
+
if (BN(maHalfTime).lt(0))
|
|
336
|
+
throw Error(`maHalfTime must be >= 0. Passed maHalfTime=${maHalfTime}`);
|
|
337
|
+
if (BN(maHalfTime).gt(604800))
|
|
338
|
+
throw Error(`maHalfTime must be <= 604800. Passed maHalfTime=${maHalfTime}`);
|
|
339
|
+
if (BN(initialPrice).lt(1e-12))
|
|
340
|
+
throw Error(`initialPrice must be >= 1e-12. Passed initialPrice=${initialPrice}`);
|
|
341
|
+
if (BN(initialPrice).gt(1e12))
|
|
342
|
+
throw Error(`initialPrice must be <= 1e12. Passed initialPrice=${initialPrice}`);
|
|
343
|
+
const _A = parseUnits(A, 0);
|
|
344
|
+
const _gamma = parseUnits(gamma);
|
|
345
|
+
const _midFee = parseUnits(midFee, 8);
|
|
346
|
+
const _outFee = parseUnits(outFee, 8);
|
|
347
|
+
const _allowedExtraProfit = parseUnits(allowedExtraProfit);
|
|
348
|
+
const _feeGamma = parseUnits(feeGamma);
|
|
349
|
+
const _adjustmentStep = parseUnits(adjustmentStep);
|
|
350
|
+
const _maHalfTime = parseUnits(maHalfTime, 0);
|
|
351
|
+
const _initialPrice = parseUnits(initialPrice);
|
|
352
|
+
const contract = this.contracts[this.constants.ALIASES.crypto_factory].contract;
|
|
353
|
+
const gas = yield contract.deploy_pool.estimateGas(name, symbol, coins, _A, _gamma, _midFee, _outFee, _allowedExtraProfit, _feeGamma, _adjustmentStep, 5000000000, _maHalfTime, _initialPrice, this.constantOptions);
|
|
354
|
+
if (estimateGas)
|
|
355
|
+
return smartNumber(gas);
|
|
356
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
357
|
+
yield this.updateFeeData();
|
|
358
|
+
return yield contract.deploy_pool(name, symbol, coins, _A, _gamma, _midFee, _outFee, _allowedExtraProfit, _feeGamma, _adjustmentStep, 5000000000, // 50%
|
|
359
|
+
_maHalfTime, _initialPrice, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
export function deployCryptoPoolEstimateGas(name, symbol, coins, A, gamma, midFee, // %
|
|
328
363
|
outFee, // %
|
|
329
364
|
allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, // Seconds
|
|
330
|
-
initialPrice)
|
|
331
|
-
return
|
|
332
|
-
|
|
333
|
-
|
|
365
|
+
initialPrice) {
|
|
366
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
367
|
+
return yield _deployCryptoPool.call(this, name, symbol, coins, A, gamma, midFee, outFee, allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, initialPrice, true);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
export function deployCryptoPool(name, symbol, coins, A, gamma, midFee, // %
|
|
334
371
|
outFee, // %
|
|
335
372
|
allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, // Seconds
|
|
336
|
-
initialPrice)
|
|
337
|
-
return
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
373
|
+
initialPrice) {
|
|
374
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
375
|
+
return yield _deployCryptoPool.call(this, name, symbol, coins, A, gamma, midFee, outFee, allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, initialPrice, false);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
export function getDeployedCryptoPoolAddress(tx) {
|
|
379
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
380
|
+
const txInfo = yield tx.wait();
|
|
381
|
+
if (!txInfo)
|
|
382
|
+
throw Error("Can't get tx info");
|
|
383
|
+
const lpTokenAddress = txInfo.logs[0].address;
|
|
384
|
+
const contract = new Contract(lpTokenAddress, CurveLpTokenV5ABI, this.provider);
|
|
385
|
+
return (yield contract.minter(this.constantOptions)).toLowerCase();
|
|
386
|
+
});
|
|
387
|
+
}
|
|
347
388
|
// ------- TWOCRYPTO POOLS -------
|
|
348
|
-
|
|
389
|
+
function _deployTwocryptoPool(name, symbol, coins, A, gamma, midFee, // %
|
|
349
390
|
outFee, // %
|
|
350
391
|
allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, // Seconds
|
|
351
|
-
initialPrice, estimateGas)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
});
|
|
415
|
-
|
|
392
|
+
initialPrice, estimateGas) {
|
|
393
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
394
|
+
if (name.length > 32)
|
|
395
|
+
throw Error("Max name length = 32");
|
|
396
|
+
if (symbol.length > 10)
|
|
397
|
+
throw Error("Max symbol length = 10");
|
|
398
|
+
if (coins.length !== 2)
|
|
399
|
+
throw Error("Invalid number of coins. Must be 2");
|
|
400
|
+
if (coins[0] === coins[1])
|
|
401
|
+
throw Error("Coins must be different");
|
|
402
|
+
if (BN(A).lt(4000))
|
|
403
|
+
throw Error(`A must be >= 4000. Passed A = ${A}`);
|
|
404
|
+
if (BN(A).gt(4 * (Math.pow(10, 9))))
|
|
405
|
+
throw Error(`A must be <= 4 * 10 ** 9. Passed A = ${A}`);
|
|
406
|
+
const MIN_GAMMA = BN((Math.pow(10, 10)) / (Math.pow(10, 18)));
|
|
407
|
+
const MAX_GAMMA = BN(199 * (Math.pow(10, 15)) / (Math.pow(10, 18)));
|
|
408
|
+
if (BN(gamma).lt(MIN_GAMMA))
|
|
409
|
+
throw Error(`gamma must be >= ${MIN_GAMMA}. Passed gamma = ${gamma}`);
|
|
410
|
+
if (BN(gamma).gt(MAX_GAMMA))
|
|
411
|
+
throw Error(`gamma must be <= ${MAX_GAMMA}. Passed gamma = ${gamma}`);
|
|
412
|
+
if (BN(midFee).lt(0.005))
|
|
413
|
+
throw Error(`midFee must be >= 0.005. Passed midFee = ${midFee}`);
|
|
414
|
+
if (BN(midFee).gt(100))
|
|
415
|
+
throw Error(`midFee must be <= 100. Passed midFee = ${midFee}`);
|
|
416
|
+
if (BN(outFee).lt(BN(midFee)))
|
|
417
|
+
throw Error(`outFee must be >= midFee. Passed outFee = ${outFee} < midFee = ${midFee}`);
|
|
418
|
+
if (BN(outFee).gt(100))
|
|
419
|
+
throw Error(`outFee must be <= 100. Passed outFee = ${outFee}`);
|
|
420
|
+
if (BN(allowedExtraProfit).lt(0))
|
|
421
|
+
throw Error(`allowedExtraProfit must be >= 0. Passed allowedExtraProfit = ${allowedExtraProfit}`);
|
|
422
|
+
if (BN(allowedExtraProfit).gt(0.01))
|
|
423
|
+
throw Error(`allowedExtraProfit must be <= 0.01. Passed allowedExtraProfit = ${allowedExtraProfit}`);
|
|
424
|
+
if (BN(feeGamma).lt(0))
|
|
425
|
+
throw Error(`feeGamma must be >= 0. Passed feeGamma = ${feeGamma}`);
|
|
426
|
+
if (BN(feeGamma).gt(1))
|
|
427
|
+
throw Error(`feeGamma must be <= 1. Passed feeGamma = ${feeGamma}`);
|
|
428
|
+
if (BN(adjustmentStep).lt(0))
|
|
429
|
+
throw Error(`adjustmentStep must be >= 0. Passed adjustmentStep=${adjustmentStep}`);
|
|
430
|
+
if (BN(adjustmentStep).gt(1))
|
|
431
|
+
throw Error(`adjustmentStep must be <= 1. Passed adjustmentStep=${adjustmentStep}`);
|
|
432
|
+
if (BN(maHalfTime).lt(0))
|
|
433
|
+
throw Error(`maHalfTime must be >= 0. Passed maHalfTime=${maHalfTime}`);
|
|
434
|
+
if (BN(maHalfTime).gt(604800))
|
|
435
|
+
throw Error(`maHalfTime must be <= 604800. Passed maHalfTime=${maHalfTime}`);
|
|
436
|
+
if (BN(initialPrice).lt(1e-12))
|
|
437
|
+
throw Error(`initialPrice must be >= 1e-12. Passed initialPrice=${initialPrice}`);
|
|
438
|
+
if (BN(initialPrice).gt(1e12))
|
|
439
|
+
throw Error(`initialPrice must be <= 1e12. Passed initialPrice=${initialPrice}`);
|
|
440
|
+
const _A = parseUnits(A, 0);
|
|
441
|
+
const _gamma = parseUnits(gamma);
|
|
442
|
+
const _midFee = parseUnits(midFee, 8);
|
|
443
|
+
const _outFee = parseUnits(outFee, 8);
|
|
444
|
+
const _allowedExtraProfit = parseUnits(allowedExtraProfit);
|
|
445
|
+
const _feeGamma = parseUnits(feeGamma);
|
|
446
|
+
const _adjustmentStep = parseUnits(adjustmentStep);
|
|
447
|
+
const _maHalfTime = parseUnits(maHalfTime, 0);
|
|
448
|
+
const _initialPrice = parseUnits(initialPrice);
|
|
449
|
+
const contract = this.contracts[this.constants.ALIASES.twocrypto_factory].contract;
|
|
450
|
+
const gas = yield contract.deploy_pool.estimateGas(name, symbol, coins, 0, _A, _gamma, _midFee, _outFee, _feeGamma, _allowedExtraProfit, _adjustmentStep, _maHalfTime, _initialPrice, this.constantOptions);
|
|
451
|
+
if (estimateGas)
|
|
452
|
+
return smartNumber(gas);
|
|
453
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
454
|
+
yield this.updateFeeData();
|
|
455
|
+
return yield contract.deploy_pool(name, symbol, coins, 0, _A, _gamma, _midFee, _outFee, _feeGamma, _allowedExtraProfit, _adjustmentStep, _maHalfTime, _initialPrice, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
export function deployTwocryptoPoolEstimateGas(name, symbol, coins, A, gamma, midFee, // %
|
|
416
459
|
outFee, // %
|
|
417
460
|
allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, // Seconds
|
|
418
|
-
initialPrice)
|
|
419
|
-
return
|
|
420
|
-
|
|
421
|
-
|
|
461
|
+
initialPrice) {
|
|
462
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
463
|
+
return yield _deployTwocryptoPool.call(this, name, symbol, coins, A, gamma, midFee, outFee, allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, initialPrice, true);
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
export function deployTwocryptoPool(name, symbol, coins, A, gamma, midFee, // %
|
|
422
467
|
outFee, // %
|
|
423
468
|
allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, // Seconds
|
|
424
|
-
initialPrice)
|
|
425
|
-
return
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (
|
|
433
|
-
|
|
434
|
-
|
|
469
|
+
initialPrice) {
|
|
470
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
471
|
+
return yield _deployTwocryptoPool.call(this, name, symbol, coins, A, gamma, midFee, outFee, allowedExtraProfit, feeGamma, adjustmentStep, maHalfTime, initialPrice, false);
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
export function getDeployedTwocryptoPoolAddress(tx) {
|
|
475
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
476
|
+
const txInfo = yield tx.wait();
|
|
477
|
+
if (!txInfo)
|
|
478
|
+
throw Error("Can't get tx info");
|
|
479
|
+
for (let i = txInfo.logs.length - 1; i > -1; i--) {
|
|
480
|
+
if ("args" in txInfo.logs[i]) {
|
|
481
|
+
return txInfo.logs[i].args[0];
|
|
482
|
+
}
|
|
435
483
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
484
|
+
throw Error("Can't get deployed tricrypto pool address");
|
|
485
|
+
});
|
|
486
|
+
}
|
|
439
487
|
// ------- TRICRYPTO POOLS -------
|
|
440
|
-
|
|
488
|
+
function _deployTricryptoPool(name, symbol, coins, A, gamma, midFee, // %
|
|
441
489
|
outFee, // %
|
|
442
490
|
allowedExtraProfit, feeGamma, adjustmentStep, emaTime, // Seconds
|
|
443
|
-
initialPrices, estimateGas)
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
});
|
|
512
|
-
|
|
491
|
+
initialPrices, estimateGas) {
|
|
492
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
493
|
+
var _a, _b, _c, _d;
|
|
494
|
+
if (name.length > 64)
|
|
495
|
+
throw Error("Max name length = 64");
|
|
496
|
+
if (symbol.length > 32)
|
|
497
|
+
throw Error("Max symbol length = 32");
|
|
498
|
+
if (coins.length !== 3)
|
|
499
|
+
throw Error("Invalid number of coins. Must be 3");
|
|
500
|
+
if (coins[0] === coins[1] || coins[1] === coins[2] || coins[0] === coins[2])
|
|
501
|
+
throw Error("Coins must be different");
|
|
502
|
+
if (BN(A).lt(2700))
|
|
503
|
+
throw Error(`A must be >= 2700. Passed A = ${A}`);
|
|
504
|
+
if (BN(A).gt(27 * (Math.pow(10, 7))))
|
|
505
|
+
throw Error(`A must be <= 27 * 10 ** 7. Passed A = ${A}`);
|
|
506
|
+
if (BN(gamma).lt(1e-8))
|
|
507
|
+
throw Error(`gamma must be >= 1e-8. Passed gamma = ${gamma}`);
|
|
508
|
+
if (BN(gamma).gt(0.05))
|
|
509
|
+
throw Error(`gamma must be <= 0.05. Passed gamma = ${gamma}`);
|
|
510
|
+
if (BN(midFee).lt(0))
|
|
511
|
+
throw Error(`midFee must be >= 0. Passed midFee = ${midFee}`);
|
|
512
|
+
if (BN(midFee).gt(100))
|
|
513
|
+
throw Error(`midFee must be <= 100. Passed midFee = ${midFee}`);
|
|
514
|
+
if (BN(outFee).lt(BN(midFee)))
|
|
515
|
+
throw Error(`outFee must be >= midFee. Passed outFee = ${outFee} < midFee = ${midFee}`);
|
|
516
|
+
if (BN(outFee).gt(100))
|
|
517
|
+
throw Error(`outFee must be <= 100. Passed outFee = ${outFee}`);
|
|
518
|
+
if (BN(allowedExtraProfit).lt(0))
|
|
519
|
+
throw Error(`allowedExtraProfit must be >= 0. Passed allowedExtraProfit = ${allowedExtraProfit}`);
|
|
520
|
+
if (BN(allowedExtraProfit).gt(1))
|
|
521
|
+
throw Error(`allowedExtraProfit must be <= 1. Passed allowedExtraProfit = ${allowedExtraProfit}`);
|
|
522
|
+
if (BN(feeGamma).lt(0))
|
|
523
|
+
throw Error(`feeGamma must be >= 0. Passed feeGamma = ${feeGamma}`);
|
|
524
|
+
if (BN(feeGamma).gt(1))
|
|
525
|
+
throw Error(`feeGamma must be <= 1. Passed feeGamma = ${feeGamma}`);
|
|
526
|
+
if (BN(adjustmentStep).lt(0))
|
|
527
|
+
throw Error(`adjustmentStep must be >= 0. Passed adjustmentStep=${adjustmentStep}`);
|
|
528
|
+
if (BN(adjustmentStep).gt(1))
|
|
529
|
+
throw Error(`adjustmentStep must be <= 1. Passed adjustmentStep=${adjustmentStep}`);
|
|
530
|
+
if (BN(emaTime).lt(60))
|
|
531
|
+
throw Error(`maHalfTime must be >= 60. Passed maHalfTime=${emaTime}`);
|
|
532
|
+
if (BN(emaTime).gt(604800))
|
|
533
|
+
throw Error(`maHalfTime must be <= 604800. Passed maHalfTime=${emaTime}`);
|
|
534
|
+
if (initialPrices.length !== 2)
|
|
535
|
+
throw Error("Invalid number of initial prices. Must be 2");
|
|
536
|
+
if (BN(initialPrices[0]).lt(1e-12))
|
|
537
|
+
throw Error(`initialPrices[0] must be >= 1e-12. Passed initialPrices[0]=${initialPrices[0]}`);
|
|
538
|
+
if (BN(initialPrices[0]).gt(1e12))
|
|
539
|
+
throw Error(`initialPrices[0] must be <= 1e12. Passed initialPrices[0]=${initialPrices[0]}`);
|
|
540
|
+
if (BN(initialPrices[1]).lt(1e-12))
|
|
541
|
+
throw Error(`initialPrices[1] must be >= 1e-12. Passed initialPrices[1]=${initialPrices[1]}`);
|
|
542
|
+
if (BN(initialPrices[1]).gt(1e12))
|
|
543
|
+
throw Error(`initialPrices[1] must be <= 1e12. Passed initialPrices[1]=${initialPrices[1]}`);
|
|
544
|
+
const _A = parseUnits(A, 0);
|
|
545
|
+
const _gamma = parseUnits(gamma);
|
|
546
|
+
const _midFee = parseUnits(midFee, 8);
|
|
547
|
+
const _outFee = parseUnits(outFee, 8);
|
|
548
|
+
const _allowedExtraProfit = parseUnits(allowedExtraProfit);
|
|
549
|
+
const _feeGamma = parseUnits(feeGamma);
|
|
550
|
+
const _adjustmentStep = parseUnits(adjustmentStep);
|
|
551
|
+
const _emaTime = parseUnits(Math.floor(emaTime / Math.log(2)), 0);
|
|
552
|
+
const _initialPrices = [parseUnits(initialPrices[0]), parseUnits(initialPrices[1])];
|
|
553
|
+
const contract = this.contracts[this.constants.ALIASES.tricrypto_factory].contract;
|
|
554
|
+
const gas = yield contract.deploy_pool.estimateGas(name, symbol, coins, this.constants.ZERO_ADDRESS, (_b = (_a = this.constants.CRYPTO_FACTORY_CONSTANTS.tricryptoDeployImplementations) === null || _a === void 0 ? void 0 : _a.implementationIdx) !== null && _b !== void 0 ? _b : 0, _A, _gamma, _midFee, _outFee, _feeGamma, _allowedExtraProfit, _adjustmentStep, _emaTime, _initialPrices, this.constantOptions);
|
|
555
|
+
if (estimateGas)
|
|
556
|
+
return smartNumber(gas);
|
|
557
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
558
|
+
yield this.updateFeeData();
|
|
559
|
+
return yield contract.deploy_pool(name, symbol, coins, this.constants.NATIVE_TOKEN.wrappedAddress, (_d = (_c = this.constants.CRYPTO_FACTORY_CONSTANTS.tricryptoDeployImplementations) === null || _c === void 0 ? void 0 : _c.implementationIdx) !== null && _d !== void 0 ? _d : 0, _A, _gamma, _midFee, _outFee, _feeGamma, _allowedExtraProfit, _adjustmentStep, _emaTime, _initialPrices, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
export function deployTricryptoPoolEstimateGas(name, symbol, coins, A, gamma, midFee, // %
|
|
513
563
|
outFee, // %
|
|
514
564
|
allowedExtraProfit, feeGamma, adjustmentStep, emaTime, // Seconds
|
|
515
|
-
initialPrices)
|
|
516
|
-
return
|
|
517
|
-
|
|
518
|
-
|
|
565
|
+
initialPrices) {
|
|
566
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
567
|
+
return yield _deployTricryptoPool.call(this, name, symbol, coins, A, gamma, midFee, outFee, allowedExtraProfit, feeGamma, adjustmentStep, emaTime, initialPrices, true);
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
export function deployTricryptoPool(name, symbol, coins, A, gamma, midFee, // %
|
|
519
571
|
outFee, // %
|
|
520
572
|
allowedExtraProfit, feeGamma, adjustmentStep, emaTime, // Seconds
|
|
521
|
-
initialPrices)
|
|
522
|
-
return
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (
|
|
530
|
-
|
|
531
|
-
|
|
573
|
+
initialPrices) {
|
|
574
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
575
|
+
return yield _deployTricryptoPool.call(this, name, symbol, coins, A, gamma, midFee, outFee, allowedExtraProfit, feeGamma, adjustmentStep, emaTime, initialPrices, false);
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
export function getDeployedTricryptoPoolAddress(tx) {
|
|
579
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
580
|
+
const txInfo = yield tx.wait();
|
|
581
|
+
if (!txInfo)
|
|
582
|
+
throw Error("Can't get tx info");
|
|
583
|
+
for (let i = txInfo.logs.length - 1; i > -1; i--) {
|
|
584
|
+
if ("args" in txInfo.logs[i]) {
|
|
585
|
+
return txInfo.logs[i].args[0];
|
|
586
|
+
}
|
|
532
587
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
588
|
+
throw Error("Can't get deployed tricrypto pool address");
|
|
589
|
+
});
|
|
590
|
+
}
|
|
536
591
|
// ------- GAUGE -------
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
export
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
592
|
+
function _deployGauge(pool, factory, estimateGas) {
|
|
593
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
594
|
+
if (this.chainId !== 1)
|
|
595
|
+
throw Error("There is no deployGauge method on sidechain network");
|
|
596
|
+
const contract = this.contracts[factory].contract;
|
|
597
|
+
const gas = yield contract.deploy_gauge.estimateGas(pool, this.constantOptions);
|
|
598
|
+
if (estimateGas)
|
|
599
|
+
return smartNumber(gas);
|
|
600
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
601
|
+
yield this.updateFeeData();
|
|
602
|
+
return yield contract.deploy_gauge(pool, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
function _deployGaugeSidechain(pool, salt, estimateGas) {
|
|
606
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
607
|
+
if (this.chainId === 1)
|
|
608
|
+
throw Error("There is no deployGaugeSidechain method on ethereum network");
|
|
609
|
+
const contract = this.contracts[this.constants.ALIASES.child_gauge_factory].contract;
|
|
610
|
+
const _salt = ethers.encodeBytes32String(salt);
|
|
611
|
+
const gas = yield contract.deploy_gauge.estimateGas(pool, Typed.bytes32(_salt), this.signerAddress, this.constantOptions);
|
|
612
|
+
if (estimateGas)
|
|
613
|
+
return smartNumber(gas);
|
|
614
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
615
|
+
yield this.updateFeeData();
|
|
616
|
+
return yield contract.deploy_gauge(pool, Typed.bytes32(_salt), this.signerAddress, Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
function _deployGaugeMirror(chainId, salt, estimateGas) {
|
|
620
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
621
|
+
if (this.chainId !== 1)
|
|
622
|
+
throw Error("There is no deployGaugeMirror method on sidechain network");
|
|
623
|
+
const rootGaugeFactory = chainId !== 42161 ? NETWORK_CONSTANTS[this.chainId].ALIASES.root_gauge_factory : NETWORK_CONSTANTS[this.chainId].ALIASES.root_gauge_factory_arbitrum;
|
|
624
|
+
const contract = this.contracts[rootGaugeFactory].contract;
|
|
625
|
+
const _salt = ethers.encodeBytes32String(salt);
|
|
626
|
+
const gas = yield contract.deploy_gauge.estimateGas(chainId, Typed.bytes32(_salt), this.constantOptions);
|
|
627
|
+
if (estimateGas)
|
|
628
|
+
return smartNumber(gas);
|
|
629
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
630
|
+
yield this.updateFeeData();
|
|
631
|
+
return yield contract.deploy_gauge(chainId, Typed.bytes32(_salt), Object.assign(Object.assign({}, this.options), { gasLimit }));
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
export function deployGaugeEstimateGas(pool, factory) {
|
|
635
|
+
return __awaiter(this, void 0, void 0, function* () { return yield _deployGauge.call(this, pool, factory, true); });
|
|
636
|
+
}
|
|
637
|
+
export function deployGauge(pool, factory) {
|
|
638
|
+
return __awaiter(this, void 0, void 0, function* () { return yield _deployGauge.call(this, pool, factory, false); });
|
|
639
|
+
}
|
|
640
|
+
export function deployGaugeSidechainEstimateGas(pool, salt) {
|
|
641
|
+
return __awaiter(this, void 0, void 0, function* () { return yield _deployGaugeSidechain.call(this, pool, salt, true); });
|
|
642
|
+
}
|
|
643
|
+
export function deployGaugeSidechain(pool, salt) {
|
|
644
|
+
return __awaiter(this, void 0, void 0, function* () { return yield _deployGaugeSidechain.call(this, pool, salt, false); });
|
|
645
|
+
}
|
|
646
|
+
export function deployGaugeMirrorEstimateGas(chainId, salt) {
|
|
647
|
+
return __awaiter(this, void 0, void 0, function* () { return yield _deployGaugeMirror.call(this, chainId, salt, true); });
|
|
648
|
+
}
|
|
649
|
+
export function deployGaugeMirror(chainId, salt) {
|
|
650
|
+
return __awaiter(this, void 0, void 0, function* () { return yield _deployGaugeMirror.call(this, chainId, salt, false); });
|
|
651
|
+
}
|
|
652
|
+
export function getDeployedGaugeAddress(tx) {
|
|
653
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
654
|
+
const txInfo = yield tx.wait();
|
|
655
|
+
if (!txInfo)
|
|
656
|
+
throw Error("Can't get tx info");
|
|
657
|
+
const log = txInfo.logs[0];
|
|
658
|
+
return log.args[log.args.length - 1].toLowerCase();
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
export function getDeployedGaugeMirrorAddressByTx(tx) {
|
|
662
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
663
|
+
if (this.chainId !== 1)
|
|
664
|
+
throw Error("There is no getDeployedGaugeMirrorAddressByTx method on sidechain network");
|
|
665
|
+
const txInfo = yield tx.wait();
|
|
666
|
+
if (!txInfo)
|
|
667
|
+
throw Error("Can't get tx info");
|
|
668
|
+
const log = txInfo.logs[1];
|
|
669
|
+
return log.args[log.args.length - 1].toLowerCase();
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
export function getDeployedGaugeMirrorAddress(chainId) {
|
|
673
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
674
|
+
if (this.chainId !== 1)
|
|
675
|
+
throw Error("There is no getDeployedGaugeMirrorAddress method on sidechain network");
|
|
676
|
+
const rootGaugeFactory = chainId !== 42161 ? NETWORK_CONSTANTS[this.chainId].ALIASES.root_gauge_factory : NETWORK_CONSTANTS[this.chainId].ALIASES.root_gauge_factory_arbitrum;
|
|
677
|
+
const contract = this.contracts[rootGaugeFactory].contract;
|
|
678
|
+
const gaugeCount = yield contract.get_gauge_count(chainId);
|
|
679
|
+
const currentIndex = Number(gaugeCount) - 1;
|
|
680
|
+
return yield contract.get_gauge(chainId, currentIndex);
|
|
681
|
+
});
|
|
682
|
+
}
|