Skip to content

Commit 3face26

Browse files
authored
Merge pull request #2268 from opentensor/fix/dissolve-tao-fees
Fix: Do not hold tao fees when dissolving LP
2 parents 4d3a7ab + a8d1745 commit 3face26

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

pallets/swap/src/pallet/impls.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -880,10 +880,12 @@ impl<T: Config> Pallet<T> {
880880
// ---------------- USER: refund τ and convert α → stake ----------------
881881

882882
// 1) Refund τ principal directly.
883-
if rm.tao > TaoCurrency::ZERO {
884-
T::BalanceOps::increase_balance(&owner, rm.tao);
885-
user_refunded_tao = user_refunded_tao.saturating_add(rm.tao);
886-
T::TaoReserve::decrease_provided(netuid, rm.tao);
883+
let tao_total_from_pool: TaoCurrency = rm.tao.saturating_add(rm.fee_tao);
884+
if tao_total_from_pool > TaoCurrency::ZERO {
885+
T::BalanceOps::increase_balance(&owner, tao_total_from_pool);
886+
user_refunded_tao =
887+
user_refunded_tao.saturating_add(tao_total_from_pool);
888+
T::TaoReserve::decrease_provided(netuid, tao_total_from_pool);
887889
}
888890

889891
// 2) Stake ALL withdrawn α (principal + fees) to the best permitted validator.
@@ -967,17 +969,17 @@ impl<T: Config> Pallet<T> {
967969
Ok(rm) => {
968970
let alpha_total_from_pool: AlphaCurrency =
969971
rm.alpha.saturating_add(rm.fee_alpha);
970-
let tao = rm.tao;
972+
let tao_total_from_pool: TaoCurrency = rm.tao.saturating_add(rm.fee_tao);
971973

972-
if tao > TaoCurrency::ZERO {
973-
burned_tao = burned_tao.saturating_add(tao);
974+
if tao_total_from_pool > TaoCurrency::ZERO {
975+
burned_tao = burned_tao.saturating_add(tao_total_from_pool);
974976
}
975977
if alpha_total_from_pool > AlphaCurrency::ZERO {
976978
burned_alpha = burned_alpha.saturating_add(alpha_total_from_pool);
977979
}
978980

979981
log::debug!(
980-
"clear_protocol_liquidity: burned protocol pos: netuid={netuid:?}, pos_id={pos_id:?}, τ={tao:?}, α_total={alpha_total_from_pool:?}"
982+
"clear_protocol_liquidity: burned protocol pos: netuid={netuid:?}, pos_id={pos_id:?}, τ={tao_total_from_pool:?}, α_total={alpha_total_from_pool:?}"
981983
);
982984
}
983985
Err(e) => {

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
220220
// `spec_version`, and `authoring_version` are the same between Wasm and native.
221221
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
222222
// the compatible custom types.
223-
spec_version: 350,
223+
spec_version: 351,
224224
impl_version: 1,
225225
apis: RUNTIME_API_VERSIONS,
226226
transaction_version: 1,

0 commit comments

Comments
 (0)