The idea is to add "direct swap" approach that doesn't require deposit/withdraw in most cases.
The way it will work:
User calls ft_transfer_call on the token that wants to swap. Passing ":::" as msg
Ref Exchange when receiving tokens tries to swap.
If successfully swaps (pool is good, token out is there, min amount is met), sends token_out directly to the user
Now if that fails (the user is not registered), on callback it records that user has them in portfolio in Ref Exhcange
Note that user still MUST be register for outgoing token ahead of time to prevent loss of funds in case they are not registered on the receiving end.
This requirement can be lifted by the caller by passing force=1, if they guarantee that user's account is registered. In case the user is not registered at the end - the funds will be returned to the exchange owner.
if sender is not registered in the exchange and force=0, it fails; if force=1 -> it proceeds
if sender is not registered in the out tokens, and it is registered in the exchange - their balance will be in the exchange. If they are not registered in exchange (meaning force=1) they loose the tokens.
The idea is to add "direct swap" approach that doesn't require deposit/withdraw in most cases. The way it will work:
msg
token_out
directly to the userNote that user still MUST be register for outgoing token ahead of time to prevent loss of funds in case they are not registered on the receiving end.
This requirement can be lifted by the caller by passing
force=1
, if they guarantee that user's account is registered. In case the user is not registered at the end - the funds will be returned to the exchangeowner
.