Skip to content

Commit

Permalink
delete migration script, revert commits not needed, remove migration …
Browse files Browse the repository at this point in the history
…helper fork files
  • Loading branch information
jordaniza committed Jan 21, 2025
1 parent caeb533 commit 00799b1
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 1,627 deletions.
163 changes: 0 additions & 163 deletions script/Migrate.s.sol

This file was deleted.

4 changes: 2 additions & 2 deletions src/voting/SimpleGaugeVoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ contract SimpleGaugeVoter is
}

/*///////////////////////////////////////////////////////////////
Voting
Voting
//////////////////////////////////////////////////////////////*/

/// @notice extrememly simple for loop. We don't need reentrancy checks in this implementation
Expand Down Expand Up @@ -181,7 +181,7 @@ contract SimpleGaugeVoter is
voteData.lastVoted = block.timestamp;
}

function reset(uint256 _tokenId) external nonReentrant whenNotPaused {
function reset(uint256 _tokenId) external nonReentrant whenNotPaused whenVotingActive {
if (!IVotingEscrow(escrow).isApprovedOrOwner(msg.sender, _tokenId))
revert NotApprovedOrOwner();
if (!isVoting(_tokenId)) revert NotCurrentlyVoting();
Expand Down
204 changes: 102 additions & 102 deletions test/escrow/curve/QuadraticCurveMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,106 +58,106 @@ contract TestQuadraticIncreasingCurve is QuadraticCurveBase {
}

// write a new checkpoint
// function testWritesCheckpoint() public {
// uint tokenIdFirst = 1;
// uint tokenIdSecond = 2;
// uint208 depositFirst = 420.69e18;
// uint208 depositSecond = 1_000_000_000e18;
// uint start = 52 weeks;
//
// // initial conditions, no balance
// assertEq(curve.votingPowerAt(tokenIdFirst, 0), 0, "Balance before deposit");
//
// vm.warp(start);
// vm.roll(420);
//
// // still no balance
// assertEq(curve.votingPowerAt(tokenIdFirst, 0), 0, "Balance before deposit");
//
// escrow.checkpoint(
// tokenIdFirst,
// LockedBalance(0, 0),
// LockedBalance(depositFirst, uint48(block.timestamp))
// );
// escrow.checkpoint(
// tokenIdSecond,
// LockedBalance(0, 0),
// LockedBalance(depositSecond, uint48(block.timestamp))
// );
//
// // check the token point is registered
// IEscrowCurve.TokenPoint memory tokenPoint = curve.tokenPointHistory(tokenIdFirst, 1);
// assertEq(tokenPoint.bias, depositFirst, "Bias is incorrect");
// assertEq(tokenPoint.checkpointTs, block.timestamp, "CP Timestamp is incorrect");
// assertEq(tokenPoint.writtenTs, block.timestamp, "Written Timestamp is incorrect");
//
// // balance now is zero but Warm up
// assertEq(curve.votingPowerAt(tokenIdFirst, 0), 0, "Balance after deposit before warmup");
// assertEq(curve.isWarm(tokenIdFirst), false, "Not warming up");
//
// // wait for warmup
// vm.warp(block.timestamp + curve.warmupPeriod());
// assertEq(curve.votingPowerAt(tokenIdFirst, 0), 0, "Balance after deposit before warmup");
// assertEq(curve.isWarm(tokenIdFirst), false, "Not warming up");
// assertEq(curve.isWarm(tokenIdSecond), false, "Not warming up II");
//
// // warmup complete
// vm.warp(block.timestamp + 1);
//
// // python: 449.206279554928541696
// // solmate (optimized): 449.206254284606635135
// assertEq(
// curve.votingPowerAt(tokenIdFirst, block.timestamp),
// 449206254284606635135,
// "Balance incorrect after warmup"
// );
// assertEq(curve.isWarm(tokenIdFirst), true, "Still warming up");
//
// // python: 1067784543380942056100724736
// // solmate: 1067784483312193385000000000
// assertEq(
// curve.votingPowerAt(tokenIdSecond, block.timestamp),
// 1067784483312193385000000000,
// "Balance incorrect after warmup II"
// );
//
// // warp to the start of period 2
// vm.warp(start + clock.epochDuration());
// // excel: 600.985714300000000000
// // PRB: 600.985163959347100568
// // solmate: 600.985163959347101852
// // python : 600.985714285714341888
// // solmate2: 600.985163959347101952
// assertEq(
// curve.votingPowerAt(tokenIdFirst, block.timestamp),
// 600985163959347101952,
// "Balance incorrect after p1"
// );
//
// uint256 expectedMaxI = 2524126241845405205760;
// uint256 expectedMaxII = 5999967296216704000000000000;
//
// // warp to the final period
// // TECHNICALLY, this should finish at exactly 5 periodd and 6 * voting power
// // but FP arithmetic has a small rounding error
// vm.warp(start + clock.epochDuration() * 5);
// assertEq(
// curve.votingPowerAt(tokenIdFirst, block.timestamp),
// expectedMaxI,
// "Balance incorrect after p6"
// );
// assertEq(
// curve.votingPowerAt(tokenIdSecond, block.timestamp),
// expectedMaxII,
// "Balance incorrect after p6 II "
// );
//
// // warp to the future and balance should be the same
// vm.warp(520 weeks);
// assertEq(
// curve.votingPowerAt(tokenIdFirst, block.timestamp),
// expectedMaxI,
// "Balance incorrect after 10 years"
// );
// }
function testWritesCheckpoint() public {
uint tokenIdFirst = 1;
uint tokenIdSecond = 2;
uint208 depositFirst = 420.69e18;
uint208 depositSecond = 1_000_000_000e18;
uint start = 52 weeks;

// initial conditions, no balance
assertEq(curve.votingPowerAt(tokenIdFirst, 0), 0, "Balance before deposit");

vm.warp(start);
vm.roll(420);

// still no balance
assertEq(curve.votingPowerAt(tokenIdFirst, 0), 0, "Balance before deposit");

escrow.checkpoint(
tokenIdFirst,
LockedBalance(0, 0),
LockedBalance(depositFirst, uint48(block.timestamp))
);
escrow.checkpoint(
tokenIdSecond,
LockedBalance(0, 0),
LockedBalance(depositSecond, uint48(block.timestamp))
);

// check the token point is registered
IEscrowCurve.TokenPoint memory tokenPoint = curve.tokenPointHistory(tokenIdFirst, 1);
assertEq(tokenPoint.bias, depositFirst, "Bias is incorrect");
assertEq(tokenPoint.checkpointTs, block.timestamp, "CP Timestamp is incorrect");
assertEq(tokenPoint.writtenTs, block.timestamp, "Written Timestamp is incorrect");

// balance now is zero but Warm up
assertEq(curve.votingPowerAt(tokenIdFirst, 0), 0, "Balance after deposit before warmup");
assertEq(curve.isWarm(tokenIdFirst), false, "Not warming up");

// wait for warmup
vm.warp(block.timestamp + curve.warmupPeriod());
assertEq(curve.votingPowerAt(tokenIdFirst, 0), 0, "Balance after deposit before warmup");
assertEq(curve.isWarm(tokenIdFirst), false, "Not warming up");
assertEq(curve.isWarm(tokenIdSecond), false, "Not warming up II");

// warmup complete
vm.warp(block.timestamp + 1);

// python: 449.206279554928541696
// solmate (optimized): 449.206254284606635135
assertEq(
curve.votingPowerAt(tokenIdFirst, block.timestamp),
449206254284606635135,
"Balance incorrect after warmup"
);
assertEq(curve.isWarm(tokenIdFirst), true, "Still warming up");

// python: 1067784543380942056100724736
// solmate: 1067784483312193385000000000
assertEq(
curve.votingPowerAt(tokenIdSecond, block.timestamp),
1067784483312193385000000000,
"Balance incorrect after warmup II"
);

// warp to the start of period 2
vm.warp(start + clock.epochDuration());
// excel: 600.985714300000000000
// PRB: 600.985163959347100568
// solmate: 600.985163959347101852
// python : 600.985714285714341888
// solmate2: 600.985163959347101952
assertEq(
curve.votingPowerAt(tokenIdFirst, block.timestamp),
600985163959347101952,
"Balance incorrect after p1"
);

uint256 expectedMaxI = 2524126241845405205760;
uint256 expectedMaxII = 5999967296216704000000000000;

// warp to the final period
// TECHNICALLY, this should finish at exactly 5 periodd and 6 * voting power
// but FP arithmetic has a small rounding error
vm.warp(start + clock.epochDuration() * 5);
assertEq(
curve.votingPowerAt(tokenIdFirst, block.timestamp),
expectedMaxI,
"Balance incorrect after p6"
);
assertEq(
curve.votingPowerAt(tokenIdSecond, block.timestamp),
expectedMaxII,
"Balance incorrect after p6 II "
);

// warp to the future and balance should be the same
vm.warp(520 weeks);
assertEq(
curve.votingPowerAt(tokenIdFirst, block.timestamp),
expectedMaxI,
"Balance incorrect after 10 years"
);
}
}
Loading

0 comments on commit 00799b1

Please sign in to comment.