@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.
Files changed (94) hide show
  1. package/lib/boosting.d.ts +33 -32
  2. package/lib/boosting.js +320 -252
  3. package/lib/cached.d.ts +4 -3
  4. package/lib/cached.js +63 -19
  5. package/lib/constants/coins/hyperliquid.d.ts +2 -0
  6. package/lib/constants/coins/hyperliquid.js +5 -0
  7. package/lib/constants/coins/index.d.ts +2 -1
  8. package/lib/constants/coins/index.js +2 -1
  9. package/lib/constants/factory/crypto.d.ts +5 -0
  10. package/lib/constants/factory/crypto.js +8 -0
  11. package/lib/constants/factory/stable.js +3 -0
  12. package/lib/constants/network_constants.js +37 -11
  13. package/lib/constants/pools/hyperliquid.d.ts +2 -0
  14. package/lib/constants/pools/hyperliquid.js +2 -0
  15. package/lib/constants/pools/index.d.ts +2 -1
  16. package/lib/constants/pools/index.js +2 -1
  17. package/lib/constants/utils.d.ts +14 -1
  18. package/lib/constants/utils.js +21 -6
  19. package/lib/constants/volumeNetworks.js +1 -1
  20. package/lib/curve.d.ts +5 -5
  21. package/lib/curve.js +21 -38
  22. package/lib/dao.d.ts +32 -31
  23. package/lib/dao.js +420 -350
  24. package/lib/external-api.d.ts +1 -1
  25. package/lib/external-api.js +2 -2
  26. package/lib/factory/common.d.ts +2 -1
  27. package/lib/factory/common.js +1 -1
  28. package/lib/factory/deploy.d.ts +46 -45
  29. package/lib/factory/deploy.js +630 -551
  30. package/lib/factory/factory-api.d.ts +3 -2
  31. package/lib/factory/factory-api.js +22 -23
  32. package/lib/factory/factory-crypto.d.ts +1 -1
  33. package/lib/factory/factory-crypto.js +12 -15
  34. package/lib/factory/factory-tricrypto.d.ts +1 -1
  35. package/lib/factory/factory-tricrypto.js +14 -15
  36. package/lib/factory/factory-twocrypto.d.ts +1 -1
  37. package/lib/factory/factory-twocrypto.js +12 -13
  38. package/lib/factory/factory.d.ts +4 -3
  39. package/lib/factory/factory.js +21 -24
  40. package/lib/index.d.ts +413 -104
  41. package/lib/index.js +253 -257
  42. package/lib/interfaces.d.ts +2 -0
  43. package/lib/pools/PoolTemplate.d.ts +13 -12
  44. package/lib/pools/PoolTemplate.js +279 -285
  45. package/lib/pools/mixins/common.js +2 -2
  46. package/lib/pools/mixins/depositBalancedAmountsMixins.d.ts +12 -4
  47. package/lib/pools/mixins/depositBalancedAmountsMixins.js +1 -15
  48. package/lib/pools/mixins/depositMixins.d.ts +25 -5
  49. package/lib/pools/mixins/depositMixins.js +38 -76
  50. package/lib/pools/mixins/depositWrappedMixins.d.ts +10 -2
  51. package/lib/pools/mixins/depositWrappedMixins.js +17 -33
  52. package/lib/pools/mixins/poolBalancesMixin.d.ts +6 -2
  53. package/lib/pools/mixins/poolBalancesMixin.js +3 -5
  54. package/lib/pools/mixins/swapMixins.d.ts +20 -4
  55. package/lib/pools/mixins/swapMixins.js +36 -70
  56. package/lib/pools/mixins/swapWrappedMixins.d.ts +19 -4
  57. package/lib/pools/mixins/swapWrappedMixins.js +32 -60
  58. package/lib/pools/mixins/withdrawExpectedMixins.d.ts +12 -4
  59. package/lib/pools/mixins/withdrawExpectedMixins.js +6 -11
  60. package/lib/pools/mixins/withdrawImbalanceMixins.d.ts +20 -4
  61. package/lib/pools/mixins/withdrawImbalanceMixins.js +26 -53
  62. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.d.ts +10 -2
  63. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +12 -27
  64. package/lib/pools/mixins/withdrawMixins.d.ts +25 -5
  65. package/lib/pools/mixins/withdrawMixins.js +33 -67
  66. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.d.ts +12 -4
  67. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +8 -13
  68. package/lib/pools/mixins/withdrawOneCoinMixins.d.ts +25 -5
  69. package/lib/pools/mixins/withdrawOneCoinMixins.js +32 -66
  70. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.d.ts +6 -2
  71. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +4 -7
  72. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.d.ts +10 -2
  73. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +13 -29
  74. package/lib/pools/mixins/withdrawWrappedMixins.d.ts +10 -2
  75. package/lib/pools/mixins/withdrawWrappedMixins.js +14 -28
  76. package/lib/pools/poolConstructor.d.ts +2 -1
  77. package/lib/pools/poolConstructor.js +27 -28
  78. package/lib/pools/subClasses/corePool.d.ts +4 -1
  79. package/lib/pools/subClasses/corePool.js +5 -7
  80. package/lib/pools/subClasses/gaugePool.d.ts +5 -3
  81. package/lib/pools/subClasses/gaugePool.js +19 -18
  82. package/lib/pools/subClasses/statsPool.d.ts +2 -0
  83. package/lib/pools/subClasses/statsPool.js +22 -10
  84. package/lib/pools/subClasses/walletPool.d.ts +2 -1
  85. package/lib/pools/subClasses/walletPool.js +6 -6
  86. package/lib/pools/utils.d.ts +7 -6
  87. package/lib/pools/utils.js +316 -297
  88. package/lib/route-graph.worker.d.ts +2 -2
  89. package/lib/route-graph.worker.js +4 -6
  90. package/lib/router.d.ts +12 -11
  91. package/lib/router.js +331 -295
  92. package/lib/utils.d.ts +34 -33
  93. package/lib/utils.js +483 -435
  94. package/package.json +2 -2
package/lib/dao.js CHANGED
@@ -7,372 +7,442 @@ 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 { curve } from "./curve.js";
11
10
  import { Contract } from "ethers";
12
- import { _getAllGauges, _getDaoProposalList, _getDaoProposal } from './external-api.js';
13
- import { _getAddress, DIGas, ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, BN, } from './utils.js';
14
- import feeDistributorViewABI from "./constants/abis/fee_distributor_view.json" with { type: 'json' };
11
+ import { _getAllGauges, _getDaoProposal, _getDaoProposalList } from './external-api.js';
12
+ import { _getAddress, BN, DIGas, ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, mulBy1_3, parseUnits, smartNumber, toBN, } from './utils.js';
13
+ import feeDistributorViewABI from "./constants/abis/fee_distributor_view.json" with { type: "json" };
15
14
  // ----------------- Refactored boosting stuff -----------------
16
- export const crvSupplyStats = () => __awaiter(void 0, void 0, void 0, function* () {
17
- if (curve.chainId !== 1)
18
- throw Error("Ethereum-only method");
19
- const crvContract = curve.contracts[curve.constants.ALIASES.crv].multicallContract;
20
- const veContract = curve.contracts[curve.constants.ALIASES.voting_escrow].multicallContract;
21
- const csContract = curve.contracts[curve.constants.ALIASES.circulating_supply].multicallContract;
22
- const [_circulating, _locked, _veCrv] = yield curve.multicallProvider.all([
23
- csContract.circulating_supply(),
24
- crvContract.balanceOf(curve.constants.ALIASES.voting_escrow),
25
- veContract.totalSupply(),
26
- ]);
27
- return {
28
- circulating: curve.formatUnits(_circulating),
29
- locked: curve.formatUnits(_locked),
30
- total: curve.formatUnits(_circulating + _locked),
31
- veCrv: curve.formatUnits(_veCrv),
32
- averageLockTime: toBN(_veCrv).div(toBN(_locked)).times(4).toFixed(4), // years
33
- };
34
- });
35
- export const userCrv = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
36
- if (curve.chainId !== 1)
37
- throw Error("Ethereum-only method");
38
- address = _getAddress(address);
39
- const _balance = yield curve.contracts[curve.constants.ALIASES.crv].contract.balanceOf(address);
40
- return curve.formatUnits(_balance);
41
- });
42
- export const userVeCrv = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
43
- if (curve.chainId !== 1)
44
- throw Error("Ethereum-only method");
45
- address = _getAddress(address);
46
- const contract = curve.contracts[curve.constants.ALIASES.voting_escrow].multicallContract;
47
- const [_veCrv, _veCrvTotal, _locked] = yield curve.multicallProvider.all([
48
- contract.balanceOf(address),
49
- contract.totalSupply(),
50
- contract.locked(address),
51
- ]);
52
- const _lockedCrv = _locked[0];
53
- const _unlockTime = _locked[1];
54
- return {
55
- veCrv: curve.formatUnits(_veCrv),
56
- veCrvPct: toBN(_veCrv).div(toBN(_veCrvTotal)).times(100).toString(),
57
- lockedCrv: curve.formatUnits(_lockedCrv),
58
- unlockTime: Number(curve.formatUnits(_unlockTime, 0)) * 1000,
59
- };
60
- });
61
- export const crvLockIsApproved = (amount) => __awaiter(void 0, void 0, void 0, function* () {
62
- if (curve.chainId !== 1)
63
- throw Error("Ethereum-only method");
64
- return yield hasAllowance([curve.constants.ALIASES.crv], [amount], curve.signerAddress, curve.constants.ALIASES.voting_escrow);
65
- });
66
- export const crvLockApproveEstimateGas = (amount) => __awaiter(void 0, void 0, void 0, function* () {
67
- if (curve.chainId !== 1)
68
- throw Error("Ethereum-only method");
69
- return yield ensureAllowanceEstimateGas([curve.constants.ALIASES.crv], [amount], curve.constants.ALIASES.voting_escrow, false);
70
- });
71
- export const crvLockApprove = (amount) => __awaiter(void 0, void 0, void 0, function* () {
72
- if (curve.chainId !== 1)
73
- throw Error("Ethereum-only method");
74
- return yield ensureAllowance([curve.constants.ALIASES.crv], [amount], curve.constants.ALIASES.voting_escrow, false);
75
- });
15
+ export function crvSupplyStats() {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ if (this.chainId !== 1)
18
+ throw Error("Ethereum-only method");
19
+ const crvContract = this.contracts[this.constants.ALIASES.crv].multicallContract;
20
+ const veContract = this.contracts[this.constants.ALIASES.voting_escrow].multicallContract;
21
+ const csContract = this.contracts[this.constants.ALIASES.circulating_supply].multicallContract;
22
+ const [_circulating, _locked, _veCrv] = yield this.multicallProvider.all([
23
+ csContract.circulating_supply(),
24
+ crvContract.balanceOf(this.constants.ALIASES.voting_escrow),
25
+ veContract.totalSupply(),
26
+ ]);
27
+ return {
28
+ circulating: this.formatUnits(_circulating),
29
+ locked: this.formatUnits(_locked),
30
+ total: this.formatUnits(_circulating + _locked),
31
+ veCrv: this.formatUnits(_veCrv),
32
+ averageLockTime: toBN(_veCrv).div(toBN(_locked)).times(4).toFixed(4), // years
33
+ };
34
+ });
35
+ }
36
+ export function userCrv() {
37
+ return __awaiter(this, arguments, void 0, function* (address = "") {
38
+ if (this.chainId !== 1)
39
+ throw Error("Ethereum-only method");
40
+ address = _getAddress.call(this, address);
41
+ const _balance = yield this.contracts[this.constants.ALIASES.crv].contract.balanceOf(address);
42
+ return this.formatUnits(_balance);
43
+ });
44
+ }
45
+ export function userVeCrv() {
46
+ return __awaiter(this, arguments, void 0, function* (address = "") {
47
+ if (this.chainId !== 1)
48
+ throw Error("Ethereum-only method");
49
+ address = _getAddress.call(this, address);
50
+ const contract = this.contracts[this.constants.ALIASES.voting_escrow].multicallContract;
51
+ const [_veCrv, _veCrvTotal, _locked] = yield this.multicallProvider.all([
52
+ contract.balanceOf(address),
53
+ contract.totalSupply(),
54
+ contract.locked(address),
55
+ ]);
56
+ const _lockedCrv = _locked[0];
57
+ const _unlockTime = _locked[1];
58
+ return {
59
+ veCrv: this.formatUnits(_veCrv),
60
+ veCrvPct: toBN(_veCrv).div(toBN(_veCrvTotal)).times(100).toString(),
61
+ lockedCrv: this.formatUnits(_lockedCrv),
62
+ unlockTime: Number(this.formatUnits(_unlockTime, 0)) * 1000,
63
+ };
64
+ });
65
+ }
66
+ export function crvLockIsApproved(amount) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ if (this.chainId !== 1)
69
+ throw Error("Ethereum-only method");
70
+ return yield hasAllowance.call(this, [this.constants.ALIASES.crv], [amount], this.signerAddress, this.constants.ALIASES.voting_escrow);
71
+ });
72
+ }
73
+ export function crvLockApproveEstimateGas(amount) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ if (this.chainId !== 1)
76
+ throw Error("Ethereum-only method");
77
+ return yield ensureAllowanceEstimateGas.call(this, [this.constants.ALIASES.crv], [amount], this.constants.ALIASES.voting_escrow, false);
78
+ });
79
+ }
80
+ export function crvLockApprove(amount) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ if (this.chainId !== 1)
83
+ throw Error("Ethereum-only method");
84
+ return yield ensureAllowance.call(this, [this.constants.ALIASES.crv], [amount], this.constants.ALIASES.voting_escrow, false);
85
+ });
86
+ }
76
87
  export const calcCrvUnlockTime = (days, start = Date.now()) => {
77
88
  const week = 86400 * 7;
78
89
  const now = Number(start) / 1000;
79
90
  const unlockTime = now + (86400 * Number(days));
80
91
  return Math.floor(unlockTime / week) * week * 1000;
81
92
  };
82
- const _createCrvLock = (amount, days, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
83
- if (curve.chainId !== 1)
84
- throw Error("Ethereum-only method");
85
- const crvBalance = yield userCrv();
86
- if (BN(crvBalance).lt(amount))
87
- throw Error(`Not enough CRV. Wallet balance: ${crvBalance}, required: ${amount}`);
88
- if (!(yield crvLockIsApproved(amount)))
89
- throw Error("Token allowance is needed to estimate gas");
90
- const _amount = parseUnits(amount);
91
- const unlockTime = Math.floor(Date.now() / 1000) + (days * 86400);
92
- const contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
93
- const gas = yield contract.create_lock.estimateGas(_amount, unlockTime, curve.constantOptions);
94
- if (estimateGas)
95
- return smartNumber(gas);
96
- yield curve.updateFeeData();
97
- const gasLimit = mulBy1_3(DIGas(gas));
98
- return (yield contract.create_lock(_amount, unlockTime, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
99
- });
100
- export const createCrvLockEstimateGas = (amount, days) => __awaiter(void 0, void 0, void 0, function* () {
101
- return yield _createCrvLock(amount, Number(days), true);
102
- });
103
- export const createCrvLock = (amount, days) => __awaiter(void 0, void 0, void 0, function* () {
104
- return yield _createCrvLock(amount, Number(days), false);
105
- });
106
- const _increaseCrvLockedAmount = (amount, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
107
- if (curve.chainId !== 1)
108
- throw Error("Ethereum-only method");
109
- const crvBalance = yield userCrv();
110
- if (BN(crvBalance).lt(amount))
111
- throw Error(`Not enough CRV. Wallet balance: ${crvBalance}, required: ${amount}`);
112
- if (!(yield crvLockIsApproved(amount)))
113
- throw Error("Token allowance is needed to estimate gas");
114
- const _amount = parseUnits(amount);
115
- const contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
116
- const gas = yield contract.increase_amount.estimateGas(_amount, curve.constantOptions);
117
- if (estimateGas)
118
- return smartNumber(gas);
119
- yield curve.updateFeeData();
120
- const gasLimit = mulBy1_3(DIGas(gas));
121
- return (yield contract.increase_amount(_amount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
122
- });
123
- export const increaseCrvLockedAmountEstimateGas = (amount) => __awaiter(void 0, void 0, void 0, function* () {
124
- return yield _increaseCrvLockedAmount(amount, true);
125
- });
126
- export const increaseCrvLockedAmount = (amount) => __awaiter(void 0, void 0, void 0, function* () {
127
- return yield _increaseCrvLockedAmount(amount, false);
128
- });
129
- const _increaseCrvUnlockTime = (days, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
130
- if (curve.chainId !== 1)
131
- throw Error("Ethereum-only method");
132
- const { unlockTime } = yield userVeCrv();
133
- const newUnlockTime = Math.floor(unlockTime / 1000) + (days * 86400);
134
- const contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
135
- const gas = yield contract.increase_unlock_time.estimateGas(newUnlockTime, curve.constantOptions);
136
- if (estimateGas)
137
- return smartNumber(gas);
138
- yield curve.updateFeeData();
139
- const gasLimit = mulBy1_3(DIGas(gas));
140
- return (yield contract.increase_unlock_time(newUnlockTime, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
141
- });
142
- export const increaseCrvUnlockTimeEstimateGas = (days) => __awaiter(void 0, void 0, void 0, function* () {
143
- return yield _increaseCrvUnlockTime(Number(days), true);
144
- });
145
- export const increaseCrvUnlockTime = (days) => __awaiter(void 0, void 0, void 0, function* () {
146
- return yield _increaseCrvUnlockTime(Number(days), false);
147
- });
148
- const _withdrawLockedCrv = (estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
149
- if (curve.chainId !== 1)
150
- throw Error("Ethereum-only method");
151
- const { unlockTime } = yield userVeCrv();
152
- if (unlockTime > Date.now())
153
- throw Error("The lock haven't expired yet");
154
- const contract = curve.contracts[curve.constants.ALIASES.voting_escrow].contract;
155
- const gas = yield contract.withdraw.estimateGas(curve.constantOptions);
156
- if (estimateGas)
157
- return smartNumber(gas);
158
- yield curve.updateFeeData();
159
- const gasLimit = mulBy1_3(DIGas(gas));
160
- return (yield contract.withdraw(Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
161
- });
162
- export const withdrawLockedCrvEstimateGas = () => __awaiter(void 0, void 0, void 0, function* () {
163
- return yield _withdrawLockedCrv(true);
164
- });
165
- export const withdrawLockedCrv = () => __awaiter(void 0, void 0, void 0, function* () {
166
- return yield _withdrawLockedCrv(false);
167
- });
168
- export const claimableFees = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
169
- address = _getAddress(address);
170
- const contract = new Contract(curve.constants.ALIASES.fee_distributor, feeDistributorViewABI, curve.provider);
171
- return curve.formatUnits(yield contract.claim(address, curve.constantOptions));
172
- });
173
- const _claimFees = (address, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
174
- address = _getAddress(address);
175
- const contract = curve.contracts[curve.constants.ALIASES.fee_distributor].contract;
176
- const gas = yield contract.claim.estimateGas(address, curve.constantOptions);
177
- if (estimateGas)
178
- return smartNumber(gas);
179
- yield curve.updateFeeData();
180
- const gasLimit = mulBy1_3(DIGas(gas));
181
- return (yield contract.claim(address, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
182
- });
183
- export const claimFeesEstimateGas = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
184
- return yield _claimFees(address, true);
185
- });
186
- export const claimFees = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
187
- return yield _claimFees(address, false);
188
- });
93
+ function _createCrvLock(amount, days, estimateGas) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ if (this.chainId !== 1)
96
+ throw Error("Ethereum-only method");
97
+ const crvBalance = yield userCrv.call(this);
98
+ if (BN(crvBalance).lt(amount))
99
+ throw Error(`Not enough CRV. Wallet balance: ${crvBalance}, required: ${amount}`);
100
+ if (!(yield crvLockIsApproved.call(this, amount)))
101
+ throw Error("Token allowance is needed to estimate gas");
102
+ const _amount = parseUnits(amount);
103
+ const unlockTime = Math.floor(Date.now() / 1000) + (days * 86400);
104
+ const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
105
+ const gas = yield contract.create_lock.estimateGas(_amount, unlockTime, this.constantOptions);
106
+ if (estimateGas)
107
+ return smartNumber(gas);
108
+ yield this.updateFeeData();
109
+ const gasLimit = mulBy1_3(DIGas(gas));
110
+ return (yield contract.create_lock(_amount, unlockTime, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
111
+ });
112
+ }
113
+ export function createCrvLockEstimateGas(amount, days) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ return yield _createCrvLock.call(this, amount, Number(days), true);
116
+ });
117
+ }
118
+ export function createCrvLock(amount, days) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ return yield _createCrvLock.call(this, amount, Number(days), false);
121
+ });
122
+ }
123
+ function _increaseCrvLockedAmount(amount, estimateGas) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ if (this.chainId !== 1)
126
+ throw Error("Ethereum-only method");
127
+ const crvBalance = yield userCrv.call(this);
128
+ if (BN(crvBalance).lt(amount))
129
+ throw Error(`Not enough CRV. Wallet balance: ${crvBalance}, required: ${amount}`);
130
+ if (!(yield crvLockIsApproved.call(this, amount)))
131
+ throw Error("Token allowance is needed to estimate gas");
132
+ const _amount = parseUnits(amount);
133
+ const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
134
+ const gas = yield contract.increase_amount.estimateGas(_amount, this.constantOptions);
135
+ if (estimateGas)
136
+ return smartNumber(gas);
137
+ yield this.updateFeeData();
138
+ const gasLimit = mulBy1_3(DIGas(gas));
139
+ return (yield contract.increase_amount(_amount, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
140
+ });
141
+ }
142
+ export function increaseCrvLockedAmountEstimateGas(amount) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ return yield _increaseCrvLockedAmount.call(this, amount, true);
145
+ });
146
+ }
147
+ export function increaseCrvLockedAmount(amount) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ return yield _increaseCrvLockedAmount.call(this, amount, false);
150
+ });
151
+ }
152
+ function _increaseCrvUnlockTime(days, estimateGas) {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ if (this.chainId !== 1)
155
+ throw Error("Ethereum-only method");
156
+ const { unlockTime } = yield userVeCrv.call(this);
157
+ const newUnlockTime = Math.floor(unlockTime / 1000) + (days * 86400);
158
+ const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
159
+ const gas = yield contract.increase_unlock_time.estimateGas(newUnlockTime, this.constantOptions);
160
+ if (estimateGas)
161
+ return smartNumber(gas);
162
+ yield this.updateFeeData();
163
+ const gasLimit = mulBy1_3(DIGas(gas));
164
+ return (yield contract.increase_unlock_time(newUnlockTime, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
165
+ });
166
+ }
167
+ export function increaseCrvUnlockTimeEstimateGas(days) {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ return yield _increaseCrvUnlockTime.call(this, Number(days), true);
170
+ });
171
+ }
172
+ export function increaseCrvUnlockTime(days) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ return yield _increaseCrvUnlockTime.call(this, Number(days), false);
175
+ });
176
+ }
177
+ function _withdrawLockedCrv(estimateGas) {
178
+ return __awaiter(this, void 0, void 0, function* () {
179
+ if (this.chainId !== 1)
180
+ throw Error("Ethereum-only method");
181
+ const { unlockTime } = yield userVeCrv.call(this);
182
+ if (unlockTime > Date.now())
183
+ throw Error("The lock haven't expired yet");
184
+ const contract = this.contracts[this.constants.ALIASES.voting_escrow].contract;
185
+ const gas = yield contract.withdraw.estimateGas(this.constantOptions);
186
+ if (estimateGas)
187
+ return smartNumber(gas);
188
+ yield this.updateFeeData();
189
+ const gasLimit = mulBy1_3(DIGas(gas));
190
+ return (yield contract.withdraw(Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
191
+ });
192
+ }
193
+ export function withdrawLockedCrvEstimateGas() {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ return yield _withdrawLockedCrv.call(this, true);
196
+ });
197
+ }
198
+ export function withdrawLockedCrv() {
199
+ return __awaiter(this, void 0, void 0, function* () {
200
+ return yield _withdrawLockedCrv.call(this, false);
201
+ });
202
+ }
203
+ export function claimableFees() {
204
+ return __awaiter(this, arguments, void 0, function* (address = "") {
205
+ address = _getAddress.call(this, address);
206
+ const contract = new Contract(this.constants.ALIASES.fee_distributor, feeDistributorViewABI, this.provider);
207
+ return this.formatUnits(yield contract.claim(address, this.constantOptions));
208
+ });
209
+ }
210
+ function _claimFees(address, estimateGas) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ address = _getAddress.call(this, address);
213
+ const contract = this.contracts[this.constants.ALIASES.fee_distributor].contract;
214
+ const gas = yield contract.claim.estimateGas(address, this.constantOptions);
215
+ if (estimateGas)
216
+ return smartNumber(gas);
217
+ yield this.updateFeeData();
218
+ const gasLimit = mulBy1_3(DIGas(gas));
219
+ return (yield contract.claim(address, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
220
+ });
221
+ }
222
+ export function claimFeesEstimateGas() {
223
+ return __awaiter(this, arguments, void 0, function* (address = "") {
224
+ return yield _claimFees.call(this, address, true);
225
+ });
226
+ }
227
+ export function claimFees() {
228
+ return __awaiter(this, arguments, void 0, function* (address = "") {
229
+ return yield _claimFees.call(this, address, false);
230
+ });
231
+ }
189
232
  // ----------------- Gauge weights -----------------
190
- const _extractNetworkFromPoolUrl = (poolUrl) => {
191
- if (!poolUrl)
192
- return "unknown";
193
- return poolUrl.split("/")[4];
194
- };
195
- export const getVotingGaugeList = () => __awaiter(void 0, void 0, void 0, function* () {
196
- var _a, _b;
197
- if (curve.chainId !== 1)
198
- throw Error("Ethereum-only method");
199
- const gaugeData = Object.values(yield _getAllGauges());
200
- const res = [];
201
- for (let i = 0; i < gaugeData.length; i++) {
202
- if ((gaugeData[i].is_killed || gaugeData[i].hasNoCrv) && Number(gaugeData[i].gauge_controller.gauge_relative_weight) === 0)
203
- continue;
204
- res.push({
205
- poolUrl: ((_a = gaugeData[i].poolUrls) === null || _a === void 0 ? void 0 : _a.swap[0]) || '',
206
- network: gaugeData[i].blockchainId,
207
- gaugeAddress: gaugeData[i].gauge,
208
- poolAddress: gaugeData[i].swap || '',
209
- lpTokenAddress: gaugeData[i].swap_token || '',
210
- poolName: gaugeData[i].shortName,
211
- totalVeCrv: curve.formatUnits(gaugeData[i].gauge_controller.get_gauge_weight, 18),
212
- relativeWeight: curve.formatUnits(gaugeData[i].gauge_controller.gauge_relative_weight, 16),
213
- isKilled: (_b = gaugeData[i].is_killed) !== null && _b !== void 0 ? _b : false,
214
- });
215
- }
216
- return res;
217
- });
218
- export const userGaugeVotes = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
219
- var _a, _b;
220
- if (curve.chainId !== 1)
221
- throw Error("Ethereum-only method");
222
- address = _getAddress(address);
223
- const gcMulticallContract = curve.contracts[curve.constants.ALIASES.gauge_controller].multicallContract;
224
- const veMulticallContract = curve.contracts[curve.constants.ALIASES.voting_escrow].multicallContract;
225
- const gaugeData = Object.values(yield _getAllGauges());
226
- const calls = [veMulticallContract.balanceOf(address)];
227
- for (const d of gaugeData) {
228
- const gaugeAddress = d.rootGauge ? d.rootGauge : d.gauge;
229
- calls.push(gcMulticallContract.vote_user_slopes(address, gaugeAddress));
230
- }
231
- const [veCrvBalance, ...votes] = yield curve.multicallProvider.all(calls);
232
- const res = { gauges: [], powerUsed: "0.0", veCrvUsed: "0.0" };
233
- let powerUsed = BigInt(0);
234
- let veCrvUsed = BigInt(0);
235
- for (let i = 0; i < votes.length; i++) {
236
- if (votes[i][1] === BigInt(0))
237
- continue;
238
- let dt = votes[i][2] - BigInt(Math.floor(Date.now() / 1000));
239
- if (dt < BigInt(0))
240
- dt = BigInt(0);
241
- res.gauges.push({
242
- userPower: curve.formatUnits(votes[i][1], 2),
243
- userVeCrv: curve.formatUnits(votes[i][0] * dt, 18),
244
- userFutureVeCrv: curve.formatUnits(veCrvBalance * votes[i][1] / BigInt(10000), 18),
245
- expired: dt === BigInt(0),
246
- gaugeData: {
233
+ export function getVotingGaugeList() {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ var _a, _b;
236
+ if (this.chainId !== 1)
237
+ throw Error("Ethereum-only method");
238
+ const gaugeData = Object.values(yield _getAllGauges());
239
+ const res = [];
240
+ for (let i = 0; i < gaugeData.length; i++) {
241
+ if ((gaugeData[i].is_killed || gaugeData[i].hasNoCrv) && Number(gaugeData[i].gauge_controller.gauge_relative_weight) === 0)
242
+ continue;
243
+ res.push({
247
244
  poolUrl: ((_a = gaugeData[i].poolUrls) === null || _a === void 0 ? void 0 : _a.swap[0]) || '',
248
245
  network: gaugeData[i].blockchainId,
249
246
  gaugeAddress: gaugeData[i].gauge,
250
247
  poolAddress: gaugeData[i].swap || '',
251
248
  lpTokenAddress: gaugeData[i].swap_token || '',
252
249
  poolName: gaugeData[i].shortName,
253
- totalVeCrv: curve.formatUnits(gaugeData[i].gauge_controller.get_gauge_weight, 18),
254
- relativeWeight: curve.formatUnits(gaugeData[i].gauge_controller.gauge_relative_weight, 16),
250
+ totalVeCrv: this.formatUnits(gaugeData[i].gauge_controller.get_gauge_weight, 18),
251
+ relativeWeight: this.formatUnits(gaugeData[i].gauge_controller.gauge_relative_weight, 16),
255
252
  isKilled: (_b = gaugeData[i].is_killed) !== null && _b !== void 0 ? _b : false,
256
- },
257
- });
258
- powerUsed += votes[i][1];
259
- veCrvUsed += votes[i][0] * dt;
260
- }
261
- res.powerUsed = curve.formatUnits(powerUsed, 2);
262
- res.veCrvUsed = curve.formatUnits(veCrvUsed.toString(), 18);
263
- return res;
264
- });
265
- export const voteForGaugeNextTime = (gauge) => __awaiter(void 0, void 0, void 0, function* () {
266
- if (curve.chainId !== 1)
267
- throw Error("Ethereum-only method");
268
- const _lastVote = yield curve.contracts[curve.constants.ALIASES.gauge_controller].contract.last_user_vote(curve.signerAddress, gauge, curve.constantOptions);
269
- return (Number(_lastVote) + (10 * 86400)) * 1000;
270
- });
271
- const _voteForGauge = (gauge, power, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
272
- if (curve.chainId !== 1)
273
- throw Error("Ethereum-only method");
274
- const gcContract = curve.contracts[curve.constants.ALIASES.gauge_controller].contract;
275
- const gcMulticallContract = curve.contracts[curve.constants.ALIASES.gauge_controller].multicallContract;
276
- const _power = parseUnits(power, 2);
277
- const [_powerUsed, _vote_slopes] = yield curve.multicallProvider.all([
278
- gcMulticallContract.vote_user_power(curve.signerAddress),
279
- gcMulticallContract.vote_user_slopes(curve.signerAddress, gauge),
280
- ]);
281
- const _freePower = BigInt(10000) - _powerUsed;
282
- if (_power > _freePower + _vote_slopes[1])
283
- throw Error(`User have only ${curve.formatUnits(_freePower, 2)} % free power. Trying to use ${curve.formatUnits(_power, 2)}`);
284
- const nextVoteTime = yield voteForGaugeNextTime(gauge);
285
- if (Date.now() < nextVoteTime)
286
- throw Error(`User can't change vote for this gauge earlier than ${new Date(nextVoteTime)}`);
287
- const gas = yield gcContract.vote_for_gauge_weights.estimateGas(gauge, _power, curve.constantOptions);
288
- if (estimateGas)
289
- return smartNumber(gas);
290
- yield curve.updateFeeData();
291
- const gasLimit = mulBy1_3(DIGas(gas));
292
- return (yield gcContract.vote_for_gauge_weights(gauge, _power, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
293
- });
294
- export const voteForGaugeEstimateGas = (gauge, power) => __awaiter(void 0, void 0, void 0, function* () {
295
- return yield _voteForGauge(gauge, power, true);
296
- });
297
- export const voteForGauge = (gauge, power) => __awaiter(void 0, void 0, void 0, function* () {
298
- return yield _voteForGauge(gauge, power, false);
299
- });
253
+ });
254
+ }
255
+ return res;
256
+ });
257
+ }
258
+ export function userGaugeVotes() {
259
+ return __awaiter(this, arguments, void 0, function* (address = "") {
260
+ var _a, _b;
261
+ if (this.chainId !== 1)
262
+ throw Error("Ethereum-only method");
263
+ address = _getAddress.call(this, address);
264
+ const gcMulticallContract = this.contracts[this.constants.ALIASES.gauge_controller].multicallContract;
265
+ const veMulticallContract = this.contracts[this.constants.ALIASES.voting_escrow].multicallContract;
266
+ const gaugeData = Object.values(yield _getAllGauges());
267
+ const calls = [veMulticallContract.balanceOf(address)];
268
+ for (const d of gaugeData) {
269
+ const gaugeAddress = d.rootGauge ? d.rootGauge : d.gauge;
270
+ calls.push(gcMulticallContract.vote_user_slopes(address, gaugeAddress));
271
+ }
272
+ const [veCrvBalance, ...votes] = yield this.multicallProvider.all(calls);
273
+ const res = { gauges: [], powerUsed: "0.0", veCrvUsed: "0.0" };
274
+ let powerUsed = BigInt(0);
275
+ let veCrvUsed = BigInt(0);
276
+ for (let i = 0; i < votes.length; i++) {
277
+ if (votes[i][1] === BigInt(0))
278
+ continue;
279
+ let dt = votes[i][2] - BigInt(Math.floor(Date.now() / 1000));
280
+ if (dt < BigInt(0))
281
+ dt = BigInt(0);
282
+ res.gauges.push({
283
+ userPower: this.formatUnits(votes[i][1], 2),
284
+ userVeCrv: this.formatUnits(votes[i][0] * dt, 18),
285
+ userFutureVeCrv: this.formatUnits(veCrvBalance * votes[i][1] / BigInt(10000), 18),
286
+ expired: dt === BigInt(0),
287
+ gaugeData: {
288
+ poolUrl: ((_a = gaugeData[i].poolUrls) === null || _a === void 0 ? void 0 : _a.swap[0]) || '',
289
+ network: gaugeData[i].blockchainId,
290
+ gaugeAddress: gaugeData[i].gauge,
291
+ poolAddress: gaugeData[i].swap || '',
292
+ lpTokenAddress: gaugeData[i].swap_token || '',
293
+ poolName: gaugeData[i].shortName,
294
+ totalVeCrv: this.formatUnits(gaugeData[i].gauge_controller.get_gauge_weight, 18),
295
+ relativeWeight: this.formatUnits(gaugeData[i].gauge_controller.gauge_relative_weight, 16),
296
+ isKilled: (_b = gaugeData[i].is_killed) !== null && _b !== void 0 ? _b : false,
297
+ },
298
+ });
299
+ powerUsed += votes[i][1];
300
+ veCrvUsed += votes[i][0] * dt;
301
+ }
302
+ res.powerUsed = this.formatUnits(powerUsed, 2);
303
+ res.veCrvUsed = this.formatUnits(veCrvUsed.toString(), 18);
304
+ return res;
305
+ });
306
+ }
307
+ export function voteForGaugeNextTime(gauge) {
308
+ return __awaiter(this, void 0, void 0, function* () {
309
+ if (this.chainId !== 1)
310
+ throw Error("Ethereum-only method");
311
+ const _lastVote = yield this.contracts[this.constants.ALIASES.gauge_controller].contract.last_user_vote(this.signerAddress, gauge, this.constantOptions);
312
+ return (Number(_lastVote) + (10 * 86400)) * 1000;
313
+ });
314
+ }
315
+ function _voteForGauge(gauge, power, estimateGas) {
316
+ return __awaiter(this, void 0, void 0, function* () {
317
+ if (this.chainId !== 1)
318
+ throw Error("Ethereum-only method");
319
+ const gcContract = this.contracts[this.constants.ALIASES.gauge_controller].contract;
320
+ const gcMulticallContract = this.contracts[this.constants.ALIASES.gauge_controller].multicallContract;
321
+ const _power = parseUnits(power, 2);
322
+ const [_powerUsed, _vote_slopes] = yield this.multicallProvider.all([
323
+ gcMulticallContract.vote_user_power(this.signerAddress),
324
+ gcMulticallContract.vote_user_slopes(this.signerAddress, gauge),
325
+ ]);
326
+ const _freePower = BigInt(10000) - _powerUsed;
327
+ if (_power > _freePower + _vote_slopes[1])
328
+ throw Error(`User have only ${this.formatUnits(_freePower, 2)} % free power. Trying to use ${this.formatUnits(_power, 2)}`);
329
+ const nextVoteTime = yield voteForGaugeNextTime.call(this, gauge);
330
+ if (Date.now() < nextVoteTime)
331
+ throw Error(`User can't change vote for this gauge earlier than ${new Date(nextVoteTime)}`);
332
+ const gas = yield gcContract.vote_for_gauge_weights.estimateGas(gauge, _power, this.constantOptions);
333
+ if (estimateGas)
334
+ return smartNumber(gas);
335
+ yield this.updateFeeData();
336
+ const gasLimit = mulBy1_3(DIGas(gas));
337
+ return (yield gcContract.vote_for_gauge_weights(gauge, _power, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
338
+ });
339
+ }
340
+ export function voteForGaugeEstimateGas(gauge, power) {
341
+ return __awaiter(this, void 0, void 0, function* () {
342
+ return yield _voteForGauge.call(this, gauge, power, true);
343
+ });
344
+ }
345
+ export function voteForGauge(gauge, power) {
346
+ return __awaiter(this, void 0, void 0, function* () {
347
+ return yield _voteForGauge.call(this, gauge, power, false);
348
+ });
349
+ }
300
350
  // ----------------- Proposals -----------------
301
- export const getProposalList = () => __awaiter(void 0, void 0, void 0, function* () {
302
- return yield _getDaoProposalList();
303
- });
304
- export const getProposal = (type, id) => __awaiter(void 0, void 0, void 0, function* () {
305
- return yield _getDaoProposal(type, id);
306
- });
307
- export const userProposalVotes = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = "") {
308
- if (curve.chainId !== 1)
309
- throw Error("Ethereum-only method");
310
- address = _getAddress(address);
311
- const proposalList = yield _getDaoProposalList();
312
- const calls = [];
313
- for (const proposal of proposalList) {
314
- if (proposal.voteType.toUpperCase() == "PARAMETER") {
315
- calls.push(curve.contracts[curve.constants.ALIASES.voting_parameter].multicallContract.getVoterState(proposal.voteId, address));
351
+ export function getProposalList() {
352
+ return __awaiter(this, void 0, void 0, function* () {
353
+ return yield _getDaoProposalList();
354
+ });
355
+ }
356
+ export function getProposal(type, id) {
357
+ return __awaiter(this, void 0, void 0, function* () {
358
+ return yield _getDaoProposal(type, id);
359
+ });
360
+ }
361
+ export function userProposalVotes() {
362
+ return __awaiter(this, arguments, void 0, function* (address = "") {
363
+ if (this.chainId !== 1)
364
+ throw Error("Ethereum-only method");
365
+ address = _getAddress.call(this, address);
366
+ const proposalList = yield _getDaoProposalList();
367
+ const calls = [];
368
+ for (const proposal of proposalList) {
369
+ if (proposal.voteType.toUpperCase() == "PARAMETER") {
370
+ calls.push(this.contracts[this.constants.ALIASES.voting_parameter].multicallContract.getVoterState(proposal.voteId, address));
371
+ }
372
+ else {
373
+ calls.push(this.contracts[this.constants.ALIASES.voting_ownership].multicallContract.getVoterState(proposal.voteId, address));
374
+ }
316
375
  }
317
- else {
318
- calls.push(curve.contracts[curve.constants.ALIASES.voting_ownership].multicallContract.getVoterState(proposal.voteId, address));
376
+ const userState = (yield this.multicallProvider.all(calls)).map(Number);
377
+ const userProposalList = [];
378
+ const voteEnum = {
379
+ 1: "yes",
380
+ 2: "no",
381
+ 3: "even",
382
+ };
383
+ for (let i = 0; i < proposalList.length; i++) {
384
+ if (userState[i] > 0)
385
+ userProposalList.push(Object.assign(Object.assign({}, proposalList[i]), { userVote: voteEnum[userState[i]] }));
319
386
  }
320
- }
321
- const userState = (yield curve.multicallProvider.all(calls)).map(Number);
322
- const userProposalList = [];
323
- const voteEnum = {
324
- 1: "yes",
325
- 2: "no",
326
- 3: "even",
327
- };
328
- for (let i = 0; i < proposalList.length; i++) {
329
- if (userState[i] > 0)
330
- userProposalList.push(Object.assign(Object.assign({}, proposalList[i]), { userVote: voteEnum[userState[i]] }));
331
- }
332
- return userProposalList;
333
- });
334
- const _voteForProposal = (type, id, support, estimateGas) => __awaiter(void 0, void 0, void 0, function* () {
335
- if (curve.chainId !== 1)
336
- throw Error("Ethereum-only method");
337
- const contractAddress = type.toUpperCase() === "PARAMETER" ? curve.constants.ALIASES.voting_parameter : curve.constants.ALIASES.voting_ownership;
338
- const contract = curve.contracts[contractAddress].contract;
339
- const yesPct = support ? BigInt(Math.pow(10, 18)) : BigInt(0);
340
- const noPct = BigInt(Math.pow(10, 18)) - yesPct;
341
- const gas = yield contract.votePct.estimateGas(id, yesPct, noPct, true, curve.constantOptions);
342
- if (estimateGas)
343
- return smartNumber(gas);
344
- yield curve.updateFeeData();
345
- const gasLimit = mulBy1_3(DIGas(gas));
346
- return (yield contract.votePct(id, yesPct, noPct, false, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
347
- });
348
- export const voteForProposalEstimateGas = (type, id, support) => __awaiter(void 0, void 0, void 0, function* () {
349
- return yield _voteForProposal(type, id, support, true);
350
- });
351
- export const voteForProposal = (type, id, support) => __awaiter(void 0, void 0, void 0, function* () {
352
- return yield _voteForProposal(type, id, support, false);
353
- });
354
- const _executeVote = (type_1, id_1, ...args_1) => __awaiter(void 0, [type_1, id_1, ...args_1], void 0, function* (type, id, estimateGas = false) {
355
- if (curve.chainId !== 1)
356
- throw Error("Ethereum-only method");
357
- const contractAddress = type.toUpperCase() === "PARAMETER" ? curve.constants.ALIASES.voting_parameter : curve.constants.ALIASES.voting_ownership;
358
- const contract = curve.contracts[contractAddress].contract;
359
- const gas = yield contract.executeVote.estimateGas(id, curve.constantOptions);
360
- if (estimateGas)
361
- return smartNumber(gas);
362
- yield curve.updateFeeData();
363
- const gasLimit = mulBy1_3(DIGas(gas));
364
- return (yield contract.executeVote(id, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
365
- });
366
- export const executeVoteEstimateGas = (type, id) => __awaiter(void 0, void 0, void 0, function* () {
367
- return yield _executeVote(type, id, true);
368
- });
369
- export const executeVote = (type, id) => __awaiter(void 0, void 0, void 0, function* () {
370
- return yield _executeVote(type, id, false);
371
- });
372
- export const isCanVoteExecute = (type, id) => __awaiter(void 0, void 0, void 0, function* () {
373
- if (curve.chainId !== 1)
374
- throw Error("Ethereum-only method");
375
- const contractAddress = type.toUpperCase() === "PARAMETER" ? curve.constants.ALIASES.voting_parameter : curve.constants.ALIASES.voting_ownership;
376
- const contract = curve.contracts[contractAddress].contract;
377
- return yield contract.canExecute(id, Object.assign({}, curve.options));
378
- });
387
+ return userProposalList;
388
+ });
389
+ }
390
+ function _voteForProposal(type, id, support, estimateGas) {
391
+ return __awaiter(this, void 0, void 0, function* () {
392
+ if (this.chainId !== 1)
393
+ throw Error("Ethereum-only method");
394
+ const contractAddress = type.toUpperCase() === "PARAMETER" ? this.constants.ALIASES.voting_parameter : this.constants.ALIASES.voting_ownership;
395
+ const contract = this.contracts[contractAddress].contract;
396
+ const yesPct = support ? BigInt(Math.pow(10, 18)) : BigInt(0);
397
+ const noPct = BigInt(Math.pow(10, 18)) - yesPct;
398
+ const gas = yield contract.votePct.estimateGas(id, yesPct, noPct, true, this.constantOptions);
399
+ if (estimateGas)
400
+ return smartNumber(gas);
401
+ yield this.updateFeeData();
402
+ const gasLimit = mulBy1_3(DIGas(gas));
403
+ return (yield contract.votePct(id, yesPct, noPct, false, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
404
+ });
405
+ }
406
+ export function voteForProposalEstimateGas(type, id, support) {
407
+ return __awaiter(this, void 0, void 0, function* () {
408
+ return yield _voteForProposal.call(this, type, id, support, true);
409
+ });
410
+ }
411
+ export function voteForProposal(type, id, support) {
412
+ return __awaiter(this, void 0, void 0, function* () {
413
+ return yield _voteForProposal.call(this, type, id, support, false);
414
+ });
415
+ }
416
+ function _executeVote(type_1, id_1) {
417
+ return __awaiter(this, arguments, void 0, function* (type, id, estimateGas = false) {
418
+ if (this.chainId !== 1)
419
+ throw Error("Ethereum-only method");
420
+ const contractAddress = type.toUpperCase() === "PARAMETER" ? this.constants.ALIASES.voting_parameter : this.constants.ALIASES.voting_ownership;
421
+ const contract = this.contracts[contractAddress].contract;
422
+ const gas = yield contract.executeVote.estimateGas(id, this.constantOptions);
423
+ if (estimateGas)
424
+ return smartNumber(gas);
425
+ yield this.updateFeeData();
426
+ const gasLimit = mulBy1_3(DIGas(gas));
427
+ return (yield contract.executeVote(id, Object.assign(Object.assign({}, this.options), { gasLimit }))).hash;
428
+ });
429
+ }
430
+ export function executeVoteEstimateGas(type, id) {
431
+ return __awaiter(this, void 0, void 0, function* () {
432
+ return yield _executeVote.call(this, type, id, true);
433
+ });
434
+ }
435
+ export function executeVote(type, id) {
436
+ return __awaiter(this, void 0, void 0, function* () {
437
+ return yield _executeVote.call(this, type, id, false);
438
+ });
439
+ }
440
+ export function isCanVoteExecute(type, id) {
441
+ return __awaiter(this, void 0, void 0, function* () {
442
+ if (this.chainId !== 1)
443
+ throw Error("Ethereum-only method");
444
+ const contractAddress = type.toUpperCase() === "PARAMETER" ? this.constants.ALIASES.voting_parameter : this.constants.ALIASES.voting_ownership;
445
+ const contract = this.contracts[contractAddress].contract;
446
+ return yield contract.canExecute(id, Object.assign({}, this.options));
447
+ });
448
+ }