Stabilis is a DeFi stablecoin implementation with a reserve asset stabilization mechanism.
Its base is an ERC20 smart contract for a stablecoin named Stabilis
, which is pegged to the US Dollar at a 1:1 ratio. It is connected to a smart contract named DepositorCoin
, which issues another token to the providers of a collateral buffer to the Stabilis smart contract.
The contracts
folder contains 4 files:
➡️ Stabilis.sol
is the main stablecoin contract. It includes functions that allow to:
- mint and burn Stabilis (the stablecoin) in exchange for ETH.
- view the transaction fee for minting or burning Stabilis tokens.
- deposit collateral buffer in ETH and mint DepositorCoin tokens. The DepositorCoin tokens are minted to the users who overcollateralize (put extra ETH in) the contract, in order for it to have a safety margin. These users do not receive the Stabilis coin, but DepositorCoin tokens instead. The price of those depends on the amount of surplus ETH in the contract, provided that is has achieved a 1:1 price ratio to USD.
If the inital collateral ratio is not met (ETH in reserve is less than the USD value of minted Stabilis tokens), extra ETH must be deposited. After the ratio is met, the remainder of the ETH value will be minted as DepositorCoin tokens.
- withdraw collateral buffer in ETH and burn DepositorCoin tokens. If there is an ETH deficit in the contract, the DepositorCoin tokens are destroyed (due to their ETH equivalent being used towards maintaining the collateral ratio). Every time the DepositorCoin contract is deployed from within the Stabilis contract, it remains locked for a period of time defined during the initial Stabilis deployment. This offers to the first depositor the benefit of being the only one for that amount of time. It also prevents from withdrawing the collateral funds immediately and potentially de-pegging the stablecoin.
➡️ Oracle.sol
is a contract to set and view the ETH/USD price. In its current state, the price is set by the deployer of the contract. The contract can also be easily modified to accept external data feed on the price from a trusted oracle provider, such as Chainlink. Click here for more info.
➡️ DepositorCoin.sol
is the token contract for the surplus collateral providers. It includes functions to mint and burn DepositorCoin tokens. The functions to deposit and withdraw collateral are handled by the Stabilis.sol contract, as mentioned above. The DepositorCoin contract is deployed from inside the Stabilis contract the first time anyone send ETH as collateral and if the contract ever has a collateral deficit.
➡️ FixedPointMath.sol
is a contract that includes math formulas. It ensures the correctness of the calculations between positive and negative integer numbers, as well as preserves decimal integrity in multiplication and division.
The Oracle smart contract has been deployed with the predefined price set as
2000
(1 ETH is equivalent to 2000 Stabilis tokens)The Stabilis smart contract has been deployed with the following constructor parameters:
-0xe4Cbb0D2127e4fbbf157764cf09E995A69020a08
as the deployment address of the above Oracle smart contract
-2%
of the funds of every Stabilis mint or burn transaction are added as transaction fee in the contract balance
-20%
as the collateral ratio percentage (if there are 100 ETH in the contract from minted Stabilis tokens, at least another 20 ETH extra must be present from minted Depositor Coin tokens)
-10 minutes
is the inital lock time for the first minter of the Depositor Coin smart contract (during that time no extra minting or burning is allowed)