created DummyPLPRegistry and DummyPLP + generated wrappers for these new contracts and their respective interfaces

This commit is contained in:
Daniel Pyrathon 2020-02-27 12:52:13 -08:00
parent 68fb6c2c27
commit 77d7afe505
17 changed files with 2376 additions and 3 deletions

View File

@ -0,0 +1,45 @@
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
contract DummyLiquidityProvider
{
constructor()
public
{}
/// @dev Quotes the amount of `makerToken` that would be obtained by
/// selling `sellAmount` of `takerToken`.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param sellAmount Amount of `takerToken` to sell.
/// @return makerTokenAmount Amount of `makerToken` that would be obtained.
function getSellQuote(
address takerToken,
address makerToken,
uint256 sellAmount
)
external
view
returns (uint256 makerTokenAmount) {
makerTokenAmount = sellAmount - 1;
}
/// @dev Quotes the amount of `takerToken` that would need to be sold in
/// order to obtain `buyAmount` of `makerToken`.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param buyAmount Amount of `makerToken` to buy.
/// @return takerTokenAmount Amount of `takerToken` that would need to be sold.
function getBuyQuote(
address takerToken,
address makerToken,
uint256 buyAmount
)
external
view
returns (uint256 takerTokenAmount) {
takerTokenAmount = buyAmount + 1;
}
}

View File

@ -0,0 +1,47 @@
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
contract DummyLiquidityProviderRegistry
{
address private constant NULL_ADDRESS = address(0x0);
constructor()
public
{}
mapping (address => mapping (address => address)) internal _gAddressBook;
/// @dev Sets address of pool for a market given market (xAsset, yAsset).
/// @param takerToken First asset managed by pool.
/// @param makerToken Second asset managed by pool.
/// @param poolAddress Address of pool.
function setLiquidityProviderForMarket(
address takerToken,
address makerToken,
address poolAddress
) external
{
_gAddressBook[takerToken][makerToken] = poolAddress;
_gAddressBook[makerToken][takerToken] = poolAddress;
}
/// @dev Returns the address of pool for a market given market (xAsset, yAsset), or reverts if pool does not exist.
/// @param takerToken First asset managed by pool.
/// @param makerToken Second asset managed by pool.
/// @return Address of pool.
function getLiquidityProviderForMarket(
address takerToken,
address makerToken
)
external
view
returns (address poolAddress)
{
poolAddress = _gAddressBook[takerToken][makerToken];
require(
poolAddress != NULL_ADDRESS,
"PLPRegistry/MARKET_PAIR_NOT_SET"
);
}
}

View File

@ -36,9 +36,9 @@
"compile:truffle": "truffle compile"
},
"config": {
"publicInterfaceContracts": "ERC20BridgeSampler,IERC20BridgeSampler,ILiquidityProvider,ILiquidityProviderRegistry",
"publicInterfaceContracts": "ERC20BridgeSampler,IERC20BridgeSampler,ILiquidityProvider,ILiquidityProviderRegistry,DummyLiquidityProviderRegistry,DummyLiquidityProvider",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
"abis": "./test/generated-artifacts/@(ERC20BridgeSampler|ICurve|IDevUtils|IERC20BridgeSampler|IEth2Dai|IKyberNetwork|ILiquidityProvider|ILiquidityProviderRegistry|IUniswapExchangeQuotes|TestERC20BridgeSampler).json"
"abis": "./test/generated-artifacts/@(DummyLiquidityProvider|DummyLiquidityProviderRegistry|ERC20BridgeSampler|ICurve|IDevUtils|IERC20BridgeSampler|IEth2Dai|IKyberNetwork|ILiquidityProvider|ILiquidityProviderRegistry|IUniswapExchangeQuotes|TestERC20BridgeSampler).json"
},
"repository": {
"type": "git",

View File

@ -5,6 +5,8 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as DummyLiquidityProvider from '../generated-artifacts/DummyLiquidityProvider.json';
import * as DummyLiquidityProviderRegistry from '../generated-artifacts/DummyLiquidityProviderRegistry.json';
import * as ERC20BridgeSampler from '../generated-artifacts/ERC20BridgeSampler.json';
import * as IERC20BridgeSampler from '../generated-artifacts/IERC20BridgeSampler.json';
import * as ILiquidityProvider from '../generated-artifacts/ILiquidityProvider.json';
@ -14,4 +16,6 @@ export const artifacts = {
IERC20BridgeSampler: IERC20BridgeSampler as ContractArtifact,
ILiquidityProvider: ILiquidityProvider as ContractArtifact,
ILiquidityProviderRegistry: ILiquidityProviderRegistry as ContractArtifact,
DummyLiquidityProviderRegistry: DummyLiquidityProviderRegistry as ContractArtifact,
DummyLiquidityProvider: DummyLiquidityProvider as ContractArtifact,
};

View File

@ -3,6 +3,8 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/dummy_liquidity_provider';
export * from '../generated-wrappers/dummy_liquidity_provider_registry';
export * from '../generated-wrappers/erc20_bridge_sampler';
export * from '../generated-wrappers/i_erc20_bridge_sampler';
export * from '../generated-wrappers/i_liquidity_provider';

View File

@ -5,6 +5,8 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as DummyLiquidityProvider from '../test/generated-artifacts/DummyLiquidityProvider.json';
import * as DummyLiquidityProviderRegistry from '../test/generated-artifacts/DummyLiquidityProviderRegistry.json';
import * as ERC20BridgeSampler from '../test/generated-artifacts/ERC20BridgeSampler.json';
import * as ICurve from '../test/generated-artifacts/ICurve.json';
import * as IDevUtils from '../test/generated-artifacts/IDevUtils.json';
@ -16,6 +18,8 @@ import * as ILiquidityProviderRegistry from '../test/generated-artifacts/ILiquid
import * as IUniswapExchangeQuotes from '../test/generated-artifacts/IUniswapExchangeQuotes.json';
import * as TestERC20BridgeSampler from '../test/generated-artifacts/TestERC20BridgeSampler.json';
export const artifacts = {
DummyLiquidityProvider: DummyLiquidityProvider as ContractArtifact,
DummyLiquidityProviderRegistry: DummyLiquidityProviderRegistry as ContractArtifact,
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
ICurve: ICurve as ContractArtifact,
IDevUtils: IDevUtils as ContractArtifact,

View File

@ -3,6 +3,8 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../test/generated-wrappers/dummy_liquidity_provider';
export * from '../test/generated-wrappers/dummy_liquidity_provider_registry';
export * from '../test/generated-wrappers/erc20_bridge_sampler';
export * from '../test/generated-wrappers/i_curve';
export * from '../test/generated-wrappers/i_dev_utils';

View File

@ -3,10 +3,14 @@
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"generated-artifacts/DummyLiquidityProvider.json",
"generated-artifacts/DummyLiquidityProviderRegistry.json",
"generated-artifacts/ERC20BridgeSampler.json",
"generated-artifacts/IERC20BridgeSampler.json",
"generated-artifacts/ILiquidityProvider.json",
"generated-artifacts/ILiquidityProviderRegistry.json",
"test/generated-artifacts/DummyLiquidityProvider.json",
"test/generated-artifacts/DummyLiquidityProviderRegistry.json",
"test/generated-artifacts/ERC20BridgeSampler.json",
"test/generated-artifacts/ICurve.json",
"test/generated-artifacts/IDevUtils.json",

View File

@ -0,0 +1,158 @@
{
"schemaVersion": "2.0.0",
"contractName": "DummyLiquidityProvider",
"compilerOutput": {
"abi": [
{
"inputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "takerToken",
"type": "address"
},
{
"internalType": "address",
"name": "makerToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "buyAmount",
"type": "uint256"
}
],
"name": "getBuyQuote",
"outputs": [
{
"internalType": "uint256",
"name": "takerTokenAmount",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "takerToken",
"type": "address"
},
{
"internalType": "address",
"name": "makerToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "sellAmount",
"type": "uint256"
}
],
"name": "getSellQuote",
"outputs": [
{
"internalType": "uint256",
"name": "makerTokenAmount",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
],
"devdoc": {
"methods": {
"getBuyQuote(address,address,uint256)": {
"details": "Quotes the amount of `takerToken` that would need to be sold in order to obtain `buyAmount` of `makerToken`.",
"params": {
"buyAmount": "Amount of `makerToken` to buy.",
"makerToken": "Address of the maker token (what to buy).",
"takerToken": "Address of the taker token (what to sell)."
},
"return": "takerTokenAmount Amount of `takerToken` that would need to be sold."
},
"getSellQuote(address,address,uint256)": {
"details": "Quotes the amount of `makerToken` that would be obtained by selling `sellAmount` of `takerToken`.",
"params": {
"makerToken": "Address of the maker token (what to buy).",
"sellAmount": "Amount of `takerToken` to sell.",
"takerToken": "Address of the taker token (what to sell)."
},
"return": "makerTokenAmount Amount of `makerToken` that would be obtained."
}
}
},
"evm": {
"bytecode": {
"linkReferences": {},
"object": "0x608060405234801561001057600080fd5b50610159806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063343fbcdd1461003b57806345060eb014610064575b600080fd5b61004e6100493660046100a8565b610077565b60405161005b91906100e8565b60405180910390f35b61004e6100723660046100a8565b61009f565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b60010192915050565b6000806000606084860312156100bc578283fd5b83356100c7816100f1565b925060208401356100d7816100f1565b929592945050506040919091013590565b90815260200190565b73ffffffffffffffffffffffffffffffffffffffff8116811461011357600080fd5b5056fea365627a7a723158202381fcfabad426957f70167a455c05b45e1a6babf4a85fb8887359d558fd68e46c6578706572696d656e74616cf564736f6c63430005100040",
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x159 DUP1 PUSH2 0x20 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN INVALID PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x4 CALLDATASIZE LT PUSH2 0x36 JUMPI PUSH1 0x0 CALLDATALOAD PUSH1 0xE0 SHR DUP1 PUSH4 0x343FBCDD EQ PUSH2 0x3B JUMPI DUP1 PUSH4 0x45060EB0 EQ PUSH2 0x64 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x4E PUSH2 0x49 CALLDATASIZE PUSH1 0x4 PUSH2 0xA8 JUMP JUMPDEST PUSH2 0x77 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0x5B SWAP2 SWAP1 PUSH2 0xE8 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0x4E PUSH2 0x72 CALLDATASIZE PUSH1 0x4 PUSH2 0xA8 JUMP JUMPDEST PUSH2 0x9F JUMP JUMPDEST PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ADD SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x1 ADD SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x0 PUSH1 0x60 DUP5 DUP7 SUB SLT ISZERO PUSH2 0xBC JUMPI DUP3 DUP4 REVERT JUMPDEST DUP4 CALLDATALOAD PUSH2 0xC7 DUP2 PUSH2 0xF1 JUMP JUMPDEST SWAP3 POP PUSH1 0x20 DUP5 ADD CALLDATALOAD PUSH2 0xD7 DUP2 PUSH2 0xF1 JUMP JUMPDEST SWAP3 SWAP6 SWAP3 SWAP5 POP POP POP PUSH1 0x40 SWAP2 SWAP1 SWAP2 ADD CALLDATALOAD SWAP1 JUMP JUMPDEST SWAP1 DUP2 MSTORE PUSH1 0x20 ADD SWAP1 JUMP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND DUP2 EQ PUSH2 0x113 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP JUMP INVALID LOG3 PUSH6 0x627A7A723158 KECCAK256 0x23 DUP2 0xFC STATICCALL 0xBA 0xD4 0x26 SWAP6 PUSH32 0x70167A455C05B45E1A6BABF4A85FB8887359D558FD68E46C6578706572696D65 PUSH15 0x74616CF564736F6C63430005100040 ",
"sourceMap": "61:1381:0:-;;;99:35;8:9:-1;5:2;;;30:1;27;20:12;5:2;99:35:0;61:1381;;;;;;"
},
"deployedBytecode": {
"linkReferences": {},
"object": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063343fbcdd1461003b57806345060eb014610064575b600080fd5b61004e6100493660046100a8565b610077565b60405161005b91906100e8565b60405180910390f35b61004e6100723660046100a8565b61009f565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b60010192915050565b6000806000606084860312156100bc578283fd5b83356100c7816100f1565b925060208401356100d7816100f1565b929592945050506040919091013590565b90815260200190565b73ffffffffffffffffffffffffffffffffffffffff8116811461011357600080fd5b5056fea365627a7a723158202381fcfabad426957f70167a455c05b45e1a6babf4a85fb8887359d558fd68e46c6578706572696d656e74616cf564736f6c63430005100040",
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x4 CALLDATASIZE LT PUSH2 0x36 JUMPI PUSH1 0x0 CALLDATALOAD PUSH1 0xE0 SHR DUP1 PUSH4 0x343FBCDD EQ PUSH2 0x3B JUMPI DUP1 PUSH4 0x45060EB0 EQ PUSH2 0x64 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x4E PUSH2 0x49 CALLDATASIZE PUSH1 0x4 PUSH2 0xA8 JUMP JUMPDEST PUSH2 0x77 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0x5B SWAP2 SWAP1 PUSH2 0xE8 JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0x4E PUSH2 0x72 CALLDATASIZE PUSH1 0x4 PUSH2 0xA8 JUMP JUMPDEST PUSH2 0x9F JUMP JUMPDEST PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ADD SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x1 ADD SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x0 PUSH1 0x60 DUP5 DUP7 SUB SLT ISZERO PUSH2 0xBC JUMPI DUP3 DUP4 REVERT JUMPDEST DUP4 CALLDATALOAD PUSH2 0xC7 DUP2 PUSH2 0xF1 JUMP JUMPDEST SWAP3 POP PUSH1 0x20 DUP5 ADD CALLDATALOAD PUSH2 0xD7 DUP2 PUSH2 0xF1 JUMP JUMPDEST SWAP3 SWAP6 SWAP3 SWAP5 POP POP POP PUSH1 0x40 SWAP2 SWAP1 SWAP2 ADD CALLDATALOAD SWAP1 JUMP JUMPDEST SWAP1 DUP2 MSTORE PUSH1 0x20 ADD SWAP1 JUMP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND DUP2 EQ PUSH2 0x113 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP JUMP INVALID LOG3 PUSH6 0x627A7A723158 KECCAK256 0x23 DUP2 0xFC STATICCALL 0xBA 0xD4 0x26 SWAP6 PUSH32 0x70167A455C05B45E1A6BABF4A85FB8887359D558FD68E46C6578706572696D65 PUSH15 0x74616CF564736F6C63430005100040 ",
"sourceMap": "61:1381:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;61:1381:0;;;;;;;;;;;;;;;;;;;;;;;;539:243;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;1200:240;;;;;;;;;:::i;539:243::-;757:14;;;539:243;-1:-1:-1;;539:243:0:o;1200:240::-;1428:1;1416:13;;1200:240;-1:-1:-1;;1200:240:0:o;279:491:-1:-;;;;417:2;405:9;396:7;392:23;388:32;385:2;;;-1:-1;;423:12;385:2;85:6;72:20;97:33;124:5;97:33;;;475:63;-1:-1;575:2;614:22;;72:20;97:33;72:20;97:33;;;379:391;;583:63;;-1:-1;;;683:2;722:22;;;;209:20;;379:391;897:213;848:37;;;1015:2;1000:18;;986:124;1422:117;1288:42;1509:5;1277:54;1484:5;1481:35;1471:2;;1530:1;;1520:12;1471:2;1465:74;"
}
}
},
"sources": {
"src/DummyLiquidityProvider.sol": {
"id": 0
}
},
"sourceCodes": {
"src/DummyLiquidityProvider.sol": "pragma solidity ^0.5.9;\npragma experimental ABIEncoderV2;\n\n\n\ncontract DummyLiquidityProvider\n{\n constructor()\n public\n {}\n\n /// @dev Quotes the amount of `makerToken` that would be obtained by\n /// selling `sellAmount` of `takerToken`.\n /// @param takerToken Address of the taker token (what to sell).\n /// @param makerToken Address of the maker token (what to buy).\n /// @param sellAmount Amount of `takerToken` to sell.\n /// @return makerTokenAmount Amount of `makerToken` that would be obtained.\n function getSellQuote(\n address takerToken,\n address makerToken,\n uint256 sellAmount\n )\n external\n view\n returns (uint256 makerTokenAmount) {\n makerTokenAmount = sellAmount - 1;\n }\n\n /// @dev Quotes the amount of `takerToken` that would need to be sold in\n /// order to obtain `buyAmount` of `makerToken`.\n /// @param takerToken Address of the taker token (what to sell).\n /// @param makerToken Address of the maker token (what to buy).\n /// @param buyAmount Amount of `makerToken` to buy.\n /// @return takerTokenAmount Amount of `takerToken` that would need to be sold.\n function getBuyQuote(\n address takerToken,\n address makerToken,\n uint256 buyAmount\n )\n external\n view\n returns (uint256 takerTokenAmount) {\n takerTokenAmount = buyAmount + 1;\n }\n}"
},
"sourceTreeHashHex": "0x5962f24dc9460337e176690d71cba0289aec29cd924cdc5eedd32a32147ae773",
"compiler": {
"name": "solc",
"version": "soljson-v0.5.16+commit.9c3226ce.js",
"settings": {
"optimizer": {
"enabled": true,
"runs": 1000000,
"details": {
"yul": true,
"deduplicate": true,
"cse": true,
"constantOptimizer": true
}
},
"outputSelection": {
"*": {
"*": [
"abi",
"devdoc",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap"
]
}
},
"evmVersion": "istanbul",
"remappings": [
"@0x/contracts-asset-proxy=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-asset-proxy",
"@0x/contracts-erc20=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-erc20",
"@0x/contracts-utils=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-utils",
"@0x/contracts-exchange-libs=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-exchange-libs",
"@0x/contracts-exchange=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-exchange"
]
}
},
"chains": {}
}

View File

@ -0,0 +1,145 @@
{
"schemaVersion": "2.0.0",
"contractName": "DummyLiquidityProviderRegistry",
"compilerOutput": {
"abi": [
{
"inputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "takerToken",
"type": "address"
},
{
"internalType": "address",
"name": "makerToken",
"type": "address"
}
],
"name": "getLiquidityProviderForMarket",
"outputs": [
{
"internalType": "address",
"name": "poolAddress",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "takerToken",
"type": "address"
},
{
"internalType": "address",
"name": "makerToken",
"type": "address"
},
{
"internalType": "address",
"name": "poolAddress",
"type": "address"
}
],
"name": "setLiquidityProviderForMarket",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
],
"devdoc": {
"methods": {
"getLiquidityProviderForMarket(address,address)": {
"details": "Returns the address of pool for a market given market (xAsset, yAsset), or reverts if pool does not exist.",
"params": {
"makerToken": "Second asset managed by pool.",
"takerToken": "First asset managed by pool."
},
"return": "Address of pool."
},
"setLiquidityProviderForMarket(address,address,address)": {
"details": "Sets address of pool for a market given market (xAsset, yAsset).",
"params": {
"makerToken": "Second asset managed by pool.",
"poolAddress": "Address of pool.",
"takerToken": "First asset managed by pool."
}
}
}
},
"evm": {
"bytecode": {
"linkReferences": {},
"object": "0x608060405234801561001057600080fd5b506102a6806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063153f59971461003b57806384da8d1e14610064575b600080fd5b61004e610049366004610192565b610079565b60405161005b919061020b565b60405180910390f35b6100776100723660046101c6565b6100f2565b005b73ffffffffffffffffffffffffffffffffffffffff808316600090815260208181526040808320858516845290915290205416806100ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100e39061022c565b60405180910390fd5b92915050565b73ffffffffffffffffffffffffffffffffffffffff92831660008181526020818152604080832095871683529481528482208054969094167fffffffffffffffffffffffff0000000000000000000000000000000000000000968716811790945581815284822092825291909152919091208054909216179055565b803573ffffffffffffffffffffffffffffffffffffffff811681146100ec57600080fd5b600080604083850312156101a4578182fd5b6101ae848461016e565b91506101bd846020850161016e565b90509250929050565b6000806000606084860312156101da578081fd5b6101e4858561016e565b92506101f3856020860161016e565b9150610202856040860161016e565b90509250925092565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b6020808252601f908201527f504c5052656769737472792f4d41524b45545f504149525f4e4f545f5345540060408201526060019056fea365627a7a72315820dfca03fa4d379650583603297046e76030ec42276b00a6b7f03c08391d9546c46c6578706572696d656e74616cf564736f6c63430005100040",
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH2 0x2A6 DUP1 PUSH2 0x20 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN INVALID PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x4 CALLDATASIZE LT PUSH2 0x36 JUMPI PUSH1 0x0 CALLDATALOAD PUSH1 0xE0 SHR DUP1 PUSH4 0x153F5997 EQ PUSH2 0x3B JUMPI DUP1 PUSH4 0x84DA8D1E EQ PUSH2 0x64 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x4E PUSH2 0x49 CALLDATASIZE PUSH1 0x4 PUSH2 0x192 JUMP JUMPDEST PUSH2 0x79 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0x5B SWAP2 SWAP1 PUSH2 0x20B JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0x77 PUSH2 0x72 CALLDATASIZE PUSH1 0x4 PUSH2 0x1C6 JUMP JUMPDEST PUSH2 0xF2 JUMP JUMPDEST STOP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP1 DUP4 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x20 DUP2 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 DUP6 DUP6 AND DUP5 MSTORE SWAP1 SWAP2 MSTORE SWAP1 KECCAK256 SLOAD AND DUP1 PUSH2 0xEC JUMPI PUSH1 0x40 MLOAD PUSH32 0x8C379A000000000000000000000000000000000000000000000000000000000 DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0xE3 SWAP1 PUSH2 0x22C JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 REVERT JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP3 DUP4 AND PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 SWAP6 DUP8 AND DUP4 MSTORE SWAP5 DUP2 MSTORE DUP5 DUP3 KECCAK256 DUP1 SLOAD SWAP7 SWAP1 SWAP5 AND PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000 SWAP7 DUP8 AND DUP2 OR SWAP1 SWAP5 SSTORE DUP2 DUP2 MSTORE DUP5 DUP3 KECCAK256 SWAP3 DUP3 MSTORE SWAP2 SWAP1 SWAP2 MSTORE SWAP2 SWAP1 SWAP2 KECCAK256 DUP1 SLOAD SWAP1 SWAP3 AND OR SWAP1 SSTORE JUMP JUMPDEST DUP1 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND DUP2 EQ PUSH2 0xEC JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x40 DUP4 DUP6 SUB SLT ISZERO PUSH2 0x1A4 JUMPI DUP2 DUP3 REVERT JUMPDEST PUSH2 0x1AE DUP5 DUP5 PUSH2 0x16E JUMP JUMPDEST SWAP2 POP PUSH2 0x1BD DUP5 PUSH1 0x20 DUP6 ADD PUSH2 0x16E JUMP JUMPDEST SWAP1 POP SWAP3 POP SWAP3 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x0 PUSH1 0x60 DUP5 DUP7 SUB SLT ISZERO PUSH2 0x1DA JUMPI DUP1 DUP2 REVERT JUMPDEST PUSH2 0x1E4 DUP6 DUP6 PUSH2 0x16E JUMP JUMPDEST SWAP3 POP PUSH2 0x1F3 DUP6 PUSH1 0x20 DUP7 ADD PUSH2 0x16E JUMP JUMPDEST SWAP2 POP PUSH2 0x202 DUP6 PUSH1 0x40 DUP7 ADD PUSH2 0x16E JUMP JUMPDEST SWAP1 POP SWAP3 POP SWAP3 POP SWAP3 JUMP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP2 SWAP1 SWAP2 AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 JUMP JUMPDEST PUSH1 0x20 DUP1 DUP3 MSTORE PUSH1 0x1F SWAP1 DUP3 ADD MSTORE PUSH32 0x504C5052656769737472792F4D41524B45545F504149525F4E4F545F53455400 PUSH1 0x40 DUP3 ADD MSTORE PUSH1 0x60 ADD SWAP1 JUMP INVALID LOG3 PUSH6 0x627A7A723158 KECCAK256 0xDF 0xCA SUB STATICCALL 0x4D CALLDATACOPY SWAP7 POP PC CALLDATASIZE SUB 0x29 PUSH17 0x46E76030EC42276B00A6B7F03C08391D95 CHAINID 0xC4 PUSH13 0x6578706572696D656E74616CF5 PUSH5 0x736F6C6343 STOP SDIV LT STOP BLOCKHASH ",
"sourceMap": "60:1358:1:-;;;165:35;8:9:-1;5:2;;;30:1;27;20:12;5:2;165:35:1;60:1358;;;;;;"
},
"deployedBytecode": {
"linkReferences": {},
"object": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063153f59971461003b57806384da8d1e14610064575b600080fd5b61004e610049366004610192565b610079565b60405161005b919061020b565b60405180910390f35b6100776100723660046101c6565b6100f2565b005b73ffffffffffffffffffffffffffffffffffffffff808316600090815260208181526040808320858516845290915290205416806100ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100e39061022c565b60405180910390fd5b92915050565b73ffffffffffffffffffffffffffffffffffffffff92831660008181526020818152604080832095871683529481528482208054969094167fffffffffffffffffffffffff0000000000000000000000000000000000000000968716811790945581815284822092825291909152919091208054909216179055565b803573ffffffffffffffffffffffffffffffffffffffff811681146100ec57600080fd5b600080604083850312156101a4578182fd5b6101ae848461016e565b91506101bd846020850161016e565b90509250929050565b6000806000606084860312156101da578081fd5b6101e4858561016e565b92506101f3856020860161016e565b9150610202856040860161016e565b90509250925092565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b6020808252601f908201527f504c5052656769737472792f4d41524b45545f504149525f4e4f545f5345540060408201526060019056fea365627a7a72315820dfca03fa4d379650583603297046e76030ec42276b00a6b7f03c08391d9546c46c6578706572696d656e74616cf564736f6c63430005100040",
"opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH2 0x10 JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP PUSH1 0x4 CALLDATASIZE LT PUSH2 0x36 JUMPI PUSH1 0x0 CALLDATALOAD PUSH1 0xE0 SHR DUP1 PUSH4 0x153F5997 EQ PUSH2 0x3B JUMPI DUP1 PUSH4 0x84DA8D1E EQ PUSH2 0x64 JUMPI JUMPDEST PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH2 0x4E PUSH2 0x49 CALLDATASIZE PUSH1 0x4 PUSH2 0x192 JUMP JUMPDEST PUSH2 0x79 JUMP JUMPDEST PUSH1 0x40 MLOAD PUSH2 0x5B SWAP2 SWAP1 PUSH2 0x20B JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 RETURN JUMPDEST PUSH2 0x77 PUSH2 0x72 CALLDATASIZE PUSH1 0x4 PUSH2 0x1C6 JUMP JUMPDEST PUSH2 0xF2 JUMP JUMPDEST STOP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP1 DUP4 AND PUSH1 0x0 SWAP1 DUP2 MSTORE PUSH1 0x20 DUP2 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 DUP6 DUP6 AND DUP5 MSTORE SWAP1 SWAP2 MSTORE SWAP1 KECCAK256 SLOAD AND DUP1 PUSH2 0xEC JUMPI PUSH1 0x40 MLOAD PUSH32 0x8C379A000000000000000000000000000000000000000000000000000000000 DUP2 MSTORE PUSH1 0x4 ADD PUSH2 0xE3 SWAP1 PUSH2 0x22C JUMP JUMPDEST PUSH1 0x40 MLOAD DUP1 SWAP2 SUB SWAP1 REVERT JUMPDEST SWAP3 SWAP2 POP POP JUMP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP3 DUP4 AND PUSH1 0x0 DUP2 DUP2 MSTORE PUSH1 0x20 DUP2 DUP2 MSTORE PUSH1 0x40 DUP1 DUP4 KECCAK256 SWAP6 DUP8 AND DUP4 MSTORE SWAP5 DUP2 MSTORE DUP5 DUP3 KECCAK256 DUP1 SLOAD SWAP7 SWAP1 SWAP5 AND PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000 SWAP7 DUP8 AND DUP2 OR SWAP1 SWAP5 SSTORE DUP2 DUP2 MSTORE DUP5 DUP3 KECCAK256 SWAP3 DUP3 MSTORE SWAP2 SWAP1 SWAP2 MSTORE SWAP2 SWAP1 SWAP2 KECCAK256 DUP1 SLOAD SWAP1 SWAP3 AND OR SWAP1 SSTORE JUMP JUMPDEST DUP1 CALLDATALOAD PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF DUP2 AND DUP2 EQ PUSH2 0xEC JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x40 DUP4 DUP6 SUB SLT ISZERO PUSH2 0x1A4 JUMPI DUP2 DUP3 REVERT JUMPDEST PUSH2 0x1AE DUP5 DUP5 PUSH2 0x16E JUMP JUMPDEST SWAP2 POP PUSH2 0x1BD DUP5 PUSH1 0x20 DUP6 ADD PUSH2 0x16E JUMP JUMPDEST SWAP1 POP SWAP3 POP SWAP3 SWAP1 POP JUMP JUMPDEST PUSH1 0x0 DUP1 PUSH1 0x0 PUSH1 0x60 DUP5 DUP7 SUB SLT ISZERO PUSH2 0x1DA JUMPI DUP1 DUP2 REVERT JUMPDEST PUSH2 0x1E4 DUP6 DUP6 PUSH2 0x16E JUMP JUMPDEST SWAP3 POP PUSH2 0x1F3 DUP6 PUSH1 0x20 DUP7 ADD PUSH2 0x16E JUMP JUMPDEST SWAP2 POP PUSH2 0x202 DUP6 PUSH1 0x40 DUP7 ADD PUSH2 0x16E JUMP JUMPDEST SWAP1 POP SWAP3 POP SWAP3 POP SWAP3 JUMP JUMPDEST PUSH20 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF SWAP2 SWAP1 SWAP2 AND DUP2 MSTORE PUSH1 0x20 ADD SWAP1 JUMP JUMPDEST PUSH1 0x20 DUP1 DUP3 MSTORE PUSH1 0x1F SWAP1 DUP3 ADD MSTORE PUSH32 0x504C5052656769737472792F4D41524B45545F504149525F4E4F545F53455400 PUSH1 0x40 DUP3 ADD MSTORE PUSH1 0x60 ADD SWAP1 JUMP INVALID LOG3 PUSH6 0x627A7A723158 KECCAK256 0xDF 0xCA SUB STATICCALL 0x4D CALLDATACOPY SWAP7 POP PC CALLDATASIZE SUB 0x29 PUSH17 0x46E76030EC42276B00A6B7F03C08391D95 CHAINID 0xC4 PUSH13 0x6578706572696D656E74616CF5 PUSH5 0x736F6C6343 STOP SDIV LT STOP BLOCKHASH ",
"sourceMap": "60:1358:1:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;60:1358:1;;;;;;;;;;;;;;;;;;;;;;;;1060:356;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;518:272;;;;;;;;;:::i;:::-;;1060:356;1257:25;;;;1208:19;1257:25;;;;;;;;;;;:37;;;;;;;;;;;;1325:27;1304:105;;;;;;;;;;;;;;;;;;;;;;1060:356;;;;:::o;518:272::-;671:25;;;;:13;:25;;;;;;;;;;;:37;;;;;;;;;;;:51;;;;;;;;;;;;;;;732:25;;;;;;:37;;;;;;;;;;;:51;;;;;;;;518:272::o;5:130:-1:-;72:20;;2450:42;2439:54;;2564:35;;2554:2;;2613:1;;2603:12;142:366;;;263:2;251:9;242:7;238:23;234:32;231:2;;;-1:-1;;269:12;231:2;331:53;376:7;352:22;331:53;;;321:63;;439:53;484:7;421:2;464:9;460:22;439:53;;;429:63;;225:283;;;;;;515:491;;;;653:2;641:9;632:7;628:23;624:32;621:2;;;-1:-1;;659:12;621:2;721:53;766:7;742:22;721:53;;;711:63;;829:53;874:7;811:2;854:9;850:22;829:53;;;819:63;;937:53;982:7;919:2;962:9;958:22;937:53;;;927:63;;615:391;;;;;;1473:213;2450:42;2439:54;;;;1084:37;;1591:2;1576:18;;1562:124;1693:407;1884:2;1898:47;;;1358:2;1869:18;;;2211:19;1394:33;2251:14;;;1374:54;1447:12;;;1855:245"
}
}
},
"sources": {
"src/DummyLiquidityProviderRegistry.sol": {
"id": 1
}
},
"sourceCodes": {
"src/DummyLiquidityProviderRegistry.sol": "pragma solidity ^0.5.9;\npragma experimental ABIEncoderV2;\n\n\ncontract DummyLiquidityProviderRegistry\n{\n address private constant NULL_ADDRESS = address(0x0);\n\n constructor()\n public\n {}\n\n mapping (address => mapping (address => address)) internal _gAddressBook;\n\n /// @dev Sets address of pool for a market given market (xAsset, yAsset).\n /// @param takerToken First asset managed by pool.\n /// @param makerToken Second asset managed by pool.\n /// @param poolAddress Address of pool.\n function setLiquidityProviderForMarket(\n address takerToken,\n address makerToken,\n address poolAddress\n ) external\n {\n _gAddressBook[takerToken][makerToken] = poolAddress;\n _gAddressBook[makerToken][takerToken] = poolAddress;\n }\n\n /// @dev Returns the address of pool for a market given market (xAsset, yAsset), or reverts if pool does not exist.\n /// @param takerToken First asset managed by pool.\n /// @param makerToken Second asset managed by pool.\n /// @return Address of pool.\n function getLiquidityProviderForMarket(\n address takerToken,\n address makerToken\n )\n external\n view\n returns (address poolAddress)\n {\n poolAddress = _gAddressBook[takerToken][makerToken];\n require(\n poolAddress != NULL_ADDRESS,\n \"PLPRegistry/MARKET_PAIR_NOT_SET\"\n );\n }\n}"
},
"sourceTreeHashHex": "0xd6e837cf3e13f77bd67de974e401884b26df577e7a9e4bb24a05d22f9b5ed031",
"compiler": {
"name": "solc",
"version": "soljson-v0.5.16+commit.9c3226ce.js",
"settings": {
"optimizer": {
"enabled": true,
"runs": 1000000,
"details": {
"yul": true,
"deduplicate": true,
"cse": true,
"constantOptimizer": true
}
},
"outputSelection": {
"*": {
"*": [
"abi",
"devdoc",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap"
]
}
},
"evmVersion": "istanbul",
"remappings": [
"@0x/contracts-asset-proxy=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-asset-proxy",
"@0x/contracts-erc20=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-erc20",
"@0x/contracts-utils=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-utils",
"@0x/contracts-exchange-libs=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-exchange-libs",
"@0x/contracts-exchange=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-exchange"
]
}
},
"chains": {}
}

View File

@ -0,0 +1,204 @@
{
"schemaVersion": "2.0.0",
"contractName": "ILiquidityProvider",
"compilerOutput": {
"abi": [
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
},
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "bridgeData",
"type": "bytes"
}
],
"name": "bridgeTransferFrom",
"outputs": [
{
"internalType": "bytes4",
"name": "success",
"type": "bytes4"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "takerToken",
"type": "address"
},
{
"internalType": "address",
"name": "makerToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "buyAmount",
"type": "uint256"
}
],
"name": "getBuyQuote",
"outputs": [
{
"internalType": "uint256",
"name": "takerTokenAmount",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "takerToken",
"type": "address"
},
{
"internalType": "address",
"name": "makerToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "sellAmount",
"type": "uint256"
}
],
"name": "getSellQuote",
"outputs": [
{
"internalType": "uint256",
"name": "makerTokenAmount",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
],
"devdoc": {
"methods": {
"bridgeTransferFrom(address,address,address,uint256,bytes)": {
"details": "Transfers `amount` of the ERC20 `tokenAddress` from `from` to `to`.",
"params": {
"amount": "Amount of asset to transfer.",
"bridgeData": "Arbitrary asset data needed by the bridge contract.",
"from": "Address to transfer asset from.",
"to": "Address to transfer asset to.",
"tokenAddress": "The address of the ERC20 token to transfer."
},
"return": "success The magic bytes `0xdc1600f3` if successful."
},
"getBuyQuote(address,address,uint256)": {
"details": "Quotes the amount of `takerToken` that would need to be sold in order to obtain `buyAmount` of `makerToken`.",
"params": {
"buyAmount": "Amount of `makerToken` to buy.",
"makerToken": "Address of the maker token (what to buy).",
"takerToken": "Address of the taker token (what to sell)."
},
"return": "takerTokenAmount Amount of `takerToken` that would need to be sold."
},
"getSellQuote(address,address,uint256)": {
"details": "Quotes the amount of `makerToken` that would be obtained by selling `sellAmount` of `takerToken`.",
"params": {
"makerToken": "Address of the maker token (what to buy).",
"sellAmount": "Amount of `takerToken` to sell.",
"takerToken": "Address of the taker token (what to sell)."
},
"return": "makerTokenAmount Amount of `makerToken` that would be obtained."
}
}
},
"evm": {
"bytecode": {
"linkReferences": {},
"object": "0x",
"opcodes": "",
"sourceMap": ""
},
"deployedBytecode": {
"linkReferences": {},
"object": "0x",
"opcodes": "",
"sourceMap": ""
}
}
},
"sources": {
"src/ILiquidityProvider.sol": {
"id": 8
}
},
"sourceCodes": {
"src/ILiquidityProvider.sol": "/*\n\n Copyright 2019 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.5.9;\n\n\ninterface ILiquidityProvider {\n\n /// @dev Transfers `amount` of the ERC20 `tokenAddress` from `from` to `to`.\n /// @param tokenAddress The address of the ERC20 token to transfer.\n /// @param from Address to transfer asset from.\n /// @param to Address to transfer asset to.\n /// @param amount Amount of asset to transfer.\n /// @param bridgeData Arbitrary asset data needed by the bridge contract.\n /// @return success The magic bytes `0xdc1600f3` if successful.\n function bridgeTransferFrom(\n address tokenAddress,\n address from,\n address to,\n uint256 amount,\n bytes calldata bridgeData\n )\n external\n returns (bytes4 success);\n\n /// @dev Quotes the amount of `makerToken` that would be obtained by\n /// selling `sellAmount` of `takerToken`.\n /// @param takerToken Address of the taker token (what to sell).\n /// @param makerToken Address of the maker token (what to buy).\n /// @param sellAmount Amount of `takerToken` to sell.\n /// @return makerTokenAmount Amount of `makerToken` that would be obtained.\n function getSellQuote(\n address takerToken,\n address makerToken,\n uint256 sellAmount\n )\n external\n view\n returns (uint256 makerTokenAmount);\n\n /// @dev Quotes the amount of `takerToken` that would need to be sold in\n /// order to obtain `buyAmount` of `makerToken`.\n /// @param takerToken Address of the taker token (what to sell).\n /// @param makerToken Address of the maker token (what to buy).\n /// @param buyAmount Amount of `makerToken` to buy.\n /// @return takerTokenAmount Amount of `takerToken` that would need to be sold.\n function getBuyQuote(\n address takerToken,\n address makerToken,\n uint256 buyAmount\n )\n external\n view\n returns (uint256 takerTokenAmount);\n}\n"
},
"sourceTreeHashHex": "0x3aa914bd3a043f6b6d9bfa0670279ac5544994c2fe62d4764879b109ee620699",
"compiler": {
"name": "solc",
"version": "soljson-v0.5.16+commit.9c3226ce.js",
"settings": {
"optimizer": {
"enabled": true,
"runs": 1000000,
"details": {
"yul": true,
"deduplicate": true,
"cse": true,
"constantOptimizer": true
}
},
"outputSelection": {
"*": {
"*": [
"abi",
"devdoc",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap"
]
}
},
"evmVersion": "istanbul",
"remappings": [
"@0x/contracts-asset-proxy=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-asset-proxy",
"@0x/contracts-erc20=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-erc20",
"@0x/contracts-utils=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-utils",
"@0x/contracts-exchange-libs=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-exchange-libs",
"@0x/contracts-exchange=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-exchange"
]
}
},
"chains": {}
}

View File

@ -0,0 +1,106 @@
{
"schemaVersion": "2.0.0",
"contractName": "ILiquidityProviderRegistry",
"compilerOutput": {
"abi": [
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "takerToken",
"type": "address"
},
{
"internalType": "address",
"name": "makerToken",
"type": "address"
}
],
"name": "getLiquidityProviderForMarket",
"outputs": [
{
"internalType": "address",
"name": "providerAddress",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
],
"devdoc": {
"methods": {
"getLiquidityProviderForMarket(address,address)": {
"details": "Returns the address of a liquidity provider for the given market (takerToken, makerToken), reverting if the pool does not exist.",
"params": {
"makerToken": "Maker asset managed by liquidity provider.",
"takerToken": "Taker asset managed by liquidity provider."
},
"return": "Address of the liquidity provider."
}
}
},
"evm": {
"bytecode": {
"linkReferences": {},
"object": "0x",
"opcodes": "",
"sourceMap": ""
},
"deployedBytecode": {
"linkReferences": {},
"object": "0x",
"opcodes": "",
"sourceMap": ""
}
}
},
"sources": {
"src/ILiquidityProviderRegistry.sol": {
"id": 9
}
},
"sourceCodes": {
"src/ILiquidityProviderRegistry.sol": "/*\n\n Copyright 2019 ZeroEx Intl.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.5.9;\n\n\ninterface ILiquidityProviderRegistry {\n\n /// @dev Returns the address of a liquidity provider for the given market\n /// (takerToken, makerToken), reverting if the pool does not exist.\n /// @param takerToken Taker asset managed by liquidity provider.\n /// @param makerToken Maker asset managed by liquidity provider.\n /// @return Address of the liquidity provider.\n function getLiquidityProviderForMarket(\n address takerToken,\n address makerToken\n )\n external\n view\n returns (address providerAddress);\n}\n"
},
"sourceTreeHashHex": "0x580f250d5134c119fad782c3e9cd3762e3ebd9af20b9768f257c2a0544e62d88",
"compiler": {
"name": "solc",
"version": "soljson-v0.5.16+commit.9c3226ce.js",
"settings": {
"optimizer": {
"enabled": true,
"runs": 1000000,
"details": {
"yul": true,
"deduplicate": true,
"cse": true,
"constantOptimizer": true
}
},
"outputSelection": {
"*": {
"*": [
"abi",
"devdoc",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap"
]
}
},
"evmVersion": "istanbul",
"remappings": [
"@0x/contracts-asset-proxy=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-asset-proxy",
"@0x/contracts-erc20=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-erc20",
"@0x/contracts-utils=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-utils",
"@0x/contracts-exchange-libs=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-exchange-libs",
"@0x/contracts-exchange=/Users/danielpyrathon/Desktop/Projects/0x-monorepo/contracts/erc20-bridge-sampler/node_modules/@0x/contracts-exchange"
]
}
},
"chains": {}
}

View File

@ -31,7 +31,7 @@
"wrappers:generate": "abi-gen --abis ${npm_package_config_abis} --output src/generated-wrappers --backend ethers"
},
"config": {
"abis": "../contract-artifacts/artifacts/@(DevUtils|ERC20Token|ERC721Token|Exchange|Forwarder|IAssetData|LibTransactionDecoder|WETH9|Coordinator|Staking|StakingProxy|IERC20BridgeSampler|GodsUnchainedValidator|Broker).json"
"abis": "../contract-artifacts/artifacts/@(DevUtils|ERC20Token|ERC721Token|Exchange|Forwarder|IAssetData|LibTransactionDecoder|WETH9|Coordinator|Staking|StakingProxy|IERC20BridgeSampler|GodsUnchainedValidator|Broker|ILiquidityProvider|ILiquidityProviderRegistry|DummyLiquidityProvider|DummyLiquidityProviderRegistry).json"
},
"repository": {
"type": "git",

View File

@ -0,0 +1,406 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable
import {
AwaitTransactionSuccessOpts,
ContractFunctionObj,
ContractTxFunctionObj,
SendTransactionOpts,
BaseContract,
PromiseWithTransactionHash,
methodAbiToFunctionSignature,
linkLibrariesInBytecode,
} from '@0x/base-contract';
import { schemas } from '@0x/json-schemas';
import {
BlockParam,
BlockParamLiteral,
BlockRange,
CallData,
ContractAbi,
ContractArtifact,
DecodedLogArgs,
MethodAbi,
TransactionReceiptWithDecodedLogs,
TxData,
TxDataPayable,
SupportedProvider,
} from 'ethereum-types';
import { BigNumber, classUtils, hexUtils, logUtils, providerUtils } from '@0x/utils';
import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert';
import * as ethers from 'ethers';
// tslint:enable:no-unused-variable
/* istanbul ignore next */
// tslint:disable:array-type
// tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name
export class DummyLiquidityProviderContract extends BaseContract {
/**
* @ignore
*/
public static deployedBytecode: string | undefined;
public static contractName = 'DummyLiquidityProvider';
private readonly _methodABIIndex: { [name: string]: number } = {};
public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<DummyLiquidityProviderContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
return DummyLiquidityProviderContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
}
public static async deployWithLibrariesFrom0xArtifactAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<DummyLiquidityProviderContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
const libraryAddresses = await DummyLiquidityProviderContract._deployLibrariesAsync(
artifact,
libraryArtifacts,
new Web3Wrapper(provider),
txDefaults
);
const bytecode = linkLibrariesInBytecode(
artifact,
libraryAddresses,
);
return DummyLiquidityProviderContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
}
public static async deployAsync(
bytecode: string,
abi: ContractAbi,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractAbi },
): Promise<DummyLiquidityProviderContract> {
assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: txData,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`DummyLiquidityProvider successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new DummyLiquidityProviderContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
contractInstance.constructorArgs = [];
return contractInstance;
}
/**
* @returns The contract ABI
*/
public static ABI(): ContractAbi {
const abi = [
{
inputs: [
],
outputs: [
],
payable: false,
stateMutability: 'nonpayable',
type: 'constructor',
},
{
constant: true,
inputs: [
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerToken',
type: 'address',
},
{
name: 'buyAmount',
type: 'uint256',
},
],
name: 'getBuyQuote',
outputs: [
{
name: 'takerTokenAmount',
type: 'uint256',
},
],
payable: false,
stateMutability: 'view',
type: 'function',
},
{
constant: true,
inputs: [
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerToken',
type: 'address',
},
{
name: 'sellAmount',
type: 'uint256',
},
],
name: 'getSellQuote',
outputs: [
{
name: 'makerTokenAmount',
type: 'uint256',
},
],
payable: false,
stateMutability: 'view',
type: 'function',
},
] as ContractAbi;
return abi;
}
protected static async _deployLibrariesAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
web3Wrapper: Web3Wrapper,
txDefaults: Partial<TxData>,
libraryAddresses: { [libraryName: string]: string } = {},
): Promise<{ [libraryName: string]: string }> {
const links = artifact.compilerOutput.evm.bytecode.linkReferences;
// Go through all linked libraries, recursively deploying them if necessary.
for (const link of Object.values(links)) {
for (const libraryName of Object.keys(link)) {
if (!libraryAddresses[libraryName]) {
// Library not yet deployed.
const libraryArtifact = libraryArtifacts[libraryName];
if (!libraryArtifact) {
throw new Error(`Missing artifact for linked library "${libraryName}"`);
}
// Deploy any dependent libraries used by this library.
await DummyLiquidityProviderContract._deployLibrariesAsync(
libraryArtifact,
libraryArtifacts,
web3Wrapper,
txDefaults,
libraryAddresses,
);
// Deploy this library.
const linkedLibraryBytecode = linkLibrariesInBytecode(
libraryArtifact,
libraryAddresses,
);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: linkedLibraryBytecode,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const { contractAddress } = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`${libraryArtifact.contractName} successfully deployed at ${contractAddress}`);
libraryAddresses[libraryArtifact.contractName] = contractAddress as string;
}
}
}
return libraryAddresses;
}
public getFunctionSignature(methodName: string): string {
const index = this._methodABIIndex[methodName];
const methodAbi = DummyLiquidityProviderContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion
const functionSignature = methodAbiToFunctionSignature(methodAbi);
return functionSignature;
}
public getABIDecodedTransactionData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as DummyLiquidityProviderContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecode<T>(callData);
return abiDecodedCallData;
}
public getABIDecodedReturnData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as DummyLiquidityProviderContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecodeReturnValue<T>(callData);
return abiDecodedCallData;
}
public getSelector(methodName: string): string {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as DummyLiquidityProviderContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
return abiEncoder.getSelector();
}
/**
* Quotes the amount of `takerToken` that would need to be sold in
* order to obtain `buyAmount` of `makerToken`.
* @param takerToken Address of the taker token (what to sell).
* @param makerToken Address of the maker token (what to buy).
* @param buyAmount Amount of `makerToken` to buy.
* @returns takerTokenAmount Amount of &#x60;takerToken&#x60; that would need to be sold.
*/
public getBuyQuote(
takerToken: string,
makerToken: string,
buyAmount: BigNumber,
): ContractFunctionObj<BigNumber
> {
const self = this as any as DummyLiquidityProviderContract;
assert.isString('takerToken', takerToken);
assert.isString('makerToken', makerToken);
assert.isBigNumber('buyAmount', buyAmount);
const functionSignature = 'getBuyQuote(address,address,uint256)';
return {
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<BigNumber
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync({ ...callData, data: this.getABIEncodedTransactionData() }, defaultBlock);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [takerToken.toLowerCase(),
makerToken.toLowerCase(),
buyAmount
]);
},
}
};
/**
* Quotes the amount of `makerToken` that would be obtained by
* selling `sellAmount` of `takerToken`.
* @param takerToken Address of the taker token (what to sell).
* @param makerToken Address of the maker token (what to buy).
* @param sellAmount Amount of `takerToken` to sell.
* @returns makerTokenAmount Amount of &#x60;makerToken&#x60; that would be obtained.
*/
public getSellQuote(
takerToken: string,
makerToken: string,
sellAmount: BigNumber,
): ContractFunctionObj<BigNumber
> {
const self = this as any as DummyLiquidityProviderContract;
assert.isString('takerToken', takerToken);
assert.isString('makerToken', makerToken);
assert.isBigNumber('sellAmount', sellAmount);
const functionSignature = 'getSellQuote(address,address,uint256)';
return {
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<BigNumber
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync({ ...callData, data: this.getABIEncodedTransactionData() }, defaultBlock);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [takerToken.toLowerCase(),
makerToken.toLowerCase(),
sellAmount
]);
},
}
};
constructor(
address: string,
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
deployedBytecode: string | undefined = DummyLiquidityProviderContract.deployedBytecode,
) {
super('DummyLiquidityProvider', DummyLiquidityProviderContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies, deployedBytecode);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
DummyLiquidityProviderContract.ABI().forEach((item, index) => {
if (item.type === 'function') {
const methodAbi = item as MethodAbi;
this._methodABIIndex[methodAbi.name] = index;
}
});
}
}
// tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
// tslint:enable:trailing-comma whitespace no-trailing-whitespace

View File

@ -0,0 +1,418 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable
import {
AwaitTransactionSuccessOpts,
ContractFunctionObj,
ContractTxFunctionObj,
SendTransactionOpts,
BaseContract,
PromiseWithTransactionHash,
methodAbiToFunctionSignature,
linkLibrariesInBytecode,
} from '@0x/base-contract';
import { schemas } from '@0x/json-schemas';
import {
BlockParam,
BlockParamLiteral,
BlockRange,
CallData,
ContractAbi,
ContractArtifact,
DecodedLogArgs,
MethodAbi,
TransactionReceiptWithDecodedLogs,
TxData,
TxDataPayable,
SupportedProvider,
} from 'ethereum-types';
import { BigNumber, classUtils, hexUtils, logUtils, providerUtils } from '@0x/utils';
import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert';
import * as ethers from 'ethers';
// tslint:enable:no-unused-variable
/* istanbul ignore next */
// tslint:disable:array-type
// tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name
export class DummyLiquidityProviderRegistryContract extends BaseContract {
/**
* @ignore
*/
public static deployedBytecode: string | undefined;
public static contractName = 'DummyLiquidityProviderRegistry';
private readonly _methodABIIndex: { [name: string]: number } = {};
public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<DummyLiquidityProviderRegistryContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
return DummyLiquidityProviderRegistryContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
}
public static async deployWithLibrariesFrom0xArtifactAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<DummyLiquidityProviderRegistryContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
const libraryAddresses = await DummyLiquidityProviderRegistryContract._deployLibrariesAsync(
artifact,
libraryArtifacts,
new Web3Wrapper(provider),
txDefaults
);
const bytecode = linkLibrariesInBytecode(
artifact,
libraryAddresses,
);
return DummyLiquidityProviderRegistryContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
}
public static async deployAsync(
bytecode: string,
abi: ContractAbi,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractAbi },
): Promise<DummyLiquidityProviderRegistryContract> {
assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: txData,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`DummyLiquidityProviderRegistry successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new DummyLiquidityProviderRegistryContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
contractInstance.constructorArgs = [];
return contractInstance;
}
/**
* @returns The contract ABI
*/
public static ABI(): ContractAbi {
const abi = [
{
inputs: [
],
outputs: [
],
payable: false,
stateMutability: 'nonpayable',
type: 'constructor',
},
{
constant: true,
inputs: [
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerToken',
type: 'address',
},
],
name: 'getLiquidityProviderForMarket',
outputs: [
{
name: 'poolAddress',
type: 'address',
},
],
payable: false,
stateMutability: 'view',
type: 'function',
},
{
constant: false,
inputs: [
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerToken',
type: 'address',
},
{
name: 'poolAddress',
type: 'address',
},
],
name: 'setLiquidityProviderForMarket',
outputs: [
],
payable: false,
stateMutability: 'nonpayable',
type: 'function',
},
] as ContractAbi;
return abi;
}
protected static async _deployLibrariesAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
web3Wrapper: Web3Wrapper,
txDefaults: Partial<TxData>,
libraryAddresses: { [libraryName: string]: string } = {},
): Promise<{ [libraryName: string]: string }> {
const links = artifact.compilerOutput.evm.bytecode.linkReferences;
// Go through all linked libraries, recursively deploying them if necessary.
for (const link of Object.values(links)) {
for (const libraryName of Object.keys(link)) {
if (!libraryAddresses[libraryName]) {
// Library not yet deployed.
const libraryArtifact = libraryArtifacts[libraryName];
if (!libraryArtifact) {
throw new Error(`Missing artifact for linked library "${libraryName}"`);
}
// Deploy any dependent libraries used by this library.
await DummyLiquidityProviderRegistryContract._deployLibrariesAsync(
libraryArtifact,
libraryArtifacts,
web3Wrapper,
txDefaults,
libraryAddresses,
);
// Deploy this library.
const linkedLibraryBytecode = linkLibrariesInBytecode(
libraryArtifact,
libraryAddresses,
);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: linkedLibraryBytecode,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const { contractAddress } = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`${libraryArtifact.contractName} successfully deployed at ${contractAddress}`);
libraryAddresses[libraryArtifact.contractName] = contractAddress as string;
}
}
}
return libraryAddresses;
}
public getFunctionSignature(methodName: string): string {
const index = this._methodABIIndex[methodName];
const methodAbi = DummyLiquidityProviderRegistryContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion
const functionSignature = methodAbiToFunctionSignature(methodAbi);
return functionSignature;
}
public getABIDecodedTransactionData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as DummyLiquidityProviderRegistryContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecode<T>(callData);
return abiDecodedCallData;
}
public getABIDecodedReturnData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as DummyLiquidityProviderRegistryContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecodeReturnValue<T>(callData);
return abiDecodedCallData;
}
public getSelector(methodName: string): string {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as DummyLiquidityProviderRegistryContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
return abiEncoder.getSelector();
}
/**
* Returns the address of pool for a market given market (xAsset, yAsset), or reverts if pool does not exist.
* @param takerToken First asset managed by pool.
* @param makerToken Second asset managed by pool.
* @returns Address of pool.
*/
public getLiquidityProviderForMarket(
takerToken: string,
makerToken: string,
): ContractFunctionObj<string
> {
const self = this as any as DummyLiquidityProviderRegistryContract;
assert.isString('takerToken', takerToken);
assert.isString('makerToken', makerToken);
const functionSignature = 'getLiquidityProviderForMarket(address,address)';
return {
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync({ ...callData, data: this.getABIEncodedTransactionData() }, defaultBlock);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [takerToken.toLowerCase(),
makerToken.toLowerCase()
]);
},
}
};
/**
* Sets address of pool for a market given market (xAsset, yAsset).
* @param takerToken First asset managed by pool.
* @param makerToken Second asset managed by pool.
* @param poolAddress Address of pool.
*/
public setLiquidityProviderForMarket(
takerToken: string,
makerToken: string,
poolAddress: string,
): ContractTxFunctionObj<void
> {
const self = this as any as DummyLiquidityProviderRegistryContract;
assert.isString('takerToken', takerToken);
assert.isString('makerToken', makerToken);
assert.isString('poolAddress', poolAddress);
const functionSignature = 'setLiquidityProviderForMarket(address,address,address)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ ...txData, data: this.getABIEncodedTransactionData() },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(
txData?: Partial<TxData> | undefined,
): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ ...txData, data: this.getABIEncodedTransactionData() }
);
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync({ ...callData, data: this.getABIEncodedTransactionData() }, defaultBlock);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<void
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [takerToken.toLowerCase(),
makerToken.toLowerCase(),
poolAddress.toLowerCase()
]);
},
}
};
constructor(
address: string,
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
deployedBytecode: string | undefined = DummyLiquidityProviderRegistryContract.deployedBytecode,
) {
super('DummyLiquidityProviderRegistry', DummyLiquidityProviderRegistryContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies, deployedBytecode);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
DummyLiquidityProviderRegistryContract.ABI().forEach((item, index) => {
if (item.type === 'function') {
const methodAbi = item as MethodAbi;
this._methodABIIndex[methodAbi.name] = index;
}
});
}
}
// tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
// tslint:enable:trailing-comma whitespace no-trailing-whitespace

View File

@ -0,0 +1,507 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable
import {
AwaitTransactionSuccessOpts,
ContractFunctionObj,
ContractTxFunctionObj,
SendTransactionOpts,
BaseContract,
PromiseWithTransactionHash,
methodAbiToFunctionSignature,
linkLibrariesInBytecode,
} from '@0x/base-contract';
import { schemas } from '@0x/json-schemas';
import {
BlockParam,
BlockParamLiteral,
BlockRange,
CallData,
ContractAbi,
ContractArtifact,
DecodedLogArgs,
MethodAbi,
TransactionReceiptWithDecodedLogs,
TxData,
TxDataPayable,
SupportedProvider,
} from 'ethereum-types';
import { BigNumber, classUtils, hexUtils, logUtils, providerUtils } from '@0x/utils';
import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert';
import * as ethers from 'ethers';
// tslint:enable:no-unused-variable
/* istanbul ignore next */
// tslint:disable:array-type
// tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name
export class ILiquidityProviderContract extends BaseContract {
/**
* @ignore
*/
public static deployedBytecode: string | undefined;
public static contractName = 'ILiquidityProvider';
private readonly _methodABIIndex: { [name: string]: number } = {};
public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<ILiquidityProviderContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
return ILiquidityProviderContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
}
public static async deployWithLibrariesFrom0xArtifactAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<ILiquidityProviderContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
const libraryAddresses = await ILiquidityProviderContract._deployLibrariesAsync(
artifact,
libraryArtifacts,
new Web3Wrapper(provider),
txDefaults
);
const bytecode = linkLibrariesInBytecode(
artifact,
libraryAddresses,
);
return ILiquidityProviderContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
}
public static async deployAsync(
bytecode: string,
abi: ContractAbi,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractAbi },
): Promise<ILiquidityProviderContract> {
assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: txData,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`ILiquidityProvider successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new ILiquidityProviderContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
contractInstance.constructorArgs = [];
return contractInstance;
}
/**
* @returns The contract ABI
*/
public static ABI(): ContractAbi {
const abi = [
{
constant: false,
inputs: [
{
name: 'tokenAddress',
type: 'address',
},
{
name: 'from',
type: 'address',
},
{
name: 'to',
type: 'address',
},
{
name: 'amount',
type: 'uint256',
},
{
name: 'bridgeData',
type: 'bytes',
},
],
name: 'bridgeTransferFrom',
outputs: [
{
name: 'success',
type: 'bytes4',
},
],
payable: false,
stateMutability: 'nonpayable',
type: 'function',
},
{
constant: true,
inputs: [
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerToken',
type: 'address',
},
{
name: 'buyAmount',
type: 'uint256',
},
],
name: 'getBuyQuote',
outputs: [
{
name: 'takerTokenAmount',
type: 'uint256',
},
],
payable: false,
stateMutability: 'view',
type: 'function',
},
{
constant: true,
inputs: [
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerToken',
type: 'address',
},
{
name: 'sellAmount',
type: 'uint256',
},
],
name: 'getSellQuote',
outputs: [
{
name: 'makerTokenAmount',
type: 'uint256',
},
],
payable: false,
stateMutability: 'view',
type: 'function',
},
] as ContractAbi;
return abi;
}
protected static async _deployLibrariesAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
web3Wrapper: Web3Wrapper,
txDefaults: Partial<TxData>,
libraryAddresses: { [libraryName: string]: string } = {},
): Promise<{ [libraryName: string]: string }> {
const links = artifact.compilerOutput.evm.bytecode.linkReferences;
// Go through all linked libraries, recursively deploying them if necessary.
for (const link of Object.values(links)) {
for (const libraryName of Object.keys(link)) {
if (!libraryAddresses[libraryName]) {
// Library not yet deployed.
const libraryArtifact = libraryArtifacts[libraryName];
if (!libraryArtifact) {
throw new Error(`Missing artifact for linked library "${libraryName}"`);
}
// Deploy any dependent libraries used by this library.
await ILiquidityProviderContract._deployLibrariesAsync(
libraryArtifact,
libraryArtifacts,
web3Wrapper,
txDefaults,
libraryAddresses,
);
// Deploy this library.
const linkedLibraryBytecode = linkLibrariesInBytecode(
libraryArtifact,
libraryAddresses,
);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: linkedLibraryBytecode,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const { contractAddress } = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`${libraryArtifact.contractName} successfully deployed at ${contractAddress}`);
libraryAddresses[libraryArtifact.contractName] = contractAddress as string;
}
}
}
return libraryAddresses;
}
public getFunctionSignature(methodName: string): string {
const index = this._methodABIIndex[methodName];
const methodAbi = ILiquidityProviderContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion
const functionSignature = methodAbiToFunctionSignature(methodAbi);
return functionSignature;
}
public getABIDecodedTransactionData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as ILiquidityProviderContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecode<T>(callData);
return abiDecodedCallData;
}
public getABIDecodedReturnData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as ILiquidityProviderContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecodeReturnValue<T>(callData);
return abiDecodedCallData;
}
public getSelector(methodName: string): string {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as ILiquidityProviderContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
return abiEncoder.getSelector();
}
/**
* Transfers `amount` of the ERC20 `tokenAddress` from `from` to `to`.
* @param tokenAddress The address of the ERC20 token to transfer.
* @param from Address to transfer asset from.
* @param to Address to transfer asset to.
* @param amount Amount of asset to transfer.
* @param bridgeData Arbitrary asset data needed by the bridge contract.
* @returns success The magic bytes &#x60;0xdc1600f3&#x60; if successful.
*/
public bridgeTransferFrom(
tokenAddress: string,
from: string,
to: string,
amount: BigNumber,
bridgeData: string,
): ContractTxFunctionObj<string
> {
const self = this as any as ILiquidityProviderContract;
assert.isString('tokenAddress', tokenAddress);
assert.isString('from', from);
assert.isString('to', to);
assert.isBigNumber('amount', amount);
assert.isString('bridgeData', bridgeData);
const functionSignature = 'bridgeTransferFrom(address,address,address,uint256,bytes)';
return {
async sendTransactionAsync(
txData?: Partial<TxData> | undefined,
opts: SendTransactionOpts = { shouldValidate: true },
): Promise<string> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ ...txData, data: this.getABIEncodedTransactionData() },
this.estimateGasAsync.bind(this),
);
if (opts.shouldValidate !== false) {
await this.callAsync(txDataWithDefaults);
}
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
},
awaitTransactionSuccessAsync(
txData?: Partial<TxData>,
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
},
async estimateGasAsync(
txData?: Partial<TxData> | undefined,
): Promise<number> {
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ ...txData, data: this.getABIEncodedTransactionData() }
);
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
},
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync({ ...callData, data: this.getABIEncodedTransactionData() }, defaultBlock);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [tokenAddress.toLowerCase(),
from.toLowerCase(),
to.toLowerCase(),
amount,
bridgeData
]);
},
}
};
/**
* Quotes the amount of `takerToken` that would need to be sold in
* order to obtain `buyAmount` of `makerToken`.
* @param takerToken Address of the taker token (what to sell).
* @param makerToken Address of the maker token (what to buy).
* @param buyAmount Amount of `makerToken` to buy.
* @returns takerTokenAmount Amount of &#x60;takerToken&#x60; that would need to be sold.
*/
public getBuyQuote(
takerToken: string,
makerToken: string,
buyAmount: BigNumber,
): ContractFunctionObj<BigNumber
> {
const self = this as any as ILiquidityProviderContract;
assert.isString('takerToken', takerToken);
assert.isString('makerToken', makerToken);
assert.isBigNumber('buyAmount', buyAmount);
const functionSignature = 'getBuyQuote(address,address,uint256)';
return {
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<BigNumber
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync({ ...callData, data: this.getABIEncodedTransactionData() }, defaultBlock);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [takerToken.toLowerCase(),
makerToken.toLowerCase(),
buyAmount
]);
},
}
};
/**
* Quotes the amount of `makerToken` that would be obtained by
* selling `sellAmount` of `takerToken`.
* @param takerToken Address of the taker token (what to sell).
* @param makerToken Address of the maker token (what to buy).
* @param sellAmount Amount of `takerToken` to sell.
* @returns makerTokenAmount Amount of &#x60;makerToken&#x60; that would be obtained.
*/
public getSellQuote(
takerToken: string,
makerToken: string,
sellAmount: BigNumber,
): ContractFunctionObj<BigNumber
> {
const self = this as any as ILiquidityProviderContract;
assert.isString('takerToken', takerToken);
assert.isString('makerToken', makerToken);
assert.isBigNumber('sellAmount', sellAmount);
const functionSignature = 'getSellQuote(address,address,uint256)';
return {
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<BigNumber
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync({ ...callData, data: this.getABIEncodedTransactionData() }, defaultBlock);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [takerToken.toLowerCase(),
makerToken.toLowerCase(),
sellAmount
]);
},
}
};
constructor(
address: string,
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
deployedBytecode: string | undefined = ILiquidityProviderContract.deployedBytecode,
) {
super('ILiquidityProvider', ILiquidityProviderContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies, deployedBytecode);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
ILiquidityProviderContract.ABI().forEach((item, index) => {
if (item.type === 'function') {
const methodAbi = item as MethodAbi;
this._methodABIIndex[methodAbi.name] = index;
}
});
}
}
// tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
// tslint:enable:trailing-comma whitespace no-trailing-whitespace

View File

@ -0,0 +1,321 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable
import {
AwaitTransactionSuccessOpts,
ContractFunctionObj,
ContractTxFunctionObj,
SendTransactionOpts,
BaseContract,
PromiseWithTransactionHash,
methodAbiToFunctionSignature,
linkLibrariesInBytecode,
} from '@0x/base-contract';
import { schemas } from '@0x/json-schemas';
import {
BlockParam,
BlockParamLiteral,
BlockRange,
CallData,
ContractAbi,
ContractArtifact,
DecodedLogArgs,
MethodAbi,
TransactionReceiptWithDecodedLogs,
TxData,
TxDataPayable,
SupportedProvider,
} from 'ethereum-types';
import { BigNumber, classUtils, hexUtils, logUtils, providerUtils } from '@0x/utils';
import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { assert } from '@0x/assert';
import * as ethers from 'ethers';
// tslint:enable:no-unused-variable
/* istanbul ignore next */
// tslint:disable:array-type
// tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name
export class ILiquidityProviderRegistryContract extends BaseContract {
/**
* @ignore
*/
public static deployedBytecode: string | undefined;
public static contractName = 'ILiquidityProviderRegistry';
private readonly _methodABIIndex: { [name: string]: number } = {};
public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<ILiquidityProviderRegistryContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const bytecode = artifact.compilerOutput.evm.bytecode.object;
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
return ILiquidityProviderRegistryContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
}
public static async deployWithLibrariesFrom0xArtifactAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<ILiquidityProviderRegistryContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
if (artifact.compilerOutput === undefined) {
throw new Error('Compiler output not found in the artifact file');
}
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const abi = artifact.compilerOutput.abi;
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
if (Object.keys(logDecodeDependencies) !== undefined) {
for (const key of Object.keys(logDecodeDependencies)) {
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
}
}
const libraryAddresses = await ILiquidityProviderRegistryContract._deployLibrariesAsync(
artifact,
libraryArtifacts,
new Web3Wrapper(provider),
txDefaults
);
const bytecode = linkLibrariesInBytecode(
artifact,
libraryAddresses,
);
return ILiquidityProviderRegistryContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
}
public static async deployAsync(
bytecode: string,
abi: ContractAbi,
supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractAbi },
): Promise<ILiquidityProviderRegistryContract> {
assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema,
schemas.numberSchema,
schemas.jsNumber,
]);
const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: txData,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`ILiquidityProviderRegistry successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new ILiquidityProviderRegistryContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
contractInstance.constructorArgs = [];
return contractInstance;
}
/**
* @returns The contract ABI
*/
public static ABI(): ContractAbi {
const abi = [
{
constant: true,
inputs: [
{
name: 'takerToken',
type: 'address',
},
{
name: 'makerToken',
type: 'address',
},
],
name: 'getLiquidityProviderForMarket',
outputs: [
{
name: 'providerAddress',
type: 'address',
},
],
payable: false,
stateMutability: 'view',
type: 'function',
},
] as ContractAbi;
return abi;
}
protected static async _deployLibrariesAsync(
artifact: ContractArtifact,
libraryArtifacts: { [libraryName: string]: ContractArtifact },
web3Wrapper: Web3Wrapper,
txDefaults: Partial<TxData>,
libraryAddresses: { [libraryName: string]: string } = {},
): Promise<{ [libraryName: string]: string }> {
const links = artifact.compilerOutput.evm.bytecode.linkReferences;
// Go through all linked libraries, recursively deploying them if necessary.
for (const link of Object.values(links)) {
for (const libraryName of Object.keys(link)) {
if (!libraryAddresses[libraryName]) {
// Library not yet deployed.
const libraryArtifact = libraryArtifacts[libraryName];
if (!libraryArtifact) {
throw new Error(`Missing artifact for linked library "${libraryName}"`);
}
// Deploy any dependent libraries used by this library.
await ILiquidityProviderRegistryContract._deployLibrariesAsync(
libraryArtifact,
libraryArtifacts,
web3Wrapper,
txDefaults,
libraryAddresses,
);
// Deploy this library.
const linkedLibraryBytecode = linkLibrariesInBytecode(
libraryArtifact,
libraryAddresses,
);
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
{
data: linkedLibraryBytecode,
...txDefaults,
},
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
logUtils.log(`transactionHash: ${txHash}`);
const { contractAddress } = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`${libraryArtifact.contractName} successfully deployed at ${contractAddress}`);
libraryAddresses[libraryArtifact.contractName] = contractAddress as string;
}
}
}
return libraryAddresses;
}
public getFunctionSignature(methodName: string): string {
const index = this._methodABIIndex[methodName];
const methodAbi = ILiquidityProviderRegistryContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion
const functionSignature = methodAbiToFunctionSignature(methodAbi);
return functionSignature;
}
public getABIDecodedTransactionData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as ILiquidityProviderRegistryContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecode<T>(callData);
return abiDecodedCallData;
}
public getABIDecodedReturnData<T>(methodName: string, callData: string): T {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as ILiquidityProviderRegistryContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
const abiDecodedCallData = abiEncoder.strictDecodeReturnValue<T>(callData);
return abiDecodedCallData;
}
public getSelector(methodName: string): string {
const functionSignature = this.getFunctionSignature(methodName);
const self = (this as any) as ILiquidityProviderRegistryContract;
const abiEncoder = self._lookupAbiEncoder(functionSignature);
return abiEncoder.getSelector();
}
/**
* Returns the address of a liquidity provider for the given market
* (takerToken, makerToken), reverting if the pool does not exist.
* @param takerToken Taker asset managed by liquidity provider.
* @param makerToken Maker asset managed by liquidity provider.
* @returns Address of the liquidity provider.
*/
public getLiquidityProviderForMarket(
takerToken: string,
makerToken: string,
): ContractFunctionObj<string
> {
const self = this as any as ILiquidityProviderRegistryContract;
assert.isString('takerToken', takerToken);
assert.isString('makerToken', makerToken);
const functionSignature = 'getLiquidityProviderForMarket(address,address)';
return {
async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
BaseContract._assertCallParams(callData, defaultBlock);
const rawCallResult = await self._performCallAsync({ ...callData, data: this.getABIEncodedTransactionData() }, defaultBlock);
const abiEncoder = self._lookupAbiEncoder(functionSignature);
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
return abiEncoder.strictDecodeReturnValue<string
>(rawCallResult);
},
getABIEncodedTransactionData(): string {
return self._strictEncodeArguments(functionSignature, [takerToken.toLowerCase(),
makerToken.toLowerCase()
]);
},
}
};
constructor(
address: string,
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
deployedBytecode: string | undefined = ILiquidityProviderRegistryContract.deployedBytecode,
) {
super('ILiquidityProviderRegistry', ILiquidityProviderRegistryContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies, deployedBytecode);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
ILiquidityProviderRegistryContract.ABI().forEach((item, index) => {
if (item.type === 'function') {
const methodAbi = item as MethodAbi;
this._methodABIIndex[methodAbi.name] = index;
}
});
}
}
// tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
// tslint:enable:trailing-comma whitespace no-trailing-whitespace