Skip to content

Commit

Permalink
decoupled the escrow and the nft logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaniza committed Sep 17, 2024
1 parent 8fac2e9 commit 3dd41ea
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/escrow/increasing/ExitQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.17;
import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {IExitQueue} from "./interfaces/IExitQueue.sol";
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IVotingEscrowIncreasing as IVotingEscrow} from "@escrow-interfaces/IVotingEscrowIncreasing.sol";
import {IVotingEscrow} from "@escrow-interfaces/IVotingEscrow.sol";
import {IClockUser, IClock} from "@clock/IClock.sol";

import {SafeERC20Upgradeable as SafeERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
Expand Down
6 changes: 2 additions & 4 deletions src/escrow/increasing/Lock.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {IWhitelist} from "@escrow-interfaces/ILock.sol";
import {ILock} from "@escrow-interfaces/ILock.sol";
import {ERC721EnumerableUpgradeable as ERC721Enumerable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {DaoAuthorizableUpgradeable as DaoAuthorizable} from "@aragon/osx/core/plugin/dao-authorizable/DaoAuthorizableUpgradeable.sol";
import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";

/// @title NFT representation of an escrow locking mechanism
contract Lock is IWhitelist, ERC721Enumerable, UUPSUpgradeable, DaoAuthorizable {
contract Lock is ILock, ERC721Enumerable, UUPSUpgradeable, DaoAuthorizable {
/// @dev enables transfers without whitelisting
address public constant WHITELIST_ANY_ADDRESS =
address(uint160(uint256(keccak256("WHITELIST_ANY_ADDRESS"))));
Expand All @@ -22,8 +22,6 @@ contract Lock is IWhitelist, ERC721Enumerable, UUPSUpgradeable, DaoAuthorizable
/// @notice Whitelisted contracts that are allowed to transfer
mapping(address => bool) public whitelisted;

error OnlyEscrow();

/*//////////////////////////////////////////////////////////////
Modifiers
//////////////////////////////////////////////////////////////*/
Expand Down
2 changes: 1 addition & 1 deletion src/escrow/increasing/QuadraticIncreasingEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.17;
// interfaces
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {IVotingEscrowIncreasing as IVotingEscrow} from "@escrow-interfaces/IVotingEscrowIncreasing.sol";
import {IVotingEscrow} from "@escrow-interfaces/IVotingEscrow.sol";
import {IEscrowCurveIncreasing as IEscrowCurve} from "@escrow-interfaces/IEscrowCurveIncreasing.sol";
import {IClockUser, IClock} from "@clock/IClock.sol";

Expand Down
4 changes: 2 additions & 2 deletions src/escrow/increasing/VotingEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {ISimpleGaugeVoter} from "@voting/ISimpleGaugeVoter.sol";
import {IClock} from "@clock/IClock.sol";
import {IEscrowCurveIncreasing as IEscrowCurve} from "./interfaces/IEscrowCurveIncreasing.sol";
import {IExitQueue} from "./interfaces/IExitQueue.sol";
import {IVotingEscrowIncreasing as IVotingEscrow, ILockedBalanceIncreasing, IVotingEscrowCore, IDynamicVoter, IVotingEscrowEventsStorageErrorsEvents} from "./interfaces/IVotingEscrowIncreasing.sol";
import {IVotingEscrow} from "./interfaces/IVotingEscrow.sol";

// libraries
import {SafeERC20Upgradeable as SafeERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
Expand All @@ -25,7 +25,7 @@ import {PausableUpgradeable as Pausable} from "@openzeppelin/contracts-upgradeab
import {DaoAuthorizableUpgradeable as DaoAuthorizable} from "@aragon/osx/core/plugin/dao-authorizable/DaoAuthorizableUpgradeable.sol";

contract VotingEscrow is
IVotingEscrowEventsStorageErrorsEvents,
IVotingEscrow,
ReentrancyGuard,
Pausable,
DaoAuthorizable,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ILockedBalanceIncreasing} from "./IVotingEscrowIncreasing.sol";
import {ILockedBalanceIncreasing} from "./IVotingEscrow.sol";

/*///////////////////////////////////////////////////////////////
Global Curve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ interface IVotingEscrowCore is
/// @notice Address of the underying ERC20 token.
function token() external view returns (address);

/// @notice Address of the lock receipt NFT.
function lockNFT() external view returns (address);

/// @notice Total underlying tokens deposited in the contract
function totalLocked() external view returns (uint256);

Expand All @@ -78,25 +81,6 @@ interface IVotingEscrowCore is
function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool);
}

/*///////////////////////////////////////////////////////////////
WHITELIST ESCROW
//////////////////////////////////////////////////////////////*/
interface IWhitelistEvents {
event WhitelistSet(address indexed account, bool status);
}

interface IWhitelistErrors {
error NotWhitelisted();
}

interface IWhitelist is IWhitelistEvents, IWhitelistErrors {
/// @notice Set whitelist status for an address
function setWhitelisted(address addr, bool isWhitelisted) external;

/// @notice Check if an address is whitelisted
function whitelisted(address addr) external view returns (bool);
}

/*///////////////////////////////////////////////////////////////
WITHDRAWAL QUEUE
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -191,25 +175,17 @@ interface IDynamicVoter is IDynamicVoterErrors {
INCREASED ESCROW
//////////////////////////////////////////////////////////////*/

interface IVotingEscrowIncreasing is
IVotingEscrowCore,
IDynamicVoter,
IWithdrawalQueue,
IWhitelist,
ISweeper
{
interface IVotingEscrow is IVotingEscrowCore, IDynamicVoter, IWithdrawalQueue, ISweeper {

}

/// @dev useful for testing
interface IVotingEscrowEventsStorageErrorsEvents is
IVotingEscrowCoreErrors,
IVotingEscrowCoreEvents,
IWhitelistEvents,
IWithdrawalQueueErrors,
IWithdrawalQueueEvents,
ILockedBalanceIncreasing,
IWhitelistErrors,
ISweeperEvents,
ISweeperErrors
{
Expand Down
2 changes: 1 addition & 1 deletion src/voting/SimpleGaugeVoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.17;

import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {IVotingEscrowIncreasing as IVotingEscrow} from "@escrow-interfaces/IVotingEscrowIncreasing.sol";
import {IVotingEscrow} from "@escrow-interfaces/IVotingEscrow.sol";
import {IClockUser, IClock} from "@clock/IClock.sol";
import {ISimpleGaugeVoter} from "./ISimpleGaugeVoter.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/e2e.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "./helpers/OSxHelpers.sol";

import {Clock} from "@clock/Clock.sol";
import {IEscrowCurveUserStorage} from "@escrow-interfaces/IEscrowCurveIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrowIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrow.sol";
import {IGaugeVote} from "src/voting/ISimpleGaugeVoter.sol";
import {VotingEscrow, Lock, QuadraticIncreasingEscrow, ExitQueue, SimpleGaugeVoter, SimpleGaugeVoterSetup, ISimpleGaugeVoterSetupParams} from "src/voting/SimpleGaugeVoterSetup.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/escrow/curve/QuadraticCurveBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {DAO, createTestDAO} from "@mocks/MockDAO.sol";
import {QuadraticIncreasingEscrow, IVotingEscrow, IEscrowCurve} from "src/escrow/increasing/QuadraticIncreasingEscrow.sol";
import {Clock} from "@clock/Clock.sol";
import {IVotingEscrowIncreasing, ILockedBalanceIncreasing} from "src/escrow/increasing/interfaces/IVotingEscrowIncreasing.sol";
import {IVotingEscrow, ILockedBalanceIncreasing} from "src/escrow/increasing/interfaces/IVotingEscrow.sol";
import {ProxyLib} from "@libs/ProxyLib.sol";

contract MockEscrow {
Expand Down
36 changes: 1 addition & 35 deletions test/escrow/curve/QuadraticCurveLogic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@ pragma solidity ^0.8.17;
import {console2 as console} from "forge-std/console2.sol";

import {QuadraticIncreasingEscrow, IVotingEscrow, IEscrowCurve} from "src/escrow/increasing/QuadraticIncreasingEscrow.sol";
import {IVotingEscrowIncreasing, ILockedBalanceIncreasing} from "src/escrow/increasing/interfaces/IVotingEscrowIncreasing.sol";
import {IVotingEscrow, ILockedBalanceIncreasing} from "src/escrow/increasing/interfaces/IVotingEscrow.sol";
import {QuadraticCurveBase, MockEscrow} from "./QuadraticCurveBase.t.sol";

contract TestQuadraticIncreasingCurve is QuadraticCurveBase {
address attacker = address(0x1);

// check that our constants are initialized correctly
// check the escrow is set
function testEscrowInitializesCorrectly() public {
// MockEscrow escrow = new MockEscrow();
// QuadraticIncreasingEscrow curve_ = new QuadraticIncreasingEscrow();
// curve_.initialize(address(escrow), address(dao));
// assertEq(address(curve_.escrow()), address(escrow));
}

function testUUPSUpgrade() public {
address newImpl = address(new QuadraticIncreasingEscrow());
curve.upgradeTo(newImpl);
Expand All @@ -28,29 +19,4 @@ contract TestQuadraticIncreasingCurve is QuadraticCurveBase {
vm.expectRevert(err);
curve.upgradeTo(newImpl);
}

// validate multiple checkpoint situation
// validate the bias bounding works
// warmup: TODO - how do we ensure the warmup doesn't add to an epoch that snaps
// in the future
// warmup: variable warmup perid (create a setter)
// warmup: empty warmup period returns fase
// supplyAt reverts
// same block checkpointing overwrite user point history
// updating checkpoint with a lower balance
// updating checkpoint with a higher balance
// updating with the same balance
// only the escrow can call checkpoint
// point index with large number of points
// - if userepoch 0 return 0
// - if latest user epoch before ts, return the latest user epoch
// - implicit zero balance
// understand at what boundary the curve starts to break down by doing a very small and very large
// deposit
// test the bound bias caps at the boundary
// test that the cooldown correcty calculates
// test a checkpoint correctly saves the user point
// test that the cooldown is respected for the NFT balance
// test the fetched NFT balance from a point in timeFirst
// TODO: check aero tests for other ideas
}
2 changes: 1 addition & 1 deletion test/escrow/curve/QuadraticCurveMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.17;
import {console2 as console} from "forge-std/console2.sol";

import {QuadraticIncreasingEscrow, IVotingEscrow, IEscrowCurve} from "src/escrow/increasing/QuadraticIncreasingEscrow.sol";
import {IVotingEscrowIncreasing, ILockedBalanceIncreasing} from "src/escrow/increasing/interfaces/IVotingEscrowIncreasing.sol";
import {IVotingEscrow, ILockedBalanceIncreasing} from "src/escrow/increasing/interfaces/IVotingEscrow.sol";
import {QuadraticCurveBase} from "./QuadraticCurveBase.t.sol";

contract TestQuadraticIncreasingCurve is QuadraticCurveBase {
Expand Down
10 changes: 8 additions & 2 deletions test/escrow/escrow/EscrowBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ import {createTestDAO} from "@mocks/MockDAO.sol";
import "@helpers/OSxHelpers.sol";
import {ProxyLib} from "@libs/ProxyLib.sol";

import {IVotingEscrowEventsStorageErrorsEvents} from "@escrow-interfaces/IVotingEscrowIncreasing.sol";
import {IVotingEscrowEventsStorageErrorsEvents} from "@escrow-interfaces/IVotingEscrow.sol";
import {IWhitelistErrors, IWhitelistEvents} from "@escrow-interfaces/ILock.sol";
import {Lock} from "@escrow/Lock.sol";
import {VotingEscrow} from "@escrow/VotingEscrow.sol";
import {QuadraticIncreasingEscrow} from "@escrow/QuadraticIncreasingEscrow.sol";
import {ExitQueue} from "@escrow/ExitQueue.sol";
import {SimpleGaugeVoter, SimpleGaugeVoterSetup} from "src/voting/SimpleGaugeVoterSetup.sol";
import {Clock} from "@clock/Clock.sol";

contract EscrowBase is Test, IVotingEscrowEventsStorageErrorsEvents {
contract EscrowBase is
Test,
IVotingEscrowEventsStorageErrorsEvents,
IWhitelistErrors,
IWhitelistEvents
{
using ProxyLib for address;
string name = "Voting Escrow";
string symbol = "VE";
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/escrow/queue/ExitQueueBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {DAO, createTestDAO} from "@mocks/MockDAO.sol";
import {DaoUnauthorized} from "@aragon/osx/core/utils/auth.sol";
import {IExitQueue, ExitQueue} from "@escrow/ExitQueue.sol";
import {IExitQueueErrorsAndEvents} from "@escrow-interfaces/IExitQueue.sol";
import {IVotingEscrowEventsStorageErrorsEvents} from "@escrow-interfaces/IVotingEscrowIncreasing.sol";
import {IVotingEscrowEventsStorageErrorsEvents} from "@escrow-interfaces/IVotingEscrow.sol";
import {MockERC20} from "@mocks/MockERC20.sol";

contract MockEscrow {
Expand Down
2 changes: 1 addition & 1 deletion test/voting/GaugeManage.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {MockERC20} from "@mocks/MockERC20.sol";
import "@helpers/OSxHelpers.sol";

import {IEscrowCurveUserStorage} from "@escrow-interfaces/IEscrowCurveIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrowIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrow.sol";
import {IGaugeVote} from "src/voting/ISimpleGaugeVoter.sol";
import {VotingEscrow, QuadraticIncreasingEscrow, ExitQueue, SimpleGaugeVoter, SimpleGaugeVoterSetup, ISimpleGaugeVoterSetupParams} from "src/voting/SimpleGaugeVoterSetup.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/voting/GaugeTime.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {MockERC20} from "@mocks/MockERC20.sol";
import "@helpers/OSxHelpers.sol";

import {IEscrowCurveUserStorage} from "@escrow-interfaces/IEscrowCurveIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrowIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrow.sol";
import {IGaugeVote} from "src/voting/ISimpleGaugeVoter.sol";
import {VotingEscrow, QuadraticIncreasingEscrow, ExitQueue, SimpleGaugeVoter, SimpleGaugeVoterSetup, ISimpleGaugeVoterSetupParams} from "src/voting/SimpleGaugeVoterSetup.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/voting/GaugeVote.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {MockERC20} from "@mocks/MockERC20.sol";
import "@helpers/OSxHelpers.sol";

import {IEscrowCurveUserStorage} from "@escrow-interfaces/IEscrowCurveIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrowIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrow.sol";
import {IGaugeVote} from "src/voting/ISimpleGaugeVoter.sol";
import {VotingEscrow, QuadraticIncreasingEscrow, ExitQueue, SimpleGaugeVoter, SimpleGaugeVoterSetup, ISimpleGaugeVoterSetupParams} from "src/voting/SimpleGaugeVoterSetup.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/voting/GaugeVotingBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "@helpers/OSxHelpers.sol";
import {Clock} from "@clock/Clock.sol";
import {ISimpleGaugeVoterStorageEventsErrors} from "src/voting/ISimpleGaugeVoter.sol";
import {IEscrowCurveUserStorage} from "@escrow-interfaces/IEscrowCurveIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrowIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrow.sol";
import {IGaugeVote} from "src/voting/ISimpleGaugeVoter.sol";
import {VotingEscrow, Lock, QuadraticIncreasingEscrow, ExitQueue, SimpleGaugeVoter, SimpleGaugeVoterSetup, ISimpleGaugeVoterSetupParams} from "src/voting/SimpleGaugeVoterSetup.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/voting/Setup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {MockERC20} from "@mocks/MockERC20.sol";
import "@helpers/OSxHelpers.sol";

import {IEscrowCurveUserStorage} from "@escrow-interfaces/IEscrowCurveIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrowIncreasing.sol";
import {IWithdrawalQueueErrors} from "src/escrow/increasing/interfaces/IVotingEscrow.sol";
import {IGaugeVote} from "src/voting/ISimpleGaugeVoter.sol";
import {VotingEscrow, QuadraticIncreasingEscrow, ExitQueue, SimpleGaugeVoter, SimpleGaugeVoterSetup, ISimpleGaugeVoterSetupParams} from "src/voting/SimpleGaugeVoterSetup.sol";

Expand Down

0 comments on commit 3dd41ea

Please sign in to comment.