For more information about the protocol, please visit our website: solid.world
To deploy the smart contracts, follow these steps:
-
Copy and populate the environment variables by running the command:
cp .env.example .env
-
To deploy to localhost, run the command:
yarn hardhat deploy --network localhost
-
To verify the contracts on Etherscan, run the following commands:
yarn hardhat --network <network> etherscan-verify yarn hardhat verify --network goerli <SolidWorldManager_Implementation address>
(The second command is required due to a bug that prevents contract verification with linked libraries.)
-
To verify the contracts on Sourcify, run the following command:
yarn hardhat --network <network> sourcify
The following tasks are available in Hardhat:
-
Deploy a new reward price oracle:
yarn hardhat --network localhost deploy-reward-oracle [OPTIONS]
Options:
--owner
: The owner of the contract. Defaults toOWNER_ADDRESS
.--factory
: UniswapV3Factory address. If not provided, a mock factory will be deployed.--base-token
: The base token address. If not provided, a mock token will be deployed.--quote-token
: The quote token address. If not provided, a mock token will be deployed.--fee
: Pool fee (default: 500).--seconds-ago
: Seconds ago to calculate the time-weighted means (default: 300).
-
Deploy a new LiquidityDeployer contract:
yarn hardhat --network localhost deploy-liquidity-deployer [OPTIONS]
Options:
--token0
: The address of token0.--token1
: The address of token1.--gamma-vault
: The address of the GammaVault contract.--uni-proxy
: The address of the UniProxy contract.--conversion-rate
: The conversion rate between token0 and token1.--conversion-rate-decimals
: The number of decimals of the conversion rate.
-
Deploy ERC-20 tokens with Hardhat:
yarn hardhat deploy-erc20 --network localhost --quantity 3 --owner 0xabcde
This command deploys 3 ERC-20 tokens on the localhost network, owned by the address 0xabcde.
Flags:
--quantity
: The number of tokens to deploy (Default: 1).--owner
: The owner of the tokens (Default: OWNER_ADDRESS).
-
Deploy a new SolidZapStaker contract:
yarn hardhat --network localhost deploy-zap-staker [OPTIONS]
Options:
--router
: The address of the router used to perform token swaps.--weth
: The address of WETH contract of the network.--solid-staking
: The address of our SolidStaking contract, to stake with recipient.
-
Deploy a new SolidZapDecollateralize contract:
yarn hardhat --network localhost deploy-zap-decollateralize [OPTIONS]
Options:
--router
: The address of the router used to perform token swaps.--weth
: The address of WETH contract of the network.--sw-manager
: The address of the SolidWorldManager contract used for decollateralizing tokens.--forward-contract-batch
: The address of our ForwardContractBatchToken contract, to transfer ERC1155 to receiver.
-
Deploy a new SolidZapCollateralize contract:
yarn hardhat --network localhost deploy-zap-collateralize [OPTIONS]
Options:
--router
: The address of the router used to perform token swaps.--weth
: The address of WETH contract of the network.--sw-manager
: The address of the SolidWorldManager contract used for collateralizing forward credits.--forward-contract-batch
: The address of our ForwardContractBatchToken contract, to transfer over ERC1155 from receiver.
The following contracts are upgradable and managed by a DefaultProxyAdmin
contract. The owner of the DefaultProxyAdmin
contract is authorized to upgrade both contracts.
- SolidWorldManager
- VerificationRegistry
To export contract addresses and ABI files to contract-deployment.json, run the command:
yarn hardhat export --export contract-deployment.json --network localhost
This repository includes unit tests that cover all smart contract features. The tests are built using the Foundry smart contract development toolchain.
To run the unit tests, follow these steps:
-
Install Foundry by referring to the documentation: Foundry Book.
-
Before running the tests, update forge to map forge-std lib:
forge update lib/forge-std
-
Compile all smart contracts:
forge build
-
Execute the unit tests:
npm run test
To see detailed traces, use the following command:
forge test -vvvv
You can also debug a single test by adding the
--debug
flag followed by the test function name:forge test --debug functionToDebug
Unit tests are located in the
./test
and./test_gas
folders.
To check the test coverage, you can use the following commands:
-
Quick coverage check:
yarn test:coverage
-
Detailed coverage report (requires
lcov
package):yarn test:coverage:lcov
If you don't have the
lcov
package installed, you can install it using the command:brew install lcov
Typechain is used to generate TypeScript bindings for Solidity smart contracts. The generated types are located in the ./types
folder.
To generate TypeScript bindings, run the following command:
yarn typechain