Platform: Code4rena
Start Date: 14/06/2022
End Date: 21/06/2022
Period: 7 days
Status: Completed
Pot Size: $100,000 USDC
Participants: 59
Reporter: liveactionllama
Judge: GalloDaSballo
Id: 133
League: ETH
Auditor per page
Glossary | |
---|---|
Manifest/wrapped-Manifest | Native token of New Blockchain, equivalent to Ethereum on the EVM |
Note(Stablecoin) | ERC-20 based Stablecoin soft-pegged to USD by auto-updating interest rate |
cNote | Lending market for Note based on compounds cToken market |
noteInterestRateModel | Interest rate model used for Stablecoin market with Supply Rate equal to the Borrow Rate and interest rate updated based on the price difference between note and USD |
Accountant | Smart contract which owns all Note in existence and is responsible for lending and redeeming Note from cNote lending market when external users require liquidity |
Treasury | Smart contract which holds funds from the Community pool as well as interest earned from Accountant supplying Note |
UniGov(Unified Governance) | Cosmos SDK module which updates Proposal Map Contract when governance proposals for dApps pass on Cosmos Governance Module |
Dripper/Reservoir | Mechanism to meter rewards for suppliers and borrowers of the Lending Market |
Proposal Map Contract | Storage contract with function to query proposal data by ID |
ZeroSwap | Zero fee Dex without governance forked from Sushiswap/Solidly |
cToken | Lending Market for tokens forked from Compound |
LP (token) | Token that represent share in Liquidity Pool |
Lending Market | Compound fork without Compound Token and modified governance, |
This contest includes code for 3 separate solidity DApps as well as one Cosmos SDK blockchain. The 3 DApps are Zeroswap, Stableswap and Lending Market which are forks of Sushiswap, Solidly and Compound respectively. The blockchain is Manifest, which is an Evmos fork.
New Blockchain(Manifest) is a Layer 1 blockchain built using Cosmos SDK core modules and Tendermint Consensus with an EVM execution layer in the form of the Ethermint Module and network owned/incentivized defi primitives(stablecoin, dex, lending market).
The aim of New Blockchain is to become the best execution layer for original work. New Blockchain accomplishes this by offering:
New Blockchain’s core blockchain infrastructure is forked from EVMOS (https://docs.evmos.org/), including the main Ethermint and ERC-20 modules which simulate a EVM execution environment (Ethermint module) and offer native conversion between Cosmos SDK coins and ERC-20 tokens using an internal bridging mechanism (ERC-20 module). The claims module and incentives module are removed and we have added a custom Unified Governance Module that allows specific types of proposals that pass in the Governance module to be pushed to a storage contract on the EVM and read by dApps deployed on the EVM.
New Blockchain provides free liquidity to the ecosystem by removing swap fees from its native dex Zeroswap, a fork of SushiSwap without governance or a protocol token. Liquidity providers who supply their LP tokens to the lending market receive rewards in the form of wrapped-Manifest tokens.
The native lending market on New Blockchain is a fork of Compounds most recent codebase with the removal of Compounds native governance token Comp. Governance instead is conducted by submitting and voting on proposals through the Governance Module in the Cosmos SDK. When proposals pass, the storage smart contract on the EVM is updated with the proposal that passed. The proposal that was added can then be queued into the timelock for execution. Instead of dripping Comp token rewards to suppliers and borrowers, we are dripping the wrapped version of New Blockchains native token which is identical to wrapped-ETH. This involves wrapping New Blockchain token sent from the Treasury using the WETH-9 smart contract and then sending these tokens to the Reservoir of Compound.
The stable coin of the ecosystem Note is implemented as a standard ERC-20 token smart contract which has it’s full supply minted to another smart contract Accountant.sol. The only way to create new Note is to borrow it directly from the cNote lending market in the same way any other asset is borrowed. The noteInterestRateModel is a new model that has Supply Rate and Borrow Rate set to the same value.
Since Note cannot be created, only borrowed, and the Supply Rate is the same as the Borrow Rate we needed to create a mechanism to keep track of how much of the interest paid by the market to borrow Note goes to the Accountant and eventually gets swept into the Treasury vs how much is paid to external suppliers. This is done by supplying and redeeming liquidity during every action taken by an external user of cNote. When users borrow Note or redeem cNote, the function in CNote will call another function in the Accountant to supply cNote in the exact amount required to offset the request. When Users supply or repay Note to the market, the function in CNote will call another function in Accountant to redeem exactly the same amount of Note from the market. This results in there never being any Note present in the CNote market other than during function calls, while also providing an infinite amount of Note to be borrowed or redeemed from the Market.
The unigov module is a wrapper around the Cosmos-sdk x/gov module. The module defines two proposal types (as well as their JSON formats): LendingMarketProposals, TreasuryProposals. The proposals are structured after the Compound-Finance Protocol’s proposal type, that is, each proposal is essentially an array of tuples: (signature, calldata, msg.value). Upon a proposal’s passing, the proposalHandler either deploys the ProposalStore contract (if it is not already deployed) or appends the proposal into the ProposalStore’s mapping ( uint ⇒ Proposal). The Unigov module uses the evm.Call() method from geth to route/create messages within the EVM.
Unified Governance refers to the Governance Bridge between the Cosmos SDK Governance Module and the storage contract in the EVM that is owned by the Governance Module and that receives updates when designated proposals are passed. There is only one smart contract that is used, the storage contract that receives updates:
Zeroswap and Stableswap are sushiswap and solidly forks respectively with all fee related logic removed. No other changes were made. An externally updated TWAP oracle was added to Zeroswap in uniswap/UniswapV2Oracle.sol
The Lending Market is a decentralized money market forked from Compound protocol. The lending protocol utilizes the full suite of Compound Smart Contracts. The full compound documentation can be found here. The modifications that we have made include the removal of proposing and voting from the GovernorBravo logic as well as the modification of Comptroller to allow for the granting of any generic ERC-20 token as a reward instead of Comp token :
On genesis, type(uint).max Note is minted to the Accountant, on borrows/redeems into the cNote Lending Market, the Accountant supplies Note to the cNote contract, receiving cNote in return. On repayBorrows and mints, the Accountant redeems suppliedNote/curExRate cNOTE, and receives the Note it had previously lent to the market. The interest earned on the Note the Accountant lends to the market is swept to the treasury via an external method in Accountant.
The treasury receives the interest swept from the Accountant. In maintains a reserve of Note for community use. These funds are dispersed via UniGov Proposals.