-
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.
* AMM-CDA-1: Switch to AmmCdaHybrid enum field (#1274) * switch to AmmCdaHybrid enum field * Update zrml/parimutuel/src/tests/buy.rs Co-authored-by: Malte Kliemann <[email protected]> * Update zrml/parimutuel/src/tests/claim.rs Co-authored-by: Malte Kliemann <[email protected]> * Update zrml/parimutuel/src/tests/refund.rs Co-authored-by: Malte Kliemann <[email protected]> * Update storage version to 11 and add MigrateScoringRuleAmmCdaHybrid * Update primitives/src/market.rs * update migration --------- Co-authored-by: Malte Kliemann <[email protected]> * merge amm-cda-3 changes * merge amm-cda-2 changes * merge amm-cda-4 changes * correct clippy * merge amm-cda-5 changes * merge amm-cda-6 changes * Fix Hybrid Router clippy and tests (#1291) * glue everything together * add hybrid router to configuration * fix tests * fix conditional tests * AMM-CDA-8 Add event information for fees and aggregated amount_out (#1293) * add event info * use slice as function parameter * update test amm amount out of event * fix order book tests * update documentation * removed dependency * AMM-CDA-9 Adds soft and hard failure distinction for AMM and order book errors (#1294) * add event info * use slice as function parameter * update test amm amount out of event * wip * handle soft and hard failure * add order book soft failure * fix clippy * fix CI * remove swaps pallet dependency * add compact to order book struct * fix recursion overflow * Fix of Hybrid Router after asset system merge (#1309) * wip * use asset conversions * adapt hybrid router to new asset system * apply review suggestions * fmt * rename Asset to Assets * update copyrights * update hybrid router crate version * correct orderbook spelling * add amount is zero tests * add price limit too high test * add max order exceeded test * use saturated conversion * use saturated conversion again * remove unused code * add tests for soft failures * add skip order test * add changelog for devs description * add amm soft failure test * add numerical soft failure test for sell * correct failing test for parachain feature * cover remaining is zero execution path --------- Co-authored-by: Malte Kliemann <[email protected]>
- Loading branch information
1 parent
fd18a90
commit dc7e7f9
Showing
93 changed files
with
6,394 additions
and
441 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
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,70 @@ | ||
// 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/>. | ||
|
||
#![cfg(feature = "mock")] | ||
|
||
use crate::constants::BASE; | ||
|
||
pub const _1: u128 = BASE; | ||
pub const _2: u128 = 2 * _1; | ||
pub const _3: u128 = 3 * _1; | ||
pub const _4: u128 = 4 * _1; | ||
pub const _5: u128 = 5 * _1; | ||
pub const _6: u128 = 6 * _1; | ||
pub const _7: u128 = 7 * _1; | ||
pub const _8: u128 = 8 * _1; | ||
pub const _9: u128 = 9 * _1; | ||
pub const _10: u128 = 10 * _1; | ||
pub const _11: u128 = 11 * _1; | ||
pub const _12: u128 = 12 * _1; | ||
pub const _14: u128 = 14 * _1; | ||
pub const _17: u128 = 17 * _1; | ||
pub const _20: u128 = 20 * _1; | ||
pub const _23: u128 = 23 * _1; | ||
pub const _24: u128 = 24 * _1; | ||
pub const _30: u128 = 30 * _1; | ||
pub const _36: u128 = 36 * _1; | ||
pub const _40: u128 = 40 * _1; | ||
pub const _70: u128 = 70 * _1; | ||
pub const _80: u128 = 80 * _1; | ||
pub const _100: u128 = 100 * _1; | ||
pub const _101: u128 = 101 * _1; | ||
pub const _444: u128 = 444 * _1; | ||
pub const _500: u128 = 500 * _1; | ||
pub const _777: u128 = 777 * _1; | ||
pub const _1000: u128 = 1_000 * _1; | ||
|
||
pub const _1_2: u128 = _1 / 2; | ||
|
||
pub const _1_3: u128 = _1 / 3; | ||
pub const _2_3: u128 = _2 / 3; | ||
|
||
pub const _1_4: u128 = _1 / 4; | ||
pub const _3_4: u128 = _3 / 4; | ||
|
||
pub const _1_5: u128 = _1 / 5; | ||
|
||
pub const _1_6: u128 = _1 / 6; | ||
pub const _5_6: u128 = _5 / 6; | ||
|
||
pub const _1_10: u128 = _1 / 10; | ||
pub const _2_10: u128 = _2 / 10; | ||
pub const _3_10: u128 = _3 / 10; | ||
pub const _4_10: u128 = _4 / 10; | ||
pub const _9_10: u128 = _9 / 10; | ||
|
||
pub const _1_100: u128 = _1 / 100; |
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,63 @@ | ||
// 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::*; | ||
use scale_info::TypeInfo; | ||
|
||
#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, Debug, TypeInfo)] | ||
pub struct AmmTrade<Balance> { | ||
pub amount_in: Balance, | ||
pub amount_out: Balance, | ||
pub swap_fee_amount: Balance, | ||
pub external_fee_amount: Balance, | ||
} | ||
|
||
#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, Debug, TypeInfo)] | ||
pub struct ExternalFee<AccountId, Balance> { | ||
pub account: AccountId, | ||
pub amount: Balance, | ||
} | ||
|
||
#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, Debug, TypeInfo)] | ||
pub struct OrderbookTrade<AccountId, Balance> { | ||
pub filled_maker_amount: Balance, | ||
pub filled_taker_amount: Balance, | ||
pub external_fee: ExternalFee<AccountId, Balance>, | ||
} | ||
|
||
pub trait FailSoft {} | ||
|
||
#[derive(Debug)] | ||
pub enum AmmSoftFail { | ||
Numerical, | ||
} | ||
|
||
impl FailSoft for AmmSoftFail {} | ||
|
||
#[derive(Debug)] | ||
pub enum OrderbookSoftFail { | ||
BelowMinimumBalance, | ||
PartialFillNearFullFillNotAllowed, | ||
} | ||
|
||
impl FailSoft for OrderbookSoftFail {} | ||
|
||
#[derive(Debug)] | ||
pub enum ApiError<S: FailSoft> { | ||
SoftFailure(S), | ||
HardFailure(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
Oops, something went wrong.