@raac/rpc 1.2.0-beta.10 → 1.2.0-beta.12
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 +76 -112
- 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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setMaxClaimBound = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
7
|
+
const _helpers_2 = require("../_helpers");
|
|
8
|
+
/**
|
|
9
|
+
* Caps how many epochs a claim walks per call (MAX_EPOCHS). Requires DISTRIBUTOR_ADMIN.
|
|
10
|
+
*
|
|
11
|
+
* @param chainId - The chain/network to use.
|
|
12
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeRewardsDistributor address.
|
|
13
|
+
* @param enabled - True to cap claim walks.
|
|
14
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
15
|
+
* @returns The transaction after it has been mined.
|
|
16
|
+
*/
|
|
17
|
+
const setMaxClaimBound = async (chainId, gaugeSystem, enabled, signer) => {
|
|
18
|
+
if (!signer)
|
|
19
|
+
throw new Error("Signer is required");
|
|
20
|
+
const address = (0, _helpers_1.resolveGaugeDistributor)(chainId, gaugeSystem);
|
|
21
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugerewardsdistributor"), signer);
|
|
22
|
+
try {
|
|
23
|
+
const tx = await contract.setMaxClaimBound(enabled);
|
|
24
|
+
await tx.wait();
|
|
25
|
+
return tx;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw (0, _helpers_2.toGovernanceTxError)("Failed to set max claim bound", error);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.setMaxClaimBound = setMaxClaimBound;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withdrawDust = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
7
|
+
const _helpers_2 = require("../_helpers");
|
|
8
|
+
/**
|
|
9
|
+
* Sweeps leftover rewards from fully settled epochs to a recipient. Requires DEFAULT_ADMIN_ROLE. Reverts when there is nothing new to sweep.
|
|
10
|
+
*
|
|
11
|
+
* @param chainId - The chain/network to use.
|
|
12
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeRewardsDistributor address.
|
|
13
|
+
* @param recipient - Address that receives the dust.
|
|
14
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
15
|
+
* @returns The transaction after it has been mined.
|
|
16
|
+
*/
|
|
17
|
+
const withdrawDust = async (chainId, gaugeSystem, recipient, signer) => {
|
|
18
|
+
if (!signer)
|
|
19
|
+
throw new Error("Signer is required");
|
|
20
|
+
const address = (0, _helpers_1.resolveGaugeDistributor)(chainId, gaugeSystem);
|
|
21
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugerewardsdistributor"), signer);
|
|
22
|
+
try {
|
|
23
|
+
const tx = await contract.withdrawDust(recipient);
|
|
24
|
+
await tx.wait();
|
|
25
|
+
return tx;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw (0, _helpers_2.toGovernanceTxError)("Failed to withdraw dust", error);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.withdrawDust = withdrawDust;
|
|
@@ -2,26 +2,32 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withdrawRemovedGaugeRewards = 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
|
-
* Requires DEFAULT_ADMIN_ROLE.
|
|
9
|
+
* Redirects a removed gauge's unclaimed entitlement to a recipient. Requires CONTROLLER_ROLE: the controller calls it from `removeGauge`, so admins normally use `governance.controller.removeGauge`.
|
|
10
10
|
*
|
|
11
11
|
* @param chainId - The chain/network to use.
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
12
|
+
* @param gaugeSystem - Gauge system id ("raacgauges" or "rwagauges") or a GaugeRewardsDistributor address.
|
|
13
|
+
* @param gaugeAddressOrId - Address or config id of the gauge.
|
|
14
|
+
* @param recipient - Address that receives the redirected rewards.
|
|
14
15
|
* @param signer - An ethers.js Signer instance (required).
|
|
15
|
-
* @returns
|
|
16
|
+
* @returns The transaction after it has been mined.
|
|
16
17
|
*/
|
|
17
|
-
const withdrawRemovedGaugeRewards = async (chainId,
|
|
18
|
+
const withdrawRemovedGaugeRewards = async (chainId, gaugeSystem, gaugeAddressOrId, recipient, signer) => {
|
|
18
19
|
if (!signer)
|
|
19
20
|
throw new Error("Signer is required");
|
|
20
|
-
const address = (0,
|
|
21
|
-
const
|
|
22
|
-
const contract = new ethers_1.ethers.Contract(address,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const address = (0, _helpers_1.resolveGaugeDistributor)(chainId, gaugeSystem);
|
|
22
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
23
|
+
const contract = new ethers_1.ethers.Contract(address, (0, artifacts_1.getABI)("gaugerewardsdistributor"), signer);
|
|
24
|
+
try {
|
|
25
|
+
const tx = await contract.withdrawRemovedGaugeRewards(gaugeAddress, recipient);
|
|
26
|
+
await tx.wait();
|
|
27
|
+
return tx;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
throw (0, _helpers_2.toGovernanceTxError)("Failed to withdraw removed gauge rewards", error);
|
|
31
|
+
}
|
|
26
32
|
};
|
|
27
33
|
exports.withdrawRemovedGaugeRewards = withdrawRemovedGaugeRewards;
|
|
@@ -0,0 +1,122 @@
|
|
|
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.loadGaugeApyState = exports.toApyPct = exports.SECONDS_PER_YEAR = 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
|
+
exports.SECONDS_PER_YEAR = 365n * 24n * 60n * 60n;
|
|
12
|
+
const E18 = 10n ** 18n;
|
|
13
|
+
const E36 = 10n ** 36n;
|
|
14
|
+
const ERC20_DECIMALS_ABI = ["function decimals() view returns (uint8)"];
|
|
15
|
+
const priceOf = (prices, token) => {
|
|
16
|
+
const target = token.toLowerCase();
|
|
17
|
+
const entry = Object.entries(prices.rewardTokenPricesUSD ?? {}).find(([key]) => key.toLowerCase() === target);
|
|
18
|
+
return entry && Number.isFinite(entry[1]) ? entry[1] : null;
|
|
19
|
+
};
|
|
20
|
+
const toReward = (token, kind, yearly, decimals, active, prices) => {
|
|
21
|
+
const priceUSD = priceOf(prices, token);
|
|
22
|
+
const yearlyRewards = ethers_1.ethers.formatUnits(yearly, decimals);
|
|
23
|
+
return {
|
|
24
|
+
token,
|
|
25
|
+
kind,
|
|
26
|
+
yearlyRewards,
|
|
27
|
+
priceUSD,
|
|
28
|
+
yearlyRewardsUSD: priceUSD === null ? null : Number(yearlyRewards) * priceUSD,
|
|
29
|
+
active,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/** Annualized percentage: yearly USD over staked USD, or null when nothing is staked or the staking token has no price. */
|
|
33
|
+
const toApyPct = (yearlyUSD, stakedUnits, stakingTokenPriceUSD) => {
|
|
34
|
+
const stakedUSD = stakedUnits * stakingTokenPriceUSD;
|
|
35
|
+
return stakedUSD > 0 ? (yearlyUSD / stakedUSD) * 100 : null;
|
|
36
|
+
};
|
|
37
|
+
exports.toApyPct = toApyPct;
|
|
38
|
+
/**
|
|
39
|
+
* Loads the gauge state an APY calculation needs: supplies, boost bounds and each reward token's yearly emission.
|
|
40
|
+
*
|
|
41
|
+
* @param chainId - The chain/network to use.
|
|
42
|
+
* @param gaugeAddressOrId - Address of the gauge contract or its config ID.
|
|
43
|
+
* @param prices - USD prices for the staking token and reward tokens.
|
|
44
|
+
* @param options - Reward source selection.
|
|
45
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
46
|
+
* @returns The loaded state.
|
|
47
|
+
*/
|
|
48
|
+
const loadGaugeApyState = async (chainId, gaugeAddressOrId, prices, options = {}, provider) => {
|
|
49
|
+
if (!provider) {
|
|
50
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
51
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
52
|
+
}
|
|
53
|
+
if (!prices || !Number.isFinite(prices.stakingTokenPriceUSD)) {
|
|
54
|
+
throw new Error("prices.stakingTokenPriceUSD is required");
|
|
55
|
+
}
|
|
56
|
+
const rewardSource = options.rewardSource ?? "epoch";
|
|
57
|
+
const gauge = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
58
|
+
const gaugeContract = new ethers_1.ethers.Contract(gauge, (0, artifacts_1.getABI)("basegauge"), provider);
|
|
59
|
+
const [data, controllerAddress, extraTokens, [, periodEnd], block] = await Promise.all([
|
|
60
|
+
gaugeContract.gaugeData(),
|
|
61
|
+
gaugeContract.gaugeController(),
|
|
62
|
+
gaugeContract.getExtraRewardTokens(),
|
|
63
|
+
gaugeContract.getPeriodBoundaries(),
|
|
64
|
+
provider.getBlock("latest"),
|
|
65
|
+
]);
|
|
66
|
+
if (!block)
|
|
67
|
+
throw new Error("Failed to read the latest block");
|
|
68
|
+
const now = BigInt(block.timestamp);
|
|
69
|
+
const controller = new ethers_1.ethers.Contract(controllerAddress, (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
70
|
+
const stakingTokenContract = new ethers_1.ethers.Contract(data.stakingToken, ERC20_DECIMALS_ABI, provider);
|
|
71
|
+
const [minBoost, maxBoost, stakingDecimals, mainData] = await Promise.all([
|
|
72
|
+
controller.MIN_BOOST(),
|
|
73
|
+
controller.MAX_BOOST(),
|
|
74
|
+
stakingTokenContract.decimals().then((d) => Number(d)),
|
|
75
|
+
gaugeContract.getGaugeRewardTokenData(data.rewardToken),
|
|
76
|
+
]);
|
|
77
|
+
const rewards = [];
|
|
78
|
+
if (rewardSource === "epoch") {
|
|
79
|
+
const distributor = new ethers_1.ethers.Contract(data.rewardDistributor, (0, artifacts_1.getABI)("gaugerewardsdistributor"), provider);
|
|
80
|
+
const [week, currentEpoch] = await Promise.all([controller.WEEK(), controller.getCurrentEpoch()]);
|
|
81
|
+
const lastEpoch = currentEpoch - week;
|
|
82
|
+
const [deposited, [relativeWeight]] = await Promise.all([
|
|
83
|
+
distributor.depositedAtEpoch(data.rewardToken, lastEpoch),
|
|
84
|
+
controller.getGaugeRelativeWeightView(gauge, lastEpoch),
|
|
85
|
+
]);
|
|
86
|
+
const perEpoch = (deposited * relativeWeight) / E18;
|
|
87
|
+
rewards.push(toReward(data.rewardToken, "main", (perEpoch * exports.SECONDS_PER_YEAR) / week, Number(mainData.decimals), perEpoch > 0n, prices));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// rate is 18-decimal-normalized tokens per second scaled by 1e36 (ray-divided wad) and only streams until the period ends.
|
|
91
|
+
const active = now < periodEnd && mainData.rate > 0n;
|
|
92
|
+
const yearly = active ? (mainData.rate * exports.SECONDS_PER_YEAR) / E36 : 0n;
|
|
93
|
+
rewards.push(toReward(data.rewardToken, "main", yearly, 18, active, prices));
|
|
94
|
+
}
|
|
95
|
+
const extras = await Promise.all([...extraTokens].map(async (token) => {
|
|
96
|
+
const extra = await gaugeContract.extraRewardTokenData(token);
|
|
97
|
+
// Extra rate is 18-decimal-normalized tokens per second scaled by 1e18.
|
|
98
|
+
const active = extra.isActive && now < extra.periodFinish && extra.rate > 0n;
|
|
99
|
+
const yearly = active ? (extra.rate * exports.SECONDS_PER_YEAR) / E18 : 0n;
|
|
100
|
+
return toReward(token, "extra", yearly, 18, active, prices);
|
|
101
|
+
}));
|
|
102
|
+
rewards.push(...extras);
|
|
103
|
+
const sumUSD = (kind) => rewards.filter((r) => r.kind === kind).reduce((sum, r) => sum + (r.yearlyRewardsUSD ?? 0), 0);
|
|
104
|
+
return {
|
|
105
|
+
provider,
|
|
106
|
+
now,
|
|
107
|
+
gauge,
|
|
108
|
+
gaugeContract,
|
|
109
|
+
controller,
|
|
110
|
+
stakingToken: data.stakingToken,
|
|
111
|
+
stakingDecimals,
|
|
112
|
+
totalSupply: data.totalSupply,
|
|
113
|
+
workingSupply: data.workingSupply,
|
|
114
|
+
minBoost,
|
|
115
|
+
maxBoost,
|
|
116
|
+
rewardSource,
|
|
117
|
+
rewards,
|
|
118
|
+
mainYearlyUSD: sumUSD("main"),
|
|
119
|
+
extraYearlyUSD: sumUSD("extra"),
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
exports.loadGaugeApyState = loadGaugeApyState;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGaugeTokens = exports.ERC4626_ABI = exports.ERC20_ABI = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const GAUGE_ABI = [
|
|
6
|
+
"function gaugeData() view returns (uint256 gaugeInitialStartTime, uint256 periodDuration, uint256 periodIndex, address stakingToken, uint256 totalSupply, uint256 workingSupply, address rewardDistributor, address rewardToken, uint256 lastUpdateTime)",
|
|
7
|
+
];
|
|
8
|
+
const VAULT_ABI = ["function asset() view returns (address)", "function totalAssets() view returns (uint256)"];
|
|
9
|
+
exports.ERC20_ABI = [
|
|
10
|
+
"function symbol() view returns (string)",
|
|
11
|
+
"function decimals() view returns (uint8)",
|
|
12
|
+
"function balanceOf(address) view returns (uint256)",
|
|
13
|
+
"function allowance(address owner, address spender) view returns (uint256)",
|
|
14
|
+
"function approve(address spender, uint256 amount) returns (bool)",
|
|
15
|
+
];
|
|
16
|
+
exports.ERC4626_ABI = [
|
|
17
|
+
"function deposit(uint256 assets, address receiver) returns (uint256 shares)",
|
|
18
|
+
"function redeem(uint256 shares, address receiver, address owner) returns (uint256 assets)",
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Reads a gauge's staking token from the gauge and whether it wraps another token. A staking token counts as a wrapper
|
|
22
|
+
* when it exposes a non-zero `asset()` and a working `totalAssets()`, the same test the subgraph uses for its `wrapped` flag.
|
|
23
|
+
*/
|
|
24
|
+
const getGaugeTokens = async (gaugeAddress, runner) => {
|
|
25
|
+
const gauge = new ethers_1.ethers.Contract(gaugeAddress, GAUGE_ABI, runner);
|
|
26
|
+
const stakingToken = (await gauge.gaugeData()).stakingToken;
|
|
27
|
+
const vault = new ethers_1.ethers.Contract(stakingToken, VAULT_ABI, runner);
|
|
28
|
+
try {
|
|
29
|
+
const [asset] = await Promise.all([vault.asset(), vault.totalAssets()]);
|
|
30
|
+
return { stakingToken, underlying: asset === ethers_1.ethers.ZeroAddress ? null : asset };
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return { stakingToken, underlying: null };
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.getGaugeTokens = getGaugeTokens;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.addRewardToken = void 0;
|
|
7
4
|
const ethers_1 = require("ethers");
|
|
8
5
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
9
|
-
const
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
10
7
|
/**
|
|
11
8
|
* Registers a new reward token on the gauge (requires GAUGE_ADMIN).
|
|
12
9
|
* @param chainId - The chain/network to use.
|
|
@@ -17,14 +14,7 @@ const getContractAddress_1 = __importDefault(require("../../getContractAddress")
|
|
|
17
14
|
const addRewardToken = async (chainId, gaugeAddressOrId, token, signer) => {
|
|
18
15
|
if (!signer)
|
|
19
16
|
throw new Error("Signer is required");
|
|
20
|
-
|
|
21
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
22
|
-
gaugeAddress = gaugeAddressOrId;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
27
|
-
}
|
|
17
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
28
18
|
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
29
19
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, signer);
|
|
30
20
|
const tx = await contract.addRewardToken(token);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.approveGaugeToken = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
6
|
+
const _tokens_1 = require("./_tokens");
|
|
7
|
+
/**
|
|
8
|
+
* Approves the contract that pulls a gauge token: the staking token to the gauge, or for a wrapped gauge the underlying
|
|
9
|
+
* to the wrapper.
|
|
10
|
+
*
|
|
11
|
+
* @param chainId - The chain/network to use.
|
|
12
|
+
* @param gaugeAddressOrId - Address of the gauge contract or its config ID.
|
|
13
|
+
* @param token - "staking" to stake, "underlying" to wrap.
|
|
14
|
+
* @param amount - Allowance to set, base units.
|
|
15
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
16
|
+
* @returns The mined transaction.
|
|
17
|
+
*/
|
|
18
|
+
const approveGaugeToken = async (chainId, gaugeAddressOrId, token, amount, signer) => {
|
|
19
|
+
if (!signer)
|
|
20
|
+
throw new Error("Signer is required");
|
|
21
|
+
const gauge = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
22
|
+
const { stakingToken, underlying } = await (0, _tokens_1.getGaugeTokens)(gauge, signer);
|
|
23
|
+
if (token === "underlying" && !underlying) {
|
|
24
|
+
throw new Error(`Gauge ${gauge} does not take a wrapped token`);
|
|
25
|
+
}
|
|
26
|
+
const [address, spender] = token === "staking" ? [stakingToken, gauge] : [underlying, stakingToken];
|
|
27
|
+
const tx = await new ethers_1.ethers.Contract(address, _tokens_1.ERC20_ABI, signer).approve(spender, amount);
|
|
28
|
+
await tx.wait();
|
|
29
|
+
return tx;
|
|
30
|
+
};
|
|
31
|
+
exports.approveGaugeToken = approveGaugeToken;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.claimExtraReward = void 0;
|
|
7
4
|
const ethers_1 = require("ethers");
|
|
8
5
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
9
|
-
const
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
10
7
|
/**
|
|
11
8
|
* Claims a single extra reward token for the caller on the given gauge.
|
|
12
9
|
* @param chainId - The chain/network to use.
|
|
@@ -17,14 +14,7 @@ const getContractAddress_1 = __importDefault(require("../../getContractAddress")
|
|
|
17
14
|
const claimExtraReward = async (chainId, gaugeAddressOrId, token, signer) => {
|
|
18
15
|
if (!signer)
|
|
19
16
|
throw new Error("Signer is required");
|
|
20
|
-
|
|
21
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
22
|
-
gaugeAddress = gaugeAddressOrId;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
27
|
-
}
|
|
17
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
28
18
|
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
29
19
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, signer);
|
|
30
20
|
const tx = await contract.claimExtraReward(token);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.claimExtraRewards = void 0;
|
|
7
4
|
const ethers_1 = require("ethers");
|
|
8
5
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
9
|
-
const
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
10
7
|
/**
|
|
11
8
|
* Claims all extra reward tokens for the caller on the given gauge.
|
|
12
9
|
* @param chainId - The chain/network to use.
|
|
@@ -16,14 +13,7 @@ const getContractAddress_1 = __importDefault(require("../../getContractAddress")
|
|
|
16
13
|
const claimExtraRewards = async (chainId, gaugeAddressOrId, signer) => {
|
|
17
14
|
if (!signer)
|
|
18
15
|
throw new Error("Signer is required");
|
|
19
|
-
|
|
20
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
21
|
-
gaugeAddress = gaugeAddressOrId;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
26
|
-
}
|
|
16
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
27
17
|
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
28
18
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, signer);
|
|
29
19
|
const tx = await contract.claimExtraRewards();
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.claimOnBehalfOf = void 0;
|
|
7
4
|
const ethers_1 = require("ethers");
|
|
8
5
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
9
|
-
const
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
10
7
|
/**
|
|
11
8
|
* Claims a specific token amount on behalf of a user (requires CLAIM_FOR_ROLE).
|
|
12
9
|
* @param chainId - The chain/network to use.
|
|
@@ -19,14 +16,7 @@ const getContractAddress_1 = __importDefault(require("../../getContractAddress")
|
|
|
19
16
|
const claimOnBehalfOf = async (chainId, gaugeAddressOrId, token, amount, user, signer) => {
|
|
20
17
|
if (!signer)
|
|
21
18
|
throw new Error("Signer is required");
|
|
22
|
-
|
|
23
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
24
|
-
gaugeAddress = gaugeAddressOrId;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
29
|
-
}
|
|
19
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
30
20
|
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
31
21
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, signer);
|
|
32
22
|
const tx = await contract.claimOnBehalfOf(token, amount, user);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.claimRewardToken = void 0;
|
|
7
4
|
const ethers_1 = require("ethers");
|
|
8
5
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
9
|
-
const
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
10
7
|
/**
|
|
11
|
-
* Claims
|
|
8
|
+
* Claims the caller's main reward token from a gauge, pulling the gauge's share from its distributor first. Reverts while the gauge or its controller is paused.
|
|
12
9
|
*
|
|
13
10
|
* @param chainId - The chain/network to use.
|
|
14
11
|
* @param gaugeAddressOrId - Address of the gauge contract or ID of the gauge.
|
|
@@ -19,15 +16,8 @@ const claimRewardToken = async (chainId, gaugeAddressOrId, signer) => {
|
|
|
19
16
|
if (!signer) {
|
|
20
17
|
throw new Error("Signer is required");
|
|
21
18
|
}
|
|
22
|
-
|
|
19
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
23
20
|
try {
|
|
24
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
25
|
-
gaugeAddress = gaugeAddressOrId;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
30
|
-
}
|
|
31
21
|
const gaugeABI = (0, artifacts_1.getABI)("basegauge");
|
|
32
22
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, gaugeABI, signer);
|
|
33
23
|
const tx = await contract.claimRewardToken();
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.claimRewardsFor = void 0;
|
|
7
4
|
const ethers_1 = require("ethers");
|
|
8
5
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
9
|
-
const
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
10
7
|
/**
|
|
11
8
|
* Claims rewards on behalf of a user (requires DISTRIBUTOR_ROLE).
|
|
12
9
|
* @param chainId - The chain/network to use.
|
|
@@ -17,14 +14,7 @@ const getContractAddress_1 = __importDefault(require("../../getContractAddress")
|
|
|
17
14
|
const claimRewardsFor = async (chainId, gaugeAddressOrId, user, signer) => {
|
|
18
15
|
if (!signer)
|
|
19
16
|
throw new Error("Signer is required");
|
|
20
|
-
|
|
21
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
22
|
-
gaugeAddress = gaugeAddressOrId;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
27
|
-
}
|
|
17
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
28
18
|
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
29
19
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, signer);
|
|
30
20
|
const tx = await contract.claimRewardsFor(user);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.depositRewardToken = void 0;
|
|
7
4
|
const ethers_1 = require("ethers");
|
|
8
5
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
9
|
-
const
|
|
6
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
10
7
|
/**
|
|
11
8
|
* Deposits an amount of a reward token into the gauge for distribution.
|
|
12
9
|
* @param chainId - The chain/network to use.
|
|
@@ -18,14 +15,7 @@ const getContractAddress_1 = __importDefault(require("../../getContractAddress")
|
|
|
18
15
|
const depositRewardToken = async (chainId, gaugeAddressOrId, token, amount, signer) => {
|
|
19
16
|
if (!signer)
|
|
20
17
|
throw new Error("Signer is required");
|
|
21
|
-
|
|
22
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
23
|
-
gaugeAddress = gaugeAddressOrId;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
28
|
-
}
|
|
18
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
29
19
|
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
30
20
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, signer);
|
|
31
21
|
const tx = await contract.depositRewardToken(token, amount);
|
|
@@ -7,7 +7,7 @@ exports.getAllPendingExtraRewards = void 0;
|
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
9
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
-
const
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
11
|
/**
|
|
12
12
|
* Gets all pending extra rewards for a user across all extra reward tokens.
|
|
13
13
|
* @param chainId - The chain/network to use.
|
|
@@ -20,14 +20,7 @@ const getAllPendingExtraRewards = async (chainId, gaugeAddressOrId, user, provid
|
|
|
20
20
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
21
21
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
25
|
-
gaugeAddress = gaugeAddressOrId;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
30
|
-
}
|
|
23
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
31
24
|
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
32
25
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, provider);
|
|
33
26
|
const [tokens, amounts] = await contract.allPendingExtraRewards(user);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getApy = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const _apy_1 = require("./_apy");
|
|
6
|
+
const add = (a, b) => (a === null && b === null ? null : (a ?? 0) + (b ?? 0));
|
|
7
|
+
/**
|
|
8
|
+
* Calculates a gauge's minimum (no boost) and maximum (full boost) APY. Figures are simple annualized rates in percent, not compounded.
|
|
9
|
+
*
|
|
10
|
+
* Main rewards are shared by working balance, where a staker counts for `balance × boost / MAX_BOOST` (capped at balance). A fully boosted staker's working balance equals their stake, so maxApy = yearly main rewards USD / (workingSupply × staking price), and minApy = maxApy × MIN_BOOST / MAX_BOOST. Extra rewards are shared by raw balance over totalSupply. The figures hold workingSupply fixed, so a large new deposit, or other stakers boosting, lowers them. The "stream" source jumps whenever a pull compresses rewards into the rest of a period, e.g. after a pause.
|
|
11
|
+
*
|
|
12
|
+
* @param chainId - The chain/network to use.
|
|
13
|
+
* @param gaugeAddressOrId - Address of the gauge contract or its config ID.
|
|
14
|
+
* @param prices - USD price of the staking token and of each reward token (see `getRewardTokens`).
|
|
15
|
+
* @param options - Optional reward source: "epoch" (default) or "stream".
|
|
16
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
+
* @returns Min, max and extra APY with the supplies and per-token yearly rewards behind them. An APY is null when nothing is staked.
|
|
18
|
+
*/
|
|
19
|
+
const getApy = async (chainId, gaugeAddressOrId, prices, options = {}, provider) => {
|
|
20
|
+
const state = await (0, _apy_1.loadGaugeApyState)(chainId, gaugeAddressOrId, prices, options, provider);
|
|
21
|
+
const totalStaked = ethers_1.ethers.formatUnits(state.totalSupply, state.stakingDecimals);
|
|
22
|
+
const workingSupply = ethers_1.ethers.formatUnits(state.workingSupply, state.stakingDecimals);
|
|
23
|
+
const price = prices.stakingTokenPriceUSD;
|
|
24
|
+
const maxApy = (0, _apy_1.toApyPct)(state.mainYearlyUSD, Number(workingSupply), price);
|
|
25
|
+
const minApy = maxApy === null ? null : (maxApy * Number(state.minBoost)) / Number(state.maxBoost);
|
|
26
|
+
const extraApy = (0, _apy_1.toApyPct)(state.extraYearlyUSD, Number(totalStaked), price);
|
|
27
|
+
return {
|
|
28
|
+
gauge: state.gauge,
|
|
29
|
+
stakingToken: state.stakingToken,
|
|
30
|
+
rewardSource: state.rewardSource,
|
|
31
|
+
totalStaked,
|
|
32
|
+
workingSupply,
|
|
33
|
+
tvlUSD: Number(totalStaked) * price,
|
|
34
|
+
minBoost: Number(state.minBoost) / 10000,
|
|
35
|
+
maxBoost: Number(state.maxBoost) / 10000,
|
|
36
|
+
minApy,
|
|
37
|
+
maxApy,
|
|
38
|
+
extraApy,
|
|
39
|
+
totalMinApy: add(minApy, extraApy),
|
|
40
|
+
totalMaxApy: add(maxApy, extraApy),
|
|
41
|
+
rewards: state.rewards,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.getApy = getApy;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getBalanceOf = void 0;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
-
const
|
|
9
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
10
10
|
const BALANCE_OF_ABI = "function balanceOf(address account) view returns (uint256)";
|
|
11
11
|
/**
|
|
12
12
|
* Gets the working balance of an account (includes boost).
|
|
@@ -22,20 +22,7 @@ const getBalanceOf = async (chainId, gaugeAddressOrId, accountAddress, provider)
|
|
|
22
22
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
23
23
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
28
|
-
gaugeAddress = gaugeAddressOrId;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
console.error("Error getting balance of:", error);
|
|
37
|
-
throw new Error(`Failed to get balance of from gauge ${gaugeAddress}: ${error.message}`);
|
|
38
|
-
}
|
|
25
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
39
26
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, [BALANCE_OF_ABI], provider);
|
|
40
27
|
const balance = await contract.balanceOf(accountAddress);
|
|
41
28
|
return ethers_1.ethers.formatEther(balance);
|
|
@@ -7,7 +7,7 @@ exports.getControllerAddress = void 0;
|
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
9
|
const artifacts_1 = require("../../../utils/artifacts");
|
|
10
|
-
const
|
|
10
|
+
const _helpers_1 = require("../gaugeSystems/_helpers");
|
|
11
11
|
/**
|
|
12
12
|
* Gets the gauge controller address registered on the gauge.
|
|
13
13
|
* @param chainId - The chain/network to use.
|
|
@@ -19,14 +19,7 @@ const getControllerAddress = async (chainId, gaugeAddressOrId, provider) => {
|
|
|
19
19
|
const rpc = chains_1.default[chainId].rpcs[0];
|
|
20
20
|
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
if ((0, ethers_1.isAddress)(gaugeAddressOrId)) {
|
|
24
|
-
gaugeAddress = gaugeAddressOrId;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
gaugeAddress = (0, getContractAddress_1.default)(chainId, gaugeAddressOrId.toLowerCase());
|
|
29
|
-
}
|
|
22
|
+
const gaugeAddress = (0, _helpers_1.resolveGauge)(chainId, gaugeAddressOrId);
|
|
30
23
|
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
31
24
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, provider);
|
|
32
25
|
return contract.getControllerAddress();
|