Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Livepeer] fix: arbitrum fork test test_rebase #72

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions test/fork-tests/Livepeer.arbitrum.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ contract LivepeerForkTest is Test, TenderizerEvents, ERC721Receiver {
bytes32 salt = bytes32(uint256(1));
vm.createSelectFork(vm.envString("ARBITRUM_RPC"));
fixture = tenderizerFixture();
adapter = new LivepeerAdapter{salt: salt}();
adapter = new LivepeerAdapter{ salt: salt }();
fixture.registry.registerAdapter(address(LPT), address(adapter));
}

Expand Down Expand Up @@ -267,9 +267,9 @@ contract LivepeerForkTest is Test, TenderizerEvents, ERC721Receiver {
vm.roll(currentRoundStartBlock + roundLength);
ROUNDS.initializeRound();
Tenderizer(tenderizer).rebase();
assertEq(tenderizer.totalSupply(), depositAmount + quotedOut, "total supply");
assertEq(tenderizer.totalSupply(), depositAmount + quotedOut, "total supply fees only");
(uint256 bondedAmount,,,,,,) = BONDING.getDelegator(address(tenderizer));
assertEq(bondedAmount, depositAmount + quotedOut, "Bonded amount");
assertEq(bondedAmount, depositAmount + quotedOut, "Bonded amount fees only");

// Initialize next round
// Check LPT rewards only rebase
Expand All @@ -287,7 +287,7 @@ contract LivepeerForkTest is Test, TenderizerEvents, ERC721Receiver {
uint256 round = ROUNDS.currentRound();
(,,, uint256 crfAfter,) = BONDING.getTranscoderEarningsPoolForRound(ORCHESTRATOR_1, round);
uint256 expStake = bondedAmount * crfAfter / crfBefore;
assertEq(tenderizer.totalSupply(), expStake, "total supply");
assertEq(tenderizer.totalSupply(), expStake, "total supply rewards only");

// Initialize next round
currentRoundStartBlock = ROUNDS.currentRoundStartBlock();
Expand All @@ -306,9 +306,12 @@ contract LivepeerForkTest is Test, TenderizerEvents, ERC721Receiver {
BONDING.reward();
round = ROUNDS.currentRound();
(,,, crfAfter,) = BONDING.getTranscoderEarningsPoolForRound(ORCHESTRATOR_1, round);
expStake = expStake * crfAfter / crfBefore + quotedOut;
expStake = expStake * (crfAfter * 1e27 / crfBefore) / 1e27 + quotedOut - 1;
Tenderizer(tenderizer).rebase();
assertEq(tenderizer.totalSupply(), expStake, "total supply");
assertEq(
tenderizer.totalSupply(), BONDING.pendingStake(address(tenderizer), type(uint256).max), "total supply vs pending stake"
);
assertEq(tenderizer.totalSupply(), expStake, "total supply rewards & fees");
}

function updateTenderizerFees(address tenderizer, uint256 amount) internal {
Expand All @@ -321,9 +324,7 @@ contract LivepeerForkTest is Test, TenderizerEvents, ERC721Receiver {
uint256 orchStake = BONDING.transcoderTotalStake(orchestrator);
uint256 tenderizerStake = BONDING.pendingStake(tenderizer, round);

// amount = fees * feeShare / 1e6 * tenderizerStake / orchStake
// fees = amount * orchStake *1e6 / feeShare / tenderizerStake
uint256 fees = amount * orchStake * 1e6 / feeShare / tenderizerStake;
uint256 fees = amount * (orchStake * 1e6 / feeShare) / tenderizerStake;
vm.prank(TICKET_BROKER);
BONDING.updateTranscoderWithFees(orchestrator, fees, round);
vm.prank(MINTER);
Expand Down
Loading