@raac/rpc 1.2.0-beta.6 → 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/configs/chains/11155111.json +13 -2
- package/dist/contracts/governance/gaugeController/getGaugeEmissions.js +136 -0
- package/dist/contracts/governance/gaugeController/index.js +1 -0
- package/dist/types/contracts/governance/gaugeController/getGaugeEmissions.d.ts +51 -0
- package/dist/types/contracts/governance/gaugeController/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -298,8 +298,11 @@
|
|
|
298
298
|
"id": "RAAC_RcrvUSD",
|
|
299
299
|
"name": "RAAC RcrvUSD Gauge",
|
|
300
300
|
"type": "RAACGauge",
|
|
301
|
-
"contract": "
|
|
302
|
-
"stakingToken": "
|
|
301
|
+
"contract": "0xc6e49678e7a7D797Cb11EE5D2834A3896200096D",
|
|
302
|
+
"stakingToken": "0xa610498F28448Eb379BFD3179381F6f094ad110b",
|
|
303
|
+
"wrapped": true,
|
|
304
|
+
"underlying": "0x062a641EF54810B321f123487fFf083cadB50989",
|
|
305
|
+
"wrapper": "0xa610498F28448Eb379BFD3179381F6f094ad110b"
|
|
303
306
|
},
|
|
304
307
|
"raac_crvusd_lp": {
|
|
305
308
|
"id": "RAAC_crvUSD_LP",
|
|
@@ -307,6 +310,14 @@
|
|
|
307
310
|
"type": "RAACGauge",
|
|
308
311
|
"contract": "0x04F3e12A814b21B9F947c726be512719a41b980f",
|
|
309
312
|
"stakingToken": "0xCfDBbad91770fb7Fd57e623A59dcbD14670164c7"
|
|
313
|
+
},
|
|
314
|
+
"raac_rcrvusd_old": {
|
|
315
|
+
"id": "RAAC_RcrvUSD_old",
|
|
316
|
+
"name": "RAAC RcrvUSD Gauge (deprecated)",
|
|
317
|
+
"type": "RAACGauge",
|
|
318
|
+
"contract": "0xE8eBe8294542d47f481c17036C8165CB8935554a",
|
|
319
|
+
"stakingToken": "0x062a641EF54810B321f123487fFf083cadB50989",
|
|
320
|
+
"_note": "Replaced by raac_rcrvusd (wrapped). Active state is read on-chain; reclaim stuck votes via removePowerFromGauge."
|
|
310
321
|
}
|
|
311
322
|
}
|
|
312
323
|
}
|
|
@@ -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;
|
|
@@ -25,6 +25,7 @@ __exportStar(require("./getCurrentEpoch"), exports);
|
|
|
25
25
|
__exportStar(require("./getGauge"), exports);
|
|
26
26
|
__exportStar(require("./getGaugeRelativeWeight"), exports);
|
|
27
27
|
__exportStar(require("./getGaugeRelativeWeightView"), exports);
|
|
28
|
+
__exportStar(require("./getGaugeEmissions"), exports);
|
|
28
29
|
__exportStar(require("./getGaugeWeight"), exports);
|
|
29
30
|
__exportStar(require("./getLastVoteTime"), exports);
|
|
30
31
|
__exportStar(require("./getNextEpoch"), exports);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Provider } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
export interface GaugeEpochEmission {
|
|
4
|
+
/** Epoch (Unix-week) start timestamp, seconds. */
|
|
5
|
+
epoch: number;
|
|
6
|
+
/** Reward token deposited into the distributor for this epoch (formatted). */
|
|
7
|
+
deposited: string;
|
|
8
|
+
/** Gauge relative weight at this epoch, 1e18-scaled (1e18 = 100%). */
|
|
9
|
+
relativeWeight: bigint;
|
|
10
|
+
/** Gauge relative weight as a percentage 0..100. */
|
|
11
|
+
relativeWeightPct: number;
|
|
12
|
+
/** RAAC this gauge received/was allocated for this epoch = deposited × relativeWeight. */
|
|
13
|
+
gaugeEmission: string;
|
|
14
|
+
gaugeEmissionRaw: bigint;
|
|
15
|
+
/** True for the in-progress (current) epoch — `deposited` may still grow via tick(). */
|
|
16
|
+
isCurrent: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* True for the upcoming (next) epoch preview. Nothing is deposited yet, so `deposited`
|
|
19
|
+
* is the PROJECTED system emission for that week (schedule × distributor share) and
|
|
20
|
+
* `gaugeEmission` is the projection from the gauge's weight at `nextEpoch` — i.e. what
|
|
21
|
+
* this gauge would receive if voting stays as it currently stands.
|
|
22
|
+
*/
|
|
23
|
+
isProjected?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface GaugeEmissionsResult {
|
|
26
|
+
gauge: string;
|
|
27
|
+
rewardToken: string;
|
|
28
|
+
currentEpoch: number;
|
|
29
|
+
weekSeconds: number;
|
|
30
|
+
/** Current-epoch gauge relative weight as a percentage 0..100. */
|
|
31
|
+
relativeWeightPct: number;
|
|
32
|
+
/** RAAC allocated to this gauge for the current (in-progress) epoch. */
|
|
33
|
+
currentWeekEmission: string;
|
|
34
|
+
/** Per-epoch series, oldest → newest, ending at the current epoch. */
|
|
35
|
+
epochs: GaugeEpochEmission[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Per-epoch emissions actually received by a gauge: the GaugeController snapshots
|
|
39
|
+
* gauge weights per epoch, and the GaugeRewardsDistributor records the RAAC deposited
|
|
40
|
+
* per epoch. A gauge's emission for an epoch is therefore
|
|
41
|
+
* depositedAtEpoch(epoch) × gaugeRelativeWeight(gauge, epoch).
|
|
42
|
+
*
|
|
43
|
+
* Returns a series ending at the current (in-progress) epoch so callers can chart
|
|
44
|
+
* "week of X → this gauge received Y RAAC".
|
|
45
|
+
*
|
|
46
|
+
* @param chainId - The chain/network to use.
|
|
47
|
+
* @param gauge - Gauge address (or config key).
|
|
48
|
+
* @param numEpochs - How many epochs to include, ending at the current one (default 8).
|
|
49
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
50
|
+
*/
|
|
51
|
+
export declare const getGaugeEmissions: (chainId: ChainId, gauge: string, numEpochs?: number, includeUpcoming?: boolean, provider?: Provider) => Promise<GaugeEmissionsResult>;
|
|
@@ -8,6 +8,7 @@ export * from "./getCurrentEpoch";
|
|
|
8
8
|
export * from "./getGauge";
|
|
9
9
|
export * from "./getGaugeRelativeWeight";
|
|
10
10
|
export * from "./getGaugeRelativeWeightView";
|
|
11
|
+
export * from "./getGaugeEmissions";
|
|
11
12
|
export * from "./getGaugeWeight";
|
|
12
13
|
export * from "./getLastVoteTime";
|
|
13
14
|
export * from "./getNextEpoch";
|