Skip to content

Commit 39b3e94

Browse files
committed
Add snapshot of capital ratio on assignFunds first assignment
1 parent 3975a26 commit 39b3e94

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

contracts/contract/megapool/RocketMegapoolDelegate.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ contract RocketMegapoolDelegate is RocketMegapoolDelegateBase, RocketMegapoolDel
320320
nodeBond += assignedNodeBond;
321321
userQueuedCapital -= assignedUserCapital;
322322
nodeQueuedBond -= assignedNodeBond;
323+
// Snapshot capital ratio if first assignment
324+
if (lastDistributionTime == 0) {
325+
_snapshotCapitalRatio();
326+
}
323327
// Delete prestake signature for a small gas refund (no longer needed)
324328
delete prestakeSignatures[_validatorId];
325329
// Emit event
@@ -335,7 +339,7 @@ contract RocketMegapoolDelegate is RocketMegapoolDelegateBase, RocketMegapoolDel
335339
require(validator.inPrestake, "Validator must be pre-staked");
336340
// Store last requested value for later
337341
uint32 lastRequestedValue = validator.lastRequestedValue;
338-
// Snapshot capital ratio (sets lastDistributionTime on first validator)
342+
// Snapshot capital ratio
339343
_snapshotCapitalRatio();
340344
// Account for assigned value
341345
uint256 assignedUsed = lastRequestedValue * milliToWei - prestakeValue;

test/megapool/megapool-tests.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,15 +1276,6 @@ export default function() {
12761276
await setDAOProtocolBootstrapSetting(RocketDAOProtocolSettingsMegapool, 'megapool.time.before.dissolve', dissolvePeriod, { from: owner });
12771277
});
12781278

1279-
it(printTitle('node', 'receives any ETH that was already in the megapool prior to first validator stake'), async () => {
1280-
const preStakeRewards = '0.123'.ether;
1281-
await nodeDeposit(node);
1282-
await mockRewards(megapool, preStakeRewards);
1283-
await stakeMegapoolValidator(megapool, 0);
1284-
assertBN.equal(await megapool.getRefundValue(), preStakeRewards);
1285-
assertBN.equal(await megapool.getPendingRewards(), 0n);
1286-
});
1287-
12881279
it(printTitle('node', 'can deposit while assignments are disabled and be assigned once enabled again'), async () => {
12891280
const rocketDepositPool = await RocketDepositPool.deployed();
12901281
// Disable deposit assignments
@@ -1830,8 +1821,8 @@ export default function() {
18301821
// Exit remaining 2 validators
18311822
await exitValidator(megapool, 1, '32'.ether);
18321823
await exitValidator(megapool, 2, '32'.ether);
1833-
// Capital ratio should be 0
1834-
assertBN.equal(await rocketNetworkRevenues.getNodeAverageCapitalRatioSince(node.address, await megapool.getLastDistributionTime()), 0n);
1824+
// Capital ratio should remain 12.5%
1825+
assertBN.equal(await rocketNetworkRevenues.getNodeAverageCapitalRatioSince(node.address, await megapool.getLastDistributionTime()), '0.125'.ether);
18351826
// Create a new validator
18361827
await nodeDeposit(node);
18371828
await stakeMegapoolValidator(megapool, 3);

0 commit comments

Comments
 (0)