@raac/rpc 1.2.0-beta.10 → 1.2.0-beta.11
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/dist/RPCLibrary.js +2 -0
- package/dist/artifacts/core/governance/gauges/BaseGauge.sol/BaseGauge.json +113 -20
- package/dist/artifacts/core/governance/gauges/GaugeController.sol/GaugeController.json +259 -31
- package/dist/artifacts/core/governance/gauges/GaugeRewardsDistributor.sol/GaugeRewardsDistributor.json +159 -31
- package/dist/artifacts/core/governance/gauges/RAACGauge.sol/RAACGauge.json +115 -22
- package/dist/artifacts/core/governance/gauges/RWAGauge.sol/RWAGauge.json +115 -22
- package/dist/configs/chains/1.json +22 -25
- package/dist/configs/chains/11155111.json +56 -71
- package/dist/configs/chains/17000.json +22 -25
- package/dist/configs/chains/18453.json +22 -25
- package/dist/configs/chains/8453.json +61 -31
- package/dist/contracts/findContract.js +11 -4
- package/dist/contracts/getContractAddress.js +0 -1
- package/dist/contracts/governance/distributor/claimAll.js +18 -11
- package/dist/contracts/governance/distributor/claimForGauge.js +18 -12
- package/dist/contracts/governance/distributor/deposit.js +17 -12
- package/dist/contracts/governance/distributor/getClaimableForGauge.js +10 -9
- package/dist/contracts/governance/distributor/getClaimedAtEpoch.js +11 -10
- package/dist/contracts/governance/distributor/getDepositedAtEpoch.js +8 -8
- package/dist/contracts/governance/distributor/getDustLastProcessedEpoch.js +28 -0
- package/dist/contracts/governance/distributor/getGaugeController.js +7 -7
- package/dist/contracts/governance/distributor/getLastClaimedEpoch.js +10 -9
- package/dist/contracts/governance/distributor/getMaxClaimBound.js +29 -0
- package/dist/contracts/governance/distributor/getPeriodDuration.js +7 -7
- package/dist/contracts/governance/distributor/getRewardToken.js +7 -7
- package/dist/contracts/governance/distributor/getRewardTokenInfo.js +7 -7
- package/dist/contracts/governance/distributor/getRewardTokenStats.js +7 -7
- package/dist/contracts/governance/distributor/index.js +5 -2
- package/dist/contracts/governance/distributor/setController.js +17 -12
- package/dist/contracts/governance/distributor/setLastClaimedEpoch.js +32 -0
- package/dist/contracts/governance/distributor/setMaxClaimBound.js +31 -0
- package/dist/contracts/governance/distributor/withdrawDust.js +31 -0
- package/dist/contracts/governance/distributor/withdrawRemovedGaugeRewards.js +19 -13
- package/dist/contracts/governance/gauge/_apy.js +122 -0
- package/dist/contracts/governance/gauge/_tokens.js +36 -0
- package/dist/contracts/governance/gauge/addRewardToken.js +2 -12
- package/dist/contracts/governance/gauge/approveGaugeToken.js +31 -0
- package/dist/contracts/governance/gauge/claimExtraReward.js +2 -12
- package/dist/contracts/governance/gauge/claimExtraRewards.js +2 -12
- package/dist/contracts/governance/gauge/claimOnBehalfOf.js +2 -12
- package/dist/contracts/governance/gauge/claimRewardToken.js +3 -13
- package/dist/contracts/governance/gauge/claimRewardsFor.js +2 -12
- package/dist/contracts/governance/gauge/depositRewardToken.js +2 -12
- package/dist/contracts/governance/gauge/getAllPendingExtraRewards.js +2 -9
- package/dist/contracts/governance/gauge/getApy.js +44 -0
- package/dist/contracts/governance/gauge/getBalanceOf.js +2 -15
- package/dist/contracts/governance/gauge/getControllerAddress.js +2 -9
- package/dist/contracts/governance/gauge/getDecimalAdjustment.js +2 -9
- package/dist/contracts/governance/gauge/getDepositRAACOnClaim.js +2 -9
- package/dist/contracts/governance/gauge/getDistributorData.js +2 -9
- package/dist/contracts/governance/gauge/getDistributors.js +2 -9
- package/dist/contracts/governance/gauge/getEarnedExtraReward.js +30 -0
- package/dist/contracts/governance/gauge/getEarnedReward.js +8 -14
- package/dist/contracts/governance/gauge/getExtraRewardTokens.js +2 -9
- package/dist/contracts/governance/gauge/getGaugeData.js +39 -0
- package/dist/contracts/governance/gauge/getGaugeRewardTokenData.js +2 -9
- package/dist/contracts/governance/gauge/getPauseStatus.js +31 -0
- package/dist/contracts/governance/gauge/getPendingExtraRewards.js +2 -9
- package/dist/contracts/governance/gauge/getPendingRewards.js +8 -14
- package/dist/contracts/governance/gauge/getPeriodBoundaries.js +2 -15
- package/dist/contracts/governance/gauge/getPeriodDuration.js +2 -15
- package/dist/contracts/governance/gauge/getRaacAutolockMin.js +2 -9
- package/dist/contracts/governance/gauge/getRawBalanceOf.js +2 -15
- package/dist/contracts/governance/gauge/getRawTotalSupply.js +2 -15
- package/dist/contracts/governance/gauge/getRewardTokens.js +28 -0
- package/dist/contracts/governance/gauge/getTotalSupply.js +2 -15
- package/dist/contracts/governance/gauge/getUserApy.js +71 -0
- package/dist/contracts/governance/gauge/getUserClaimableRewards.js +21 -73
- package/dist/contracts/governance/gauge/getUserGaugeState.js +44 -0
- package/dist/contracts/governance/gauge/getUserRewardTokenData.js +2 -9
- package/dist/contracts/governance/gauge/getUserWeight.js +2 -9
- package/dist/contracts/governance/gauge/index.js +11 -1
- package/dist/contracts/governance/gauge/isPaused.js +4 -11
- package/dist/contracts/governance/gauge/manageDistributor.js +2 -12
- package/dist/contracts/governance/gauge/pullRewardsFromDistributor.js +30 -0
- package/dist/contracts/governance/gauge/setController.js +2 -12
- package/dist/contracts/governance/gauge/setDepositRAACOnClaim.js +2 -12
- package/dist/contracts/governance/gauge/setEmergencyPaused.js +2 -12
- package/dist/contracts/governance/gauge/setGaugeRewardDistributor.js +2 -12
- package/dist/contracts/governance/gauge/setRaacAutolockMin.js +2 -12
- package/dist/contracts/governance/gauge/stake.js +2 -18
- package/dist/contracts/governance/gauge/unwrapStakingToken.js +28 -0
- package/dist/contracts/governance/gauge/updateUserRewards.js +2 -18
- package/dist/contracts/governance/gauge/withdraw.js +2 -18
- package/dist/contracts/governance/gauge/wrapStakingToken.js +28 -0
- package/dist/contracts/governance/gaugeController/addGauge.js +19 -11
- package/dist/contracts/governance/gaugeController/batchVote.js +20 -12
- package/dist/contracts/governance/gaugeController/calculateBoost.js +20 -23
- package/dist/contracts/governance/gaugeController/forceCompleteCheckpoint.js +19 -11
- package/dist/contracts/governance/gaugeController/getActiveGaugeCount.js +28 -0
- package/dist/contracts/governance/gaugeController/getActiveGauges.js +10 -13
- package/dist/contracts/governance/gaugeController/getConstants.js +10 -18
- package/dist/contracts/governance/gaugeController/getCurrentEpoch.js +8 -7
- package/dist/contracts/governance/gaugeController/getExpiredGaugeVotePower.js +30 -0
- package/dist/contracts/governance/gaugeController/getGauge.js +11 -9
- package/dist/contracts/governance/gaugeController/getGaugeDistributor.js +28 -0
- package/dist/contracts/governance/gaugeController/getGaugeEmissions.js +15 -9
- package/dist/contracts/governance/gaugeController/getGaugeRelativeWeight.js +19 -15
- package/dist/contracts/governance/gaugeController/getGaugeRelativeWeightView.js +12 -10
- package/dist/contracts/governance/gaugeController/getGaugeWeight.js +10 -8
- package/dist/contracts/governance/gaugeController/getLastVoteTime.js +11 -9
- package/dist/contracts/governance/gaugeController/getMaxVoteBuckets.js +28 -0
- package/dist/contracts/governance/gaugeController/getNextEpoch.js +8 -7
- package/dist/contracts/governance/gaugeController/getRegisteredGaugeList.js +28 -0
- package/dist/contracts/governance/gaugeController/getTotalWeight.js +8 -7
- package/dist/contracts/governance/gaugeController/getUserGaugeVotePower.js +11 -9
- package/dist/contracts/governance/gaugeController/getUserVotePowerRemaining.js +10 -9
- package/dist/contracts/governance/gaugeController/getVeToken.js +8 -7
- package/dist/contracts/governance/gaugeController/getVoteUserLocks.js +32 -0
- package/dist/contracts/governance/gaugeController/getVoteUserPower.js +8 -7
- package/dist/contracts/governance/gaugeController/getVoteUserSlope.js +12 -10
- package/dist/contracts/governance/gaugeController/index.js +10 -1
- package/dist/contracts/governance/gaugeController/isGaugeActive.js +11 -9
- package/dist/contracts/governance/gaugeController/isPaused.js +9 -8
- package/dist/contracts/governance/gaugeController/kick.js +17 -10
- package/dist/contracts/governance/gaugeController/removeGauge.js +20 -11
- package/dist/contracts/governance/gaugeController/removePowerFromGauge.js +19 -11
- package/dist/contracts/governance/gaugeController/setBoostAmplificationEnabled.js +20 -12
- package/dist/contracts/governance/gaugeController/setDistributor.js +31 -0
- package/dist/contracts/governance/gaugeController/setEmergencyGaugePause.js +20 -12
- package/dist/contracts/governance/gaugeController/setEmergencyGaugePauseBatch.js +33 -0
- package/dist/contracts/governance/gaugeController/setEmergencyPause.js +18 -11
- package/dist/contracts/governance/gaugeController/setMaxVoteBuckets.js +31 -0
- package/dist/contracts/governance/gaugeController/vote.js +15 -16
- package/dist/contracts/governance/gaugeSystems/_helpers.js +123 -0
- package/dist/contracts/governance/gaugeSystems/findGauge.js +14 -0
- package/dist/contracts/governance/gaugeSystems/getGaugeSystem.js +14 -0
- package/dist/contracts/governance/gaugeSystems/getGaugeSystems.js +13 -0
- package/dist/contracts/governance/gaugeSystems/getGauges.js +15 -0
- package/dist/contracts/governance/gaugeSystems/index.js +21 -0
- package/dist/types/RPCLibrary.d.ts +2 -0
- package/dist/types/configs/chains/index.d.ts +36 -46
- package/dist/types/configs/index.d.ts +18 -23
- package/dist/types/contracts/governance/distributor/claimAll.d.ts +7 -5
- package/dist/types/contracts/governance/distributor/claimForGauge.d.ts +7 -6
- package/dist/types/contracts/governance/distributor/deposit.d.ts +7 -6
- package/dist/types/contracts/governance/distributor/getClaimableForGauge.d.ts +6 -4
- package/dist/types/contracts/governance/distributor/getClaimedAtEpoch.d.ts +7 -5
- package/dist/types/contracts/governance/distributor/getDepositedAtEpoch.d.ts +6 -4
- package/dist/types/contracts/governance/distributor/getDustLastProcessedEpoch.d.ts +12 -0
- package/dist/types/contracts/governance/distributor/getGaugeController.d.ts +5 -3
- package/dist/types/contracts/governance/distributor/getLastClaimedEpoch.d.ts +6 -4
- package/dist/types/contracts/governance/distributor/getMaxClaimBound.d.ts +15 -0
- package/dist/types/contracts/governance/distributor/getPeriodDuration.d.ts +5 -3
- package/dist/types/contracts/governance/distributor/getRewardToken.d.ts +5 -3
- package/dist/types/contracts/governance/distributor/getRewardTokenInfo.d.ts +5 -3
- package/dist/types/contracts/governance/distributor/getRewardTokenStats.d.ts +5 -3
- package/dist/types/contracts/governance/distributor/index.d.ts +5 -2
- package/dist/types/contracts/governance/distributor/setController.d.ts +7 -6
- package/dist/types/contracts/governance/distributor/setLastClaimedEpoch.d.ts +13 -0
- package/dist/types/contracts/governance/distributor/setMaxClaimBound.d.ts +13 -0
- package/dist/types/contracts/governance/distributor/withdrawDust.d.ts +13 -0
- package/dist/types/contracts/governance/distributor/withdrawRemovedGaugeRewards.d.ts +8 -7
- package/dist/types/contracts/governance/gauge/_apy.d.ts +61 -0
- package/dist/types/contracts/governance/gauge/_tokens.d.ts +14 -0
- package/dist/types/contracts/governance/gauge/approveGaugeToken.d.ts +14 -0
- package/dist/types/contracts/governance/gauge/claimRewardToken.d.ts +1 -1
- package/dist/types/contracts/governance/gauge/getApy.d.ts +41 -0
- package/dist/types/contracts/governance/gauge/getEarnedExtraReward.d.ts +13 -0
- package/dist/types/contracts/governance/gauge/getEarnedReward.d.ts +3 -2
- package/dist/types/contracts/governance/gauge/getGaugeData.d.ts +23 -0
- package/dist/types/contracts/governance/gauge/getPauseStatus.d.ts +19 -0
- package/dist/types/contracts/governance/gauge/getPendingRewards.d.ts +3 -2
- package/dist/types/contracts/governance/gauge/getRewardTokens.d.ts +11 -0
- package/dist/types/contracts/governance/gauge/getUserApy.d.ts +44 -0
- package/dist/types/contracts/governance/gauge/getUserClaimableRewards.d.ts +14 -12
- package/dist/types/contracts/governance/gauge/getUserGaugeState.d.ts +31 -0
- package/dist/types/contracts/governance/gauge/index.d.ts +11 -1
- package/dist/types/contracts/governance/gauge/isPaused.d.ts +1 -1
- package/dist/types/contracts/governance/gauge/pullRewardsFromDistributor.d.ts +11 -0
- package/dist/types/contracts/governance/gauge/unwrapStakingToken.d.ts +12 -0
- package/dist/types/contracts/governance/gauge/wrapStakingToken.d.ts +13 -0
- package/dist/types/contracts/governance/gaugeController/addGauge.d.ts +8 -5
- package/dist/types/contracts/governance/gaugeController/batchVote.d.ts +9 -6
- package/dist/types/contracts/governance/gaugeController/calculateBoost.d.ts +10 -8
- package/dist/types/contracts/governance/gaugeController/forceCompleteCheckpoint.d.ts +8 -5
- package/dist/types/contracts/governance/gaugeController/getActiveGaugeCount.d.ts +12 -0
- package/dist/types/contracts/governance/gaugeController/getActiveGauges.d.ts +7 -3
- package/dist/types/contracts/governance/gaugeController/getConstants.d.ts +6 -4
- package/dist/types/contracts/governance/gaugeController/getCurrentEpoch.d.ts +6 -3
- package/dist/types/contracts/governance/gaugeController/getExpiredGaugeVotePower.d.ts +16 -0
- package/dist/types/contracts/governance/gaugeController/getGauge.d.ts +7 -4
- package/dist/types/contracts/governance/gaugeController/getGaugeDistributor.d.ts +12 -0
- package/dist/types/contracts/governance/gaugeController/getGaugeEmissions.d.ts +6 -3
- package/dist/types/contracts/governance/gaugeController/getGaugeRelativeWeight.d.ts +8 -9
- package/dist/types/contracts/governance/gaugeController/getGaugeRelativeWeightView.d.ts +8 -5
- package/dist/types/contracts/governance/gaugeController/getGaugeWeight.d.ts +6 -4
- package/dist/types/contracts/governance/gaugeController/getLastVoteTime.d.ts +7 -4
- package/dist/types/contracts/governance/gaugeController/getMaxVoteBuckets.d.ts +12 -0
- package/dist/types/contracts/governance/gaugeController/getNextEpoch.d.ts +6 -3
- package/dist/types/contracts/governance/gaugeController/getRegisteredGaugeList.d.ts +12 -0
- package/dist/types/contracts/governance/gaugeController/getTotalWeight.d.ts +5 -3
- package/dist/types/contracts/governance/gaugeController/getUserGaugeVotePower.d.ts +7 -4
- package/dist/types/contracts/governance/gaugeController/getUserVotePowerRemaining.d.ts +6 -4
- package/dist/types/contracts/governance/gaugeController/getVeToken.d.ts +6 -3
- package/dist/types/contracts/governance/gaugeController/getVoteUserLocks.d.ts +17 -0
- package/dist/types/contracts/governance/gaugeController/getVoteUserPower.d.ts +6 -3
- package/dist/types/contracts/governance/gaugeController/getVoteUserSlope.d.ts +8 -5
- package/dist/types/contracts/governance/gaugeController/index.d.ts +10 -1
- package/dist/types/contracts/governance/gaugeController/isGaugeActive.d.ts +6 -4
- package/dist/types/contracts/governance/gaugeController/isPaused.d.ts +6 -3
- package/dist/types/contracts/governance/gaugeController/kick.d.ts +7 -4
- package/dist/types/contracts/governance/gaugeController/removeGauge.d.ts +9 -5
- package/dist/types/contracts/governance/gaugeController/removePowerFromGauge.d.ts +8 -5
- package/dist/types/contracts/governance/gaugeController/setBoostAmplificationEnabled.d.ts +9 -6
- package/dist/types/contracts/governance/gaugeController/setDistributor.d.ts +13 -0
- package/dist/types/contracts/governance/gaugeController/setEmergencyGaugePause.d.ts +9 -6
- package/dist/types/contracts/governance/gaugeController/setEmergencyGaugePauseBatch.d.ts +14 -0
- package/dist/types/contracts/governance/gaugeController/setEmergencyPause.d.ts +8 -5
- package/dist/types/contracts/governance/gaugeController/setMaxVoteBuckets.d.ts +13 -0
- package/dist/types/contracts/governance/gaugeController/vote.d.ts +9 -7
- package/dist/types/contracts/governance/gaugeSystems/_helpers.d.ts +71 -0
- package/dist/types/contracts/governance/gaugeSystems/findGauge.d.ts +11 -0
- package/dist/types/contracts/governance/gaugeSystems/getGaugeSystem.d.ts +11 -0
- package/dist/types/contracts/governance/gaugeSystems/getGaugeSystems.d.ts +10 -0
- package/dist/types/contracts/governance/gaugeSystems/getGauges.d.ts +13 -0
- package/dist/types/contracts/governance/gaugeSystems/index.d.ts +5 -0
- package/dist/types/typechain-types/contracts/core/governance/gauges/BaseGauge.d.ts +176 -105
- package/dist/types/typechain-types/contracts/core/governance/gauges/GaugeController.d.ts +260 -213
- package/dist/types/typechain-types/contracts/core/governance/gauges/GaugeRewardsDistributor.d.ts +173 -212
- package/dist/types/typechain-types/contracts/core/governance/gauges/RAACGauge.d.ts +176 -105
- package/dist/types/typechain-types/contracts/core/governance/gauges/RWAGauge.d.ts +176 -105
- package/dist/types/typechain-types/contracts/interfaces/core/governance/gauges/IBaseGauge.d.ts +111 -108
- package/dist/types/typechain-types/contracts/interfaces/core/governance/gauges/IGaugeController.d.ts +210 -34
- package/dist/types/typechain-types/contracts/interfaces/core/governance/gauges/IGaugeRewardsDistributor.d.ts +112 -151
- package/dist/types/typechain-types/factories/contracts/core/governance/gauges/BaseGauge__factory.d.ts +174 -95
- package/dist/types/typechain-types/factories/contracts/core/governance/gauges/GaugeController__factory.d.ts +243 -227
- package/dist/types/typechain-types/factories/contracts/core/governance/gauges/GaugeRewardsDistributor__factory.d.ts +164 -232
- package/dist/types/typechain-types/factories/contracts/core/governance/gauges/RAACGauge__factory.d.ts +185 -98
- package/dist/types/typechain-types/factories/contracts/core/governance/gauges/RWAGauge__factory.d.ts +185 -98
- package/dist/types/typechain-types/factories/contracts/interfaces/core/governance/gauges/IBaseGauge__factory.d.ts +104 -95
- package/dist/types/typechain-types/factories/contracts/interfaces/core/governance/gauges/IGaugeController__factory.d.ts +241 -22
- package/dist/types/typechain-types/factories/contracts/interfaces/core/governance/gauges/IGaugeRewardsDistributor__factory.d.ts +72 -158
- package/dist/types/utils/artifacts.d.ts +40 -0
- package/dist/types/utils/contracts.d.ts +34 -44
- package/dist/utils/contracts.js +1 -1
- package/package.json +1 -1
- package/dist/contracts/governance/distributor/getStartEpoch.js +0 -28
- package/dist/contracts/governance/distributor/withdrawUnallocatedRewards.js +0 -26
- package/dist/contracts/governance/gauge/setDistributorApproval.js +0 -35
- package/dist/types/contracts/governance/distributor/getStartEpoch.d.ts +0 -10
- package/dist/types/contracts/governance/distributor/withdrawUnallocatedRewards.d.ts +0 -12
- package/dist/types/contracts/governance/gauge/setDistributorApproval.d.ts +0 -11
|
@@ -1,36 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.calculateBoost = void 0;
|
|
4
7
|
const ethers_1 = require("ethers");
|
|
5
|
-
const
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
6
9
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
12
|
+
* Calculates the reward boost a user would get on a gauge for a staked amount.
|
|
9
13
|
*
|
|
10
14
|
* @param chainId - The chain/network to use.
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
16
|
+
* @param user - Address of the user.
|
|
17
|
+
* @param gaugeAddressOrId - Address or config id of the gauge.
|
|
18
|
+
* @param amount - Staked amount, base units.
|
|
19
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
20
|
+
* @returns The boost in basis points and the boosted amount.
|
|
16
21
|
*/
|
|
17
|
-
const calculateBoost = async (chainId,
|
|
22
|
+
const calculateBoost = async (chainId, gaugeSystem, user, gaugeAddressOrId, amount, provider) => {
|
|
18
23
|
if (!provider) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const gaugeControllerAddress = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
23
|
-
const gaugeControllerABI = (0, artifacts_1.getABI)("gaugecontroller");
|
|
24
|
-
const gaugeControllerContract = new ethers_1.ethers.Contract(gaugeControllerAddress, gaugeControllerABI, provider);
|
|
25
|
-
const [boostBasisPoints, boostedAmount] = await gaugeControllerContract.calculateBoost(userAddress, gaugeAddress, amount);
|
|
26
|
-
return {
|
|
27
|
-
boostBasisPoints,
|
|
28
|
-
boostedAmount,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error("Error calculating boost from contract:", error);
|
|
33
|
-
throw new Error(`Failed to calculate boost: ${error.message}`);
|
|
24
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
25
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
34
26
|
}
|
|
27
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
28
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
29
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
30
|
+
const [boostBasisPoints, boostedAmount] = await contract.calculateBoost(user, gaugeAddress, amount);
|
|
31
|
+
return { boostBasisPoints, boostedAmount };
|
|
35
32
|
};
|
|
36
33
|
exports.calculateBoost = calculateBoost;
|
|
@@ -2,23 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.forceCompleteCheckpoint = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
|
-
const getContractAddress_1 = require("../../getContractAddress");
|
|
6
5
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
7
|
+
const _helpers_2 = require("../_helpers");
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Completes a gauge's pending weight checkpoint.
|
|
10
|
+
*
|
|
9
11
|
* @param chainId - The chain/network to use.
|
|
10
|
-
* @param
|
|
12
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
13
|
+
* @param gaugeAddressOrId - Address or config id of the gauge.
|
|
11
14
|
* @param signer - An ethers.js Signer instance (required).
|
|
12
|
-
* @returns The transaction
|
|
15
|
+
* @returns The transaction after it has been mined.
|
|
13
16
|
*/
|
|
14
|
-
const forceCompleteCheckpoint = async (chainId,
|
|
17
|
+
const forceCompleteCheckpoint = async (chainId, gaugeSystem, gaugeAddressOrId, signer) => {
|
|
15
18
|
if (!signer)
|
|
16
19
|
throw new Error("Signer is required");
|
|
17
|
-
const address = (0,
|
|
18
|
-
const
|
|
19
|
-
const contract = new ethers_1.ethers.Contract(address,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
21
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
22
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), signer);
|
|
23
|
+
try {
|
|
24
|
+
const tx = await contract.forceCompleteCheckpoint(gaugeAddress);
|
|
25
|
+
await tx.wait();
|
|
26
|
+
return tx;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw (0, _helpers_2.toGovernanceTxError)("Failed to force checkpoint", error);
|
|
30
|
+
}
|
|
23
31
|
};
|
|
24
32
|
exports.forceCompleteCheckpoint = forceCompleteCheckpoint;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getActiveGaugeCount = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
|
+
/**
|
|
12
|
+
* Returns the number of registered gauges on the controller. Emergency-paused gauges are counted.
|
|
13
|
+
*
|
|
14
|
+
* @param chainId - The chain/network to use.
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
16
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
+
* @returns The registered gauge count.
|
|
18
|
+
*/
|
|
19
|
+
const getActiveGaugeCount = async (chainId, gaugeSystem, provider) => {
|
|
20
|
+
if (!provider) {
|
|
21
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
22
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
23
|
+
}
|
|
24
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
25
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
26
|
+
return contract.activeGaugeCount();
|
|
27
|
+
};
|
|
28
|
+
exports.getActiveGaugeCount = getActiveGaugeCount;
|
|
@@ -6,29 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getActiveGauges = void 0;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
address[] memory,
|
|
12
|
-
uint256[] memory,
|
|
13
|
-
uint256 totalWeight
|
|
14
|
-
)`;
|
|
9
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
15
11
|
/**
|
|
16
|
-
* Gets the active gauges and their weights.
|
|
12
|
+
* Gets the active gauges on a controller and their weights at the current epoch.
|
|
17
13
|
*
|
|
18
14
|
* @param chainId - The chain/network to use.
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
19
16
|
* @param provider - Optional ethers.js Provider instance.
|
|
20
|
-
* @returns Active gauges, their weights
|
|
17
|
+
* @returns Active gauges, their weights and the total weight.
|
|
21
18
|
*/
|
|
22
|
-
const getActiveGauges = async (chainId, provider) => {
|
|
19
|
+
const getActiveGauges = async (chainId, gaugeSystem, provider) => {
|
|
23
20
|
if (!provider) {
|
|
24
21
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
25
22
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
26
23
|
}
|
|
27
|
-
const
|
|
28
|
-
const contract = new ethers_1.ethers.Contract(
|
|
29
|
-
const [
|
|
24
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
25
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
26
|
+
const [gauges, weights, totalWeight] = await contract.getActiveGauges();
|
|
30
27
|
return {
|
|
31
|
-
gauges:
|
|
28
|
+
gauges: [...gauges],
|
|
32
29
|
weights: weights.map((w) => ethers_1.ethers.formatEther(w)),
|
|
33
30
|
totalWeight: ethers_1.ethers.formatEther(totalWeight),
|
|
34
31
|
};
|
|
@@ -6,24 +6,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getConstants = void 0;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
-
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
9
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
11
|
/**
|
|
12
|
-
* Reads the
|
|
12
|
+
* Reads the constant configuration values from a GaugeController.
|
|
13
|
+
*
|
|
13
14
|
* @param chainId - The chain/network to use.
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
14
16
|
* @param provider - Optional ethers.js Provider instance.
|
|
15
|
-
* @returns
|
|
16
|
-
* minVoteWeight and maxVoteWeight, all bigint.
|
|
17
|
+
* @returns maxBoost, minBoost, weightPrecision, week, weightVoteDelay, minVoteWeight and maxVoteWeight.
|
|
17
18
|
*/
|
|
18
|
-
const getConstants = async (chainId, provider) => {
|
|
19
|
+
const getConstants = async (chainId, gaugeSystem, provider) => {
|
|
19
20
|
if (!provider) {
|
|
20
21
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
21
22
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
22
23
|
}
|
|
23
|
-
const address = (0,
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const [maxBoost, minBoost, weightPrecision, week, weightVoteDelay, minVoteWeight, maxVoteWeight,] = await Promise.all([
|
|
24
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
25
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
26
|
+
const [maxBoost, minBoost, weightPrecision, week, weightVoteDelay, minVoteWeight, maxVoteWeight] = await Promise.all([
|
|
27
27
|
contract.MAX_BOOST(),
|
|
28
28
|
contract.MIN_BOOST(),
|
|
29
29
|
contract.WEIGHT_PRECISION(),
|
|
@@ -32,14 +32,6 @@ const getConstants = async (chainId, provider) => {
|
|
|
32
32
|
contract.MIN_VOTE_WEIGHT(),
|
|
33
33
|
contract.MAX_VOTE_WEIGHT(),
|
|
34
34
|
]);
|
|
35
|
-
return {
|
|
36
|
-
maxBoost,
|
|
37
|
-
minBoost,
|
|
38
|
-
weightPrecision,
|
|
39
|
-
week,
|
|
40
|
-
weightVoteDelay,
|
|
41
|
-
minVoteWeight,
|
|
42
|
-
maxVoteWeight,
|
|
43
|
-
};
|
|
35
|
+
return { maxBoost, minBoost, weightPrecision, week, weightVoteDelay, minVoteWeight, maxVoteWeight };
|
|
44
36
|
};
|
|
45
37
|
exports.getConstants = getConstants;
|
|
@@ -6,22 +6,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getCurrentEpoch = void 0;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
-
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
9
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Returns the start timestamp of the controller's current epoch.
|
|
13
|
+
*
|
|
13
14
|
* @param chainId - The chain/network to use.
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
14
16
|
* @param provider - Optional ethers.js Provider instance.
|
|
15
|
-
* @returns
|
|
17
|
+
* @returns The current epoch timestamp, seconds.
|
|
16
18
|
*/
|
|
17
|
-
const getCurrentEpoch = async (chainId, provider) => {
|
|
19
|
+
const getCurrentEpoch = async (chainId, gaugeSystem, provider) => {
|
|
18
20
|
if (!provider) {
|
|
19
21
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
20
22
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
21
23
|
}
|
|
22
|
-
const address = (0,
|
|
23
|
-
const
|
|
24
|
-
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
24
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
25
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
25
26
|
return contract.getCurrentEpoch();
|
|
26
27
|
};
|
|
27
28
|
exports.getCurrentEpoch = getCurrentEpoch;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getExpiredGaugeVotePower = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
|
+
/**
|
|
12
|
+
* Returns the vote power a user still has assigned to gauges whose votes no longer count, because every lock backing the vote has decayed out by the next epoch. Free it by re-voting those gauges.
|
|
13
|
+
*
|
|
14
|
+
* @param chainId - The chain/network to use.
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
16
|
+
* @param user - Address of the voter.
|
|
17
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
18
|
+
* @returns The stale vote weight in basis points and the gauges it sits on.
|
|
19
|
+
*/
|
|
20
|
+
const getExpiredGaugeVotePower = async (chainId, gaugeSystem, user, provider) => {
|
|
21
|
+
if (!provider) {
|
|
22
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
23
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
24
|
+
}
|
|
25
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
26
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
27
|
+
const [expiredGaugePower, gauges] = await contract.getExpiredGaugeVotePower(user);
|
|
28
|
+
return { expiredGaugePower, gauges: [...gauges] };
|
|
29
|
+
};
|
|
30
|
+
exports.getExpiredGaugeVotePower = getExpiredGaugeVotePower;
|
|
@@ -6,24 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getGauge = void 0;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
-
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
9
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
11
|
/**
|
|
12
|
-
* Reads
|
|
12
|
+
* Reads a gauge's entry from the controller's public `gauges` mapping.
|
|
13
|
+
*
|
|
13
14
|
* @param chainId - The chain/network to use.
|
|
14
|
-
* @param
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
16
|
+
* @param gaugeAddressOrId - Address or config id of the gauge.
|
|
15
17
|
* @param provider - Optional ethers.js Provider instance.
|
|
16
|
-
* @returns
|
|
18
|
+
* @returns isActive and isBoostAmplificationEnabled flags, weight and lastUpdateTime.
|
|
17
19
|
*/
|
|
18
|
-
const getGauge = async (chainId,
|
|
20
|
+
const getGauge = async (chainId, gaugeSystem, gaugeAddressOrId, provider) => {
|
|
19
21
|
if (!provider) {
|
|
20
22
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
21
23
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
22
24
|
}
|
|
23
|
-
const address = (0,
|
|
24
|
-
const
|
|
25
|
-
const contract = new ethers_1.ethers.Contract(address,
|
|
26
|
-
const [isActive, isBoostAmplificationEnabled, weight, lastUpdateTime] = await contract.gauges(
|
|
25
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
26
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
27
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
28
|
+
const [isActive, isBoostAmplificationEnabled, weight, lastUpdateTime] = await contract.gauges(gaugeAddress);
|
|
27
29
|
return { isActive, isBoostAmplificationEnabled, weight, lastUpdateTime };
|
|
28
30
|
};
|
|
29
31
|
exports.getGauge = getGauge;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getGaugeDistributor = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
|
+
/**
|
|
12
|
+
* Returns the GaugeRewardsDistributor wired to the controller.
|
|
13
|
+
*
|
|
14
|
+
* @param chainId - The chain/network to use.
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
16
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
+
* @returns The distributor address.
|
|
18
|
+
*/
|
|
19
|
+
const getGaugeDistributor = async (chainId, gaugeSystem, provider) => {
|
|
20
|
+
if (!provider) {
|
|
21
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
22
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
23
|
+
}
|
|
24
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
25
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
26
|
+
return contract.gaugeDistributor();
|
|
27
|
+
};
|
|
28
|
+
exports.getGaugeDistributor = getGaugeDistributor;
|
|
@@ -8,6 +8,7 @@ const ethers_1 = require("ethers");
|
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
9
|
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
10
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
12
|
const E18 = 10n ** 18n;
|
|
12
13
|
/**
|
|
13
14
|
* Per-epoch emissions for a gauge. The GaugeController snapshots gauge weights per epoch
|
|
@@ -22,26 +23,32 @@ const E18 = 10n ** 18n;
|
|
|
22
23
|
* where scheduledWeekEmission = minter.calculateScheduledMintableAmount(week) × distributorShare.
|
|
23
24
|
*
|
|
24
25
|
* @param chainId - The chain/network to use.
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
26
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges").
|
|
27
|
+
* @param gaugeAddressOrId - Address or config id of the gauge.
|
|
28
|
+
* @param numEpochs - How many epochs to include, ending at the current one (default 8), clamped to the gauge's start.
|
|
29
|
+
* @param includeUpcoming - Whether to append a projection for the next epoch (default true).
|
|
27
30
|
* @param provider - Optional ethers.js Provider instance.
|
|
28
31
|
*/
|
|
29
|
-
const getGaugeEmissions = async (chainId,
|
|
32
|
+
const getGaugeEmissions = async (chainId, gaugeSystem, gaugeAddressOrId, numEpochs = 8, includeUpcoming = true, provider) => {
|
|
30
33
|
if (!provider) {
|
|
31
34
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
32
35
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
33
36
|
}
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
+
const gauge = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
38
|
+
const distAddr = (0, _helpers_1.resolveGaugeDistributor)(chainId, gaugeSystem);
|
|
39
|
+
const controller = new ethers_1.ethers.Contract((0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem), (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
40
|
+
const distributor = new ethers_1.ethers.Contract(distAddr, (0, artifacts_1.getABI)("gaugerewardsdistributor"), provider);
|
|
41
|
+
const gaugeContract = new ethers_1.ethers.Contract(gauge, (0, artifacts_1.getABI)("basegauge"), provider);
|
|
42
|
+
const [weekBn, currentEpochBn, gaugeData, rewardToken] = await Promise.all([
|
|
37
43
|
controller.WEEK(),
|
|
38
44
|
controller.getCurrentEpoch(),
|
|
39
|
-
|
|
45
|
+
gaugeContract.gaugeData(),
|
|
40
46
|
distributor.rewardToken(),
|
|
41
47
|
]);
|
|
42
48
|
const week = BigInt(weekBn);
|
|
43
49
|
const currentEpoch = BigInt(currentEpochBn);
|
|
44
|
-
const
|
|
50
|
+
const gaugeStart = BigInt(gaugeData.gaugeInitialStartTime ?? gaugeData[0] ?? 0n);
|
|
51
|
+
const startEpoch = gaugeStart > 0n ? (gaugeStart / week) * week : currentEpoch;
|
|
45
52
|
// ── Distributor's share of the minter + scheduled-emission helper ─────────
|
|
46
53
|
// The schedule deterministically sets each week's system emission, so we use it for
|
|
47
54
|
// the in-progress and upcoming epochs (where depositedAtEpoch is partial/zero).
|
|
@@ -49,7 +56,6 @@ const getGaugeEmissions = async (chainId, gauge, numEpochs = 8, includeUpcoming
|
|
|
49
56
|
let minter = null;
|
|
50
57
|
try {
|
|
51
58
|
minter = new ethers_1.ethers.Contract((0, getContractAddress_1.getContractAddress)(chainId, "raacminter"), (0, artifacts_1.getABI)("raacminter"), provider);
|
|
52
|
-
const distAddr = (0, getContractAddress_1.getContractAddress)(chainId, "gaugerewardsdistributor");
|
|
53
59
|
const [info, totalWeight] = await Promise.all([minter.poolInfo(distAddr), minter.totalWeight()]);
|
|
54
60
|
const poolWeight = BigInt(info.weight ?? info[0] ?? 0n);
|
|
55
61
|
const exists = Boolean(info.exists ?? info[1]);
|
|
@@ -2,28 +2,32 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getGaugeRelativeWeight = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
|
-
const getContractAddress_1 = require("../../getContractAddress");
|
|
6
5
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
7
|
+
const _helpers_2 = require("../_helpers");
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* This is a state-modifying call (it writes checkpoints), so it requires a Signer.
|
|
11
|
-
* For a pure read with no state changes, use getGaugeRelativeWeightView instead.
|
|
9
|
+
* Checkpoints a gauge and computes its relative weight at an epoch. State-changing; use `getGaugeRelativeWeightView` to read without a transaction. Reverts during a global pause.
|
|
12
10
|
*
|
|
13
11
|
* @param chainId - The chain/network to use.
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
12
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
13
|
+
* @param gaugeAddressOrId - Address or config id of the gauge.
|
|
14
|
+
* @param epoch - Epoch start timestamp, seconds.
|
|
16
15
|
* @param signer - An ethers.js Signer instance (required).
|
|
17
|
-
* @returns The transaction
|
|
16
|
+
* @returns The transaction after it has been mined.
|
|
18
17
|
*/
|
|
19
|
-
const getGaugeRelativeWeight = async (chainId,
|
|
18
|
+
const getGaugeRelativeWeight = async (chainId, gaugeSystem, gaugeAddressOrId, epoch, signer) => {
|
|
20
19
|
if (!signer)
|
|
21
20
|
throw new Error("Signer is required");
|
|
22
|
-
const address = (0,
|
|
23
|
-
const
|
|
24
|
-
const contract = new ethers_1.ethers.Contract(address,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
22
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
23
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), signer);
|
|
24
|
+
try {
|
|
25
|
+
const tx = await contract.getGaugeRelativeWeight(gaugeAddress, epoch);
|
|
26
|
+
await tx.wait();
|
|
27
|
+
return tx;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
throw (0, _helpers_2.toGovernanceTxError)("Failed to checkpoint gauge relative weight", error);
|
|
31
|
+
}
|
|
28
32
|
};
|
|
29
33
|
exports.getGaugeRelativeWeight = getGaugeRelativeWeight;
|
|
@@ -6,25 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getGaugeRelativeWeightView = void 0;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
-
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
9
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Returns a gauge's relative weight at an epoch without checkpointing.
|
|
13
|
+
*
|
|
13
14
|
* @param chainId - The chain/network to use.
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
16
|
+
* @param gaugeAddressOrId - Address or config id of the gauge.
|
|
17
|
+
* @param epoch - Epoch start timestamp, seconds.
|
|
16
18
|
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
-
* @returns
|
|
19
|
+
* @returns relativeWeight (1e18 = 100%) and the total weight at that epoch.
|
|
18
20
|
*/
|
|
19
|
-
const getGaugeRelativeWeightView = async (chainId,
|
|
21
|
+
const getGaugeRelativeWeightView = async (chainId, gaugeSystem, gaugeAddressOrId, epoch, provider) => {
|
|
20
22
|
if (!provider) {
|
|
21
23
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
22
24
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
23
25
|
}
|
|
24
|
-
const address = (0,
|
|
25
|
-
const
|
|
26
|
-
const contract = new ethers_1.ethers.Contract(address,
|
|
27
|
-
const [relativeWeight, totalWeight] = await contract.getGaugeRelativeWeightView(
|
|
26
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
27
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
28
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
29
|
+
const [relativeWeight, totalWeight] = await contract.getGaugeRelativeWeightView(gaugeAddress, epoch);
|
|
28
30
|
return { relativeWeight, totalWeight };
|
|
29
31
|
};
|
|
30
32
|
exports.getGaugeRelativeWeightView = getGaugeRelativeWeightView;
|
|
@@ -6,23 +6,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getGaugeWeight = void 0;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Returns a gauge's weight at the current epoch.
|
|
13
13
|
*
|
|
14
14
|
* @param chainId - The chain/network to use.
|
|
15
|
-
* @param
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
16
|
+
* @param gaugeAddressOrId - Address or config id of the gauge.
|
|
16
17
|
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
-
* @returns
|
|
18
|
+
* @returns The weight formatted in ether units.
|
|
18
19
|
*/
|
|
19
|
-
const getGaugeWeight = async (chainId,
|
|
20
|
+
const getGaugeWeight = async (chainId, gaugeSystem, gaugeAddressOrId, provider) => {
|
|
20
21
|
if (!provider) {
|
|
21
22
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
22
23
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
23
24
|
}
|
|
24
|
-
const
|
|
25
|
-
const
|
|
25
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
26
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
27
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
26
28
|
const weight = await contract.getGaugeWeight(gaugeAddress);
|
|
27
29
|
return ethers_1.ethers.formatEther(weight);
|
|
28
30
|
};
|
|
@@ -6,24 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getLastVoteTime = void 0;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
-
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
9
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Returns when a user last voted on a gauge.
|
|
13
|
+
*
|
|
13
14
|
* @param chainId - The chain/network to use.
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
14
16
|
* @param user - Address of the user.
|
|
15
|
-
* @param
|
|
17
|
+
* @param gaugeAddressOrId - Address or config id of the gauge.
|
|
16
18
|
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
-
* @returns The last vote timestamp
|
|
19
|
+
* @returns The last vote timestamp, seconds.
|
|
18
20
|
*/
|
|
19
|
-
const getLastVoteTime = async (chainId, user,
|
|
21
|
+
const getLastVoteTime = async (chainId, gaugeSystem, user, gaugeAddressOrId, provider) => {
|
|
20
22
|
if (!provider) {
|
|
21
23
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
22
24
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
23
25
|
}
|
|
24
|
-
const address = (0,
|
|
25
|
-
const
|
|
26
|
-
const contract = new ethers_1.ethers.Contract(address,
|
|
27
|
-
return contract.lastVoteTime(user,
|
|
26
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
27
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
28
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
29
|
+
return contract.lastVoteTime(user, gaugeAddress);
|
|
28
30
|
};
|
|
29
31
|
exports.getLastVoteTime = getLastVoteTime;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getMaxVoteBuckets = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
|
+
/**
|
|
12
|
+
* Returns the per-vote decay-bucket cap. 0 means exact (one entry per lock).
|
|
13
|
+
*
|
|
14
|
+
* @param chainId - The chain/network to use.
|
|
15
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeController address.
|
|
16
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
+
* @returns The bucket cap.
|
|
18
|
+
*/
|
|
19
|
+
const getMaxVoteBuckets = async (chainId, gaugeSystem, provider) => {
|
|
20
|
+
if (!provider) {
|
|
21
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
22
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
23
|
+
}
|
|
24
|
+
const address = (0, _helpers_1.resolveGaugeController)(chainId, gaugeSystem);
|
|
25
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
26
|
+
return contract.maxVoteBuckets();
|
|
27
|
+
};
|
|
28
|
+
exports.getMaxVoteBuckets = getMaxVoteBuckets;
|