Add tokenquote interface

This commit is contained in:
lash 2023-08-03 14:13:26 +01:00
parent 48d69ce74c
commit b9a29b7827
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
7 changed files with 93 additions and 3 deletions

View File

@ -638,7 +638,7 @@ Define limits of value amounts of tokens that individual addresses can
hold.
Limits are inclusive; a limit for 42 means transfer resulting in a token
balance \_higher\_ than 42 should be rejected.
balance *higher* than 42 should be rejected.
A return value of 0 indicates that the token is categorically not
accepted by the holder.
@ -650,6 +650,9 @@ accepted by the holder.
#### Solidity interface definition
interface ITokenLimit {
// Returns limit of total value a holder will accept of a specific token.
// The value limit returned is inclusive; A limit of 42 means any operation resulting in a balance OVER 42 should be rejected.
// A value of 0 means that no value of the token is accepted.
function limitOf(address _token, address _holder) external view returns(uint256);
}
@ -657,6 +660,29 @@ accepted by the holder.
- <git://holbrook.no/erc20-limiter.git>
### TokenQuote
Quote an output token value for a given value of input tokens.
Both input and output value is denominated in the smallest available
unit of respective tokens.
#### ERC165 Interface identifier
dbb21d40
#### Solidity interface definition
interface ITokenQuote {
// Returns, within a current context, what value of outTokens the given value of inTokens translates to.
// The values are given in smallest unit of each respective token.
function valueFor(address _outToken, address _inToken, uint256 value) external view returns (uint256);
}
#### Example implementation
- <git://holbrook.no/erc20-limiter.git>
### TokenRateChange
Enables detection of properties for CIC tokens that change value over

View File

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

View File

@ -2,7 +2,7 @@
Define limits of value amounts of tokens that individual addresses can hold.
Limits are inclusive; a limit for 42 means transfer resulting in a token balance _higher_ than 42 should be rejected.
Limits are inclusive; a limit for 42 means transfer resulting in a token balance @emph{higher} than 42 should be rejected.
A return value of 0 indicates that the token is categorically not accepted by the holder.

View File

@ -0,0 +1,20 @@
@subsection TokenQuote
Quote an output token value for a given value of input tokens.
Both input and output value is denominated in the smallest available unit of respective tokens.
@subsubsection ERC165 Interface identifier
@include ../../build/TokenQuote.interface
@subsubsection Solidity interface definition
@include ../../build/contract_TokenQuote.texi
@subsubsection Example implementation
@itemize
@item
@uref{git://holbrook.no/erc20-limiter.git,}
@end itemize

View File

@ -638,7 +638,7 @@ Define limits of value amounts of tokens that individual addresses can
hold.
Limits are inclusive; a limit for 42 means transfer resulting in a token
balance \_higher\_ than 42 should be rejected.
balance *higher* than 42 should be rejected.
A return value of 0 indicates that the token is categorically not
accepted by the holder.
@ -650,6 +650,9 @@ accepted by the holder.
#### Solidity interface definition
interface ITokenLimit {
// Returns limit of total value a holder will accept of a specific token.
// The value limit returned is inclusive; A limit of 42 means any operation resulting in a balance OVER 42 should be rejected.
// A value of 0 means that no value of the token is accepted.
function limitOf(address _token, address _holder) external view returns(uint256);
}
@ -657,6 +660,29 @@ accepted by the holder.
- <git://holbrook.no/erc20-limiter.git>
### TokenQuote
Quote an output token value for a given value of input tokens.
Both input and output value is denominated in the smallest available
unit of respective tokens.
#### ERC165 Interface identifier
dbb21d40
#### Solidity interface definition
interface ITokenQuote {
// Returns, within a current context, what value of outTokens the given value of inTokens translates to.
// The values are given in smallest unit of each respective token.
function valueFor(address _outToken, address _inToken, uint256 value) external view returns (uint256);
}
#### Example implementation
- <git://holbrook.no/erc20-limiter.git>
### TokenRateChange
Enables detection of properties for CIC tokens that change value over

View File

@ -5,5 +5,8 @@ pragma solidity >=0.6.12;
// File-version: 1
interface ITokenLimit {
// Returns limit of total value a holder will accept of a specific token.
// The value limit returned is inclusive; A limit of 42 means any operation resulting in a balance OVER 42 should be rejected.
// A value of 0 means that no value of the token is accepted.
function limitOf(address _token, address _holder) external view returns(uint256);
}

13
solidity/TokenQuote.sol Normal file
View File

@ -0,0 +1,13 @@
pragma solidity >=0.6.12;
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
// SPDX-License-Identifier: AGPL-3.0-or-later
// File-version: 1
// Value translator between tokens
interface ITokenQuote {
// Returns, within a current context, what value of outTokens the given value of inTokens translates to.
// The values are given in smallest unit of each respective token.
function valueFor(address _outToken, address _inToken, uint256 value) external view returns (uint256);
}