Skip to content

feat: ICE#1360

Open
enthusiastmartin wants to merge 139 commits intomasterfrom
feat/ice-pallet
Open

feat: ICE#1360
enthusiastmartin wants to merge 139 commits intomasterfrom
feat/ice-pallet

Conversation

@enthusiastmartin
Copy link
Copy Markdown
Member

This PR introduces foundation of ICE - Intent Composing Engine.

Included:

  • intent submissions
  • solution execution
  • solver v1 - initial solving mechanism with matching algorithm ( will be expanded and improved )

Comment thread pallets/ice/src/lib.rs
let owner = pallet_intent::Pallet::<T>::intent_owner(id).ok_or(Error::<T>::IntentOwnerNotFound)?;
pallet_intent::Pallet::<T>::unlock_funds(&owner, intent.asset_in(), intent.amount_in())?;

log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), unlock and transfer amounts, owner: {:?}, asset: {:?}, amount: {:?}",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), unlock and transfer amounts, owner: {:?}, asset: {:?}, amount: {:?}",
log::debug!(target: LOG_TARGET, "{:?}: submit_solution(), unlock and transfer amounts, owner: {:?}, asset: {:?}, amount: {:?}",

Comment thread pallets/ice/src/lib.rs

match t.direction {
SwapType::ExactOut => {
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), buying, asset_in: {:?}, asset_out: {:?}, amount_out: {:?}, max_amount_in: {:?}, route: {:?}",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), buying, asset_in: {:?}, asset_out: {:?}, amount_out: {:?}, max_amount_in: {:?}, route: {:?}",
log::debug!(target: LOG_TARGET, "{:?}: submit_solution(), buying, asset_in: {:?}, asset_out: {:?}, amount_out: {:?}, max_amount_in: {:?}, route: {:?}",

Comment thread pallets/ice/src/lib.rs
)?;
}
SwapType::ExactIn => {
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), selling, asset_in: {:?}, asset_out: {:?}, amount_in: {:?}, min_amount_out: {:?}, route: {:?}",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), selling, asset_in: {:?}, asset_out: {:?}, amount_in: {:?}, min_amount_out: {:?}, route: {:?}",
log::debug!(target: LOG_TARGET, "{:?}: submit_solution(), selling, asset_in: {:?}, asset_out: {:?}, amount_in: {:?}, min_amount_out: {:?}, route: {:?}",

Comment thread pallets/ice/src/lib.rs
let fee_amount = Self::protocol_fee().mul_floor(resolve.amount_out());
let payout = resolve.amount_out().saturating_sub(fee_amount);

log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), transferring, id: {:?}, to: {:?}, amount: {:?}, fee: {:?}", LOG_PREFIX, id, owner, payout, fee_amount);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), transferring, id: {:?}, to: {:?}, amount: {:?}, fee: {:?}", LOG_PREFIX, id, owner, payout, fee_amount);
log::debug!(target: LOG_TARGET, "{:?}: submit_solution(), transferring, id: {:?}, to: {:?}, amount: {:?}, fee: {:?}", LOG_PREFIX, id, owner, payout, fee_amount);

Comment thread pallets/ice/src/lib.rs
let intent = pallet_intent::Pallet::<T>::get_intent(id).ok_or(Error::<T>::IntentNotFound)?;
let surplus = pallet_intent::Pallet::<T>::compute_surplus(&intent, resolve)
.ok_or(Error::<T>::ArithmeticOverflow)?;
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), id: {:?}, surplus: {:?}", LOG_PREFIX, id, surplus);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), id: {:?}, surplus: {:?}", LOG_PREFIX, id, surplus);
log::debug!(target: LOG_TARGET, "{:?}: submit_solution(), id: {:?}, surplus: {:?}", LOG_PREFIX, id, surplus);

Comment thread pallets/intent/src/lib.rs
let call = Call::cleanup_intent { id: *intent_id };
let tx = T::create_bare(call.into());
if let Err(e) = SubmitTransaction::<T, Call<T>>::submit_transaction(tx) {
debug_assert!(false, "laxy-executorn: failed to submit dispatch_top transaction");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debug_assert!(false, "laxy-executorn: failed to submit dispatch_top transaction");
debug_assert!(false, "laxy-executor: failed to submit dispatch_top transaction");

dmoka and others added 18 commits April 15, 2026 11:05
Rolling DCA schedules (total_amount = 0) were being prematurely
terminated when the price of the bought asset increased after schedule
creation. The remaining_amount (set once at creation, never updated
for rolling schedules) would become smaller than the recalculated
amount_for_next_trade, triggering completion even though the user
had plenty of funds.

Skip both budget termination checks for rolling schedules since
their budget is infinite by definition.
@mrq1911 mrq1911 changed the title feat: ICE foundations feat: ICE Apr 17, 2026

parameter_types! {
//24 hours
pub const MaxIntentDuration: u64 = 24 * 3_600 * 1_000;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is still an limit?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you can create intent without deadline or withing this limit

}

parameter_types! {
pub const IcePalletId: PalletId = PalletId(*b"ice_ice#");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub const IcePalletId: PalletId = PalletId(*b"ice_ice#");
pub const IcePalletId: PalletId = PalletId(*b"iceicebb");

@@ -0,0 +1,4 @@
mod mock;
mod ocw;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cow?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are offchain-worker(ocw) related tests

Comment thread pallets/intent/src/lib.rs

#[pallet::storage]
/// Reverse index mapping account to its intent ids for easy lookup.
pub type AccountIntents<T: Config> =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need 3 maps? cannot we just store intents here where it preserve ownership as well? this way you are spending 3x reads and writes per intent bloat storage and take longer time to load into solver

Comment thread pallets/intent/src/lib.rs

#[pallet::storage]
#[pallet::getter(fn intent_owner)]
pub(super) type IntentOwner<T: Config> = StorageMap<_, Blake2_128Concat, IntentId, T::AccountId>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if intent cannot change ower there is no reason to have separate map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants