-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ubiquityPoolFacet): add invariant test for Ubiquity Dollar minti…
…ng limits with fuzzing
- Loading branch information
1 parent
9e0d5fc
commit 42d739a
Showing
2 changed files
with
203 additions
and
32 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
packages/contracts/test/invariant/diamond/facets/PoolFacetHandler.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,54 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.19; | ||
|
||
import "forge-std/Test.sol"; | ||
import {UbiquityPoolFacet} from "../../../../src/dollar/facets/UbiquityPoolFacet.sol"; | ||
import {MockChainLinkFeed} from "../../../../src/dollar/mocks/MockChainLinkFeed.sol"; | ||
|
||
contract PoolFacetHandler is Test { | ||
MockChainLinkFeed collateralTokenPriceFeed; | ||
UbiquityPoolFacet ubiquityPoolFacet; | ||
|
||
constructor( | ||
MockChainLinkFeed _collateralTokenPriceFeed, | ||
UbiquityPoolFacet _ubiquityPoolFacet | ||
) { | ||
collateralTokenPriceFeed = _collateralTokenPriceFeed; | ||
ubiquityPoolFacet = _ubiquityPoolFacet; | ||
} | ||
|
||
function setCollateralRatio(uint256 newRatio) public { | ||
ubiquityPoolFacet.setCollateralRatio(newRatio); | ||
} | ||
|
||
function updateCollateralPrice(uint256 newPrice) public { | ||
uint256 timestamp = block.timestamp; | ||
|
||
collateralTokenPriceFeed.updateMockParams( | ||
1, | ||
int256(newPrice), | ||
timestamp, | ||
timestamp, | ||
1 | ||
); | ||
|
||
ubiquityPoolFacet.updateChainLinkCollateralPrice(0); | ||
} | ||
|
||
function mintUbiquityDollars( | ||
uint256 dollarAmount, | ||
uint256 dollarOutMin, | ||
uint256 maxCollateralIn, | ||
uint256 maxGovernanceIn, | ||
bool isOneToOne | ||
) public { | ||
ubiquityPoolFacet.mintDollar( | ||
0, | ||
dollarAmount, | ||
dollarOutMin, | ||
maxCollateralIn, | ||
maxGovernanceIn, | ||
isOneToOne | ||
); | ||
} | ||
} |
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