-
Notifications
You must be signed in to change notification settings - Fork 550
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
Dex offchain rebalance swap #2219
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking if we want to implement this in aggregated-dex so it can also rebalance pools with stable asset pools.
modules/dex/src/lib.rs
Outdated
.push(pair.second()); | ||
}); | ||
for (currency_id, trading_tokens) in trading_pair_values_map { | ||
let _ = TradingPairNodes::<T>::try_mutate(currency_id, |maybe_trading_tokens| -> DispatchResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you can mutate storages in offchain worker? at least the storages won't be saved. you need to use offchain worker db for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TradingPairNodes
type is CurrencyId->[CurrencyId], I think this datastructure is too complicate for offchain db. Current I'm moving this storage mutate part to on_idle
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove TradingPairNodes
, and direct calculate without on chain storage.
closes: #2137
set_rebalance_swap_info
set the threshold and supply amount of token. if target swapped amount is less than threshold, no rebalance happened. We're using treasury account to do rebalance swap, so the treasury account should have balance for specified token.CurrencyId
-> values:[CurrencyId]
fromDEX::TradingPairStatuses
which help decide the rebalance swap path in the case of pure DEX. i.e. if trading pair has [A,B],[A,C],[B,C], then datastructure is: A-[B,C], B-[C], and (A,B,C) can be rebalance path, the final trading path is Dex(A,B,C) + Dex(C,A).RebalanceSwapPaths
, it's only used by offchain worker, not used by normal aggregated dex swap.or 3USD pool: Taiga(AUSD,USDC)+Taiga(USDC,USDT)+Taiga(USDT,AUSD).