polkamarkets-js 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abis/AddAdminToLand.json +1 -0
- package/abis/ClaimMerkleRoot.json +1 -0
- package/abis/CreateLand.json +1 -0
- package/abis/CreateMarkets.json +1 -0
- package/abis/DeployContracts.json +1 -0
- package/abis/DeployMerkleRewardsDistributor.json +1 -0
- package/abis/DeployToken.json +1 -0
- package/abis/DeployUSDT.json +1 -0
- package/abis/MintTokens.json +1 -0
- package/abis/PublishMerkleRoot.json +1 -0
- package/abis/ResolveMarket.json +1 -0
- package/abis/TradeMarket.json +1 -0
- package/abis/USDT.json +1 -0
- package/package.json +1 -1
- package/script/UpdateMarket.s.sol +56 -0
- package/scripts/AddAdminToLand.s.sol +29 -0
- package/scripts/ClaimMerkleRoot.s.sol +34 -0
- package/scripts/CreateLand.s.sol +28 -0
- package/scripts/CreateMarkets.s.sol +71 -0
- package/scripts/DeployContracts.s.sol +94 -0
- package/scripts/DeployMerkleRewardsDistributor.s.sol +27 -0
- package/scripts/DeployToken.s.sol +17 -0
- package/scripts/DeployUSDT.s.sol +24 -0
- package/scripts/MintTokens.s.sol +21 -0
- package/scripts/PublishMerkleRoot.s.sol +50 -0
- package/scripts/ResolveMarket.s.sol +23 -0
- package/scripts/TradeMarket.s.sol +28 -0
- package/scripts/UpdateMarket.s.sol +55 -0
- package/src/models/PredictionMarketV3Contract.js +5 -1
- package/test/UpdateTest.t.sol +55 -0
- package/test/WhaleTest.t.sol +188 -0
- package/contracts/PredictionMarketV3_4Bad.sol +0 -1487
- package/contracts/PredictionMarketV3_4Good.sol +0 -1508
- package/dist/Application.d.ts +0 -201
- package/dist/Application.d.ts.map +0 -1
- package/dist/Application.js +0 -411
- package/dist/Application.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -16
- package/dist/index.js.map +0 -1
- package/dist/interfaces/index.d.ts +0 -4
- package/dist/interfaces/index.d.ts.map +0 -1
- package/dist/interfaces/index.js +0 -22
- package/dist/interfaces/index.js.map +0 -1
- package/dist/models/AchievementsContract.d.ts +0 -43
- package/dist/models/AchievementsContract.d.ts.map +0 -1
- package/dist/models/AchievementsContract.js +0 -177
- package/dist/models/AchievementsContract.js.map +0 -1
- package/dist/models/ArbitrationContract.d.ts +0 -23
- package/dist/models/ArbitrationContract.d.ts.map +0 -1
- package/dist/models/ArbitrationContract.js +0 -47
- package/dist/models/ArbitrationContract.js.map +0 -1
- package/dist/models/ArbitrationProxyContract.d.ts +0 -14
- package/dist/models/ArbitrationProxyContract.d.ts.map +0 -1
- package/dist/models/ArbitrationProxyContract.js +0 -26
- package/dist/models/ArbitrationProxyContract.js.map +0 -1
- package/dist/models/ERC20Contract.d.ts +0 -50
- package/dist/models/ERC20Contract.d.ts.map +0 -1
- package/dist/models/ERC20Contract.js +0 -99
- package/dist/models/ERC20Contract.js.map +0 -1
- package/dist/models/FantasyERC20Contract.d.ts +0 -13
- package/dist/models/FantasyERC20Contract.d.ts.map +0 -1
- package/dist/models/FantasyERC20Contract.js +0 -43
- package/dist/models/FantasyERC20Contract.js.map +0 -1
- package/dist/models/IContract.d.ts +0 -57
- package/dist/models/IContract.d.ts.map +0 -1
- package/dist/models/IContract.js +0 -515
- package/dist/models/IContract.js.map +0 -1
- package/dist/models/PolkamarketsSmartAccount.d.ts +0 -26
- package/dist/models/PolkamarketsSmartAccount.d.ts.map +0 -1
- package/dist/models/PolkamarketsSmartAccount.js +0 -100
- package/dist/models/PolkamarketsSmartAccount.js.map +0 -1
- package/dist/models/PredictionMarketContract.d.ts +0 -113
- package/dist/models/PredictionMarketContract.d.ts.map +0 -1
- package/dist/models/PredictionMarketContract.js +0 -298
- package/dist/models/PredictionMarketContract.js.map +0 -1
- package/dist/models/PredictionMarketV2Contract.d.ts +0 -157
- package/dist/models/PredictionMarketV2Contract.d.ts.map +0 -1
- package/dist/models/PredictionMarketV2Contract.js +0 -431
- package/dist/models/PredictionMarketV2Contract.js.map +0 -1
- package/dist/models/PredictionMarketV3Contract.d.ts +0 -42
- package/dist/models/PredictionMarketV3Contract.d.ts.map +0 -1
- package/dist/models/PredictionMarketV3Contract.js +0 -277
- package/dist/models/PredictionMarketV3Contract.js.map +0 -1
- package/dist/models/PredictionMarketV3ControllerContract.d.ts +0 -128
- package/dist/models/PredictionMarketV3ControllerContract.d.ts.map +0 -1
- package/dist/models/PredictionMarketV3ControllerContract.js +0 -174
- package/dist/models/PredictionMarketV3ControllerContract.js.map +0 -1
- package/dist/models/PredictionMarketV3FactoryContract.d.ts +0 -31
- package/dist/models/PredictionMarketV3FactoryContract.d.ts.map +0 -1
- package/dist/models/PredictionMarketV3FactoryContract.js +0 -81
- package/dist/models/PredictionMarketV3FactoryContract.js.map +0 -1
- package/dist/models/PredictionMarketV3ManagerContract.d.ts +0 -67
- package/dist/models/PredictionMarketV3ManagerContract.d.ts.map +0 -1
- package/dist/models/PredictionMarketV3ManagerContract.js +0 -97
- package/dist/models/PredictionMarketV3ManagerContract.js.map +0 -1
- package/dist/models/PredictionMarketV3QuerierContract.d.ts +0 -33
- package/dist/models/PredictionMarketV3QuerierContract.d.ts.map +0 -1
- package/dist/models/PredictionMarketV3QuerierContract.js +0 -61
- package/dist/models/PredictionMarketV3QuerierContract.js.map +0 -1
- package/dist/models/PredictionMarketV3_2Contract.d.ts +0 -32
- package/dist/models/PredictionMarketV3_2Contract.d.ts.map +0 -1
- package/dist/models/PredictionMarketV3_2Contract.js +0 -169
- package/dist/models/PredictionMarketV3_2Contract.js.map +0 -1
- package/dist/models/RealitioERC20Contract.d.ts +0 -16
- package/dist/models/RealitioERC20Contract.d.ts.map +0 -1
- package/dist/models/RealitioERC20Contract.js +0 -18
- package/dist/models/RealitioERC20Contract.js.map +0 -1
- package/dist/models/VotingContract.d.ts +0 -38
- package/dist/models/VotingContract.d.ts.map +0 -1
- package/dist/models/VotingContract.js +0 -85
- package/dist/models/VotingContract.js.map +0 -1
- package/dist/models/WETH9Contract.d.ts +0 -29
- package/dist/models/WETH9Contract.d.ts.map +0 -1
- package/dist/models/WETH9Contract.js +0 -44
- package/dist/models/WETH9Contract.js.map +0 -1
- package/dist/models/index.d.ts +0 -18
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/index.js +0 -37
- package/dist/models/index.js.map +0 -1
- package/dist/types/contracts.d.ts +0 -46
- package/dist/types/contracts.d.ts.map +0 -1
- package/dist/types/contracts.js +0 -3
- package/dist/types/contracts.js.map +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/utils/Account.d.ts +0 -34
- package/dist/utils/Account.d.ts.map +0 -1
- package/dist/utils/Account.js +0 -38
- package/dist/utils/Account.js.map +0 -1
- package/dist/utils/Contract.d.ts +0 -31
- package/dist/utils/Contract.d.ts.map +0 -1
- package/dist/utils/Contract.js +0 -123
- package/dist/utils/Contract.js.map +0 -1
- package/dist/utils/Numbers.d.ts +0 -27
- package/dist/utils/Numbers.d.ts.map +0 -1
- package/dist/utils/Numbers.js +0 -87
- package/dist/utils/Numbers.js.map +0 -1
- package/script/CreateMarketLib.sol +0 -1873
- package/script/DeployProxy.s.sol +0 -27
- package/script/DeployUpgradeablePM.s.sol +0 -47
- package/script/PredictionMarketV3_3Flow.s.sol +0 -132
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-2.0
|
|
2
|
+
pragma solidity ^0.8.26;
|
|
3
|
+
|
|
4
|
+
import {Script} from "forge-std/Script.sol";
|
|
5
|
+
import {console} from "forge-std/console.sol";
|
|
6
|
+
// Import your contracts here
|
|
7
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
8
|
+
import {PredictionMarketV3_3, IWETH} from "../contracts/PredictionMarketV3_3.sol";
|
|
9
|
+
import {IPredictionMarketV3Manager} from "../contracts/IPredictionMarketV3Manager.sol";
|
|
10
|
+
import {PredictionMarketV3Manager, FantasyERC20} from "../contracts/PredictionMarketV3Manager.sol";
|
|
11
|
+
import {IRealityETH_ERC20} from "../contracts/IRealityETH_ERC20.sol";
|
|
12
|
+
|
|
13
|
+
contract UpdateMarket is Script {
|
|
14
|
+
function run() public {
|
|
15
|
+
|
|
16
|
+
vm.startBroadcast();
|
|
17
|
+
|
|
18
|
+
address payable PREDICTION_MARKET_V3_3 = payable(address(0x3e0F5F8F5Fb043aBFA475C0308417Bf72c463289));
|
|
19
|
+
address PREDICTION_MARKET_V3_MANAGER = address(0x68dDc91CCC06e63d74905D901A30edEA7C77EebE);
|
|
20
|
+
|
|
21
|
+
PredictionMarketV3_3.MarketState state = PredictionMarketV3_3(PREDICTION_MARKET_V3_3).getMarketState(486);
|
|
22
|
+
console2.log("state: ", state);
|
|
23
|
+
|
|
24
|
+
PredictionMarketV3_3.MarketUpdateDescription memory description = PredictionMarketV3_3.MarketUpdateDescription({
|
|
25
|
+
closesAtTimestamp: 1762066800,
|
|
26
|
+
balance: 456538064447348172635074428,
|
|
27
|
+
liquidity: 120000000000000000000000000,
|
|
28
|
+
sharesAvailable: 1272835104225672313766121101,
|
|
29
|
+
state: PredictionMarketV3_3.MarketState.open,
|
|
30
|
+
resolution: PredictionMarketV3_3.MarketResolution({
|
|
31
|
+
resolved: false,
|
|
32
|
+
realitio: IRealityETH_ERC20(0x71D76Ff3C2729071B2c52A667197d9f715029F2c),
|
|
33
|
+
outcomeId: 115792089237316195423570985008687907853269984665640564039457584007913129639935,
|
|
34
|
+
questionId: 0x21d6c6c195572d82a7d0a7ba677251dfd3839b21e09df9b39ae36ec99fa6744d,
|
|
35
|
+
realitioTimeout: 3600
|
|
36
|
+
}),
|
|
37
|
+
feesPoolWeight: 0,
|
|
38
|
+
feesTreasury: address(0xBc30e9765Dc8c735206c76DE96d369754eBbcc1f),
|
|
39
|
+
feesDistributor: address(0xBc30e9765Dc8c735206c76DE96d369754eBbcc1f),
|
|
40
|
+
buyFees: PredictionMarketV3_3.Fees({fee: 0, treasuryFee: 0, distributorFee: 0}),
|
|
41
|
+
sellFees: PredictionMarketV3_3.Fees({fee: 0, treasuryFee: 0, distributorFee: 0}),
|
|
42
|
+
outcomeCount: 5,
|
|
43
|
+
token: IERC20(0x0b07cf011B6e2b7E0803b892d97f751659940F23),
|
|
44
|
+
manager: IPredictionMarketV3Manager(0x2EbD002d755bdFadb9e5549aA00a80bd7fa408AE),
|
|
45
|
+
creator: address(0xBc30e9765Dc8c735206c76DE96d369754eBbcc1f),
|
|
46
|
+
paused: false
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
PredictionMarketV3_3(PREDICTION_MARKET_V3_3).updateMarket(486, description);
|
|
50
|
+
PredictionMarketV3_3(PREDICTION_MARKET_V3_3).updateMarketResolution(486, description);
|
|
51
|
+
|
|
52
|
+
state = PredictionMarketV3_3(PREDICTION_MARKET_V3_3).getMarketState(486);
|
|
53
|
+
console2.log("new state: ", state);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const predictionV3 = require("../interfaces").predictionV3;
|
|
2
2
|
const PredictionMarketV2Contract = require("./PredictionMarketV2Contract");
|
|
3
3
|
const PredictionMarketV3QuerierContract = require("./PredictionMarketV3QuerierContract");
|
|
4
|
+
const _ = require('lodash');
|
|
4
5
|
|
|
5
6
|
const Numbers = require('../utils/Numbers');
|
|
6
7
|
|
|
@@ -217,6 +218,8 @@ class PredictionMarketV3Contract extends PredictionMarketV2Contract {
|
|
|
217
218
|
];
|
|
218
219
|
}));
|
|
219
220
|
|
|
221
|
+
const liquidityFeesClaimed = _.sumBy(_.filter(events, { action: 'Claim Fees' }), 'value');
|
|
222
|
+
|
|
220
223
|
const item = {
|
|
221
224
|
liquidity: {
|
|
222
225
|
shares: Numbers.fromDecimalsNumber(marketData.liquidityShares, decimals),
|
|
@@ -230,7 +233,8 @@ class PredictionMarketV3Contract extends PredictionMarketV2Contract {
|
|
|
230
233
|
liquidityClaimed: marketData.liquidityClaimed,
|
|
231
234
|
voidedWinningsToClaim: marketData.voidedSharesToClaim,
|
|
232
235
|
voidedWinningsClaimed: false,
|
|
233
|
-
liquidityFees: 0 // discontinued
|
|
236
|
+
liquidityFees: 0, // discontinued
|
|
237
|
+
liquidityFeesClaimed
|
|
234
238
|
}
|
|
235
239
|
};
|
|
236
240
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import "forge-std/console2.sol";
|
|
5
|
+
import "../contracts/PredictionMarketV3_3.sol";
|
|
6
|
+
|
|
7
|
+
import {Test} from "forge-std/Test.sol";
|
|
8
|
+
import {console} from "forge-std/console.sol";
|
|
9
|
+
|
|
10
|
+
// forge test --match-contract POC -vvvvv --fork-url $RPC_URL --fork-block-number 13292408 --zksync
|
|
11
|
+
contract UpdateTest is Test {
|
|
12
|
+
function test_POC() public {
|
|
13
|
+
address predictionMarketV3 = 0x3e0F5F8F5Fb043aBFA475C0308417Bf72c463289;
|
|
14
|
+
address admin = 0x0a70f6F09caa802D8d62dE9C7EdacE1d3b5Ca160;
|
|
15
|
+
|
|
16
|
+
vm.startPrank(admin);
|
|
17
|
+
|
|
18
|
+
address payable PREDICTION_MARKET_V3_3 = payable(address(0x3e0F5F8F5Fb043aBFA475C0308417Bf72c463289));
|
|
19
|
+
|
|
20
|
+
(PredictionMarketV3_3.MarketState state, uint256 closesAt, uint256 liquidity, uint256 balance, uint256 sharesAvailable, int256 resolvedOutcomeId) = PredictionMarketV3_3(payable(predictionMarketV3)).getMarketData(486);
|
|
21
|
+
console.log("state: ", uint256(state));
|
|
22
|
+
|
|
23
|
+
PredictionMarketV3_3.MarketUpdateDescription memory description = PredictionMarketV3_3.MarketUpdateDescription({
|
|
24
|
+
closesAtTimestamp: 1762066800,
|
|
25
|
+
balance: 456538064447348172635074428,
|
|
26
|
+
liquidity: 120000000000000000000000000,
|
|
27
|
+
sharesAvailable: 1272835104225672313766121101,
|
|
28
|
+
state: PredictionMarketV3_3.MarketState.open,
|
|
29
|
+
resolution: PredictionMarketV3_3.MarketResolution({
|
|
30
|
+
resolved: false,
|
|
31
|
+
realitio: IRealityETH_ERC20(0x71D76Ff3C2729071B2c52A667197d9f715029F2c),
|
|
32
|
+
outcomeId: 115792089237316195423570985008687907853269984665640564039457584007913129639935,
|
|
33
|
+
questionId: 0x21d6c6c195572d82a7d0a7ba677251dfd3839b21e09df9b39ae36ec99fa6744d,
|
|
34
|
+
realitioTimeout: 3600
|
|
35
|
+
}),
|
|
36
|
+
feesPoolWeight: 0,
|
|
37
|
+
feesTreasury: address(0xBc30e9765Dc8c735206c76DE96d369754eBbcc1f),
|
|
38
|
+
feesDistributor: address(0xBc30e9765Dc8c735206c76DE96d369754eBbcc1f),
|
|
39
|
+
buyFees: PredictionMarketV3_3.Fees({fee: 0, treasuryFee: 0, distributorFee: 0}),
|
|
40
|
+
sellFees: PredictionMarketV3_3.Fees({fee: 0, treasuryFee: 0, distributorFee: 0}),
|
|
41
|
+
outcomeCount: 5,
|
|
42
|
+
token: IERC20(0x0b07cf011B6e2b7E0803b892d97f751659940F23),
|
|
43
|
+
manager: IPredictionMarketV3Manager(0x2EbD002d755bdFadb9e5549aA00a80bd7fa408AE),
|
|
44
|
+
creator: address(0xBc30e9765Dc8c735206c76DE96d369754eBbcc1f),
|
|
45
|
+
paused: false
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
PredictionMarketV3_3(PREDICTION_MARKET_V3_3).updateMarket(486, description);
|
|
49
|
+
PredictionMarketV3_3(PREDICTION_MARKET_V3_3).updateMarketResolution(486, description);
|
|
50
|
+
|
|
51
|
+
(state, closesAt, liquidity, balance, sharesAvailable, resolvedOutcomeId) = PredictionMarketV3_3(PREDICTION_MARKET_V3_3).getMarketData(486);
|
|
52
|
+
console2.log("new state: ", uint256(state));
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import "forge-std/console2.sol";
|
|
5
|
+
|
|
6
|
+
import {Test} from "forge-std/Test.sol";
|
|
7
|
+
import {ERC20, IERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
|
|
8
|
+
|
|
9
|
+
// forge test --match-contract POC -vvvvv --fork-url $RPC_URL --fork-block-number 13292408 --zksync
|
|
10
|
+
contract WhaleTest is Test {
|
|
11
|
+
function test_POC() public {
|
|
12
|
+
address predictionMarketV3 = 0x39E66eE6b2ddaf4DEfDEd3038E0162180dbeF340;
|
|
13
|
+
address predictionMarketV3Manager = 0xDeFb36c47754D2e37d44b8b8C647D4D643e03bAd;
|
|
14
|
+
address usdc = 0x176211869cA2b568f2A7D4EE941E073a821EE1ff;
|
|
15
|
+
address admin = 0x7836D709E750F6A2D6ff9362457028e8Cd901EB3;
|
|
16
|
+
address whale = 0x374D7860c4f2f604De0191298dD393703Cce84f3;
|
|
17
|
+
|
|
18
|
+
vm.deal(address(this), 200000e6); // Small eth amount needed to trick contract accounting, 0.000000000001 eth would be enough to steal 10_000 usdc
|
|
19
|
+
|
|
20
|
+
// take usdc from the whale
|
|
21
|
+
vm.startPrank(whale);
|
|
22
|
+
IERC20(usdc).transfer(admin, 250000e6);
|
|
23
|
+
vm.stopPrank();
|
|
24
|
+
|
|
25
|
+
console2.log("admin's usdc balance at the start: ", IERC20(usdc).balanceOf(admin));
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
vm.startPrank(admin);
|
|
29
|
+
uint256[] memory distribution = new uint256[](2);
|
|
30
|
+
distribution[0] = 100e6;
|
|
31
|
+
distribution[1] = 100e6;
|
|
32
|
+
|
|
33
|
+
IERC20(usdc).approve(predictionMarketV3, type(uint256).max);
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
uint256 marketId = PredictionMarketV3(predictionMarketV3).createMarket(CreateMarketDescription({
|
|
37
|
+
value: 10_000e6,
|
|
38
|
+
closesAt: uint32(block.timestamp + 3600),
|
|
39
|
+
outcomes: 2,
|
|
40
|
+
token: IERC20(usdc),
|
|
41
|
+
distribution: distribution,
|
|
42
|
+
question: "test",
|
|
43
|
+
image: "test",
|
|
44
|
+
arbitrator: address(this),
|
|
45
|
+
buyFees: Fees({fee: 1e16, treasuryFee: 0, distributorFee: 0}),
|
|
46
|
+
sellFees: Fees({fee: 0, treasuryFee: 0, distributorFee: 0}),
|
|
47
|
+
treasury: address(0),
|
|
48
|
+
distributor: address(0),
|
|
49
|
+
realitioTimeout: 3600,
|
|
50
|
+
manager: IPredictionMarketV3Manager(predictionMarketV3Manager)
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
for (uint256 i = 0; i < 100; i++) {
|
|
54
|
+
PredictionMarketV3(predictionMarketV3).buy(marketId, 0, 0, 1000e6);
|
|
55
|
+
PredictionMarketV3(predictionMarketV3).buy(marketId, 1, 0, 1000e6);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
(uint256 liquidity, uint256[] memory outcomes) = PredictionMarketV3(predictionMarketV3).getUserMarketShares(marketId, admin);
|
|
59
|
+
console2.log("liquidity: ", liquidity);
|
|
60
|
+
console2.log("outcome 0: ", outcomes[0]);
|
|
61
|
+
console2.log("outcome 1: ", outcomes[1]);
|
|
62
|
+
|
|
63
|
+
vm.stopPrank();
|
|
64
|
+
|
|
65
|
+
console2.log("admin's usdc balance at the end: ", IERC20(usdc).balanceOf(admin));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface IPredictionMarketV3Manager {
|
|
70
|
+
function getERC20RealitioAddress(IERC20 token) external view returns (address);
|
|
71
|
+
function isAllowedToCreateMarket(address, address) external view returns (bool);
|
|
72
|
+
function askQuestionERC20(uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 tokens) external returns (bytes32);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
contract Manager is IPredictionMarketV3Manager {
|
|
76
|
+
function getERC20RealitioAddress(IERC20 token) external view returns (address) {
|
|
77
|
+
return address(this);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function isAllowedToCreateMarket(address, address) external view returns (bool) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function askQuestionERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 tokens) external returns (bytes32) {
|
|
85
|
+
return bytes32(uint256(1));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface PredictionMarketV3 {
|
|
91
|
+
function buy(uint256 marketId, uint256 outcomeId, uint256 minOutcomeSharesToBuy, uint256 value) external;
|
|
92
|
+
function sell(uint256 marketId, uint256 outcomeId, uint256 value, uint256 maxOutcomeSharesToSell) external ;
|
|
93
|
+
function createMarket(CreateMarketDescription calldata desc) external returns (uint256);
|
|
94
|
+
function getUserMarketShares(uint256 marketId, address user) external view returns (uint256 liquidity, uint256[] memory outcomes);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
enum MarketState {
|
|
99
|
+
open,
|
|
100
|
+
closed,
|
|
101
|
+
resolved
|
|
102
|
+
}
|
|
103
|
+
enum MarketAction {
|
|
104
|
+
buy,
|
|
105
|
+
sell,
|
|
106
|
+
addLiquidity,
|
|
107
|
+
removeLiquidity,
|
|
108
|
+
claimWinnings,
|
|
109
|
+
claimLiquidity,
|
|
110
|
+
claimFees,
|
|
111
|
+
claimVoided
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
struct Market {
|
|
116
|
+
// market details
|
|
117
|
+
uint256 closesAtTimestamp;
|
|
118
|
+
uint256 balance; // total stake
|
|
119
|
+
uint256 liquidity; // stake held
|
|
120
|
+
uint256 sharesAvailable; // shares held (all outcomes)
|
|
121
|
+
mapping(address => uint256) liquidityShares;
|
|
122
|
+
mapping(address => bool) liquidityClaims; // wether user has claimed liquidity earnings
|
|
123
|
+
MarketState state; // resolution variables
|
|
124
|
+
MarketResolution resolution; // fees
|
|
125
|
+
MarketFees fees;
|
|
126
|
+
// market outcomes
|
|
127
|
+
uint256 outcomeCount;
|
|
128
|
+
mapping(uint256 => MarketOutcome) outcomes;
|
|
129
|
+
IERC20 token; // ERC20 token market will use for trading
|
|
130
|
+
IPredictionMarketV3Manager manager; // manager contract
|
|
131
|
+
address creator; // market creator
|
|
132
|
+
bool paused; // market paused, no trading allowed
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
struct Fees {
|
|
136
|
+
uint256 fee; // fee % taken from every transaction
|
|
137
|
+
uint256 treasuryFee; // fee % taken from every transaction to a treasury address
|
|
138
|
+
uint256 distributorFee; // fee % taken from every transaction to a distributor address
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
struct MarketFees {
|
|
142
|
+
uint256 poolWeight; // internal var used to ensure pro-rate fee distribution
|
|
143
|
+
mapping(address => uint256) claimed;
|
|
144
|
+
address treasury; // address to send treasury fees to
|
|
145
|
+
address distributor; // fee % taken from every transaction to a treasury address
|
|
146
|
+
Fees buyFees; // fees for buy transactions
|
|
147
|
+
Fees sellFees; // fees for sell transactions
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
struct MarketResolution {
|
|
151
|
+
bool resolved;
|
|
152
|
+
address realitio;
|
|
153
|
+
uint256 outcomeId;
|
|
154
|
+
bytes32 questionId; // realitio questionId
|
|
155
|
+
// realitio
|
|
156
|
+
uint256 realitioTimeout;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
struct MarketOutcome {
|
|
160
|
+
uint256 marketId;
|
|
161
|
+
uint256 id;
|
|
162
|
+
Shares shares;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
struct Shares {
|
|
166
|
+
uint256 total; // number of shares
|
|
167
|
+
uint256 available; // available shares
|
|
168
|
+
mapping(address => uint256) holders;
|
|
169
|
+
mapping(address => bool) claims; // wether user has claimed winnings
|
|
170
|
+
mapping(address => bool) voidedClaims; // wether user has claimed voided market shares
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
struct CreateMarketDescription {
|
|
174
|
+
uint256 value;
|
|
175
|
+
uint32 closesAt;
|
|
176
|
+
uint256 outcomes;
|
|
177
|
+
IERC20 token;
|
|
178
|
+
uint256[] distribution;
|
|
179
|
+
string question;
|
|
180
|
+
string image;
|
|
181
|
+
address arbitrator;
|
|
182
|
+
Fees buyFees;
|
|
183
|
+
Fees sellFees;
|
|
184
|
+
address treasury;
|
|
185
|
+
address distributor;
|
|
186
|
+
uint32 realitioTimeout;
|
|
187
|
+
IPredictionMarketV3Manager manager;
|
|
188
|
+
}
|