This repository contains suite of utility solidity smart contracts that facilitate setting up scripts and tests. It's meant for reusability of a lot of utility functions.
This file is the base class. It has the following lookups:
mapping(string => uint256) forkLookup;
mapping(string => bool) gasEthLookup;
mapping(string => address) wethLookup;
mapping(string => address) wrappedLookup;
mapping(string => uint256) chainIdLookup;
Classes like ChainsInfo
subclass this and populate all those
lookup tables. This way you don't have to figure out
what weth
's address is in your scripts. They're provided
for you.
It also has utility functions such as:
For getting a user's weth balance
For getting wrapped balance for noneth chains
For getting weth address in a chain
For getting wrapped asset address in noneth chains
If the script is running in a mainnet environment
Similar to above
If it's a forge unit-test
If it's running in a forked environment
For setting the runtime
For tests, it's vm.startPrank
, and for scripts
it's vm.startBroadcast
, for more info refer to
foundry 's documentation.
For populating the lookups shown above. They get used in the ChainsInfo contract.
Switches to a different chain. Conveniently this uses
a string as input which is the chain alias, defined in foundry.toml
file.
Here's
forge's
documentation on how aliases are defined, and you can see
our aliases defined in
utb
and
decent bridge
under the [rpc_endpoints]
section.
Deals money to the account. In the case of a test it uses vm.deal
and in case of scripts, just simply sends money to that address.
Utility functions for receiving native and wrapped balances. And asserting their values.
Some constants instead of using magic strings.
Contains a utility function for populating all the lookup tables in the
BaseChainSetup.sol
.
Much like BaseChainSetup.sol
but for LayerZero's chains. It has lookups for
their endpoints, their light nodes, their chain id's, etc.
Much like ChainsInfo.sol
, but for LayerZero's stuff. It also has utility functions for
delivering LayerZero's messages at the destination chain. An example of this can be seen
in the
Decent Bridge's test-utilities.
Contains all the constants and lookups for Stargate's contracts.
Contains all the constants and lookups for Uniswap's Router & Quoter contracts. It also has utility functions:
Returns the address of the router for chain
.
Creates a uniswap route path encoding for an ExactAmountIn
route.
Refer to
here
for more explanation about uniswap paths.
Same as above but for ExactAmountOut
.
Loads up the lookups and addresses.
Loads up usdc contract addresses in lookups so you can use them in tests and scripts. It also has utility functions for minting usdc to a user.
The trick
here is to impersonateAs
a whale, then have that whale submit some USDC to
the user's address.
Much like UsdcHelper.sol
but for WETH
.