Formalize allowance behavior in SEP-41 documentation #1919
Replies: 1 comment 3 replies
|
I agree, the existing SEP-41 is underspecified in a couple places that make it ambiguous as to how allowances work. I think #1918 also risks over specifying allowances by discussing implementation specific details like storage patterns and auth requirements. When I look at ERC-20, a couple things stand out to me. It also says very little, but what it does say very clearly communicates how allowances work. ERC-20 focuses on what behaviours are possible, while SEP-41 discusses what values change. For example, the ERC-20
Ref: ERC-20 L126 While the SEP-41
I think we can fill the gap in SEP-41 by similar to ERC-20 discussing the feature very briefly, avoiding implementation details. |
Uh oh!
There was an error while loading. Please reload this page.
SEP-41 defines the token standard for custom tokens on Soroban and aims to make these tokens as compatible with SACs as possible in terms of interface and functionality. It states that its interface is a subset of, and compatible with, the Stellar Asset Contract defined in CAP-46-6.
Version 0.4.1 of SEP-41 defines an interface for allowances but only hints in comments at how the token contract should implement allowances. As a consumer of this SEP, it's not immediately obvious how allowances should work and referencing CAP-46 does not make it much clearer.
I've recently fielded the question:
If I approve a spender for 40 XLM, then approve the same spender 50 XLM, is their total allowance 90 or 50? The spec doesn't seem to define this.The answer is 50, approve overwrites the previous allowance rather than incrementing it. That behavior is mentioned only obliquely, in a security caution on the token interface documentation:
Impact
Divergent allowance implementations create confusion about how to interact with allowances and ambiguity for downstream systems that consume allowance events. An indexer that wants to track an account's current allowance for a token from
approve/transfer_from/burn_fromevents needs a normative rule for whether approve overwrites or accumulates, whethertransfer_fromandburn_fromdecrement the recorded amount, and howlive_until_ledgerinteracts with reads, none of which are positively stated in v0.4.1.Proposal
Document explicitly how allowances should behave so implementers and consumers can rely on a single normative source. I have opened PR 1918 to add an Allowances section to SEP-41 capturing the semantics described in the developer docs and matching Stellar Asset Contract behavior.
References
All reactions