Kwenta smart margin: Batched Commands and Account Balances
Last updated ·Kwenta smart margin batched ordered Synthetix commands into one transaction through a dedicated trading account. Its legacy Synthetix Perps V2 implementation could combine collateral deposits with market-margin changes while preserving each command’s inputs and order. A successful batch could finish a funding action without completing a delayed trade. Account collateral, market collateral, and an executed position represented different states. This command model belonged to the older trading architecture that preceded Synthetix’s later Ethereum Mainnet order-book exchange.
In short: The order of funding and margin commands mattered because each later action relied on the account state left by earlier commands.
Synthetix Positions and the Smart Margin Account
Synthetix Perps V2 supplied the trading rules, while a Smart Margin account organized changes to collateral and positions. Its commands could affect margin and position size across multiple supported markets. The selected market still determined how an order behaved, including whether its route required later execution.
Direct isolated-margin trading required separate deposits and withdrawals for individual markets. Smart Margin added a shared account and a programmable command sequence above those market contracts. That arrangement made collateral management easier to combine while retaining the underlying market’s trading rules.
Command Order and Spending Permission
A wallet needed an existing Smart Margin account and the relevant spending authorization before a batch could pull its sUSD. The legacy onboarding sequence created the account, authorized sUSD spending, and then completed the first deposit. The allowance set how much sUSD the account could transfer from the wallet. A missing allowance prevented the account from pulling the wallet’s sUSD.
A command that needed newly deposited collateral had to follow the command that supplied it.
Commands could use funds that the account already held, so a wallet transfer wasn’t necessary in every batch. The contract still needed enough available margin for the requested allocation, after allowing for any existing commitments.
Matched Commands and Encoded Inputs
Account.execute
accepted a command array alongside an array of encoded inputs.
Each command used the encoded input at the same array index.
The application binary interface (ABI) encoding followed the parameters for that command. Changing the command order therefore required keeping each operation paired with its own inputs. The engine also supported swap commands through Uniswap’s UniversalRouter.
An off-chain delayed-order submission required a market address, a position-size change, and a desired fill price. A delayed-order cancellation required the market address with an active delayed order for that account. Both operations used the same account entry point while requiring different input layouts.
Wallet Funds and Market Margin
Unused sUSD in the account and sUSD allocated to a market represented different balances in the legacy Optimism setup. The interface displayed Free Account Margin for available account collateral and Market Margin for collateral assigned to the selected position. Allocating funds reduced what remained available for another command. Unused account collateral stayed outside the selected market’s position margin. A liquidation of that market position didn’t consume unused account collateral. Outstanding opening orders could also earmark funds, so the wallet balance, account balance, and immediately available margin didn’t necessarily match.
A Hypothetical sUSD Funding Batch
In this hypothetical historical Optimism example, a wallet held 172 sUSD and aimed to allocate 132 sUSD to a supported Synthetix Perps V2 market. Assume an existing Smart Margin account with no free collateral, no pending orders, and no open position. The wallet had enough ETH for gas, but it hadn’t granted the necessary sUSD spending allowance.
Authorization had to come first. With a sufficient allowance in place, the owner could submit an ordered batch that deposited 172 sUSD into the account and then allocated 132 sUSD to the chosen market. The deposit changed the balance that the allocation command could draw on. Reversing those commands would fail the allocation’s free-margin check and revert the whole batch.
After successful execution, the expected balances were 132 sUSD of market margin and 40 sUSD of unused account collateral: 172 - 132 = 40 sUSD. The example included no swap, trade, existing commitments, or other sUSD movements. Matching those account and market balances completed the funding task. Opening a position would require an executed order. Increasing the allocation would reduce unused collateral by the same amount, within the available balance.
Batch Submission and Delayed Execution
A delayed-order submission recorded an instruction for later market execution, even when the submission shared a batch with margin changes. The legacy market-order route used delayed execution, so the account transaction could succeed before the position changed. A transaction receipt established the batch’s on-chain outcome; order and position records established what happened afterward.
Conditional limit orders introduced a trigger condition before the requested trade could proceed. The order remained pending while its trigger condition was unmet. A funded account or an entry under the Orders tab wasn’t equivalent to a trade in the position history.
Executed Notional and Separate Gas Costs
Batching combined submissions for supported account actions; the market still charged its applicable trading fees. For legacy Synthetix Perps V2 market execution, maker and taker fees used executed notional, the value of the order that executed. Unused account collateral wasn’t the fee base. Maker and taker rates could differ by market, while keeper charges reflected the execution route and gas conditions. Network gas covered the transaction itself. Combining commands therefore didn’t establish a fixed total cost or remove the fee that a later execution could incur.
Legacy Deployments and Later Exchange Versions
Smart Margin used upgradeable account proxies, with a shared implementation that the Factory contract could update. The implementation determined the available command behavior.
Synthetix acquired Kwenta in November 2024, and the frontend later transitioned to Synthetix Exchange. Synthetix’s March 13, 2026 roadmap described L2 AMMs as deprecated after its shift to an Ethereum Mainnet order-book exchange. That later matching system differed from the legacy Smart Margin command engine. Interpreting historical transactions required the original network, account implementation, and market contract. The later exchange’s order rules weren’t interchangeable with an old account’s command inputs.
Kwenta smart margin FAQ
Did Smart Margin Batching Require a one-click Trading Session?
Batching didn’t require one-click trading. Smart Margin grouped commands at the contract level, while one-click trading delegated transaction submission to a separate wallet. The legacy interface also offered manual signing, so the number of wallet prompts and the number of commands described different aspects of the process.
How Did Changing Browsers Affect a Delegated Smart Margin Session?
A delegated one-click session belonged to the browser that stored its key. Switching browsers or devices required another session, even though the trading account could remain the same. Session state concerned permission to submit transactions; it didn’t represent a new margin deposit or change the account’s existing balances.
Which Records Identified a Smart Margin Deposit?
Deposit events identified margin deposits, and the account balance showed the funds remaining afterward. Smart Margin consolidated activity events through an Events contract. An event for placing a conditional order concerned that order action; it didn’t establish that a trade had subsequently filled.
Were Smart Margin and isolated-margin Positions on the Same Market Merged?
The legacy interface kept Smart Margin and isolated-margin positions separate, even when they used the same market and opposite directions.
Did Every Conditional Order Reserve Additional Smart Margin Collateral?
An opening conditional order could reserve account margin. Closing orders didn’t reserve additional margin when they stayed within the existing open position and used only its existing margin. The account’s raw sUSD balance therefore couldn’t always stand in for available collateral; outstanding commitments also affected the funds available for another command.
What Happened to Costs When a Smart Margin Advanced Order Failed?
Synthetix charged its trading fee only when the trade executed; an unsuccessful attempt could still consume ETH for gas. The published Smart Margin 2.1.5 implementation could also charge a configured account fee at delayed-order submission and pay an executor before cancelling an invalid reduce-only order. The gas charge covered blockchain processing even when the requested trade didn’t complete.