Skip to content

Commit ce3532b

Browse files
authored
Merge pull request fei-protocol#4 from fei-protocol/feat/emitVotes
emit votes
2 parents b309c36 + 63ec9b4 commit ce3532b

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

lib/ERC4626

lib/forge-std

lib/solmate

src/test/xTRIBE.t.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ contract xTRIBETest is DSTestPlus {
142142
for (uint256 i = 0; i < 20; i++) {
143143
hevm.assume(
144144
gauges[i] != address(0) && // no zero gauge
145-
!xTribe.isGaugeLive(gauges[i]) && // no same gauge twice
145+
!xTribe.isGauge(gauges[i]) && // no same gauge twice
146146
gaugeTotalSupply[i] != 0 // no zero supply
147147
);
148148
userGaugeBalance[i] = uint104(
@@ -173,7 +173,7 @@ contract xTRIBETest is DSTestPlus {
173173
hevm.prank(user);
174174
xTribe.incrementGauges(gaugeList, amounts);
175175
}
176-
hevm.warp(xTribe.getCurrentCycle());
176+
hevm.warp(xTribe.getGaugeCycleEnd());
177177

178178
// set the rewards and queue for the rewards cycle
179179
rewardToken.mint(address(stream), quantity);
@@ -228,7 +228,7 @@ contract xTRIBETest is DSTestPlus {
228228
uint256 gaugeWeightBefore = xTribe.getGaugeWeight(gauge);
229229
uint256 totalWeightBefore = xTribe.totalWeight();
230230

231-
uint32 cycleEnd = xTribe.getCurrentCycle();
231+
uint32 cycleEnd = xTribe.getGaugeCycleEnd();
232232

233233
hevm.startPrank(user);
234234
// Test the two major cases of successfull increment and failed increment

src/xTRIBE.sol

+18-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ contract xTRIBE is ERC20MultiVotes, ERC20Gauges, xERC4626, Multicall {
6363
}
6464

6565
/**
66-
@notice calculate past voting power at a given block of xTRIBE AND underlying TRIBE voting power for user, converted to xTRIBE shares.
66+
@notice calculate past voting power at a given block of xTRIBE AND underlying TRIBE voting power for user, converted to xTRIBE shares.
6767
@param account the user to calculate voting power of.
6868
@param blockNumber the block in the past to get voting power from.
6969
@return the voting power of `account` at block `blockNumber`.
@@ -81,6 +81,23 @@ contract xTRIBE is ERC20MultiVotes, ERC20Gauges, xERC4626, Multicall {
8181
convertToShares(tribe().getPriorVotes(account, blockNumber));
8282
}
8383

84+
/**
85+
@notice an event for manually emitting voting balances.
86+
87+
This is important because this contract cannot be synchronously notified of Tribe delegations.
88+
*/
89+
function emitVotingBalances(address[] calldata accounts) external {
90+
uint256 size = accounts.length;
91+
92+
for (uint256 i = 0; i < size; ) {
93+
emit DelegateVotesChanged(accounts[i], 0, getVotes(accounts[i]));
94+
95+
unchecked {
96+
i++;
97+
}
98+
}
99+
}
100+
84101
/*///////////////////////////////////////////////////////////////
85102
ERC20 LOGIC
86103
//////////////////////////////////////////////////////////////*/

0 commit comments

Comments
 (0)