feat(amm): let LPs choose the LP-token destination account

Add-liquidity minted a fresh LP account every time, fragmenting a position
across holdings. The New position form now has an LP-destination selector (the
same Input-mode component as the token funding rows): add-liquidity preselects
the wallet's existing LP holding so deposits consolidate, while create-pool has
none and mints a fresh one.

- addLiquidityQuote returns lpDefinitionId (base58) so the form matches holdings
- createPool/addLiquidity submit into the chosen holding, else create-fresh
- e2e: add-liquidity waits for the preselect; create-pool asserts fresh-account
This commit is contained in:
r4bbit
2026-08-21 15:35:27 +02:00
parent 4cb7c7e51c
commit 62d133e909
7 changed files with 106 additions and 10 deletions
+3
View File
@@ -307,6 +307,9 @@ pub(super) fn add_liquidity_quote(request: AddLiquidityQuoteRequest) -> Result<V
"expectedLp": delta_lp.to_string(),
"minimumLp": minimum_lp.to_string(),
"price": price.to_string(),
// The pool's LP token definition (base58, matching the holdings' definitionId) so
// the UI can offer the wallet's existing LP holdings as the mint destination.
"lpDefinitionId": pool.liquidity_pool_id.to_string(),
}))
}
+2 -1
View File
@@ -1036,7 +1036,8 @@ LogosMap AmmModuleImpl::addLiquidityQuote(const LogosMap& request) {
if (!quoteResult.ok)
return error(quoteResult.error.empty() ? "backend_error" : quoteResult.error);
// Success: wrap { amountA, amountB, expectedLp, minimumLp, price }.
// Success: wrap { amountA, amountB, expectedLp, minimumLp, price, lpDefinitionId }.
// (lpDefinitionId is the pool's LP token so the UI can offer existing LP holdings.)
LogosMap out = quoteResult.value;
out["status"] = "ok";
out["error"] = "";