MarginSimulationBuildResponse
Full build loop response enriched with post-trade simulation (POST only).
quotes object[]required
deltas object
Aggregator source
Trade input amount
Trade output amount
deltas object
Balance deltas
Balance deltas
tx object
Target contract address
0x1234...abcdEncoded calldata
0xabcdef...ETH value to send with the transaction
0permissionTxns object[]required
Target contract address
Encoded calldata
ETH value
Human-readable description of the approval
simulation objectnullable
Projected post-trade metrics, or null if simulation failed
- LoopPostTradeMetrics
Health factor before the trade
Health factor after the trade
Borrow capacity (USD) before the trade
Borrow capacity (USD) after the trade
balanceDataPost object
Aggregated balance data for a sub-account.
Total deposits in USD
10000.5Total debt in USD
5000.25Debt adjusted for borrow factors
5500Collateral value in USD
9000Collateral if all assets were enabled
10000.5Collateral discounted by borrow factors
8000Discounted collateral if all enabled
9000Net asset value (deposits - debt)
5000.25Deposits 24h ago (for change calculation)
9800Debt 24h ago
4900NAV 24h ago
4900rewards object
Pending rewards by token
Pending rewards by token
aprDataPost object
APR breakdown for a sub-account.
Net APR (deposit - borrow)
2.5Weighted deposit APR
3.5Weighted borrow APR
5.2Total reward APR
1.2Reward APR on deposits
0.8Reward APR on borrows
0.4Intrinsic yield APR (e.g., stETH staking)
0Intrinsic yield APR portion from deposits
0Intrinsic yield APR portion from borrows
0rewards object
Reward token details
Reward token details
Error message if simulation failed
{
"lender": "string",
"quotes": [
{
"deltas": {
"aggregator": "string",
"tradeInput": 0,
"tradeOutput": 0,
"deltas": {}
},
"tx": {
"to": "0x1234...abcd",
"data": "0xabcdef...",
"value": "0"
}
}
],
"permissionTxns": [
{
"to": "string",
"data": "string",
"value": "string",
"info": "string"
}
],
"simulation": {
"healthFactor": 0,
"healthFactorPost": 0,
"borrowCapacity": 0,
"borrowCapacityPost": 0,
"balanceDataPost": {
"deposits": 10000.5,
"debt": 5000.25,
"adjustedDebt": 5500,
"collateral": 9000,
"collateralAllActive": 10000.5,
"borrowDiscountedCollateral": 8000,
"borrowDiscountedCollateralAllActive": 9000,
"nav": 5000.25,
"deposits24h": 9800,
"debt24h": 4900,
"nav24h": 4900,
"rewards": {}
},
"aprDataPost": {
"apr": 2.5,
"depositApr": 3.5,
"borrowApr": 5.2,
"rewardApr": 1.2,
"rewardDepositApr": 0.8,
"rewardBorrowApr": 0.4,
"intrinsicApr": 0,
"intrinsicDepositApr": 0,
"intrinsicBorrowApr": 0,
"rewards": {}
}
},
"simulationError": "string"
}