@dolomite-exchange/dolomite-margin
Version:
Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol
713 lines (712 loc) • 242 kB
JSON
{
"contractName": "TestExchangeWrapper",
"abi": [
{
"constant": true,
"inputs": [],
"name": "EXCHANGE_ADDRESS",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "tradeOriginator",
"type": "address"
},
{
"internalType": "address",
"name": "receiver",
"type": "address"
},
{
"internalType": "address",
"name": "makerToken",
"type": "address"
},
{
"internalType": "address",
"name": "takerToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "requestedFillAmount",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "orderData",
"type": "bytes"
}
],
"name": "exchange",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "makerToken",
"type": "address"
},
{
"internalType": "address",
"name": "takerToken",
"type": "address"
},
{
"internalType": "uint256",
"name": "desiredMakerToken",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "orderData",
"type": "bytes"
}
],
"name": "getExchangeCost",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
],
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[],\"name\":\"EXCHANGE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"tradeOriginator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"makerToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"takerToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"requestedFillAmount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"orderData\",\"type\":\"bytes\"}],\"name\":\"exchange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"makerToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"takerToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"desiredMakerToken\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"orderData\",\"type\":\"bytes\"}],\"name\":\"getExchangeCost\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"dYdX * An ExchangeWrapper for testing\",\"methods\":{},\"title\":\"TestExchangeWrapper\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/testing/TestExchangeWrapper.sol\":\"TestExchangeWrapper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IExchangeWrapper.sol\":{\"keccak256\":\"0x74799c3fac16738be41e270a70d3f7ad4f75d1dc7e5d8c58f0fe4c6128345112\",\"urls\":[\"bzz-raw://d9602af1001189d199736d17266d5fb34a32f71cd05fbcf4c0f97c0b3a642eee\",\"dweb:/ipfs/QmPto2DkZ1nKqicBMdMkaek7kGSSXqSKnf697h5zuthvsy\"]},\"/home/cdc218/projects/dolomite-protocol-v2/contracts/testing/TestExchangeWrapper.sol\":{\"keccak256\":\"0x0eb424106139badbd79db6e4a650a277d2344a975e736dc4378280a5d251a210\",\"urls\":[\"bzz-raw://c43da8e671b3942bcecabfc630f8f861fbf406bbf284b529b61e6fa31130270e\",\"dweb:/ipfs/QmY3V5mfNHk3Y65NtkwzKsi7fnMFs3wGpdbYnm9eQdWAsN\"]},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x640b6dee7a4b830bdfd52b5031a07fc2b12209f5b2e29e5d364a7d37f69d8076\",\"urls\":[\"bzz-raw://31113152e1ddb78fe7a4197f247591ca894e93f916867beb708d8e747b6cc74f\",\"dweb:/ipfs/QmbZaJyXdpsYGykVhHH9qpVGQg9DGCxE2QufbCUy3daTgq\"]},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0xe5bb0f57cff3e299f360052ba50f1ea0fff046df2be070b6943e0e3c3fdad8a9\",\"urls\":[\"bzz-raw://59fd025151435da35faa8093a5c7a17de02de9d08ad27275c5cdf05050820d91\",\"dweb:/ipfs/QmQMvwEcPhoRXzbXyrdoeRtvLoifUW9Qh7Luho7bmUPRkc\"]},\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\":{\"keccak256\":\"0x6f2c9955d65c522b80f4b8792f076512d2df947d2112cbc4d98a4781ed42ede2\",\"urls\":[\"bzz-raw://7d8ec81683520c06baeef3f7e06cd82bd6fd5fa611f26857f475f6c829540aff\",\"dweb:/ipfs/QmTDkFzKnrpiV1UKnSoiZAHPuguWzokrr4pFbSPvyaSo56\"]},\"@openzeppelin/contracts/utils/Address.sol\":{\"keccak256\":\"0x1a8e5072509c5ea7365eb1d48030b9be865140c8fb779968da0a459a0e174a11\",\"urls\":[\"bzz-raw://03335b7b07c7c8c8d613cfdd8ec39a0b5ec133ee510bf2fe6cc5a496767bef4b\",\"dweb:/ipfs/Qmebp4nzPja645c9yXSdJkGq96oU3am3LUnG2K3R7XxyKf\"]}},\"version\":1}",
"bytecode": "0x608060405234801561001057600080fd5b50610c1d806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80633a8fdd7d1461004657806360aec0f0146100f55780637d98ebac14610126575b600080fd5b6100e36004803603608081101561005c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8235811692602081013590911691604082013591908101906080810160608201356401000000008111156100a457600080fd5b8201836020820111156100b657600080fd5b803590602001918460018302840111640100000000831117156100d857600080fd5b5090925090506101d0565b60408051918252519081900360200190f35b6100fd610389565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6100e3600480360360c081101561013c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8235811692602081013582169260408201358316926060830135169160808101359181019060c0810160a082013564010000000081111561019157600080fd5b8201836020820111156101a357600080fd5b803590602001918460018302840111640100000000831117156101c557600080fd5b50909250905061038e565b60006101da610b09565b61021984848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061062392505050565b9050848160c0015114610273576040805162461bcd60e51b815260206004820152601b60248201527f446573697265644d616b6572416d6f756e74206d69736d617463680000000000604482015290519081900360640190fd5b8673ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16146102f7576040805162461bcd60e51b815260206004820152601360248201527f4d616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b8573ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff161461037b576040805162461bcd60e51b815260206004820152601360248201527f54616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b60a001519695505050505050565b600181565b6000610398610b09565b6103d784848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061062392505050565b90508873ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161461045d576040805162461bcd60e51b815260206004820152601360248201527f4f726967696e61746f72206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b8673ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16146104e1576040805162461bcd60e51b815260206004820152601360248201527f4d616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b8573ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff1614610565576040805162461bcd60e51b815260206004820152601360248201527f54616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b848160800151146105bd576040805162461bcd60e51b815260206004820152601360248201527f54616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b6105e573ffffffffffffffffffffffffffffffffffffffff871660018763ffffffff6106d516565b60608101516106139073ffffffffffffffffffffffffffffffffffffffff8916908a9063ffffffff61076716565b6060015198975050505050505050565b61062b610b09565b815160e014610681576040805162461bcd60e51b815260206004820152601860248201527f6f726465724461746120696e76616c6964206c656e6774680000000000000000604482015290519081900360640190fd5b610689610b09565b6020830151815260408301516020820152606083015160408201526080830151606082015260a0830151608082015260c083015160a082015260e083015160c082015280915050919050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526107629084906108d7565b505050565b8015806108135750604080517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156107e557600080fd5b505afa1580156107f9573d6000803e3d6000fd5b505050506040513d602081101561080f57600080fd5b5051155b61084e5760405162461bcd60e51b8152600401808060200182810382526036815260200180610bb36036913960400191505060405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b3000000000000000000000000000000000000000000000000000000001790526107629084905b6108f68273ffffffffffffffffffffffffffffffffffffffff16610acd565b610947576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b602083106109b057805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610973565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610a12576040519150601f19603f3d011682016040523d82523d6000602084013e610a17565b606091505b509150915081610a6e576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610ac757808060200190516020811015610a8a57600080fd5b5051610ac75760405162461bcd60e51b815260040180806020018281038252602a815260200180610b89602a913960400191505060405180910390fd5b50505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610b0157508115155b949350505050565b6040518060e00160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152509056fe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a72315820d58573a1def3545fb8868ea94bbe596cc3f69f4271abce458578303d99cf7a0564736f6c63430005100032",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80633a8fdd7d1461004657806360aec0f0146100f55780637d98ebac14610126575b600080fd5b6100e36004803603608081101561005c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8235811692602081013590911691604082013591908101906080810160608201356401000000008111156100a457600080fd5b8201836020820111156100b657600080fd5b803590602001918460018302840111640100000000831117156100d857600080fd5b5090925090506101d0565b60408051918252519081900360200190f35b6100fd610389565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6100e3600480360360c081101561013c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8235811692602081013582169260408201358316926060830135169160808101359181019060c0810160a082013564010000000081111561019157600080fd5b8201836020820111156101a357600080fd5b803590602001918460018302840111640100000000831117156101c557600080fd5b50909250905061038e565b60006101da610b09565b61021984848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061062392505050565b9050848160c0015114610273576040805162461bcd60e51b815260206004820152601b60248201527f446573697265644d616b6572416d6f756e74206d69736d617463680000000000604482015290519081900360640190fd5b8673ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16146102f7576040805162461bcd60e51b815260206004820152601360248201527f4d616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b8573ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff161461037b576040805162461bcd60e51b815260206004820152601360248201527f54616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b60a001519695505050505050565b600181565b6000610398610b09565b6103d784848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061062392505050565b90508873ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161461045d576040805162461bcd60e51b815260206004820152601360248201527f4f726967696e61746f72206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b8673ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff16146104e1576040805162461bcd60e51b815260206004820152601360248201527f4d616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b8573ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff1614610565576040805162461bcd60e51b815260206004820152601360248201527f54616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b848160800151146105bd576040805162461bcd60e51b815260206004820152601360248201527f54616b6572546f6b656e206d69736d6174636800000000000000000000000000604482015290519081900360640190fd5b6105e573ffffffffffffffffffffffffffffffffffffffff871660018763ffffffff6106d516565b60608101516106139073ffffffffffffffffffffffffffffffffffffffff8916908a9063ffffffff61076716565b6060015198975050505050505050565b61062b610b09565b815160e014610681576040805162461bcd60e51b815260206004820152601860248201527f6f726465724461746120696e76616c6964206c656e6774680000000000000000604482015290519081900360640190fd5b610689610b09565b6020830151815260408301516020820152606083015160408201526080830151606082015260a0830151608082015260c083015160a082015260e083015160c082015280915050919050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526107629084906108d7565b505050565b8015806108135750604080517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156107e557600080fd5b505afa1580156107f9573d6000803e3d6000fd5b505050506040513d602081101561080f57600080fd5b5051155b61084e5760405162461bcd60e51b8152600401808060200182810382526036815260200180610bb36036913960400191505060405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b3000000000000000000000000000000000000000000000000000000001790526107629084905b6108f68273ffffffffffffffffffffffffffffffffffffffff16610acd565b610947576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b602083106109b057805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610973565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610a12576040519150601f19603f3d011682016040523d82523d6000602084013e610a17565b606091505b509150915081610a6e576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610ac757808060200190516020811015610a8a57600080fd5b5051610ac75760405162461bcd60e51b815260040180806020018281038252602a815260200180610b89602a913960400191505060405180910390fd5b50505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610b0157508115155b949350505050565b6040518060e00160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152509056fe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a72315820d58573a1def3545fb8868ea94bbe596cc3f69f4271abce458578303d99cf7a0564736f6c63430005100032",
"sourceMap": "954:3178:121:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;954:3178:121;;;;;;;",
"deployedSourceMap": "954:3178:121:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;954:3178:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2493:646;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;2493:646:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;21:11:-1;5:28;;2:2;;;46:1;43;36:12;2:2;2493:646:121;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;2493:646:121;;;;;;100:9:-1;95:1;81:12;77:20;67:8;63:35;60:50;39:11;25:12;22:29;11:107;8:2;;;131:1;128;121:12;8:2;-1:-1;2493:646:121;;-1:-1:-1;2493:646:121;-1:-1:-1;2493:646:121;:::i;:::-;;;;;;;;;;;;;;;;1151:55;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1555:932;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;1555:932:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;21:11:-1;5:28;;2:2;;;46:1;43;36:12;2:2;1555:932:121;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;1555:932:121;;;;;;100:9:-1;95:1;81:12;77:20;67:8;63:35;60:50;39:11;25:12;22:29;11:107;8:2;;;131:1;128;121:12;8:2;-1:-1;1555:932:121;;-1:-1:-1;1555:932:121;-1:-1:-1;1555:932:121;:::i;2493:646::-;2684:7;2707:18;;:::i;:::-;2728:20;2738:9;;2728:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;2728:9:121;;-1:-1:-1;;;2728:20:121:i;:::-;2707:41;;2808:17;2780:5;:24;;;:45;2759:119;;;;;-1:-1:-1;;;2759:119:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;2929:10;2909:30;;:5;:16;;;:30;;;2888:96;;;;;-1:-1:-1;;;2888:96:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;3035:10;3015:30;;:5;:16;;;:30;;;2994:96;;;;;-1:-1:-1;;;2994:96:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;3108:24;;;;2493:646;-1:-1:-1;;;;;;2493:646:121:o;1151:55::-;1202:3;1151:55;:::o;1555:932::-;1791:7;1814:18;;:::i;:::-;1835:20;1845:9;;1835:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;1835:9:121;;-1:-1:-1;;;1835:20:121:i;:::-;1814:41;;1907:15;1887:35;;:5;:16;;;:35;;;1866:101;;;;;-1:-1:-1;;;1866:101:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;2018:10;1998:30;;:5;:16;;;:30;;;1977:96;;;;;-1:-1:-1;;;1977:96:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;2124:10;2104:30;;:5;:16;;;:30;;;2083:96;;;;;-1:-1:-1;;;2083:96:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;2231:19;2210:5;:17;;;:40;2189:106;;;;;-1:-1:-1;;;2189:106:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;2306:70;:31;;;1202:3;2356:19;2306:70;:31;:70;:::i;:::-;2427:17;;;;2386:59;;:30;;;;2417:8;;2386:59;:30;:59;:::i;:::-;2463:17;;;;1555:932;-1:-1:-1;;;;;;;;1555:932:121:o;3197:933::-;3288:12;;:::i;:::-;3337:9;:16;3357:3;3337:23;3316:94;;;;;-1:-1:-1;;;3316:94:121;;;;;;;;;;;;;;;;;;;;;;;;;;;;3421:18;;:::i;:::-;3585:2;3574:9;3570:18;3564:25;3547:5;3540:50;3663:2;3652:9;3648:18;3642:25;3636:2;3629:5;3625:14;3618:50;3741:2;3730:9;3726:18;3720:25;3714:2;3707:5;3703:14;3696:50;3819:3;3808:9;3804:19;3798:26;3792:2;3785:5;3781:14;3774:51;3898:3;3887:9;3883:19;3877:26;3871:3;3864:5;3860:15;3853:51;3977:3;3966:9;3962:19;3956:26;3950:3;3943:5;3939:15;3932:51;4063:3;4052:9;4048:19;4042:26;4036:3;4029:5;4025:15;4018:51;4118:5;4111:12;;;3197:933;;;:::o;662:174:153:-;770:58;;;793:14;770:58;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;770:58:153;;;;;;;;25:18:-1;;61:17;;770:58:153;182:15:-1;793:23:153;179:29:-1;160:49;;744:85:153;;763:5;;744:18;:85::i;:::-;662:174;;;:::o;1050:612::-;1415:10;;;1414:62;;-1:-1:-1;1431:39:153;;;;;;1455:4;1431:39;;;;:15;:39;;;;;;;;;:15;;;;;;:39;;;;;;;;;;;;;;;:15;:39;;;5:2:-1;;;;30:1;27;20:12;5:2;1431:39:153;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1431:39:153;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;1431:39:153;:44;1414:62;1406:150;;;;-1:-1:-1;;;1406:150:153;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1592:62;;;1615:13;1592:62;;;;;;;;;;;;;;;26:21:-1;;;22:32;;;6:49;;1592:62:153;;;;;;;;25:18:-1;;61:17;;1592:62:153;182:15:-1;1615:22:153;179:29:-1;160:49;;1566:89:153;;1585:5;;2666:1095;3261:27;3269:5;3261:25;;;:27::i;:::-;3253:71;;;;;-1:-1:-1;;;3253:71:153;;;;;;;;;;;;;;;;;;;;;;;;;;;;3395:12;3409:23;3444:5;3436:19;;3456:4;3436:25;;;;;;;;;;;;;36:153:-1;66:2;61:3;58:11;36:153;;176:10;;164:23;;139:12;;;;;98:2;89:12;;;;114;36:153;;;274:1;267:3;263:2;259:12;254:3;250:22;246:30;315:4;311:9;305:3;299:10;295:26;356:4;350:3;344:10;340:21;389:7;380;377:20;372:3;365:33;3:399;;;3436:25:153;;;;;;;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;;3394:67:153;;;;3479:7;3471:52;;;;;-1:-1:-1;;;3471:52:153;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3538:17;;:21;3534:221;;3678:10;3667:30;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;3667:30:153;3659:85;;;;-1:-1:-1;;;3659:85:153;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2666:1095;;;;:::o;686:610:154:-;746:4;1207:20;;1052:66;1246:23;;;;;;:42;;-1:-1:-1;1273:15:154;;;1246:42;1238:51;686:610;-1:-1:-1;;;;686:610:154:o;954:3178:121:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o",
"source": "/*\n\n Copyright 2018 dYdX Trading Inc.\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\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\n\nimport { IExchangeWrapper } from \"../protocol/interfaces/IExchangeWrapper.sol\";\n\n\n/**\n * @title TestExchangeWrapper\n * @author dYdX\n *\n * An ExchangeWrapper for testing\n */\ncontract TestExchangeWrapper is IExchangeWrapper {\n using SafeERC20 for IERC20;\n\n // ============ Constants ============\n\n // arbitrary address to send the tokens to (they are burned)\n address public constant EXCHANGE_ADDRESS = address(0x1);\n\n // ============ Structs ============\n\n struct Order {\n address originator;\n address makerToken;\n address takerToken;\n uint256 makerAmount;\n uint256 takerAmount;\n uint256 allegedTakerAmount;\n uint256 desiredMakerAmount;\n }\n\n // ============ ExchangeWrapper functions ============\n\n function exchange(\n address tradeOriginator,\n address receiver,\n address makerToken,\n address takerToken,\n uint256 requestedFillAmount,\n bytes calldata orderData\n )\n external\n returns (uint256)\n {\n Order memory order = parseData(orderData);\n\n require(\n order.originator == tradeOriginator,\n \"Originator mismatch\"\n );\n require(\n order.makerToken == makerToken,\n \"MakerToken mismatch\"\n );\n require(\n order.takerToken == takerToken,\n \"TakerToken mismatch\"\n );\n require(\n order.takerAmount == requestedFillAmount,\n \"TakerToken mismatch\"\n );\n\n IERC20(takerToken).safeTransfer(EXCHANGE_ADDRESS, requestedFillAmount);\n IERC20(makerToken).safeApprove(receiver, order.makerAmount);\n\n return order.makerAmount;\n }\n\n function getExchangeCost(\n address makerToken,\n address takerToken,\n uint256 desiredMakerToken,\n bytes calldata orderData\n )\n external\n view\n returns (uint256)\n {\n Order memory order = parseData(orderData);\n\n require(\n order.desiredMakerAmount == desiredMakerToken,\n \"DesiredMakerAmount mismatch\"\n );\n require(\n order.makerToken == makerToken,\n \"MakerToken mismatch\"\n );\n require(\n order.takerToken == takerToken,\n \"TakerToken mismatch\"\n );\n\n return order.allegedTakerAmount;\n }\n\n // ============ Private functions ============\n\n function parseData(\n bytes memory orderData\n )\n private\n pure\n returns (Order memory)\n {\n require(\n orderData.length == 224,\n \"orderData invalid length\"\n );\n\n Order memory order;\n\n /* solium-disable-next-line security/no-inline-assembly */\n assembly {\n mstore(order, mload(add(orderData, 32))) // originator\n mstore(add(order, 32), mload(add(orderData, 64))) // makerToken\n mstore(add(order, 64), mload(add(orderData, 96))) // takerToken\n mstore(add(order, 96), mload(add(orderData, 128))) // makerAmount\n mstore(add(order, 128), mload(add(orderData, 160))) // takerAmount\n mstore(add(order, 160), mload(add(orderData, 192))) // allegedTakerAmount\n mstore(add(order, 192), mload(add(orderData, 224))) // desiredMakerAmount\n }\n\n return order;\n }\n}\n",
"sourcePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/testing/TestExchangeWrapper.sol",
"ast": {
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/testing/TestExchangeWrapper.sol",
"exportedSymbols": {
"TestExchangeWrapper": [
33769
]
},
"id": 33770,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 33592,
"literals": [
"solidity",
"^",
"0.5",
".9"
],
"nodeType": "PragmaDirective",
"src": "603:23:121"
},
{
"absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol",
"file": "@openzeppelin/contracts/token/ERC20/IERC20.sol",
"id": 33594,
"nodeType": "ImportDirective",
"scope": 33770,
"sourceUnit": 37553,
"src": "628:72:121",
"symbolAliases": [
{
"foreign": 33593,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "@openzeppelin/contracts/token/ERC20/SafeERC20.sol",
"file": "@openzeppelin/contracts/token/ERC20/SafeERC20.sol",
"id": 33596,
"nodeType": "ImportDirective",
"scope": 33770,
"sourceUnit": 37773,
"src": "701:78:121",
"symbolAliases": [
{
"foreign": 33595,
"local": null
}
],
"unitAlias": ""
},
{
"absolutePath": "/home/cdc218/projects/dolomite-protocol-v2/contracts/protocol/interfaces/IExchangeWrapper.sol",
"file": "../protocol/interfaces/IExchangeWrapper.sol",
"id": 33598,
"nodeType": "ImportDirective",
"scope": 33770,
"sourceUnit": 24750,
"src": "781:79:121",
"symbolAliases": [
{
"foreign": 33597,
"local": null
}
],
"unitAlias": ""
},
{
"baseContracts": [
{
"arguments": null,
"baseName": {
"contractScope": null,
"id": 33599,
"name": "IExchangeWrapper",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 24749,
"src": "986:16:121",
"typeDescriptions": {
"typeIdentifier": "t_contract$_IExchangeWrapper_$24749",
"typeString": "contract IExchangeWrapper"
}
},
"id": 33600,
"nodeType": "InheritanceSpecifier",
"src": "986:16:121"
}
],
"contractDependencies": [
24749
],
"contractKind": "contract",
"documentation": "@title TestExchangeWrapper\n@author dYdX\n * An ExchangeWrapper for testing",
"fullyImplemented": true,
"id": 33769,
"linearizedBaseContracts": [
33769,
24749
],
"name": "TestExchangeWrapper",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 33603,
"libraryName": {
"contractScope": null,
"id": 33601,
"name": "SafeERC20",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 37772,
"src": "1015:9:121",
"typeDescriptions": {
"typeIdentifier": "t_contract$_SafeERC20_$37772",
"typeString": "library SafeERC20"
}
},
"nodeType": "UsingForDirective",
"src": "1009:27:121",
"typeName": {
"contractScope": null,
"id": 33602,
"name": "IERC20",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 37552,
"src": "1029:6:121",
"typeDescriptions": {
"typeIdentifier": "t_contract$_IERC20_$37552",
"typeString": "contract IERC20"
}
}
},
{
"constant": true,
"id": 33608,
"name": "EXCHANGE_ADDRESS",
"nodeType": "VariableDeclaration",
"scope": 33769,
"src": "1151:55:121",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 33604,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1151:7:121",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"hexValue": "307831",
"id": 33606,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1202:3:121",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "0x1"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
}
],
"id": 33605,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "1194:7:121",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_address_$",
"typeString": "type(address)"
},
"typeName": "address"
},
"id": 33607,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1194:12:121",
"typeDescriptions": {
"typeIdentifier": "t_address_payable",
"typeString": "address payable"
}
},
"visibility": "public"
},
{
"canonicalName": "TestExchangeWrapper.Order",
"id": 33623,
"members": [
{
"constant": false,
"id": 33610,
"name": "originator",
"nodeType": "VariableDeclaration",
"scope": 33623,
"src": "1278:18:121",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 33609,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1278:7:121",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 33612,
"name": "makerToken",
"nodeType": "VariableDeclaration",
"scope": 33623,
"src": "1306:18:121",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 33611,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1306:7:121",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 33614,
"name": "takerToken",
"nodeType": "VariableDeclaration",
"scope": 33623,
"src": "1334:18:121",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 33613,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "1334:7:121",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 33616,
"name": "makerAmount",
"nodeType": "VariableDeclaration",
"scope": 33623,
"src": "1362:19:121",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 33615,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1362:7:121",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 33618,
"name": "takerAmount",
"nodeType": "VariableDeclaration",
"scope": 33623,
"src": "1391:19:121",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 33617,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1391:7:121",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 33620,
"name": "allegedTakerAmount",
"nodeType": "VariableDeclaration",
"scope": 33623,
"src": "1420:26:121",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 33619,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1420:7:121",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 33622,
"name": "desiredMakerAmount",
"nodeType": "VariableDeclaration",
"scope": 33623,
"src": "1456:26:121",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 33621,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "1456:7:121",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "Order",
"nodeType": "StructDefinition",
"scope": 33769,
"src": "1255:234:121",
"visibility": "public"
},
{
"body": {
"id": 33698,
"nodeType": "Block",
"src": "1804:683:121",
"statements": [
{
"assignments": [
33641
],
"declarations": [
{
"constant": false,
"id": 33641,
"name": "order",
"nodeType": "VariableDeclaration",
"scope": 33698,
"src": "1814:18:121",
"stateVariable": false,
"storageLocation": "memory",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Order_$33623_memory_ptr",
"typeString": "struct TestExchangeWrapper.Order"
},
"typeName": {
"contractScope": null,
"id": 33640,
"name": "Order",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 33623,
"src": "1814:5:121",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Order_$33623_storage_ptr",
"typeString": "struct TestExchangeWrapper.Order"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 33645,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 33643,
"name": "orderData",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 33635,
"src": "1845:9:121",
"typeDescriptions": {
"typeIdentifier": "t_bytes_calldata_ptr",
"typeString": "bytes calldata"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bytes_calldata_ptr",
"typeString": "bytes calldata"
}
],
"id": 33642,
"name": "parseData",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 33768,
"src": "1835:9:121",
"typeDescriptions": {
"typeIdentifier": "t_function_internal_pure$_t_bytes_memory_ptr_$returns$_t_struct$_Order_$33623_memory_ptr_$",
"typeString": "function (bytes memory) pure returns (struct TestExchangeWrapper.Order memory)"
}
},
"id": 33644,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "1835:20:121",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Order_$33623_memory_ptr",
"typeString": "struct TestExchangeWrapper.Order memory"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "1814:41:121"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"id": 33650,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 33647,
"name": "order",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 33641,
"src": "1887:5:121",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Order_$33623_memory_ptr",
"typeString": "struct TestExchangeWrapper.Order memory"
}
},
"id": 33648,
"isConstant": false,
"isLValue": true,
"isPure": false,
"lValueRequested": false,
"memberName": "originator",
"nodeType": "MemberAccess",
"referencedDeclaration": 33610,
"src": "1887:16:121",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"id": 33649,
"name": "tradeOriginator",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 33625,
"src": "1907:15:121",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"src": "1887:35:121",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "4f726967696e61746f72206d69736d61746368",
"id": 33651,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1936:21:121",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_bade15c1857e1bdcc4560ada22bab9d665c465f0a0e4b423a21b637b7ff4b937",
"typeString": "literal_string \"Originator mismatch\""
},
"value": "Originator mismatch"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_bade15c1857e1bdcc4560ada22bab9d665c465f0a0e4b423a21b637b7ff4b937",
"typeString": "literal_string \"Originator mismatch\""
}
],
"id": 33646,
"name": "require",
"nodeType": "Identifier",
"overloadedDeclarations": [
38110,