SIP-233: Multi-Collateral Loans V2

Author
StatusDraft
TypeGovernance
NetworkOptimism
ImplementorTBD
ReleaseTBD
Created2022-03-03

Summary

A proposal to improve the usability of loans and shorts.

Abstract

This SIP proposes to upgrade the multi-collateral loan contracts to fix some deprecated code, but more importantly it aims to make life easier for other developers building on Synthetix.

Motivation

After the Synthesis (SIP-165) is complete, the Collateral Manager's borrow rate function (which uses the legacy DebtCache method to get the value of total issued synths) should be updated to use the oracle's debt value instead.

Additionally, there have been many requests from the community to upgrade the current Collateral contracts to include convenience functions, nomenclature changes, and adding configurable values. These feature requests are now possible since there are no longer any gas or contract size constraints on Optimism.

Specification

This new iteration of multi-collateral loans will consist of several improvements to the existing contracts. Including:

  1. Refactoring existing code
  2. Adding convenience functions
  3. Adding new features to loans and shorts

Refactor Existing Code

  • Update CollateralManager.getBorrowRate to get the total issued synths value from the oracle.
  • Update Collateral._repayWithCollateral to conform to return pattern of the other loan functions.
  • Refactor all interest rate models and make it configurable via sccp
  • Refactor the old liquidation mechanism on loans and shorts
    • e.g. insta-liquidation trigger at a configurable c-ratio
  • Other various nomenclature edits to make the code more readable

Convenience Functions

  • Add view function to get all loans for a specific account: getLoansForAccount(address account).
  • Add view function to get all longable and shortable synths: getSynths() and getShortableSynths().
  • Add view function to get the accrued interest value for a loan: getAccruedInterestForLoan(uint id).
  • Add function to set a short position's principal and collateral to specified values: setShortAndCollateralTo(uint x, uint y).

New Features

  • Loan and short positions will be represented as ERC-721 tokens.
  • Add varied interest rates for each synth.
  • Add dynamic fee for opening and closing a short, with configurable base fee.
  • Add configurable min c-ratio for each type of loan taken against ETH
    • e.g. sETH/ETH loan min cratio is 111% while sUSD/ETH loans min cratio 120%

State Migration

This SIP will also require a migration of all the Loan state and CollateralManagerState to the new contracts. This will be done in a similar way to how the debt share migration process worked in SIP-185.

Copyright and related rights waived via CC0.