@raac/rpc 1.2.0-beta.5 → 1.2.0-beta.7
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 +38 -97
- package/dist/artifacts/core/collectors/FeeCollector.sol/FeeCollector.json +2 -2
- package/dist/artifacts/core/governance/gauges/BaseGauge.sol/BaseGauge.json +155 -144
- package/dist/artifacts/core/governance/gauges/GaugeController.sol/GaugeController.json +119 -335
- package/dist/artifacts/core/governance/gauges/GaugeRewardsDistributor.sol/GaugeRewardsDistributor.json +104 -325
- package/dist/artifacts/core/governance/gauges/RAACGauge.sol/RAACGauge.json +167 -146
- package/dist/artifacts/core/governance/gauges/RWAGauge.sol/RWAGauge.json +167 -146
- package/dist/artifacts/core/governance/proposals/Governance.sol/Governance.json +2 -2
- package/dist/artifacts/core/lockers/RAACLiquidLocker.sol/RAACLiquidLocker.json +2 -2
- package/dist/artifacts/core/tokens/veRAACToken.sol/veRAACToken.json +66 -32
- package/dist/configs/chains/11155111.json +83 -16
- package/dist/configs/chains/8453.json +6 -6
- package/dist/contracts/getContractAddress.js +1 -0
- package/dist/contracts/governance/distributor/claimAll.js +25 -0
- package/dist/contracts/governance/distributor/claimForGauge.js +26 -0
- package/dist/contracts/governance/distributor/deposit.js +12 -21
- package/dist/contracts/governance/distributor/getClaimableForGauge.js +29 -0
- package/dist/contracts/governance/distributor/getClaimedAtEpoch.js +30 -0
- package/dist/contracts/governance/distributor/getDepositedAtEpoch.js +30 -0
- package/dist/contracts/governance/distributor/getGaugeController.js +28 -0
- package/dist/contracts/governance/distributor/getLastClaimedEpoch.js +29 -0
- package/dist/contracts/governance/distributor/getPeriodDuration.js +28 -0
- package/dist/contracts/governance/distributor/{getRewardTokens.js → getRewardToken.js} +10 -9
- package/dist/contracts/governance/distributor/getRewardTokenInfo.js +9 -19
- package/dist/contracts/governance/distributor/getRewardTokenStats.js +30 -0
- package/dist/contracts/governance/{gaugeController/isGauge.js → distributor/getStartEpoch.js} +10 -10
- package/dist/contracts/governance/distributor/index.js +31 -17
- package/dist/contracts/governance/distributor/setController.js +26 -0
- package/dist/contracts/governance/distributor/withdrawRemovedGaugeRewards.js +27 -0
- package/dist/contracts/governance/distributor/withdrawUnallocatedRewards.js +26 -0
- package/dist/contracts/governance/gauge/addRewardToken.js +34 -0
- package/dist/contracts/governance/gauge/claimExtraReward.js +34 -0
- package/dist/contracts/governance/gauge/claimExtraRewards.js +33 -0
- package/dist/contracts/governance/gauge/claimOnBehalfOf.js +36 -0
- package/dist/contracts/governance/gauge/claimRewardToken.js +3 -4
- package/dist/contracts/governance/gauge/claimRewardsFor.js +34 -0
- package/dist/contracts/governance/gauge/depositRewardToken.js +35 -0
- package/dist/contracts/governance/gauge/getAllPendingExtraRewards.js +36 -0
- package/dist/contracts/governance/gauge/getControllerAddress.js +34 -0
- package/dist/contracts/governance/gauge/getDecimalAdjustment.js +35 -0
- package/dist/contracts/governance/gauge/getDepositRAACOnClaim.js +34 -0
- package/dist/contracts/governance/gauge/getDistributorData.js +36 -0
- package/dist/contracts/governance/gauge/getDistributors.js +34 -0
- package/dist/contracts/governance/gauge/getEarnedReward.js +11 -19
- package/dist/contracts/governance/gauge/getExtraRewardTokens.js +34 -0
- package/dist/contracts/governance/gauge/getGaugeRewardTokenData.js +44 -0
- package/dist/contracts/governance/gauge/getPendingExtraRewards.js +36 -0
- package/dist/contracts/governance/gauge/getPendingRewards.js +11 -19
- package/dist/contracts/governance/gauge/getRaacAutolockMin.js +34 -0
- package/dist/contracts/governance/gauge/getUserRewardTokenData.js +37 -0
- package/dist/contracts/governance/gauge/getUserWeight.js +35 -0
- package/dist/contracts/governance/gauge/index.js +53 -35
- package/dist/contracts/governance/gauge/isPaused.js +34 -0
- package/dist/contracts/governance/gauge/manageDistributor.js +35 -0
- package/dist/contracts/governance/gauge/setController.js +34 -0
- package/dist/contracts/governance/gauge/setDepositRAACOnClaim.js +34 -0
- package/dist/contracts/governance/gauge/setDistributorApproval.js +35 -0
- package/dist/contracts/governance/gauge/setEmergencyPaused.js +34 -0
- package/dist/contracts/governance/gauge/setGaugeRewardDistributor.js +34 -0
- package/dist/contracts/governance/gauge/setRaacAutolockMin.js +34 -0
- package/dist/contracts/governance/gauge/updateUserRewards.js +3 -2
- package/dist/contracts/governance/gaugeController/addGauge.js +24 -0
- package/dist/contracts/governance/gaugeController/batchVote.js +25 -0
- package/dist/contracts/governance/gaugeController/forceCompleteCheckpoint.js +24 -0
- package/dist/contracts/governance/gaugeController/getConstants.js +45 -0
- package/dist/contracts/governance/gaugeController/getCurrentEpoch.js +27 -0
- package/dist/contracts/governance/gaugeController/getGauge.js +29 -0
- package/dist/contracts/governance/gaugeController/getGaugeEmissions.js +136 -0
- package/dist/contracts/governance/gaugeController/getGaugeRelativeWeight.js +29 -0
- package/dist/contracts/governance/gaugeController/getGaugeRelativeWeightView.js +30 -0
- package/dist/contracts/governance/gaugeController/getLastVoteTime.js +29 -0
- package/dist/contracts/governance/gaugeController/getNextEpoch.js +27 -0
- package/dist/contracts/governance/gaugeController/getUserGaugeVotePower.js +29 -0
- package/dist/contracts/governance/gaugeController/getVeToken.js +27 -0
- package/dist/contracts/governance/gaugeController/getVoteUserPower.js +28 -0
- package/dist/contracts/governance/gaugeController/getVoteUserSlope.js +30 -0
- package/dist/contracts/governance/gaugeController/index.js +44 -23
- package/dist/contracts/governance/gaugeController/isPaused.js +27 -0
- package/dist/contracts/governance/gaugeController/kick.js +24 -0
- package/dist/contracts/governance/gaugeController/removeGauge.js +24 -0
- package/dist/contracts/governance/gaugeController/removePowerFromGauge.js +24 -0
- package/dist/contracts/governance/gaugeController/setBoostAmplificationEnabled.js +25 -0
- package/dist/contracts/governance/gaugeController/setEmergencyGaugePause.js +25 -0
- package/dist/contracts/governance/gaugeController/setEmergencyPause.js +24 -0
- package/dist/contracts/lockers/botLocker/unlock.js +4 -1
- package/dist/contracts/lockers/maturityVault/harvest.js +3 -2
- package/dist/types/RPCLibrary.d.ts +6 -64
- package/dist/types/contracts/governance/distributor/claimAll.d.ts +11 -0
- package/dist/types/contracts/governance/distributor/claimForGauge.d.ts +12 -0
- package/dist/types/contracts/governance/distributor/deposit.d.ts +6 -7
- package/dist/types/contracts/governance/distributor/getClaimableForGauge.d.ts +11 -0
- package/dist/types/contracts/governance/distributor/getClaimedAtEpoch.d.ts +12 -0
- package/dist/types/contracts/governance/distributor/getDepositedAtEpoch.d.ts +12 -0
- package/dist/types/contracts/governance/distributor/getGaugeController.d.ts +10 -0
- package/dist/types/contracts/governance/distributor/getLastClaimedEpoch.d.ts +11 -0
- package/dist/types/contracts/governance/distributor/getPeriodDuration.d.ts +10 -0
- package/dist/types/contracts/governance/distributor/{getRewardTokens.d.ts → getRewardToken.d.ts} +3 -3
- package/dist/types/contracts/governance/distributor/getRewardTokenInfo.d.ts +8 -10
- package/dist/types/contracts/governance/distributor/getRewardTokenStats.d.ts +15 -0
- package/dist/types/contracts/governance/distributor/getStartEpoch.d.ts +10 -0
- package/dist/types/contracts/governance/distributor/index.d.ts +16 -8
- package/dist/types/contracts/governance/distributor/setController.d.ts +12 -0
- package/dist/types/contracts/governance/distributor/withdrawRemovedGaugeRewards.d.ts +13 -0
- package/dist/types/contracts/governance/distributor/withdrawUnallocatedRewards.d.ts +12 -0
- package/dist/types/contracts/governance/gauge/addRewardToken.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/claimExtraReward.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/claimExtraRewards.d.ts +9 -0
- package/dist/types/contracts/governance/gauge/claimOnBehalfOf.d.ts +12 -0
- package/dist/types/contracts/governance/gauge/claimRewardToken.d.ts +1 -2
- package/dist/types/contracts/governance/gauge/claimRewardsFor.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/depositRewardToken.d.ts +11 -0
- package/dist/types/contracts/governance/gauge/getAllPendingExtraRewards.d.ts +13 -0
- package/dist/types/contracts/governance/gauge/getControllerAddress.d.ts +9 -0
- package/dist/types/contracts/governance/gauge/getDecimalAdjustment.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/getDepositRAACOnClaim.d.ts +9 -0
- package/dist/types/contracts/governance/gauge/getDistributorData.d.ts +13 -0
- package/dist/types/contracts/governance/gauge/{getRewardTokens.d.ts → getDistributors.d.ts} +3 -5
- package/dist/types/contracts/governance/gauge/getEarnedReward.d.ts +4 -5
- package/dist/types/contracts/governance/gauge/getExtraRewardTokens.d.ts +9 -0
- package/dist/types/contracts/governance/gauge/getGaugeRewardTokenData.d.ts +18 -0
- package/dist/types/contracts/governance/gauge/getPendingExtraRewards.d.ts +11 -0
- package/dist/types/contracts/governance/gauge/getPendingRewards.d.ts +4 -5
- package/dist/types/contracts/governance/gauge/getRaacAutolockMin.d.ts +9 -0
- package/dist/types/contracts/governance/gauge/getUserRewardTokenData.d.ts +17 -0
- package/dist/types/contracts/governance/gauge/getUserWeight.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/index.d.ts +38 -17
- package/dist/types/contracts/governance/gauge/isPaused.d.ts +9 -0
- package/dist/types/contracts/governance/gauge/manageDistributor.d.ts +11 -0
- package/dist/types/contracts/governance/gauge/setController.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/setDepositRAACOnClaim.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/setDistributorApproval.d.ts +11 -0
- package/dist/types/contracts/governance/gauge/setEmergencyPaused.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/setGaugeRewardDistributor.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/setRaacAutolockMin.d.ts +10 -0
- package/dist/types/contracts/governance/gauge/updateUserRewards.d.ts +2 -1
- package/dist/types/contracts/governance/gaugeController/addGauge.d.ts +10 -0
- package/dist/types/contracts/governance/gaugeController/batchVote.d.ts +11 -0
- package/dist/types/contracts/governance/gaugeController/forceCompleteCheckpoint.d.ts +10 -0
- package/dist/types/contracts/governance/gaugeController/getConstants.d.ts +18 -0
- package/dist/types/contracts/governance/gaugeController/getCurrentEpoch.d.ts +9 -0
- package/dist/types/contracts/governance/gaugeController/getGauge.d.ts +15 -0
- package/dist/types/contracts/governance/gaugeController/getGaugeEmissions.d.ts +51 -0
- package/dist/types/contracts/governance/gaugeController/getGaugeRelativeWeight.d.ts +15 -0
- package/dist/types/contracts/governance/gaugeController/getGaugeRelativeWeightView.d.ts +14 -0
- package/dist/types/contracts/governance/gaugeController/getLastVoteTime.d.ts +11 -0
- package/dist/types/contracts/governance/gaugeController/getNextEpoch.d.ts +9 -0
- package/dist/types/contracts/governance/gaugeController/getUserGaugeVotePower.d.ts +11 -0
- package/dist/types/contracts/governance/gaugeController/getVeToken.d.ts +9 -0
- package/dist/types/contracts/governance/gaugeController/getVoteUserPower.d.ts +10 -0
- package/dist/types/contracts/governance/gaugeController/getVoteUserSlope.d.ts +15 -0
- package/dist/types/contracts/governance/gaugeController/index.d.ts +29 -11
- package/dist/types/contracts/governance/gaugeController/isPaused.d.ts +9 -0
- package/dist/types/contracts/governance/gaugeController/kick.d.ts +10 -0
- package/dist/types/contracts/governance/gaugeController/removeGauge.d.ts +10 -0
- package/dist/types/contracts/governance/gaugeController/removePowerFromGauge.d.ts +10 -0
- package/dist/types/contracts/governance/gaugeController/setBoostAmplificationEnabled.d.ts +11 -0
- package/dist/types/contracts/governance/gaugeController/setEmergencyGaugePause.d.ts +11 -0
- package/dist/types/contracts/governance/gaugeController/setEmergencyPause.d.ts +10 -0
- package/dist/types/contracts/lockers/botLocker/unlock.d.ts +3 -0
- package/dist/types/contracts/lockers/maturityVault/harvest.d.ts +1 -1
- package/dist/utils/contracts.js +1 -1
- package/package.json +1 -1
- package/dist/contracts/governance/distributor/getAvailableBalance.js +0 -29
- package/dist/contracts/governance/distributor/getGaugeRewardTokens.js +0 -28
- package/dist/contracts/governance/distributor/getTransferableBalance.js +0 -30
- package/dist/contracts/governance/distributor/isRewardTokenApproved.js +0 -29
- package/dist/contracts/governance/distributor/isTokenApproved.js +0 -29
- package/dist/contracts/governance/gauge/claimReward.js +0 -44
- package/dist/contracts/governance/gauge/getAllEarnedRewards.js +0 -51
- package/dist/contracts/governance/gauge/getAllPendingRewards.js +0 -41
- package/dist/contracts/governance/gauge/getRewardTokens.js +0 -41
- package/dist/contracts/governance/gauge/getUserGaugeVoteWeight.js +0 -42
- package/dist/contracts/governance/gauge/getWorkingBalance.js +0 -43
- package/dist/contracts/governance/gauge/syncRewardTokens.js +0 -51
- package/dist/contracts/governance/gaugeController/checkpoint.js +0 -33
- package/dist/contracts/governance/gaugeController/checkpointGauge.js +0 -34
- package/dist/contracts/governance/gaugeController/getUserGaugeVoteWeight.js +0 -30
- package/dist/tests/liquidLocker.test.js +0 -262
- package/dist/tests/test.js +0 -32
- package/dist/types/contracts/governance/distributor/getAvailableBalance.d.ts +0 -11
- package/dist/types/contracts/governance/distributor/getGaugeRewardTokens.d.ts +0 -11
- package/dist/types/contracts/governance/distributor/getTransferableBalance.d.ts +0 -12
- package/dist/types/contracts/governance/distributor/isRewardTokenApproved.d.ts +0 -12
- package/dist/types/contracts/governance/distributor/isTokenApproved.d.ts +0 -11
- package/dist/types/contracts/governance/gauge/claimReward.d.ts +0 -11
- package/dist/types/contracts/governance/gauge/getAllEarnedRewards.d.ts +0 -17
- package/dist/types/contracts/governance/gauge/getAllPendingRewards.d.ts +0 -19
- package/dist/types/contracts/governance/gauge/getUserGaugeVoteWeight.d.ts +0 -14
- package/dist/types/contracts/governance/gauge/getWorkingBalance.d.ts +0 -12
- package/dist/types/contracts/governance/gauge/syncRewardTokens.d.ts +0 -13
- package/dist/types/contracts/governance/gaugeController/checkpoint.d.ts +0 -11
- package/dist/types/contracts/governance/gaugeController/checkpointGauge.d.ts +0 -12
- package/dist/types/contracts/governance/gaugeController/getUserGaugeVoteWeight.d.ts +0 -12
- package/dist/types/contracts/governance/gaugeController/isGauge.d.ts +0 -11
- package/dist/types/tests/liquidLocker.test.d.ts +0 -18
- package/dist/types/tests/test.d.ts +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
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.setGaugeRewardDistributor = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
9
|
+
const getContractAddress_1 = __importDefault(require("../../getContractAddress"));
|
|
10
|
+
/**
|
|
11
|
+
* Sets the gauge reward distributor address (requires DEFAULT_ADMIN_ROLE).
|
|
12
|
+
* @param chainId - The chain/network to use.
|
|
13
|
+
* @param gaugeAddressOrId - Address of the gauge contract or its config ID.
|
|
14
|
+
* @param rewardDistributor - Address of the new reward distributor.
|
|
15
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
16
|
+
*/
|
|
17
|
+
const setGaugeRewardDistributor = async (chainId, gaugeAddressOrId, rewardDistributor, signer) => {
|
|
18
|
+
if (!signer)
|
|
19
|
+
throw new Error("Signer is required");
|
|
20
|
+
let gaugeAddress;
|
|
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
|
+
}
|
|
28
|
+
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
29
|
+
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, signer);
|
|
30
|
+
const tx = await contract.setGaugeRewardDistributor(rewardDistributor);
|
|
31
|
+
await tx.wait();
|
|
32
|
+
return tx;
|
|
33
|
+
};
|
|
34
|
+
exports.setGaugeRewardDistributor = setGaugeRewardDistributor;
|
|
@@ -0,0 +1,34 @@
|
|
|
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.setRaacAutolockMin = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
9
|
+
const getContractAddress_1 = __importDefault(require("../../getContractAddress"));
|
|
10
|
+
/**
|
|
11
|
+
* Sets the minimum RAAC amount required to trigger an autolock on claim (requires DEFAULT_ADMIN_ROLE).
|
|
12
|
+
* @param chainId - The chain/network to use.
|
|
13
|
+
* @param gaugeAddressOrId - Address of the gauge contract or its config ID.
|
|
14
|
+
* @param amount - The new minimum autolock amount.
|
|
15
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
16
|
+
*/
|
|
17
|
+
const setRaacAutolockMin = async (chainId, gaugeAddressOrId, amount, signer) => {
|
|
18
|
+
if (!signer)
|
|
19
|
+
throw new Error("Signer is required");
|
|
20
|
+
let gaugeAddress;
|
|
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
|
+
}
|
|
28
|
+
const abi = (0, artifacts_1.getABI)("basegauge");
|
|
29
|
+
const contract = new ethers_1.ethers.Contract(gaugeAddress, abi, signer);
|
|
30
|
+
const tx = await contract.setRaacAutolockMin(amount);
|
|
31
|
+
await tx.wait();
|
|
32
|
+
return tx;
|
|
33
|
+
};
|
|
34
|
+
exports.setRaacAutolockMin = setRaacAutolockMin;
|
|
@@ -13,10 +13,11 @@ const getContractAddress_1 = __importDefault(require("../../getContractAddress")
|
|
|
13
13
|
*
|
|
14
14
|
* @param chainId - The chain/network to use.
|
|
15
15
|
* @param gaugeAddressOrId - Address of the gauge contract or ID of the gauge.
|
|
16
|
+
* @param user - Address of the user whose reward state should be settled/kicked.
|
|
16
17
|
* @param signer - An ethers.js Signer instance (must be connected to wallet).
|
|
17
18
|
* @returns Transaction receipt after the update is complete.
|
|
18
19
|
*/
|
|
19
|
-
const updateUserRewards = async (chainId, gaugeAddressOrId, signer) => {
|
|
20
|
+
const updateUserRewards = async (chainId, gaugeAddressOrId, user, signer) => {
|
|
20
21
|
if (!signer) {
|
|
21
22
|
throw new Error("Signer is required");
|
|
22
23
|
}
|
|
@@ -37,7 +38,7 @@ const updateUserRewards = async (chainId, gaugeAddressOrId, signer) => {
|
|
|
37
38
|
try {
|
|
38
39
|
const gaugeABI = (0, artifacts_1.getABI)("basegauge");
|
|
39
40
|
const contract = new ethers_1.ethers.Contract(gaugeAddress, gaugeABI, signer);
|
|
40
|
-
const tx = await contract.updateUserRewards();
|
|
41
|
+
const tx = await contract.updateUserRewards(user);
|
|
41
42
|
await tx.wait();
|
|
42
43
|
console.log(`Updated user rewards for gauge: ${gaugeAddress}`);
|
|
43
44
|
return tx;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addGauge = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
6
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
7
|
+
/**
|
|
8
|
+
* Adds a new gauge to the GaugeController. Requires the GAUGE_ADMIN role.
|
|
9
|
+
* @param chainId - The chain/network to use.
|
|
10
|
+
* @param gauge - Address of the gauge to add.
|
|
11
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
12
|
+
* @returns The transaction response.
|
|
13
|
+
*/
|
|
14
|
+
const addGauge = async (chainId, gauge, signer) => {
|
|
15
|
+
if (!signer)
|
|
16
|
+
throw new Error("Signer is required");
|
|
17
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
18
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
19
|
+
const contract = new ethers_1.ethers.Contract(address, abi, signer);
|
|
20
|
+
const tx = await contract.addGauge(gauge);
|
|
21
|
+
await tx.wait();
|
|
22
|
+
return tx;
|
|
23
|
+
};
|
|
24
|
+
exports.addGauge = addGauge;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.batchVote = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
6
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
7
|
+
/**
|
|
8
|
+
* Casts votes on multiple gauges in a single transaction.
|
|
9
|
+
* @param chainId - The chain/network to use.
|
|
10
|
+
* @param gaugeAddresses - Array of gauge addresses to vote on.
|
|
11
|
+
* @param voteWeights - Array of vote weights (basis points) aligned with gaugeAddresses.
|
|
12
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
13
|
+
* @returns The transaction response.
|
|
14
|
+
*/
|
|
15
|
+
const batchVote = async (chainId, gaugeAddresses, voteWeights, signer) => {
|
|
16
|
+
if (!signer)
|
|
17
|
+
throw new Error("Signer is required");
|
|
18
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
19
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
20
|
+
const contract = new ethers_1.ethers.Contract(address, abi, signer);
|
|
21
|
+
const tx = await contract.batchVote(gaugeAddresses, voteWeights);
|
|
22
|
+
await tx.wait();
|
|
23
|
+
return tx;
|
|
24
|
+
};
|
|
25
|
+
exports.batchVote = batchVote;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.forceCompleteCheckpoint = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
6
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
7
|
+
/**
|
|
8
|
+
* Forces completion of a pending checkpoint for a gauge.
|
|
9
|
+
* @param chainId - The chain/network to use.
|
|
10
|
+
* @param gauge - Address of the gauge to checkpoint.
|
|
11
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
12
|
+
* @returns The transaction response.
|
|
13
|
+
*/
|
|
14
|
+
const forceCompleteCheckpoint = async (chainId, gauge, signer) => {
|
|
15
|
+
if (!signer)
|
|
16
|
+
throw new Error("Signer is required");
|
|
17
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
18
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
19
|
+
const contract = new ethers_1.ethers.Contract(address, abi, signer);
|
|
20
|
+
const tx = await contract.forceCompleteCheckpoint(gauge);
|
|
21
|
+
await tx.wait();
|
|
22
|
+
return tx;
|
|
23
|
+
};
|
|
24
|
+
exports.forceCompleteCheckpoint = forceCompleteCheckpoint;
|
|
@@ -0,0 +1,45 @@
|
|
|
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.getConstants = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Reads the immutable/constant configuration values from the GaugeController.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
15
|
+
* @returns An object with maxBoost, minBoost, weightPrecision, week, weightVoteDelay,
|
|
16
|
+
* minVoteWeight and maxVoteWeight, all bigint.
|
|
17
|
+
*/
|
|
18
|
+
const getConstants = async (chainId, provider) => {
|
|
19
|
+
if (!provider) {
|
|
20
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
21
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
22
|
+
}
|
|
23
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
24
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
25
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
26
|
+
const [maxBoost, minBoost, weightPrecision, week, weightVoteDelay, minVoteWeight, maxVoteWeight,] = await Promise.all([
|
|
27
|
+
contract.MAX_BOOST(),
|
|
28
|
+
contract.MIN_BOOST(),
|
|
29
|
+
contract.WEIGHT_PRECISION(),
|
|
30
|
+
contract.WEEK(),
|
|
31
|
+
contract.WEIGHT_VOTE_DELAY(),
|
|
32
|
+
contract.MIN_VOTE_WEIGHT(),
|
|
33
|
+
contract.MAX_VOTE_WEIGHT(),
|
|
34
|
+
]);
|
|
35
|
+
return {
|
|
36
|
+
maxBoost,
|
|
37
|
+
minBoost,
|
|
38
|
+
weightPrecision,
|
|
39
|
+
week,
|
|
40
|
+
weightVoteDelay,
|
|
41
|
+
minVoteWeight,
|
|
42
|
+
maxVoteWeight,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
exports.getConstants = getConstants;
|
|
@@ -0,0 +1,27 @@
|
|
|
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.getCurrentEpoch = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Gets the current epoch boundary (rounded down to the week) from the GaugeController.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
15
|
+
* @returns Current epoch timestamp as a bigint.
|
|
16
|
+
*/
|
|
17
|
+
const getCurrentEpoch = async (chainId, provider) => {
|
|
18
|
+
if (!provider) {
|
|
19
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
20
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
21
|
+
}
|
|
22
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
23
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
24
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
25
|
+
return contract.getCurrentEpoch();
|
|
26
|
+
};
|
|
27
|
+
exports.getCurrentEpoch = getCurrentEpoch;
|
|
@@ -0,0 +1,29 @@
|
|
|
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.getGauge = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Reads the gauge config struct from the public `gauges` mapping on the GaugeController.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param gauge - Address of the gauge.
|
|
15
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
16
|
+
* @returns An object with isActive, isBoostAmplificationEnabled (booleans), weight and lastUpdateTime (bigint).
|
|
17
|
+
*/
|
|
18
|
+
const getGauge = async (chainId, gauge, provider) => {
|
|
19
|
+
if (!provider) {
|
|
20
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
21
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
22
|
+
}
|
|
23
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
24
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
25
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
26
|
+
const [isActive, isBoostAmplificationEnabled, weight, lastUpdateTime] = await contract.gauges(gauge);
|
|
27
|
+
return { isActive, isBoostAmplificationEnabled, weight, lastUpdateTime };
|
|
28
|
+
};
|
|
29
|
+
exports.getGauge = getGauge;
|
|
@@ -0,0 +1,136 @@
|
|
|
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.getGaugeEmissions = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
const E18 = 10n ** 18n;
|
|
12
|
+
/**
|
|
13
|
+
* Per-epoch emissions actually received by a gauge: the GaugeController snapshots
|
|
14
|
+
* gauge weights per epoch, and the GaugeRewardsDistributor records the RAAC deposited
|
|
15
|
+
* per epoch. A gauge's emission for an epoch is therefore
|
|
16
|
+
* depositedAtEpoch(epoch) × gaugeRelativeWeight(gauge, epoch).
|
|
17
|
+
*
|
|
18
|
+
* Returns a series ending at the current (in-progress) epoch so callers can chart
|
|
19
|
+
* "week of X → this gauge received Y RAAC".
|
|
20
|
+
*
|
|
21
|
+
* @param chainId - The chain/network to use.
|
|
22
|
+
* @param gauge - Gauge address (or config key).
|
|
23
|
+
* @param numEpochs - How many epochs to include, ending at the current one (default 8).
|
|
24
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
25
|
+
*/
|
|
26
|
+
const getGaugeEmissions = async (chainId, gauge, numEpochs = 8, includeUpcoming = true, provider) => {
|
|
27
|
+
if (!provider) {
|
|
28
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
29
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
30
|
+
}
|
|
31
|
+
const controller = new ethers_1.ethers.Contract((0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller"), (0, artifacts_1.getABI)("gaugecontroller"), provider);
|
|
32
|
+
const distributor = new ethers_1.ethers.Contract((0, getContractAddress_1.getContractAddress)(chainId, "gaugerewardsdistributor"), (0, artifacts_1.getABI)("gaugerewardsdistributor"), provider);
|
|
33
|
+
const [weekBn, currentEpochBn, startEpochBn, rewardToken] = await Promise.all([
|
|
34
|
+
controller.WEEK(),
|
|
35
|
+
controller.getCurrentEpoch(),
|
|
36
|
+
distributor.startEpoch(),
|
|
37
|
+
distributor.rewardToken(),
|
|
38
|
+
]);
|
|
39
|
+
const week = BigInt(weekBn);
|
|
40
|
+
const currentEpoch = BigInt(currentEpochBn);
|
|
41
|
+
const startEpoch = BigInt(startEpochBn) > 0n ? BigInt(startEpochBn) : currentEpoch;
|
|
42
|
+
// Window: [currentEpoch - (numEpochs-1)*week .. currentEpoch], clamped to startEpoch.
|
|
43
|
+
const span = BigInt(Math.max(1, numEpochs) - 1) * week;
|
|
44
|
+
let from = currentEpoch - span;
|
|
45
|
+
if (from < startEpoch)
|
|
46
|
+
from = startEpoch;
|
|
47
|
+
const epochList = [];
|
|
48
|
+
for (let e = from; e <= currentEpoch; e += week)
|
|
49
|
+
epochList.push(e);
|
|
50
|
+
const epochs = await Promise.all(epochList.map(async (e) => {
|
|
51
|
+
let deposited = 0n;
|
|
52
|
+
let relativeWeight = 0n;
|
|
53
|
+
try {
|
|
54
|
+
deposited = BigInt(await distributor.depositedAtEpoch(rewardToken, e));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
/* ignore */
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const [rel] = await controller.getGaugeRelativeWeightView(gauge, e);
|
|
61
|
+
relativeWeight = BigInt(rel);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
/* no snapshot at this epoch */
|
|
65
|
+
}
|
|
66
|
+
const gaugeEmissionRaw = (deposited * relativeWeight) / E18;
|
|
67
|
+
return {
|
|
68
|
+
epoch: Number(e),
|
|
69
|
+
deposited: ethers_1.ethers.formatEther(deposited),
|
|
70
|
+
relativeWeight,
|
|
71
|
+
relativeWeightPct: Number((relativeWeight * 10000n) / E18) / 100,
|
|
72
|
+
gaugeEmission: ethers_1.ethers.formatEther(gaugeEmissionRaw),
|
|
73
|
+
gaugeEmissionRaw,
|
|
74
|
+
isCurrent: e === currentEpoch,
|
|
75
|
+
};
|
|
76
|
+
}));
|
|
77
|
+
const current = epochs[epochs.length - 1];
|
|
78
|
+
// ── Upcoming-epoch preview ────────────────────────────────────────────────
|
|
79
|
+
// Votes cast this epoch take effect at nextEpoch, so getGaugeRelativeWeightView
|
|
80
|
+
// at nextEpoch already reflects current voting. Nothing is deposited yet, so we
|
|
81
|
+
// project the distributor's deposit from the emission schedule:
|
|
82
|
+
// projectedSystem = minterWeekly(nextEpoch) × distributorShareOfMinter
|
|
83
|
+
// projectedGauge = projectedSystem × gaugeRelativeWeight(nextEpoch)
|
|
84
|
+
if (includeUpcoming) {
|
|
85
|
+
const nextEpoch = currentEpoch + week;
|
|
86
|
+
let relNext = 0n;
|
|
87
|
+
let minterWeekly = 0n;
|
|
88
|
+
let distShare = 0n; // 1e18-scaled fraction of the minter routed to the distributor
|
|
89
|
+
try {
|
|
90
|
+
const [rel] = await controller.getGaugeRelativeWeightView(gauge, nextEpoch);
|
|
91
|
+
relNext = BigInt(rel);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
/* no projected snapshot */
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const minter = new ethers_1.ethers.Contract((0, getContractAddress_1.getContractAddress)(chainId, "raacminter"), (0, artifacts_1.getABI)("raacminter"), provider);
|
|
98
|
+
minterWeekly = BigInt(await minter.calculateScheduledMintableAmount(nextEpoch, nextEpoch + week));
|
|
99
|
+
// distributor's share of the minter's weighted distribution
|
|
100
|
+
const distAddr = (0, getContractAddress_1.getContractAddress)(chainId, "gaugerewardsdistributor");
|
|
101
|
+
const [info, totalWeight] = await Promise.all([
|
|
102
|
+
minter.poolInfo(distAddr),
|
|
103
|
+
minter.totalWeight(),
|
|
104
|
+
]);
|
|
105
|
+
const poolWeight = BigInt(info.weight ?? info[0] ?? 0n);
|
|
106
|
+
const exists = Boolean(info.exists ?? info[1]);
|
|
107
|
+
const tw = BigInt(totalWeight);
|
|
108
|
+
distShare = exists && tw > 0n ? (poolWeight * E18) / tw : 0n;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
/* minter not readable — projection stays 0 */
|
|
112
|
+
}
|
|
113
|
+
const projectedSystem = (minterWeekly * distShare) / E18;
|
|
114
|
+
const projectedRaw = (projectedSystem * relNext) / E18;
|
|
115
|
+
epochs.push({
|
|
116
|
+
epoch: Number(nextEpoch),
|
|
117
|
+
deposited: ethers_1.ethers.formatEther(projectedSystem),
|
|
118
|
+
relativeWeight: relNext,
|
|
119
|
+
relativeWeightPct: Number((relNext * 10000n) / E18) / 100,
|
|
120
|
+
gaugeEmission: ethers_1.ethers.formatEther(projectedRaw),
|
|
121
|
+
gaugeEmissionRaw: projectedRaw,
|
|
122
|
+
isCurrent: false,
|
|
123
|
+
isProjected: true,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
gauge,
|
|
128
|
+
rewardToken,
|
|
129
|
+
currentEpoch: Number(currentEpoch),
|
|
130
|
+
weekSeconds: Number(week),
|
|
131
|
+
relativeWeightPct: current ? current.relativeWeightPct : 0,
|
|
132
|
+
currentWeekEmission: current ? current.gaugeEmission : "0",
|
|
133
|
+
epochs,
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
exports.getGaugeEmissions = getGaugeEmissions;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGaugeRelativeWeight = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
6
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
7
|
+
/**
|
|
8
|
+
* Computes and checkpoints a gauge's relative weight at a given epoch.
|
|
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.
|
|
12
|
+
*
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param gauge - Address of the gauge.
|
|
15
|
+
* @param epoch - Epoch timestamp to checkpoint.
|
|
16
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
17
|
+
* @returns The transaction response.
|
|
18
|
+
*/
|
|
19
|
+
const getGaugeRelativeWeight = async (chainId, gauge, epoch, signer) => {
|
|
20
|
+
if (!signer)
|
|
21
|
+
throw new Error("Signer is required");
|
|
22
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
23
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
24
|
+
const contract = new ethers_1.ethers.Contract(address, abi, signer);
|
|
25
|
+
const tx = await contract.getGaugeRelativeWeight(gauge, epoch);
|
|
26
|
+
await tx.wait();
|
|
27
|
+
return tx;
|
|
28
|
+
};
|
|
29
|
+
exports.getGaugeRelativeWeight = getGaugeRelativeWeight;
|
|
@@ -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.getGaugeRelativeWeightView = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Reads a gauge's relative weight at a given epoch without modifying state.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param gauge - Address of the gauge.
|
|
15
|
+
* @param epoch - Epoch timestamp to query.
|
|
16
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
+
* @returns An object with relativeWeight (1e18-scaled, where 1e18 = 100%) and totalWeight, both bigint.
|
|
18
|
+
*/
|
|
19
|
+
const getGaugeRelativeWeightView = async (chainId, gauge, epoch, 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, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
25
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
26
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
27
|
+
const [relativeWeight, totalWeight] = await contract.getGaugeRelativeWeightView(gauge, epoch);
|
|
28
|
+
return { relativeWeight, totalWeight };
|
|
29
|
+
};
|
|
30
|
+
exports.getGaugeRelativeWeightView = getGaugeRelativeWeightView;
|
|
@@ -0,0 +1,29 @@
|
|
|
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.getLastVoteTime = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Gets the timestamp of a user's last vote on a given gauge.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param user - Address of the user.
|
|
15
|
+
* @param gauge - Address of the gauge.
|
|
16
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
+
* @returns The last vote timestamp as a bigint.
|
|
18
|
+
*/
|
|
19
|
+
const getLastVoteTime = async (chainId, user, gauge, 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, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
25
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
26
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
27
|
+
return contract.lastVoteTime(user, gauge);
|
|
28
|
+
};
|
|
29
|
+
exports.getLastVoteTime = getLastVoteTime;
|
|
@@ -0,0 +1,27 @@
|
|
|
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.getNextEpoch = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Gets the next epoch boundary (current epoch plus one week) from the GaugeController.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
15
|
+
* @returns Next epoch timestamp as a bigint.
|
|
16
|
+
*/
|
|
17
|
+
const getNextEpoch = async (chainId, provider) => {
|
|
18
|
+
if (!provider) {
|
|
19
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
20
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
21
|
+
}
|
|
22
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
23
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
24
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
25
|
+
return contract.getNextEpoch();
|
|
26
|
+
};
|
|
27
|
+
exports.getNextEpoch = getNextEpoch;
|
|
@@ -0,0 +1,29 @@
|
|
|
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.getUserGaugeVotePower = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Gets the vote weight (in basis points) a user has allocated to a gauge.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param user - Address of the user.
|
|
15
|
+
* @param gauge - Address of the gauge.
|
|
16
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
+
* @returns Vote weight in basis points as a bigint.
|
|
18
|
+
*/
|
|
19
|
+
const getUserGaugeVotePower = async (chainId, user, gauge, 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, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
25
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
26
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
27
|
+
return contract.getUserGaugeVotePower(user, gauge);
|
|
28
|
+
};
|
|
29
|
+
exports.getUserGaugeVotePower = getUserGaugeVotePower;
|
|
@@ -0,0 +1,27 @@
|
|
|
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.getVeToken = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Gets the veToken (voting escrow token) address used by the GaugeController.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
15
|
+
* @returns The veToken contract address as a string.
|
|
16
|
+
*/
|
|
17
|
+
const getVeToken = async (chainId, provider) => {
|
|
18
|
+
if (!provider) {
|
|
19
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
20
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
21
|
+
}
|
|
22
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
23
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
24
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
25
|
+
return contract.veToken();
|
|
26
|
+
};
|
|
27
|
+
exports.getVeToken = getVeToken;
|
|
@@ -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.getVoteUserPower = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Gets the total vote power a user has currently allocated across all gauges.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param user - Address of the user.
|
|
15
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
16
|
+
* @returns The user's allocated vote power as a bigint.
|
|
17
|
+
*/
|
|
18
|
+
const getVoteUserPower = async (chainId, user, provider) => {
|
|
19
|
+
if (!provider) {
|
|
20
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
21
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
22
|
+
}
|
|
23
|
+
const address = (0, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
24
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
25
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
26
|
+
return contract.voteUserPower(user);
|
|
27
|
+
};
|
|
28
|
+
exports.getVoteUserPower = getVoteUserPower;
|
|
@@ -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.getVoteUserSlope = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Reads a user's vote slope for a gauge from the public `voteUserSlopes` mapping.
|
|
13
|
+
* @param chainId - The chain/network to use.
|
|
14
|
+
* @param user - Address of the user.
|
|
15
|
+
* @param gauge - Address of the gauge.
|
|
16
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
+
* @returns An object with locked, power and end, all bigint.
|
|
18
|
+
*/
|
|
19
|
+
const getVoteUserSlope = async (chainId, user, gauge, 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, getContractAddress_1.getContractAddress)(chainId, "gaugecontroller");
|
|
25
|
+
const abi = (0, artifacts_1.getABI)("gaugecontroller");
|
|
26
|
+
const contract = new ethers_1.ethers.Contract(address, abi, provider);
|
|
27
|
+
const [locked, power, end] = await contract.voteUserSlopes(user, gauge);
|
|
28
|
+
return { locked, power, end };
|
|
29
|
+
};
|
|
30
|
+
exports.getVoteUserSlope = getVoteUserSlope;
|