Standard freeze() func for token interface
#1652
Replies: 3 comments 5 replies
-
|
This seems like it may be pretty useful, although I don't have a great perspective into all the use cases. I do have some questions regarding the proposed semantics. Specifically, the interaction between the 'frozen' allowance and Instead, we could e.g. make In case if we keep using |
Beta Was this translation helpful? Give feedback.
-
|
On the benefit side, I agree that this might be useful for tax reporting. Although I'd love to get some more signal. Is there any prior art for something like this on other chains? On the cost side, my knee jerk reaction is to resist complexity, especially when it sets us apart from other platforms. If we share this reporting challenge with erc20 assets, for example, then it's likely that there are tax reporting solutions that already handle these cases. I acknowledge that this complexity and balance bifurcation already exists with XLM balances (base reserve, dex liabilities) and TrustLines (dex liabilities). But
|
Beta Was this translation helpful? Give feedback.
-
|
Something for us to consider is that this is building more custom logic into all tokens, rather than leaning into contracts as a way to bring custom logic to all tokens. The later is interesting because the freeze logic can take many shapes and forms if it can be defined independent of tokens. I don't love to suggest this because it may be very much over-engineered, but if balance holders could hook in other contracts into their balance on any transfer, they could achieve things like freezing without freezing needing to be added to every token, or the token standard. How I imagine this would happen is a balance holder could register a "transfer hook" that would either approve or deny the transfer. There's quite a lot to figure out if we went this route, so I'm not proposing any specific design here, just that "hooks" would make this possible without the token standard having to buy into this feature specifically. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Multiple DeFi usage scenarios (DAO, trading, bridges, etc.) require locking some amount of tokens on the account/contract balance in order to use them later. A standard
approve()function can set the spending token allowance but it cannot ensure that the contract will be able to spend it in the future because a user can transfer/spend/lock these tokens, so the actual balance during the transaction execution might be lower than the allowance. Users can also approve several conflicting allowances to different contracts. This case is similar to the issue addressed by the CAP-3 (Asset-backed offers).Currently, the only way to overcome this problem is to transfer funds to the contract that will temporary lock them. It's potentially less secure than freezing tokens on the address balance, and not ideal from the tax reporting perspective since transferring funds to some contract even solely for the temporary lockup purpose may be considered a taxable event depending on the jurisdiction.
It would be nice to have a
freeze()function in both SAC and standard token interface to provide the ability for the contracts to temporary lock user funds within a pre-approved allowance amount.A
spendershould be allowed to freeze tokens only if it previously received allowance to spend these tokens, and for the period not exceeding the current allowance. Semantics should be similar to theapprove()func:freeze()for the first time with non-zero amount creates a record containing the amount of frozen tokens andexpiration_ledger.freeze()func with a zeroamountor whenexpiration_ledger<current_ledgershould unlock all previously locked tokens.freeze()when thespenderalready has some frozen allowance modifies currently frozen amount (but never exceeding current allowance limits).Unlike the
approve()func, callingfreeze()should implicitly check the actually available tokens balance and prevent thespenderfrom locking more tokens that currently available. Before thespenderwill be able to use frozen tokens it must callfreeze()to reduce the frozen amount or unfreeze it completely, so that the amount of tokens thespenderwill be able to transfer/burn using thetransfer_from()func should be equal tomin(current_balance, allowance - frozen).Freezing the tokens on the account balance should increase its
selling_liabilities. This way Classic operations (transfers, SDEX operations) will be unable to use frozen tokens.Potential applications: cross-chain bridges, DAO voting, orderbook-based DEXes, escrow contracts, non-custodial wallets.
It's just an idea at this point. Obviously, not comprehensive enough.
Would love to hear some feedback on this before starting working on the formal proposal.
Beta Was this translation helpful? Give feedback.
All reactions