Skip to content

Commit

Permalink
Adds increase and decrease allowance
Browse files Browse the repository at this point in the history
  • Loading branch information
xhad committed Mar 7, 2024
1 parent 8187614 commit a6e351b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Chamber.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ contract Chamber is IChamber, Common {
accountDelegation[_msgSender()][tokenId] -= amount;
if (totalDelegation[tokenId]== 0){
_removeFromLeaderboard(tokenId);
}else{
} else {
_updateLeaderboard(tokenId);
}

SafeERC20.safeDecreaseAllowance(IERC20(govToken), address(this), amount);
SafeERC20.safeTransfer(IERC20(govToken), _msgSender(), amount);
emit Demoted(_msgSender(), amount, tokenId);
}
Expand Down
3 changes: 2 additions & 1 deletion test/performance/ChamberPerf.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ contract ChamberPerfTest is Test {
// Test the performance of the promote function with 10000 calls
function test_Chamber_perf_promote_many(uint256 amount) public {

vm.assume(amount > 0 && amount < 10000000 ether);
vm.assume(amount > 0);

uint256 runs = 50;
for (uint256 i = 1; i <= runs; i++) {
vm.startPrank(bones);
deal(address(LORE), bones, amount);
LORE.approve(address(chamber), amount);
chamber.promote(amount, i);
chamber.demote(amount, i);
}
}

Expand Down

0 comments on commit a6e351b

Please sign in to comment.