Phylax Standard Library is a collection of helpful contracts and libraries for use with Phylax. It provides a set of interfaces and contracts to interact with Phylax and Foundry.
forge install phylax-systems/phylax-std
yarn add @phylax-systems/phylax-std
and add the following remappings to your project by creating the remappings.txt
.
forge-std/=node_modules/forge-std/src/
ds-test/=node_modules/ds-test/src/
Forking uses Foundry in the background, so you can follow the same best practices:
- Set the RPC url inside the contract
- Set the RPC url in an env variable and then use the relevant Foundry cheatcodes to get it
- Set the RPC url inside
foundry.toml
and use an alias in the contracts
Read more in the Foundry Fork Testing Docs.
This is the main interface for interacting with Phylax. It enables the Phylax-only Foundry cheatcodes, such as ph.export(string,string)
.
This is the base contract for all Phylax alert contracts. It provides a constant reference to Phylax and RE-IMPORTS forge-std/Script.sol
.
Read the docs at https://phylax-std.phylax.watch
import { Action } from "phylax-std/Action.sol";
contract PauseProtocol is Action {
function run() public {
// pause protocol
uint256 collateral_left = protocol.collateral_left();
ph.export("collateral_left", collateral_left);
}
}
This is the base contract for all Phylax alert contracts. It provides a constant reference to Phylax and RE-IMPORTS forge-std/Test.sol
.
Read the docs at https://phylax-std.phylax.watch
import { Alert } from "phylax-std/Alert.sol";
contract CollateralAlert is Alert {
uint256 polygon;
uint256 ethereum;
uint256 BASELINE_BLOCK = 5000;
function setUp() public {
polygon = enableChain(<RPC_URL>);
ethereum = enableChain(<RPC_URL>, BASELINE_BLOCK);
}
function testCollateralPolygon() chain(polygon) public {
// ...
}
function testCollateralPolygonBaseline() chain(ethereum) public {
// ...
}
}
Phylax Standard Library is offered under either MIT or Apache 2.0.