Add tokenlimit interface

This commit is contained in:
lash
2023-08-03 10:27:05 +01:00
parent da5d7d9d2d
commit 9df26634fd
8 changed files with 196 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
@subsection Expire
Defines an expiry time after which token balances or supply @emph{cannot change}.
Defines an expiry time after which token balances and supply @emph{cannot change}.
A contract defining an expiry @emph{must not} allow changing the expiration time to a time in the past.

View File

@@ -74,6 +74,8 @@ The following well-known solidity interfaces are partially implemented in CIC na
@include seal.sol.texi
@include tokenlimit.sol.texi
@include tokenratechange.sol.texi
@include tokenswap.sol.texi

View File

@@ -0,0 +1,18 @@
@subsection TokenLimit
Define limits of value amounts of tokens that individual addresses can hold.
@subsubsection ERC165 Interface identifier
@include ../../build/TokenLimit.interface
@subsubsection Solidity interface definition
@include ../../build/contract_TokenLimit.texi
@subsubsection Reference implementations
@itemize
@item
@uref{git://holbrook.no/erc20-limiter.git,}
@end itemize

View File

@@ -1,6 +1,17 @@
@subsection TokenSwap
Token swap interface that can fit token escrow aswell as token swap contracts.
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
@subsubsection ERC165 Interface identifier
@@ -14,5 +25,16 @@ Token swap interface that can fit token escrow aswell as token swap contracts.
@itemize
@item
@uref{git://holbrook.no/erc20-vend.git,}
@uref{git://holbrook.no/erc20-pool.git,}
@end itemize
@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.