add_liquidity
Debit USD from the trading margin to mint counterparty-vault LP shares.
The vault is the perps exchange's passive market maker; LPs share its
inventory-skew-aware quoting PnL. Shares are minted via the ERC-4626 virtual
shares pattern, floor-rounded. Use min_shares_to_mint as a slippage guard
when the vault equity is moving. See protocol book: perps/5-vault §2.
Signature
def add_liquidity(
self,
amount: float | int | str | Decimal,
*,
min_shares_to_mint: int | None = None,
) -> dict[str, Any]Example
from dango.exchange import Exchange
from dango.utils.types import Addr
exchange = Exchange(wallet, base_url, account_address=Addr("0x..."))
# Deposit 100 USD of margin into the LP vault
exchange.add_liquidity(100)
# With slippage protection: revert if minting fewer than 95 shares
exchange.add_liquidity("100.00", min_shares_to_mint=95)Parameters
amount — float | int | str | Decimal. USD amount, canonicalised via dango_decimal. Must be positive (ValueError on zero / negative).
min_shares_to_mint — int | None, optional. Slippage guard: revert if fewer than this many shares would be minted. None (default) disables the guard. bool is rejected (TypeError); negative ints are rejected (ValueError).
Returns
dict[str, Any] — the BroadcastTxOutcome envelope.
Notes
- The USD amount is debited from the caller's existing trading margin — NOT attached as funds on the execute message.
- Vault deposits flow inside the contract; the wallet boundary is not crossed.
- Deposits revert if the vault's
effective_equityis non-positive (catastrophic loss).
See also
remove_liquidity— counterpart that burns sharesdeposit_margin— top up margin before adding liquidity