[
  {
    "name": "facets",
    "type": "function",
    "stateMutability": "pure",
    "inputs": [],
    "outputs": [
      {
        "type": "tuple[]",
        "components": [
          {
            "type": "address",
            "name": "facetAddress"
          },
          {
            "type": "bytes4[]",
            "name": "functionSelectors"
          }
        ]
      }
    ]
  },
  {
    "name": "facetFunctionSelectors",
    "type": "function",
    "stateMutability": "pure",
    "inputs": [
      {
        "type": "address",
        "name": "facet"
      }
    ],
    "outputs": [
      {
        "type": "bytes4[]",
        "name": "functionSelectors"
      }
    ]
  },
  {
    "name": "facetAddresses",
    "type": "function",
    "stateMutability": "pure",
    "inputs": [],
    "outputs": [
      {
        "type": "address[]",
        "name": "addresses"
      }
    ]
  },
  {
    "name": "facetAddress",
    "type": "function",
    "stateMutability": "pure",
    "inputs": [
      {
        "type": "bytes4",
        "name": "functionSelector"
      }
    ],
    "outputs": [
      {
        "type": "address"
      }
    ]
  },
  {
    "name": "emitDiamondCutEvent",
    "type": "function",
    "stateMutability": "nonpayable",
    "inputs": [],
    "outputs": [
      {
        "type": "bool"
      }
    ]
  },
  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "which",
        "type": "bytes32"
      }
    ],
    "name": "FeatureUnavailable",
    "type": "error"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      }
    ],
    "name": "InvalidAccountId",
    "type": "error"
  },
  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      }
    ],
    "name": "InvalidPermission",
    "type": "error"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "origin",
        "type": "address"
      }
    ],
    "name": "OnlyAccountTokenProxy",
    "type": "error"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      },
      {
        "internalType": "address",
        "name": "target",
        "type": "address"
      }
    ],
    "name": "PermissionDenied",
    "type": "error"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      },
      {
        "internalType": "address",
        "name": "user",
        "type": "address"
      }
    ],
    "name": "PermissionNotGranted",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "PositionOutOfBounds",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "ValueAlreadyInSet",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "ValueNotInSet",
    "type": "error"
  },
  {
    "inputs": [],
    "name": "ZeroAddress",
    "type": "error"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "owner",
        "type": "address"
      }
    ],
    "name": "AccountCreated",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "indexed": true,
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "user",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "sender",
        "type": "address"
      }
    ],
    "name": "PermissionGranted",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "indexed": true,
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      },
      {
        "indexed": true,
        "internalType": "address",
        "name": "user",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "sender",
        "type": "address"
      }
    ],
    "name": "PermissionRevoked",
    "type": "event"
  },
  {
    "inputs": [],
    "name": "createAccount",
    "outputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "requestedAccountId",
        "type": "uint128"
      }
    ],
    "name": "createAccount",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      }
    ],
    "name": "getAccountLastInteraction",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      }
    ],
    "name": "getAccountOwner",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      }
    ],
    "name": "getAccountPermissions",
    "outputs": [
      {
        "components": [
          {
            "internalType": "address",
            "name": "user",
            "type": "address"
          },
          {
            "internalType": "bytes32[]",
            "name": "permissions",
            "type": "bytes32[]"
          }
        ],
        "internalType": "struct IAccountModule.AccountPermissions[]",
        "name": "accountPerms",
        "type": "tuple[]"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "getAccountTokenAddress",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      },
      {
        "internalType": "address",
        "name": "user",
        "type": "address"
      }
    ],
    "name": "grantPermission",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      },
      {
        "internalType": "address",
        "name": "user",
        "type": "address"
      }
    ],
    "name": "hasPermission",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      },
      {
        "internalType": "address",
        "name": "user",
        "type": "address"
      }
    ],
    "name": "isAuthorized",
    "outputs": [
      {
        "internalType": "bool",
        "name": "",
        "type": "bool"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "to",
        "type": "address"
      },
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      }
    ],
    "name": "notifyAccountTransfer",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      }
    ],
    "name": "renouncePermission",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint128",
        "name": "accountId",
        "type": "uint128"
      },
      {
        "internalType": "bytes32",
        "name": "permission",
        "type": "bytes32"
      },
      {
        "internalType": "address",
        "name": "user",
        "type": "address"
      }
    ],
    "name": "revokePermission",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "expected",
        "type": "bytes32"
      },
      {
        "internalType": "bytes32",
        "name": "actual",
        "type": "bytes32"
      }
    ],
    "name": "MismatchAssociatedSystemKind",
    "type": "error"
  },
  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "id",
        "type": "bytes32"
      }
    ],
    "name": "MissingAssociatedSystem",
    "type": "error"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "addr",
        "type": "address"
      }
    ],
    "name": "Unauthorized",
    "type": "error"
  },
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "bytes32",
        "name": "kind",
        "type": "bytes32"
      },
      {
        "indexed": true,
        "internalType": "bytes32",
        "name": "id",
        "type": "bytes32"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "proxy",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "impl",
        "type": "address"
      }
    ],
    "name": "AssociatedSystemSet",
    "type": "event"
  },
  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "id",
        "type": "bytes32"
      }
    ],
    "name": "getAssociatedSystem",
    "outputs": [
      {
        "internalType": "address",
        "name": "addr",
        "type": "address"
      },
      {
        "internalType": "bytes32",
        "name": "kind",
        "type": "bytes32"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "id",
        "type": "bytes32"
      },
      {
        "internalType": "string",
        "name": "name",
        "type": "string"
      },
      {
        "internalType": "string",
        "name": "symbol",
        "type": "string"
      },
      {
        "internalType": "string",
        "name": "uri",
        "type": "string"
      },
      {
        "internalType": "address",
        "name": "impl",
        "type": "address"
      }
    ],
    "name": "initOrUpgradeNft",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "id",
        "type": "bytes32"
      },
      {
        "internalType": "string",
        "name": "name",
        "type": "string"
      },
      {
        "internalType": "string",
        "name": "symbol",
        "type": "string"
      },
      {
        "internalType": "uint8",
        "name": "decimals",
        "type": "uint8"
      },
      {
        "internalType": "address",
        "name": "impl",
        "type": "address"
      }
    ],
    "name": "initOrUpgradeToken",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "id",
        "type": "bytes32"
      },
      {
        "internalType": "address",
        "name": "endpoint",
        "type": "address"
      }
    ],
    "name": "registerUnmanagedSystem",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "type": "function",
    "name": "acceptOwnership",
    "inputs": [],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "getImplementation",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "nominateNewOwner",
    "inputs": [
      {
        "name": "newNominatedOwner",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "nominatedOwner",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "owner",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "renounceNomination",
    "inputs": [],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "simulateUpgradeTo",
    "inputs": [
      {
        "name": "newImplementation",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "supportsInterface",
    "inputs": [
      {
        "name": "interfaceId",
        "type": "bytes4",
        "internalType": "bytes4"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "upgradeTo",
    "inputs": [
      {
        "name": "newImplementation",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "event",
    "name": "OwnerChanged",
    "inputs": [
      {
        "name": "oldOwner",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      },
      {
        "name": "newOwner",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "OwnerNominated",
    "inputs": [
      {
        "name": "newOwner",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "Upgraded",
    "inputs": [
      {
        "name": "self",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      },
      {
        "name": "implementation",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "error",
    "name": "ImplementationIsSterile",
    "inputs": [
      {
        "name": "implementation",
        "type": "address",
        "internalType": "address"
      }
    ]
  },
  {
    "type": "error",
    "name": "NoChange",
    "inputs": []
  },
  {
    "type": "error",
    "name": "NotAContract",
    "inputs": [
      {
        "name": "contr",
        "type": "address",
        "internalType": "address"
      }
    ]
  },
  {
    "type": "error",
    "name": "NotNominated",
    "inputs": [
      {
        "name": "addr",
        "type": "address",
        "internalType": "address"
      }
    ]
  },
  {
    "type": "error",
    "name": "UpgradeSimulationFailed",
    "inputs": []
  },
  {
    "type": "constructor",
    "inputs": [
      {
        "name": "_synthetix",
        "type": "address",
        "internalType": "contract ISynthetixSystem"
      },
      {
        "name": "_accountProxyAddress",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "_spotMarket",
        "type": "address",
        "internalType": "contract ISpotMarketSystem"
      },
      {
        "name": "_oracle",
        "type": "address",
        "internalType": "contract INodeModule"
      },
      {
        "name": "_usdToken",
        "type": "address",
        "internalType": "contract ITokenModule"
      },
      {
        "name": "_name",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "_perpsMarketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "accountProxy",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "contract IERC721"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "createMarket",
    "inputs": [
      {
        "name": "requestedMarketId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "marketName",
        "type": "string",
        "internalType": "string"
      },
      {
        "name": "marketSymbol",
        "type": "string",
        "internalType": "string"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "depositMarketCollateral",
    "inputs": [
      {
        "name": "collateral",
        "type": "address",
        "internalType": "contract ITokenModule"
      },
      {
        "name": "amount",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "generalName",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "bytes32",
        "internalType": "bytes32"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "interestRate",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "minimumCredit",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "name",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "string",
        "internalType": "string"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "oracle",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "contract INodeModule"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "perpsMarketId",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "reportedDebt",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "spotMarket",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "contract ISpotMarketSystem"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "synthetix",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "contract ISynthetixSystem"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "totalWithdrawableUsd",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "usdToken",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "contract ITokenModule"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "utilizationRate",
    "inputs": [],
    "outputs": [
      {
        "name": "rate",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "delegatedCollateral",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "lockedCredit",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "withdrawMarketUsd",
    "inputs": [
      {
        "name": "to",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "amount",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "event",
    "name": "FactoryInitialized",
    "inputs": [
      {
        "name": "globalPerpsMarketId",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "MarketCreated",
    "inputs": [
      {
        "name": "perpsMarketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "marketName",
        "type": "string",
        "indexed": false,
        "internalType": "string"
      },
      {
        "name": "marketSymbol",
        "type": "string",
        "indexed": false,
        "internalType": "string"
      }
    ],
    "anonymous": false
  },
  {
    "type": "error",
    "name": "InvalidMarket",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "error",
    "name": "InvalidParameter",
    "inputs": [
      {
        "name": "parameter",
        "type": "string",
        "internalType": "string"
      },
      {
        "name": "reason",
        "type": "string",
        "internalType": "string"
      }
    ]
  },
  {
    "type": "error",
    "name": "OverflowInt256ToUint256",
    "inputs": []
  },
  {
    "type": "error",
    "name": "OverflowUint256ToInt256",
    "inputs": []
  },
  {
    "type": "error",
    "name": "OverflowUint256ToUint128",
    "inputs": []
  },
  {
    "type": "error",
    "name": "PerpsMarketAlreadyInitialized",
    "inputs": []
  },
  {
    "type": "error",
    "name": "PerpsMarketNotInitialized",
    "inputs": []
  },
  {
    "type": "constructor",
    "inputs": [
      {
        "name": "_globalContext",
        "type": "address",
        "internalType": "contract GlobalContext"
      }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "debt",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "accountDebt",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "depositCollateral",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "amount",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "getAccountAllCollateralAmounts",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "collateralIds",
        "type": "uint256[]",
        "internalType": "uint256[]"
      },
      {
        "name": "collateralAmounts",
        "type": "uint256[]",
        "internalType": "uint256[]"
      },
      {
        "name": "accountDebt",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getAccountCollateralIds",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256[]",
        "internalType": "uint256[]"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getAccountFullPositionInfo",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "detailedPositions",
        "type": "tuple[]",
        "internalType": "struct IPerpsAccountModule.DetailedPosition[]",
        "components": [
          {
            "name": "marketId",
            "type": "uint128",
            "internalType": "uint128"
          },
          {
            "name": "size",
            "type": "int256",
            "internalType": "int256"
          },
          {
            "name": "pnl",
            "type": "int256",
            "internalType": "int256"
          },
          {
            "name": "accruedFunding",
            "type": "int256",
            "internalType": "int256"
          },
          {
            "name": "chargedInterest",
            "type": "uint256",
            "internalType": "uint256"
          },
          {
            "name": "currentPrice",
            "type": "uint256",
            "internalType": "uint256"
          },
          {
            "name": "entryPrice",
            "type": "uint256",
            "internalType": "uint256"
          },
          {
            "name": "requiredInitialMargin",
            "type": "uint256",
            "internalType": "uint256"
          },
          {
            "name": "requiredMaintenanceMargin",
            "type": "uint256",
            "internalType": "uint256"
          },
          {
            "name": "marketName",
            "type": "string",
            "internalType": "string"
          },
          {
            "name": "marketSymbol",
            "type": "string",
            "internalType": "string"
          }
        ]
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getAccountOpenPositions",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256[]",
        "internalType": "uint256[]"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getAvailableMargin",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "availableMargin",
        "type": "int256",
        "internalType": "int256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getCollateralAmount",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getOpenPosition",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "totalPnl",
        "type": "int256",
        "internalType": "int256"
      },
      {
        "name": "positionSize",
        "type": "int128",
        "internalType": "int128"
      },
      {
        "name": "owedInterest",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getOpenPositionSize",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "positionSize",
        "type": "int128",
        "internalType": "int128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getRequiredMargins",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "requiredInitialMargin",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "requiredMaintenanceMargin",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "maxLiquidationReward",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getWithdrawableMargin",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "withdrawableMargin",
        "type": "int256",
        "internalType": "int256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "modifyCollateral",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "amountDelta",
        "type": "int256",
        "internalType": "int256"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "payDebt",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "amount",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "totalAccountOpenInterest",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "totalCollateralValue",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "totalValue",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "event",
    "name": "CollateralDeposited",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "collateralId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "amountDeposited",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "totalAmount",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "sender",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "CollateralModified",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "collateralId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "amountDelta",
        "type": "int256",
        "indexed": false,
        "internalType": "int256"
      },
      {
        "name": "sender",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "DebtPaid",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "amount",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "sender",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "InterestRateUpdated",
    "inputs": [
      {
        "name": "superMarketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "interestRate",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      }
    ],
    "anonymous": false
  },
  {
    "type": "error",
    "name": "AccountLiquidatable",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "error",
    "name": "AccountNotFound",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "error",
    "name": "InsufficientCollateral",
    "inputs": [
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "collateralAmount",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "withdrawAmount",
        "type": "uint256",
        "internalType": "uint256"
      }
    ]
  },
  {
    "type": "error",
    "name": "InsufficientCollateralAvailableForWithdraw",
    "inputs": [
      {
        "name": "withdrawableMarginUsd",
        "type": "int256",
        "internalType": "int256"
      },
      {
        "name": "requestedMarginUsd",
        "type": "uint256",
        "internalType": "uint256"
      }
    ]
  },
  {
    "type": "error",
    "name": "InsufficientSynthCollateral",
    "inputs": [
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "collateralAmount",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "withdrawAmount",
        "type": "uint256",
        "internalType": "uint256"
      }
    ]
  },
  {
    "type": "error",
    "name": "InvalidDistributor",
    "inputs": [
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "error",
    "name": "MaxCollateralExceeded",
    "inputs": [
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "maxAmount",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "collateralAmount",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "depositAmount",
        "type": "uint256",
        "internalType": "uint256"
      }
    ]
  },
  {
    "type": "error",
    "name": "MaxCollateralsPerAccountReached",
    "inputs": [
      {
        "name": "maxCollateralsPerAccount",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "error",
    "name": "NonexistentDebt",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "error",
    "name": "OverflowUint128ToInt128",
    "inputs": []
  },
  {
    "type": "error",
    "name": "SizeDeltaIsZero",
    "inputs": []
  },
  {
    "type": "error",
    "name": "SynthNotEnabledForCollateral",
    "inputs": [
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "function",
    "name": "getAccountOwnerV4",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getAccountPermissionsV4",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "accountPerms",
        "type": "address[]",
        "internalType": "address[]"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "grantPermissionV4",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "permission",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "user",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "hasPermissionV4",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "permission",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "user",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "isAuthorizedV4",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "permission",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "target",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "revokePermissionV4",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "permission",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "user",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "event",
    "name": "PermissionGrantedV4",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "permission",
        "type": "bytes32",
        "indexed": true,
        "internalType": "bytes32"
      },
      {
        "name": "user",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      },
      {
        "name": "sender",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "PermissionRevokedV4",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "permission",
        "type": "bytes32",
        "indexed": true,
        "internalType": "bytes32"
      },
      {
        "name": "user",
        "type": "address",
        "indexed": true,
        "internalType": "address"
      },
      {
        "name": "sender",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "error",
    "name": "Unauthorized",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "permission",
        "type": "bytes32",
        "internalType": "bytes32"
      }
    ]
  },
  {
    "type": "function",
    "name": "currentFundingRate",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "int256",
        "internalType": "int256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "fillPrice",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "orderSize",
        "type": "int128",
        "internalType": "int128"
      },
      {
        "name": "price",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getMarketSummary",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "summary",
        "type": "tuple",
        "internalType": "struct IPerpsMarketModule.MarketSummary",
        "components": [
          {
            "name": "size",
            "type": "uint256",
            "internalType": "uint256"
          },
          {
            "name": "maxOpenInterest",
            "type": "uint256",
            "internalType": "uint256"
          },
          {
            "name": "currentFundingRate",
            "type": "int256",
            "internalType": "int256"
          },
          {
            "name": "indexPrice",
            "type": "uint256",
            "internalType": "uint256"
          }
        ]
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "indexPrice",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maxOpenInterest",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "metadata",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "name",
        "type": "string",
        "internalType": "string"
      },
      {
        "name": "symbol",
        "type": "string",
        "internalType": "string"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "size",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "constructor",
    "inputs": [
      {
        "name": "_globalContext",
        "type": "address",
        "internalType": "contract GlobalContext"
      },
      {
        "name": "name",
        "type": "string",
        "internalType": "string"
      },
      {
        "name": "version",
        "type": "string",
        "internalType": "string"
      }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "SIGNED_BOOK_ORDER_TYPEHASH",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "bytes32",
        "internalType": "bytes32"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "eip712Domain",
    "inputs": [],
    "outputs": [
      {
        "name": "fields",
        "type": "bytes1",
        "internalType": "bytes1"
      },
      {
        "name": "name",
        "type": "string",
        "internalType": "string"
      },
      {
        "name": "version",
        "type": "string",
        "internalType": "string"
      },
      {
        "name": "chainId",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "verifyingContract",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "salt",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "extensions",
        "type": "uint256[]",
        "internalType": "uint256[]"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "settleBookOrders",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "orders",
        "type": "tuple[]",
        "internalType": "struct IBookOrderModule.BookOrder[]",
        "components": [
          {
            "name": "signedOrder",
            "type": "tuple",
            "internalType": "struct IBookOrderModule.SignedBookOrder",
            "components": [
              {
                "name": "symbol",
                "type": "bytes32",
                "internalType": "bytes32"
              },
              {
                "name": "accountId",
                "type": "uint128",
                "internalType": "uint128"
              },
              {
                "name": "sizeDelta",
                "type": "int128",
                "internalType": "int128"
              },
              {
                "name": "orderPrice",
                "type": "uint128",
                "internalType": "uint128"
              },
              {
                "name": "expiration",
                "type": "uint64",
                "internalType": "uint64"
              },
              {
                "name": "nonce",
                "type": "uint64",
                "internalType": "uint64"
              }
            ]
          },
          {
            "name": "filledPrice",
            "type": "uint256",
            "internalType": "uint256"
          },
          {
            "name": "trackingCode",
            "type": "bytes32",
            "internalType": "bytes32"
          },
          {
            "name": "signature",
            "type": "bytes",
            "internalType": "bytes"
          }
        ]
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "event",
    "name": "AccountCharged",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      },
      {
        "name": "amount",
        "type": "int256",
        "indexed": false,
        "internalType": "int256"
      },
      {
        "name": "accountDebt",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "BookOrderSettled",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "orders",
        "type": "tuple[]",
        "indexed": false,
        "internalType": "struct IBookOrderModule.BookOrder[]",
        "components": [
          {
            "name": "signedOrder",
            "type": "tuple",
            "internalType": "struct IBookOrderModule.SignedBookOrder",
            "components": [
              {
                "name": "symbol",
                "type": "bytes32",
                "internalType": "bytes32"
              },
              {
                "name": "accountId",
                "type": "uint128",
                "internalType": "uint128"
              },
              {
                "name": "sizeDelta",
                "type": "int128",
                "internalType": "int128"
              },
              {
                "name": "orderPrice",
                "type": "uint128",
                "internalType": "uint128"
              },
              {
                "name": "expiration",
                "type": "uint64",
                "internalType": "uint64"
              },
              {
                "name": "nonce",
                "type": "uint64",
                "internalType": "uint64"
              }
            ]
          },
          {
            "name": "filledPrice",
            "type": "uint256",
            "internalType": "uint256"
          },
          {
            "name": "trackingCode",
            "type": "bytes32",
            "internalType": "bytes32"
          },
          {
            "name": "signature",
            "type": "bytes",
            "internalType": "bytes"
          }
        ]
      },
      {
        "name": "totalCollectedFees",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "DoneLoop",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "EIP712DomainChanged",
    "inputs": [],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "InterestCharged",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "interest",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "ItsGreater",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      },
      {
        "name": "cmpAccountId",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "MarketUpdated",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      },
      {
        "name": "price",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "size",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "sizeDelta",
        "type": "int256",
        "indexed": false,
        "internalType": "int256"
      },
      {
        "name": "currentFundingRate",
        "type": "int256",
        "indexed": false,
        "internalType": "int256"
      },
      {
        "name": "interestRate",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "OrderSettled",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "fillPrice",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "pnl",
        "type": "int256",
        "indexed": false,
        "internalType": "int256"
      },
      {
        "name": "accruedFunding",
        "type": "int256",
        "indexed": false,
        "internalType": "int256"
      },
      {
        "name": "sizeDelta",
        "type": "int128",
        "indexed": false,
        "internalType": "int128"
      },
      {
        "name": "newSize",
        "type": "int128",
        "indexed": false,
        "internalType": "int128"
      },
      {
        "name": "totalFees",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "referralFees",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "collectedFees",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "settlementReward",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "trackingCode",
        "type": "bytes32",
        "indexed": true,
        "internalType": "bytes32"
      },
      {
        "name": "settler",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "error",
    "name": "InvalidFillPrice",
    "inputs": [
      {
        "name": "sizeDelta",
        "type": "int128",
        "internalType": "int128"
      },
      {
        "name": "orderPrice",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "filledPrice",
        "type": "uint256",
        "internalType": "uint256"
      }
    ]
  },
  {
    "type": "error",
    "name": "InvalidShortString",
    "inputs": []
  },
  {
    "type": "error",
    "name": "NonceAlreadyUsed",
    "inputs": [
      {
        "name": "nonce",
        "type": "uint64",
        "internalType": "uint64"
      }
    ]
  },
  {
    "type": "error",
    "name": "OverflowInt128ToUint128",
    "inputs": []
  },
  {
    "type": "error",
    "name": "StringTooLong",
    "inputs": [
      {
        "name": "str",
        "type": "string",
        "internalType": "string"
      }
    ]
  },
  {
    "type": "function",
    "name": "addToFeatureFlagAllowlist",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "account",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "getDeniers",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "address[]",
        "internalType": "address[]"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getFeatureFlagAllowAll",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getFeatureFlagAllowlist",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "address[]",
        "internalType": "address[]"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getFeatureFlagDenyAll",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "isFeatureAllowed",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "account",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "removeFromFeatureFlagAllowlist",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "account",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "setDeniers",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "deniers",
        "type": "address[]",
        "internalType": "address[]"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "setFeatureFlagAllowAll",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "allowAll",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "setFeatureFlagDenyAll",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "internalType": "bytes32"
      },
      {
        "name": "denyAll",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "event",
    "name": "FeatureFlagAllowAllSet",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "indexed": true,
        "internalType": "bytes32"
      },
      {
        "name": "allowAll",
        "type": "bool",
        "indexed": false,
        "internalType": "bool"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "FeatureFlagAllowlistAdded",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "indexed": true,
        "internalType": "bytes32"
      },
      {
        "name": "account",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "FeatureFlagAllowlistRemoved",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "indexed": true,
        "internalType": "bytes32"
      },
      {
        "name": "account",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "FeatureFlagDeniersReset",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "indexed": true,
        "internalType": "bytes32"
      },
      {
        "name": "deniers",
        "type": "address[]",
        "indexed": false,
        "internalType": "address[]"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "FeatureFlagDenyAllSet",
    "inputs": [
      {
        "name": "feature",
        "type": "bytes32",
        "indexed": true,
        "internalType": "bytes32"
      },
      {
        "name": "denyAll",
        "type": "bool",
        "indexed": false,
        "internalType": "bool"
      }
    ],
    "anonymous": false
  },
  {
    "type": "function",
    "name": "canLiquidate",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "positionPrices",
        "type": "uint256[]",
        "internalType": "uint256[]"
      }
    ],
    "outputs": [
      {
        "name": "isEligible",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "liquidate",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "positionPrices",
        "type": "uint256[]",
        "internalType": "uint256[]"
      },
      {
        "name": "isLarge",
        "type": "bool",
        "internalType": "bool"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "event",
    "name": "AccountLiquidationAttempt",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "reward",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "fullLiquidation",
        "type": "bool",
        "indexed": false,
        "internalType": "bool"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "AccountMarginLiquidation",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "seizedMarginValue",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "liquidationReward",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "PositionLiquidated",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "amountLiquidated",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "currentPositionSize",
        "type": "int128",
        "indexed": false,
        "internalType": "int128"
      }
    ],
    "anonymous": false
  },
  {
    "type": "error",
    "name": "AccountHasOpenPositions",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "error",
    "name": "NoPositionsOpen",
    "inputs": []
  },
  {
    "type": "error",
    "name": "NotEligibleForLiquidation",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "error",
    "name": "NotEligibleForMarginLiquidation",
    "inputs": [
      {
        "name": "accountId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "constructor",
    "inputs": [
      {
        "name": "_makerFee",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_takerFee",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_maxMarketSize",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_initialMarginRatioD18",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_maintenanceMarginScalarD18",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_lockedOiRatioD18",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_maxLiquidationLimitAccumulationMultiplier",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_maxSecondsInLiquidationWindow",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_minimumPositionMargin",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_minimumInitialMarginRatioD18",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_maxLiquidationPd",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_maxMarketValue",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "calculateRequiredMargins",
    "inputs": [
      {
        "name": "size",
        "type": "int128",
        "internalType": "int128"
      },
      {
        "name": "price",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "outputs": [
      {
        "name": "initialMarginRatio",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "maintenanceMarginRatio",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "initialMargin",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "maintenanceMargin",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getLiquidationParameters",
    "inputs": [],
    "outputs": [
      {
        "name": "_initialMarginRatioD18",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_minimumInitialMarginRatioD18",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_maintenanceMarginScalarD18",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_minimumPositionMargin",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getLockedOiRatio",
    "inputs": [],
    "outputs": [
      {
        "name": "_lockedOiRatioD18",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getMaxLiquidationParameters",
    "inputs": [],
    "outputs": [
      {
        "name": "_maxLiquidationLimitAccumulationMultiplier",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_maxSecondsInLiquidationWindow",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_maxLiquidationPd",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getMaxMarketSize",
    "inputs": [],
    "outputs": [
      {
        "name": "_maxMarketSize",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getMaxMarketValue",
    "inputs": [],
    "outputs": [
      {
        "name": "_maxMarketValue",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getOrderFees",
    "inputs": [],
    "outputs": [
      {
        "name": "_makerFee",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_takerFee",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "initialMarginRatioD18",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "lockedOiRatioD18",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maintenanceMarginScalarD18",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "makerFee",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maxLiquidationAmountInWindow",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maxLiquidationLimitAccumulationMultiplier",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maxLiquidationPd",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maxMarketSize",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maxMarketValue",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maxSecondsInLiquidationWindow",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "minimumInitialMarginRatioD18",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "minimumPositionMargin",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "takerFee",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "event",
    "name": "LiquidationParametersSet",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "initialMarginRatioD18",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "maintenanceMarginRatioD18",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "minimumInitialMarginRatioD18",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "minimumPositionMargin",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "LockedOiRatioSet",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "lockedOiRatioD18",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "MarketPriceDataUpdated",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "feedId",
        "type": "bytes32",
        "indexed": false,
        "internalType": "bytes32"
      },
      {
        "name": "strictStalenessTolerance",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "MaxLiquidationParametersSet",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "maxLiquidationLimitAccumulationMultiplier",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "maxSecondsInLiquidationWindow",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "maxLiquidationPd",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "MaxMarketSizeSet",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "maxMarketSize",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "MaxMarketValueSet",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "maxMarketValue",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "OrderFeesSet",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "makerFeeRatio",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "takerFeeRatio",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "error",
    "name": "InvalidSettlementStrategy",
    "inputs": [
      {
        "name": "settlementStrategyId",
        "type": "uint256",
        "internalType": "uint256"
      }
    ]
  },
  {
    "type": "error",
    "name": "InvalidSettlementWindowDuration",
    "inputs": [
      {
        "name": "duration",
        "type": "uint256",
        "internalType": "uint256"
      }
    ]
  },
  {
    "type": "error",
    "name": "MaxOpenInterestReached",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "maxMarketSize",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "newSideSize",
        "type": "int256",
        "internalType": "int256"
      }
    ]
  },
  {
    "type": "error",
    "name": "MaxUSDOpenInterestReached",
    "inputs": [
      {
        "name": "marketId",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "maxMarketValue",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "newSideSize",
        "type": "int256",
        "internalType": "int256"
      },
      {
        "name": "price",
        "type": "uint256",
        "internalType": "uint256"
      }
    ]
  },
  {
    "type": "function",
    "name": "getCollateralConfiguration",
    "inputs": [
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "maxCollateralAmount",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getCollateralConfigurationFull",
    "inputs": [
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "maxCollateralAmount",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "upperLimitDiscount",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "lowerLimitDiscount",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "discountScalar",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getCollateralLiquidateRewardRatio",
    "inputs": [],
    "outputs": [
      {
        "name": "collateralLiquidateRewardRatioD18",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "event",
    "name": "CollateralConfigurationSet",
    "inputs": [
      {
        "name": "collateralId",
        "type": "uint128",
        "indexed": true,
        "internalType": "uint128"
      },
      {
        "name": "maxCollateralAmount",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "upperLimitDiscount",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "lowerLimitDiscount",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "discountScalar",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "CollateralLiquidateRewardRatioSet",
    "inputs": [
      {
        "name": "collateralLiquidateRewardRatioD18",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "RewardDistributorRegistered",
    "inputs": [
      {
        "name": "distributor",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "constructor",
    "inputs": [
      {
        "name": "_feeCollector",
        "type": "address",
        "internalType": "contract IFeeCollector"
      },
      {
        "name": "_maxPositionsPerAccount",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_maxCollateralsPerAccount",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_lowUtilizationInterestRateGradient",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_interestRateGradientBreakpoint",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_highUtilizationInterestRateGradient",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_collateralLiquidateRewardRatioD18",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_rewardDistributorImplementation",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "_collateralToken",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "calculateCollateralLiquidateReward",
    "inputs": [
      {
        "name": "notionalValue",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "outputs": [
      {
        "name": "",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "collateralLiquidateRewardRatioD18",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "collateralToken",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "collectFees",
    "inputs": [
      {
        "name": "orderFees",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "referrer",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "factory",
        "type": "address",
        "internalType": "contract PerpsMarketFactory"
      }
    ],
    "outputs": [
      {
        "name": "referralFees",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "feeCollectorFees",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "feeCollector",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "contract IFeeCollector"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getFeeCollector",
    "inputs": [],
    "outputs": [
      {
        "name": "_feeCollector",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getInterestRateParameters",
    "inputs": [],
    "outputs": [
      {
        "name": "_lowUtilizationInterestRateGradient",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_interestRateGradientBreakpoint",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_highUtilizationInterestRateGradient",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getMarkets",
    "inputs": [],
    "outputs": [
      {
        "name": "marketIds",
        "type": "uint256[]",
        "internalType": "uint256[]"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "getPerAccountCaps",
    "inputs": [],
    "outputs": [
      {
        "name": "maxPositionsPerAccount",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "maxCollateralsPerAccount",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "globalCollateralValue",
    "inputs": [
      {
        "name": "collateralId",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "outputs": [
      {
        "name": "collateralValue",
        "type": "uint256",
        "internalType": "uint256"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "highUtilizationInterestRateGradient",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "initializeFactory",
    "inputs": [
      {
        "name": "_marketFactory",
        "type": "address",
        "internalType": "contract PerpsMarketFactory"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "interestRateGradientBreakpoint",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "loadInterestRateParameters",
    "inputs": [],
    "outputs": [
      {
        "name": "_lowUtilizationInterestRateGradient",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_interestRateGradientBreakpoint",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "_highUtilizationInterestRateGradient",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "lowUtilizationInterestRateGradient",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "marketFactory",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "contract PerpsMarketFactory"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maxCollateralsPerAccount",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "maxPositionsPerAccount",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "uint128",
        "internalType": "uint128"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "rewardDistributorImplementation",
    "inputs": [],
    "outputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "setFeeCollector",
    "inputs": [
      {
        "name": "feeCollector",
        "type": "address",
        "internalType": "address"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "updateInterestRate",
    "inputs": [],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "event",
    "name": "FeeCollectorSet",
    "inputs": [
      {
        "name": "feeCollector",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "InterestRateParametersSet",
    "inputs": [
      {
        "name": "lowUtilizationInterestRateGradient",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "interestRateGradientBreakpoint",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      },
      {
        "name": "highUtilizationInterestRateGradient",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "KeeperCostNodeIdUpdated",
    "inputs": [
      {
        "name": "keeperCostNodeId",
        "type": "bytes32",
        "indexed": false,
        "internalType": "bytes32"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "PerAccountCapsSet",
    "inputs": [
      {
        "name": "maxPositionsPerAccount",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      },
      {
        "name": "maxCollateralsPerAccount",
        "type": "uint128",
        "indexed": false,
        "internalType": "uint128"
      }
    ],
    "anonymous": false
  },
  {
    "type": "event",
    "name": "ReferrerShareUpdated",
    "inputs": [
      {
        "name": "referrer",
        "type": "address",
        "indexed": false,
        "internalType": "address"
      },
      {
        "name": "shareRatioD18",
        "type": "uint256",
        "indexed": false,
        "internalType": "uint256"
      }
    ],
    "anonymous": false
  },
  {
    "type": "error",
    "name": "InvalidFeeCollectorInterface",
    "inputs": [
      {
        "name": "invalidFeeCollector",
        "type": "address",
        "internalType": "address"
      }
    ]
  },
  {
    "type": "error",
    "name": "InvalidInterestRateParameters",
    "inputs": [
      {
        "name": "lowUtilizationInterestRateGradient",
        "type": "uint128",
        "internalType": "uint128"
      },
      {
        "name": "highUtilizationInterestRateGradient",
        "type": "uint128",
        "internalType": "uint128"
      }
    ]
  },
  {
    "type": "error",
    "name": "InvalidReferrerShareRatio",
    "inputs": [
      {
        "name": "shareRatioD18",
        "type": "uint256",
        "internalType": "uint256"
      }
    ]
  }
]