Onchain Integration
Call the LeverUp Diamond directly from your own account. You control the key, you pay gas, and nothing sits between your code and the contracts.
If you want the protocol to relay and pay for your transactions instead, see Gasless Trading. The trade parameters are the same either way — this section is worth reading first regardless of which path you take.
Trading calls use one address
| Diamond | 0xea1b8E4aB7f14F7dCA68c5B214303B13078FC5ec |
| Chain ID | 143 (Monad mainnet) |
Point every trading call at that address and supply only the ABI fragment for the function you need. There is no separate address for limit orders, reads, or one-click trading. Standalone helper contracts are called out explicitly; for example, minting LVMON uses the separate LVMONMinter.
For a single machine-readable ABI covering direct trading writes, current reads, lifecycle events, and custom errors, see Trading ABI.
What you can do
| Operation | Function | Oracle data | Page |
|---|---|---|---|
| Mint LVMON from MON or WMON | LVMONMinter.mint | no | Minting LVMON |
| Open at market | openMarketTradeV2 | yes | Market Orders |
| Open a limit order | openLimitOrderV2 | yes | Limit Orders |
| Cancel a limit order | cancelLimitOrder, batchCancelLimitOrders | no | Limit Orders |
| Change a limit order's TP/SL | updateOrderTpAndSl | no | Limit Orders |
| Close fully | closeTrade, batchCloseTrade | no | Closing |
| Close partially | closeTrade(hash, closeQty, broker) | no | Closing |
| Add margin | addMargin | no | Managing a Position |
| Remove margin | removeMargin | yes | Managing a Position |
| Change a position's TP/SL | updateTradeTpAndSl | no | Managing a Position |
| Create TP/SL orders | batchCreateDecreaseOrders | no | TP/SL Orders |
| Update / cancel TP/SL orders | batchUpdateDecreaseOrders, cancelDecreaseOrder | no | TP/SL Orders |
| Read positions, orders, markets | getPositionsV4, getLimitOrders, … | n/a | Reading Data |
"Oracle data: yes" means the call takes an OracleUpdateData argument and requires a native-token fee as msg.value. See Oracle updates.
Two-phase execution
Opens and closes are requests, not immediate state changes:
your tx keeper tx
│ │
├─ openMarketTradeV2 ──────────►│
│ collateral locked │ oracle price delivered
│ MarketPendingTrade emitted ├─► position opens
│ │ OpenPosition / PositionIncreased emittedA successful receipt on your own transaction confirms the request was accepted. Confirm the outcome by watching events or polling getPositionsV4.
Requests can also be refunded — if the filled price falls outside your acceptable price, the market is closed, or a limit fails. A refund emits PendingTradeRefund with a reason code; see the Error Reference.
Before your first write
- Approve the Diamond for the collateral token you intend to use. Approve the Diamond address itself.
- Look up the pair with
GET /v1/pairs— do not hardcodepairBase. - Pair
tokenInwith the rightlvToken— see Collateral and lvToken. - Get the units right —
qtyat 1e10, prices at 1e18. See Precision & Units. - If you route trades for others, decide what to pass in
brokerbefore you start — it appears on opens, closes and TP/SL orders, and0is not a neutral value. See Brokers & Referrals.
Shared snippets
All examples on the following pages assume the config.ts from the Quickstart, plus this oracle helper:
import { API } from './config'
export async function fetchOracleUpdate(
pairBase: `0x${string}`,
collateral: `0x${string}`,
) {
const res = await fetch(`${API}/v1/oracle/price/updates/by-position`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
pairBase,
collateral,
blockChain: 'MONAD',
options: { includeEncodingData: true, includeFee: true, includePrice: true },
}),
})
if (!res.ok) throw new Error(`oracle: HTTP ${res.status}`)
const data = await res.json()
return {
updateData: {
pythPriceUpdateData: data.pythPriceUpdateData ?? [],
pythProPriceUpdateData: data.pythProPriceUpdateData ?? [],
},
value: BigInt(data.updateFee ?? '0') + BigInt(data.verifition_fee ?? '0'),
}
}Native MON collateral
When tokenIn is native MON (0x0), request oracle data using the WMON address as collateral, and set the transaction value to amountIn + oracleValue instead of just oracleValue.