@josojo/realitytoken-contracts
Version:
realitytoken basic contracts
338 lines • 700 kB
JSON
{
"contractName": "LMSRMarketMaker",
"abi": [
{
"constant": true,
"inputs": [
{
"name": "market",
"type": "address"
},
{
"name": "outcomeTokenIndex",
"type": "uint8"
},
{
"name": "outcomeTokenCount",
"type": "uint256"
}
],
"name": "calcCost",
"outputs": [
{
"name": "cost",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "market",
"type": "address"
},
{
"name": "outcomeTokenIndex",
"type": "uint8"
},
{
"name": "outcomeTokenCount",
"type": "uint256"
}
],
"name": "calcProfit",
"outputs": [
{
"name": "profit",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "market",
"type": "address"
},
{
"name": "outcomeTokenIndex",
"type": "uint8"
}
],
"name": "calcMarginalPrice",
"outputs": [
{
"name": "price",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b50611375806100206000396000f30060806040526004361061003d5763ffffffff60e060020a6000350416634091c6a98114610042578063bd8ff8171461007e578063d812d346146100a8575b600080fd5b34801561004e57600080fd5b5061006c600160a060020a036004351660ff602435166044356100cf565b60408051918252519081900360200190f35b34801561008a57600080fd5b5061006c600160a060020a036004351660ff6024351660443561041e565b3480156100b457600080fd5b5061006c600160a060020a036004351660ff602435166107ac565b60006060600080600080600189600160a060020a031663e274fd246040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561011957600080fd5b505af115801561012d573d6000803e3d6000fd5b505050506040513d602081101561014357600080fd5b50516040805160e160020a633ee478430281529051600160a060020a0390921691637dc8f086916004808201926020929091908290030181600087803b15801561018c57600080fd5b505af11580156101a0573d6000803e3d6000fd5b505050506040513d60208110156101b657600080fd5b505160ff16116101c557600080fd5b6101ce89610a1a565b945073__Math__________________________________6320ddd2556801000000000000000087510260016040518363ffffffff1660e060020a0281526004018083815260200182600281111561022157fe5b60ff1681526020019250505060206040518083038186803b15801561024557600080fd5b505af4158015610259573d6000803e3d6000fd5b505050506040513d602081101561026f57600080fd5b5051604080517fcb4c86b70000000000000000000000000000000000000000000000000000000081529051919550600160a060020a038b169163cb4c86b7916004808201926020929091908290030181600087803b1580156102d057600080fd5b505af11580156102e4573d6000803e3d6000fd5b505050506040513d60208110156102fa57600080fd5b5051925061030b8486856000610bdd565b9150600087121561031b57600080fd5b848860ff1681518110151561032c57fe5b6020908102909101810151604080517fadefc37b0000000000000000000000000000000000000000000000000000000081526004810192909252602482018a90525173__Math__________________________________9263adefc37b9260448082019391829003018186803b1580156103a557600080fd5b505af41580156103b9573d6000803e3d6000fd5b505050506040513d60208110156103cf57600080fd5b50518551869060ff8b169081106103e257fe5b602090810290910101526103f98486856001610bdd565b9050808213610406578091505b68010000000000000000910304979650505050505050565b60006060600080600080600189600160a060020a031663e274fd246040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561046857600080fd5b505af115801561047c573d6000803e3d6000fd5b505050506040513d602081101561049257600080fd5b50516040805160e160020a633ee478430281529051600160a060020a0390921691637dc8f086916004808201926020929091908290030181600087803b1580156104db57600080fd5b505af11580156104ef573d6000803e3d6000fd5b505050506040513d602081101561050557600080fd5b505160ff161161051457600080fd5b61051d89610a1a565b945073__Math__________________________________6320ddd2556801000000000000000087510260016040518363ffffffff1660e060020a0281526004018083815260200182600281111561057057fe5b60ff1681526020019250505060206040518083038186803b15801561059457600080fd5b505af41580156105a8573d6000803e3d6000fd5b505050506040513d60208110156105be57600080fd5b5051604080517fcb4c86b70000000000000000000000000000000000000000000000000000000081529051919550600160a060020a038b169163cb4c86b7916004808201926020929091908290030181600087803b15801561061f57600080fd5b505af1158015610633573d6000803e3d6000fd5b505050506040513d602081101561064957600080fd5b5051925061065a8486856000610bdd565b9150600087121561066a57600080fd5b848860ff1681518110151561067b57fe5b6020908102909101810151604080517fa5f3c23b0000000000000000000000000000000000000000000000000000000081526004810192909252602482018a90525173__Math__________________________________9263a5f3c23b9260448082019391829003018186803b1580156106f457600080fd5b505af4158015610708573d6000803e3d6000fd5b505050506040513d602081101561071e57600080fd5b50518551869060ff8b1690811061073157fe5b602090810290910101526107488486856001610bdd565b9050818112156107555750805b81810395508568010000000000000000808204021415610782576801000000000000000086049550610794565b68010000000000000000860460010195505b868611156107a0578695505b50505050509392505050565b60006060600080600080600188600160a060020a031663e274fd246040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156107f657600080fd5b505af115801561080a573d6000803e3d6000fd5b505050506040513d602081101561082057600080fd5b50516040805160e160020a633ee478430281529051600160a060020a0390921691637dc8f086916004808201926020929091908290030181600087803b15801561086957600080fd5b505af115801561087d573d6000803e3d6000fd5b505050506040513d602081101561089357600080fd5b505160ff16116108a257600080fd5b6108ab88610a1a565b945073__Math__________________________________6320ddd2556801000000000000000087510260026040518363ffffffff1660e060020a028152600401808381526020018260028111156108fe57fe5b60ff1681526020019250505060206040518083038186803b15801561092257600080fd5b505af4158015610936573d6000803e3d6000fd5b505050506040513d602081101561094c57600080fd5b5051604080517fcb4c86b70000000000000000000000000000000000000000000000000000000081529051919550600160a060020a038a169163cb4c86b7916004808201926020929091908290030181600087803b1580156109ad57600080fd5b505af11580156109c1573d6000803e3d6000fd5b505050506040513d60208110156109d757600080fd5b505192506109e98486858a6002610e72565b92505091506801000000000000000082811515610a0257fe5b0481811515610a0d57fe5b0498975050505050505050565b6060600082600160a060020a031663e274fd246040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610a5c57600080fd5b505af1158015610a70573d6000803e3d6000fd5b505050506040513d6020811015610a8657600080fd5b50516040805160e160020a633ee478430281529051600160a060020a0390921691637dc8f086916004808201926020929091908290030181600087803b158015610acf57600080fd5b505af1158015610ae3573d6000803e3d6000fd5b505050506040513d6020811015610af957600080fd5b50516040805160ff90921680835260208181028401019091528015610b28578160200160208202803883390190505b509150600090505b81518160ff161015610bd75782600160a060020a031663a157979c826040518263ffffffff1660e060020a028152600401808260ff168152602001915050602060405180830381600087803b158015610b8857600080fd5b505af1158015610b9c573d6000803e3d6000fd5b505050506040513d6020811015610bb257600080fd5b50518251839060ff8416908110610bc557fe5b60209081029091010152600101610b30565b50919050565b6000806000610bf0878787600088610e72565b509150915073__Math__________________________________6320ddd25583866040518363ffffffff1660e060020a02815260040180838152602001826002811115610c3957fe5b60ff1681526020019250505060206040518083038186803b158015610c5d57600080fd5b505af4158015610c71573d6000803e3d6000fd5b505050506040513d6020811015610c8757600080fd5b5051604080517fa5f3c23b0000000000000000000000000000000000000000000000000000000081526004810183905260248101849052905191945073__Math__________________________________9163a5f3c23b91604480820192602092909190829003018186803b158015610cff57600080fd5b505af4158015610d13573d6000803e3d6000fd5b505050506040513d6020811015610d2957600080fd5b5051604080517fbbe93d91000000000000000000000000000000000000000000000000000000008152600481018390526801000000000000000060248201529051919450889173__Math__________________________________9163bbe93d91916044808301926020929190829003018186803b158015610daa57600080fd5b505af4158015610dbe573d6000803e3d6000fd5b505050506040513d6020811015610dd457600080fd5b5051811515610ddf57fe5b0573__Math__________________________________63bbe93d919091876040518363ffffffff1660e060020a028152600401808381526020018281526020019250505060206040518083038186803b158015610e3b57600080fd5b505af4158015610e4f573d6000803e3d6000fd5b505050506040513d6020811015610e6557600080fd5b5051979650505050505050565b6000806000806000808a12158015610e8b575060008812155b1515610e9657600080fd5b6040517fccc138140000000000000000000000000000000000000000000000000000000081526020600482018181528b5160248401528b5173__Math__________________________________9363ccc13814938e9392839260440191808601910280838360005b83811015610f16578181015183820152602001610efe565b505050509050019250505060206040518083038186803b158015610f3957600080fd5b505af4158015610f4d573d6000803e3d6000fd5b505050506040513d6020811015610f6357600080fd5b5051604080517fbbe93d9100000000000000000000000000000000000000000000000000000000815260048101839052602481018d90529051919550899173__Math__________________________________9163bbe93d91916044808301926020929190829003018186803b158015610fdc57600080fd5b505af4158015610ff0573d6000803e3d6000fd5b505050506040513d602081101561100657600080fd5b505181151561101157fe5b0593508373__Math__________________________________63adefc37b909168b800000000000000006040518363ffffffff1660e060020a028152600401808381526020018281526020019250505060206040518083038186803b15801561107957600080fd5b505af415801561108d573d6000803e3d6000fd5b505050506040513d60208110156110a357600080fd5b50519350600090505b88518160ff16101561133c5773__Math__________________________________6384059dd0898b8460ff168151811015156110e457fe5b9060200190602002015173__Math__________________________________63bbe93d9190918f6040518363ffffffff1660e060020a028152600401808381526020018281526020019250505060206040518083038186803b15801561114957600080fd5b505af415801561115d573d6000803e3d6000fd5b505050506040513d602081101561117357600080fd5b505181151561117e57fe5b0573__Math__________________________________63adefc37b9091886040518363ffffffff1660e060020a028152600401808381526020018281526020019250505060206040518083038186803b1580156111da57600080fd5b505af41580156111ee573d6000803e3d6000fd5b505050506040513d602081101561120457600080fd5b505160405160e060020a63ffffffff8416028152600481018281528a9160240182600281111561123057fe5b60ff1681526020019250505060206040518083038186803b15801561125457600080fd5b505af4158015611268573d6000803e3d6000fd5b505050506040513d602081101561127e57600080fd5b5051915060ff8181169088161415611294578192505b604080517f771602f70000000000000000000000000000000000000000000000000000000081526004810187905260248101849052905173__Math__________________________________9163771602f7916044808301926020929190829003018186803b15801561130657600080fd5b505af415801561131a573d6000803e3d6000fd5b505050506040513d602081101561133057600080fd5b505194506001016110ac565b50509550955095925050505600a165627a7a72305820c0b316a21c996accbd4eceaa504292142fcd597f88767f5f0895b080a5dc04260029",
"deployedBytecode": "0x60806040526004361061003d5763ffffffff60e060020a6000350416634091c6a98114610042578063bd8ff8171461007e578063d812d346146100a8575b600080fd5b34801561004e57600080fd5b5061006c600160a060020a036004351660ff602435166044356100cf565b60408051918252519081900360200190f35b34801561008a57600080fd5b5061006c600160a060020a036004351660ff6024351660443561041e565b3480156100b457600080fd5b5061006c600160a060020a036004351660ff602435166107ac565b60006060600080600080600189600160a060020a031663e274fd246040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561011957600080fd5b505af115801561012d573d6000803e3d6000fd5b505050506040513d602081101561014357600080fd5b50516040805160e160020a633ee478430281529051600160a060020a0390921691637dc8f086916004808201926020929091908290030181600087803b15801561018c57600080fd5b505af11580156101a0573d6000803e3d6000fd5b505050506040513d60208110156101b657600080fd5b505160ff16116101c557600080fd5b6101ce89610a1a565b945073__Math__________________________________6320ddd2556801000000000000000087510260016040518363ffffffff1660e060020a0281526004018083815260200182600281111561022157fe5b60ff1681526020019250505060206040518083038186803b15801561024557600080fd5b505af4158015610259573d6000803e3d6000fd5b505050506040513d602081101561026f57600080fd5b5051604080517fcb4c86b70000000000000000000000000000000000000000000000000000000081529051919550600160a060020a038b169163cb4c86b7916004808201926020929091908290030181600087803b1580156102d057600080fd5b505af11580156102e4573d6000803e3d6000fd5b505050506040513d60208110156102fa57600080fd5b5051925061030b8486856000610bdd565b9150600087121561031b57600080fd5b848860ff1681518110151561032c57fe5b6020908102909101810151604080517fadefc37b0000000000000000000000000000000000000000000000000000000081526004810192909252602482018a90525173__Math__________________________________9263adefc37b9260448082019391829003018186803b1580156103a557600080fd5b505af41580156103b9573d6000803e3d6000fd5b505050506040513d60208110156103cf57600080fd5b50518551869060ff8b169081106103e257fe5b602090810290910101526103f98486856001610bdd565b9050808213610406578091505b68010000000000000000910304979650505050505050565b60006060600080600080600189600160a060020a031663e274fd246040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561046857600080fd5b505af115801561047c573d6000803e3d6000fd5b505050506040513d602081101561049257600080fd5b50516040805160e160020a633ee478430281529051600160a060020a0390921691637dc8f086916004808201926020929091908290030181600087803b1580156104db57600080fd5b505af11580156104ef573d6000803e3d6000fd5b505050506040513d602081101561050557600080fd5b505160ff161161051457600080fd5b61051d89610a1a565b945073__Math__________________________________6320ddd2556801000000000000000087510260016040518363ffffffff1660e060020a0281526004018083815260200182600281111561057057fe5b60ff1681526020019250505060206040518083038186803b15801561059457600080fd5b505af41580156105a8573d6000803e3d6000fd5b505050506040513d60208110156105be57600080fd5b5051604080517fcb4c86b70000000000000000000000000000000000000000000000000000000081529051919550600160a060020a038b169163cb4c86b7916004808201926020929091908290030181600087803b15801561061f57600080fd5b505af1158015610633573d6000803e3d6000fd5b505050506040513d602081101561064957600080fd5b5051925061065a8486856000610bdd565b9150600087121561066a57600080fd5b848860ff1681518110151561067b57fe5b6020908102909101810151604080517fa5f3c23b0000000000000000000000000000000000000000000000000000000081526004810192909252602482018a90525173__Math__________________________________9263a5f3c23b9260448082019391829003018186803b1580156106f457600080fd5b505af4158015610708573d6000803e3d6000fd5b505050506040513d602081101561071e57600080fd5b50518551869060ff8b1690811061073157fe5b602090810290910101526107488486856001610bdd565b9050818112156107555750805b81810395508568010000000000000000808204021415610782576801000000000000000086049550610794565b68010000000000000000860460010195505b868611156107a0578695505b50505050509392505050565b60006060600080600080600188600160a060020a031663e274fd246040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156107f657600080fd5b505af115801561080a573d6000803e3d6000fd5b505050506040513d602081101561082057600080fd5b50516040805160e160020a633ee478430281529051600160a060020a0390921691637dc8f086916004808201926020929091908290030181600087803b15801561086957600080fd5b505af115801561087d573d6000803e3d6000fd5b505050506040513d602081101561089357600080fd5b505160ff16116108a257600080fd5b6108ab88610a1a565b945073__Math__________________________________6320ddd2556801000000000000000087510260026040518363ffffffff1660e060020a028152600401808381526020018260028111156108fe57fe5b60ff1681526020019250505060206040518083038186803b15801561092257600080fd5b505af4158015610936573d6000803e3d6000fd5b505050506040513d602081101561094c57600080fd5b5051604080517fcb4c86b70000000000000000000000000000000000000000000000000000000081529051919550600160a060020a038a169163cb4c86b7916004808201926020929091908290030181600087803b1580156109ad57600080fd5b505af11580156109c1573d6000803e3d6000fd5b505050506040513d60208110156109d757600080fd5b505192506109e98486858a6002610e72565b92505091506801000000000000000082811515610a0257fe5b0481811515610a0d57fe5b0498975050505050505050565b6060600082600160a060020a031663e274fd246040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610a5c57600080fd5b505af1158015610a70573d6000803e3d6000fd5b505050506040513d6020811015610a8657600080fd5b50516040805160e160020a633ee478430281529051600160a060020a0390921691637dc8f086916004808201926020929091908290030181600087803b158015610acf57600080fd5b505af1158015610ae3573d6000803e3d6000fd5b505050506040513d6020811015610af957600080fd5b50516040805160ff90921680835260208181028401019091528015610b28578160200160208202803883390190505b509150600090505b81518160ff161015610bd75782600160a060020a031663a157979c826040518263ffffffff1660e060020a028152600401808260ff168152602001915050602060405180830381600087803b158015610b8857600080fd5b505af1158015610b9c573d6000803e3d6000fd5b505050506040513d6020811015610bb257600080fd5b50518251839060ff8416908110610bc557fe5b60209081029091010152600101610b30565b50919050565b6000806000610bf0878787600088610e72565b509150915073__Math__________________________________6320ddd25583866040518363ffffffff1660e060020a02815260040180838152602001826002811115610c3957fe5b60ff1681526020019250505060206040518083038186803b158015610c5d57600080fd5b505af4158015610c71573d6000803e3d6000fd5b505050506040513d6020811015610c8757600080fd5b5051604080517fa5f3c23b0000000000000000000000000000000000000000000000000000000081526004810183905260248101849052905191945073__Math__________________________________9163a5f3c23b91604480820192602092909190829003018186803b158015610cff57600080fd5b505af4158015610d13573d6000803e3d6000fd5b505050506040513d6020811015610d2957600080fd5b5051604080517fbbe93d91000000000000000000000000000000000000000000000000000000008152600481018390526801000000000000000060248201529051919450889173__Math__________________________________9163bbe93d91916044808301926020929190829003018186803b158015610daa57600080fd5b505af4158015610dbe573d6000803e3d6000fd5b505050506040513d6020811015610dd457600080fd5b5051811515610ddf57fe5b0573__Math__________________________________63bbe93d919091876040518363ffffffff1660e060020a028152600401808381526020018281526020019250505060206040518083038186803b158015610e3b57600080fd5b505af4158015610e4f573d6000803e3d6000fd5b505050506040513d6020811015610e6557600080fd5b5051979650505050505050565b6000806000806000808a12158015610e8b575060008812155b1515610e9657600080fd5b6040517fccc138140000000000000000000000000000000000000000000000000000000081526020600482018181528b5160248401528b5173__Math__________________________________9363ccc13814938e9392839260440191808601910280838360005b83811015610f16578181015183820152602001610efe565b505050509050019250505060206040518083038186803b158015610f3957600080fd5b505af4158015610f4d573d6000803e3d6000fd5b505050506040513d6020811015610f6357600080fd5b5051604080517fbbe93d9100000000000000000000000000000000000000000000000000000000815260048101839052602481018d90529051919550899173__Math__________________________________9163bbe93d91916044808301926020929190829003018186803b158015610fdc57600080fd5b505af4158015610ff0573d6000803e3d6000fd5b505050506040513d602081101561100657600080fd5b505181151561101157fe5b0593508373__Math__________________________________63adefc37b909168b800000000000000006040518363ffffffff1660e060020a028152600401808381526020018281526020019250505060206040518083038186803b15801561107957600080fd5b505af415801561108d573d6000803e3d6000fd5b505050506040513d60208110156110a357600080fd5b50519350600090505b88518160ff16101561133c5773__Math__________________________________6384059dd0898b8460ff168151811015156110e457fe5b9060200190602002015173__Math__________________________________63bbe93d9190918f6040518363ffffffff1660e060020a028152600401808381526020018281526020019250505060206040518083038186803b15801561114957600080fd5b505af415801561115d573d6000803e3d6000fd5b505050506040513d602081101561117357600080fd5b505181151561117e57fe5b0573__Math__________________________________63adefc37b9091886040518363ffffffff1660e060020a028152600401808381526020018281526020019250505060206040518083038186803b1580156111da57600080fd5b505af41580156111ee573d6000803e3d6000fd5b505050506040513d602081101561120457600080fd5b505160405160e060020a63ffffffff8416028152600481018281528a9160240182600281111561123057fe5b60ff1681526020019250505060206040518083038186803b15801561125457600080fd5b505af4158015611268573d6000803e3d6000fd5b505050506040513d602081101561127e57600080fd5b5051915060ff8181169088161415611294578192505b604080517f771602f70000000000000000000000000000000000000000000000000000000081526004810187905260248101849052905173__Math__________________________________9163771602f7916044808301926020929190829003018186803b15801561130657600080fd5b505af415801561131a573d6000803e3d6000fd5b505050506040513d602081101561133057600080fd5b505194506001016110ac565b50509550955095925050505600a165627a7a72305820c0b316a21c996accbd4eceaa504292142fcd597f88767f5f0895b080a5dc04260029",
"sourceMap": "251:8633:7:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;251:8633:7;;;;;;;",
"deployedSourceMap": "251:8633:7:-;;;;;;;;;-1:-1:-1;;;251:8633:7;;;;;;;;;;;;;;;;;;;;;;;2578:1265;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;2578:1265:7;-1:-1:-1;;;;;2578:1265:7;;;;;;;;;;;;;;;;;;;;;;;;;;;737:1579;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;737:1579:7;-1:-1:-1;;;;;737:1579:7;;;;;;;;;;;4087:819;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;4087:819:7;-1:-1:-1;;;;;4087:819:7;;;;;;;;;2578:1265;2711:11;2801:33;2946:9;3044:12;3085:19;3498:18;2789:1;2746:6;-1:-1:-1;;;;;2746:20:7;;:22;;;;;-1:-1:-1;;;2746:22:7;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2746:22:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2746:22:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;2746:22:7;:40;;;-1:-1:-1;;;;;2746:40:7;;;;-1:-1:-1;;;;;2746:38:7;;;;;;:40;;;;;:22;;:40;;;;;;;;;:38;:40;;;5:2:-1;;;;30:1;27;20:12;5:2;2746:40:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2746:40:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;2746:40:7;:44;;;2738:53;;;;;;2837:31;2861:6;2837:23;:31::i;:::-;2801:67;;2958:4;:9;373:19;2968:20;:27;:33;3003:30;2958:76;;;;;-1:-1:-1;;;2958:76:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2958:76:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2958:76:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;2958:76:7;3059:16;;;;;;;;2958:76;;-1:-1:-1;;;;;;3059:14:7;;;;;:16;;;;;2958:76;;3059:16;;;;;;;;;:14;:16;;;5:2:-1;;;;30:1;27;20:12;5:2;3059:16:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3059:16:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;3059:16:7;;-1:-1:-1;3107:83:7;3121:5;3128:20;3059:16;3159:30;3107:13;:83::i;:::-;3085:105;-1:-1:-1;3309:1:7;3283:27;;;3275:36;;;;;;3363:20;3384:17;3363:39;;;;;;;;;;;;;;;;;;;;;;:67;;;;;;;;;;;;;;;;;;;;:43;;;;:67;;;;;;;;;;;:43;:67;;;5:2:-1;;;;30:1;27;20:12;5:2;3363:67:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3363:67:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;3363:67:7;3321:39;;:20;;:39;;;;;;;;;;;;;;;;;;:109;3519:83;3533:5;3540:20;3562:7;3571:30;3519:13;:83::i;:::-;3498:104;-1:-1:-1;3668:33:7;;;3665:82;;3733:14;3715:32;;3665:82;373:19;3797:32;;3792:44;;;-1:-1:-1;;;;;;;2578:1265:7:o;737:1579::-;868:9;956:33;1101:9;1199:12;1240:19;1642:18;944:1;901:6;-1:-1:-1;;;;;901:20:7;;:22;;;;;-1:-1:-1;;;901:22:7;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;901:22:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;901:22:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;901:22:7;:40;;;-1:-1:-1;;;;;901:40:7;;;;-1:-1:-1;;;;;901:38:7;;;;;;:40;;;;;:22;;:40;;;;;;;;;:38;:40;;;5:2:-1;;;;30:1;27;20:12;5:2;901:40:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;901:40:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;901:40:7;:44;;;893:53;;;;;;992:31;1016:6;992:23;:31::i;:::-;956:67;;1113:4;:9;373:19;1123:20;:27;:33;1158:30;1113:76;;;;;-1:-1:-1;;;1113:76:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1113:76:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1113:76:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;1113:76:7;1214:16;;;;;;;;1113:76;;-1:-1:-1;;;;;;1214:14:7;;;;;:16;;;;;1113:76;;1214:16;;;;;;;;;:14;:16;;;5:2:-1;;;;30:1;27;20:12;5:2;1214:16:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1214:16:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;1214:16:7;;-1:-1:-1;1262:83:7;1276:5;1283:20;1214:16;1314:30;1262:13;:83::i;:::-;1240:105;-1:-1:-1;1453:1:7;1427:27;;;1419:36;;;;;;1507:20;1528:17;1507:39;;;;;;;;;;;;;;;;;;;;;;:67;;;;;;;;;;;;;;;;;;;;:43;;;;:67;;;;;;;;;;;:43;:67;;;5:2:-1;;;;30:1;27;20:12;5:2;1507:67:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1507:67:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;1507:67:7;1465:39;;:20;;:39;;;;;;;;;;;;;;;;;;:109;1663:83;1677:5;1684:20;1706:7;1715:30;1663:13;:83::i;:::-;1642:104;;1827:15;1810:14;:32;1807:81;;;-1:-1:-1;1873:15:7;1807:81;1910:32;;;;-1:-1:-1;1910:32:7;373:19;;1910:32;2009:10;:16;:24;2005:171;;;373:19;2047:11;;;;2005:171;;;373:19;2162:4;:10;2175:1;2162:14;2155:21;;2005:171;2254:17;2247:4;:24;2243:66;;;2292:17;2285:24;;2243:66;737:1579;;;;;;;;;;:::o;4087:819::-;4203:10;4292:33;4369:8;4464:12;4731:3;4738:14;4280:1;4237:6;-1:-1:-1;;;;;4237:20:7;;:22;;;;;-1:-1:-1;;;4237:22:7;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;4237:22:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;4237:22:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;4237:22:7;:40;;;-1:-1:-1;;;;;4237:40:7;;;;-1:-1:-1;;;;;4237:38:7;;;;;;:40;;;;;:22;;:40;;;;;;;;;:38;:40;;;5:2:-1;;;;30:1;27;20:12;5:2;4237:40:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;4237:40:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;4237:40:7;:44;;;4229:53;;;;;;4328:31;4352:6;4328:23;:31::i;:::-;4292:67;;4380:4;:9;373:19;4390:20;:27;:33;4425:28;4380:74;;;;;-1:-1:-1;;;4380:74:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;4380:74:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;4380:74:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;4380:74:7;4479:16;;;;;;;;4380:74;;-1:-1:-1;;;;;;4479:14:7;;;;;:16;;;;;4380:74;;4479:16;;;;;;;;;:14;:16;;;5:2:-1;;;;30:1;27;20:12;5:2;4479:16:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;4479:16:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;4479:16:7;;-1:-1:-1;4756:98:7;4769:4;4775:20;4479:16;4806:17;4825:28;4756:12;:98::i;:::-;4726:128;;;;;373:19;4889:3;:9;;;;;;;;4871:14;:28;;;;;;;;;4087:819;-1:-1:-1;;;;;;;;4087:819:7:o;8567:315::-;8665:16;8776:7;8720:6;-1:-1:-1;;;;;8720:20:7;;:22;;;;;-1:-1:-1;;;8720:22:7;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;8720:22:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;8720:22:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;8720:22:7;:40;;;-1:-1:-1;;;;;8720:40:7;;;;-1:-1:-1;;;;;8720:38:7;;;;;;:40;;;;;:22;;:40;;;;;;;;;:38;:40;;;5:2:-1;;;;30:1;27;20:12;5:2;8720:40:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;8720:40:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;8720:40:7;8710:51;;;;;;;;;;8720:40;8710:51;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;8710:51:7;;8697:64;;8786:1;8776:11;;8771:104;8793:10;:17;8789:1;:21;;;8771:104;;;8845:6;-1:-1:-1;;;;;8845:27:7;;8873:1;8845:30;;;;;-1:-1:-1;;;8845:30:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;8845:30:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;8845:30:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;8845:30:7;8829:13;;:10;;:13;;;;;;;;;;;;;;;;;;:46;8812:3;;8771:104;;;8567:315;;;;:::o;5283:682::-;5443:13;5706:3;5711:6;5723:68;5736:4;5742:20;5764:7;5773:1;5776:14;5723:12;:68::i;:::-;5701:90;;;;;5813:4;:9;5823:3;5828:14;5813:30;;;;;-1:-1:-1;;;5813:30:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;5813:30:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;5813:30:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;5813:30:7;5865:21;;;;;;;;;;;;;;;;;;;;5813:30;;-1:-1:-1;5865:13:7;;;;:21;;;;;5813:30;;5865:21;;;;;;;;:13;:21;;;5:2:-1;;;;30:1;27;20:12;5:2;5865:21:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;5865:21:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;5865:21:7;5909:23;;;;;;;;;;;;373:19;5909:23;;;;;;5865:21;;-1:-1:-1;5935:4:7;;5909:13;;;;:23;;;;;5865:21;;5909:23;;;;;;;:13;:23;;;5:2:-1;;;;30:1;27;20:12;5:2;5909:23:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;5909:23:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;5909:23:7;:30;;;;;;;;5908:36;;;;5949:7;5908:50;;;;;-1:-1:-1;;;5908:50:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;5908:50:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;5908:50:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;5908:50:7;;5283:682;-1:-1:-1;;;;;;;5283:682:7:o;6511:1576::-;6691:8;6701:10;6713:19;7778:9;7802:7;7606:1;7598:4;:9;;:30;;;;;7627:1;7615:7;7611:17;;7598:30;7590:39;;;;;;;;7648:30;;;;;;;;;;;;;;;;;;;;:4;;:8;;7657:20;;7648:30;;;;;;;;;;;;;;;8:100:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;7648:30:7;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;7648:30:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;7648:30:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;7648:30:7;7697:16;;;;;;;;;;;;;;;;;;;;7648:30;;-1:-1:-1;7720:7:7;;7697:10;;;;:16;;;;;7648:30;;7697:16;;;;;;;:10;:16;;;5:2:-1;;;;30:1;27;20:12;5:2;7697:16:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;7697:16:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;7697:16:7;:31;;;;;;;;7688:40;;7747:6;:10;;;;423:22;7747:21;;;;;-1:-1:-1;;;7747:21:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;7747:21:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;7747:21:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;7747:21:7;;-1:-1:-1;7812:1:7;;-1:-1:-1;7797:284:7;7819:20;:27;7815:1;:31;;;7797:284;;;7874:4;:9;7925:7;7885:20;7906:1;7885:23;;;;;;;;;;;;;;;;;;;;:27;;;;7913:4;7885:33;;;;;-1:-1:-1;;;7885:33:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;7885:33:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;7885:33:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;7885:33:7;:48;;;;;;;;7884:54;;;;7939:6;7884:62;;;;;-1:-1:-1;;;7884:62:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;7884:62:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;7884:62:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;7884:62:7;7874:89;;-1:-1:-1;;;7874:89:7;;;;;;;;;;;;7948:14;;7874:89;;7948:14;7874:89;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;7874:89:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;7874:89:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;7874:89:7;;-1:-1:-1;7981:17:7;;;;;;;;7977:60;;;8033:4;8016:21;;7977:60;8057:13;;;;;;;;;;;;;;;;;;;;:7;;;;:13;;;;;;;;;;;;;;:7;:13;;;5:2:-1;;;;30:1;27;20:12;5:2;8057:13:7;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;8057:13:7;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;8057:13:7;;-1:-1:-1;7848:3:7;;7797:284;;;6511:1576;;;;;;;;;;;:::o",
"source": "pragma solidity ^0.4.15;\nimport \"../Utils/Math.sol\";\nimport \"../MarketMakers/MarketMaker.sol\";\n\n\n/// @title LMSR market maker contract - Calculates share prices based on share distribution and initial funding\n/// @author Alan Lu - <alan.lu@gnosis.pm>\ncontract LMSRMarketMaker is MarketMaker {\n using Math for *;\n\n /*\n * Constants\n */\n uint constant ONE = 0x10000000000000000;\n int constant EXP_LIMIT = 3394200909562557497344;\n\n /*\n * Public functions\n */\n /// @dev Returns cost to buy given number of outcome tokens\n /// @param market Market contract\n /// @param outcomeTokenIndex Index of outcome to buy\n /// @param outcomeTokenCount Number of outcome tokens to buy\n /// @return Cost\n function calcCost(Market market, uint8 outcomeTokenIndex, uint outcomeTokenCount)\n public\n constant\n returns (uint cost)\n {\n require(market.eventContract().getOutcomeCount() > 1);\n int[] memory netOutcomeTokensSold = getNetOutcomeTokensSold(market);\n // Calculate cost level based on net outcome token balances\n int log2N = Math.log2(netOutcomeTokensSold.length * ONE, Math.EstimationMode.UpperBound);\n uint funding = market.funding();\n int costLevelBefore = calcCostLevel(log2N, netOutcomeTokensSold, funding, Math.EstimationMode.LowerBound);\n // Add outcome token count to net outcome token balance\n require(int(outcomeTokenCount) >= 0);\n netOutcomeTokensSold[outcomeTokenIndex] = netOutcomeTokensSold[outcomeTokenIndex].add(int(outcomeTokenCount));\n // Calculate cost level after balance was updated\n int costLevelAfter = calcCostLevel(log2N, netOutcomeTokensSold, funding, Math.EstimationMode.UpperBound);\n // Calculate cost as cost level difference\n if(costLevelAfter < costLevelBefore)\n costLevelAfter = costLevelBefore;\n cost = uint(costLevelAfter - costLevelBefore);\n // Take the ceiling to account for rounding\n if (cost / ONE * ONE == cost)\n cost /= ONE;\n else\n // Integer division by ONE ensures there is room to (+ 1)\n cost = cost / ONE + 1;\n // Make sure cost is not bigger than 1 per share\n if (cost > outcomeTokenCount)\n cost = outcomeTokenCount;\n }\n\n /// @dev Returns profit for selling given number of outcome tokens\n /// @param market Market contract\n /// @param outcomeTokenIndex Index of outcome to sell\n /// @param outcomeTokenCount Number of outcome tokens to sell\n /// @return Profit\n function calcProfit(Market market, uint8 outcomeTokenIndex, uint outcomeTokenCount)\n public\n constant\n returns (uint profit)\n {\n require(market.eventContract().getOutcomeCount() > 1);\n int[] memory netOutcomeTokensSold = getNetOutcomeTokensSold(market);\n // Calculate cost level based on net outcome token balances\n int log2N = Math.log2(netOutcomeTokensSold.length * ONE, Math.EstimationMode.UpperBound);\n uint funding = market.funding();\n int costLevelBefore = calcCostLevel(log2N, netOutcomeTokensSold, funding, Math.EstimationMode.LowerBound);\n // Subtract outcome token count from the net outcome token balance\n require(int(outcomeTokenCount) >= 0);\n netOutcomeTokensSold[outcomeTokenIndex] = netOutcomeTokensSold[outcomeTokenIndex].sub(int(outcomeTokenCount));\n // Calculate cost level after balance was updated\n int costLevelAfter = calcCostLevel(log2N, netOutcomeTokensSold, funding, Math.EstimationMode.UpperBound);\n // Calculate profit as cost level difference\n if(costLevelBefore <= costLevelAfter)\n costLevelBefore = costLevelAfter;\n // Take the floor\n profit = uint(costLevelBefore - costLevelAfter) / ONE;\n }\n\n /// @dev Returns marginal price of an outcome\n /// @param market Market contract\n /// @param outcomeTokenIndex Index of outcome to determine marginal price of\n /// @return Marginal price of an outcome as a fixed point number\n function calcMarginalPrice(Market market, uint8 outcomeTokenIndex)\n public\n constant\n returns (uint price)\n {\n require(market.eventContract().getOutcomeCount() > 1);\n int[] memory netOutcomeTokensSold = getNetOutcomeTokensSold(market);\n int logN = Math.log2(netOutcomeTokensSold.length * ONE, Math.EstimationMode.Midpoint);\n uint funding = market.funding();\n // The price function is exp(quantities[i]/b) / sum(exp(q/b) for q in quantities)\n // To avoid overflow, calculate with\n // exp(quantities[i]/b - offset) / sum(exp(q/b - offset) for q in quantities)\n var (sum, , outcomeExpTerm) = sumExpOffset(logN, netOutcomeTokensSold, funding, outcomeTokenIndex, Math.EstimationMode.Midpoint);\n return outcomeExpTerm / (sum / ONE);\n }\n\n /*\n * Private functions\n */\n /// @dev Calculates the result of the LMSR cost function which is used to\n /// derive prices from the market state\n /// @param logN Logarithm of the number of outcomes\n /// @param netOutcomeTokensSold Net outcome tokens sold by market\n /// @param funding Initial funding for market\n /// @return Cost level\n function calcCostLevel(int logN, int[] netOutcomeTokensSold, uint funding, Math.EstimationMode estimationMode)\n private\n constant\n returns(int costLevel)\n {\n // The cost function is C = b * log(sum(exp(q/b) for q in quantities)).\n // To avoid overflow, we need to calc with an exponent offset:\n // C = b * (offset + log(sum(exp(q/b - offset) for q in quantities)))\n var (sum, offset, ) = sumExpOffset(logN, netOutcomeTokensSold, funding, 0, estimationMode);\n costLevel = Math.log2(sum, estimationMode);\n costLevel = costLevel.add(offset);\n costLevel = (costLevel.mul(int(ONE)) / logN).mul(int(funding));\n }\n\n /// @dev Calculates sum(exp(q/b - offset) for q in quantities), where offset is set\n /// so that the sum fits in 248-256 bits\n /// @param logN Logarithm of the number of outcomes\n /// @param netOutcomeTokensSold Net outcome tokens sold by market\n /// @param funding Initial funding for market\n /// @param outcomeIndex Index of exponential term to extract (for use by marginal price function)\n /// @return A result structure composed of the sum, the offset used, and the summand associated with the supplied index\n function sumExpOffset(int logN, int[] netOutcomeTokensSold, uint funding, uint8 outcomeIndex, Math.EstimationMode estimationMode)\n private\n constant\n returns (uint sum, int offset, uint outcomeExpTerm)\n {\n // Naive calculation of this causes an overflow\n // since anything above a bit over 133*ONE supplied to exp will explode\n // as exp(133) just about fits into 192 bits of whole number data.\n\n // The choice of this offset is subject to another limit:\n // computing the inner sum successfully.\n // Since the index is 8 bits, there has to be 8 bits of headroom for\n // each summand, meaning q/b - offset <= exponential_limit,\n // where that limit can be found with `mp.floor(mp.log((2**248 - 1) / ONE) * ONE)`\n // That is what EXP_LIMIT is set to: it is about 127.5\n\n // finally, if the distribution looks like [BIG, tiny, tiny...], using a\n // BIG offset will cause the tiny quantities to go really negative\n // causing the associated exponentials to vanish.\n\n require(logN >= 0 && int(funding) >= 0);\n offset = Math.max(netOutcomeTokensSold);\n offset = offset.mul(logN) / int(funding);\n offset = offset.sub(EXP_LIMIT);\n uint term;\n for (uint8 i = 0; i < netOutcomeTokensSold.length; i++) {\n term = Math.pow2((netOutcomeTokensSold[i].mul(logN) / int(funding)).sub(offset), estimationMode);\n if (i == outcomeIndex)\n outcomeExpTerm = term;\n sum = sum.add(term);\n }\n }\n\n /// @dev Gets net outcome tokens sold by market. Since all sets of outcome tokens are backed by\n /// corresponding collateral tokens, the net quantity of a token sold by the market is the\n /// number of collateral tokens (which is the same as the number of outcome tokens the\n /// market created) subtracted by the quantity of that token held by the market.\n /// @param market Market contract\n /// @return Net outcome tokens sold by market\n function getNetOutcomeTokensSold(Market market)\n private\n constant\n returns (int[] quantities)\n {\n quantities = new int[](market.eventContract().getOutcomeCount());\n for (uint8 i = 0; i < quantities.length; i++)\n quantities[i] = market.netOutcomeTokensSold(i);\n }\n}\n",
"sourcePath": "@gnosis.pm/pm-contracts/contracts/MarketMakers/LMSRMarketMaker.sol",
"ast": {
"absolutePath": "@gnosis.pm/pm-contracts/contracts/MarketMakers/LMSRMarketMaker.sol",
"exportedSymbols": {
"LMSRMarketMaker": [
2216
]
},
"id": 2217,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 1682,
"literals": [
"solidity",
"^",
"0.4",
".15"
],
"nodeType": "PragmaDirective",
"src": "0:24:7"
},
{
"absolutePath": "@gnosis.pm/pm-contracts/contracts/Utils/Math.sol",
"file": "../Utils/Math.sol",
"id": 1683,
"nodeType": "ImportDirective",
"scope": 2217,
"sourceUnit": 4612,
"src": "25:27:7",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "@gnosis.pm/pm-contracts/contracts/MarketMakers/MarketMaker.sol",
"file": "../MarketMakers/MarketMaker.sol",
"id": 1684,
"nodeType": "ImportDirective",
"scope": 2217,
"sourceUnit": 2252,
"src": "53:41:7",
"symbolAliases": [],
"unitAlias": ""
},
{
"baseContracts": [
{
"arguments": null,
"baseName": {
"contractScope": null,
"id": 1685,
"name": "MarketMaker",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 2251,
"src": "279:11:7",
"typeDescriptions": {
"typeIdentifier": "t_contract$_MarketMaker_$2251",
"typeString": "contract MarketMaker"
}
},
"id": 1686,
"nodeType": "InheritanceSpecifier",
"src": "279:11:7"
}
],
"contractDependencies": [
2251
],
"contractKind": "contract",
"documentation": "@title LMSR market maker contract - Calculates share prices based on share distribution and initial funding\n @author Alan Lu - <alan.lu@gnosis.pm>",
"fullyImplemented": true,
"id": 2216,
"linearizedBaseContracts": [
2216,
2251
],
"name": "LMSRMarketMaker",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 1688,
"libraryName": {
"contractScope": null,
"id": 1687,
"name": "Math",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 4611,
"src": "303:4:7",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Math_$4611",
"typeString": "library Math"
}
},
"nodeType": "UsingForDirective",
"src": "297:17:7",
"typeName": null
},
{
"constant": true,
"id": 1691,
"name": "ONE",
"nodeType": "VariableDeclaration",
"scope": 2216,
"src": "353:39:7",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1689,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "353:4:7",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "30783130303030303030303030303030303030",
"id": 1690,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "373:19:7",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_18446744073709551616_by_1",
"typeString": "int_const 18446744073709551616"
},
"value": "0x10000000000000000"
},
"visibility": "internal"
},
{
"constant": true,
"id": 1694,
"name": "EXP_LIMIT",
"nodeType": "VariableDeclaration",
"scope": 2216,
"src": "398:47:7",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
},
"typeName": {
"id": 1692,
"name": "int",
"nodeType": "ElementaryTypeName",
"src": "398:3:7",
"typeDescriptions": {
"typeIdentifier": "t_int256",
"typeString": "int256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "33333934323030393039353632353537343937333434",
"id": 1693,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "423:22:7",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_3394200909562557497344_by_1",
"typeString": "int_const 3394200909562557497344"
},
"value": "3394200909562557497344"
},
"visibility": "internal"
},
{
"body": {
"id": 1829,
"nodeType": "Block",
"src": "883:1433:7",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint8",
"typeString": "uint8"
},
"id": 1712,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"expression": {
"argumentTypes": null,
"arguments": [],
"expression": {
"argumentTypes": [],
"expression": {
"argumentTypes": null,
"id": 1706,
"name": "market",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1696,
"src": "901:6:7",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Market_$2374",
"typeString": "contract Market"
}
},
"id": 1707,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "eventContract",
"nodeType": "MemberAccess",
"referencedDeclaration": 2305,
"src": "901:20:7",
"typeDescriptions": {
"typeIdentifier": "t_function_external_view$__$returns$_t_contract$_Event_$1680_$",
"typeString": "function () view external returns (contract Event)"
}
},
"id": 1708,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "901:22:7",
"typeDescriptions": {
"typeIdentifier": "t_c