cic-contracts/doc/texinfo/tokenswap.sol.texi

41 lines
1.6 KiB
Plaintext
Raw Normal View History

2023-08-01 17:07:31 +02:00
@subsection TokenSwap
2023-08-03 11:27:05 +02:00
Token swap interface that can fit token escrow purposes aswell as token swap contracts.
Optionally may define a @code{defaultToken}, that may among other things be used for @code{withdraw()} calls without an @code{inToken}.
An explicit @emph{ERC20 approval} of the balance to be transacted will usually be required for the implementing contract.
If the value 0 is passed as argument to @code{deposit} or @code{withdraw}, implementers can choose one of two possible outcomes:
@itemize
@item Noop. 0 @emph{must} be returned.
@item Use @emph{balance} or the max available @emph{allowance}. The actual (spent) value @emph{must} be returned.
@end itemize
2023-08-01 17:07:31 +02:00
@subsubsection ERC165 Interface identifier
2023-08-01 17:07:31 +02:00
@include ../../build/TokenSwap.interface
@subsubsection Solidity interface definition
2023-08-01 17:07:31 +02:00
@include ../../build/contract_TokenSwap.texi
@subsubsection Reference implementations
2023-08-01 17:07:31 +02:00
@itemize
@item
2023-08-03 11:27:05 +02:00
@uref{git://holbrook.no/erc20-pool.git,}
2023-08-01 17:07:31 +02:00
@end itemize
2023-08-03 11:27:05 +02:00
@subsubsection Handling deposits
The implementation is free to decide whether deposits can be recovered directly, or if they will be locked in the smart contract - temporarily or permanently.
For the duration deposits are locked, they are part of the smart contract's swap liquidity. During this time, locked deposits may only be withdrawn in exchange for other tokens accepted by the contract.
Deposits that are not locked should be withdrawable using the @code{withdraw(address,uint256)} (@code{0xf3fef3a3}) method signature.
Of course, as with most swap contracts, the tokens available for withdrawal by the holder may not necessarily match the tokens that were deposited by the holder.