[
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "_weth",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "_insuranceFund",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "_positionManager",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "_positionMerger",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "_deleverager",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "_orderCreator",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "_whitelist",
                "type": "address"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "constructor"
    },
    {
        "inputs": [],
        "name": "AMM_IS_ACTIVE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "AlreadyInitialized",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "BAD_DEBT",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "INACTIVE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "INSUFFICIENT_LIQUIDITY",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "INSUFFICIENT_MARGIN",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "INSUFFICIENT_OPEN_NOTIONAL",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "INSUFFICIENT_SIZE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "INVALID_AMM",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "INVALID_SIDE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "INVALID_TRIGGER_AMOUNT",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "LIQUIDATABLE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "NOT_LIMIT_CLOSE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "NOT_LIQUIDATABLE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "NOT_REDUCE_ONLY",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "NOT_TRADER",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "NO_POOL_IN_RANGE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "NO_POSITION",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "NewOwnerIsZeroAddress",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "NoHandoverRequest",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "OPEN_INTEREST_CAP_EXCEEDED",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "OVER_DIVERGENCE_CAP",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "OVER_MAX_LEVERAGE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "OVER_MAX_SIZE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "POSITION_ON_WRONG_SIDE",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "SANDWICH",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "TRIGGER_INVALID",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "TRIGGER_ON_MARK",
        "type": "error"
    },
    {
        "inputs": [],
        "name": "Unauthorized",
        "type": "error"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            }
        ],
        "name": "AMMInvalidated",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            }
        ],
        "name": "AMMValidated",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [],
        "name": "Activated",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [],
        "name": "Deactivated",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "divergenceCap",
                "type": "uint256"
            }
        ],
        "name": "DivergenceCapChanged",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "payer",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "receiver",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "enum FeeType",
                "name": "feeType",
                "type": "uint8"
            }
        ],
        "name": "FeeDistributed",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "markPrice",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "indexPrice",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "int256",
                "name": "premiumFraction",
                "type": "int256"
            }
        ],
        "name": "FundingSettled",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": false,
                "internalType": "uint8",
                "name": "version",
                "type": "uint8"
            }
        ],
        "name": "Initialized",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            },
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "trader",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "enum LimitOrderResult",
                "name": "result",
                "type": "uint8"
            }
        ],
        "name": "LimitOrderRemoved",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            },
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "trader",
                "type": "address"
            },
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "enum Side",
                        "name": "side",
                        "type": "uint8"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteAmount",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "leverage",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "reduceOnly",
                        "type": "bool"
                    }
                ],
                "indexed": false,
                "internalType": "struct LimitOrder",
                "name": "order",
                "type": "tuple"
            }
        ],
        "name": "LimitOrderUpdated",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "maker",
                "type": "address"
            }
        ],
        "name": "LiquidityAdded",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "trader",
                "type": "address"
            }
        ],
        "name": "LiquidityRemoved",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "trader",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            }
        ],
        "name": "MarginAdded",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "trader",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "amount",
                "type": "uint256"
            }
        ],
        "name": "MarginRemoved",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "minOrderbookMargin",
                "type": "uint256"
            }
        ],
        "name": "MinOrderbookMarginChanged",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "newOpenInterest",
                "type": "uint256"
            }
        ],
        "name": "OpenInterestChanged",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "pendingOwner",
                "type": "address"
            }
        ],
        "name": "OwnershipHandoverCanceled",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "pendingOwner",
                "type": "address"
            }
        ],
        "name": "OwnershipHandoverRequested",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "oldOwner",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "newOwner",
                "type": "address"
            }
        ],
        "name": "OwnershipTransferred",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "trader",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "margin",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "int256",
                "name": "size",
                "type": "int256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "openNotional",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "exchangedQuote",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "int256",
                "name": "exchangedBase",
                "type": "int256"
            },
            {
                "indexed": false,
                "internalType": "int256",
                "name": "realizedPnL",
                "type": "int256"
            },
            {
                "indexed": false,
                "internalType": "int256",
                "name": "fundingPayment",
                "type": "int256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "markPrice",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "enum TradeType",
                "name": "tradeType",
                "type": "uint8"
            }
        ],
        "name": "PositionChanged",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            },
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "trader",
                "type": "address"
            },
            {
                "indexed": false,
                "internalType": "address",
                "name": "keeper",
                "type": "address"
            }
        ],
        "name": "TriggerOrderRemoved",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            },
            {
                "indexed": true,
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "trader",
                "type": "address"
            },
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "size",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteLimit",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "takeProfit",
                        "type": "bool"
                    }
                ],
                "indexed": false,
                "internalType": "struct TriggerOrder",
                "name": "order",
                "type": "tuple"
            }
        ],
        "name": "TriggerOrderUpdated",
        "type": "event"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "components": [
                    {
                        "internalType": "uint256",
                        "name": "index",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "margin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "leverage",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct LiquidityAddData[]",
                "name": "data",
                "type": "tuple[]"
            }
        ],
        "name": "addLiquidity",
        "outputs": [
            {
                "components": [
                    {
                        "internalType": "contract IPool",
                        "name": "pool",
                        "type": "address"
                    },
                    {
                        "internalType": "uint256",
                        "name": "shares",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quote",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "base",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct LiquidityAddReturnData[]",
                "name": "returnData",
                "type": "tuple[]"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "margin",
                "type": "uint256"
            }
        ],
        "name": "addMargin",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "cancelOwnershipHandover",
        "outputs": [],
        "stateMutability": "payable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "size",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "quoteLimit",
                "type": "uint256"
            }
        ],
        "name": "closePosition",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "quoteAmount",
                "type": "uint256"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            }
        ],
        "name": "closePositionKeeper",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "quoteAmount",
                "type": "uint256"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "pendingOwner",
                "type": "address"
            }
        ],
        "name": "completeOwnershipHandover",
        "outputs": [],
        "stateMutability": "payable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "enum Side",
                        "name": "side",
                        "type": "uint8"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteAmount",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "leverage",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "reduceOnly",
                        "type": "bool"
                    }
                ],
                "internalType": "struct LimitOrder",
                "name": "order",
                "type": "tuple"
            }
        ],
        "name": "createLimitOrder",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "enum Side",
                        "name": "side",
                        "type": "uint8"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteAmount",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "leverage",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "reduceOnly",
                        "type": "bool"
                    }
                ],
                "internalType": "struct LimitOrder[]",
                "name": "_orders",
                "type": "tuple[]"
            }
        ],
        "name": "createLimitOrderBatch",
        "outputs": [
            {
                "internalType": "uint256[]",
                "name": "ids",
                "type": "uint256[]"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "size",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteLimit",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "takeProfit",
                        "type": "bool"
                    }
                ],
                "internalType": "struct TriggerOrder",
                "name": "order",
                "type": "tuple"
            }
        ],
        "name": "createTriggerOrder",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            }
        ],
        "name": "deleteLimitOrder",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256[]",
                "name": "ids",
                "type": "uint256[]"
            }
        ],
        "name": "deleteLimitOrderBatch",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            }
        ],
        "name": "deleteTriggerOrder",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "taker",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "maker",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "size",
                "type": "uint256"
            }
        ],
        "name": "deleverage",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            }
        ],
        "name": "getCumulativePremiumFraction",
        "outputs": [
            {
                "internalType": "int256",
                "name": "",
                "type": "int256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "getDivergenceCap",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "trader",
                "type": "address"
            }
        ],
        "name": "getFreeCollateral",
        "outputs": [
            {
                "internalType": "int256",
                "name": "",
                "type": "int256"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            }
        ],
        "name": "getLimitOrder",
        "outputs": [
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "enum Side",
                        "name": "side",
                        "type": "uint8"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteAmount",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "leverage",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "reduceOnly",
                        "type": "bool"
                    }
                ],
                "internalType": "struct LimitOrder",
                "name": "",
                "type": "tuple"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "getMinOrderbookMargin",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            }
        ],
        "name": "getOpenInterestNotional",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "trader",
                "type": "address"
            }
        ],
        "name": "getPosition",
        "outputs": [
            {
                "components": [
                    {
                        "internalType": "int256",
                        "name": "size",
                        "type": "int256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "margin",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "openNotional",
                        "type": "uint256"
                    },
                    {
                        "internalType": "int256",
                        "name": "lastPremiumFraction",
                        "type": "int256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "blockNumber",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct Position",
                "name": "",
                "type": "tuple"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "trader",
                "type": "address"
            }
        ],
        "name": "getPositionNotionalUpnl",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "positionNotional",
                "type": "uint256"
            },
            {
                "internalType": "int256",
                "name": "upnl",
                "type": "int256"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "trader",
                "type": "address"
            },
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            }
        ],
        "name": "getReduceOnlyOrders",
        "outputs": [
            {
                "internalType": "uint256[]",
                "name": "",
                "type": "uint256[]"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            }
        ],
        "name": "getTotalPositionSize",
        "outputs": [
            {
                "components": [
                    {
                        "internalType": "int256",
                        "name": "netPositionSize",
                        "type": "int256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "positionSizeLong",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "positionSizeShort",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct TotalPositionSize",
                "name": "",
                "type": "tuple"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            }
        ],
        "name": "getTriggerOrder",
        "outputs": [
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "size",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteLimit",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "takeProfit",
                        "type": "bool"
                    }
                ],
                "internalType": "struct TriggerOrder",
                "name": "",
                "type": "tuple"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "trader",
                "type": "address"
            },
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            }
        ],
        "name": "getTriggerOrders",
        "outputs": [
            {
                "internalType": "uint256[]",
                "name": "",
                "type": "uint256[]"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            }
        ],
        "name": "getValidAMM",
        "outputs": [
            {
                "internalType": "bool",
                "name": "",
                "type": "bool"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "_owner",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "_divergenceCap",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "_minOrderbookMargin",
                "type": "uint256"
            }
        ],
        "name": "initialize",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "isActive",
        "outputs": [
            {
                "internalType": "bool",
                "name": "",
                "type": "bool"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "trader",
                "type": "address"
            }
        ],
        "name": "isLiquidatable",
        "outputs": [
            {
                "internalType": "bool",
                "name": "",
                "type": "bool"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            }
        ],
        "name": "isTriggerOrderValid",
        "outputs": [
            {
                "internalType": "bool",
                "name": "",
                "type": "bool"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "size",
                "type": "uint256"
            },
            {
                "internalType": "address",
                "name": "liquidatee",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "margin",
                "type": "uint256"
            }
        ],
        "name": "liquidate",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "liquidatee",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "margin",
                "type": "uint256"
            }
        ],
        "name": "liquidateMaker",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "enum Side",
                "name": "side",
                "type": "uint8"
            },
            {
                "internalType": "uint256",
                "name": "quote",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "leverage",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "baseLimit",
                "type": "uint256"
            }
        ],
        "name": "openPosition",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "baseAmount",
                "type": "uint256"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "owner",
        "outputs": [
            {
                "internalType": "address",
                "name": "result",
                "type": "address"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "pendingOwner",
                "type": "address"
            }
        ],
        "name": "ownershipHandoverExpiresAt",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "result",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "components": [
                    {
                        "internalType": "uint256",
                        "name": "index",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "shares",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct LiquidityRemoveData[]",
                "name": "data",
                "type": "tuple[]"
            },
            {
                "internalType": "uint256",
                "name": "addedMargin",
                "type": "uint256"
            }
        ],
        "name": "removeLiquidity",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "margin",
                "type": "uint256"
            }
        ],
        "name": "removeMargin",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "renounceOwnership",
        "outputs": [],
        "stateMutability": "payable",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "requestOwnershipHandover",
        "outputs": [],
        "stateMutability": "payable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "bool",
                "name": "_active",
                "type": "bool"
            }
        ],
        "name": "setActive",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "_divergenceCap",
                "type": "uint256"
            }
        ],
        "name": "setDivergenceCap",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "minMargin",
                "type": "uint256"
            }
        ],
        "name": "setMinOrderbookMargin",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            },
            {
                "internalType": "bool",
                "name": "valid",
                "type": "bool"
            }
        ],
        "name": "setValidAMM",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "contract IRouter",
                "name": "amm",
                "type": "address"
            }
        ],
        "name": "settleFunding",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "newOwner",
                "type": "address"
            }
        ],
        "name": "transferOwnership",
        "outputs": [],
        "stateMutability": "payable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            },
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "enum Side",
                        "name": "side",
                        "type": "uint8"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteAmount",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "leverage",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "reduceOnly",
                        "type": "bool"
                    }
                ],
                "internalType": "struct LimitOrder",
                "name": "order",
                "type": "tuple"
            }
        ],
        "name": "updateLimitOrder",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256[]",
                "name": "ids",
                "type": "uint256[]"
            },
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "enum Side",
                        "name": "side",
                        "type": "uint8"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteAmount",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "leverage",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "reduceOnly",
                        "type": "bool"
                    }
                ],
                "internalType": "struct LimitOrder[]",
                "name": "_orders",
                "type": "tuple[]"
            }
        ],
        "name": "updateLimitOrderBatch",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "id",
                "type": "uint256"
            },
            {
                "components": [
                    {
                        "internalType": "address",
                        "name": "trader",
                        "type": "address"
                    },
                    {
                        "internalType": "contract IRouter",
                        "name": "amm",
                        "type": "address"
                    },
                    {
                        "internalType": "uint256",
                        "name": "trigger",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "size",
                        "type": "uint256"
                    },
                    {
                        "internalType": "uint256",
                        "name": "quoteLimit",
                        "type": "uint256"
                    },
                    {
                        "internalType": "bool",
                        "name": "takeProfit",
                        "type": "bool"
                    }
                ],
                "internalType": "struct TriggerOrder",
                "name": "order",
                "type": "tuple"
            }
        ],
        "name": "updateTriggerOrder",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    }
]
