depositAndAllocateForAccount
Deposit collateral into a subaccount and allocate it into the classic pool in one transaction. Calls AccountLayer.depositAndAllocateForAccount — equivalent to depositForAccount followed by an allocate, but atomic.
Not the instant-flow funding step. Instant trading spends the available balance; funds allocated here land in
the classic pool, which an instant open does not consume — the symptom is “deposited, but the trade form shows
zero margin.” For the instant (lowcap) flow, fund with depositForAccount
alone. See Balance Model.
Like depositForAccount, it requires a prior ERC-20 approval of the collateral token to the SYMMIO core (symmioAddress).
import { depositAndAllocateForAccount } from "@symmio/trading-core";
const hash = await depositAndAllocateForAccount(config, {
account: "0xsub...",
amount: 1_000000n, // collateral decimals (e.g. 1 USDC at 6 decimals)
});Parameters
accountAddressrequiredThe subaccount to credit and allocate for. The signer must equal its on-chain owner.
amountbigintrequiredAmount of collateral to deposit and allocate, in the collateral token’s decimals
(getChainConfig().addresses.collateralDecimals) — not 18 decimals.
chainIdnumberoptionalOptional chain override.
simulateBeforeWritebooleanoptionalDry-run via simulateContract first (defaults to the config’s setting, itself true by default).
Returns
HashThe broadcast tx hash. Dry-run without sending via simulateDepositAndAllocateForAccount(config, params).
Related
- Balance Model — instant flow vs. classic pool.
depositForAccount— the instant-flow funding write.allocate/deallocate— the classic-pool moves.