From 4301c41ca60fbb77e0874840cebdd2c76de368f4 Mon Sep 17 00:00:00 2001 From: nolash Date: Fri, 11 Dec 2020 10:20:56 +0100 Subject: [PATCH] Add bancor interfaces --- AccountsIndex.sol | 19 +++++++++---------- Converter.sol | 17 +++++++++++++++++ ConverterRegistry.sol | 11 +++++++++++ ERC20.sol | 23 +++++++++++------------ Faucet.sol | 13 ++++++------- Network.sol | 19 +++++++++++++++++++ Registry.sol | 10 ++++++++++ TransferApproval.sol | 17 ++++++++--------- 8 files changed, 91 insertions(+), 38 deletions(-) create mode 100644 Converter.sol create mode 100644 ConverterRegistry.sol create mode 100644 Network.sol create mode 100644 Registry.sol diff --git a/AccountsIndex.sol b/AccountsIndex.sol index a6d95c6..b572ca7 100644 --- a/AccountsIndex.sol +++ b/AccountsIndex.sol @@ -2,18 +2,17 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 // SPDX-License-Identifier: GPL-3.0-or-later -// File-version: 1 +// File-version: 2 -abstract contract AccountsIndex { - address[] public accounts; - mapping(address => uint256) public accountsIndex; - uint256 public count; - +interface AccountsIndex { event AccountAdded(address indexed addedAccount, uint256 indexed accountIndex); - function addWriter(address _writer) public virtual returns (bool); - function deleteWriter(address _writer) public virtual returns (bool); - function add(address _account) external virtual returns (bool); - function have(address _account) external virtual view returns (bool); + function accounts(uint256 _idx) external view returns (address); + function accountsIndex(address _account) external view returns (uint256); + function count() external view returns (uint256); + function addWriter(address _writer) external returns (bool); + function deleteWriter(address _writer) external returns (bool); + function add(address _account) external returns (bool); + function have(address _account) external view returns (bool); } diff --git a/Converter.sol b/Converter.sol new file mode 100644 index 0000000..27f1873 --- /dev/null +++ b/Converter.sol @@ -0,0 +1,17 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// SPDX-License-Identifier: GPL-3.0-or-later +// File-version: 1 + + +interface Converter { + function reserveBalance(address _reserveToken) external view returns (uint256); + function reserveWeight(address _reserveToken) external view returns (uint32); + function reserveTokens() external view returns (address[] memory); + function reserveRatio() external view returns (uint32); + function reserveTokenCount() external view returns (uint16); + function setConversionFee(uint32 _conversionFee) external; + function owner() external view returns (address); + function acceptOwnership() external; +} diff --git a/ConverterRegistry.sol b/ConverterRegistry.sol new file mode 100644 index 0000000..937a092 --- /dev/null +++ b/ConverterRegistry.sol @@ -0,0 +1,11 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// SPDX-License-Identifier: GPL-3.0-or-later +// File-version: 1 + + +interface ConverterRegistry { + function getConvertibleTokens() external view returns (address[] memory); + function newConverter(uint16 _type, string memory _name, string memory _symbol, uint8 _decimals, uint32 _maxConversionFee, address[] memory _reserveTokens, uint32[] memory _reserveWeights) external returns(address); +} diff --git a/ERC20.sol b/ERC20.sol index b831244..add70c4 100644 --- a/ERC20.sol +++ b/ERC20.sol @@ -2,22 +2,21 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 // SPDX-License-Identifier: GPL-3.0-or-later -// File-version: 1 +// File-version: 2 // Description: The ERC20 standard interface as specified in EIP20 (sha256:9f843cbb25a737c9351b0b6a6f54b86864490d0d5284f6877b4929d481d34312) -abstract contract ERC20Core { - string public name; - string public symbol; - uint8 public decimals; - uint256 public totalSupply; - mapping (address => uint256) public balanceOf; - mapping (address => mapping (address => uint256)) public allowance; - +interface ERC20 { event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); - function transfer(address _to, uint256 _value) public virtual returns (bool); - function transferFrom(address _from, address _to, uint256 _value) public virtual returns (bool); - function approve(address _spender, uint256 _value) public virtual returns (bool); + function name() external view returns(string memory); + function symbol() external view returns(string memory); + function decimals() external view returns(uint8); + function totalSupply() external view returns(uint256); + function balanceOf(address) external view returns(uint256); + function allowance(address _owner, address _spender) external view returns (uint256); + function transfer(address _to, uint256 _value) external returns (bool); + function transferFrom(address _from, address _to, uint256 _value) external returns (bool); + function approve(address _spender, uint256 _value) external returns (bool); } diff --git a/Faucet.sol b/Faucet.sol index 542fe8b..958040a 100644 --- a/Faucet.sol +++ b/Faucet.sol @@ -2,16 +2,15 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 // SPDX-License-Identifier: GPL-3.0-or-later -// File-version: 1 +// File-version: 2 -abstract contract Faucet { - uint256 public amount; - address public token; - +interface Faucet { event FaucetUsed(address indexed _recipient, address indexed _token, uint256 _value); event FaucetFail(address indexed _recipient, address indexed _token, uint256 _value); - function setAmount(uint256 _amount) public virtual returns (bool); - function giveTo(address _recipient) public virtual returns (bool); + function amount() external view returns (uint256); + function token() external view returns (address); + function setAmount(uint256 _amount) external returns (bool); + function giveTo(address _recipient) external returns (bool); } diff --git a/Network.sol b/Network.sol new file mode 100644 index 0000000..3fae3a9 --- /dev/null +++ b/Network.sol @@ -0,0 +1,19 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// SPDX-License-Identifier: GPL-3.0-or-later +// File-version: 1 + + +interface Network { + event Conversion( + address indexed _smartToken, + address indexed _fromToken, + address indexed _toToken, + uint256 _fromAmount, + uint256 _toAmount, + address _trader + ); + function convert(address) external view returns (address); + function rateByPath(address,uint256) external view returns (uint256); +} diff --git a/Registry.sol b/Registry.sol new file mode 100644 index 0000000..efb96e4 --- /dev/null +++ b/Registry.sol @@ -0,0 +1,10 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// SPDX-License-Identifier: GPL-3.0-or-later +// File-version: 1 + + +interface Registry { + function addressOf(address) external view returns (address); +} diff --git a/TransferApproval.sol b/TransferApproval.sol index ddca3b3..b11ef9e 100644 --- a/TransferApproval.sol +++ b/TransferApproval.sol @@ -2,19 +2,18 @@ pragma solidity >=0.6.12; // Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 // SPDX-License-Identifier: GPL-3.0-or-later -// File-version: 1 +// File-version: 2 -abstract contract TransferApproval { - uint256 public serial; - mapping(uint256 => address) public requests; - mapping(address => bool) public approvers; - +interface TransferApproval { event NewRequest(address indexed _sender, address indexed _recipient, address indexed _token, uint256 _value, uint256 _serial); event NewExecution(uint256 serial); event NewRejection(uint256 serial); - function request(address _recipient, address _token, uint256 _value) public virtual returns (uint256); - function execute(uint256 _serial) public virtual returns (bool); - function reject(uint256 _serial) public virtual returns (bool); + function serial() external view returns (uint256); + function requests(uint256) external view returns (address); + function approvers(address) external view returns(bool); + function request(address _recipient, address _token, uint256 _value) external returns (uint256); + function execute(uint256 _serial) external returns (bool); + function reject(uint256 _serial) external returns (bool); }