SIP-66: Reduce gas of SNX transfers for non-stakers
Author | |
---|---|
Status | Implemented |
Type | Governance |
Implementor | TBD |
Release | TBD |
Discussions-To | <https://discordapp.com/invite/AEdUHzt> |
Created | 2020-06-30 |
Simple Summary
Reduce gas of SNX
transfers for non stakers.
Abstract
When an account has no debt, then reduce gas requirement of SNX transfers by not checking any stale rates.
Motivation
Prior to SIP-48, transfers of SNX
would initially check for any debt and if none, skip checking the total size of the debt pool. SIP-48 inadventently undid this, meaning that SNX
transfers for non-stakers caused much higher gas limits than necessary.
Checking the total size of the debt pool involves looping over every synth in Synthetix (currently 40-odd), calculating their USD value (totalSupply * rate
), which is very gas intensive (~500k gas).
Specification
Overview
Add a check in Synthetix.transfer
and Synthetix.transferFrom
to only check Issuer.transferableSynthetixAndAnyRateIsStale
when there is debt for the account.
Rationale
Put the check back into the functions that are impacted.
Note that with this change,
SNX
transfers will be allowed for accounts with no debt even when theSNX
or any synth rates are stale.
Technical Specification
In both transfer
and transferFrom
, perform an initial check for SynthetixState.issuanceData()
and if no debt ownership, then proceed with a regular transfer.
Test Cases
- Given a user has SNX
- and they have not issued any debt
- and the rate of SNX or any synth is stale
- when they transfer any amount of their SNX
- it succeeds
- when they transfer any amount of their SNX
- and no synth rate nor SNX is stale
- when they transfer any amount of their SNX
- it succeeds
- when they transfer any amount of their SNX
- and the rate of SNX or any synth is stale
- and they have issued debt
- and the rate of SNX or any synth is stale
- when they transfer any amount of their SNX
- it fails
- when they transfer any amount of their SNX
- and no synth rate nor SNX is stale
- when they transfer any amount of their SNX
- it succeeds
- when they transfer any amount of their SNX
- and the rate of SNX or any synth is stale
- and they have not issued any debt
Configurable Values (Via SCCP)
Please list all values configurable via SCCP under this implementation.
Copyright
Copyright and related rights waived via CC0.