-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Combinatorial Betting and Futarchy #1364
Open
maltekliemann
wants to merge
47
commits into
main
Choose a base branch
from
develop-combo-futarchy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+14,061
−856
Open
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
ff21a04
Implement Combinatorial Betting (#1354)
maltekliemann c0a0598
Implement combinatorial betting extrinsics (#1365)
maltekliemann d45ecf4
Fix compiler and clippy issues (#1366)
maltekliemann 2bd5e6c
Scaffold combo pallet (#1367)
maltekliemann dcd4921
Implement combinatorial tokens (#1368)
maltekliemann a04d02e
Implement zrml-combo extrinsics (#1369)
maltekliemann fba1a07
Replace `halo2curves` and `ethnum` dependency and fix clippy issues (…
maltekliemann 964e651
Add tests for `combinatorial-tokens` (#1371)
maltekliemann d0a07a5
Refine combinatorial betting (#1372)
maltekliemann 45aeeb8
Update copyright notices (#1373)
maltekliemann d87ae7c
Fix compiler errors (#1374)
maltekliemann c4e50d4
Format `Cargo.toml` files (#1375)
maltekliemann 0b0e607
Implement and test numerical limits for combinatorial betting (#1376)
maltekliemann e586f66
Implement multi-market combinatorial betting tests (#1377)
maltekliemann 27b3db0
Scaffold futarchy pallet (#1378)
maltekliemann 0e0080b
.
maltekliemann 26d5b8a
Implement Scheduler mock
maltekliemann a2cc42f
.
maltekliemann afaf92b
wip
maltekliemann 17ab0e0
Implement and test futarchy
maltekliemann f4d2779
Implement Events
maltekliemann fcb74fa
Fix futarchy errors (#1380)
maltekliemann 2482bb3
Add missing licenses
maltekliemann d903a9b
Fix formatting
maltekliemann b453a7c
Fix toml formatting
maltekliemann e7b311e
Implement benchmarking
maltekliemann 780704f
Fix clippy errors
maltekliemann 60ab256
.
maltekliemann 0411945
.
maltekliemann b184434
.
maltekliemann e93db78
benchmarks work
maltekliemann c9edaa4
.
maltekliemann 2d339bc
.
maltekliemann eef4bda
Update copyright notices
maltekliemann d393cd1
Implement and run Decision Market Oracle Benchmarks (#1381)
maltekliemann 5ba674f
Remove old migrations (#1379) (#1382)
maltekliemann 72aa56d
Implement integration test for zrml-futarchy (#1383)
maltekliemann dd58dc6
Introduce `PoolId` (#1384)
maltekliemann f57bf6b
Implement `redeem_position` (#1385)
maltekliemann 3bda745
Implement `Payout` for `PredictionMarkets` (#1386)
maltekliemann 2660096
Benchmark combinatorial-tokens (#1387)
maltekliemann a56f929
Fix formatting and license notes (#1388)
maltekliemann 84396ca
Implement Combinatorial Pools (#1389)
maltekliemann 6ff1288
Fix formatting
maltekliemann 6055847
Fix coverage
maltekliemann 790906f
Mkl neo swaps benchmarks (#1390)
maltekliemann 93f0663
Add weights of new modules
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2024 Forecasting Technologies LTD. | ||
// | ||
// This file is part of Zeitgeist. | ||
// | ||
// Zeitgeist is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the | ||
// Free Software Foundation, either version 3 of the License, or (at | ||
// your option) any later version. | ||
// | ||
// Zeitgeist is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use crate::types::SplitPositionDispatchInfo; | ||
use alloc::vec::Vec; | ||
use sp_runtime::DispatchError; | ||
|
||
pub trait CombinatorialTokensApi { | ||
type AccountId; | ||
type Balance; | ||
type CombinatorialId; | ||
type MarketId; | ||
|
||
fn split_position( | ||
who: Self::AccountId, | ||
parent_collection_id: Option<Self::CombinatorialId>, | ||
market_id: Self::MarketId, | ||
partition: Vec<Vec<bool>>, | ||
amount: Self::Balance, | ||
force_max_work: bool, | ||
) -> Result<SplitPositionDispatchInfo<Self::CombinatorialId, Self::MarketId>, DispatchError>; | ||
} |
30 changes: 30 additions & 0 deletions
30
primitives/src/traits/combinatorial_tokens_benchmark_helper.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2024 Forecasting Technologies LTD. | ||
// | ||
// This file is part of Zeitgeist. | ||
// | ||
// Zeitgeist is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the | ||
// Free Software Foundation, either version 3 of the License, or (at | ||
// your option) any later version. | ||
// | ||
// Zeitgeist is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use alloc::vec::Vec; | ||
use sp_runtime::DispatchResult; | ||
|
||
pub trait CombinatorialTokensBenchmarkHelper { | ||
type Balance; | ||
type MarketId; | ||
|
||
/// Prepares the market with the specified `market_id` to have a particular `payout`. | ||
fn setup_payout_vector( | ||
market_id: Self::MarketId, | ||
payout: Option<Vec<Self::Balance>>, | ||
) -> DispatchResult; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2024 Forecasting Technologies LTD. | ||
// | ||
// This file is part of Zeitgeist. | ||
// | ||
// Zeitgeist is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the | ||
// Free Software Foundation, either version 3 of the License, or (at | ||
// your option) any later version. | ||
// | ||
// Zeitgeist is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use crate::types::Asset; | ||
use alloc::vec::Vec; | ||
use sp_runtime::DispatchResult; | ||
|
||
// Very fast and very unsafe API for splitting and merging combinatorial tokens. Calling the exposed | ||
// functions with a bad `assets` argument can break the reserve. | ||
pub trait CombinatorialTokensUnsafeApi { | ||
type AccountId; | ||
type Balance; | ||
type MarketId; | ||
|
||
fn split_position_unsafe( | ||
who: Self::AccountId, | ||
collateral: Asset<Self::MarketId>, | ||
assets: Vec<Asset<Self::MarketId>>, | ||
amount: Self::Balance, | ||
) -> DispatchResult; | ||
|
||
fn merge_position_unsafe( | ||
who: Self::AccountId, | ||
collateral: Asset<Self::MarketId>, | ||
assets: Vec<Asset<Self::MarketId>>, | ||
amount: Self::Balance, | ||
) -> DispatchResult; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2024 Forecasting Technologies LTD. | ||
// | ||
// This file is part of Zeitgeist. | ||
// | ||
// Zeitgeist is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the | ||
// Free Software Foundation, either version 3 of the License, or (at | ||
// your option) any later version. | ||
// | ||
// Zeitgeist is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
pub trait FutarchyBenchmarkHelper<Oracle> { | ||
/// Creates an oracle which returns `value` when evaluated, provided that state is not modified | ||
/// any further. | ||
fn create_oracle(value: bool) -> Oracle; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2024 Forecasting Technologies LTD. | ||
// | ||
// This file is part of Zeitgeist. | ||
// | ||
// Zeitgeist is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the | ||
// Free Software Foundation, either version 3 of the License, or (at | ||
// your option) any later version. | ||
// | ||
// Zeitgeist is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use frame_support::pallet_prelude::Weight; | ||
|
||
pub trait FutarchyOracle { | ||
/// Evaluates the query at the current block and returns the weight consumed and a `bool` | ||
/// indicating whether the query evaluated positively. | ||
fn evaluate(&self) -> (Weight, bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2024 Forecasting Technologies LTD. | ||
// | ||
// This file is part of Zeitgeist. | ||
// | ||
// Zeitgeist is free software: you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the | ||
// Free Software Foundation, either version 3 of the License, or (at | ||
// your option) any later version. | ||
// | ||
// Zeitgeist is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use alloc::vec::Vec; | ||
|
||
pub trait PayoutApi { | ||
type Balance; | ||
type MarketId; | ||
|
||
fn payout_vector(market_id: Self::MarketId) -> Option<Vec<Self::Balance>>; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not need a storage migration, because the enum variant
CombinatorialOutcome
has never been used before in the storage.Each enum variant is encoded separately in the storage. https://docs.substrate.io/reference/scale-codec/
The two potential storage items that could contain a
CombinatorialOutcome
areMarkets
that contains thebase_asset
as a potentialAsset
. The other isPools
. But theAsset
CombinatorialOutcome
was never assigned.