-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Combinatorial Pools (#1389)
* Define and implement `CombinatorialTokensApi` * Abstract position calculation * Implement `CombinatorialTokensUnsafeApi::combinatorial_position` * Add `CombinatorialTokens*Api` to `neo-swaps` * Fix formatting * Add copyright notices * . * . * Implement `deploy_combinatorial_pool` * Replace `market_id` with `pool_id` where appropriate * pool storage * . * Implement `PoolType` * Use `PoolOperations::is_active` * Use market ID for complete set operations * Use PoolId more * Rewrite `distribute_fees` to make use of all markets * . * Fix duplicate pool problem / adapter * . * Fix sell tests * Fix really annoying problem * clean up tests * . * . * Update copyright * Fix tests
- Loading branch information
1 parent
a56f929
commit 84396ca
Showing
42 changed files
with
2,054 additions
and
622 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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>; | ||
} |
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
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
Oops, something went wrong.