SIP-47: Prevent Empty Exchanges

Author
Discussions-To<https://discordapp.com/invite/AEdUHzt>
StatusImplemented
Created2020-03-05

Simple Summary

Prevent exchanges, burns and transferAndSettles from succeeding with 0 amounts.

Abstract

Fix an edge-case that was introduced with SIP-37 that reduces exchanges, burns and transferAndSettle invocations down to the user's balance - even if no settlement occurred.

Motivation

Since SIP-37 exchanges of invalid amounts for the user have been succeeding as 0 exchanges, emitting events. These successful transactions may cause users to think their exchanges have gone through and they also create noise in event monitoring tools such as The Graph.

For example, this user performed the same transaction twice with increasing nonces. The first succeeded and exchanged 0.003 sBTC into sUSD and the second also succeeded but exchanged 0.

This proposal is to simply check for any unsettled exchanges and only then to amend the amount, otherwise to treat the amount incoming as before SIP-37 was introduced (that is, revert if the amount is more than the user has).

Specification

  • Exchanger.settlementOwing to return the number of entries in the queue for that synth.
  • Exchanger.settle to return the number of entries removed in the settlement as numEntriesSettled
  • Exchanger.exchage, Issuer.burnSynths, Synth.transferAndSettle and Synth.transferFromAndSettle to all take this numEntriesSettled into consideration - if numEntriesSettled == 0 then the amount to use is what's been given the function - as per the pre-SIP-37 implementation. If numEntriesSettled > 0 then adjust the amount as per SIP-37.

Rationale

Admending settlementOwing to return numEntries prevents any further cross-contract calls, thereby limiting gas.

Test Cases

TBD

Implementation

TBD

Copyright and related rights waived via CC0.