{"version":3,"file":"index.mjs","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TransactionArgument, TransactionObjectArgument } from '@mysten/sui/transactions';\n\n// SPDX-License-Identifier: Apache-2.0\nexport interface BalanceManager {\n\taddress: string;\n\ttradeCap?: string;\n\tdepositCap?: string;\n\twithdrawCap?: string;\n}\n\nexport interface MarginManager {\n\taddress: string;\n\tpoolKey: string;\n}\n\nexport interface Coin {\n\taddress: string;\n\ttype: string;\n\tscalar: number;\n\tfeed?: string;\n\tcurrencyId?: string;\n\tpriceInfoObjectId?: string;\n}\n\n/** State objects identifying the Pyth deployment margin prices against. */\nexport interface PythConfig {\n\tpythStateId: string;\n\twormholeStateId: string;\n\t/** Hermes endpoint serving update data for this deployment. */\n\thermesEndpoint?: string;\n\t/**\n\t * Bearer token for the Hermes endpoint. The one serving Pyth's upgraded Core answers\n\t * 401 without it, so pushing price updates needs this set.\n\t *\n\t * Prefer the client-level `pythAccessToken` option, which sets this without having to\n\t * restate the state object ids. Supply the token at runtime — do not commit it.\n\t */\n\taccessToken?: string;\n}\n\nexport interface Pool {\n\taddress: string;\n\tbaseCoin: string;\n\tquoteCoin: string;\n}\n\nexport interface MarginPool {\n\taddress: string;\n\ttype: string;\n}\n\n// Trading constants\nexport enum OrderType {\n\tNO_RESTRICTION,\n\tIMMEDIATE_OR_CANCEL,\n\tFILL_OR_KILL,\n\tPOST_ONLY,\n}\n\n// Self matching options\nexport enum SelfMatchingOptions {\n\tSELF_MATCHING_ALLOWED,\n\tCANCEL_TAKER,\n\tCANCEL_MAKER,\n}\n\nexport interface PlaceLimitOrderParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\tclientOrderId: string;\n\tprice: number | bigint;\n\tquantity: number | bigint;\n\tisBid: boolean;\n\texpiration?: number | bigint;\n\torderType?: OrderType;\n\tselfMatchingOption?: SelfMatchingOptions;\n\tpayWithDeep?: boolean;\n}\n\nexport interface PlaceMarketOrderParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\tclientOrderId: string;\n\tquantity: number | bigint;\n\tisBid: boolean;\n\tselfMatchingOption?: SelfMatchingOptions;\n\tpayWithDeep?: boolean;\n}\n\nexport interface CanPlaceLimitOrderParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\tprice: number | bigint;\n\tquantity: number | bigint;\n\tisBid: boolean;\n\tpayWithDeep: boolean;\n\texpireTimestamp: number;\n}\n\nexport interface CanPlaceMarketOrderParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\tquantity: number | bigint;\n\tisBid: boolean;\n\tpayWithDeep: boolean;\n}\n\nexport interface PlaceMarginLimitOrderParams {\n\tpoolKey: string;\n\tmarginManagerKey: string;\n\tclientOrderId: string;\n\tprice: number | bigint;\n\tquantity: number | bigint;\n\tisBid: boolean;\n\texpiration?: number | bigint;\n\torderType?: OrderType;\n\tselfMatchingOption?: SelfMatchingOptions;\n\tpayWithDeep?: boolean;\n}\n\nexport interface PlaceMarginMarketOrderParams {\n\tpoolKey: string;\n\tmarginManagerKey: string;\n\tclientOrderId: string;\n\tquantity: number | bigint;\n\tisBid: boolean;\n\tselfMatchingOption?: SelfMatchingOptions;\n\tpayWithDeep?: boolean;\n}\n\nexport interface PendingLimitOrderParams {\n\tclientOrderId: string;\n\torderType?: OrderType;\n\tselfMatchingOption?: SelfMatchingOptions;\n\tprice: number | bigint;\n\tquantity: number | bigint;\n\tisBid: boolean;\n\tpayWithDeep?: boolean;\n\texpireTimestamp?: number | bigint;\n}\n\nexport interface PendingMarketOrderParams {\n\tclientOrderId: string;\n\tselfMatchingOption?: SelfMatchingOptions;\n\tquantity: number | bigint;\n\tisBid: boolean;\n\tpayWithDeep?: boolean;\n}\n\nexport interface AddConditionalOrderParams {\n\tmarginManagerKey: string;\n\tconditionalOrderId: string;\n\ttriggerBelowPrice: boolean;\n\ttriggerPrice: number | bigint;\n\tpendingOrder: PendingLimitOrderParams | PendingMarketOrderParams;\n}\n\nexport interface ProposalParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\ttakerFee: number | bigint;\n\tmakerFee: number | bigint;\n\tstakeRequired: number | bigint;\n}\n\nexport interface MarginProposalParams {\n\ttakerFee: number | bigint;\n\tmakerFee: number | bigint;\n\tstakeRequired: number | bigint;\n}\n\nexport interface SwapParams {\n\tpoolKey: string;\n\tamount: number | bigint;\n\tdeepAmount: number | bigint;\n\tminOut: number | bigint;\n\tdeepCoin?: TransactionObjectArgument;\n\tbaseCoin?: TransactionObjectArgument;\n\tquoteCoin?: TransactionObjectArgument;\n}\n\nexport interface SwapWithManagerParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\ttradeCap: string;\n\tdepositCap: string;\n\twithdrawCap: string;\n\tamount: number | bigint;\n\tminOut: number | bigint;\n\tbaseCoin?: TransactionObjectArgument;\n\tquoteCoin?: TransactionObjectArgument;\n}\n\nexport interface StakeParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\tamount: number | bigint;\n}\n\nexport interface VoteParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\tproposalId: string;\n}\n\nexport interface FlashLoanParams {\n\tpoolKey: string;\n\tamount: number | bigint;\n}\n\nexport interface CreatePoolAdminParams {\n\tbaseCoinKey: string;\n\tquoteCoinKey: string;\n\ttickSize: number | bigint;\n\tlotSize: number | bigint;\n\tminSize: number | bigint;\n\twhitelisted: boolean;\n\tstablePool: boolean;\n}\n\nexport interface CreatePermissionlessPoolParams {\n\tbaseCoinKey: string;\n\tquoteCoinKey: string;\n\ttickSize: number | bigint;\n\tlotSize: number | bigint;\n\tminSize: number | bigint;\n\tdeepCoin?: TransactionObjectArgument;\n}\n\nexport interface SetEwmaParams {\n\talpha: number | bigint;\n\tzScoreThreshold: number | bigint;\n\tadditionalTakerFee: number | bigint;\n}\n\nexport interface PoolConfigParams {\n\tminWithdrawRiskRatio: number | bigint;\n\tminBorrowRiskRatio: number | bigint;\n\tliquidationRiskRatio: number | bigint;\n\ttargetLiquidationRiskRatio: number | bigint;\n\tuserLiquidationReward: number | bigint;\n\tpoolLiquidationReward: number | bigint;\n}\n\nexport interface MarginPoolConfigParams {\n\tsupplyCap: number | bigint;\n\tmaxUtilizationRate: number | bigint;\n\tprotocolSpread: number | bigint;\n\tminBorrow: number | bigint;\n\trateLimitCapacity?: number | bigint;\n\trateLimitRefillRatePerMs?: number | bigint;\n\trateLimitEnabled?: boolean;\n}\n\nexport interface InterestConfigParams {\n\tbaseRate: number | bigint;\n\tbaseSlope: number | bigint;\n\toptimalUtilization: number | bigint;\n\texcessSlope: number | bigint;\n}\n\nexport interface Config {\n\tDEEPBOOK_PACKAGE_ID: string;\n\tREGISTRY_ID: string;\n\tDEEP_TREASURY_ID: string;\n}\n\n// === Named Return Types ===\n\n// Balance\nexport interface ManagerBalance {\n\tcoinType: string;\n\tbalance: number;\n}\nexport interface VaultBalances {\n\tbase: number;\n\tquote: number;\n\tdeep: number;\n}\nexport interface LockedBalances {\n\tbase: number;\n\tquote: number;\n\tdeep: number;\n}\nexport interface ReferralBalances {\n\tbase: number;\n\tquote: number;\n\tdeep: number;\n}\n\n// Pool\nexport interface PoolTradeParams {\n\ttakerFee: number;\n\tmakerFee: number;\n\tstakeRequired: number;\n}\nexport interface PoolBookParams {\n\ttickSize: number;\n\tlotSize: number;\n\tminSize: number;\n}\nexport type PoolDeepPrice =\n\t{ asset_is_base: true; deep_per_base: number } | { asset_is_base: false; deep_per_quote: number };\n\n// Quantity calculations\nexport interface QuoteQuantityOut {\n\tbaseQuantity: number;\n\tbaseOut: number;\n\tquoteOut: number;\n\tdeepRequired: number;\n}\nexport interface BaseQuantityOut {\n\tquoteQuantity: number;\n\tbaseOut: number;\n\tquoteOut: number;\n\tdeepRequired: number;\n}\nexport interface QuantityOut {\n\tbaseQuantity: number;\n\tquoteQuantity: number;\n\tbaseOut: number;\n\tquoteOut: number;\n\tdeepRequired: number;\n}\nexport interface BaseQuantityIn {\n\tbaseIn: number;\n\tquoteOut: number;\n\tdeepRequired: number;\n}\nexport interface QuoteQuantityIn {\n\tbaseOut: number;\n\tquoteIn: number;\n\tdeepRequired: number;\n}\nexport interface OrderDeepRequiredResult {\n\tdeepRequiredTaker: number;\n\tdeepRequiredMaker: number;\n}\n\n// Order book\nexport interface Level2Range {\n\tprices: number[];\n\tquantities: number[];\n}\nexport interface Level2TicksFromMid {\n\tbid_prices: number[];\n\tbid_quantities: number[];\n\task_prices: number[];\n\task_quantities: number[];\n}\n\n// Account\nexport interface AccountBalances {\n\tbase: number;\n\tquote: number;\n\tdeep: number;\n}\nexport interface AccountInfo {\n\tepoch: string;\n\topen_orders: { contents: string[] };\n\ttaker_volume: number;\n\tmaker_volume: number;\n\tactive_stake: number;\n\tinactive_stake: number;\n\tcreated_proposal: boolean;\n\tvoted_proposal: string | null;\n\tunclaimed_rebates: AccountBalances;\n\tsettled_balances: AccountBalances;\n\towed_balances: AccountBalances;\n}\n\n// Order\nexport interface DecodedOrderId {\n\tisBid: boolean;\n\tprice: number;\n\torderId: number;\n}\n\n// Margin\nexport interface MarginManagerState {\n\tmanagerId: string;\n\tdeepbookPoolId: string;\n\triskRatio: number;\n\tbaseAsset: string;\n\tquoteAsset: string;\n\tbaseDebt: string;\n\tquoteDebt: string;\n\tbasePythPrice: string;\n\tbasePythDecimals: number;\n\tquotePythPrice: string;\n\tquotePythDecimals: number;\n\tcurrentPrice: bigint;\n\tlowestTriggerAbovePrice: bigint;\n\thighestTriggerBelowPrice: bigint;\n}\nexport interface MarginManagerAssets {\n\tbaseAsset: string;\n\tquoteAsset: string;\n}\nexport interface MarginManagerDebts {\n\tbaseDebt: string;\n\tquoteDebt: string;\n}\nexport interface MarginManagerBalancesResult {\n\tbase: string;\n\tquote: string;\n\tdeep: string;\n}\nexport interface BorrowedShares {\n\tbaseShares: string;\n\tquoteShares: string;\n}\n\n/**\n * Parameters for depositing into a margin manager.\n * Either `amount` (number) or `coin` (TransactionArgument) must be provided, but not both.\n */\nexport type DepositParams = {\n\tmanagerKey: string;\n} & ({ amount: number | bigint; coin?: never } | { amount?: never; coin: TransactionArgument });\n\n/**\n * Parameters for depositing during margin manager initialization.\n * Either (`coinType` + `amount`) or (`coinType` + `coin`) must be provided.\n * `coinType` should be a coin key from config (e.g., 'SUI', 'DBUSDC', 'DEEP').\n */\nexport type DepositDuringInitParams = {\n\tmanager: TransactionArgument;\n\tpoolKey: string;\n\tcoinType: string;\n} & ({ amount: number | bigint; coin?: never } | { amount?: never; coin: TransactionArgument });\n"],"mappings":";AAuDA,IAAY,kDAAL;AACN;AACA;AACA;AACA;;;AAID,IAAY,sEAAL;AACN;AACA;AACA"}