Trading ABI
Use this ABI for direct onchain trading against the LeverUp Diamond on Monad mainnet. It is a raw JSON ABI array, so it can be passed directly to viem, ethers, web3.js, or another EVM client.
| Contract | LeverUp Diamond |
| Address | 0xea1b8E4aB7f14F7dCA68c5B214303B13078FC5ec |
| Chain ID | 143 (Monad mainnet) |
| Format | JSON ABI array |
Download
Download leverup-trading-abi.json
Stable URL:
https://developer-docs.leverup.xyz/abi/leverup-trading-abi.jsonThe file contains the user-facing direct-trading functions, current read functions, lifecycle events, and relevant custom errors. The same ABI is used with the Diamond address for every entry — facet names only describe how the contract is organised internally.
The bundle intentionally excludes:
- admin functions and keeper-only settlement functions;
- legacy
V2andV3read methods when aV4method is available; _forOneclickfunctions, which are protocol relay entrypoints rather than public integration methods;- ERC-20 approval and the standalone
LVMONMinterABI.
See Authorizing an Agent for 1CT authorization calls and Minting LVMON for the separate minter contract.
Pin the ABI in production
The download URL always represents the current documented deployment. Vendor the JSON into your application and review the changelog before updating it; this keeps a docs release from changing your runtime unexpectedly.
Load the ABI
import type { Abi } from 'viem'
const ABI_URL = 'https://developer-docs.leverup.xyz/abi/leverup-trading-abi.json'
const response = await fetch(ABI_URL)
if (!response.ok) throw new Error(`ABI download failed: HTTP ${response.status}`)
export const tradingAbi = await response.json() as AbiOr download and vendor it during your build:
curl -L https://developer-docs.leverup.xyz/abi/leverup-trading-abi.json \
--output leverup-trading-abi.jsonimport tradingAbi from './leverup-trading-abi.json'
import { getContract } from 'viem'
import { publicClient, walletClient, account, DIAMOND } from './config'
const trading = getContract({
address: DIAMOND,
abi: tradingAbi,
client: { public: publicClient, wallet: walletClient },
})
const positions = await trading.read.getPositionsV4([account.address, pairBase])Write functions
Open orders
| Function | Payable | Description |
|---|---|---|
openMarketTradeV2(OpenDataInput, OracleUpdateData, uint96) | yes | Request a market open. Returns the pending trade hash. |
openLimitOrderV2(OpenDataInput, OracleUpdateData, uint96) | yes | Place a limit order. Returns the order hash. |
Both calls require an oracle update and may require native-token msg.value. The last argument is the optional broker extraFee, not the oracle fee. See Market Orders and Limit Orders for executable examples.
Change or cancel a limit order
| Function | Description |
|---|---|
updateOrderTp(bytes32,uint128) | Change the order's take-profit price. |
updateOrderSl(bytes32,uint128) | Change or clear the order's stop-loss price. |
updateOrderTpAndSl(bytes32,uint128,uint128) | Change TP and SL atomically. |
cancelLimitOrder(bytes32) | Cancel one unfilled limit order. |
batchCancelLimitOrders(bytes32[]) | Cancel several unfilled limit orders. |
These calls are not payable. Prices use 1e18 precision; see Precision & Units.
Close a position
| Function signature | Description |
|---|---|
closeTrade(bytes32) | Fully close using the position's existing broker. |
closeTrade(bytes32,uint24) | Fully close and specify the close-fee broker. |
closeTrade(bytes32,uint128,uint24) | Partially close closeQty and specify the broker. |
batchCloseTrade(bytes32[]) | Fully close several positions using their existing brokers. |
batchCloseTrade(bytes32[],uint24) | Fully close several positions with one broker ID. |
The ABI includes all overloads. With ethers, use the full signature when the overload is ambiguous, for example contract['closeTrade(bytes32,uint128,uint24)'](...). See Closing & Partial Close for lifecycle details.
Manage a position
| Function | Payable | Description |
|---|---|---|
addMargin(bytes32,address,uint96) | yes | Add collateral to an open position. |
removeMargin(bytes32,uint96,OracleUpdateData) | yes | Remove margin after an oracle-backed risk check. |
updateTradeTp(bytes32,uint128) | no | Change the embedded full-position take profit. |
updateTradeSl(bytes32,uint128) | no | Change or clear the embedded full-position stop loss. |
updateTradeTpAndSl(bytes32,uint128,uint128) | no | Change embedded TP and SL atomically. |
addMargin is payable only when adding native MON; removeMargin uses msg.value for the oracle update fee. See Managing a Position.
TP/SL decrease orders
| Function | Description |
|---|---|
createDecreaseOrder(bytes32,DecreaseOrderInput) | Create one standalone TP or SL order. |
batchCreateDecreaseOrders(bytes32,DecreaseOrderInput[]) | Create multiple orders atomically. |
batchUpdateDecreaseOrders(DecreaseOrderUpdateInput[]) | Update multiple active orders. |
cancelDecreaseOrder(bytes32) | Cancel one order. |
cancelAllDecreaseOrders(bytes32) | Cancel every order attached to a position. |
These calls are not payable. closeQty uses 1e10 precision. See TP/SL Orders for order constraints and tuple definitions.
Read functions
Reads use the same Diamond address and do not require a wallet.
| Area | Functions | Description |
|---|---|---|
| Positions | getPositionsV4, getPositionByHashV4, getPositionByKeyV4 | Return current position snapshots. |
| Position identity | getPositionHash, getPositionTrader | Compute or resolve a merged position hash. |
| Pending opens | getPendingTrade | Return a pending market-open request. |
| Limit orders | getLimitOrders, getLimitOrderByHash | Return active limit orders. |
| TP/SL orders | getDecreaseOrders, getTraderDecreaseOrders, getDecreaseOrder | Return active standalone decrease orders. |
| Market state | getMarketInfoV2, getMarketInfosV2 | Return open interest and funding state. |
| Pair configuration | getPairByBaseV4, getPairConfig, getPairFeeConfig, getPairHoldingFeeRate, getPairSlippageConfig | Return trading limits, fees, holding rates, and slippage settings. |
| Locked assets | traderAssets | Return protocol-locked totals by token and purpose. |
Return tuple layouts and examples are documented in Reading Data.
Shared ABI types
The JSON file includes the complete tuple components. These are the main types you will encounter:
| Type | Used by | Notes |
|---|---|---|
OpenDataInput | Market and limit opens | Pair, direction, collateral, quantity, price bounds, TP/SL, and broker. |
OracleUpdateData | Opens and margin removal | Pyth and Pyth Pro update byte arrays. |
PositionV4 | Position reads | Current merged-position state and accrued fee fields. |
LimitOrderView | Limit-order reads | Active order state plus its orderHash. |
DecreaseOrderInput | TP/SL order creation | Kind, trigger price, close quantity, and broker. |
DecreaseOrderUpdateInput | TP/SL order updates | Order hash plus replacement values. |
OpenTradeEventV2 | Settlement events | Full position snapshot after an open, increase, or decrease. |
CloseInfo | Settlement events | Fill price, funding fee, close fee, PnL, and holding fee. |
Solidity enums appear in JSON ABI as their integer types. In particular, DecreaseOrderKind is uint8: 0 is TP and 1 is SL.
Events and errors
The ABI contains request and settlement events, including MarketPendingTrade, OpenPosition, PositionIncreased, PendingTradeRefund, OpenLimitOrder, CloseTradeRequested, ClosePosition, PositionDecreased, and the decrease-order events. Use settlement events—not only the transaction receipt—to determine whether a two-phase open or close actually completed. See Events.
Relevant custom error entries are included so clients can decode revert data with the same ABI. Some protocol failures still use Solidity's standard Error(string) or Panic(uint256) formats; handle those as a fallback. See Error Reference.