Skip to content
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

feat: ICE #907

Draft
wants to merge 160 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
977c350
initial omnix pallet stub
enthusiastmartin Jun 25, 2024
1c3488c
add submit intent impl
enthusiastmartin Jun 25, 2024
fd22161
add submit intent impl
enthusiastmartin Jun 25, 2024
96d2862
add sumbit solution
enthusiastmartin Jun 27, 2024
e4aa161
add lrna swaps
enthusiastmartin Jun 27, 2024
a09bdd6
prepare solution
enthusiastmartin Jun 27, 2024
a3fe311
implement execute solution
enthusiastmartin Jun 28, 2024
bb308cf
add execute solution
enthusiastmartin Jun 28, 2024
afe4196
test simple prepare solution
enthusiastmartin Jun 28, 2024
4620f07
test simple prepare solution with two matching intents
enthusiastmartin Jun 28, 2024
bcc9533
refactor
enthusiastmartin Jun 28, 2024
efabdd1
add support to buy lrna
enthusiastmartin Jul 2, 2024
0a50123
rounding
enthusiastmartin Jul 2, 2024
ed70eff
add only allowed accounts to buy hub asset directly
enthusiastmartin Jul 2, 2024
0c871e0
add omnix basic integration tests
enthusiastmartin Jul 2, 2024
7bcbcad
add support for buying LRNA
dmoka Jul 8, 2024
7e5b198
add simple solver
enthusiastmartin Jul 10, 2024
436a7f0
implement one intent solver
enthusiastmartin Jul 10, 2024
17ce673
rounding
enthusiastmartin Jul 10, 2024
3e59c27
add price validation
enthusiastmartin Jul 10, 2024
8e3ebe7
add assertions
enthusiastmartin Jul 11, 2024
df87f8f
add init omnipool with subpool
enthusiastmartin Jul 11, 2024
9d4222e
solve using router and route provider
enthusiastmartin Jul 11, 2024
52381c2
two intents solution test
enthusiastmartin Jul 12, 2024
a156298
Merge branch 'master' into feat/omnix
enthusiastmartin Jul 22, 2024
e00642a
initial simple tx order
enthusiastmartin Jul 25, 2024
ff5fe01
remove solution prices
enthusiastmartin Jul 26, 2024
b619136
Merge branch 'master' into feat/omnix
enthusiastmartin Jul 30, 2024
f838ad1
refactor to use instructionsi n solution
enthusiastmartin Jul 30, 2024
b4b1532
Merge branch 'master' into feat/omnix
enthusiastmartin Aug 1, 2024
0e02be6
add validation of intesnts
enthusiastmartin Aug 2, 2024
efb18ba
rework simple solver
enthusiastmartin Aug 7, 2024
74455ef
fix solver
enthusiastmartin Aug 8, 2024
dafecec
fix pool setup
enthusiastmartin Aug 8, 2024
9ee7441
additional tests
enthusiastmartin Aug 12, 2024
1f76694
remove storagE
enthusiastmartin Aug 12, 2024
a235101
add score param
enthusiastmartin Aug 12, 2024
ab13024
add solution score extension
enthusiastmartin Aug 13, 2024
2ef3939
Merge branch 'master' into feat/omnix
enthusiastmartin Aug 23, 2024
f24bcdc
propose solutioln
enthusiastmartin Aug 26, 2024
f2c7d77
unsigned approach
enthusiastmartin Aug 28, 2024
dec5f4c
order by score
enthusiastmartin Aug 28, 2024
11897f5
add block check and solution score
enthusiastmartin Sep 4, 2024
6f7f14d
Merge branch 'master' into feat/omnix
enthusiastmartin Sep 6, 2024
1f63bb2
validate deadline
enthusiastmartin Sep 6, 2024
e4f7bca
esnure resolved intent correctness
enthusiastmartin Sep 6, 2024
454e6d4
add fee to lrna buy
enthusiastmartin Sep 8, 2024
7d34cb6
correct intent duration
enthusiastmartin Sep 8, 2024
3190b28
track solver swap amounts
enthusiastmartin Sep 9, 2024
851af51
rename omnix -> ice
enthusiastmartin Sep 10, 2024
e605510
rename omnix -> ice
enthusiastmartin Sep 10, 2024
9920955
reserve and unreserve intents amounts
enthusiastmartin Sep 10, 2024
bbe87f4
comment
enthusiastmartin Sep 10, 2024
2ac040d
adjust ice tests
enthusiastmartin Sep 10, 2024
3db7279
update comment
enthusiastmartin Sep 10, 2024
8b1e5a5
score solution
enthusiastmartin Sep 11, 2024
1d0e87a
update and clear intents, use price oracle
enthusiastmartin Sep 12, 2024
e4ca5b4
updat runtime config
enthusiastmartin Sep 12, 2024
ec10147
Merge branch 'master' into feat/ice
enthusiastmartin Sep 13, 2024
292e7fd
score solution correctly
enthusiastmartin Sep 13, 2024
18882b7
add additional intent sumbission tests
enthusiastmartin Sep 14, 2024
c6031f1
add additional solution sumbission tests
enthusiastmartin Sep 14, 2024
a4c7c54
add additional solution sumbission tests
enthusiastmartin Sep 14, 2024
e5cb639
add tests for clear/update intents
enthusiastmartin Sep 14, 2024
22412ba
make scoring solution part of engine api
enthusiastmartin Sep 15, 2024
54be984
warnings
enthusiastmartin Sep 15, 2024
3c25e6e
Add weigher
enthusiastmartin Sep 15, 2024
f431440
change sumbit solution weight calculation
enthusiastmartin Sep 15, 2024
08dd7e6
simply engine impl
enthusiastmartin Sep 15, 2024
7719e0d
simplify error
enthusiastmartin Sep 15, 2024
8a0507c
refactor little things
enthusiastmartin Sep 15, 2024
7b9b058
move to types
enthusiastmartin Sep 15, 2024
f6c7c18
refactor little things
enthusiastmartin Sep 15, 2024
a63ba52
add comment
enthusiastmartin Sep 15, 2024
ff9a6ce
calculate weight of submit solution
enthusiastmartin Sep 16, 2024
0f731d9
remove comment
enthusiastmartin Sep 16, 2024
54b5f98
calculate swap weight using route
enthusiastmartin Sep 16, 2024
146a163
use sell and buy weight
enthusiastmartin Sep 16, 2024
6730663
fix runtime
enthusiastmartin Sep 16, 2024
562b037
add coment
enthusiastmartin Sep 18, 2024
31fa02b
add intents ids simple test
enthusiastmartin Sep 18, 2024
8703f6a
add intents ids simple test
enthusiastmartin Sep 18, 2024
c865625
add intents ids simple test
enthusiastmartin Sep 18, 2024
553bd27
remove uneccessary type
enthusiastmartin Sep 18, 2024
8f1565b
use intent in submit extrinsic
enthusiastmartin Sep 18, 2024
331f969
set executed flag
enthusiastmartin Sep 18, 2024
74abea9
Add comment
enthusiastmartin Sep 20, 2024
b62e71d
rework submit solution so no need to provide transfers in/out
enthusiastmartin Sep 21, 2024
63b6726
adjust submit solution weight
enthusiastmartin Sep 24, 2024
f22c315
unreserve when removing expired intent
enthusiastmartin Sep 24, 2024
d669117
slash invalid solutions
enthusiastmartin Sep 24, 2024
59bed11
additional tests
enthusiastmartin Sep 24, 2024
4ba5e58
configure ice pallet runtime
enthusiastmartin Sep 24, 2024
711952a
fix integration tests
enthusiastmartin Sep 24, 2024
6c1e41a
happy clippy happy life
enthusiastmartin Sep 24, 2024
3c5bef8
Merge branch 'master' into feat/ice
enthusiastmartin Sep 26, 2024
536baa7
implement slahsing in tx validation
enthusiastmartin Sep 26, 2024
3548dce
slash integration tests
enthusiastmartin Sep 26, 2024
c5d47ac
use correct submit solution
enthusiastmartin Sep 26, 2024
110f151
add unreserve test
enthusiastmartin Oct 1, 2024
3b5dbd2
add unsigned submit proposal
enthusiastmartin Oct 1, 2024
c151871
introduce cvx solver
enthusiastmartin Oct 3, 2024
e7ea56b
use other lib
enthusiastmartin Oct 4, 2024
9da705f
just some values
enthusiastmartin Oct 9, 2024
a53642e
something
enthusiastmartin Oct 11, 2024
6888bf3
cvx solver impl
enthusiastmartin Oct 15, 2024
a5fa862
add assertion for the test case
enthusiastmartin Oct 15, 2024
69971d9
remove unused stuff
enthusiastmartin Oct 15, 2024
a4ea0d4
extract test data
enthusiastmartin Oct 15, 2024
8f2f997
use with proper balances in u128 with conversion to f64
enthusiastmartin Oct 16, 2024
b16ca6c
test case with different precision
enthusiastmartin Oct 16, 2024
cf3f55b
Add coment
enthusiastmartin Oct 16, 2024
161e890
refactor little things
enthusiastmartin Oct 16, 2024
6395286
setup new omnipool snapshot
enthusiastmartin Oct 16, 2024
6d0f9a5
use real omnipool state
enthusiastmartin Oct 16, 2024
2e5e10c
ddd on intent test
enthusiastmartin Oct 16, 2024
51bd23f
tests
enthusiastmartin Oct 16, 2024
d49a0f3
refactor ice integration tests
enthusiastmartin Oct 17, 2024
546369b
refactor ice integration tests
enthusiastmartin Oct 17, 2024
3043c01
refactor ice integration tests
enthusiastmartin Oct 17, 2024
e5e69dd
refactor ice integration tests
enthusiastmartin Oct 17, 2024
9ea2105
refactor ice integration tests
enthusiastmartin Oct 17, 2024
cf10d9a
cvx2
enthusiastmartin Oct 17, 2024
df7ba1b
cvs2 testing
enthusiastmartin Oct 17, 2024
20311ee
Setup solver unit tests
enthusiastmartin Oct 18, 2024
2728a13
Merge branch 'feat/ice' of github.com:galacticcouncil/HydraDX-node in…
enthusiastmartin Oct 21, 2024
e37de28
random intents
enthusiastmartin Oct 21, 2024
91c1487
Merge branch 'feat/ice' of github.com:galacticcouncil/HydraDX-node in…
enthusiastmartin Oct 21, 2024
bebdf60
set up integration test for omni solver
enthusiastmartin Oct 22, 2024
31cff6b
test omni solver with one intent
enthusiastmartin Oct 22, 2024
0674a83
simplify utils for intengraton tests
enthusiastmartin Oct 22, 2024
2908284
submit solution
enthusiastmartin Oct 22, 2024
4a46eeb
integration test for omni solver
enthusiastmartin Oct 22, 2024
359c037
solver and pallet ice refactor
enthusiastmartin Oct 24, 2024
09ff972
solver code consolidation
enthusiastmartin Oct 25, 2024
c531fbe
integration tests for ice solvers
enthusiastmartin Oct 25, 2024
d385e38
fix build
enthusiastmartin Oct 25, 2024
f4be727
fix build
enthusiastmartin Oct 25, 2024
6e0b545
Merge branch 'master' into feat/ice
enthusiastmartin Oct 25, 2024
7958857
Merge branch 'feat/ice' into feat/ice-offchain
enthusiastmartin Oct 25, 2024
49141e2
fix build
enthusiastmartin Oct 25, 2024
6c5cbf9
updat lock
enthusiastmartin Oct 26, 2024
4de09fa
noop solver
enthusiastmartin Oct 26, 2024
22dc832
ice cargo config
enthusiastmartin Oct 27, 2024
b97b17f
working build - no solver
enthusiastmartin Oct 27, 2024
a35fe6b
use git clarabel
enthusiastmartin Oct 27, 2024
ad65a66
use workspace deps
enthusiastmartin Oct 27, 2024
9291170
ice builds
enthusiastmartin Oct 29, 2024
ffd8da7
fix integration tests
enthusiastmartin Oct 29, 2024
13569c2
simplify and call prpose solution
enthusiastmartin Oct 29, 2024
aec29b3
use git deps
enthusiastmartin Oct 29, 2024
1642c87
solver unit tests
enthusiastmartin Oct 29, 2024
96fb553
disable solver unit tests
enthusiastmartin Oct 29, 2024
f266efc
Merge branch 'feat/ice' into feat/ice-offchain
enthusiastmartin Oct 29, 2024
bf4bdb7
Merge branch 'feat/ice-offchain' into feat/ice-works
enthusiastmartin Oct 29, 2024
5fa0ba7
refactor engine
enthusiastmartin Oct 30, 2024
8d48bb0
clippy
enthusiastmartin Oct 30, 2024
9b74b1e
Merge branch 'master' into feat/ice
enthusiastmartin Oct 31, 2024
d44a659
revert omnipool lrna buy support
enthusiastmartin Oct 31, 2024
bbfaf8b
change trade intrusctions calculation
enthusiastmartin Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,486 changes: 1,355 additions & 1,131 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ members = [
'pallets/dynamic-evm-fee',
'pallets/xyk-liquidity-mining',
'precompiles/call-permit',
'runtime-mock'
'runtime-mock',
'pallets/ice',
'pallets/ice/solver'
]

resolver = "2"

[workspace.dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
scale-info = { version = "2.11.1", default-features = false, features = ["derive"] }
serde = { version = "1.0.197", default-features = false }
serde = { version = "=1.0.197", default-features = false }
primitive-types = { version = "0.12.0", default-features = false }

affix = "0.1.2"
Expand Down Expand Up @@ -90,7 +92,7 @@ rand_xoshiro = "0.6.0"
rug = { version = "1.17.0", features = ["num-traits"] }
rustc-hex = { version = '2.1.0', default-features = false }
sha3 = { version = "0.10.6", default-features = false }
serde_json = { version = "1.0.117", default-features = false }
serde_json = { version = "=1.0.117", default-features = false }
slices = "0.2.0"
smallvec = "1.9.0"
similar-asserts = "1.1.0"
Expand All @@ -102,6 +104,8 @@ toml = "0.5"
trie-db = "0.28.0"
trybuild = "1.0"

clarabel = { git = "https://github.com/enthusiastmartin/Clarabel.rs" , branch = "feat/sp-support", default-features = false }

hydra-dx-math = { path = "math", default-features = false }
hydradx = { path = "node", default-features = false }
hydradx-traits = { path = "traits", default-features = false }
Expand Down Expand Up @@ -143,6 +147,8 @@ pallet-xyk-liquidity-mining = { path = "pallets/xyk-liquidity-mining", default-f
pallet-referrals = { path = "pallets/referrals", default-features = false }
pallet-evm-accounts = { path = "pallets/evm-accounts", default-features = false }
pallet-evm-accounts-rpc-runtime-api = { path = "pallets/evm-accounts/rpc/runtime-api", default-features = false }
pallet-ice = { path = "pallets/ice", default-features = false}
ice-solver = { path = "pallets/ice/solver", default-features = false}

hydra-dx-build-script-utils = { path = "utils/build-script-utils", default-features = false }
scraper = { path = "scraper", default-features = false }
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pallet-staking = { workspace = true }
pallet-lbp = { workspace = true }
pallet-xyk = { workspace = true }
pallet-evm-accounts = { workspace = true }
pallet-ice = { workspace = true}
ice-solver = { workspace = true}

pallet-treasury = { workspace = true }
pallet-democracy = { workspace = true }
Expand Down Expand Up @@ -217,6 +219,8 @@ std = [
"pallet-dynamic-evm-fee/std",
"precompile-utils/std",
"pallet-transaction-pause/std",
"pallet-ice/std",
"ice-solver/std",
]

# we don't include integration tests when benchmarking feature is enabled
Expand Down
Binary file added integration-tests/omnipool-snapshot/2024-10-18
Binary file not shown.
44 changes: 44 additions & 0 deletions integration-tests/src/ice/intents.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use super::*;

#[test]
fn submit_intent_should_work() {
Hydra::execute_with(|| {
crate::utils::pools::setup_omnipool();

let deadline: Moment = NOW + 43_200_000;

let swap = Swap {
asset_in: HDX,
asset_out: DAI,
amount_in: 1_000_000_000_000,
amount_out: 2_000_000_000_000,
swap_type: pallet_ice::types::SwapType::ExactIn,
};
assert_ok!(ICE::submit_intent(
RuntimeOrigin::signed(BOB.into()),
Intent {
who: BOB.into(),
swap: swap.clone(),
deadline,
partial: false,
on_success: None,
on_failure: None,
}
));

let intent_id = pallet_ice::Pallet::<hydradx_runtime::Runtime>::get_intent_id(deadline, 0);

let expected_entry = pallet_ice::types::Intent {
who: BOB.into(),
swap,
deadline,
partial: false,
on_success: None,
on_failure: None,
};
assert_eq!(
pallet_ice::Pallet::<hydradx_runtime::Runtime>::get_intent(intent_id),
Some(expected_entry)
);
});
}
92 changes: 92 additions & 0 deletions integration-tests/src/ice/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
mod intents;
mod omni;

use crate::polkadot_test_net::*;
use frame_support::assert_ok;
use frame_support::traits::fungible::Mutate;
use hydra_dx_math::ratio::Ratio;
use hydradx_adapters::price::OraclePriceProviderUsingRoute;
use hydradx_adapters::OraclePriceProvider;
use hydradx_runtime::{
Currencies, EmaOracle, Omnipool, ReferralsOraclePeriod, Router, RuntimeOrigin, ICE, LRNA as LRNAT,
};
use hydradx_traits::price::PriceProvider;
use hydradx_traits::router::AssetPair;
use orml_traits::MultiCurrency;
use pallet_ice::traits::Solver;
use pallet_ice::types::{Balance, BoundedResolvedIntents, BoundedTrades, Intent, IntentId, ResolvedIntent as RI, Swap};
use primitives::{AccountId, AssetId, Moment};
use sp_core::crypto::AccountId32;
use xcm_emulator::TestExt;

const PATH_TO_SNAPSHOT: &str = "omnipool-snapshot/2024-10-18";

pub(crate) fn solve_intents_with<S: Solver<(IntentId, Intent<sp_runtime::AccountId32, AssetId>)>>(
intents: Vec<(IntentId, Intent<sp_runtime::AccountId32, AssetId>)>,
) -> Result<BoundedResolvedIntents, ()> {
let (result, metadata) = S::solve(intents).map_err(|_| ())?;
let resolved_intents = BoundedResolvedIntents::try_from(result).unwrap();
//let trades = BoundedTrades::try_from(solution.trades()).unwrap();
//let score = solution.score();
Ok(resolved_intents)
}

#[test]
fn test_omnipool_snapshot() {
hydra_live_ext(PATH_TO_SNAPSHOT).execute_with(|| {
//let omnipool_account = hydradx_runtime::Omnipool::protocol_account();
let buy_asset = 27;
let initial_balance20 = Currencies::free_balance(buy_asset, &AccountId32::from(BOB));
hydradx_runtime::Balances::set_balance(&BOB.into(), 200_000_000_000_000_000);

assert_ok!(Router::sell(
RuntimeOrigin::signed(BOB.into()),
0,
buy_asset,
100_000_000_000_000,
0,
vec![]
));
let balance20 = Currencies::free_balance(buy_asset, &AccountId32::from(BOB));

assert_eq!(balance20 - initial_balance20, 1249711278057);
});
}

pub(crate) fn submit_intents(intents: Vec<Intent<AccountId, AssetId>>) -> Vec<IntentId> {
let mut intent_ids = Vec::new();
for intent in intents {
let deadline = intent.deadline;
let increment_id = pallet_ice::Pallet::<hydradx_runtime::Runtime>::next_incremental_id();
assert_ok!(ICE::submit_intent(RuntimeOrigin::signed(intent.who.clone()), intent,));
let intent_id = pallet_ice::Pallet::<hydradx_runtime::Runtime>::get_intent_id(deadline, increment_id);
intent_ids.push(intent_id);
}

intent_ids
}

/*

fn print_json_str(assets: &[OmnipoolAssetInfo<AssetId>]) {
// dump assets info in json format
let mut json = String::from("[");
for asset in assets {
json.push_str(&format!(
r#"{{"asset_id": {}, "reserve": {}, "hub_reserve": {}, "decimals": {}, "fee": {}, "hub_fee": {}, "symbol": "{}"}}"#,
asset.asset_id,
asset.reserve,
asset.hub_reserve,
asset.decimals,
asset.fee.deconstruct(),
asset.hub_fee.deconstruct(),
asset.symbol
));
json.push_str(",");
}
json.pop();
json.push_str("]");
println!("{}", json);
}

*/
128 changes: 128 additions & 0 deletions integration-tests/src/ice/omni.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
use crate::ice::{solve_intents_with, submit_intents, PATH_TO_SNAPSHOT};
use crate::polkadot_test_net::*;
use frame_support::assert_ok;
use frame_support::traits::fungible::Mutate;
use hydradx_adapters::ice::{IceRoutingSupport, OmnipoolDataProvider};
use hydradx_adapters::price::OraclePriceProviderUsingRoute;
use hydradx_adapters::OraclePriceProvider;
use hydradx_runtime::{
Currencies, EmaOracle, Omnipool, ReferralsOraclePeriod, Router, RuntimeOrigin, System, Timestamp, ICE,
LRNA as LRNAT,
};
use hydradx_traits::router::{PoolType, Trade};
use pallet_ice::types::{BoundedResolvedIntents, BoundedTrades, Intent, IntentId, Swap};
use pallet_ice::Call::submit_intent;
use pallet_omnipool::types::Tradability;
use primitives::{AccountId, AssetId, Moment};
use sp_runtime::traits::BlockNumberProvider;

type PriceP =
OraclePriceProviderUsingRoute<Router, OraclePriceProvider<AssetId, EmaOracle, LRNAT>, ReferralsOraclePeriod>;

type OmniSolverWithOmnipool =
ice_solver::omni::OmniSolver<AccountId, AssetId, OmnipoolDataProvider<hydradx_runtime::Runtime>>;

#[test]
fn solver_should_find_solution_with_one_intent() {
hydra_live_ext(PATH_TO_SNAPSHOT).execute_with(|| {
hydradx_runtime::Balances::set_balance(&BOB.into(), 200_000_000_000_000);

let deadline: Moment = Timestamp::now() + 43_200_000;
let intent_ids = submit_intents(vec![Intent {
who: BOB.into(),
swap: Swap {
asset_in: 0,
asset_out: 27,
amount_in: 100_000_000_000_000,
amount_out: 1149711278057,
swap_type: pallet_ice::types::SwapType::ExactIn,
},
deadline,
partial: true,
on_success: None,
on_failure: None,
}]);

let intents = vec![(
intent_ids[0],
pallet_ice::Pallet::<hydradx_runtime::Runtime>::get_intent(intent_ids[0]).unwrap(),
)];

let resolved = solve_intents_with::<OmniSolverWithOmnipool>(intents).unwrap();

let (trades, score) =
pallet_ice::Pallet::<hydradx_runtime::Runtime>::calculate_trades_and_score(&resolved.to_vec()).unwrap();

assert_eq!(
resolved.to_vec(),
vec![pallet_ice::types::ResolvedIntent {
intent_id: 796899343984252629811200000,
amount_in: 99853645824127,
amount_out: 1148028627591,
},]
);

assert_eq!(
trades,
vec![pallet_ice::types::TradeInstruction::SwapExactIn {
asset_in: 0,
asset_out: 27,
amount_in: 99853645824127,
amount_out: 1148028627591,
route: pallet_ice::types::BoundedRoute::try_from(vec![Trade {
pool: PoolType::Omnipool,
asset_in: 0,
asset_out: 27,
}])
.unwrap()
},]
);

assert_eq!(score, 1000000);
});
}

#[test]
fn execute_solution_should_work_with_solved_intents() {
hydra_live_ext(PATH_TO_SNAPSHOT).execute_with(|| {
hydradx_runtime::Balances::set_balance(&BOB.into(), 200_000_000_000_000);
assert_ok!(hydradx_runtime::Omnipool::set_asset_tradable_state(
hydradx_runtime::RuntimeOrigin::root(),
LRNA,
Tradability::SELL | Tradability::BUY
));

let deadline: Moment = Timestamp::now() + 43_200_000;
let intent_ids = submit_intents(vec![Intent {
who: BOB.into(),
swap: Swap {
asset_in: 0,
asset_out: 27,
amount_in: 100_000_000_000_000,
amount_out: 1149711278057,
swap_type: pallet_ice::types::SwapType::ExactIn,
},
deadline,
partial: true,
on_success: None,
on_failure: None,
}]);

let intents = vec![(
intent_ids[0],
pallet_ice::Pallet::<hydradx_runtime::Runtime>::get_intent(intent_ids[0]).unwrap(),
)];
let resolved = solve_intents_with::<OmniSolverWithOmnipool>(intents).unwrap();

let (trades, score) =
pallet_ice::Pallet::<hydradx_runtime::Runtime>::calculate_trades_and_score(&resolved.to_vec()).unwrap();

assert_ok!(ICE::submit_solution(
RuntimeOrigin::signed(BOB.into()),
resolved,
BoundedTrades::try_from(trades).unwrap(),
score,
System::current_block_number()
));
});
}
1 change: 1 addition & 0 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod evm_permit;
mod exchange_asset;
mod fee_calculation;
mod global_account_derivation;
mod ice;
mod insufficient_assets_ed;
mod multi_payment;
mod non_native_fee;
Expand Down
1 change: 1 addition & 0 deletions integration-tests/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub(crate) mod accounts;
pub(crate) mod contracts;
pub(crate) mod pools;
Loading
Loading