Conversation
| 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: {:?}", |
There was a problem hiding this comment.
| 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: {:?}", |
|
|
||
| match t.direction { | ||
| SwapType::ExactOut => { | ||
| log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), buying, asset_in: {:?}, asset_out: {:?}, amount_out: {:?}, max_amount_in: {:?}, route: {:?}", |
There was a problem hiding this comment.
| 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: {:?}", |
| )?; | ||
| } | ||
| SwapType::ExactIn => { | ||
| log::debug!(target: LOG_TARGET, "{:?}: sumbit_solution(), selling, asset_in: {:?}, asset_out: {:?}, amount_in: {:?}, min_amount_out: {:?}, route: {:?}", |
There was a problem hiding this comment.
| 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: {:?}", |
| 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); |
There was a problem hiding this comment.
| 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); |
| 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); |
There was a problem hiding this comment.
| 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); |
| 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"); |
There was a problem hiding this comment.
| debug_assert!(false, "laxy-executorn: failed to submit dispatch_top transaction"); | |
| debug_assert!(false, "laxy-executor: failed to submit dispatch_top transaction"); |
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.
|
|
||
| parameter_types! { | ||
| //24 hours | ||
| pub const MaxIntentDuration: u64 = 24 * 3_600 * 1_000; |
There was a problem hiding this comment.
yes, you can create intent without deadline or withing this limit
| } | ||
|
|
||
| parameter_types! { | ||
| pub const IcePalletId: PalletId = PalletId(*b"ice_ice#"); |
There was a problem hiding this comment.
| pub const IcePalletId: PalletId = PalletId(*b"ice_ice#"); | |
| pub const IcePalletId: PalletId = PalletId(*b"iceicebb"); |
| @@ -0,0 +1,4 @@ | |||
| mod mock; | |||
| mod ocw; | |||
There was a problem hiding this comment.
these are offchain-worker(ocw) related tests
|
|
||
| #[pallet::storage] | ||
| /// Reverse index mapping account to its intent ids for easy lookup. | ||
| pub type AccountIntents<T: Config> = |
There was a problem hiding this comment.
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
|
|
||
| #[pallet::storage] | ||
| #[pallet::getter(fn intent_owner)] | ||
| pub(super) type IntentOwner<T: Config> = StorageMap<_, Blake2_128Concat, IntentId, T::AccountId>; |
There was a problem hiding this comment.
if intent cannot change ower there is no reason to have separate map
This PR introduces foundation of ICE - Intent Composing Engine.
Included: