@curvefi/api 2.66.29 → 2.66.31
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/utils.d.ts +14 -1
- package/lib/constants/utils.js +21 -6
- 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 +481 -435
- package/package.json +1 -1
package/lib/boosting.js
CHANGED
|
@@ -9,83 +9,97 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { Contract } from "ethers";
|
|
11
11
|
import BigNumber from "bignumber.js";
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { _getBalances, _prepareAddresses, DIGas, ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, mulBy1_3, smartNumber, } from "./utils.js";
|
|
16
|
-
import { _ensureAllowance, toBN, toStringFromBN, parseUnits, BN } from './utils.js';
|
|
12
|
+
import feeDistributorViewABI from "./constants/abis/fee_distributor_view.json" with { type: "json" };
|
|
13
|
+
import feeDistributorCrvUSDViewABI from "./constants/abis/fee_distributor_crvusd_view.json" with { type: "json" };
|
|
14
|
+
import { _ensureAllowance, _getBalances, _prepareAddresses, BN, DIGas, ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, toStringFromBN, } from "./utils.js";
|
|
17
15
|
import { _generateBoostingProof } from './external-api.js';
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
return
|
|
88
|
-
|
|
16
|
+
export function getCrv(...addresses) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
addresses = _prepareAddresses.call(this, addresses);
|
|
19
|
+
const rawBalances = (yield _getBalances.call(this, [this.constants.ALIASES.crv], addresses));
|
|
20
|
+
const balances = {};
|
|
21
|
+
for (const address of addresses) {
|
|
22
|
+
balances[address] = rawBalances[address].shift();
|
|
23
|
+
}
|
|
24
|
+
return addresses.length === 1 ? balances[addresses[0]] : balances;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function getLockedAmountAndUnlockTime(...addresses) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
addresses = _prepareAddresses.call(this, addresses);
|
|
30
|
+
const veContract = this.contracts[this.constants.ALIASES.voting_escrow].multicallContract;
|
|
31
|
+
const contractCalls = addresses.map((address) => veContract.locked(address));
|
|
32
|
+
const response = (yield this.multicallProvider.all(contractCalls)).map((value) => [this.formatUnits(value[0]), Number(this.formatUnits(value[1], 0)) * 1000]);
|
|
33
|
+
const result = {};
|
|
34
|
+
addresses.forEach((addr, i) => {
|
|
35
|
+
result[addr] = { lockedAmount: response[i][0], unlockTime: response[i][1] };
|
|
36
|
+
});
|
|
37
|
+
return addresses.length === 1 ? result[addresses[0]] : result;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function getVeCrv(...addresses) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
addresses = _prepareAddresses.call(this, addresses);
|
|
43
|
+
const veContract = this.contracts[this.constants.ALIASES.voting_escrow].multicallContract;
|
|
44
|
+
const contractCalls = addresses.map((address) => veContract.balanceOf(address));
|
|
45
|
+
const response = (yield this.multicallProvider.all(contractCalls)).map((value) => this.formatUnits(value));
|
|
46
|
+
const result = {};
|
|
47
|
+
addresses.forEach((addr, i) => {
|
|
48
|
+
result[addr] = response[i];
|
|
49
|
+
});
|
|
50
|
+
return addresses.length === 1 ? result[addresses[0]] : result;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function getVeCrvPct(...addresses) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
addresses = _prepareAddresses.call(this, addresses);
|
|
56
|
+
const veContract = this.contracts[this.constants.ALIASES.voting_escrow].multicallContract;
|
|
57
|
+
const contractCalls = [veContract.totalSupply()];
|
|
58
|
+
addresses.forEach((address) => {
|
|
59
|
+
contractCalls.push(veContract.balanceOf(address));
|
|
60
|
+
});
|
|
61
|
+
const response = (yield this.multicallProvider.all(contractCalls)).map((value) => toBN(value));
|
|
62
|
+
const [veTotalSupply] = response.splice(0, 1);
|
|
63
|
+
const resultBN = {};
|
|
64
|
+
addresses.forEach((acct, i) => {
|
|
65
|
+
resultBN[acct] = response[i].div(veTotalSupply).times(100);
|
|
66
|
+
});
|
|
67
|
+
const result = {};
|
|
68
|
+
for (const entry of Object.entries(resultBN)) {
|
|
69
|
+
result[entry[0]] = toStringFromBN(entry[1]);
|
|
70
|
+
}
|
|
71
|
+
return addresses.length === 1 ? result[addresses[0]] : result;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function isApproved(amount) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return yield hasAllowance.call(this, [this.constants.ALIASES.crv], [amount], this.signerAddress, this.constants.ALIASES.voting_escrow);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export function approveEstimateGas(amount) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
return yield ensureAllowanceEstimateGas.call(this, [this.constants.ALIASES.crv], [amount], this.constants.ALIASES.voting_escrow, false);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
export function approve(amount) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
return yield ensureAllowance.call(this, [this.constants.ALIASES.crv], [amount], this.constants.ALIASES.voting_escrow, false);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export function createLockEstimateGas(amount, days) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const crvBalance = yield getCrv.call(this);
|
|
92
|
+
if (Number(crvBalance) < Number(amount)) {
|
|
93
|
+
throw Error(`Not enough . Actual: ${crvBalance}, required: ${amount}`);
|
|
94
|
+
}
|
|
95
|
+
if (!(yield hasAllowance.call(this, [this.constants.ALIASES.crv], [amount], this.signerAddress, this.constants.ALIASES.voting_escrow))) {
|
|
96
|
+
throw Error("Token allowance is needed to estimate gas");
|
|
97
|
+
}
|
|
98
|
+
const _amount = parseUnits(amount);
|
|
99
|
+
const unlockTime = Math.floor(Date.now() / 1000) + (days * 86400);
|
|
100
|
+
return Number(yield this.contracts[this.constants.ALIASES.voting_escrow].contract.create_lock.estimateGas(_amount, unlockTime, this.constantOptions));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
89
103
|
export const calcUnlockTime = (days, start = Date.now()) => {
|
|
90
104
|
const week = 86400 * 7;
|
|
91
105
|
const now = start / 1000;
|
|
@@ -113,180 +127,234 @@ export const calculateVeCrv = (amount, unlockTimestamp) => {
|
|
|
113
127
|
.div(MAX_TIME_SECONDS);
|
|
114
128
|
return veCrvBN.toNumber();
|
|
115
129
|
};
|
|
116
|
-
export
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
export
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
export
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
export
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
export
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return (
|
|
211
|
-
|
|
130
|
+
export function createLock(amount, days) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const _amount = parseUnits(amount);
|
|
133
|
+
const unlockTime = Math.floor(Date.now() / 1000) + (86400 * days);
|
|
134
|
+
yield _ensureAllowance.call(this, [this.constants.ALIASES.crv], [_amount], this.constants.ALIASES.voting_escrow, false);
|
|
135
|
+
const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
|
|
136
|
+
yield this.updateFeeData();
|
|
137
|
+
const gasLimit = mulBy1_3(DIGas(yield contract.create_lock.estimateGas(_amount, unlockTime, this.constantOptions)));
|
|
138
|
+
return (yield contract.create_lock(_amount, unlockTime, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export function increaseAmountEstimateGas(amount) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
const crvBalance = yield getCrv.call(this);
|
|
144
|
+
if (Number(crvBalance) < Number(amount)) {
|
|
145
|
+
throw Error(`Not enough. Actual: ${crvBalance}, required: ${amount}`);
|
|
146
|
+
}
|
|
147
|
+
if (!(yield hasAllowance.call(this, [this.constants.ALIASES.crv], [amount], this.signerAddress, this.constants.ALIASES.voting_escrow))) {
|
|
148
|
+
throw Error("Token allowance is needed to estimate gas");
|
|
149
|
+
}
|
|
150
|
+
const _amount = parseUnits(amount);
|
|
151
|
+
const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
|
|
152
|
+
return Number(yield contract.increase_amount.estimateGas(_amount, this.constantOptions));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
export function increaseAmount(amount) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
const _amount = parseUnits(amount);
|
|
158
|
+
yield _ensureAllowance.call(this, [this.constants.ALIASES.crv], [_amount], this.constants.ALIASES.voting_escrow, false);
|
|
159
|
+
const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
|
|
160
|
+
yield this.updateFeeData();
|
|
161
|
+
const gasLimit = mulBy1_3(DIGas(yield contract.increase_amount.estimateGas(_amount, this.constantOptions)));
|
|
162
|
+
return (yield contract.increase_amount(_amount, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
export function increaseUnlockTimeEstimateGas(days) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
const { unlockTime } = yield getLockedAmountAndUnlockTime.call(this);
|
|
168
|
+
const newUnlockTime = Math.floor(unlockTime / 1000) + (days * 86400);
|
|
169
|
+
const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
|
|
170
|
+
return Number(DIGas(yield contract.increase_unlock_time.estimateGas(newUnlockTime, this.constantOptions)));
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
export function increaseUnlockTime(days) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
const { unlockTime } = yield getLockedAmountAndUnlockTime.call(this);
|
|
176
|
+
const newUnlockTime = Math.floor(unlockTime / 1000) + (days * 86400);
|
|
177
|
+
const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
|
|
178
|
+
yield this.updateFeeData();
|
|
179
|
+
const gasLimit = mulBy1_3(DIGas(yield contract.increase_unlock_time.estimateGas(newUnlockTime, this.constantOptions)));
|
|
180
|
+
return (yield contract.increase_unlock_time(newUnlockTime, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
export function withdrawLockedCrvEstimateGas() {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
|
|
186
|
+
return Number(DIGas(yield contract.withdraw.estimateGas(this.constantOptions)));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
export function withdrawLockedCrv() {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
|
|
192
|
+
yield this.updateFeeData();
|
|
193
|
+
const gasLimit = mulBy1_3(DIGas(yield contract.withdraw.estimateGas(this.constantOptions)));
|
|
194
|
+
return (yield contract.withdraw(Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
export function claimableFees() {
|
|
198
|
+
return __awaiter(this, arguments, void 0, function* (address = "") {
|
|
199
|
+
address = address || this.signerAddress;
|
|
200
|
+
const contract = new Contract(this.constants.ALIASES.fee_distributor, feeDistributorViewABI, this.provider);
|
|
201
|
+
return this.formatUnits(yield contract.claim(address, this.constantOptions));
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
export function claimFeesEstimateGas() {
|
|
205
|
+
return __awaiter(this, arguments, void 0, function* (address = "") {
|
|
206
|
+
address = address || this.signerAddress;
|
|
207
|
+
const contract = this.contracts[this.constants.ALIASES.fee_distributor].contract;
|
|
208
|
+
return Number(DIGas(yield contract.claim.estimateGas(address, this.constantOptions)));
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
export function claimFees() {
|
|
212
|
+
return __awaiter(this, arguments, void 0, function* (address = "") {
|
|
213
|
+
if (this.chainId !== 1) {
|
|
214
|
+
throw Error('This method is only available for the network with chainId 1');
|
|
215
|
+
}
|
|
216
|
+
address = address || this.signerAddress;
|
|
217
|
+
const contract = this.contracts[this.constants.ALIASES.fee_distributor].contract;
|
|
218
|
+
yield this.updateFeeData();
|
|
219
|
+
const gasLimit = mulBy1_3(DIGas(yield contract.claim.estimateGas(address, this.constantOptions)));
|
|
220
|
+
return (yield contract.claim(address, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
export function claimableFeesCrvUSD() {
|
|
224
|
+
return __awaiter(this, arguments, void 0, function* (address = "") {
|
|
225
|
+
if (this.chainId !== 1) {
|
|
226
|
+
throw Error('This method is only available for the network with chainId 1');
|
|
227
|
+
}
|
|
228
|
+
address = address || this.signerAddress;
|
|
229
|
+
const contract = new Contract(this.constants.ALIASES.fee_distributor_crvusd, feeDistributorCrvUSDViewABI, this.provider);
|
|
230
|
+
return this.formatUnits(yield contract.claim(address, this.constantOptions));
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
export function claimFeesCrvUSDEstimateGas() {
|
|
234
|
+
return __awaiter(this, arguments, void 0, function* (address = "") {
|
|
235
|
+
if (this.chainId !== 1) {
|
|
236
|
+
throw Error('This method is only available for the network with chainId 1');
|
|
237
|
+
}
|
|
238
|
+
address = address || this.signerAddress;
|
|
239
|
+
const contract = this.contracts[this.constants.ALIASES.fee_distributor_crvusd].contract;
|
|
240
|
+
return Number(DIGas(yield contract.claim.estimateGas(address, this.constantOptions)));
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
export function claimFeesCrvUSD() {
|
|
244
|
+
return __awaiter(this, arguments, void 0, function* (address = "") {
|
|
245
|
+
address = address || this.signerAddress;
|
|
246
|
+
const contract = this.contracts[this.constants.ALIASES.fee_distributor_crvusd].contract;
|
|
247
|
+
yield this.updateFeeData();
|
|
248
|
+
const gasLimit = mulBy1_3(DIGas(yield contract.claim.estimateGas(address, this.constantOptions)));
|
|
249
|
+
return (yield contract.claim(address, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
212
252
|
// ------------ SIDECHAIN ------------
|
|
213
|
-
export
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
export
|
|
291
|
-
return
|
|
292
|
-
|
|
253
|
+
export function lastEthBlock() {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
if (this.chainId === 1)
|
|
256
|
+
throw Error("There is no lastBlock method on ethereum network");
|
|
257
|
+
const veOracleContract = this.contracts[this.constants.ALIASES.voting_escrow_oracle].contract;
|
|
258
|
+
return Number(yield veOracleContract.last_eth_block_number(this.constantOptions));
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
export function getAnycallBalance() {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
if (this.chainId === 1)
|
|
264
|
+
throw Error("There is no getAnycallBalance method on ethereum network");
|
|
265
|
+
const anycallContract = this.contracts[this.constants.ALIASES.anycall].contract;
|
|
266
|
+
const _balance = yield anycallContract.executionBudget(this.constants.ALIASES.voting_escrow_oracle, this.constantOptions);
|
|
267
|
+
return this.formatUnits(_balance);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
function defaultAmount() {
|
|
271
|
+
return (this.chainId === 42161 || this.chainId === 10) ? 0.00001 : 0.1;
|
|
272
|
+
}
|
|
273
|
+
function _topUpAnycall(amount, estimateGas) {
|
|
274
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
275
|
+
if (this.chainId === 1)
|
|
276
|
+
throw Error("There is no topUpAnycall method on ethereum network");
|
|
277
|
+
const anycallContract = this.contracts[this.constants.ALIASES.anycall].contract;
|
|
278
|
+
const value = this.parseUnits(String(amount));
|
|
279
|
+
const gas = yield anycallContract.deposit.estimateGas(this.constants.ALIASES.voting_escrow_oracle, Object.assign(Object.assign({}, this.constantOptions), { value }));
|
|
280
|
+
if (estimateGas)
|
|
281
|
+
return smartNumber(gas);
|
|
282
|
+
yield this.updateFeeData();
|
|
283
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
284
|
+
return (yield anycallContract.deposit(this.constants.ALIASES.voting_escrow_oracle, Object.assign(Object.assign({}, this.options), { gasLimit, value }))).hash;
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
export function topUpAnycallEstimateGas() {
|
|
288
|
+
return __awaiter(this, arguments, void 0, function* (amount = defaultAmount.call(this)) {
|
|
289
|
+
return yield _topUpAnycall.call(this, amount, true);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
export function topUpAnycall() {
|
|
293
|
+
return __awaiter(this, arguments, void 0, function* (amount = defaultAmount.call(this)) {
|
|
294
|
+
return yield _topUpAnycall.call(this, amount, false);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
export function lastBlockSent(chainId) {
|
|
298
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
299
|
+
if (this.chainId !== 1)
|
|
300
|
+
throw Error("lastBlockNumberSent method is on ethereum network only");
|
|
301
|
+
const veOracleContract = this.contracts[this.constants.ALIASES.voting_escrow_oracle].contract;
|
|
302
|
+
return Number(yield veOracleContract.get_last_block_number_sent(chainId, this.constantOptions));
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
export function blockToSend() {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
+
if (this.chainId !== 1)
|
|
308
|
+
throw Error("blockToSend method is on ethereum network only");
|
|
309
|
+
return (yield this.provider.getBlockNumber()) - 128;
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function _sendBlockhash(block, chainId, estimateGas) {
|
|
313
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
314
|
+
if (this.chainId !== 1)
|
|
315
|
+
throw Error("sendBlockhash method is on ethereum network only");
|
|
316
|
+
const veOracleContract = this.contracts[this.constants.ALIASES.voting_escrow_oracle].contract;
|
|
317
|
+
const gas = yield veOracleContract.send_blockhash.estimateGas(block, chainId, this.constantOptions);
|
|
318
|
+
if (estimateGas)
|
|
319
|
+
return smartNumber(gas);
|
|
320
|
+
yield this.updateFeeData();
|
|
321
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
322
|
+
return (yield veOracleContract.send_blockhash(block, chainId, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
export function sendBlockhashEstimateGas(block, chainId) {
|
|
326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
+
return yield _sendBlockhash.call(this, block, chainId, true);
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
export function sendBlockhash(block, chainId) {
|
|
331
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
332
|
+
return yield _sendBlockhash.call(this, block, chainId, false);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
function _submitProof(block_1) {
|
|
336
|
+
return __awaiter(this, arguments, void 0, function* (block, address = this.signerAddress, estimateGas) {
|
|
337
|
+
if (this.chainId === 1)
|
|
338
|
+
throw Error("submitProof method is on ethereum network only");
|
|
339
|
+
if (address === "")
|
|
340
|
+
throw Error("Pass address you want to submit proof for");
|
|
341
|
+
const proof = yield _generateBoostingProof(block, address);
|
|
342
|
+
const veOracleContract = this.contracts[this.constants.ALIASES.voting_escrow_oracle].contract;
|
|
343
|
+
const gas = yield veOracleContract.submit_state.estimateGas(address, "0x" + proof.block_header_rlp, "0x" + proof.proof_rlp, this.constantOptions);
|
|
344
|
+
if (estimateGas)
|
|
345
|
+
return smartNumber(gas);
|
|
346
|
+
yield this.updateFeeData();
|
|
347
|
+
const gasLimit = mulBy1_3(DIGas(gas));
|
|
348
|
+
return (yield veOracleContract.submit_state(address, "0x" + proof.block_header_rlp, "0x" + proof.proof_rlp, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
export function submitProofEstimateGas(block_1) {
|
|
352
|
+
return __awaiter(this, arguments, void 0, function* (block, address = this.signerAddress) {
|
|
353
|
+
return yield _submitProof.call(this, block, address, true);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
export function submitProof(block_1) {
|
|
357
|
+
return __awaiter(this, arguments, void 0, function* (block, address = this.signerAddress) {
|
|
358
|
+
return yield _submitProof.call(this, block, address, false);
|
|
359
|
+
});
|
|
360
|
+
}
|