SIP 60: New Escrow Contract & Migration Source

AuthorClinton Ennis
Discussions-To<https://discord.gg/ShGSzny>
StatusWIP
Created2020-05-20

Simple Summary

Add new flexible escrow API to the SNX Escrow contract.

Abstract

The current SNX RewardEscrow contract is limited only allowing the FeePool to escrow SNX rewards from the inflationary supply.

It was not designed to be used as a general purpose escrow contract. New requirements include adding arbitary length escrow entries to be created by anyone as well as supporting the new terminal inflation and liquidation.

This will require a migration of all escrowed SNX and escrow entries from the current RewardEscrow to new Escrow contract.

Motivation

Current limitations of the RewardEscrow contract

  1. Only escrows SNX for 12 months.
  2. Only FeePool has the authority to create escrow entries.
  3. The escrow table checkAccountSchedule only supports returning up to 5 years of escrow entries from the initial inflationary supply.
  4. Vest can only be called by the owner of the SNX.
  5. Cannot support liquidations of escrowed SNX for sip-15.

Desired features for a general SynthetixEscrow contract

  1. Ability to add arbitrary escrow periods. e.g. 3 months to 2 years.
  2. Public escrowing. Allows any EOA or any contract to escrow SNX. Allowing SNX to be escrowed for protocol contributors, investors and funds or contracts that escrow some sort of incentive similar to the Staking Rewards.
  3. Update checkAccountSchedule to allow for terminal inflation and an unlimited escrow navigation through paging.
  4. Allowing anyone to vest an accounts escrowed tokens allows Synthetix network keepers to help support SNX holders and supports the Liquidation system to vest an under collateralised accounts vest-able SNX to be paid to the liquidator.
  5. If an account being liquidated does not have enough transferable SNX in their account and the system needs to liquidate escrowed SNX being used as collateral then reassign the escrow amounts to the liquidators account to vest. TBD: Should the escrowed SNX be liquidated at a larger discount? or vested and transfered to the liquidator at the standard discount?

Specification

interface ISynthetixEscrow {
    // Views
    
    // Updated to handle paging of 100 escrow entries at a time from a starting vesting index
    function checkAccountSchedule(address account, uint startIndex) public view returns (uint[100] memory) 

    // Mutative functions
    
    // Added escrowLength argument allowing any length of escrow period from 1 second to x years
    function appendVestingEntry(address account, uint quantity, uint escrowLength) external;
        
    function vest() external;
    
    // New function to allow any account vest another account
    function vestOnBehalf(address account) external;
}

Migration

  1. Synthetix will need to be upgraded to migrate the SNX to the new contract onchain.
  2. During the migration Vest needs to be disabled or effectivly fail to ensure integrity of escrow entries and SNX balances beign migrated for all accounts.

Test Cases

TBD

Implementation

Configurable Values (Via SCCP)

TBD

Copyright and related rights waived via CC0.