The Sense Protocol is a decentralized fixed-income protocol on Ethereum, allowing users to manage risk through fixed rates and future yield trading on existing yield bearing-assets.
Extensive documentation and use cases are available within this README and in the Sense docs here.
One way to interact with Sense is through our official app
Active development occurs in this repository, which means some contracts in it might not be production-ready. Proceed with caution.
* We are aware that the Name and Symbol does not include the Space LP Share. This will be fixed in the next version of Space.
Contract | Address |
---|---|
Divider | 0x09B10E45A912BcD4E80a8A3119f0cfCcad1e1f12 |
Periphery | 0x4bCBA1316C95B812cC014CA18C08971Ce1C10861 |
BalancerVault | 0x1aB16CB0cb0e5520e0C081530C679B2e846e4D37 |
This repo uses Foundry: forge for development and testing
and git submodules for dependency management (we previously used dapp
and nix
, so there are vestiges from those tools around).
To install Foundry Foundry: Forge, use the instructions in the linked repo.
In addition, this repo uses just as our command runner:
brew install just
# or
cargo install just
# Get contract dependencies
git submodule update --init --recursive
yarn install # or npm install
# Run basic tests suite against a local chain. This is all tests ending in .t.sol
# All tests run with underlying, target and stake as ERC20 compliant tokens with 18 decimals
yarn test
# Run mainnet tests (against a mainnet fork). This is all tests ending in .tm.sol
# All tests run with underlying, target and stake as ERC20 compliant tokens with 18 decimals
# (unless they use existing tokens)
yarn test:mainnet
# Run full local test suite (against a local chain) which includes combinations for:
# 1. ERC4626, ERC20 and non-ERC20 for target, underlying and stake
# 2. 6, 8 and 18 decimals for target, underlying and stake
yarn test:fuzz
# Run linter
yarn lint
# Run formatter
yarn fix
- Create a local
.env
file in the root directory of this project - Set
ALCHEMY_KEY
to a valid Alchemy API key - Set
MNEMONIC
to a valid seed phrase for deployments - Set
ETHERSCAN_API_KEY
to a valid Etherscan API key (used for verification)
This repo uses hardhat deploy for replicable deployments. To create a new deployment:
# Navigate to the `deployments` package
cd pkg/deployments
# Deploy the protocol with mocks on a forked network
yarn deploy:hardhat-fork:sim
# Deploy the protocol with production config on a forked network
yarn deploy:hardhat-fork:sim
# Deploy the protocol with mocks on a live network
yarn hardhat deploy --network <network> --tags scenario:simulated
# Deploy the protocol with production config on a live network
yarn hardhat deploy --network <network> --tags scenario:prod
New contracts or contract modifications/upgrades are deployed and configured using a Hardhat tasks. Tasks live in the [tasks](https://github.com/sense-finance/sense-v1/tree/dev/pkg/deployments/tasks)
directory of the deployment
package of the sense-v1 repository.
Aside from deployment, tasks are also responsible for ensuring:
-
other contracts are aware of the new contract,
-
the newly deployed contract is aware of existing contracts, and
-
permissions are set appropriately.
IMPORTANT: After configuring every new contract, these permissions must be set:
// Set the multisig as trusted newContract.setIsTrusted(multisig, true) // Set the deployer as non-trusted newContract.setIsTrusted(deployer, false)
-
contracts are verified on Etherscan
To create a new task:
-
Create the task folder and its related files:
# Navigate to the `deployments/tasks` folder cd pkg/deployments/tasks # Create a new folder with a name following the YYYYMMYY-TASK_NAME pattern mkdir YYYYMMYY-TASK_NAME
Each task folder must contain 2 files:
index.js
: where the hardhat task logic lives (what should the task do)input.js
which contains all the input addresses that the task needs in order to be executed
Optionally (though most likely), the task will need to instantiate some contracts, requiring the ABIs of them. Create a
pkg/deployments/tasks/YYYYMMYY-TASK_NAME/abi
folder to store these ABIs. -
Add the task into
pkg/deployments/tasks/index.js
. -
Run the new task:
# Navigate to the `deployments/tasks` folder cd pkg/deployments/tasks # Execute hardhat task yarn hardhat 20220517-long-wsteth-adapter --network mainnet
It is important that you first test that your task does what's intended by running it on a fork from mainnet and, optionally, on Goerli. Just use
--network hardhat
or--network goerli
when executing the command. -
Add output files into task folder:
After successfully executing the task, Hardhat would have saved the resulting deployments (contract addresses along their abi, bytecode, metadata...) on
pkg/deployments/deployments
. Move that folder insidepkg/deployments/tasks/YYYYMMYY-TASK_NAME
and rename it tooutput
. -
Commit and push code to GitHub.
NOTE: check existing tasks as a guide on how to create and execute a new one.
Sense-v1 has been audited by four, independent smart contract auditors, ranked by recency:
- 2022-02/03 Space AMM - Fixed Point Solutions (Kurt Barry)
- 2022-03 Sense - ABDK
- 2022-01 Sense & Space AMM - Spearbit
- 2021-11/12 Sense - Fixed Point Solutions (Kurt Barry)
- 2021-11 Sense - ABDK
- 2021-11 Sense - Peckshield
Sense has an active bug bounty on ImmuneFi, with up to $50,000 for reporting a bug in deployed contracts & the Sense Portal.
Right now, we are using dev
and main
branches.
main
represents the contracts live onmainnet
and all testnetsdev
is for the newest version of contracts, and is reserved for deployments togoerli
When a new version of the contracts makes its way through the testnet, it eventually becomes promoted in main
, with semver reflecting contract changes in the major
or minor
portion of the version (depending on backwards compatibility).