This documentation is a work in progress!
Contracts that Kresko has developed mainly fall into four categories:
- Diamond: Contracts related to EIP-2535 diamond proxy pattern.
- Core: Borrow/Mint/Liquidation state, logic and configuration.
- Tokenization: Kresko Asset, Kresko Asset Anchor (Non-rebasing wrapper token) and KISS.
- Utility: Non-protocol contracts like staking and helper contracts.
Enumerable access control based on the OpenZeppelin AccessControlEnumerable but is customized to work as a diamond proxy facet that uses shared diamond storage through a library.
Proxy contract that holds the address and storage of he protocol. Main logic included is the fallback function which maps the incoming function signature to an implementation facet.
Functions for modifying the mapping of function selectors into their implementation facet and performing state upgrades when doing so.
Functions that allow inspection of the function selector to facet mappings inside the diamond proxy.
Two-step ownership facet that handles ownership for the diamond.
ERC-2535 related storage in a single struct that is stored in the diamond storage.
Includes the diamond storage setter as a free function and the storage location hash.
Structs used within DiamondState.
Standard interface detection facet.
Main upgradeability logic for the diamond proxy.
Ownership handling logic for the diamond proxy.
View functions that can be used to obain information about account states within the protocol.
Exposes the function to burn (repay) kresko assets.
Quality-of-life helper functions that deal with burning (repaying) kresko assets.
Authorized functions that allow the configuration of protocol state.
Functions to deal with collateral assets. Namely the deposit and withdraw of collateral assets.
Exposes the core liquidation function and a view to calculate the maximum liquidatable value for a market pair in a user position.
Exposes the function to mint (borrow) kresko assets.
Contains all modifiers related to the diamond proxy and the protocol in separate abstract contracts.
Allows the safety council (multisig of 5) to toggle a pause status on each core functionality (Deposit/Withdraw/Repay/Borrow/Liquidation).
View functions that can be used to obtain information about the global state.
View functions that are used by the Minter application.
Shared account state related functions.
Utility functions that are connected to the Kresko Asset struct and Collateral Asset struct.
Functions that perform calculations for open and close fee and liquidations.
Logic and helpers for handling collateral actions and amounts.
Decimal conversion utilities mainly involving oracle values and collateral assets.
Logic and helpers for handling kresko asset actions and amounts.
Main state modifying logic for handling mints (borrows).
Main state modifying logic for handling repayment of debt.
Frontend related structs and view functions.
Main storage layout for the protocol defined as a struct.
Includes the protocol storage setter as a free function and the storage location hash.
Structs used within the protocol.
Oracle contract to get on-chain prices from any UniswapV2Pair. Non-upgradeable.
ERC4626 Tokenized Vault Standard, used by the non-rebasing wrapper token (Kresko Asset Anchor).
Mintable and burnable rebasing ERC-20. Minting and burning is controlled by AccessControlUpgradeable.
ERC-4626 that handles the pro-rata representation of Kresko Assets. Main purpose is to allow easier integration for the rebasing KreskoAsset with other protocols and chains.
Mintable, burnable and pausable ERC-20 token that only the protocol can mint and burn.
Library that contains the positive and negative rebasing functions.
Staking contract that handles multiple pools and multiple reward tokens.
Contract that contains helper functionality related to the KrStaking.