The Sumer Protocol is an Binance Smart Chain smart contract for supplying or borrowing assets. Through the sdrToken contracts, accounts on the blockchain supply capital (HT or HRC-20 tokens) to receive sdrTokens or borrow assets from the protocol (holding other assets as collateral). The protocol will also enable the minting of suUSD, which is the first synthetic stablecoin on Sumer that aims to be pegged to 1 USD. suUSD is minted by the same collateral that is supplied to the protocol. The Sumer sdrToken contracts track these balances and algorithmically set interest rates for borrowers.
Before getting started with this repo, please read:
We detail a few of the core contracts in the Sumer protocol.
- SDRToken, SDRHrc20 and SDRNative
- The Sumer sdrTokens, which are self-contained borrowing and lending contracts. SDRToken contains the core logic and SDRHrc20, SDRBUSD, SDRSXP and SDRNative add public interfaces for Hrc20 tokens and bnb, respectively. Each SDRToken is assigned an interest rate and risk model (see InterestRateModel and Comptroller sections), and allows accounts to *mint* (supply capital), *redeem* (withdraw capital), *borrow* and *repay a borrow*. Each SDRToken is an BEP-20 compliant token where balances represent ownership of the market.
- Comptroller
- The risk model contract, which validates permissible user actions and disallows actions if they do not fit certain risk parameters. For instance, the Comptroller enforces that each borrowing user must maintain a sufficient collateral balance across all sdrTokens.
- Sumer
- The Sumer Governance Token (Sumer). Holders of this token have the ability to govern the protocol via the governor contract.
- SXP
- The Sumer Governance Token (SXP). Holders of this token have the ability to govern the protocol via the governor contract.
- Governor Alpha
- The administrator of the Sumer timelock contract. Holders of Sumer(SXP) token may create and vote on proposals which will be queued into the Sumer timelock and then have effects on Sumer sdrToken and Comptroller contracts. This contract may be replaced in the future with a beta version.
- InterestRateModel
- Contracts which define interest rate models. These models algorithmically determine interest rates based on the current utilization of a given market (that is, how much of the supplied assets are liquid versus borrowed).
- Careful Math
- Library for safe math operations.
- ErrorReporter
- Library for tracking error codes and failure conditions.
- Exponential
- Library for handling fixed-point decimal numbers.
- SafeToken
- Library for safely handling Bep20 interaction.
- WhitePaperInterestRateModel
- Initial interest rate model, as defined in the Whitepaper. This contract accepts a base rate and slope parameter in its constructor.
To run charge, pull the repository from GitHub and install its dependencies. You will need yarn or npm installed.
git clone https://github.com/dfinlab/sumer-protocol
cd charge-protocol
yarn install --lock-file # or `npm install`
The Sumer Protocol has a simple scenario evaluation tool to test and evaluate scenarios which could occur on the blockchain. This is primarily used for constructing high-level integration tests. The tool also has a REPL to interact with local the Sumer Protocol (similar to truffle console
).
yarn repl -n development
yarn repl -n rinkeby
> Read SDRToken sdrBAT Address
Command: Read SDRToken sdrBAT Address
AddressV<val=0xAD53863b864AE703D31b819d29c14cDA93D7c6a6>
You can read more about the scenario runner in the Scenario Docs on steps for using the repl.
Jest contract tests are defined under the tests directory. To run the tests run:
yarn test
There are additional tests under the spec/scenario folder. These are high-level integration tests based on the scenario runner depicted above. The aim of these tests is to be highly literate and have high coverage in the interaction of contracts.
The Sumer Protocol has a number of formal verification specifications, powered by Certik. The Certik Verification evaluates smart contracts for vulnerabilities and certifies their behavior with respect to a custom function specification.
See the Scenario Docs on steps for using the repl.
Contract tests are defined under the tests directory. To run the tests run:
yarn test
To run code coverage, run:
yarn coverage
To lint the code, run:
yarn lint
To deploy a new sdrToken, you can run the token:deploy
. command, as follows. If you set VERIFY=true
, the script will verify the token on BscScan as well. The JSON here is the token config JSON, which should be specific to the token you wish to list.
npx hardhat run scripts/DeployAll.ts
_© Copyright 2024, meterio