generated from refcell/femplate
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewards Invariants: Significant improvements (#897)
* added multiple staked positions * alphabetized functions, made position with indexes accurate, updateExchangeRates now updates buckets that have position in them * reverted alphabetization change so PR is easier to read * cleaned up and removed excess tracking * cleanup log typo * cleaned up how already claimed rewards are tracked * Fix kickWithDeposit handler call in rewards manager regression test * updateExchangeRate now creates positions * removed unused tracker * fixed unit tests * Add rewardsManager handler with ERC721Pool (#899) Co-authored-by: Ian Harvey <[email protected]> * fixed regression_gen * Rewards invariants erc721pool (#908) * Add rewardsManager handler with ERC721Pool * made number of max epochs customizable and removed excess logging --------- Co-authored-by: prateek105 <[email protected]> Co-authored-by: Ian Harvey <[email protected]> * renamed vars made epoch periods longer * added dynamic updating * cleaned up map checking * tests now pass without failing when no position is created via add quote token * refactored positions cleanly * refactored rewards and positions * clean up * cleanup * renamed test files, hardcoded pool hash, added MAX_AJNA_AMOUNT to readme --------- Co-authored-by: Ian Harvey <[email protected]> Co-authored-by: prateek105 <[email protected]> Co-authored-by: Prateek Gupta <[email protected]>
- Loading branch information
1 parent
f61fba5
commit 5e7f5cf
Showing
25 changed files
with
1,237 additions
and
1,265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
tests/forge/invariants/PositionsAndRewards/ERC20PoolRewardsInvariants.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity 0.8.18; | ||
|
||
import "@std/console.sol"; | ||
import { Maths } from 'src/libraries/internal/Maths.sol'; | ||
import { Pool } from 'src/base/Pool.sol'; | ||
import { ERC20Pool } from 'src/ERC20Pool.sol'; | ||
import { ERC721Pool } from 'src/ERC721Pool.sol'; | ||
import { ERC20PoolFactory } from 'src/ERC20PoolFactory.sol'; | ||
import { ERC721PoolFactory } from 'src/ERC721PoolFactory.sol'; | ||
import { PositionManager } from 'src/PositionManager.sol'; | ||
import { RewardsManager } from 'src/RewardsManager.sol'; | ||
|
||
import { TokenWithNDecimals } from '../../utils/Tokens.sol'; | ||
|
||
import { ERC20PoolRewardsHandler } from './handlers/ERC20PoolRewardsHandler.sol'; | ||
import { RewardsInvariants } from './RewardsInvariants.t.sol'; | ||
|
||
contract ERC20PoolRewardsInvariants is RewardsInvariants { | ||
|
||
TokenWithNDecimals internal _collateral; | ||
ERC20Pool internal _erc20pool; | ||
ERC20PoolRewardsHandler internal _erc20poolrewardsHandler; | ||
|
||
function setUp() public override virtual { | ||
|
||
super.setUp(); | ||
|
||
_collateral = new TokenWithNDecimals("Collateral", "C", uint8(vm.envOr("COLLATERAL_PRECISION", uint256(18)))); | ||
_erc20poolFactory = new ERC20PoolFactory(address(_ajna)); | ||
_erc20impl = _erc20poolFactory.implementation(); | ||
_erc721poolFactory = new ERC721PoolFactory(address(_ajna)); | ||
_erc721impl = _erc721poolFactory.implementation(); | ||
_erc20pool = ERC20Pool(_erc20poolFactory.deployPool(address(_collateral), address(_quote), 0.05 * 10**18)); | ||
_pool = Pool(address(_erc20pool)); | ||
_positionManager = new PositionManager(_erc20poolFactory, _erc721poolFactory); | ||
_rewardsManager = new RewardsManager(address(_ajna), _positionManager); | ||
|
||
// fund the rewards manager with 100M ajna | ||
_ajna.mint(address(_rewardsManager), 100_000_000 * 1e18); | ||
|
||
excludeContract(address(_ajna)); | ||
excludeContract(address(_collateral)); | ||
excludeContract(address(_quote)); | ||
excludeContract(address(_erc20poolFactory)); | ||
excludeContract(address(_erc721poolFactory)); | ||
excludeContract(address(_erc20pool)); | ||
excludeContract(address(_poolInfo)); | ||
excludeContract(address(_erc20impl)); | ||
excludeContract(address(_erc721impl)); | ||
excludeContract(address(_positionManager)); | ||
excludeContract(address(_rewardsManager)); | ||
|
||
_erc20poolrewardsHandler = new ERC20PoolRewardsHandler( | ||
address(_rewardsManager), | ||
address(_positionManager), | ||
address(_erc20pool), | ||
address(_ajna), | ||
address(_quote), | ||
address(_collateral), | ||
address(_poolInfo), | ||
NUM_ACTORS, | ||
address(this) | ||
); | ||
|
||
_handler = address(_erc20poolrewardsHandler); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
tests/forge/invariants/PositionsAndRewards/ERC721PoolRewardsInvariants.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity 0.8.18; | ||
|
||
import "@std/console.sol"; | ||
import { Maths } from 'src/libraries/internal/Maths.sol'; | ||
import { Pool } from 'src/base/Pool.sol'; | ||
import { ERC20Pool } from 'src/ERC20Pool.sol'; | ||
import { ERC721Pool } from 'src/ERC721Pool.sol'; | ||
import { ERC20PoolFactory } from 'src/ERC20PoolFactory.sol'; | ||
import { ERC721PoolFactory } from 'src/ERC721PoolFactory.sol'; | ||
import { PositionManager } from 'src/PositionManager.sol'; | ||
import { RewardsManager } from 'src/RewardsManager.sol'; | ||
|
||
import { NFTCollateralToken } from '../../utils/Tokens.sol'; | ||
|
||
import { ERC721PoolRewardsHandler } from './handlers/ERC721PoolRewardsHandler.sol'; | ||
import { RewardsInvariants } from './RewardsInvariants.t.sol'; | ||
|
||
contract ERC721PoolRewardsInvariants is RewardsInvariants { | ||
|
||
NFTCollateralToken internal _collateral; | ||
ERC721Pool internal _erc721pool; | ||
ERC721PoolRewardsHandler internal _erc721poolrewardsHandler; | ||
|
||
function setUp() public override virtual { | ||
|
||
super.setUp(); | ||
|
||
uint256[] memory tokenIds; | ||
_collateral = new NFTCollateralToken(); | ||
_erc20poolFactory = new ERC20PoolFactory(address(_ajna)); | ||
_erc20impl = _erc20poolFactory.implementation(); | ||
_erc721poolFactory = new ERC721PoolFactory(address(_ajna)); | ||
_erc721pool = ERC721Pool(_erc721poolFactory.deployPool(address(_collateral), address(_quote), tokenIds, 0.05 * 10**18)); | ||
_erc721impl = _erc721poolFactory.implementation(); | ||
_pool = Pool(address(_erc721pool)); | ||
_positionManager = new PositionManager(_erc20poolFactory, _erc721poolFactory); | ||
_rewardsManager = new RewardsManager(address(_ajna), _positionManager); | ||
|
||
// fund the rewards manager with 100M ajna | ||
_ajna.mint(address(_rewardsManager), 100_000_000 * 1e18); | ||
|
||
excludeContract(address(_ajna)); | ||
excludeContract(address(_collateral)); | ||
excludeContract(address(_quote)); | ||
excludeContract(address(_erc20poolFactory)); | ||
excludeContract(address(_erc721poolFactory)); | ||
excludeContract(address(_erc721pool)); | ||
excludeContract(address(_poolInfo)); | ||
excludeContract(address(_erc20impl)); | ||
excludeContract(address(_erc721impl)); | ||
excludeContract(address(_positionManager)); | ||
excludeContract(address(_rewardsManager)); | ||
|
||
_erc721poolrewardsHandler = new ERC721PoolRewardsHandler( | ||
address(_rewardsManager), | ||
address(_positionManager), | ||
address(_erc721pool), | ||
address(_ajna), | ||
address(_quote), | ||
address(_collateral), | ||
address(_poolInfo), | ||
NUM_ACTORS, | ||
address(this) | ||
); | ||
|
||
_handler = address(_erc721poolrewardsHandler); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.