Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interfaces to contract files and Jupyter Labs demo #18

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions contracts/interfaces/AddressProviderInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pragma solidity ^0.5.0;

interface AddressProvider {
event AddressModified (uint256 indexed id, address new_address, uint256 version);
event CommitNewAdmin (uint256 indexed deadline, address indexed admin);
event NewAddressIdentifier (uint256 indexed id, address addr, string description);
event NewAdmin (address indexed admin);

function add_new_id (address _address, string calldata _description) external returns (uint256);
function apply_transfer_ownership () external returns (bool);
function commit_transfer_ownership (address _new_admin) external returns (bool);
function revert_transfer_ownership () external returns (bool);
function set_address (uint256 _id, address _address) external returns (bool);
function unset_address (uint256 _id) external returns (bool);
function admin () external view returns (address);
function future_admin () external view returns (address);
function get_address (uint256 _id) external view returns (address);
function get_id_info (uint256 arg0) external view returns (address addr, bool is_active, uint256 version, uint256 last_modified, string memory description);
function get_registry () external view returns (address);
function max_id () external view returns (uint256);
function transfer_ownership_deadline () external view returns (uint256);
}
6 changes: 6 additions & 0 deletions contracts/interfaces/CurveCalcInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.0;

interface CurveCalc {
function get_dx (uint256 n_coins, uint256[8] calldata balances, uint256 amp, uint256 fee, uint256[8] calldata rates, uint256[8] calldata precisions, int128 i, int128 j, uint256 dy) external view returns (uint256);
function get_dy (uint256 n_coins, uint256[8] calldata balances, uint256 amp, uint256 fee, uint256[8] calldata rates, uint256[8] calldata precisions, int128 i, int128 j, uint256[100] calldata dx) external view returns (uint256[100] memory);
}
10 changes: 10 additions & 0 deletions contracts/interfaces/PoolInfoInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma solidity ^0.5.0;
pragma experimental ABIEncoderV2;

interface PoolInfo {
struct Tuple1 { uint256 A; uint256 future_A; uint256 fee; uint256 admin_fee; uint256 future_fee; uint256 future_admin_fee; address future_owner; uint256 initial_A; uint256 initial_A_time; uint256 future_A_time; }

function address_provider () external view returns (address);
function get_pool_coins (address _pool) external view returns (address[8] memory coins, address[8] memory underlying_coins, uint256[8] memory decimals, uint256[8] memory underlying_decimals);
function get_pool_info (address _pool) external view returns (uint256[8] memory balances, uint256[8] memory underlying_balances, uint256[8] memory decimals, uint256[8] memory underlying_decimals, uint256[8] memory rates, address lp_token, Tuple1 memory params);
}
39 changes: 39 additions & 0 deletions contracts/interfaces/RegistryInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pragma solidity ^0.5.0;

interface Registry {
event PoolAdded (address indexed pool, bytes rate_method_id);
event PoolRemoved (address indexed pool);

function add_metapool (address _pool, uint256 _n_coins, address _lp_token, uint256 _decimals) external;
function add_pool (address _pool, uint256 _n_coins, address _lp_token, bytes32 _rate_method_id, uint256 _decimals, uint256 _underlying_decimals, bool _has_initial_A, bool _is_v1) external;
function add_pool_without_underlying (address _pool, uint256 _n_coins, address _lp_token, bytes32 _rate_method_id, uint256 _decimals, uint256 _use_rates, bool _has_initial_A, bool _is_v1) external;
function remove_pool (address _pool) external;
function set_coin_gas_estimates (address[10] calldata _addr, uint256[10] calldata _amount) external;
function set_gas_estimate_contract (address _pool, address _estimator) external;
function set_liquidity_gauges (address _pool, address[10] calldata _liquidity_gauges) external;
function set_pool_gas_estimates (address[5] calldata _addr, uint256[2][5] calldata _amount) external;
function address_provider () external view returns (address);
function estimate_gas_used (address _pool, address _from, address _to) external view returns (uint256);
function find_pool_for_coins (address _from, address _to) external view returns (address);
function find_pool_for_coins (address _from, address _to, uint256 i) external view returns (address);
function gauge_controller () external view returns (address);
function get_A (address _pool) external view returns (uint256);
function get_admin_balances (address _pool) external view returns (uint256[8] memory);
function get_balances (address _pool) external view returns (uint256[8] memory);
function get_coin_indices (address _pool, address _from, address _to) external view returns (int128, int128, bool);
function get_coins (address _pool) external view returns (address[8] memory);
function get_decimals (address _pool) external view returns (uint256[8] memory);
function get_fees (address _pool) external view returns (uint256[2] memory);
function get_gauges (address _pool) external view returns (address[10] memory, int128[10] memory);
function get_lp_token (address arg0) external view returns (address);
function get_n_coins (address _pool) external view returns (uint256[2] memory);
function get_parameters (address _pool) external view returns (uint256 A, uint256 future_A, uint256 fee, uint256 admin_fee, uint256 future_fee, uint256 future_admin_fee, address future_owner, uint256 initial_A, uint256 initial_A_time, uint256 future_A_time);
function get_pool_from_lp_token (address arg0) external view returns (address);
function get_rates (address _pool) external view returns (uint256[8] memory);
function get_underlying_balances (address _pool) external view returns (uint256[8] memory);
function get_underlying_coins (address _pool) external view returns (address[8] memory);
function get_underlying_decimals (address _pool) external view returns (uint256[8] memory);
function get_virtual_price_from_lp_token (address _token) external view returns (uint256);
function pool_count () external view returns (uint256);
function pool_list (uint256 arg0) external view returns (address);
}
24 changes: 24 additions & 0 deletions contracts/interfaces/SwapsInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pragma solidity ^0.5.0;

interface Swaps {
event TokenExchange (address indexed buyer, address indexed receiver, address indexed pool, address token_sold, address token_bought, uint256 amount_sold, uint256 amount_bought);

function claim_balance (address _token) external returns (bool);
function set_calculator (address _pool, address _calculator) external returns (bool);
function set_default_calculator (address _calculator) external returns (bool);
function set_killed (bool _is_killed) external returns (bool);
function update_registry_address () external returns (bool);
function exchange (address _pool, address _from, address _to, uint256 _amount, uint256 _expected) external payable returns (uint256);
function exchange (address _pool, address _from, address _to, uint256 _amount, uint256 _expected, address _receiver) external payable returns (uint256);
function exchange_with_best_rate (address _from, address _to, uint256 _amount, uint256 _expected) external payable returns (uint256);
function exchange_with_best_rate (address _from, address _to, uint256 _amount, uint256 _expected, address _receiver) external payable returns (uint256);
function default_calculator () external view returns (address);
function get_best_rate (address _from, address _to, uint256 _amount) external view returns (address, uint256);
function get_calculator (address _pool) external view returns (address);
function get_exchange_amount (address _pool, address _from, address _to, uint256 _amount) external view returns (uint256);
function get_exchange_amounts (address _pool, address _from, address _to, uint256[100] calldata _amounts) external view returns (uint256[100] memory);
function get_input_amount (address _pool, address _from, address _to, uint256 _amount) external view returns (uint256);
function is_killed () external view returns (bool);
function registry () external view returns (address);
function () external payable;
}
1 change: 1 addition & 0 deletions demo/dai_exchange.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"name": "TokenPurchase", "inputs": [{"type": "address", "name": "buyer", "indexed": true}, {"type": "uint256", "name": "eth_sold", "indexed": true}, {"type": "uint256", "name": "tokens_bought", "indexed": true}], "anonymous": false, "type": "event"}, {"name": "EthPurchase", "inputs": [{"type": "address", "name": "buyer", "indexed": true}, {"type": "uint256", "name": "tokens_sold", "indexed": true}, {"type": "uint256", "name": "eth_bought", "indexed": true}], "anonymous": false, "type": "event"}, {"name": "AddLiquidity", "inputs": [{"type": "address", "name": "provider", "indexed": true}, {"type": "uint256", "name": "eth_amount", "indexed": true}, {"type": "uint256", "name": "token_amount", "indexed": true}], "anonymous": false, "type": "event"}, {"name": "RemoveLiquidity", "inputs": [{"type": "address", "name": "provider", "indexed": true}, {"type": "uint256", "name": "eth_amount", "indexed": true}, {"type": "uint256", "name": "token_amount", "indexed": true}], "anonymous": false, "type": "event"}, {"name": "Transfer", "inputs": [{"type": "address", "name": "_from", "indexed": true}, {"type": "address", "name": "_to", "indexed": true}, {"type": "uint256", "name": "_value", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "Approval", "inputs": [{"type": "address", "name": "_owner", "indexed": true}, {"type": "address", "name": "_spender", "indexed": true}, {"type": "uint256", "name": "_value", "indexed": false}], "anonymous": false, "type": "event"}, {"name": "setup", "outputs": [], "inputs": [{"type": "address", "name": "token_addr"}], "constant": false, "payable": false, "type": "function", "gas": 175875}, {"name": "addLiquidity", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "min_liquidity"}, {"type": "uint256", "name": "max_tokens"}, {"type": "uint256", "name": "deadline"}], "constant": false, "payable": true, "type": "function", "gas": 82616}, {"name": "removeLiquidity", "outputs": [{"type": "uint256", "name": "out"}, {"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "amount"}, {"type": "uint256", "name": "min_eth"}, {"type": "uint256", "name": "min_tokens"}, {"type": "uint256", "name": "deadline"}], "constant": false, "payable": false, "type": "function", "gas": 116814}, {"name": "__default__", "outputs": [], "inputs": [], "constant": false, "payable": true, "type": "function"}, {"name": "ethToTokenSwapInput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "min_tokens"}, {"type": "uint256", "name": "deadline"}], "constant": false, "payable": true, "type": "function", "gas": 12757}, {"name": "ethToTokenTransferInput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "min_tokens"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "recipient"}], "constant": false, "payable": true, "type": "function", "gas": 12965}, {"name": "ethToTokenSwapOutput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_bought"}, {"type": "uint256", "name": "deadline"}], "constant": false, "payable": true, "type": "function", "gas": 50463}, {"name": "ethToTokenTransferOutput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_bought"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "recipient"}], "constant": false, "payable": true, "type": "function", "gas": 50671}, {"name": "tokenToEthSwapInput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_sold"}, {"type": "uint256", "name": "min_eth"}, {"type": "uint256", "name": "deadline"}], "constant": false, "payable": false, "type": "function", "gas": 47503}, {"name": "tokenToEthTransferInput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_sold"}, {"type": "uint256", "name": "min_eth"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "recipient"}], "constant": false, "payable": false, "type": "function", "gas": 47712}, {"name": "tokenToEthSwapOutput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "eth_bought"}, {"type": "uint256", "name": "max_tokens"}, {"type": "uint256", "name": "deadline"}], "constant": false, "payable": false, "type": "function", "gas": 50175}, {"name": "tokenToEthTransferOutput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "eth_bought"}, {"type": "uint256", "name": "max_tokens"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "recipient"}], "constant": false, "payable": false, "type": "function", "gas": 50384}, {"name": "tokenToTokenSwapInput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_sold"}, {"type": "uint256", "name": "min_tokens_bought"}, {"type": "uint256", "name": "min_eth_bought"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "token_addr"}], "constant": false, "payable": false, "type": "function", "gas": 51007}, {"name": "tokenToTokenTransferInput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_sold"}, {"type": "uint256", "name": "min_tokens_bought"}, {"type": "uint256", "name": "min_eth_bought"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "recipient"}, {"type": "address", "name": "token_addr"}], "constant": false, "payable": false, "type": "function", "gas": 51098}, {"name": "tokenToTokenSwapOutput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_bought"}, {"type": "uint256", "name": "max_tokens_sold"}, {"type": "uint256", "name": "max_eth_sold"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "token_addr"}], "constant": false, "payable": false, "type": "function", "gas": 54928}, {"name": "tokenToTokenTransferOutput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_bought"}, {"type": "uint256", "name": "max_tokens_sold"}, {"type": "uint256", "name": "max_eth_sold"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "recipient"}, {"type": "address", "name": "token_addr"}], "constant": false, "payable": false, "type": "function", "gas": 55019}, {"name": "tokenToExchangeSwapInput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_sold"}, {"type": "uint256", "name": "min_tokens_bought"}, {"type": "uint256", "name": "min_eth_bought"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "exchange_addr"}], "constant": false, "payable": false, "type": "function", "gas": 49342}, {"name": "tokenToExchangeTransferInput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_sold"}, {"type": "uint256", "name": "min_tokens_bought"}, {"type": "uint256", "name": "min_eth_bought"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "recipient"}, {"type": "address", "name": "exchange_addr"}], "constant": false, "payable": false, "type": "function", "gas": 49532}, {"name": "tokenToExchangeSwapOutput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_bought"}, {"type": "uint256", "name": "max_tokens_sold"}, {"type": "uint256", "name": "max_eth_sold"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "exchange_addr"}], "constant": false, "payable": false, "type": "function", "gas": 53233}, {"name": "tokenToExchangeTransferOutput", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_bought"}, {"type": "uint256", "name": "max_tokens_sold"}, {"type": "uint256", "name": "max_eth_sold"}, {"type": "uint256", "name": "deadline"}, {"type": "address", "name": "recipient"}, {"type": "address", "name": "exchange_addr"}], "constant": false, "payable": false, "type": "function", "gas": 53423}, {"name": "getEthToTokenInputPrice", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "eth_sold"}], "constant": true, "payable": false, "type": "function", "gas": 5542}, {"name": "getEthToTokenOutputPrice", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_bought"}], "constant": true, "payable": false, "type": "function", "gas": 6872}, {"name": "getTokenToEthInputPrice", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "tokens_sold"}], "constant": true, "payable": false, "type": "function", "gas": 5637}, {"name": "getTokenToEthOutputPrice", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "uint256", "name": "eth_bought"}], "constant": true, "payable": false, "type": "function", "gas": 6897}, {"name": "tokenAddress", "outputs": [{"type": "address", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1413}, {"name": "factoryAddress", "outputs": [{"type": "address", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1443}, {"name": "balanceOf", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "address", "name": "_owner"}], "constant": true, "payable": false, "type": "function", "gas": 1645}, {"name": "transfer", "outputs": [{"type": "bool", "name": "out"}], "inputs": [{"type": "address", "name": "_to"}, {"type": "uint256", "name": "_value"}], "constant": false, "payable": false, "type": "function", "gas": 75034}, {"name": "transferFrom", "outputs": [{"type": "bool", "name": "out"}], "inputs": [{"type": "address", "name": "_from"}, {"type": "address", "name": "_to"}, {"type": "uint256", "name": "_value"}], "constant": false, "payable": false, "type": "function", "gas": 110907}, {"name": "approve", "outputs": [{"type": "bool", "name": "out"}], "inputs": [{"type": "address", "name": "_spender"}, {"type": "uint256", "name": "_value"}], "constant": false, "payable": false, "type": "function", "gas": 38769}, {"name": "allowance", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [{"type": "address", "name": "_owner"}, {"type": "address", "name": "_spender"}], "constant": true, "payable": false, "type": "function", "gas": 1925}, {"name": "name", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1623}, {"name": "symbol", "outputs": [{"type": "bytes32", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1653}, {"name": "decimals", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1683}, {"name": "totalSupply", "outputs": [{"type": "uint256", "name": "out"}], "inputs": [], "constant": true, "payable": false, "type": "function", "gas": 1713}]
Loading