Token swap interface implementation
This commit is contained in:
parent
80671fdfaa
commit
e3d0704d4f
43
README.md
43
README.md
@ -471,6 +471,9 @@ Solidity interface definition
|
|||||||
// Tokens are successfully minted; by who, to whom and how much
|
// Tokens are successfully minted; by who, to whom and how much
|
||||||
event Mint(address indexed _minter, address indexed _beneficiary, uint256 value);
|
event Mint(address indexed _minter, address indexed _beneficiary, uint256 value);
|
||||||
|
|
||||||
|
// The given token has been successfully minted; by who, to whom and how much
|
||||||
|
event Mint(address indexed _minter, address indexed _beneficiary, address indexed _token, uint256 value);
|
||||||
|
|
||||||
// Mint the specified value of tokens to the specified recipient
|
// Mint the specified value of tokens to the specified recipient
|
||||||
function mintTo(address _beneficiary, uint256 value) external returns (bool);
|
function mintTo(address _beneficiary, uint256 value) external returns (bool);
|
||||||
|
|
||||||
@ -628,33 +631,33 @@ Solidity interface definition
|
|||||||
Reference implementations
|
Reference implementations
|
||||||
- <git://holbrook.no/erc20-demurrage-token.git>
|
- <git://holbrook.no/erc20-demurrage-token.git>
|
||||||
|
|
||||||
### TokenVend
|
### TokenSwap
|
||||||
|
|
||||||
This interface defines the mechanism for which a specific ERC20 token
|
Token swap interface that can fit token escrow aswell as token swap
|
||||||
may be exchanged for a different ERC20 token.
|
contracts.
|
||||||
|
|
||||||
A typical use-case is generation of voting tokens based on a momentary
|
|
||||||
voucher balance. This is especially useful if the original ERC20 token
|
|
||||||
is subject to decay (demurrage).
|
|
||||||
|
|
||||||
The tokens used for exchange **SHOULD** be locked for the full duration
|
|
||||||
of holding the vended tokens.
|
|
||||||
|
|
||||||
The withdrawal function may or may not allow partial withdrawals.
|
|
||||||
|
|
||||||
ERC165 Interface identifier
|
ERC165 Interface identifier
|
||||||
8a13249c
|
9e2d0236
|
||||||
|
|
||||||
Solidity interface definition
|
Solidity interface definition
|
||||||
interface ITokenVend {
|
interface ITokenSwap {
|
||||||
// A new vended token has been created.
|
// Add inToken liquidity of the full balance of the sender
|
||||||
event TokenCreated(uint256 indexed _tokenIdx, uint256 indexed _supply, address _token);
|
// Requires token approval for the balance.
|
||||||
|
function deposit(address _inToken) external returns (uint256);
|
||||||
|
|
||||||
// Create corresponding vended tokens for the control token balance of the caller.
|
// Add inToken liquidity to the tune of given value.
|
||||||
function getFor(address _token) external returns (uint256);
|
// Requires token approval for the corresponding value.
|
||||||
|
function deposit(address _inToken, uint256 _value) external returns (uint256);
|
||||||
|
|
||||||
// Recover control tokens that were used to retrieve the corresponding vended tokens.
|
// Withdraw any pending outToken balance in the pool for the sender.
|
||||||
function withdrawFor(address _token) external returns (uint256);
|
function withdraw(address _outToken) external returns (uint256);
|
||||||
|
|
||||||
|
// Withdraw pending outToken balance of given value in the pool for the sender.
|
||||||
|
function withdraw(address _outToken, uint256 _value) external returns (uint256);
|
||||||
|
|
||||||
|
// Exchange inToken equalling given value for outToken.
|
||||||
|
// Requires token approval for the value of inToken.
|
||||||
|
function withdraw(address _outToken, address _inToken, uint256 _value) external returns (uint256);
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference implementations
|
Reference implementations
|
||||||
|
@ -76,7 +76,7 @@ The following well-known solidity interfaces are partially implemented in CIC na
|
|||||||
|
|
||||||
@include tokenratechange.sol.texi
|
@include tokenratechange.sol.texi
|
||||||
|
|
||||||
@include tokenvend.sol.texi
|
@include tokenswap.sol.texi
|
||||||
|
|
||||||
@include tokenvote.sol.texi
|
@include tokenvote.sol.texi
|
||||||
|
|
||||||
|
15
doc/texinfo/tokenswap.sol.texi
Normal file
15
doc/texinfo/tokenswap.sol.texi
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
@subsection TokenSwap
|
||||||
|
|
||||||
|
Token swap interface that can fit token escrow aswell as token swap contracts.
|
||||||
|
|
||||||
|
@table @dfn
|
||||||
|
@item ERC165 Interface identifier
|
||||||
|
@include ../../build/TokenSwap.interface
|
||||||
|
@item Solidity interface definition
|
||||||
|
@include ../../build/contract_TokenSwap.texi
|
||||||
|
@item Reference implementations
|
||||||
|
@itemize
|
||||||
|
@item
|
||||||
|
@uref{git://holbrook.no/erc20-vend.git,}
|
||||||
|
@end itemize
|
||||||
|
@end table
|
@ -471,6 +471,9 @@ Solidity interface definition
|
|||||||
// Tokens are successfully minted; by who, to whom and how much
|
// Tokens are successfully minted; by who, to whom and how much
|
||||||
event Mint(address indexed _minter, address indexed _beneficiary, uint256 value);
|
event Mint(address indexed _minter, address indexed _beneficiary, uint256 value);
|
||||||
|
|
||||||
|
// The given token has been successfully minted; by who, to whom and how much
|
||||||
|
event Mint(address indexed _minter, address indexed _beneficiary, address indexed _token, uint256 value);
|
||||||
|
|
||||||
// Mint the specified value of tokens to the specified recipient
|
// Mint the specified value of tokens to the specified recipient
|
||||||
function mintTo(address _beneficiary, uint256 value) external returns (bool);
|
function mintTo(address _beneficiary, uint256 value) external returns (bool);
|
||||||
|
|
||||||
@ -628,33 +631,33 @@ Solidity interface definition
|
|||||||
Reference implementations
|
Reference implementations
|
||||||
- <git://holbrook.no/erc20-demurrage-token.git>
|
- <git://holbrook.no/erc20-demurrage-token.git>
|
||||||
|
|
||||||
### TokenVend
|
### TokenSwap
|
||||||
|
|
||||||
This interface defines the mechanism for which a specific ERC20 token
|
Token swap interface that can fit token escrow aswell as token swap
|
||||||
may be exchanged for a different ERC20 token.
|
contracts.
|
||||||
|
|
||||||
A typical use-case is generation of voting tokens based on a momentary
|
|
||||||
voucher balance. This is especially useful if the original ERC20 token
|
|
||||||
is subject to decay (demurrage).
|
|
||||||
|
|
||||||
The tokens used for exchange **SHOULD** be locked for the full duration
|
|
||||||
of holding the vended tokens.
|
|
||||||
|
|
||||||
The withdrawal function may or may not allow partial withdrawals.
|
|
||||||
|
|
||||||
ERC165 Interface identifier
|
ERC165 Interface identifier
|
||||||
8a13249c
|
9e2d0236
|
||||||
|
|
||||||
Solidity interface definition
|
Solidity interface definition
|
||||||
interface ITokenVend {
|
interface ITokenSwap {
|
||||||
// A new vended token has been created.
|
// Add inToken liquidity of the full balance of the sender
|
||||||
event TokenCreated(uint256 indexed _tokenIdx, uint256 indexed _supply, address _token);
|
// Requires token approval for the balance.
|
||||||
|
function deposit(address _inToken) external returns (uint256);
|
||||||
|
|
||||||
// Create corresponding vended tokens for the control token balance of the caller.
|
// Add inToken liquidity to the tune of given value.
|
||||||
function getFor(address _token) external returns (uint256);
|
// Requires token approval for the corresponding value.
|
||||||
|
function deposit(address _inToken, uint256 _value) external returns (uint256);
|
||||||
|
|
||||||
// Recover control tokens that were used to retrieve the corresponding vended tokens.
|
// Withdraw any pending outToken balance in the pool for the sender.
|
||||||
function withdrawFor(address _token) external returns (uint256);
|
function withdraw(address _outToken) external returns (uint256);
|
||||||
|
|
||||||
|
// Withdraw pending outToken balance of given value in the pool for the sender.
|
||||||
|
function withdraw(address _outToken, uint256 _value) external returns (uint256);
|
||||||
|
|
||||||
|
// Exchange inToken equalling given value for outToken.
|
||||||
|
// Requires token approval for the value of inToken.
|
||||||
|
function withdraw(address _outToken, address _inToken, uint256 _value) external returns (uint256);
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference implementations
|
Reference implementations
|
||||||
|
@ -8,6 +8,9 @@ interface IMinter {
|
|||||||
// Tokens are successfully minted; by who, to whom and how much
|
// Tokens are successfully minted; by who, to whom and how much
|
||||||
event Mint(address indexed _minter, address indexed _beneficiary, uint256 value);
|
event Mint(address indexed _minter, address indexed _beneficiary, uint256 value);
|
||||||
|
|
||||||
|
// The given token has been successfully minted; by who, to whom and how much
|
||||||
|
event Mint(address indexed _minter, address indexed _beneficiary, address indexed _token, uint256 value);
|
||||||
|
|
||||||
// Mint the specified value of tokens to the specified recipient
|
// Mint the specified value of tokens to the specified recipient
|
||||||
function mintTo(address _beneficiary, uint256 value) external returns (bool);
|
function mintTo(address _beneficiary, uint256 value) external returns (bool);
|
||||||
|
|
||||||
|
25
solidity/TokenSwap.sol
Normal file
25
solidity/TokenSwap.sol
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
pragma solidity >=0.6.12;
|
||||||
|
|
||||||
|
// Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
// File-version: 1
|
||||||
|
|
||||||
|
interface ITokenSwap {
|
||||||
|
// Add inToken liquidity of the full balance of the sender
|
||||||
|
// Requires token approval for the balance.
|
||||||
|
function deposit(address _inToken) external returns (uint256);
|
||||||
|
|
||||||
|
// Add inToken liquidity to the tune of given value.
|
||||||
|
// Requires token approval for the corresponding value.
|
||||||
|
function deposit(address _inToken, uint256 _value) external returns (uint256);
|
||||||
|
|
||||||
|
// Withdraw any pending outToken balance in the pool for the sender.
|
||||||
|
function withdraw(address _outToken) external returns (uint256);
|
||||||
|
|
||||||
|
// Withdraw pending outToken balance of given value in the pool for the sender.
|
||||||
|
function withdraw(address _outToken, uint256 _value) external returns (uint256);
|
||||||
|
|
||||||
|
// Exchange inToken equalling given value for outToken.
|
||||||
|
// Requires token approval for the value of inToken.
|
||||||
|
function withdraw(address _outToken, address _inToken, uint256 _value) external returns (uint256);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user