This is the repository for Spark Lend deploy scripts and custom code. Primarily this repository acts as an orchestration toolkit for deploying and managing Spark Lend instances across many chains. Apart from the custom code below everything is combined from third party vendors.
Run tests: make test
Deploy Spark Lend: ETH_RPC_URL=<YOUR RPC ENDPOINT> make deploy
Deploy Config Engine: ETH_RPC_URL=<YOUR RPC ENDPOINT> make deploy-engine
Deploy Spark Lend (Custom Instance): INSTANCE_ID=<Custom Instance Name> ETH_RPC_URL=<YOUR RPC ENDPOINT> make deploy
Deploy Config Engine (Custom Instance): INSTANCE_ID=<Custom Instance Name> ETH_RPC_URL=<YOUR RPC ENDPOINT> make deploy-engine
Deploy Pool Upgrade: ETH_RPC_URL=<YOUR RPC ENDPOINT> make deploy-pool
(Please note you need to set the proper POOL_REVISION
in Pool.sol
)
Please note there may be some custom configs so please check the Makefile
.
These instructions assume that an admin
L2 Executor governance relay has already been deployed. If you haven't deployed this already then please follow the instructions to deploy in https://github.com/marsfoundation/spark-gov-relay .
As deployer:
- Create directory
script/input/<CHAINID>/
. - Copy
primary.json
fromscript/input/100/
to your newly created directory. - Update relevant fields in the json.
admin
will usually point to the L2 Executor governance relay. - Run
ETH_RPC_URL=<YOUR RPC ENDPOINT> make deploy
to deploy an empty instance of Spark Lend. - This will generate an output file in
script/output/<CHAINID>/primary-<TIMESTAMP>.json
. Rename this toprimary-latest.json
. - Inside
script/output/<CHAINID>/
create the directorybroadcast
. - Copy the broadcast file generated from
broadcast/DeploySpark.s.sol/<CHAINID>/run-latest.json
into the newly created broadcast directory. Rename it toprimary-<DATE>.json
. This broadcast file will be used to validate the deploy by reviewers. - Run
ETH_RPC_URL=<YOUR RPC ENDPOINT> make deploy-engine
to deploy an instance of the config engine. - This will generate an output file in
script/output/<CHAINID>/primary-sce-<TIMESTAMP>.json
. Rename this toprimary-sce-latest.json
. - Copy the broadcast file generated from
broadcast/DeploySparkConfigEngine.s.sol/<CHAINID>/run-latest.json
into the broadcast directory. Rename it toprimary-sce-<DATE>.json
. - Copy the file
test/deploys/100/primary/SparkDeploy_20230714_GnosisPrimary.t.sol
totest/deploys/<CHAINID>/primary/SparkDeploy_<DATE>_<CHAINNAME>Primary.t.sol
. - Update the file as necessary. Tests should pass.
- Notify the reviewers that the deploy is ready for review.
As reviewer:
- Verify the deployer followed all steps above.
- Verify all contract addresses in the json files makes sense. IE
admin
is the L2 Executor.pool
is the pool proxy, etc. - Run
forge test
. This will ensure the deployment configuration was done correctly, and will check most of the permissions (not all - you need to check some manually below). - Verify the bytecode of all deployed contracts for both the Spark Lend and Config Engine Deploys. (see detailed instructions below on how to do this)
- Manually verify no extra permissions have been added on the
ACLManager
. The automated checks will prove thatadmin
has access anddeployer
doesn't, but thedeployer
may have added another address in an intermediate transaction. In the transactions tab for theACLManager
ensure that only the proper adds and removes that correspond to the deployer script are present with either the addressdeployer
(which should be the deployer address) and theadmin
.
- Install local instance of sourcify via https://docs.sourcify.dev/docs/run-locally/#running-the-server
- Default
.env.dev
is mostly fine, but updateNODE_URL_MAINNET
to be a valid rpc endpoint. - Start the server
npm run server:start
.
Run ./validate-deploy.sh path/to/broadcast.json --local
(Be sure to forge build
with proper settings first)
If you want to delete previously verified contracts then run rm -rf /tmp/sourcify/repository/contracts/*
A special interest rate strategy is used for the DAI market which anchors to the Dai Savings Rate (DSR). It is a flat rate up to the debt ceiling. If Maker needs to bring back liquidity by lowering the debt ceiling then the interest rate will spike to ensure user deposits and borrow repayments.
You can read more about this here.
This is the oracle for sDAI which will take the input of a standard DAI price feed and convert it via the pot.chi
factor.
There is a bug bounty program at https://immunefi.com/bounty/sparklend/
The IP in this repository was assigned to Mars SPC Limited in respect of the MarsOne SP