@velocity-exchange/sdk 0.2.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/README.md +3 -3
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.js +18 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +18 -0
- package/lib/browser/accounts/bulkAccountLoader.d.ts +52 -0
- package/lib/browser/accounts/bulkAccountLoader.js +51 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +9 -2
- package/lib/browser/accounts/bulkUserStatsSubscription.js +9 -2
- package/lib/browser/accounts/bulkUserSubscription.d.ts +8 -2
- package/lib/browser/accounts/bulkUserSubscription.js +8 -2
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.js +37 -0
- package/lib/browser/accounts/fetch.d.ts +59 -2
- package/lib/browser/accounts/fetch.js +57 -2
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +30 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +30 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +118 -37
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +40 -12
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +33 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +15 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.js +15 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +15 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +34 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +34 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +19 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +21 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +22 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +32 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +22 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
- package/lib/browser/accounts/testBulkAccountLoader.d.ts +8 -0
- package/lib/browser/accounts/testBulkAccountLoader.js +8 -0
- package/lib/browser/accounts/types.d.ts +149 -0
- package/lib/browser/accounts/types.js +13 -0
- package/lib/browser/accounts/utils.d.ts +18 -0
- package/lib/browser/accounts/utils.js +32 -16
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +41 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.js +41 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +31 -23
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +36 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +26 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +33 -0
- package/lib/browser/addresses/marketAddresses.d.ts +10 -0
- package/lib/browser/addresses/marketAddresses.js +10 -0
- package/lib/browser/addresses/pda.d.ts +214 -2
- package/lib/browser/addresses/pda.js +217 -5
- package/lib/browser/adminClient.d.ts +2139 -5
- package/lib/browser/adminClient.js +2173 -11
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
- package/lib/browser/auctionSubscriber/index.d.ts +6 -0
- package/lib/browser/auctionSubscriber/index.js +6 -0
- package/lib/browser/auctionSubscriber/types.d.ts +7 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +33 -0
- package/lib/browser/blockhashSubscriber/index.d.ts +5 -0
- package/lib/browser/blockhashSubscriber/index.js +5 -0
- package/lib/browser/blockhashSubscriber/types.d.ts +5 -0
- package/lib/browser/clock/clockSubscriber.d.ts +24 -0
- package/lib/browser/clock/clockSubscriber.js +22 -0
- package/lib/browser/config.d.ts +58 -4
- package/lib/browser/config.js +88 -21
- package/lib/browser/constants/numericConstants.d.ts +67 -0
- package/lib/browser/constants/numericConstants.js +68 -1
- package/lib/browser/constants/perpMarkets.d.ts +10 -0
- package/lib/browser/constants/perpMarkets.js +40 -908
- package/lib/browser/constants/spotMarkets.d.ts +13 -0
- package/lib/browser/constants/spotMarkets.js +16 -742
- package/lib/browser/constants/txConstants.d.ts +1 -0
- package/lib/browser/constants/txConstants.js +1 -0
- package/lib/browser/core/VelocityCore.d.ts +285 -8
- package/lib/browser/core/VelocityCore.js +281 -8
- package/lib/browser/core/instructions/deposit.d.ts +22 -0
- package/lib/browser/core/instructions/deposit.js +22 -0
- package/lib/browser/core/instructions/fill.d.ts +17 -0
- package/lib/browser/core/instructions/fill.js +17 -0
- package/lib/browser/core/instructions/funding.d.ts +12 -0
- package/lib/browser/core/instructions/funding.js +12 -0
- package/lib/browser/core/instructions/liquidation.d.ts +18 -0
- package/lib/browser/core/instructions/liquidation.js +18 -0
- package/lib/browser/core/instructions/orders.d.ts +28 -0
- package/lib/browser/core/instructions/orders.js +28 -0
- package/lib/browser/core/instructions/perpOrders.d.ts +106 -0
- package/lib/browser/core/instructions/perpOrders.js +106 -0
- package/lib/browser/core/instructions/settlement.d.ts +14 -0
- package/lib/browser/core/instructions/settlement.js +14 -0
- package/lib/browser/core/instructions/trigger.d.ts +15 -0
- package/lib/browser/core/instructions/trigger.js +15 -0
- package/lib/browser/core/instructions/withdraw.d.ts +21 -0
- package/lib/browser/core/instructions/withdraw.js +21 -0
- package/lib/browser/core/remainingAccounts.d.ts +47 -3
- package/lib/browser/core/remainingAccounts.js +20 -0
- package/lib/browser/core/signedMsg.d.ts +38 -0
- package/lib/browser/core/signedMsg.js +33 -0
- package/lib/browser/decode/customCoder.d.ts +39 -3
- package/lib/browser/decode/customCoder.js +45 -3
- package/lib/browser/decode/user.d.ts +22 -0
- package/lib/browser/decode/user.js +22 -0
- package/lib/browser/dlob/DLOB.d.ts +502 -53
- package/lib/browser/dlob/DLOB.js +540 -98
- package/lib/browser/dlob/DLOBNode.d.ts +86 -4
- package/lib/browser/dlob/DLOBNode.js +37 -4
- package/lib/browser/dlob/DLOBSubscriber.d.ts +39 -12
- package/lib/browser/dlob/DLOBSubscriber.js +42 -12
- package/lib/browser/dlob/NodeList.d.ts +69 -0
- package/lib/browser/dlob/NodeList.js +66 -0
- package/lib/browser/dlob/orderBookLevels.d.ts +106 -13
- package/lib/browser/dlob/orderBookLevels.js +84 -14
- package/lib/browser/dlob/types.d.ts +15 -0
- package/lib/browser/events/eventList.d.ts +14 -0
- package/lib/browser/events/eventList.js +14 -0
- package/lib/browser/events/eventSubscriber.d.ts +87 -10
- package/lib/browser/events/eventSubscriber.js +93 -8
- package/lib/browser/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/browser/events/eventsServerLogProvider.js +27 -0
- package/lib/browser/events/fetchLogs.d.ts +31 -0
- package/lib/browser/events/fetchLogs.js +46 -1
- package/lib/browser/events/parse.d.ts +23 -0
- package/lib/browser/events/parse.js +23 -0
- package/lib/browser/events/pollingLogProvider.d.ts +24 -0
- package/lib/browser/events/pollingLogProvider.js +24 -0
- package/lib/browser/events/sort.d.ts +11 -0
- package/lib/browser/events/sort.js +12 -0
- package/lib/browser/events/txEventCache.d.ts +13 -3
- package/lib/browser/events/txEventCache.js +19 -7
- package/lib/browser/events/types.d.ts +118 -2
- package/lib/browser/events/types.js +11 -0
- package/lib/browser/events/webSocketLogProvider.d.ts +23 -0
- package/lib/browser/events/webSocketLogProvider.js +28 -0
- package/lib/browser/factory/oracleClient.js +2 -2
- package/lib/browser/idl/velocity.d.ts +50 -1
- package/lib/browser/idl/velocity.json +50 -1
- package/lib/browser/keypair.d.ts +8 -0
- package/lib/browser/keypair.js +8 -0
- package/lib/browser/marginCalculation.d.ts +134 -2
- package/lib/browser/marginCalculation.js +121 -0
- package/lib/browser/math/amm.d.ts +348 -29
- package/lib/browser/math/amm.js +310 -32
- package/lib/browser/math/auction.d.ts +95 -19
- package/lib/browser/math/auction.js +118 -28
- package/lib/browser/math/bankruptcy.d.ts +46 -0
- package/lib/browser/math/bankruptcy.js +89 -1
- package/lib/browser/math/builder.d.ts +64 -8
- package/lib/browser/math/builder.js +71 -9
- package/lib/browser/math/conversion.d.ts +21 -0
- package/lib/browser/math/conversion.js +21 -0
- package/lib/browser/math/exchangeStatus.d.ts +92 -0
- package/lib/browser/math/exchangeStatus.js +111 -1
- package/lib/browser/math/funding.d.ts +57 -20
- package/lib/browser/math/funding.js +63 -23
- package/lib/browser/math/insurance.d.ts +62 -0
- package/lib/browser/math/insurance.js +62 -0
- package/lib/browser/math/liquidation.d.ts +127 -11
- package/lib/browser/math/liquidation.js +182 -19
- package/lib/browser/math/margin.d.ts +79 -13
- package/lib/browser/math/margin.js +80 -14
- package/lib/browser/math/market.d.ts +135 -15
- package/lib/browser/math/market.js +145 -17
- package/lib/browser/math/oracles.d.ts +113 -0
- package/lib/browser/math/oracles.js +118 -1
- package/lib/browser/math/orders.d.ts +115 -7
- package/lib/browser/math/orders.js +133 -18
- package/lib/browser/math/position.d.ts +80 -33
- package/lib/browser/math/position.js +80 -33
- package/lib/browser/math/repeg.d.ts +48 -10
- package/lib/browser/math/repeg.js +48 -10
- package/lib/browser/math/spotBalance.d.ts +200 -5
- package/lib/browser/math/spotBalance.js +239 -10
- package/lib/browser/math/spotMarket.d.ts +36 -3
- package/lib/browser/math/spotMarket.js +36 -3
- package/lib/browser/math/spotPosition.d.ts +72 -0
- package/lib/browser/math/spotPosition.js +62 -0
- package/lib/browser/math/state.d.ts +31 -0
- package/lib/browser/math/state.js +32 -1
- package/lib/browser/math/superStake.d.ts +126 -2
- package/lib/browser/math/superStake.js +123 -3
- package/lib/browser/math/tiers.d.ts +29 -0
- package/lib/browser/math/tiers.js +29 -0
- package/lib/browser/math/trade.d.ts +102 -51
- package/lib/browser/math/trade.js +101 -55
- package/lib/browser/math/utils.d.ts +71 -9
- package/lib/browser/math/utils.js +71 -9
- package/lib/browser/memcmp.d.ts +94 -0
- package/lib/browser/memcmp.js +129 -7
- package/lib/browser/oracles/oracleClientCache.d.ts +16 -0
- package/lib/browser/oracles/oracleClientCache.js +16 -0
- package/lib/browser/oracles/oracleId.d.ts +31 -0
- package/lib/browser/oracles/oracleId.js +39 -8
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +20 -0
- package/lib/browser/oracles/prelaunchOracleClient.js +20 -0
- package/lib/browser/oracles/pythClient.d.ts +31 -0
- package/lib/browser/oracles/pythClient.js +32 -1
- package/lib/browser/oracles/pythLazerClient.d.ts +34 -0
- package/lib/browser/oracles/pythLazerClient.js +35 -1
- package/lib/browser/oracles/quoteAssetOracleClient.d.ts +18 -0
- package/lib/browser/oracles/quoteAssetOracleClient.js +18 -0
- package/lib/browser/oracles/strictOraclePrice.d.ts +21 -0
- package/lib/browser/oracles/strictOraclePrice.js +21 -0
- package/lib/browser/oracles/types.d.ts +45 -0
- package/lib/browser/oracles/utils.d.ts +20 -0
- package/lib/browser/oracles/utils.js +20 -0
- package/lib/browser/orderParams.d.ts +42 -4
- package/lib/browser/orderParams.js +42 -4
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +56 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.js +67 -2
- package/lib/browser/orderSubscriber/PollingSubscription.d.ts +11 -0
- package/lib/browser/orderSubscriber/PollingSubscription.js +11 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +18 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +18 -0
- package/lib/browser/orderSubscriber/grpcSubscription.d.ts +16 -0
- package/lib/browser/orderSubscriber/grpcSubscription.js +16 -0
- package/lib/browser/orderSubscriber/types.d.ts +9 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.js +1 -0
- package/lib/browser/priorityFee/averageStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/averageStrategy.js +1 -0
- package/lib/browser/priorityFee/ewmaStrategy.d.ts +10 -0
- package/lib/browser/priorityFee/ewmaStrategy.js +10 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +9 -2
- package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.js +1 -0
- package/lib/browser/priorityFee/maxStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/maxStrategy.js +1 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +39 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +39 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +21 -2
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +10 -0
- package/lib/browser/priorityFee/types.d.ts +32 -0
- package/lib/browser/priorityFee/types.js +5 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +8 -0
- package/lib/browser/slot/SlotSubscriber.d.ts +18 -0
- package/lib/browser/slot/SlotSubscriber.js +16 -0
- package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/browser/slot/SlothashSubscriber.js +25 -1
- package/lib/browser/swift/swiftOrderSubscriber.js +2 -2
- package/lib/browser/tokenFaucet.d.ts +2 -2
- package/lib/browser/tokenFaucet.js +11 -4
- package/lib/browser/tx/baseTxSender.d.ts +163 -0
- package/lib/browser/tx/baseTxSender.js +174 -6
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
- package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/browser/tx/fastSingleTxSender.d.ts +47 -0
- package/lib/browser/tx/fastSingleTxSender.js +48 -1
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +48 -0
- package/lib/browser/tx/forwardOnlyTxSender.js +48 -0
- package/lib/browser/tx/reportTransactionError.d.ts +18 -6
- package/lib/browser/tx/reportTransactionError.js +18 -6
- package/lib/browser/tx/retryTxSender.d.ts +40 -0
- package/lib/browser/tx/retryTxSender.js +39 -0
- package/lib/browser/tx/txHandler.d.ts +146 -35
- package/lib/browser/tx/txHandler.js +132 -32
- package/lib/browser/tx/txParamProcessor.d.ts +47 -0
- package/lib/browser/tx/txParamProcessor.js +47 -0
- package/lib/browser/tx/types.d.ts +46 -0
- package/lib/browser/tx/types.js +5 -0
- package/lib/browser/tx/utils.d.ts +26 -0
- package/lib/browser/tx/utils.js +26 -0
- package/lib/browser/tx/whileValidTxSender.d.ts +82 -0
- package/lib/browser/tx/whileValidTxSender.js +81 -0
- package/lib/browser/types.d.ts +786 -13
- package/lib/browser/types.js +133 -9
- package/lib/browser/user.d.ts +645 -84
- package/lib/browser/user.js +779 -96
- package/lib/browser/userMap/PollingSubscription.d.ts +10 -0
- package/lib/browser/userMap/PollingSubscription.js +14 -2
- package/lib/browser/userMap/WebsocketSubscription.d.ts +9 -0
- package/lib/browser/userMap/WebsocketSubscription.js +9 -0
- package/lib/browser/userMap/grpcSubscription.d.ts +8 -0
- package/lib/browser/userMap/grpcSubscription.js +8 -0
- package/lib/browser/userMap/referrerMap.d.ts +72 -2
- package/lib/browser/userMap/referrerMap.js +84 -2
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +37 -10
- package/lib/browser/userMap/revenueShareEscrowMap.js +38 -11
- package/lib/browser/userMap/userMap.d.ts +81 -3
- package/lib/browser/userMap/userMap.js +81 -4
- package/lib/browser/userMap/userMapConfig.d.ts +23 -0
- package/lib/browser/userMap/userStatsMap.d.ts +22 -0
- package/lib/browser/userMap/userStatsMap.js +22 -0
- package/lib/browser/userName.d.ts +16 -0
- package/lib/browser/userName.js +16 -0
- package/lib/browser/userStats.d.ts +28 -1
- package/lib/browser/userStats.js +28 -1
- package/lib/browser/util/TransactionConfirmationManager.d.ts +33 -0
- package/lib/browser/util/TransactionConfirmationManager.js +33 -0
- package/lib/browser/util/chainClock.d.ts +24 -0
- package/lib/browser/util/chainClock.js +20 -0
- package/lib/browser/util/computeUnits.d.ts +32 -0
- package/lib/browser/util/computeUnits.js +32 -0
- package/lib/browser/util/digest.d.ts +17 -0
- package/lib/browser/util/digest.js +17 -0
- package/lib/browser/util/ed25519Utils.d.ts +12 -2
- package/lib/browser/util/ed25519Utils.js +12 -2
- package/lib/browser/util/promiseTimeout.d.ts +9 -0
- package/lib/browser/util/promiseTimeout.js +9 -0
- package/lib/browser/velocityClient.d.ts +3323 -216
- package/lib/browser/velocityClient.js +3428 -249
- package/lib/browser/wallet.d.ts +37 -0
- package/lib/browser/wallet.js +37 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserAccountSubscriber.js +18 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +18 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts +52 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/bulkAccountLoader.js +51 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts +9 -2
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts.map +1 -1
- package/lib/node/accounts/bulkUserStatsSubscription.js +9 -2
- package/lib/node/accounts/bulkUserSubscription.d.ts +8 -2
- package/lib/node/accounts/bulkUserSubscription.d.ts.map +1 -1
- package/lib/node/accounts/bulkUserSubscription.js +8 -2
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.js +37 -0
- package/lib/node/accounts/fetch.d.ts +59 -2
- package/lib/node/accounts/fetch.d.ts.map +1 -1
- package/lib/node/accounts/fetch.js +57 -2
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcAccountSubscriber.js +30 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +118 -37
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +40 -12
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +33 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +15 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserAccountSubscriber.js +15 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +15 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +34 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +34 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +21 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +22 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +32 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +22 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
- package/lib/node/accounts/testBulkAccountLoader.d.ts +8 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/testBulkAccountLoader.js +8 -0
- package/lib/node/accounts/types.d.ts +149 -0
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/types.js +13 -0
- package/lib/node/accounts/utils.d.ts +18 -0
- package/lib/node/accounts/utils.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +32 -16
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +41 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +41 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +31 -23
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +36 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +26 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +33 -0
- package/lib/node/addresses/marketAddresses.d.ts +10 -0
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
- package/lib/node/addresses/marketAddresses.js +10 -0
- package/lib/node/addresses/pda.d.ts +214 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +217 -5
- package/lib/node/adminClient.d.ts +2139 -5
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +2173 -11
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
- package/lib/node/auctionSubscriber/index.d.ts +6 -0
- package/lib/node/auctionSubscriber/index.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/index.js +6 -0
- package/lib/node/auctionSubscriber/types.d.ts +7 -0
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +33 -0
- package/lib/node/blockhashSubscriber/index.d.ts +5 -0
- package/lib/node/blockhashSubscriber/index.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/index.js +5 -0
- package/lib/node/blockhashSubscriber/types.d.ts +5 -0
- package/lib/node/blockhashSubscriber/types.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.d.ts +24 -0
- package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.js +22 -0
- package/lib/node/config.d.ts +58 -4
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +88 -21
- package/lib/node/constants/numericConstants.d.ts +67 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +68 -1
- package/lib/node/constants/perpMarkets.d.ts +10 -0
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +40 -908
- package/lib/node/constants/spotMarkets.d.ts +13 -0
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +16 -742
- package/lib/node/constants/txConstants.d.ts +1 -0
- package/lib/node/constants/txConstants.d.ts.map +1 -1
- package/lib/node/constants/txConstants.js +1 -0
- package/lib/node/core/VelocityCore.d.ts +285 -8
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +281 -8
- package/lib/node/core/instructions/deposit.d.ts +22 -0
- package/lib/node/core/instructions/deposit.d.ts.map +1 -1
- package/lib/node/core/instructions/deposit.js +22 -0
- package/lib/node/core/instructions/fill.d.ts +17 -0
- package/lib/node/core/instructions/fill.d.ts.map +1 -1
- package/lib/node/core/instructions/fill.js +17 -0
- package/lib/node/core/instructions/funding.d.ts +12 -0
- package/lib/node/core/instructions/funding.d.ts.map +1 -1
- package/lib/node/core/instructions/funding.js +12 -0
- package/lib/node/core/instructions/liquidation.d.ts +18 -0
- package/lib/node/core/instructions/liquidation.d.ts.map +1 -1
- package/lib/node/core/instructions/liquidation.js +18 -0
- package/lib/node/core/instructions/orders.d.ts +28 -0
- package/lib/node/core/instructions/orders.d.ts.map +1 -1
- package/lib/node/core/instructions/orders.js +28 -0
- package/lib/node/core/instructions/perpOrders.d.ts +106 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
- package/lib/node/core/instructions/perpOrders.js +106 -0
- package/lib/node/core/instructions/settlement.d.ts +14 -0
- package/lib/node/core/instructions/settlement.d.ts.map +1 -1
- package/lib/node/core/instructions/settlement.js +14 -0
- package/lib/node/core/instructions/trigger.d.ts +15 -0
- package/lib/node/core/instructions/trigger.d.ts.map +1 -1
- package/lib/node/core/instructions/trigger.js +15 -0
- package/lib/node/core/instructions/withdraw.d.ts +21 -0
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/core/instructions/withdraw.js +21 -0
- package/lib/node/core/remainingAccounts.d.ts +47 -3
- package/lib/node/core/remainingAccounts.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.js +20 -0
- package/lib/node/core/signedMsg.d.ts +38 -0
- package/lib/node/core/signedMsg.d.ts.map +1 -1
- package/lib/node/core/signedMsg.js +33 -0
- package/lib/node/decode/customCoder.d.ts +39 -3
- package/lib/node/decode/customCoder.d.ts.map +1 -1
- package/lib/node/decode/customCoder.js +45 -3
- package/lib/node/decode/user.d.ts +22 -0
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +22 -0
- package/lib/node/dlob/DLOB.d.ts +502 -53
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +540 -98
- package/lib/node/dlob/DLOBNode.d.ts +86 -4
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +37 -4
- package/lib/node/dlob/DLOBSubscriber.d.ts +39 -12
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +42 -12
- package/lib/node/dlob/NodeList.d.ts +69 -0
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.js +66 -0
- package/lib/node/dlob/orderBookLevels.d.ts +106 -13
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +84 -14
- package/lib/node/dlob/types.d.ts +15 -0
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/events/eventList.d.ts +14 -0
- package/lib/node/events/eventList.d.ts.map +1 -1
- package/lib/node/events/eventList.js +14 -0
- package/lib/node/events/eventSubscriber.d.ts +87 -10
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +93 -8
- package/lib/node/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
- package/lib/node/events/eventsServerLogProvider.js +27 -0
- package/lib/node/events/fetchLogs.d.ts +31 -0
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.js +46 -1
- package/lib/node/events/parse.d.ts +23 -0
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/events/parse.js +23 -0
- package/lib/node/events/pollingLogProvider.d.ts +24 -0
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
- package/lib/node/events/pollingLogProvider.js +24 -0
- package/lib/node/events/sort.d.ts +11 -0
- package/lib/node/events/sort.d.ts.map +1 -1
- package/lib/node/events/sort.js +12 -0
- package/lib/node/events/txEventCache.d.ts +13 -3
- package/lib/node/events/txEventCache.d.ts.map +1 -1
- package/lib/node/events/txEventCache.js +19 -7
- package/lib/node/events/types.d.ts +118 -2
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +11 -0
- package/lib/node/events/webSocketLogProvider.d.ts +23 -0
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
- package/lib/node/events/webSocketLogProvider.js +28 -0
- package/lib/node/factory/oracleClient.js +2 -2
- package/lib/node/idl/velocity.d.ts +50 -1
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +50 -1
- package/lib/node/keypair.d.ts +8 -0
- package/lib/node/keypair.d.ts.map +1 -1
- package/lib/node/keypair.js +8 -0
- package/lib/node/marginCalculation.d.ts +134 -2
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marginCalculation.js +121 -0
- package/lib/node/math/amm.d.ts +348 -29
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +310 -32
- package/lib/node/math/auction.d.ts +95 -19
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +118 -28
- package/lib/node/math/bankruptcy.d.ts +46 -0
- package/lib/node/math/bankruptcy.d.ts.map +1 -1
- package/lib/node/math/bankruptcy.js +89 -1
- package/lib/node/math/builder.d.ts +64 -8
- package/lib/node/math/builder.d.ts.map +1 -1
- package/lib/node/math/builder.js +71 -9
- package/lib/node/math/conversion.d.ts +21 -0
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/conversion.js +21 -0
- package/lib/node/math/exchangeStatus.d.ts +92 -0
- package/lib/node/math/exchangeStatus.d.ts.map +1 -1
- package/lib/node/math/exchangeStatus.js +111 -1
- package/lib/node/math/funding.d.ts +57 -20
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +63 -23
- package/lib/node/math/insurance.d.ts +62 -0
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +62 -0
- package/lib/node/math/liquidation.d.ts +127 -11
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/liquidation.js +182 -19
- package/lib/node/math/margin.d.ts +79 -13
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +80 -14
- package/lib/node/math/market.d.ts +135 -15
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +145 -17
- package/lib/node/math/oracles.d.ts +113 -0
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +118 -1
- package/lib/node/math/orders.d.ts +115 -7
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +133 -18
- package/lib/node/math/position.d.ts +80 -33
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +80 -33
- package/lib/node/math/repeg.d.ts +48 -10
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/repeg.js +48 -10
- package/lib/node/math/spotBalance.d.ts +200 -5
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +239 -10
- package/lib/node/math/spotMarket.d.ts +36 -3
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +36 -3
- package/lib/node/math/spotPosition.d.ts +72 -0
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/spotPosition.js +62 -0
- package/lib/node/math/state.d.ts +31 -0
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/state.js +32 -1
- package/lib/node/math/superStake.d.ts +126 -2
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +123 -3
- package/lib/node/math/tiers.d.ts +29 -0
- package/lib/node/math/tiers.d.ts.map +1 -1
- package/lib/node/math/tiers.js +29 -0
- package/lib/node/math/trade.d.ts +102 -51
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +101 -55
- package/lib/node/math/utils.d.ts +71 -9
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/math/utils.js +71 -9
- package/lib/node/memcmp.d.ts +94 -0
- package/lib/node/memcmp.d.ts.map +1 -1
- package/lib/node/memcmp.js +129 -7
- package/lib/node/oracles/oracleClientCache.d.ts +16 -0
- package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
- package/lib/node/oracles/oracleClientCache.js +16 -0
- package/lib/node/oracles/oracleId.d.ts +31 -0
- package/lib/node/oracles/oracleId.d.ts.map +1 -1
- package/lib/node/oracles/oracleId.js +39 -8
- package/lib/node/oracles/prelaunchOracleClient.d.ts +20 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +20 -0
- package/lib/node/oracles/pythClient.d.ts +31 -0
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.js +32 -1
- package/lib/node/oracles/pythLazerClient.d.ts +34 -0
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +35 -1
- package/lib/node/oracles/quoteAssetOracleClient.d.ts +18 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/quoteAssetOracleClient.js +18 -0
- package/lib/node/oracles/strictOraclePrice.d.ts +21 -0
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/strictOraclePrice.js +21 -0
- package/lib/node/oracles/types.d.ts +45 -0
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +20 -0
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/oracles/utils.js +20 -0
- package/lib/node/orderParams.d.ts +42 -4
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderParams.js +42 -4
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +56 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +67 -2
- package/lib/node/orderSubscriber/PollingSubscription.d.ts +11 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/PollingSubscription.js +11 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +18 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/WebsocketSubscription.js +18 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts +16 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +16 -0
- package/lib/node/orderSubscriber/types.d.ts +9 -0
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/averageOverSlotsStrategy.js +1 -0
- package/lib/node/priorityFee/averageStrategy.d.ts +1 -0
- package/lib/node/priorityFee/averageStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/averageStrategy.js +1 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts +10 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/ewmaStrategy.js +10 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/heliusPriorityFeeMethod.js +9 -2
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/maxOverSlotsStrategy.js +1 -0
- package/lib/node/priorityFee/maxStrategy.d.ts +1 -0
- package/lib/node/priorityFee/maxStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/maxStrategy.js +1 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +39 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +39 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +21 -2
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/solanaPriorityFeeMethod.js +10 -0
- package/lib/node/priorityFee/types.d.ts +32 -0
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/types.js +5 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.js +8 -0
- package/lib/node/slot/SlotSubscriber.d.ts +18 -0
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.js +16 -0
- package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlothashSubscriber.js +25 -1
- package/lib/node/swift/swiftOrderSubscriber.js +2 -2
- package/lib/node/tokenFaucet.d.ts +2 -2
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +11 -4
- package/lib/node/tx/baseTxSender.d.ts +163 -0
- package/lib/node/tx/baseTxSender.d.ts.map +1 -1
- package/lib/node/tx/baseTxSender.js +174 -6
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts.map +1 -1
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts.map +1 -1
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.d.ts +47 -0
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.js +48 -1
- package/lib/node/tx/forwardOnlyTxSender.d.ts +48 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -1
- package/lib/node/tx/forwardOnlyTxSender.js +48 -0
- package/lib/node/tx/reportTransactionError.d.ts +18 -6
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
- package/lib/node/tx/reportTransactionError.js +18 -6
- package/lib/node/tx/retryTxSender.d.ts +40 -0
- package/lib/node/tx/retryTxSender.d.ts.map +1 -1
- package/lib/node/tx/retryTxSender.js +39 -0
- package/lib/node/tx/txHandler.d.ts +146 -35
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +132 -32
- package/lib/node/tx/txParamProcessor.d.ts +47 -0
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
- package/lib/node/tx/txParamProcessor.js +47 -0
- package/lib/node/tx/types.d.ts +46 -0
- package/lib/node/tx/types.d.ts.map +1 -1
- package/lib/node/tx/types.js +5 -0
- package/lib/node/tx/utils.d.ts +26 -0
- package/lib/node/tx/utils.d.ts.map +1 -1
- package/lib/node/tx/utils.js +26 -0
- package/lib/node/tx/whileValidTxSender.d.ts +82 -0
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.js +81 -0
- package/lib/node/types.d.ts +786 -13
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +133 -9
- package/lib/node/user.d.ts +645 -84
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +779 -96
- package/lib/node/userMap/PollingSubscription.d.ts +10 -0
- package/lib/node/userMap/PollingSubscription.d.ts.map +1 -1
- package/lib/node/userMap/PollingSubscription.js +14 -2
- package/lib/node/userMap/WebsocketSubscription.d.ts +9 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/userMap/WebsocketSubscription.js +9 -0
- package/lib/node/userMap/grpcSubscription.d.ts +8 -0
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
- package/lib/node/userMap/grpcSubscription.js +8 -0
- package/lib/node/userMap/referrerMap.d.ts +72 -2
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +84 -2
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +37 -10
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +38 -11
- package/lib/node/userMap/userMap.d.ts +81 -3
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +81 -4
- package/lib/node/userMap/userMapConfig.d.ts +23 -0
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +22 -0
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +22 -0
- package/lib/node/userName.d.ts +16 -0
- package/lib/node/userName.d.ts.map +1 -1
- package/lib/node/userName.js +16 -0
- package/lib/node/userStats.d.ts +28 -1
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +28 -1
- package/lib/node/util/TransactionConfirmationManager.d.ts +33 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
- package/lib/node/util/TransactionConfirmationManager.js +33 -0
- package/lib/node/util/chainClock.d.ts +24 -0
- package/lib/node/util/chainClock.d.ts.map +1 -1
- package/lib/node/util/chainClock.js +20 -0
- package/lib/node/util/computeUnits.d.ts +32 -0
- package/lib/node/util/computeUnits.d.ts.map +1 -1
- package/lib/node/util/computeUnits.js +32 -0
- package/lib/node/util/digest.d.ts +17 -0
- package/lib/node/util/digest.d.ts.map +1 -1
- package/lib/node/util/digest.js +17 -0
- package/lib/node/util/ed25519Utils.d.ts +12 -2
- package/lib/node/util/ed25519Utils.d.ts.map +1 -1
- package/lib/node/util/ed25519Utils.js +12 -2
- package/lib/node/util/promiseTimeout.d.ts +9 -0
- package/lib/node/util/promiseTimeout.d.ts.map +1 -1
- package/lib/node/util/promiseTimeout.js +9 -0
- package/lib/node/velocityClient.d.ts +3323 -216
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +3428 -249
- package/lib/node/wallet.d.ts +37 -0
- package/lib/node/wallet.d.ts.map +1 -1
- package/lib/node/wallet.js +37 -0
- package/package.json +2 -1
- package/src/accounts/basicUserAccountSubscriber.ts +18 -0
- package/src/accounts/basicUserStatsAccountSubscriber.ts +18 -0
- package/src/accounts/bulkAccountLoader.ts +52 -0
- package/src/accounts/bulkUserStatsSubscription.ts +9 -2
- package/src/accounts/bulkUserSubscription.ts +8 -2
- package/src/accounts/customizedCadenceBulkAccountLoader.ts +37 -0
- package/src/accounts/fetch.ts +59 -2
- package/src/accounts/grpcAccountSubscriber.ts +30 -0
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +16 -0
- package/src/accounts/grpcMultiAccountSubscriber.ts +121 -38
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +49 -11
- package/src/accounts/grpcProgramAccountSubscriber.ts +33 -0
- package/src/accounts/grpcUserAccountSubscriber.ts +15 -0
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +15 -0
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +41 -0
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +160 -1
- package/src/accounts/laserProgramAccountSubscriber.ts +34 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +19 -0
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +19 -0
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +31 -0
- package/src/accounts/pollingOracleAccountSubscriber.ts +21 -2
- package/src/accounts/pollingTokenAccountSubscriber.ts +22 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +32 -0
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +22 -0
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +84 -1
- package/src/accounts/testBulkAccountLoader.ts +8 -0
- package/src/accounts/types.ts +149 -0
- package/src/accounts/utils.ts +42 -24
- package/src/accounts/webSocketAccountSubscriber.ts +41 -0
- package/src/accounts/webSocketAccountSubscriberV2.ts +31 -23
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +27 -0
- package/src/accounts/webSocketProgramAccountSubscriber.ts +36 -0
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +26 -0
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +21 -0
- package/src/accounts/webSocketUserAccountSubscriber.ts +26 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +20 -0
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +127 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +110 -0
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +33 -0
- package/src/addresses/marketAddresses.ts +10 -0
- package/src/addresses/pda.ts +228 -12
- package/src/adminClient.ts +2184 -4
- package/src/auctionSubscriber/auctionSubscriber.ts +15 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +19 -0
- package/src/auctionSubscriber/index.ts +6 -0
- package/src/auctionSubscriber/types.ts +7 -0
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +33 -0
- package/src/blockhashSubscriber/index.ts +5 -0
- package/src/blockhashSubscriber/types.ts +5 -4
- package/src/clock/clockSubscriber.ts +24 -0
- package/src/config.ts +109 -22
- package/src/constants/numericConstants.ts +70 -0
- package/src/constants/perpMarkets.ts +45 -960
- package/src/constants/spotMarkets.ts +23 -793
- package/src/constants/txConstants.ts +1 -0
- package/src/core/VelocityCore.ts +286 -8
- package/src/core/instructions/deposit.ts +22 -0
- package/src/core/instructions/fill.ts +17 -0
- package/src/core/instructions/funding.ts +12 -0
- package/src/core/instructions/liquidation.ts +18 -0
- package/src/core/instructions/orders.ts +28 -0
- package/src/core/instructions/perpOrders.ts +106 -0
- package/src/core/instructions/settlement.ts +14 -0
- package/src/core/instructions/trigger.ts +15 -0
- package/src/core/instructions/withdraw.ts +21 -0
- package/src/core/remainingAccounts.ts +47 -3
- package/src/core/signedMsg.ts +38 -0
- package/src/decode/customCoder.ts +46 -3
- package/src/decode/user.ts +22 -0
- package/src/dlob/DLOB.ts +668 -97
- package/src/dlob/DLOBNode.ts +98 -6
- package/src/dlob/DLOBSubscriber.ts +49 -12
- package/src/dlob/NodeList.ts +69 -0
- package/src/dlob/orderBookLevels.ts +108 -14
- package/src/dlob/types.ts +15 -0
- package/src/events/eventList.ts +14 -0
- package/src/events/eventSubscriber.ts +100 -19
- package/src/events/eventsServerLogProvider.ts +28 -0
- package/src/events/fetchLogs.ts +52 -2
- package/src/events/parse.ts +23 -0
- package/src/events/pollingLogProvider.ts +24 -0
- package/src/events/sort.ts +12 -0
- package/src/events/txEventCache.ts +19 -7
- package/src/events/types.ts +131 -11
- package/src/events/webSocketLogProvider.ts +29 -0
- package/src/factory/oracleClient.ts +2 -2
- package/src/idl/velocity.json +50 -1
- package/src/idl/velocity.ts +50 -1
- package/src/keypair.ts +8 -0
- package/src/marginCalculation.ts +153 -2
- package/src/math/amm.ts +371 -36
- package/src/math/auction.ts +139 -30
- package/src/math/bankruptcy.ts +104 -1
- package/src/math/builder.ts +74 -8
- package/src/math/conversion.ts +21 -0
- package/src/math/exchangeStatus.ts +125 -0
- package/src/math/funding.ts +63 -23
- package/src/math/insurance.ts +62 -0
- package/src/math/liquidation.ts +227 -17
- package/src/math/margin.ts +80 -14
- package/src/math/market.ts +148 -17
- package/src/math/oracles.ts +124 -0
- package/src/math/orders.ts +144 -18
- package/src/math/position.ts +80 -33
- package/src/math/repeg.ts +48 -10
- package/src/math/spotBalance.ts +252 -12
- package/src/math/spotMarket.ts +36 -3
- package/src/math/spotPosition.ts +72 -0
- package/src/math/state.ts +32 -1
- package/src/math/superStake.ts +126 -3
- package/src/math/tiers.ts +29 -0
- package/src/math/trade.ts +125 -55
- package/src/math/utils.ts +71 -9
- package/src/memcmp.ts +131 -7
- package/src/oracles/oracleClientCache.ts +16 -0
- package/src/oracles/oracleId.ts +39 -6
- package/src/oracles/prelaunchOracleClient.ts +20 -0
- package/src/oracles/pythClient.ts +32 -1
- package/src/oracles/pythLazerClient.ts +35 -1
- package/src/oracles/quoteAssetOracleClient.ts +18 -0
- package/src/oracles/strictOraclePrice.ts +21 -0
- package/src/oracles/types.ts +45 -0
- package/src/oracles/utils.ts +20 -0
- package/src/orderParams.ts +42 -4
- package/src/orderSubscriber/OrderSubscriber.ts +74 -2
- package/src/orderSubscriber/PollingSubscription.ts +11 -0
- package/src/orderSubscriber/WebsocketSubscription.ts +18 -0
- package/src/orderSubscriber/grpcSubscription.ts +16 -0
- package/src/orderSubscriber/types.ts +9 -0
- package/src/priorityFee/averageOverSlotsStrategy.ts +1 -0
- package/src/priorityFee/averageStrategy.ts +1 -0
- package/src/priorityFee/ewmaStrategy.ts +10 -0
- package/src/priorityFee/heliusPriorityFeeMethod.ts +13 -2
- package/src/priorityFee/maxOverSlotsStrategy.ts +1 -0
- package/src/priorityFee/maxStrategy.ts +1 -0
- package/src/priorityFee/priorityFeeSubscriber.ts +39 -0
- package/src/priorityFee/priorityFeeSubscriberMap.ts +21 -2
- package/src/priorityFee/solanaPriorityFeeMethod.ts +12 -0
- package/src/priorityFee/types.ts +33 -15
- package/src/priorityFee/velocityPriorityFeeMethod.ts +11 -0
- package/src/slot/SlotSubscriber.ts +18 -0
- package/src/slot/SlothashSubscriber.ts +27 -1
- package/src/swift/swiftOrderSubscriber.ts +2 -2
- package/src/tokenFaucet.ts +10 -7
- package/src/tx/baseTxSender.ts +185 -5
- package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +12 -0
- package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +15 -0
- package/src/tx/blockhashFetcher/types.ts +4 -0
- package/src/tx/fastSingleTxSender.ts +58 -4
- package/src/tx/forwardOnlyTxSender.ts +48 -0
- package/src/tx/reportTransactionError.ts +18 -6
- package/src/tx/retryTxSender.ts +40 -0
- package/src/tx/txHandler.ts +146 -35
- package/src/tx/txParamProcessor.ts +47 -0
- package/src/tx/types.ts +46 -0
- package/src/tx/utils.ts +26 -0
- package/src/tx/whileValidTxSender.ts +82 -0
- package/src/types.ts +783 -22
- package/src/user.ts +869 -110
- package/src/userMap/PollingSubscription.ts +16 -2
- package/src/userMap/WebsocketSubscription.ts +9 -0
- package/src/userMap/grpcSubscription.ts +8 -0
- package/src/userMap/referrerMap.ts +92 -3
- package/src/userMap/revenueShareEscrowMap.ts +38 -11
- package/src/userMap/userMap.ts +82 -4
- package/src/userMap/userMapConfig.ts +23 -10
- package/src/userMap/userStatsMap.ts +22 -0
- package/src/userName.ts +16 -0
- package/src/userStats.ts +28 -1
- package/src/util/TransactionConfirmationManager.ts +33 -0
- package/src/util/chainClock.ts +24 -0
- package/src/util/computeUnits.ts +32 -0
- package/src/util/digest.ts +17 -0
- package/src/util/ed25519Utils.ts +12 -2
- package/src/util/promiseTimeout.ts +9 -0
- package/src/velocityClient.ts +3456 -254
- package/src/wallet.ts +37 -0
- package/tests/VelocityCore/builder_escrow.test.ts +121 -0
- package/tests/amm/test.ts +102 -0
- package/tests/builder/builderFee.test.ts +42 -0
- package/tests/dlob/helpers.ts +1 -0
- package/tests/dlob/tickSizeStandardization.ts +545 -0
- package/tests/exchangeStatus/test.ts +45 -0
- package/tests/liquidation/test.ts +125 -0
- package/tests/oracles/mmOracleGate.test.ts +379 -0
- package/tests/oracles/pythPegSnap.test.ts +76 -0
- package/tests/sdkParity/enumParity.test.ts +84 -0
- package/tests/sdkParity/marginCategoryFill.test.ts +143 -0
- package/tests/sdkParity/memcmpOffsets.test.ts +139 -0
- package/tests/spot/test.ts +55 -0
- package/tests/user/bankruptcy.ts +165 -0
- package/tests/user/feeAndWithdrawLimits.ts +284 -0
- package/tests/user/getMarginCalculation.ts +226 -1
- package/tests/user/test.ts +8 -4
package/src/types.ts
CHANGED
|
@@ -19,13 +19,20 @@ import {
|
|
|
19
19
|
import { BN } from './isomorphic/anchor';
|
|
20
20
|
import { ZERO } from './constants/numericConstants';
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
/** Utility type that maps every key of `A` to the same-shaped record with all values replaced by type `B`. */
|
|
23
23
|
export type MappedRecord<A extends Record<string, unknown>, B> = {
|
|
24
24
|
[K in keyof A]: B;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
// # Utility Types / Enums / Constants
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Bitmask mirror of `State.exchangeStatus`. Each non-zero member pauses one class of
|
|
31
|
+
* instructions protocol-wide; multiple bits may be set simultaneously (e.g. deposits and
|
|
32
|
+
* withdrawals paused together). `PAUSED` (255) is the "pause everything" value, not a flag
|
|
33
|
+
* combinable with the others. Only `coldAdmin`/`warmAdmin` may clear bits; `pauseAdmin` may
|
|
34
|
+
* only set them (see `StateAccount.pauseAdmin`).
|
|
35
|
+
*/
|
|
29
36
|
export enum ExchangeStatus {
|
|
30
37
|
ACTIVE = 0,
|
|
31
38
|
DEPOSIT_PAUSED = 1,
|
|
@@ -39,13 +46,36 @@ export enum ExchangeStatus {
|
|
|
39
46
|
PAUSED = 255,
|
|
40
47
|
}
|
|
41
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Mirror of the Rust `SolvencyStatus` bitflag (`StateAccount.solvencyStatus`). Gates internal
|
|
51
|
+
* solvency-repair flows (bankruptcy / pnl-deficit resolution) independently of
|
|
52
|
+
* `ExchangeStatus.WITHDRAW_PAUSED`, so withdrawals can be halted while repair keeps running, or
|
|
53
|
+
* repair can be frozen on its own (e.g. when an oracle is suspect) without touching withdrawals.
|
|
54
|
+
* `ACTIVE` (0) means repair is allowed.
|
|
55
|
+
*/
|
|
56
|
+
export enum SolvencyStatus {
|
|
57
|
+
ACTIVE = 0,
|
|
58
|
+
SOLVENCY_REPAIR_PAUSED = 1,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Bitmask mirror of `StateAccount.featureBitFlags`, gating protocol-wide optional features. */
|
|
42
62
|
export enum FeatureBitFlags {
|
|
43
63
|
MM_ORACLE_UPDATE = 1,
|
|
44
64
|
MEDIAN_TRIGGER_PRICE = 2,
|
|
45
65
|
BUILDER_CODES = 4,
|
|
46
|
-
BUILDER_REFERRAL = 8,
|
|
47
66
|
}
|
|
48
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Mirrors the Rust `MarketStatus` enum on `PerpMarketAccount.status` / `SpotMarketAccount.status`.
|
|
70
|
+
* Controls which operations a market allows: `INITIALIZED` (warm-up, fills paused), `ACTIVE` (all
|
|
71
|
+
* operations allowed), `REDUCE_ONLY` (fills may only shrink a liability), `SETTLEMENT` (market has
|
|
72
|
+
* a determined settlement price; positions must be settled), `DELISTED` (no participants remain).
|
|
73
|
+
* Velocity's on-chain discriminants (`Initialized`=0, `Active`=1, `ReduceOnly`=2, `Settlement`=3,
|
|
74
|
+
* `Delisted`=4) are **shifted down from upstream Drift's** (`ReduceOnly`=6, `Settlement`=7,
|
|
75
|
+
* `Delisted`=8) after the deprecated `FundingPaused`/`AmmPaused`/`FillPaused`/`WithdrawPaused`
|
|
76
|
+
* variants were removed — any decoder built against the old Drift discriminants will silently
|
|
77
|
+
* misread these states.
|
|
78
|
+
*/
|
|
49
79
|
export class MarketStatus {
|
|
50
80
|
static readonly INITIALIZED = { initialized: {} };
|
|
51
81
|
static readonly ACTIVE = { active: {} };
|
|
@@ -54,6 +84,7 @@ export class MarketStatus {
|
|
|
54
84
|
static readonly DELISTED = { delisted: {} };
|
|
55
85
|
}
|
|
56
86
|
|
|
87
|
+
/** Bitmask mirror of `PerpMarketAccount.pausedOperations`; each bit disables one perp-market operation. */
|
|
57
88
|
export enum PerpOperation {
|
|
58
89
|
UPDATE_FUNDING = 1,
|
|
59
90
|
AMM_FILL = 2,
|
|
@@ -61,9 +92,11 @@ export enum PerpOperation {
|
|
|
61
92
|
SETTLE_PNL = 8,
|
|
62
93
|
SETTLE_PNL_WITH_POSITION = 16,
|
|
63
94
|
LIQUIDATION = 32,
|
|
64
|
-
|
|
95
|
+
AMM_IMMEDIATE_FILL = 64,
|
|
96
|
+
SETTLE_REV_POOL = 128,
|
|
65
97
|
}
|
|
66
98
|
|
|
99
|
+
/** Bitmask mirror of `SpotMarketAccount.pausedOperations`; each bit disables one spot-market operation. */
|
|
67
100
|
export enum SpotOperation {
|
|
68
101
|
UPDATE_CUMULATIVE_INTEREST = 1,
|
|
69
102
|
FILL = 2,
|
|
@@ -72,6 +105,7 @@ export enum SpotOperation {
|
|
|
72
105
|
LIQUIDATION = 16,
|
|
73
106
|
}
|
|
74
107
|
|
|
108
|
+
/** Bitmask mirror of `SpotMarketAccount.ifPausedOperations`; each bit disables one insurance-fund-stake operation. */
|
|
75
109
|
export enum InsuranceFundOperation {
|
|
76
110
|
INIT = 1,
|
|
77
111
|
ADD = 2,
|
|
@@ -79,6 +113,11 @@ export enum InsuranceFundOperation {
|
|
|
79
113
|
REMOVE = 8,
|
|
80
114
|
}
|
|
81
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Bitmask mirror of `UserAccount.status`. Multiple bits can be set at once (e.g. a bankrupt user
|
|
118
|
+
* is also `BEING_LIQUIDATED`). `0` (unset) means active/normal. Bit `16` (was `PROTECTED_MAKER`)
|
|
119
|
+
* is reserved and no longer assigned.
|
|
120
|
+
*/
|
|
82
121
|
export enum UserStatus {
|
|
83
122
|
BEING_LIQUIDATED = 1,
|
|
84
123
|
BANKRUPT = 2,
|
|
@@ -87,29 +126,44 @@ export enum UserStatus {
|
|
|
87
126
|
// 16 reserved (was PROTECTED_MAKER)
|
|
88
127
|
}
|
|
89
128
|
|
|
129
|
+
/** Bitmask mirror of `UserAccount.specialUserStatus`. `VAMM_HEDGER` marks the account used by the protocol's own vAMM-hedging bot. */
|
|
90
130
|
export enum SpecialUserStatus {
|
|
91
131
|
VAMM_HEDGER = 1,
|
|
92
132
|
}
|
|
93
133
|
|
|
134
|
+
/** Bitmask mirror of `UserStatsAccount.pausedOperations`; each bit disables one per-user-stats update path. */
|
|
94
135
|
export enum UserStatsPausedOperation {
|
|
95
136
|
UPDATE_BID_ASK_TWAP = 1,
|
|
96
137
|
AMM_ATOMIC_FILL = 2,
|
|
97
138
|
AMM_ATOMIC_RISK_INCREASING_FILL = 4,
|
|
98
139
|
}
|
|
99
140
|
|
|
141
|
+
/** Bitmask mirror of `PerpMarketAccount.marketConfig`. `DISABLE_FORMULAIC_K_UPDATE` turns off the AMM's automatic `k` (liquidity depth) adjustments for that market. */
|
|
100
142
|
export enum MarketConfigFlag {
|
|
101
143
|
DISABLE_FORMULAIC_K_UPDATE = 1,
|
|
102
144
|
}
|
|
103
145
|
|
|
146
|
+
/** Margin-mode enum-class. Currently only `DEFAULT` (cross margin) exists; isolated margin is expressed per-position via `PositionFlag.IsolatedPosition`, not a distinct margin mode. */
|
|
104
147
|
export class MarginMode {
|
|
105
148
|
static readonly DEFAULT = { default: {} };
|
|
106
149
|
}
|
|
107
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Mirrors the on-chain `ContractType` on `PerpMarketAccount.contractType`. Only `PERPETUAL` is
|
|
153
|
+
* live; `DEPRECATED_FUTURE` and `DEPRECATED_PREDICTION` are inert stubs kept for IDL/discriminant
|
|
154
|
+
* compatibility and are never assigned to a market.
|
|
155
|
+
*/
|
|
108
156
|
export class ContractType {
|
|
109
157
|
static readonly PERPETUAL = { perpetual: {} };
|
|
110
|
-
static readonly
|
|
158
|
+
static readonly DEPRECATED_FUTURE = { deprecatedFuture: {} };
|
|
159
|
+
static readonly DEPRECATED_PREDICTION = { deprecatedPrediction: {} };
|
|
111
160
|
}
|
|
112
161
|
|
|
162
|
+
/**
|
|
163
|
+
* A perp market's speculativeness tier (`PerpMarketAccount.contractTier`). Determines how much of
|
|
164
|
+
* the insurance fund the market may draw on during bankruptcy and the order markets are
|
|
165
|
+
* liquidated in — `ISOLATED` markets receive no shared insurance coverage; `A` is safest.
|
|
166
|
+
*/
|
|
113
167
|
export class ContractTier {
|
|
114
168
|
static readonly A = { a: {} };
|
|
115
169
|
static readonly B = { b: {} };
|
|
@@ -119,6 +173,12 @@ export class ContractTier {
|
|
|
119
173
|
static readonly ISOLATED = { isolated: {} };
|
|
120
174
|
}
|
|
121
175
|
|
|
176
|
+
/**
|
|
177
|
+
* A spot market's collateral-safety tier (`SpotMarketAccount.assetTier`). Determines whether a
|
|
178
|
+
* deposit can be used as cross-margin collateral alongside other assets: `COLLATERAL` may back
|
|
179
|
+
* any borrow, `PROTECTED`/`CROSS` have restrictions on being borrowed against, `ISOLATED` deposits
|
|
180
|
+
* can't be combined with other borrows, and `UNLISTED` deposits count for nothing.
|
|
181
|
+
*/
|
|
122
182
|
export class AssetTier {
|
|
123
183
|
static readonly COLLATERAL = { collateral: {} };
|
|
124
184
|
static readonly PROTECTED = { protected: {} };
|
|
@@ -127,31 +187,43 @@ export class AssetTier {
|
|
|
127
187
|
static readonly UNLISTED = { unlisted: {} };
|
|
128
188
|
}
|
|
129
189
|
|
|
190
|
+
/** Bitmask mirror of `SpotMarketAccount.tokenProgramFlag`, recording which SPL token-program features the market's mint uses. */
|
|
130
191
|
export enum TokenProgramFlag {
|
|
131
192
|
Token2022 = 1,
|
|
132
193
|
TransferHook = 2,
|
|
133
194
|
}
|
|
134
195
|
|
|
196
|
+
/** Direction of an LP-pool constituent swap (add liquidity vs remove liquidity). */
|
|
135
197
|
export class SwapDirection {
|
|
136
198
|
static readonly ADD = { add: {} };
|
|
137
199
|
static readonly REMOVE = { remove: {} };
|
|
138
200
|
}
|
|
139
201
|
|
|
202
|
+
/** Whether a `SpotPosition`/`PoolBalance`'s scaled balance represents a deposit (positive token claim) or a borrow (liability). */
|
|
140
203
|
export class SpotBalanceType {
|
|
141
204
|
static readonly DEPOSIT = { deposit: {} };
|
|
142
205
|
static readonly BORROW = { borrow: {} };
|
|
143
206
|
}
|
|
144
207
|
|
|
208
|
+
/** Long (bid) or short (ask) side of a perp/spot order or position. */
|
|
145
209
|
export class PositionDirection {
|
|
146
210
|
static readonly LONG = { long: {} };
|
|
147
211
|
static readonly SHORT = { short: {} };
|
|
148
212
|
}
|
|
149
213
|
|
|
214
|
+
/** Direction of a `DepositRecord` / `LPBorrowLendDepositRecord` event: funds entering or leaving the protocol. */
|
|
150
215
|
export class DepositDirection {
|
|
151
216
|
static readonly DEPOSIT = { deposit: {} };
|
|
152
217
|
static readonly WITHDRAW = { withdraw: {} };
|
|
153
218
|
}
|
|
154
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Mirrors the on-chain `OracleSource` enum, identifying which oracle provider/decoder to use for
|
|
222
|
+
* a market's `oracle` account. The `1K`/`1M` suffixes scale the raw feed price by 1e3/1e6 (used
|
|
223
|
+
* for low-priced assets like BONK). `DEPRECATED_SWITCHBOARD`/`DEPRECATED_SWITCHBOARD_ON_DEMAND`
|
|
224
|
+
* are inert stubs — using them returns `InvalidOracle`. `Prelaunch` reads from a `PrelaunchOracle`
|
|
225
|
+
* account instead of an external feed.
|
|
226
|
+
*/
|
|
155
227
|
export class OracleSource {
|
|
156
228
|
static readonly PYTH = { pyth: {} };
|
|
157
229
|
static readonly PYTH_1K = { pyth1K: {} };
|
|
@@ -159,18 +231,27 @@ export class OracleSource {
|
|
|
159
231
|
static readonly PYTH_PULL = { pythPull: {} };
|
|
160
232
|
static readonly PYTH_1K_PULL = { pyth1KPull: {} };
|
|
161
233
|
static readonly PYTH_1M_PULL = { pyth1MPull: {} };
|
|
162
|
-
static readonly
|
|
234
|
+
static readonly DEPRECATED_SWITCHBOARD = { deprecatedSwitchboard: {} };
|
|
163
235
|
static readonly QUOTE_ASSET = { quoteAsset: {} };
|
|
164
236
|
static readonly PYTH_STABLE_COIN = { pythStableCoin: {} };
|
|
165
237
|
static readonly PYTH_STABLE_COIN_PULL = { pythStableCoinPull: {} };
|
|
166
238
|
static readonly Prelaunch = { prelaunch: {} };
|
|
167
|
-
static readonly
|
|
239
|
+
static readonly DEPRECATED_SWITCHBOARD_ON_DEMAND = {
|
|
240
|
+
deprecatedSwitchboardOnDemand: {},
|
|
241
|
+
};
|
|
168
242
|
static readonly PYTH_LAZER = { pythLazer: {} };
|
|
169
243
|
static readonly PYTH_LAZER_1K = { pythLazer1K: {} };
|
|
170
244
|
static readonly PYTH_LAZER_1M = { pythLazer1M: {} };
|
|
171
245
|
static readonly PYTH_LAZER_STABLE_COIN = { pythLazerStableCoin: {} };
|
|
172
246
|
}
|
|
173
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Stable SDK-internal numeric encoding of `OracleSource`, used only for oracle-id string
|
|
250
|
+
* round-tripping (`getOracleSourceNum` ↔ `getOracleSourceFromNum` in `oracles/oracleId.ts`).
|
|
251
|
+
* NOTE: these numbers are **not** the on-chain Borsh discriminants and are **not** in the
|
|
252
|
+
* on-chain enum's declaration order — do not use them for raw memcmp filters against chain
|
|
253
|
+
* data. They only need to be self-consistent within the SDK.
|
|
254
|
+
*/
|
|
174
255
|
export class OracleSourceNum {
|
|
175
256
|
static readonly PYTH = 0;
|
|
176
257
|
static readonly PYTH_1K = 1;
|
|
@@ -178,18 +259,19 @@ export class OracleSourceNum {
|
|
|
178
259
|
static readonly PYTH_PULL = 3;
|
|
179
260
|
static readonly PYTH_1K_PULL = 4;
|
|
180
261
|
static readonly PYTH_1M_PULL = 5;
|
|
181
|
-
static readonly
|
|
262
|
+
static readonly DEPRECATED_SWITCHBOARD = 6;
|
|
182
263
|
static readonly QUOTE_ASSET = 7;
|
|
183
264
|
static readonly PYTH_STABLE_COIN = 8;
|
|
184
265
|
static readonly PYTH_STABLE_COIN_PULL = 9;
|
|
185
266
|
static readonly PRELAUNCH = 10;
|
|
186
|
-
static readonly
|
|
267
|
+
static readonly DEPRECATED_SWITCHBOARD_ON_DEMAND = 11;
|
|
187
268
|
static readonly PYTH_LAZER = 12;
|
|
188
269
|
static readonly PYTH_LAZER_1K = 13;
|
|
189
270
|
static readonly PYTH_LAZER_1M = 14;
|
|
190
271
|
static readonly PYTH_LAZER_STABLE_COIN = 15;
|
|
191
272
|
}
|
|
192
273
|
|
|
274
|
+
/** The order's price-determination mechanism: `LIMIT`/`TRIGGER_LIMIT` use `Order.price`, `MARKET`/`TRIGGER_MARKET` fill at the best available price (subject to any auction), and `ORACLE` prices relative to the oracle via `Order.oraclePriceOffset`. `TRIGGER_*` variants only become active once `Order.triggerPrice` is crossed. */
|
|
193
275
|
export class OrderType {
|
|
194
276
|
static readonly LIMIT = { limit: {} };
|
|
195
277
|
static readonly TRIGGER_MARKET = { triggerMarket: {} };
|
|
@@ -198,12 +280,15 @@ export class OrderType {
|
|
|
198
280
|
static readonly ORACLE = { oracle: {} };
|
|
199
281
|
}
|
|
200
282
|
|
|
283
|
+
/** String-literal twin of `MarketType`, used where a plain `'perp' | 'spot'` string (not the `{variant: {}}` shape) is more convenient, e.g. UI/query params. */
|
|
201
284
|
export declare type MarketTypeStr = 'perp' | 'spot';
|
|
285
|
+
/** Whether an order/position/market is on the spot or perp side of the protocol. */
|
|
202
286
|
export class MarketType {
|
|
203
287
|
static readonly SPOT = { spot: {} };
|
|
204
288
|
static readonly PERP = { perp: {} };
|
|
205
289
|
}
|
|
206
290
|
|
|
291
|
+
/** Lifecycle state of an `Order`: `INIT` (unused slot), `OPEN` (live, may still be filled), `FILLED` (fully filled), `CANCELED`. */
|
|
207
292
|
export class OrderStatus {
|
|
208
293
|
static readonly INIT = { init: {} };
|
|
209
294
|
static readonly OPEN = { open: {} };
|
|
@@ -211,13 +296,28 @@ export class OrderStatus {
|
|
|
211
296
|
static readonly CANCELED = { canceled: {} };
|
|
212
297
|
}
|
|
213
298
|
|
|
299
|
+
/**
|
|
300
|
+
* Bitmask mirror of `Order.bitFlags` / `OrderParams.bitFlags`.
|
|
301
|
+
* - `SignedMessage`: order originated from a signed off-chain message (swift/signed-msg flow).
|
|
302
|
+
* - `OracleTriggerMarket`: a `TriggerMarket` order whose trigger condition is evaluated against
|
|
303
|
+
* the oracle price rather than the last mark/fill price.
|
|
304
|
+
* - `SafeTriggerOrder`: exempts the order from the AMM's low-risk-fill slot-delay gate — it may
|
|
305
|
+
* be immediately filled by the AMM once triggered, or when the order itself is a liquidation.
|
|
306
|
+
* - `NewTriggerReduceOnly`: for a reduce-only order that has triggered, suppresses updating the
|
|
307
|
+
* user's `openBids`/`openAsks` counters (avoids double-counting margin already reserved).
|
|
308
|
+
* - `HasBuilder`: the order carries a `builderIdx`/`builderFeeTenthBps` builder-code fee split.
|
|
309
|
+
* - `IsIsolatedPosition`: the order trades against/opens an isolated-margin position rather than cross margin.
|
|
310
|
+
*/
|
|
214
311
|
export class OrderBitFlag {
|
|
215
312
|
static readonly SignedMessage = 1;
|
|
216
313
|
static readonly OracleTriggerMarket = 2;
|
|
217
314
|
static readonly SafeTriggerOrder = 4;
|
|
218
315
|
static readonly NewTriggerReduceOnly = 8;
|
|
316
|
+
static readonly HasBuilder = 16;
|
|
317
|
+
static readonly IsIsolatedPosition = 32;
|
|
219
318
|
}
|
|
220
319
|
|
|
320
|
+
/** The kind of action an `OrderActionRecord` event describes. */
|
|
221
321
|
export class OrderAction {
|
|
222
322
|
static readonly PLACE = { place: {} };
|
|
223
323
|
static readonly CANCEL = { cancel: {} };
|
|
@@ -226,6 +326,7 @@ export class OrderAction {
|
|
|
226
326
|
static readonly TRIGGER = { trigger: {} };
|
|
227
327
|
}
|
|
228
328
|
|
|
329
|
+
/** Why an `OrderActionRecord` event happened — the specific reason a fill/cancel/expire/trigger occurred (e.g. which fulfillment method filled the order, or why it was rejected/canceled). */
|
|
229
330
|
export class OrderActionExplanation {
|
|
230
331
|
static readonly NONE = { none: {} };
|
|
231
332
|
static readonly INSUFFICIENT_FREE_COLLATERAL = {
|
|
@@ -278,6 +379,7 @@ export class OrderActionExplanation {
|
|
|
278
379
|
};
|
|
279
380
|
}
|
|
280
381
|
|
|
382
|
+
/** Trigger-order condition on `Order.triggerCondition`. `ABOVE`/`BELOW` are the pending (not-yet-triggered) states; `TRIGGERED_ABOVE`/`TRIGGERED_BELOW` record that the condition has already fired, so the order is now live for filling. */
|
|
281
383
|
export class OrderTriggerCondition {
|
|
282
384
|
static readonly ABOVE = { above: {} };
|
|
283
385
|
static readonly BELOW = { below: {} };
|
|
@@ -285,6 +387,7 @@ export class OrderTriggerCondition {
|
|
|
285
387
|
static readonly TRIGGERED_BELOW = { triggeredBelow: {} }; // below condition has been triggered
|
|
286
388
|
}
|
|
287
389
|
|
|
390
|
+
/** Why a `DepositRecord` event happened: a direct transfer, a borrow being drawn, a borrow being repaid, or a protocol reward credit. */
|
|
288
391
|
export class DepositExplanation {
|
|
289
392
|
static readonly NONE = { none: {} };
|
|
290
393
|
static readonly TRANSFER = { transfer: {} };
|
|
@@ -293,11 +396,13 @@ export class DepositExplanation {
|
|
|
293
396
|
static readonly REWARD = { reward: {} };
|
|
294
397
|
}
|
|
295
398
|
|
|
399
|
+
/** Why a `SettlePnlRecord` event happened: a normal settle, or settlement of an expired-market position at the market's `expiryPrice`. */
|
|
296
400
|
export class SettlePnlExplanation {
|
|
297
401
|
static readonly NONE = { none: {} };
|
|
298
402
|
static readonly EXPIRED_POSITION = { expiredPosition: {} };
|
|
299
403
|
}
|
|
300
404
|
|
|
405
|
+
/** The insurance-fund-stake action an `InsuranceFundStakeRecord` event describes. */
|
|
301
406
|
export class StakeAction {
|
|
302
407
|
static readonly STAKE = { stake: {} };
|
|
303
408
|
static readonly UNSTAKE_REQUEST = { unstakeRequest: {} };
|
|
@@ -307,31 +412,37 @@ export class StakeAction {
|
|
|
307
412
|
static readonly STAKE_TRANSFER = { stakeTransfer: {} };
|
|
308
413
|
}
|
|
309
414
|
|
|
415
|
+
/** Fill/settle-PnL strictness passed to settle-PnL instructions: `TRY_SETTLE` settles as much as is safe and never fails outright, `MUST_SETTLE` requires the full requested settlement to succeed or the instruction reverts. */
|
|
310
416
|
export class SettlePnlMode {
|
|
311
417
|
static readonly TRY_SETTLE = { trySettle: {} };
|
|
312
418
|
static readonly MUST_SETTLE = { mustSettle: {} };
|
|
313
419
|
}
|
|
314
420
|
|
|
421
|
+
/** Returns true if the Anchor enum-class instance `object` (shape `{ [variant]: {} }`) is the given variant key. */
|
|
315
422
|
export function isVariant(object: unknown, type: string) {
|
|
316
423
|
return Object.prototype.hasOwnProperty.call(object, type);
|
|
317
424
|
}
|
|
318
425
|
|
|
426
|
+
/** Returns true if the Anchor enum-class instance `object` matches any of the given variant keys. */
|
|
319
427
|
export function isOneOfVariant(object: unknown, types: string[]) {
|
|
320
428
|
return types.reduce((result, type) => {
|
|
321
429
|
return result || Object.prototype.hasOwnProperty.call(object, type);
|
|
322
430
|
}, false);
|
|
323
431
|
}
|
|
324
432
|
|
|
433
|
+
/** Returns the sole variant key of an Anchor enum-class instance (shape `{ [variant]: {} }`), e.g. `"long"` for `PositionDirection.LONG`. */
|
|
325
434
|
export function getVariant(object: unknown): string {
|
|
326
435
|
return Object.keys(object as object)[0];
|
|
327
436
|
}
|
|
328
437
|
|
|
438
|
+
/** Aggressor side of a trade for candle/trade-history purposes. `None` is used when a fill has no clear taker side (e.g. some liquidations). */
|
|
329
439
|
export enum TradeSide {
|
|
330
440
|
None = 0,
|
|
331
441
|
Buy = 1,
|
|
332
442
|
Sell = 2,
|
|
333
443
|
}
|
|
334
444
|
|
|
445
|
+
/** Candle bucket size in minutes (`'1'`…`'240'`), or `'D'`/`'W'`/`'M'` for day/week/month candles. */
|
|
335
446
|
export type CandleResolution =
|
|
336
447
|
| '1'
|
|
337
448
|
| '5'
|
|
@@ -342,6 +453,7 @@ export type CandleResolution =
|
|
|
342
453
|
| 'W'
|
|
343
454
|
| 'M';
|
|
344
455
|
|
|
456
|
+
/** Emitted when a new `UserAccount` sub-account is created. */
|
|
345
457
|
export type NewUserRecord = {
|
|
346
458
|
ts: BN;
|
|
347
459
|
userAuthority: PublicKey;
|
|
@@ -351,6 +463,7 @@ export type NewUserRecord = {
|
|
|
351
463
|
referrer: PublicKey;
|
|
352
464
|
};
|
|
353
465
|
|
|
466
|
+
/** Emitted on every deposit, withdraw, or internal transfer that moves tokens into/out of a spot market. */
|
|
354
467
|
export type DepositRecord = {
|
|
355
468
|
ts: BN;
|
|
356
469
|
userAuthority: PublicKey;
|
|
@@ -360,68 +473,108 @@ export type DepositRecord = {
|
|
|
360
473
|
withdraw?: any;
|
|
361
474
|
};
|
|
362
475
|
marketIndex: number;
|
|
476
|
+
/** amount moved, in the spot market's token-mint precision (`SpotMarketConfig.precision`) */
|
|
363
477
|
amount: BN;
|
|
478
|
+
/** PRICE_PRECISION (1e6) */
|
|
364
479
|
oraclePrice: BN;
|
|
480
|
+
/** market's total deposit balance after this action, SPOT_BALANCE_PRECISION (1e9) scaled balance */
|
|
365
481
|
marketDepositBalance: BN;
|
|
482
|
+
/** market's total borrow balance after this action, SPOT_BALANCE_PRECISION (1e9) scaled balance */
|
|
366
483
|
marketWithdrawBalance: BN;
|
|
484
|
+
/** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
|
|
367
485
|
marketCumulativeDepositInterest: BN;
|
|
486
|
+
/** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
|
|
368
487
|
marketCumulativeBorrowInterest: BN;
|
|
488
|
+
/** user's lifetime deposits after this action, QUOTE_PRECISION (1e6) */
|
|
369
489
|
totalDepositsAfter: BN;
|
|
490
|
+
/** user's lifetime withdraws after this action, QUOTE_PRECISION (1e6) */
|
|
370
491
|
totalWithdrawsAfter: BN;
|
|
371
492
|
depositRecordId: BN;
|
|
372
493
|
explanation: DepositExplanation;
|
|
494
|
+
/** set when this was a `transferDeposit`: the counterparty user account */
|
|
373
495
|
transferUser?: PublicKey;
|
|
496
|
+
/** the signer that authorized the action, when different from the user's own authority (e.g. a delegate or keeper) */
|
|
374
497
|
signer?: PublicKey;
|
|
498
|
+
/** the user's token amount (deposit/borrow value) after this action, spot market token-mint precision */
|
|
375
499
|
userTokenAmountAfter: BN;
|
|
376
500
|
};
|
|
377
501
|
|
|
502
|
+
/** Emitted whenever a spot market's cumulative deposit/borrow interest is updated. */
|
|
378
503
|
export type SpotInterestRecord = {
|
|
379
504
|
ts: BN;
|
|
380
505
|
marketIndex: number;
|
|
506
|
+
/** SPOT_BALANCE_PRECISION (1e9) */
|
|
381
507
|
depositBalance: BN;
|
|
508
|
+
/** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
|
|
382
509
|
cumulativeDepositInterest: BN;
|
|
510
|
+
/** SPOT_BALANCE_PRECISION (1e9) */
|
|
383
511
|
borrowBalance: BN;
|
|
512
|
+
/** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
|
|
384
513
|
cumulativeBorrowInterest: BN;
|
|
514
|
+
/** SPOT_UTILIZATION_PRECISION (1e6) */
|
|
385
515
|
optimalUtilization: number;
|
|
516
|
+
/** SPOT_RATE_PRECISION (1e6) */
|
|
386
517
|
optimalBorrowRate: number;
|
|
518
|
+
/** SPOT_RATE_PRECISION (1e6) */
|
|
387
519
|
maxBorrowRate: number;
|
|
388
520
|
};
|
|
389
521
|
|
|
522
|
+
/** Emitted when a perp market's AMM curve is adjusted (repeg or `k` update). */
|
|
390
523
|
export type AmmCurveChanged = {
|
|
391
524
|
ts: BN;
|
|
392
525
|
marketIndex: number;
|
|
526
|
+
/** PEG_PRECISION (1e6) */
|
|
393
527
|
pegMultiplierBefore: BN;
|
|
528
|
+
/** AMM_RESERVE_PRECISION (1e9) */
|
|
394
529
|
baseAssetReserveBefore: BN;
|
|
530
|
+
/** AMM_RESERVE_PRECISION (1e9) */
|
|
395
531
|
quoteAssetReserveBefore: BN;
|
|
532
|
+
/** AMM_RESERVE_PRECISION (1e9) */
|
|
396
533
|
sqrtKBefore: BN;
|
|
534
|
+
/** PEG_PRECISION (1e6) */
|
|
397
535
|
pegMultiplierAfter: BN;
|
|
536
|
+
/** AMM_RESERVE_PRECISION (1e9) */
|
|
398
537
|
baseAssetReserveAfter: BN;
|
|
538
|
+
/** AMM_RESERVE_PRECISION (1e9) */
|
|
399
539
|
quoteAssetReserveAfter: BN;
|
|
540
|
+
/** AMM_RESERVE_PRECISION (1e9) */
|
|
400
541
|
sqrtKAfter: BN;
|
|
542
|
+
/** signed cost of the curve adjustment, QUOTE_PRECISION (1e6) */
|
|
401
543
|
adjustmentCost: BN;
|
|
544
|
+
/** QUOTE_PRECISION (1e6) */
|
|
402
545
|
totalFeeMinusDistributionsAfter: BN;
|
|
546
|
+
/** PRICE_PRECISION (1e6) */
|
|
403
547
|
oraclePrice: BN;
|
|
404
548
|
};
|
|
405
549
|
|
|
550
|
+
/** Emitted on insurance-fund vault operations (init/add/request-remove/remove) for a spot market's IF, keyed by the perp market that triggered it when settling a deficit. */
|
|
406
551
|
export declare type InsuranceFundRecord = {
|
|
407
552
|
ts: BN;
|
|
408
553
|
spotMarketIndex: number;
|
|
409
554
|
perpMarketIndex: number;
|
|
555
|
+
/** IF_FACTOR_PRECISION (1e6) share of this action attributed to the user */
|
|
410
556
|
userIfFactor: number;
|
|
557
|
+
/** IF_FACTOR_PRECISION (1e6) total IF factor at the time of the action */
|
|
411
558
|
totalIfFactor: number;
|
|
559
|
+
/** spot market vault token balance before the action, spot market token-mint precision */
|
|
412
560
|
vaultAmountBefore: BN;
|
|
561
|
+
/** insurance-fund vault token balance before the action, spot market token-mint precision */
|
|
413
562
|
insuranceVaultAmountBefore: BN;
|
|
414
563
|
totalIfSharesBefore: BN;
|
|
415
564
|
totalIfSharesAfter: BN;
|
|
565
|
+
/** amount moved, spot market token-mint precision */
|
|
416
566
|
amount: BN;
|
|
417
567
|
};
|
|
418
568
|
|
|
569
|
+
/** Emitted on every `InsuranceFundStake` account mutation (stake, unstake request/cancel, unstake, transfer). */
|
|
419
570
|
export declare type InsuranceFundStakeRecord = {
|
|
420
571
|
ts: BN;
|
|
421
572
|
userAuthority: PublicKey;
|
|
422
573
|
action: StakeAction;
|
|
574
|
+
/** amount staked/unstaked, spot market token-mint precision */
|
|
423
575
|
amount: BN;
|
|
424
576
|
marketIndex: number;
|
|
577
|
+
/** insurance-fund vault token balance before the action, spot market token-mint precision */
|
|
425
578
|
insuranceVaultAmountBefore: BN;
|
|
426
579
|
ifSharesBefore: BN;
|
|
427
580
|
userIfSharesBefore: BN;
|
|
@@ -431,41 +584,61 @@ export declare type InsuranceFundStakeRecord = {
|
|
|
431
584
|
totalIfSharesAfter: BN;
|
|
432
585
|
};
|
|
433
586
|
|
|
587
|
+
/** Emitted every time a perp market's funding rate is updated. */
|
|
434
588
|
export type FundingRateRecord = {
|
|
435
589
|
ts: BN;
|
|
436
590
|
recordId: BN;
|
|
437
591
|
marketIndex: number;
|
|
592
|
+
/** unit is quote per base, FUNDING_RATE_PRECISION (1e9) */
|
|
438
593
|
fundingRate: BN;
|
|
594
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
439
595
|
fundingRateLong: BN;
|
|
596
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
440
597
|
fundingRateShort: BN;
|
|
598
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
441
599
|
cumulativeFundingRateLong: BN;
|
|
600
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
442
601
|
cumulativeFundingRateShort: BN;
|
|
602
|
+
/** PRICE_PRECISION (1e6) */
|
|
443
603
|
oraclePriceTwap: BN;
|
|
604
|
+
/** PRICE_PRECISION (1e6) */
|
|
444
605
|
markPriceTwap: BN;
|
|
606
|
+
/** BASE_PRECISION (1e9) */
|
|
445
607
|
baseAssetAmountWithAmm: BN;
|
|
446
608
|
};
|
|
447
609
|
|
|
610
|
+
/** Emitted whenever a user's perp position settles a funding payment. */
|
|
448
611
|
export type FundingPaymentRecord = {
|
|
449
612
|
ts: BN;
|
|
450
613
|
userAuthority: PublicKey;
|
|
451
614
|
user: PublicKey;
|
|
452
615
|
marketIndex: number;
|
|
616
|
+
/** signed, positive = user received funding; QUOTE_PRECISION (1e6) */
|
|
453
617
|
fundingPayment: BN;
|
|
618
|
+
/** the position size the payment was calculated against, BASE_PRECISION (1e9) */
|
|
454
619
|
baseAssetAmount: BN;
|
|
620
|
+
/** the user's cumulative funding rate prior to this payment, FUNDING_RATE_PRECISION (1e9) */
|
|
455
621
|
userLastCumulativeFunding: BN;
|
|
622
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
456
623
|
ammCumulativeFundingLong: BN;
|
|
624
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
457
625
|
ammCumulativeFundingShort: BN;
|
|
458
626
|
};
|
|
459
627
|
|
|
628
|
+
/** Emitted for every liquidation action. Exactly one of `liquidatePerp`/`liquidateSpot`/`liquidateBorrowForPerpPnl`/`liquidatePerpPnlForDeposit`/`perpBankruptcy`/`spotBankruptcy` is populated, selected by `liquidationType`; the others are left as zeroed defaults. */
|
|
460
629
|
export type LiquidationRecord = {
|
|
461
630
|
ts: BN;
|
|
462
631
|
user: PublicKey;
|
|
463
632
|
liquidator: PublicKey;
|
|
464
633
|
liquidationType: LiquidationType;
|
|
634
|
+
/** QUOTE_PRECISION (1e6) */
|
|
465
635
|
marginRequirement: BN;
|
|
636
|
+
/** signed, QUOTE_PRECISION (1e6) */
|
|
466
637
|
totalCollateral: BN;
|
|
638
|
+
/** cumulative margin freed by this liquidation so far, QUOTE_PRECISION (1e6) */
|
|
467
639
|
marginFreed: BN;
|
|
468
640
|
liquidationId: number;
|
|
641
|
+
/** true if the user was bankrupt (their loss exceeded their collateral) as of this action */
|
|
469
642
|
bankrupt: boolean;
|
|
470
643
|
canceledOrderIds: number[];
|
|
471
644
|
liquidatePerp: LiquidatePerpRecord;
|
|
@@ -474,9 +647,11 @@ export type LiquidationRecord = {
|
|
|
474
647
|
liquidatePerpPnlForDeposit: LiquidatePerpPnlForDepositRecord;
|
|
475
648
|
perpBankruptcy: PerpBankruptcyRecord;
|
|
476
649
|
spotBankruptcy: SpotBankruptcyRecord;
|
|
650
|
+
/** bitmask, see `LiquidationBitFlag` */
|
|
477
651
|
bitFlags: number;
|
|
478
652
|
};
|
|
479
653
|
|
|
654
|
+
/** Which liquidation path a `LiquidationRecord` describes; selects which of the record's sub-record fields is populated. */
|
|
480
655
|
export class LiquidationType {
|
|
481
656
|
static readonly LIQUIDATE_PERP = { liquidatePerp: {} };
|
|
482
657
|
static readonly LIQUIDATE_BORROW_FOR_PERP_PNL = {
|
|
@@ -496,96 +671,141 @@ export class LiquidationType {
|
|
|
496
671
|
};
|
|
497
672
|
}
|
|
498
673
|
|
|
674
|
+
/** Populated on `LiquidationRecord` when `liquidationType` is `LIQUIDATE_PERP`: a perp position was force-closed. */
|
|
499
675
|
export type LiquidatePerpRecord = {
|
|
500
676
|
marketIndex: number;
|
|
677
|
+
/** PRICE_PRECISION (1e6) */
|
|
501
678
|
oraclePrice: BN;
|
|
679
|
+
/** signed size transferred to the liquidator, BASE_PRECISION (1e9) */
|
|
502
680
|
baseAssetAmount: BN;
|
|
681
|
+
/** QUOTE_PRECISION (1e6) */
|
|
503
682
|
quoteAssetAmount: BN;
|
|
504
683
|
userOrderId: number;
|
|
505
684
|
liquidatorOrderId: number;
|
|
506
685
|
fillRecordId: BN;
|
|
686
|
+
/** paid to the liquidator, LIQUIDATOR_FEE_PRECISION (1e6)-denominated rate applied to `quoteAssetAmount`; QUOTE_PRECISION (1e6) amount */
|
|
507
687
|
liquidatorFee: BN;
|
|
688
|
+
/** cut routed to the insurance fund, QUOTE_PRECISION (1e6) */
|
|
508
689
|
ifFee: BN;
|
|
690
|
+
/** cut routed to the protocol fee pool, QUOTE_PRECISION (1e6) */
|
|
509
691
|
protocolFee: BN;
|
|
510
692
|
};
|
|
511
693
|
|
|
694
|
+
/** Populated on `LiquidationRecord` when `liquidationType` is `LIQUIDATE_SPOT`: a spot borrow was liquidated against a spot asset deposit. */
|
|
512
695
|
export type LiquidateSpotRecord = {
|
|
513
696
|
assetMarketIndex: number;
|
|
697
|
+
/** PRICE_PRECISION (1e6) */
|
|
514
698
|
assetPrice: BN;
|
|
699
|
+
/** asset market token-mint precision */
|
|
515
700
|
assetTransfer: BN;
|
|
516
701
|
liabilityMarketIndex: number;
|
|
702
|
+
/** PRICE_PRECISION (1e6) */
|
|
517
703
|
liabilityPrice: BN;
|
|
704
|
+
/** liability market token-mint precision */
|
|
518
705
|
liabilityTransfer: BN;
|
|
706
|
+
/** liability market token-mint precision */
|
|
519
707
|
ifFee: BN;
|
|
708
|
+
/** liability market token-mint precision */
|
|
520
709
|
protocolFee: BN;
|
|
521
710
|
};
|
|
522
711
|
|
|
712
|
+
/** Populated on `LiquidationRecord` when `liquidationType` is `LIQUIDATE_BORROW_FOR_PERP_PNL`: a user's negative perp PnL was covered by seizing one of their spot borrows/deposits. */
|
|
523
713
|
export type LiquidateBorrowForPerpPnlRecord = {
|
|
524
714
|
perpMarketIndex: number;
|
|
715
|
+
/** PRICE_PRECISION (1e6) */
|
|
525
716
|
marketOraclePrice: BN;
|
|
717
|
+
/** QUOTE_PRECISION (1e6) */
|
|
526
718
|
pnlTransfer: BN;
|
|
527
719
|
liabilityMarketIndex: number;
|
|
720
|
+
/** PRICE_PRECISION (1e6) */
|
|
528
721
|
liabilityPrice: BN;
|
|
722
|
+
/** liability market token-mint precision */
|
|
529
723
|
liabilityTransfer: BN;
|
|
530
724
|
};
|
|
531
725
|
|
|
726
|
+
/** Populated on `LiquidationRecord` when `liquidationType` is `LIQUIDATE_PERP_PNL_FOR_DEPOSIT`: a user's positive perp PnL was seized to cover a deficit, paid out from one of their spot deposits. */
|
|
532
727
|
export type LiquidatePerpPnlForDepositRecord = {
|
|
533
728
|
perpMarketIndex: number;
|
|
729
|
+
/** PRICE_PRECISION (1e6) */
|
|
534
730
|
marketOraclePrice: BN;
|
|
731
|
+
/** QUOTE_PRECISION (1e6) */
|
|
535
732
|
pnlTransfer: BN;
|
|
536
733
|
assetMarketIndex: number;
|
|
734
|
+
/** PRICE_PRECISION (1e6) */
|
|
537
735
|
assetPrice: BN;
|
|
736
|
+
/** asset market token-mint precision */
|
|
538
737
|
assetTransfer: BN;
|
|
539
738
|
};
|
|
540
739
|
|
|
740
|
+
/** Populated on `LiquidationRecord` when `liquidationType` is `PERP_BANKRUPTCY`: a user's unpaid perp loss was resolved via insurance-fund payout and/or socialized loss (`clawbackUser`/`clawbackUserPayment` set only when a clawback source exists). */
|
|
541
741
|
export type PerpBankruptcyRecord = {
|
|
542
742
|
marketIndex: number;
|
|
743
|
+
/** the bankrupt (unresolved negative) pnl, signed, QUOTE_PRECISION (1e6) */
|
|
543
744
|
pnl: BN;
|
|
745
|
+
/** amount paid from the insurance fund, QUOTE_PRECISION (1e6) */
|
|
544
746
|
ifPayment: BN;
|
|
545
747
|
clawbackUser: PublicKey | null;
|
|
748
|
+
/** QUOTE_PRECISION (1e6), set only when `clawbackUser` is set */
|
|
546
749
|
clawbackUserPayment: BN | null;
|
|
750
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
547
751
|
cumulativeFundingRateDelta: BN;
|
|
548
752
|
};
|
|
549
753
|
|
|
754
|
+
/** Populated on `LiquidationRecord` when `liquidationType` is `SPOT_BANKRUPTCY`: a user's unpaid spot borrow was resolved via insurance-fund payout and socialized loss. */
|
|
550
755
|
export type SpotBankruptcyRecord = {
|
|
551
756
|
marketIndex: number;
|
|
757
|
+
/** spot market token-mint precision */
|
|
552
758
|
borrowAmount: BN;
|
|
759
|
+
/** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
|
|
553
760
|
cumulativeDepositInterestDelta: BN;
|
|
761
|
+
/** amount paid from the insurance fund, spot market token-mint precision */
|
|
554
762
|
ifPayment: BN;
|
|
555
763
|
};
|
|
556
764
|
|
|
765
|
+
/** Bitmask mirror of `LiquidationRecord.bitFlags`. `IsolatedPosition` marks that the liquidation acted on an isolated-margin position rather than the user's cross-margin account. */
|
|
557
766
|
export class LiquidationBitFlag {
|
|
558
767
|
static readonly IsolatedPosition = 1;
|
|
559
768
|
}
|
|
560
769
|
|
|
770
|
+
/** Emitted every time a user's perp PnL is settled against the market's pnl pool. */
|
|
561
771
|
export type SettlePnlRecord = {
|
|
562
772
|
ts: BN;
|
|
563
773
|
user: PublicKey;
|
|
564
774
|
marketIndex: number;
|
|
775
|
+
/** signed amount settled, QUOTE_PRECISION (1e6) */
|
|
565
776
|
pnl: BN;
|
|
777
|
+
/** the position size at settlement time, BASE_PRECISION (1e9) */
|
|
566
778
|
baseAssetAmount: BN;
|
|
779
|
+
/** `PerpPosition.quoteAssetAmount` after settlement, QUOTE_PRECISION (1e6) */
|
|
567
780
|
quoteAssetAmountAfter: BN;
|
|
781
|
+
/** `PerpPosition.quoteEntryAmount` at settlement time, QUOTE_PRECISION (1e6) */
|
|
568
782
|
quoteEntryAmount: BN;
|
|
783
|
+
/** the price pnl was settled at, PRICE_PRECISION (1e6) */
|
|
569
784
|
settlePrice: BN;
|
|
570
785
|
explanation: SettlePnlExplanation;
|
|
571
786
|
};
|
|
572
787
|
|
|
788
|
+
/** Emitted when a signed off-chain (swift) order message is matched/recorded on-chain, so indexers can associate the signed message with its resulting order. */
|
|
573
789
|
export type SignedMsgOrderRecord = {
|
|
574
790
|
ts: BN;
|
|
575
791
|
user: PublicKey;
|
|
792
|
+
/** hash of the signed message, used to dedupe/look up the original signed order */
|
|
576
793
|
hash: string;
|
|
577
794
|
matchingOrderParams: OrderParams;
|
|
795
|
+
/** slot after which the signed message is no longer eligible to be placed */
|
|
578
796
|
signedMsgOrderMaxSlot: BN;
|
|
579
797
|
signedMsgOrderUuid: Uint8Array;
|
|
580
798
|
userOrderId: number;
|
|
581
799
|
};
|
|
582
800
|
|
|
801
|
+
/** Emitted whenever an `Order` slot is written (placed, updated on fill, canceled, expired, triggered) — a full snapshot of the order's post-action state. */
|
|
583
802
|
export type OrderRecord = {
|
|
584
803
|
ts: BN;
|
|
585
804
|
user: PublicKey;
|
|
586
805
|
order: Order;
|
|
587
806
|
};
|
|
588
807
|
|
|
808
|
+
/** Emitted for every order lifecycle action (place/fill/cancel/expire/trigger). Taker/maker fields are `null` when not applicable to the action (e.g. AMM fills have no `maker`). */
|
|
589
809
|
export type OrderActionRecord = {
|
|
590
810
|
ts: BN;
|
|
591
811
|
action: OrderAction;
|
|
@@ -593,115 +813,176 @@ export type OrderActionRecord = {
|
|
|
593
813
|
marketIndex: number;
|
|
594
814
|
marketType: MarketType;
|
|
595
815
|
filler: PublicKey | null;
|
|
816
|
+
/** paid to the filler/keeper, QUOTE_PRECISION (1e6) */
|
|
596
817
|
fillerReward: BN | null;
|
|
597
818
|
fillRecordId: BN | null;
|
|
819
|
+
/** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
|
|
598
820
|
baseAssetAmountFilled: BN | null;
|
|
821
|
+
/** QUOTE_PRECISION (1e6) */
|
|
599
822
|
quoteAssetAmountFilled: BN | null;
|
|
823
|
+
/** QUOTE_PRECISION (1e6) */
|
|
600
824
|
takerFee: BN | null;
|
|
825
|
+
/** rebate paid to the maker (can be negative if the maker pays a fee), QUOTE_PRECISION (1e6) */
|
|
601
826
|
makerFee: BN | null;
|
|
827
|
+
/** BPS_PRECISION-style share of the taker fee credited to the referrer */
|
|
602
828
|
referrerReward: number | null;
|
|
829
|
+
/** taker's price improvement vs. their limit/oracle price, QUOTE_PRECISION (1e6) */
|
|
603
830
|
quoteAssetAmountSurplus: BN | null;
|
|
831
|
+
/** fee charged by the spot fulfillment method (e.g. an external DEX), spot market token-mint precision */
|
|
604
832
|
spotFulfillmentMethodFee: BN | null;
|
|
605
833
|
taker: PublicKey | null;
|
|
606
834
|
takerOrderId: number | null;
|
|
607
835
|
takerOrderDirection: PositionDirection | null;
|
|
836
|
+
/** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
|
|
608
837
|
takerOrderBaseAssetAmount: BN | null;
|
|
838
|
+
/** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
|
|
609
839
|
takerOrderCumulativeBaseAssetAmountFilled: BN | null;
|
|
840
|
+
/** QUOTE_PRECISION (1e6) */
|
|
610
841
|
takerOrderCumulativeQuoteAssetAmountFilled: BN | null;
|
|
611
842
|
maker: PublicKey | null;
|
|
612
843
|
makerOrderId: number | null;
|
|
613
844
|
makerOrderDirection: PositionDirection | null;
|
|
845
|
+
/** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
|
|
614
846
|
makerOrderBaseAssetAmount: BN | null;
|
|
847
|
+
/** perp: BASE_PRECISION (1e9); spot: market token-mint precision */
|
|
615
848
|
makerOrderCumulativeBaseAssetAmountFilled: BN | null;
|
|
849
|
+
/** QUOTE_PRECISION (1e6) */
|
|
616
850
|
makerOrderCumulativeQuoteAssetAmountFilled: BN | null;
|
|
851
|
+
/** PRICE_PRECISION (1e6) */
|
|
617
852
|
oraclePrice: BN;
|
|
853
|
+
/** bitmask, currently records isolated-margin/builder-fee flags mirrored from `OrderBitFlag` */
|
|
618
854
|
bitFlags: number;
|
|
855
|
+
/** taker's `PerpPosition.quoteEntryAmount` immediately before this fill, QUOTE_PRECISION (1e6) */
|
|
619
856
|
takerExistingQuoteEntryAmount: BN | null;
|
|
857
|
+
/** taker's `PerpPosition.baseAssetAmount` immediately before this fill, BASE_PRECISION (1e9) */
|
|
620
858
|
takerExistingBaseAssetAmount: BN | null;
|
|
859
|
+
/** maker's `PerpPosition.quoteEntryAmount` immediately before this fill, QUOTE_PRECISION (1e6) */
|
|
621
860
|
makerExistingQuoteEntryAmount: BN | null;
|
|
861
|
+
/** maker's `PerpPosition.baseAssetAmount` immediately before this fill, BASE_PRECISION (1e9) */
|
|
622
862
|
makerExistingBaseAssetAmount: BN | null;
|
|
863
|
+
/** PRICE_PRECISION (1e6), set only for trigger-order fills */
|
|
623
864
|
triggerPrice: BN | null;
|
|
865
|
+
/** index into the taker's `RevenueShareEscrow.approvedBuilders`, set only when the taker order had `OrderBitFlag.HasBuilder` */
|
|
624
866
|
builderIdx: number | null;
|
|
867
|
+
/** builder fee charged on this fill, QUOTE_PRECISION (1e6) */
|
|
625
868
|
builderFee: BN | null;
|
|
626
869
|
};
|
|
627
870
|
|
|
871
|
+
/** Emitted on every constant-product spot swap (`beginSwap`/`endSwap`) between two spot markets. */
|
|
628
872
|
export type SwapRecord = {
|
|
629
873
|
ts: BN;
|
|
630
874
|
user: PublicKey;
|
|
875
|
+
/** out market token-mint precision */
|
|
631
876
|
amountOut: BN;
|
|
877
|
+
/** in market token-mint precision */
|
|
632
878
|
amountIn: BN;
|
|
633
879
|
outMarketIndex: number;
|
|
634
880
|
inMarketIndex: number;
|
|
881
|
+
/** PRICE_PRECISION (1e6) */
|
|
635
882
|
outOraclePrice: BN;
|
|
883
|
+
/** PRICE_PRECISION (1e6) */
|
|
636
884
|
inOraclePrice: BN;
|
|
885
|
+
/** total fee charged on the swap, out market token-mint precision */
|
|
637
886
|
fee: BN;
|
|
638
887
|
};
|
|
639
888
|
|
|
889
|
+
/** Emitted when a spot market's vault balance is reconciled against `SpotMarketAccount.depositBalance`/`borrowBalance` (drift/donation detection). */
|
|
640
890
|
export type SpotMarketVaultDepositRecord = {
|
|
641
891
|
ts: BN;
|
|
642
892
|
marketIndex: number;
|
|
893
|
+
/** SPOT_BALANCE_PRECISION (1e9) */
|
|
643
894
|
depositBalance: BN;
|
|
895
|
+
/** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
|
|
644
896
|
cumulativeDepositInterestBefore: BN;
|
|
897
|
+
/** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
|
|
645
898
|
cumulativeDepositInterestAfter: BN;
|
|
899
|
+
/** spot market token-mint precision */
|
|
646
900
|
depositTokenAmountBefore: BN;
|
|
901
|
+
/** spot market token-mint precision */
|
|
647
902
|
amount: BN;
|
|
648
903
|
};
|
|
649
904
|
|
|
905
|
+
/** Emitted when a `UserAccount` sub-account is deleted. */
|
|
650
906
|
export type DeleteUserRecord = {
|
|
651
907
|
ts: BN;
|
|
652
908
|
userAuthority: PublicKey;
|
|
653
909
|
user: PublicKey;
|
|
654
910
|
subAccountId: number;
|
|
911
|
+
/** set when a keeper (not the user/delegate) deleted an idle account */
|
|
655
912
|
keeper: PublicKey | null;
|
|
656
913
|
};
|
|
657
914
|
|
|
915
|
+
/** Emitted on every constituent-to-constituent swap inside an LP pool (`LPPoolAccount`). */
|
|
658
916
|
export type LPSwapRecord = {
|
|
659
917
|
ts: BN;
|
|
660
918
|
slot: BN;
|
|
661
919
|
authority: PublicKey;
|
|
920
|
+
/** out constituent's spot market token-mint precision */
|
|
662
921
|
outAmount: BN;
|
|
922
|
+
/** in constituent's spot market token-mint precision */
|
|
663
923
|
inAmount: BN;
|
|
924
|
+
/** out constituent's spot market token-mint precision */
|
|
664
925
|
outFee: BN;
|
|
926
|
+
/** in constituent's spot market token-mint precision */
|
|
665
927
|
inFee: BN;
|
|
666
928
|
outSpotMarketIndex: number;
|
|
667
929
|
inSpotMarketIndex: number;
|
|
668
930
|
outConstituentIndex: number;
|
|
669
931
|
inConstituentIndex: number;
|
|
932
|
+
/** PRICE_PRECISION (1e6) */
|
|
670
933
|
outOraclePrice: BN;
|
|
934
|
+
/** PRICE_PRECISION (1e6) */
|
|
671
935
|
inOraclePrice: BN;
|
|
936
|
+
/** LP pool AUM at the time of the swap, QUOTE_PRECISION (1e6) */
|
|
672
937
|
lastAum: BN;
|
|
673
938
|
lastAumSlot: BN;
|
|
939
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
674
940
|
inMarketCurrentWeight: BN;
|
|
941
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
675
942
|
outMarketCurrentWeight: BN;
|
|
943
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
676
944
|
inMarketTargetWeight: BN;
|
|
945
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
677
946
|
outMarketTargetWeight: BN;
|
|
678
947
|
inSwapId: BN;
|
|
679
948
|
outSwapId: BN;
|
|
680
949
|
lpPool: PublicKey;
|
|
681
950
|
};
|
|
682
951
|
|
|
952
|
+
/** Emitted when LP tokens are minted (deposit) or redeemed (withdraw) against an LP pool. */
|
|
683
953
|
export type LPMintRedeemRecord = {
|
|
684
954
|
ts: BN;
|
|
685
955
|
slot: BN;
|
|
686
956
|
authority: PublicKey;
|
|
957
|
+
/** encodes mint vs. redeem (and any sub-variant); compare against the program's `MintRedeemDescription` discriminant */
|
|
687
958
|
description: number;
|
|
959
|
+
/** constituent spot market token-mint precision */
|
|
688
960
|
amount: BN;
|
|
961
|
+
/** constituent spot market token-mint precision */
|
|
689
962
|
fee: BN;
|
|
690
963
|
spotMarketIndex: number;
|
|
691
964
|
constituentIndex: number;
|
|
965
|
+
/** PRICE_PRECISION (1e6) */
|
|
692
966
|
oraclePrice: BN;
|
|
693
967
|
mint: PublicKey;
|
|
968
|
+
/** LP token precision (quote-mint precision, QUOTE_PRECISION 1e6) */
|
|
694
969
|
lpAmount: BN;
|
|
970
|
+
/** LP token precision */
|
|
695
971
|
lpFee: BN;
|
|
972
|
+
/** LP token price, PRICE_PRECISION (1e6) */
|
|
696
973
|
lpPrice: BN;
|
|
697
974
|
mintRedeemId: BN;
|
|
975
|
+
/** LP pool AUM at the time of the action, QUOTE_PRECISION (1e6) */
|
|
698
976
|
lastAum: BN;
|
|
699
977
|
lastAumSlot: BN;
|
|
978
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
700
979
|
inMarketCurrentWeight: BN;
|
|
980
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
701
981
|
inMarketTargetWeight: BN;
|
|
702
982
|
lpPool: PublicKey;
|
|
703
983
|
};
|
|
704
984
|
|
|
985
|
+
/** Emitted when a perp market settles PnL/fees with its hedging LP pool. */
|
|
705
986
|
export type LPSettleRecord = {
|
|
706
987
|
recordId: BN;
|
|
707
988
|
lastTs: BN;
|
|
@@ -709,27 +990,55 @@ export type LPSettleRecord = {
|
|
|
709
990
|
ts: BN;
|
|
710
991
|
slot: BN;
|
|
711
992
|
perpMarketIndex: number;
|
|
993
|
+
/** signed amount transferred to/from the LP pool, QUOTE_PRECISION (1e6) */
|
|
712
994
|
settleToLpAmount: BN;
|
|
995
|
+
/** signed, QUOTE_PRECISION (1e6) */
|
|
713
996
|
perpAmmPnlDelta: BN;
|
|
997
|
+
/** signed, QUOTE_PRECISION (1e6) */
|
|
714
998
|
perpAmmExFeeDelta: BN;
|
|
999
|
+
/** LP pool AUM after this settle, QUOTE_PRECISION (1e6) */
|
|
715
1000
|
lpAum: BN;
|
|
1001
|
+
/** LP token price after this settle, PRICE_PRECISION (1e6) */
|
|
716
1002
|
lpPrice: BN;
|
|
717
1003
|
lpPool: PublicKey;
|
|
718
1004
|
};
|
|
719
1005
|
|
|
1006
|
+
/** Emitted when an LP pool constituent's borrow/lend deposit into (or withdrawal from) the underlying spot market changes. */
|
|
720
1007
|
export type LPBorrowLendDepositRecord = {
|
|
721
1008
|
ts: BN;
|
|
722
1009
|
slot: BN;
|
|
723
1010
|
spotMarketIndex: number;
|
|
724
1011
|
constituentIndex: number;
|
|
725
1012
|
direction: DepositDirection;
|
|
1013
|
+
/** constituent spot market token-mint precision */
|
|
726
1014
|
tokenBalance: BN;
|
|
1015
|
+
/** constituent spot market token-mint precision */
|
|
727
1016
|
lastTokenBalance: BN;
|
|
1017
|
+
/** interest accrued since the last update, constituent spot market token-mint precision */
|
|
728
1018
|
interestAccruedTokenAmount: BN;
|
|
1019
|
+
/** constituent spot market token-mint precision */
|
|
729
1020
|
amountDepositWithdraw: BN;
|
|
730
1021
|
lpPool: PublicKey;
|
|
731
1022
|
};
|
|
732
1023
|
|
|
1024
|
+
/**
|
|
1025
|
+
* The protocol's single global config account (one per deployment). Decoded mirror of the Rust
|
|
1026
|
+
* `State` zero-copy account.
|
|
1027
|
+
*
|
|
1028
|
+
* **Admin tiers** — three levels of authority, from slowest/most-trusted to fastest/least-trusted:
|
|
1029
|
+
* - `coldAdmin`: root authority, set once at `initialize`. Only key that can rotate `warmAdmin`
|
|
1030
|
+
* and `pauseAdmin`. Expected to sit behind a (small) timelocked multisig.
|
|
1031
|
+
* - `warmAdmin`: operational authority that can rotate the eleven `hot*` bot keys below.
|
|
1032
|
+
* `PublicKey.default()` means unset, in which case only `coldAdmin` can act.
|
|
1033
|
+
* - `pauseAdmin`: emergency-pause authority with no on-chain timelock — may only *add* pause bits
|
|
1034
|
+
* to `exchangeStatus` (never clear them); `coldAdmin`/`warmAdmin` retain full pause+unpause power.
|
|
1035
|
+
* `PublicKey.default()` means unassigned (only cold/warm can pause).
|
|
1036
|
+
*
|
|
1037
|
+
* **Hot role keys** (`hot*`): purpose-specific bot keys for high-frequency keeper actions (AMM
|
|
1038
|
+
* cranking, LP cache/swap/settle, feature-flag toggles, fuel, user-flag updates, vault deposits,
|
|
1039
|
+
* mm-oracle cranking, AMM spread adjustment, protocol-fee withdrawal). `PublicKey.default()` means
|
|
1040
|
+
* the role is unassigned and only `warmAdmin`/`coldAdmin` may call handlers gated on that role.
|
|
1041
|
+
*/
|
|
733
1042
|
export type StateAccount = {
|
|
734
1043
|
coldAdmin: PublicKey;
|
|
735
1044
|
warmAdmin: PublicKey;
|
|
@@ -744,9 +1053,13 @@ export type StateAccount = {
|
|
|
744
1053
|
hotVaultDeposit: PublicKey;
|
|
745
1054
|
hotMmOracleCrank: PublicKey;
|
|
746
1055
|
hotAmmSpreadAdjust: PublicKey;
|
|
1056
|
+
/** hot key authorized to trigger protocol-fee withdrawals to `protocolFeeRecipientPerp`/`protocolFeeRecipientSpot` */
|
|
747
1057
|
hotFeeWithdraw: PublicKey;
|
|
1058
|
+
/** treasury PERP protocol fees are withdrawn to (settable only by `coldAdmin`); `PublicKey.default()` makes perp fee withdrawals inert */
|
|
748
1059
|
protocolFeeRecipientPerp: PublicKey;
|
|
1060
|
+
/** treasury SPOT protocol fees are withdrawn to (settable only by `coldAdmin`); `PublicKey.default()` makes spot fee withdrawals inert */
|
|
749
1061
|
protocolFeeRecipientSpot: PublicKey;
|
|
1062
|
+
/** bitmask, see `ExchangeStatus` */
|
|
750
1063
|
exchangeStatus: number;
|
|
751
1064
|
whitelistMint: PublicKey;
|
|
752
1065
|
discountMint: PublicKey;
|
|
@@ -755,120 +1068,195 @@ export type StateAccount = {
|
|
|
755
1068
|
numberOfSubAccounts: BN;
|
|
756
1069
|
numberOfMarkets: number;
|
|
757
1070
|
numberOfSpotMarkets: number;
|
|
1071
|
+
/** slots */
|
|
758
1072
|
minPerpAuctionDuration: number;
|
|
1073
|
+
/** seconds */
|
|
759
1074
|
defaultMarketOrderTimeInForce: number;
|
|
1075
|
+
/** slots */
|
|
760
1076
|
defaultSpotAuctionDuration: number;
|
|
1077
|
+
/** MARGIN_PRECISION (1e4); extra maintenance-margin buffer required before a liquidation may proceed */
|
|
761
1078
|
liquidationMarginBufferRatio: number;
|
|
1079
|
+
/** seconds a market stays in `SETTLEMENT` status before positions must be settled */
|
|
762
1080
|
settlementDuration: number;
|
|
763
1081
|
maxNumberOfSubAccounts: number;
|
|
764
1082
|
signer: PublicKey;
|
|
765
1083
|
signerNonce: number;
|
|
766
1084
|
srmVault: PublicKey;
|
|
1085
|
+
/** default `FeeStructure` applied to new perp markets */
|
|
767
1086
|
perpFeeStructure: FeeStructure;
|
|
1087
|
+
/** default `FeeStructure` applied to new spot markets */
|
|
768
1088
|
spotFeeStructure: FeeStructure;
|
|
1089
|
+
/** LIQUIDATION_PCT_PRECISION (1e4); fraction of a position liquidated per partial-liquidation pass */
|
|
769
1090
|
initialPctToLiquidate: number;
|
|
1091
|
+
/** seconds a liquidation is spread over */
|
|
770
1092
|
liquidationDuration: number;
|
|
1093
|
+
/** max SOL fee `getInitUserFee` may charge to create a new sub-account, in value/100 SOL (e.g. 100 = 1 SOL); ramps from 0 to this max as account-space utilization rises from 80% to 100% of `maxNumberOfSubAccounts` */
|
|
771
1094
|
maxInitializeUserFee: number;
|
|
1095
|
+
/** bitmask, see `FeatureBitFlags` */
|
|
772
1096
|
featureBitFlags: number;
|
|
1097
|
+
/** bitmask of LP-pool-specific feature flags */
|
|
773
1098
|
lpPoolFeatureBitFlags: number;
|
|
1099
|
+
/** bitmask, see `SolvencyStatus` */
|
|
1100
|
+
solvencyStatus: number;
|
|
774
1101
|
};
|
|
775
1102
|
|
|
1103
|
+
/** Decoded mirror of the on-chain `PerpMarket` zero-copy account. */
|
|
776
1104
|
export type PerpMarketAccount = {
|
|
777
1105
|
status: MarketStatus;
|
|
778
1106
|
contractType: ContractType;
|
|
779
1107
|
contractTier: ContractTier;
|
|
1108
|
+
/** unix timestamp the market will expire; only set if the market is reduce-only */
|
|
780
1109
|
expiryTs: BN;
|
|
1110
|
+
/** PRICE_PRECISION (1e6); the price positions settle at, only set once the market is expired */
|
|
781
1111
|
expiryPrice: BN;
|
|
782
1112
|
marketIndex: number;
|
|
783
1113
|
pubkey: PublicKey;
|
|
784
1114
|
name: number[];
|
|
1115
|
+
/** the market's constant-product vAMM state */
|
|
785
1116
|
amm: AMM;
|
|
1117
|
+
/** market-wide stats shared across all makers (mark/oracle TWAPs, volume, mm-oracle snapshot) */
|
|
786
1118
|
marketStats: MarketStats;
|
|
787
1119
|
numberOfUsersWithBase: number;
|
|
788
1120
|
numberOfUsers: number;
|
|
1121
|
+
/** MARGIN_PRECISION (1e4); collateral fraction required to open a position, e.g. 1000 = 10% = 10x max leverage */
|
|
789
1122
|
marginRatioInitial: number;
|
|
1123
|
+
/** MARGIN_PRECISION (1e4); collateral fraction below which a position is liquidated */
|
|
790
1124
|
marginRatioMaintenance: number;
|
|
791
1125
|
nextFillRecordId: BN;
|
|
792
1126
|
nextFundingRateRecordId: BN;
|
|
1127
|
+
/** the market's pnl pool: increases when users settle negative pnl, decreases when users settle positive pnl; SPOT_BALANCE_PRECISION (1e9) scaled balance in the quote spot market */
|
|
793
1128
|
pnlPool: PoolBalance;
|
|
1129
|
+
/** protocol-owned quote-denominated fee claim, withdrawn to `StateAccount.protocolFeeRecipientPerp`; SPOT_BALANCE_PRECISION (1e9) scaled balance */
|
|
794
1130
|
protocolFeePool: PoolBalance;
|
|
1131
|
+
/** consolidated fee-split accounting: lifetime analytics counters plus pending protocol/IF/AMM carveouts */
|
|
795
1132
|
feeLedger: FeeLedger;
|
|
1133
|
+
/** LIQUIDATOR_FEE_PRECISION (1e6); fee paid to the liquidator for taking over the position */
|
|
796
1134
|
liquidatorFee: number;
|
|
1135
|
+
/** LIQUIDATOR_FEE_PRECISION (1e6); cut of a liquidation routed to the insurance fund */
|
|
797
1136
|
ifLiquidationFee: number;
|
|
1137
|
+
/** LIQUIDATOR_FEE_PRECISION (1e6); protocol's cut of a liquidation, taken from the liquidatee */
|
|
798
1138
|
protocolLiquidationFee: number;
|
|
1139
|
+
/** QUOTE_PRECISION (1e6); pnl-pool retention buffer the fee-sweep leaves untouched above `max(net_user_pnl, 0)` */
|
|
799
1140
|
feePoolBufferTarget: BN;
|
|
1141
|
+
/** MARGIN_PRECISION (1e4); scales margin ratio up for large positions */
|
|
800
1142
|
imfFactor: number;
|
|
1143
|
+
/** MARGIN_PRECISION (1e4); discounts positive-unrealized-pnl asset weight for large positions */
|
|
801
1144
|
unrealizedPnlImfFactor: number;
|
|
1145
|
+
/** QUOTE_PRECISION (1e6); pnl imbalance (long pnl − short pnl) above which positive-pnl asset weight starts being discounted */
|
|
802
1146
|
unrealizedPnlMaxImbalance: BN;
|
|
1147
|
+
/** SPOT_WEIGHT_PRECISION (1e4); initial-margin asset weight applied to a user's unrealized positive pnl */
|
|
803
1148
|
unrealizedPnlInitialAssetWeight: number;
|
|
1149
|
+
/** SPOT_WEIGHT_PRECISION (1e4); maintenance-margin asset weight applied to a user's unrealized positive pnl */
|
|
804
1150
|
unrealizedPnlMaintenanceAssetWeight: number;
|
|
1151
|
+
/** the market's claim on the insurance fund */
|
|
805
1152
|
insuranceClaim: {
|
|
1153
|
+
/** QUOTE_PRECISION (1e6), signed: positive if funds left the market, negative if pulled in */
|
|
806
1154
|
revenueWithdrawSinceLastSettle: BN;
|
|
1155
|
+
/** QUOTE_PRECISION (1e6); cap on revenue withdrawable per settle period */
|
|
807
1156
|
maxRevenueWithdrawPerPeriod: BN;
|
|
808
1157
|
lastRevenueWithdrawTs: BN;
|
|
1158
|
+
/** QUOTE_PRECISION (1e6); insurance already used to resolve bankruptcy/pnl deficits */
|
|
809
1159
|
quoteSettledInsurance: BN;
|
|
1160
|
+
/** QUOTE_PRECISION (1e6); max insurance this market may draw to resolve bankruptcy/pnl deficits */
|
|
810
1161
|
quoteMaxInsurance: BN;
|
|
811
1162
|
};
|
|
812
1163
|
quoteSpotMarketIndex: number;
|
|
1164
|
+
/** -100 to 100; percentage adjustment applied to the base fee rate (e.g. -50 halves a 5bps fee to 2.5bps) */
|
|
813
1165
|
feeAdjustment: number;
|
|
1166
|
+
/** bitmask, see `PerpOperation` */
|
|
814
1167
|
pausedOperations: number;
|
|
815
1168
|
|
|
1169
|
+
/** PRICE_PRECISION (1e6); price of the most recent fill */
|
|
816
1170
|
lastFillPrice: BN;
|
|
817
1171
|
poolId: number;
|
|
818
1172
|
|
|
1173
|
+
/** this market's relationship to its hedging LP pool; admin-set, never mutated per fill */
|
|
819
1174
|
hedgeConfig: {
|
|
1175
|
+
/** the `LPPoolAccount.lpPoolId` this market hedges into */
|
|
820
1176
|
poolId: number;
|
|
1177
|
+
/** hedging enabled for this market when non-zero */
|
|
821
1178
|
status: number;
|
|
1179
|
+
/** bitmask of paused `ConstituentLpOperation`s */
|
|
822
1180
|
pausedOperations: number;
|
|
1181
|
+
/** scalar excluding a share of exchange fees from hedge routing */
|
|
823
1182
|
exchangeFeeExclusionScalar: number;
|
|
1183
|
+
/** scalar for the share of fees transferred to the hedge pool */
|
|
824
1184
|
feeTransferScalar: number;
|
|
825
1185
|
};
|
|
1186
|
+
/** bitmask, see `MarketConfigFlag` */
|
|
826
1187
|
marketConfig: number;
|
|
827
1188
|
|
|
828
1189
|
// Fields migrated off AMM to top-level PerpMarket
|
|
829
1190
|
oracle: PublicKey;
|
|
830
1191
|
oracleSource: OracleSource;
|
|
1192
|
+
/** override for the per-fill slot delay required from the oracle; -1 = use the state default */
|
|
831
1193
|
oracleSlotDelayOverride: number;
|
|
1194
|
+
/** override for `StateAccount.minPerpAuctionDuration`; 0 = no override, -1 = disable speed bump, 1-100 = literal speed bump slots */
|
|
832
1195
|
oracleLowRiskSlotDelayOverride: number;
|
|
1196
|
+
/** always non-negative; total long open interest across all users, BASE_PRECISION (1e9) */
|
|
833
1197
|
baseAssetAmountLong: BN;
|
|
1198
|
+
/** always non-positive; total short open interest across all users, BASE_PRECISION (1e9) */
|
|
834
1199
|
baseAssetAmountShort: BN;
|
|
1200
|
+
/** sum of all users' `PerpPosition.quoteAssetAmount` in this market, QUOTE_PRECISION (1e6) */
|
|
835
1201
|
quoteAssetAmount: BN;
|
|
1202
|
+
/** QUOTE_PRECISION (1e6) */
|
|
836
1203
|
quoteEntryAmountLong: BN;
|
|
1204
|
+
/** QUOTE_PRECISION (1e6) */
|
|
837
1205
|
quoteEntryAmountShort: BN;
|
|
1206
|
+
/** QUOTE_PRECISION (1e6) */
|
|
838
1207
|
quoteBreakEvenAmountLong: BN;
|
|
1208
|
+
/** QUOTE_PRECISION (1e6) */
|
|
839
1209
|
quoteBreakEvenAmountShort: BN;
|
|
1210
|
+
/** QUOTE_PRECISION (1e6); accumulated socialized loss paid by users in this market since inception */
|
|
840
1211
|
totalSocialLoss: BN;
|
|
1212
|
+
/** BASE_PRECISION (1e9); max allowed open interest — trades that would breach this are blocked */
|
|
841
1213
|
maxOpenInterest: BN;
|
|
1214
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
842
1215
|
cumulativeFundingRateLong: BN;
|
|
1216
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
843
1217
|
cumulativeFundingRateShort: BN;
|
|
1218
|
+
/** unit is quote per base, FUNDING_RATE_PRECISION (1e9) */
|
|
844
1219
|
lastFundingRate: BN;
|
|
1220
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
845
1221
|
lastFundingRateLong: BN;
|
|
1222
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
846
1223
|
lastFundingRateShort: BN;
|
|
847
1224
|
lastFundingRateTs: BN;
|
|
1225
|
+
/** unsettled funding pnl across the whole market */
|
|
848
1226
|
netUnsettledFundingPnl: BN;
|
|
1227
|
+
/** BPS_PRECISION (1e4); dead-zone threshold for the funding premium — mark/oracle spreads within this band add no funding premium */
|
|
849
1228
|
fundingClampThreshold: number;
|
|
1229
|
+
/** PERCENTAGE_PRECISION (1e6); slope of the funding premium ramp above the dead zone (1.0x = pass shrunk spread through unchanged) */
|
|
850
1230
|
fundingRampSlope: number;
|
|
1231
|
+
/** orders must be a multiple of this, BASE_PRECISION (1e9) */
|
|
851
1232
|
orderStepSize: BN;
|
|
1233
|
+
/** orders must be a multiple of this, PRICE_PRECISION (1e6) */
|
|
852
1234
|
orderTickSize: BN;
|
|
853
1235
|
};
|
|
854
1236
|
|
|
1237
|
+
/** Oracle price/TWAP snapshot shared by `PerpMarketAccount.marketStats` and `SpotMarketAccount`. All price fields are PRICE_PRECISION (1e6). */
|
|
855
1238
|
export type HistoricalOracleData = {
|
|
856
1239
|
lastOraclePrice: BN;
|
|
1240
|
+
/** number of slots since the last oracle update */
|
|
857
1241
|
lastOracleDelay: BN;
|
|
858
1242
|
lastOracleConf: BN;
|
|
859
1243
|
lastOraclePriceTwap: BN;
|
|
860
1244
|
lastOraclePriceTwap5Min: BN;
|
|
1245
|
+
/** unix timestamp of the last TWAP snapshot */
|
|
861
1246
|
lastOraclePriceTwapTs: BN;
|
|
862
1247
|
};
|
|
863
1248
|
|
|
1249
|
+
/** Rolling index-price stats for a spot market (bid/ask/TWAP of the underlying index, e.g. a basket or peg reference). All price fields are PRICE_PRECISION (1e6). */
|
|
864
1250
|
export type HistoricalIndexData = {
|
|
865
1251
|
lastIndexBidPrice: BN;
|
|
866
1252
|
lastIndexAskPrice: BN;
|
|
867
1253
|
lastIndexPriceTwap: BN;
|
|
868
1254
|
lastIndexPriceTwap5Min: BN;
|
|
1255
|
+
/** unix timestamp of the last TWAP snapshot */
|
|
869
1256
|
lastIndexPriceTwapTs: BN;
|
|
870
1257
|
};
|
|
871
1258
|
|
|
1259
|
+
/** Decoded mirror of the on-chain `SpotMarket` zero-copy account. */
|
|
872
1260
|
export type SpotMarketAccount = {
|
|
873
1261
|
status: MarketStatus;
|
|
874
1262
|
assetTier: AssetTier;
|
|
@@ -877,6 +1265,7 @@ export type SpotMarketAccount = {
|
|
|
877
1265
|
marketIndex: number;
|
|
878
1266
|
pubkey: PublicKey;
|
|
879
1267
|
mint: PublicKey;
|
|
1268
|
+
/** the market's token vault; balance should be >= `depositBalance` token amount − `borrowBalance` token amount */
|
|
880
1269
|
vault: PublicKey;
|
|
881
1270
|
|
|
882
1271
|
oracle: PublicKey;
|
|
@@ -884,253 +1273,400 @@ export type SpotMarketAccount = {
|
|
|
884
1273
|
historicalOracleData: HistoricalOracleData;
|
|
885
1274
|
historicalIndexData: HistoricalIndexData;
|
|
886
1275
|
|
|
1276
|
+
/** covers bankruptcies for borrows of this market's token and perps settling in this market's token */
|
|
887
1277
|
insuranceFund: {
|
|
888
1278
|
vault: PublicKey;
|
|
889
1279
|
totalShares: BN;
|
|
890
1280
|
userShares: BN;
|
|
1281
|
+
/** exponent used to rebase `totalShares`/`userShares` */
|
|
891
1282
|
sharesBase: BN;
|
|
1283
|
+
/** seconds a stake must wait after an unstake request before it can be withdrawn */
|
|
892
1284
|
unstakingPeriod: BN;
|
|
893
1285
|
lastRevenueSettleTs: BN;
|
|
1286
|
+
/** seconds; how often `revenuePool` may settle into the IF vault */
|
|
894
1287
|
revenueSettlePeriod: BN;
|
|
1288
|
+
/** IF_FACTOR_PRECISION (1e6); fraction of spot deposit-interest gains carved out to the (100% staker-owned) insurance fund */
|
|
895
1289
|
ifFeeFactor: number;
|
|
896
1290
|
};
|
|
897
1291
|
|
|
1292
|
+
/** revenue this market's token has collected (e.g. for SOL-PERP, settled funds flow into the USDC revenue pool); SPOT_BALANCE_PRECISION (1e9) scaled balance */
|
|
898
1293
|
revenuePool: PoolBalance;
|
|
1294
|
+
/** protocol-owned fee claim in this market's token, withdrawn to `StateAccount.protocolFeeRecipientSpot`; SPOT_BALANCE_PRECISION (1e9) scaled balance */
|
|
899
1295
|
protocolFeePool: PoolBalance;
|
|
900
1296
|
|
|
1297
|
+
/** LIQUIDATOR_FEE_PRECISION (1e6); cut of a liquidation routed to the insurance fund */
|
|
901
1298
|
ifLiquidationFee: number;
|
|
1299
|
+
/** LIQUIDATOR_FEE_PRECISION (1e6); protocol's cut of a spot liquidation, taken from the liquidatee */
|
|
902
1300
|
protocolLiquidationFee: number;
|
|
1301
|
+
/** IF_FACTOR_PRECISION (1e6); protocol's carveout of lending deposit-interest gains */
|
|
903
1302
|
protocolFeeFactor: number;
|
|
904
1303
|
|
|
1304
|
+
/** token mint decimals; token-mint precision throughout this account is 10^decimals */
|
|
905
1305
|
decimals: number;
|
|
1306
|
+
/** SPOT_UTILIZATION_PRECISION (1e6) */
|
|
906
1307
|
optimalUtilization: number;
|
|
1308
|
+
/** SPOT_RATE_PRECISION (1e6); borrow rate when the market is at `optimalUtilization` */
|
|
907
1309
|
optimalBorrowRate: number;
|
|
1310
|
+
/** SPOT_RATE_PRECISION (1e6); borrow rate at 100% utilization */
|
|
908
1311
|
maxBorrowRate: number;
|
|
1312
|
+
/** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
|
|
909
1313
|
cumulativeDepositInterest: BN;
|
|
1314
|
+
/** SPOT_CUMULATIVE_INTEREST_PRECISION (1e10) */
|
|
910
1315
|
cumulativeBorrowInterest: BN;
|
|
1316
|
+
/** token mint precision; accumulated socialized loss from borrows, in this market's own token */
|
|
911
1317
|
totalSocialLoss: BN;
|
|
1318
|
+
/** QUOTE_PRECISION (1e6); accumulated socialized loss from borrows, converted to quote */
|
|
912
1319
|
totalQuoteSocialLoss: BN;
|
|
1320
|
+
/** SPOT_BALANCE_PRECISION (1e9) scaled balance; multiply by `cumulativeDepositInterest` for the token amount */
|
|
913
1321
|
depositBalance: BN;
|
|
1322
|
+
/** SPOT_BALANCE_PRECISION (1e9) scaled balance; multiply by `cumulativeBorrowInterest` for the token amount */
|
|
914
1323
|
borrowBalance: BN;
|
|
1324
|
+
/** token mint precision; 0 = no limit */
|
|
915
1325
|
maxTokenDeposits: BN;
|
|
916
1326
|
|
|
917
1327
|
lastInterestTs: BN;
|
|
918
1328
|
lastTwapTs: BN;
|
|
1329
|
+
/** unix timestamp the market is set to expire; only set if reduce-only */
|
|
919
1330
|
expiryTs: BN;
|
|
1331
|
+
/** SPOT_WEIGHT_PRECISION (1e4); e.g. 8000 (.8) means $100 of deposits contributes $80 to initial collateral */
|
|
920
1332
|
initialAssetWeight: number;
|
|
1333
|
+
/** SPOT_WEIGHT_PRECISION (1e4); e.g. 9000 (.9) means $100 of deposits contributes $90 to maintenance collateral */
|
|
921
1334
|
maintenanceAssetWeight: number;
|
|
1335
|
+
/** SPOT_WEIGHT_PRECISION (1e4); e.g. 9000 (.9) means $100 of borrows contributes $90 to the initial margin requirement */
|
|
922
1336
|
initialLiabilityWeight: number;
|
|
1337
|
+
/** SPOT_WEIGHT_PRECISION (1e4); e.g. 8000 (.8) means $100 of borrows contributes $80 to the maintenance margin requirement */
|
|
923
1338
|
maintenanceLiabilityWeight: number;
|
|
1339
|
+
/** LIQUIDATOR_FEE_PRECISION (1e6); fee paid to the liquidator for taking over the borrow/deposit */
|
|
924
1340
|
liquidatorFee: number;
|
|
1341
|
+
/** MARGIN_PRECISION (1e4); scales liability weight up / asset weight down for large positions */
|
|
925
1342
|
imfFactor: number;
|
|
1343
|
+
/** QUOTE_PRECISION (1e6); deposit level at which `initialAssetWeight` begins scaling down; 0 = disabled */
|
|
926
1344
|
scaleInitialAssetWeightStart: BN;
|
|
927
1345
|
|
|
1346
|
+
/** token mint precision; below this vault balance, no withdraw limits/guards apply */
|
|
928
1347
|
withdrawGuardThreshold: BN;
|
|
1348
|
+
/** token mint precision; 24h rolling average of deposit token amount */
|
|
929
1349
|
depositTokenTwap: BN;
|
|
1350
|
+
/** token mint precision; 24h rolling average of borrow token amount */
|
|
930
1351
|
borrowTokenTwap: BN;
|
|
1352
|
+
/** SPOT_UTILIZATION_PRECISION (1e6); 24h rolling average utilization (borrow / total) */
|
|
931
1353
|
utilizationTwap: BN;
|
|
932
1354
|
nextDepositRecordId: BN;
|
|
933
1355
|
|
|
1356
|
+
/** orders must be a multiple of this, token mint precision */
|
|
934
1357
|
orderStepSize: BN;
|
|
1358
|
+
/** orders must be a multiple of this, PRICE_PRECISION (1e6) */
|
|
935
1359
|
orderTickSize: BN;
|
|
1360
|
+
/** token mint precision */
|
|
936
1361
|
minOrderSize: BN;
|
|
1362
|
+
/** token mint precision; 0 = no limit */
|
|
937
1363
|
maxPositionSize: BN;
|
|
938
1364
|
nextFillRecordId: BN;
|
|
1365
|
+
/** fees collected from swaps between this market and the quote market, settled to the quote market's revenue pool; SPOT_BALANCE_PRECISION (1e9) scaled balance */
|
|
939
1366
|
spotFeePool: PoolBalance;
|
|
1367
|
+
/** QUOTE_PRECISION (1e6) */
|
|
940
1368
|
totalSpotFee: BN;
|
|
1369
|
+
/** token mint precision; total fees received from swaps */
|
|
941
1370
|
totalSwapFee: BN;
|
|
942
1371
|
|
|
1372
|
+
/** token mint precision; amount loaned out in `beginSwap`, for the in-flight flash-loan invariant check */
|
|
943
1373
|
flashLoanAmount: BN;
|
|
1374
|
+
/** token mint precision; user's token balance snapshotted at `beginSwap`, used to compute how much left the system by `endSwap` */
|
|
944
1375
|
flashLoanInitialTokenAmount: BN;
|
|
945
1376
|
|
|
946
1377
|
ordersEnabled: boolean;
|
|
947
1378
|
|
|
1379
|
+
/** bitmask, see `SpotOperation` */
|
|
948
1380
|
pausedOperations: number;
|
|
949
1381
|
|
|
1382
|
+
/** bitmask, see `InsuranceFundOperation` */
|
|
950
1383
|
ifPausedOperations: number;
|
|
951
1384
|
|
|
1385
|
+
/** X/10000; fraction of `maxTokenDeposits` that may be borrowed in total; 0 disables the cap */
|
|
952
1386
|
maxTokenBorrowsFraction: number;
|
|
1387
|
+
/** X/200; floor borrow rate regardless of utilization */
|
|
953
1388
|
minBorrowRate: number;
|
|
954
1389
|
|
|
1390
|
+
/** bitmask, see `TokenProgramFlag` */
|
|
955
1391
|
tokenProgramFlag: number;
|
|
956
1392
|
|
|
957
1393
|
poolId: number;
|
|
958
1394
|
|
|
1395
|
+
/** -100 to 100; percentage adjustment applied to the base fee rate */
|
|
959
1396
|
feeAdjustment: number;
|
|
960
1397
|
};
|
|
961
1398
|
|
|
1399
|
+
/** A scaled token balance inside a market's internal pools (pnl pool, protocol fee pool, revenue pool, spot fee pool, AMM fee pool). Multiply `scaledBalance` (SPOT_BALANCE_PRECISION, 1e9) by the referenced spot market's `cumulativeDepositInterest`/`cumulativeBorrowInterest` to get the token amount. */
|
|
962
1400
|
export type PoolBalance = {
|
|
963
1401
|
scaledBalance: BN;
|
|
1402
|
+
/** the spot market this balance's token amount is denominated in */
|
|
964
1403
|
marketIndex: number;
|
|
965
1404
|
};
|
|
966
1405
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1406
|
+
/**
|
|
1407
|
+
* Consolidated per-market fee ledger: lifetime analytics counters plus the pending
|
|
1408
|
+
* (not-yet-materialized) protocol/IF/AMM carveouts and the AMM's backstop-of-last-resort
|
|
1409
|
+
* clawback cap. All fields are QUOTE_PRECISION (1e6). Pure counters — the actual token claims
|
|
1410
|
+
* live in `PerpMarketAccount.protocolFeePool` / `pnlPool` / `AMM.feePool`.
|
|
1411
|
+
*/
|
|
970
1412
|
export type FeeLedger = {
|
|
1413
|
+
/** lifetime gross taker fees collected (analytics only, post referee-discount, pre carve-outs) */
|
|
971
1414
|
totalExchangeFee: BN;
|
|
1415
|
+
/** lifetime liquidation fees charged to liquidatees (IF + protocol cuts; analytics only) */
|
|
972
1416
|
totalLiquidationFee: BN;
|
|
1417
|
+
/** protocol carveouts accrued but not yet materialized into `protocolFeePool` */
|
|
973
1418
|
pendingProtocolFee: BN;
|
|
1419
|
+
/** insurance-fund carveouts accrued but not yet materialized into the quote market's revenue pool; also the first bankruptcy tranche */
|
|
974
1420
|
pendingIfFee: BN;
|
|
1421
|
+
/** cumulative fee provision granted to the AMM as its backstop-of-last-resort tranche; drawable (and decremented) only in bankruptcy */
|
|
975
1422
|
ammProtocolFeesReceived: BN;
|
|
1423
|
+
/** AMM fee provision accrued at fill but not yet tokenized into `AMM.feePool` by the sweep; always `<= ammProtocolFeesReceived` */
|
|
976
1424
|
pendingAmmProvision: BN;
|
|
977
1425
|
};
|
|
978
1426
|
|
|
1427
|
+
/** Decoded mirror of the on-chain constant-product `AMM` struct embedded in `PerpMarketAccount.amm`. */
|
|
979
1428
|
export type AMM = {
|
|
1429
|
+
/** partition of fees moved from pnl settlements; SPOT_BALANCE_PRECISION (1e9) scaled balance */
|
|
980
1430
|
feePool: PoolBalance;
|
|
1431
|
+
/** `x` reserve of the constant-product formula (x*y=k), AMM_RESERVE_PRECISION (1e9) */
|
|
981
1432
|
baseAssetReserve: BN;
|
|
1433
|
+
/** `y` reserve of the constant-product formula (x*y=k), AMM_RESERVE_PRECISION (1e9) */
|
|
982
1434
|
quoteAssetReserve: BN;
|
|
1435
|
+
/** PERCENTAGE_PRECISION (1e6); how tightly the min/max reserves bracket the current reserves (lowers slippage without adding liquidity) */
|
|
983
1436
|
concentrationCoef: BN;
|
|
1437
|
+
/** AMM_RESERVE_PRECISION (1e9); reserve floor below which the AMM is unavailable */
|
|
984
1438
|
minBaseAssetReserve: BN;
|
|
1439
|
+
/** AMM_RESERVE_PRECISION (1e9); reserve ceiling above which the AMM is unavailable */
|
|
985
1440
|
maxBaseAssetReserve: BN;
|
|
1441
|
+
/** `sqrt(k)`, AMM_RESERVE_PRECISION (1e9); cached to avoid precision loss recomputing it */
|
|
986
1442
|
sqrtK: BN;
|
|
1443
|
+
/** normalizes quote reserves for lowest slippage when the market is balanced; PEG_PRECISION (1e6) */
|
|
987
1444
|
pegMultiplier: BN;
|
|
1445
|
+
/** `y` reserve when the market is balanced, AMM_RESERVE_PRECISION (1e9) */
|
|
988
1446
|
terminalQuoteAssetReserve: BN;
|
|
1447
|
+
/** net position (longs − shorts) with the AMM as counterparty, BASE_PRECISION (1e9) */
|
|
989
1448
|
baseAssetAmountWithAmm: BN;
|
|
990
|
-
|
|
991
|
-
/// market's gross fees are feeLedger.totalExchangeFee
|
|
1449
|
+
/** the AMM's own fee-derived income (provision + spread surplus), QUOTE_PRECISION (1e6) — the market's gross fees are `feeLedger.totalExchangeFee` */
|
|
992
1450
|
totalFee: BN;
|
|
993
|
-
|
|
1451
|
+
/** spread-capture component of `totalFee` (trading profit, not a paid fee), QUOTE_PRECISION (1e6) */
|
|
994
1452
|
totalMmFee: BN;
|
|
995
|
-
|
|
996
|
-
/// + credits − curve costs − bankruptcy clawbacks; AMM money only
|
|
1453
|
+
/** the AMM's equity ledger (retained earnings): fee income + funding/PnL + credits − curve costs − bankruptcy clawbacks; AMM money only, QUOTE_PRECISION (1e6) */
|
|
997
1454
|
totalFeeMinusDistributions: BN;
|
|
998
|
-
|
|
1455
|
+
/** @deprecated frozen pre-isolation analytics counter; nothing writes this anymore. QUOTE_PRECISION (1e6) */
|
|
999
1456
|
totalFeeWithdrawn: BN;
|
|
1457
|
+
/** cached spread-adjusted ask (long-take) reserve, AMM_RESERVE_PRECISION (1e9) */
|
|
1000
1458
|
askBaseAssetReserve: BN;
|
|
1459
|
+
/** AMM_RESERVE_PRECISION (1e9) */
|
|
1001
1460
|
askQuoteAssetReserve: BN;
|
|
1461
|
+
/** cached spread-adjusted bid (short-take) reserve, AMM_RESERVE_PRECISION (1e9) */
|
|
1002
1462
|
bidBaseAssetReserve: BN;
|
|
1463
|
+
/** AMM_RESERVE_PRECISION (1e9) */
|
|
1003
1464
|
bidQuoteAssetReserve: BN;
|
|
1004
1465
|
lastUpdateSlot: BN;
|
|
1466
|
+
/** change in `totalFeeMinusDistributions` since the last funding update, QUOTE_PRECISION (1e6) */
|
|
1005
1467
|
netRevenueSinceLastFunding: BN;
|
|
1468
|
+
/** the AMM's last-seen cumulative long funding rate (mirrors `PerpPosition.lastCumulativeFundingRate`), FUNDING_RATE_PRECISION (1e9) */
|
|
1006
1469
|
lastCumulativeFundingRateLong: BN;
|
|
1470
|
+
/** FUNDING_RATE_PRECISION (1e9) */
|
|
1007
1471
|
lastCumulativeFundingRateShort: BN;
|
|
1472
|
+
/** signed, BID_ASK_SPREAD_PRECISION (1e6); cached oracle-vs-reserve price spread feeding `calculate_spread` */
|
|
1008
1473
|
lastOracleReservePriceSpreadPct: BN;
|
|
1009
1474
|
lastSpreadUpdateSlot: BN;
|
|
1475
|
+
/** BID_ASK_SPREAD_PRECISION (1e6); minimum spread the AMM can quote */
|
|
1010
1476
|
baseSpread: number;
|
|
1477
|
+
/** BID_ASK_SPREAD_PRECISION (1e6); maximum spread the AMM can quote */
|
|
1011
1478
|
maxSpread: number;
|
|
1479
|
+
/** BID_ASK_SPREAD_PRECISION (1e6); cached spread applied to the ask (long-take) side */
|
|
1012
1480
|
longSpread: number;
|
|
1481
|
+
/** BID_ASK_SPREAD_PRECISION (1e6); cached spread applied to the bid (short-take) side */
|
|
1013
1482
|
shortSpread: number;
|
|
1483
|
+
/** signed, PRICE_PRECISION (1e6); cached reference-price offset applied to both sides' quotes */
|
|
1014
1484
|
referencePriceOffset: number;
|
|
1485
|
+
/** fraction of total available liquidity a single AMM fill may consume */
|
|
1015
1486
|
maxFillReserveFraction: number;
|
|
1487
|
+
/** maximum slippage ratio a single AMM fill may push */
|
|
1016
1488
|
maxSlippageRatio: number;
|
|
1489
|
+
/** 0-100; intensity of the AMM's formulaic `k` updates */
|
|
1017
1490
|
curveUpdateIntensity: number;
|
|
1491
|
+
/** 0 = no AMM JIT participation, (0,100] = intensity of protocol-owned-AMM JIT participation */
|
|
1018
1492
|
ammJitIntensity: number;
|
|
1493
|
+
/** signed, -100 = 0x scale, 100 = 2x scale, applied to the computed spread */
|
|
1019
1494
|
ammSpreadAdjustment: number;
|
|
1495
|
+
/** signed, -100 = 0x scale, 100 = 2x scale, applied to the inventory-skew component of the spread */
|
|
1020
1496
|
ammInventorySpreadAdjustment: number;
|
|
1021
1497
|
referencePriceOffsetDeadbandPct: number;
|
|
1498
|
+
/** stored in hundredths (value/100); how much the paying side's spread widens while the AMM pays funding on its inventory — 50 => 1.5x, 100 => 2x, 0 disables the bias */
|
|
1022
1499
|
fundingBiasSensitivity: number;
|
|
1023
1500
|
};
|
|
1024
1501
|
|
|
1502
|
+
/** Market-wide stats shared across all makers (vAMM, DLOB resting orders, JIT participants), updated on every fill regardless of which maker filled. */
|
|
1025
1503
|
export type MarketStats = {
|
|
1504
|
+
/** average (bid+ask)/2 price over `fundingPeriod`, PRICE_PRECISION (1e6) */
|
|
1026
1505
|
lastMarkPriceTwap: BN;
|
|
1506
|
+
/** average (bid+ask)/2 price over 5 minutes, PRICE_PRECISION (1e6) */
|
|
1027
1507
|
lastMarkPriceTwap5Min: BN;
|
|
1028
1508
|
lastMarkPriceTwapTs: BN;
|
|
1509
|
+
/** PRICE_PRECISION (1e6) */
|
|
1029
1510
|
lastBidPriceTwap: BN;
|
|
1511
|
+
/** PRICE_PRECISION (1e6) */
|
|
1030
1512
|
lastAskPriceTwap: BN;
|
|
1513
|
+
/** standard deviation of fill (mark) prices, PRICE_PRECISION (1e6) */
|
|
1031
1514
|
markStd: BN;
|
|
1515
|
+
/** standard deviation of the oracle price at each update, PRICE_PRECISION (1e6) */
|
|
1032
1516
|
oracleStd: BN;
|
|
1517
|
+
/** PERCENTAGE_PRECISION (1e6); size of the oracle confidence interval as a fraction of price */
|
|
1033
1518
|
lastOracleConfPct: BN;
|
|
1519
|
+
/** QUOTE_PRECISION (1e6); estimated total volume traded in the market */
|
|
1034
1520
|
volume24H: BN;
|
|
1035
1521
|
longIntensityVolume: BN;
|
|
1036
1522
|
shortIntensityVolume: BN;
|
|
1037
1523
|
lastTradeTs: BN;
|
|
1524
|
+
/** unit is quote per base, QUOTE_PRECISION (1e6); estimate of the last 24h average funding rate */
|
|
1038
1525
|
last24HAvgFundingRate: BN;
|
|
1526
|
+
/** seconds; periodicity of funding rate updates */
|
|
1039
1527
|
fundingPeriod: BN;
|
|
1528
|
+
/** BASE_PRECISION (1e9); minimum order size, mirrored here from `PerpMarketAccount` config so the AMM can read it without touching the market's other fields */
|
|
1040
1529
|
minOrderSize: BN;
|
|
1530
|
+
/** market-maker oracle price snapshot set by the native `updateMmOracle` handler */
|
|
1041
1531
|
mmOraclePrice: BN;
|
|
1042
1532
|
mmOracleSlot: BN;
|
|
1533
|
+
/** monotonically increasing; guards against out-of-order mm-oracle updates */
|
|
1043
1534
|
mmOracleSequenceId: BN;
|
|
1535
|
+
/** canonical sanitised/clamped oracle price after normalisation */
|
|
1044
1536
|
lastOracleNormalisedPrice: BN;
|
|
1537
|
+
/** PRICE_PRECISION (1e6); reference-price offset from the previous `_update_amm` call, used to smooth the sign-flip transition when the freshly computed offset changes direction */
|
|
1045
1538
|
lastReferencePriceOffset: number;
|
|
1046
1539
|
lastOracleValid: boolean;
|
|
1540
|
+
/** unit is quote per base, QUOTE_PRECISION (1e6); oracle TWAP snapshot used by the funding-rate computation */
|
|
1047
1541
|
lastFundingOracleTwap: BN;
|
|
1048
1542
|
historicalOracleData: HistoricalOracleData;
|
|
1049
1543
|
};
|
|
1050
1544
|
|
|
1051
1545
|
// # User Account Types
|
|
1546
|
+
/** A user's position in one perp market. Decoded mirror of the on-chain `PerpPosition`. */
|
|
1052
1547
|
export type PerpPosition = {
|
|
1548
|
+
/** signed size of the position, BASE_PRECISION (1e9) */
|
|
1053
1549
|
baseAssetAmount: BN;
|
|
1550
|
+
/** the market's last cumulative funding rate this position has settled against, FUNDING_RATE_PRECISION (1e9) */
|
|
1054
1551
|
lastCumulativeFundingRate: BN;
|
|
1055
1552
|
marketIndex: number;
|
|
1553
|
+
/** used to calculate pnl; updated on open/close/settle, includes fees/funding, QUOTE_PRECISION (1e6) */
|
|
1056
1554
|
quoteAssetAmount: BN;
|
|
1555
|
+
/** quote the position was entered with (base * avg entry price), excludes fees/funding, QUOTE_PRECISION (1e6) */
|
|
1057
1556
|
quoteEntryAmount: BN;
|
|
1557
|
+
/** quote needed to exit at breakeven, includes fees/funding, QUOTE_PRECISION (1e6) */
|
|
1058
1558
|
quoteBreakEvenAmount: BN;
|
|
1059
1559
|
openOrders: number;
|
|
1560
|
+
/** size of non-reduce-only bids resting/triggering against this position, BASE_PRECISION (1e9) */
|
|
1060
1561
|
openBids: BN;
|
|
1562
|
+
/** size of non-reduce-only asks resting/triggering against this position, BASE_PRECISION (1e9) */
|
|
1061
1563
|
openAsks: BN;
|
|
1564
|
+
/** cumulative pnl settled in this market since the position was opened, QUOTE_PRECISION (1e6) */
|
|
1062
1565
|
settledPnl: BN;
|
|
1063
1566
|
/** TODO: remove this field - it doesn't exist on chain */
|
|
1064
1567
|
remainderBaseAssetAmount: number;
|
|
1568
|
+
/** MARGIN_PRECISION (1e4); custom max margin ratio for this position, 0 = use the market default */
|
|
1065
1569
|
maxMarginRatio: number;
|
|
1570
|
+
/** bitmask, see `PositionFlag` */
|
|
1066
1571
|
positionFlag: number;
|
|
1572
|
+
/** SPOT_BALANCE_PRECISION (1e9) scaled balance backing this position when it is isolated-margin (`PositionFlag.IsolatedPosition` set) */
|
|
1067
1573
|
isolatedPositionScaledBalance: BN;
|
|
1068
1574
|
};
|
|
1069
1575
|
|
|
1576
|
+
/** Decoded mirror of the on-chain `UserStats` account: authority-level (cross-sub-account) rolling volume, fee, and referral stats. */
|
|
1070
1577
|
export type UserStatsAccount = {
|
|
1071
1578
|
numberOfSubAccounts: number;
|
|
1579
|
+
/** can exceed `numberOfSubAccounts` if sub-accounts were deleted */
|
|
1072
1580
|
numberOfSubAccountsCreated: number;
|
|
1581
|
+
/** rolling 30-day maker volume, QUOTE_PRECISION (1e6) */
|
|
1073
1582
|
makerVolume30D: BN;
|
|
1583
|
+
/** rolling 30-day taker volume, QUOTE_PRECISION (1e6) */
|
|
1074
1584
|
takerVolume30D: BN;
|
|
1585
|
+
/** rolling 30-day filler (keeper) volume, QUOTE_PRECISION (1e6) */
|
|
1075
1586
|
fillerVolume30D: BN;
|
|
1076
1587
|
lastMakerVolume30DTs: BN;
|
|
1077
1588
|
lastTakerVolume30DTs: BN;
|
|
1078
1589
|
lastFillerVolume30DTs: BN;
|
|
1079
1590
|
fees: {
|
|
1591
|
+
/** total taker fees paid, QUOTE_PRECISION (1e6) */
|
|
1080
1592
|
totalFeePaid: BN;
|
|
1593
|
+
/** total maker rebate received, QUOTE_PRECISION (1e6) */
|
|
1081
1594
|
totalFeeRebate: BN;
|
|
1595
|
+
/** total discount from holding the discount token, QUOTE_PRECISION (1e6) */
|
|
1082
1596
|
totalTokenDiscount: BN;
|
|
1597
|
+
/** total discount from being a referred user, QUOTE_PRECISION (1e6) */
|
|
1083
1598
|
totalRefereeDiscount: BN;
|
|
1084
1599
|
};
|
|
1085
1600
|
referrer: PublicKey;
|
|
1601
|
+
/** bitmask, see `ReferrerStatus` */
|
|
1086
1602
|
referrerStatus: number;
|
|
1087
1603
|
disableUpdatePerpBidAskTwap: number;
|
|
1604
|
+
/** bitmask, see `UserStatsPausedOperation` */
|
|
1088
1605
|
pausedOperations: number;
|
|
1089
1606
|
authority: PublicKey;
|
|
1090
1607
|
ifStakedQuoteAssetAmount: BN;
|
|
1091
1608
|
delegatePermissions: number;
|
|
1092
1609
|
};
|
|
1093
1610
|
|
|
1611
|
+
/** Decoded mirror of the on-chain `User` (sub-account) zero-copy account. */
|
|
1094
1612
|
export type UserAccount = {
|
|
1095
1613
|
authority: PublicKey;
|
|
1614
|
+
/** address that can control the account on the authority's behalf; limited power, cannot withdraw */
|
|
1096
1615
|
delegate: PublicKey;
|
|
1097
1616
|
name: number[];
|
|
1098
1617
|
subAccountId: number;
|
|
1099
1618
|
spotPositions: SpotPosition[];
|
|
1100
1619
|
perpPositions: PerpPosition[];
|
|
1101
1620
|
orders: Order[];
|
|
1621
|
+
/** bitmask, see `UserStatus` */
|
|
1102
1622
|
status: number;
|
|
1103
1623
|
nextLiquidationId: number;
|
|
1104
1624
|
nextOrderId: number;
|
|
1625
|
+
/** MARGIN_PRECISION (1e4); custom max initial margin ratio for the whole account, 0 = use market defaults */
|
|
1105
1626
|
maxMarginRatio: number;
|
|
1627
|
+
/** fees (taker fee, maker rebate, referrer reward, filler reward) and pnl for perps, QUOTE_PRECISION (1e6) */
|
|
1106
1628
|
settledPerpPnl: BN;
|
|
1629
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1107
1630
|
totalDeposits: BN;
|
|
1631
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1108
1632
|
totalWithdraws: BN;
|
|
1633
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1109
1634
|
totalSocialLoss: BN;
|
|
1635
|
+
/** cumulative funding paid/received across perps, QUOTE_PRECISION (1e6) */
|
|
1110
1636
|
cumulativePerpFunding: BN;
|
|
1637
|
+
/** fees (taker fee, maker rebate, filler reward) for spot, QUOTE_PRECISION (1e6) */
|
|
1111
1638
|
cumulativeSpotFees: BN;
|
|
1639
|
+
/** QUOTE_PRECISION (1e6); margin freed so far during an in-progress liquidation (spreads the liquidation over time); 0 when not being liquidated */
|
|
1112
1640
|
liquidationMarginFreed: BN;
|
|
1113
1641
|
lastActiveSlot: BN;
|
|
1114
1642
|
isMarginTradingEnabled: boolean;
|
|
1643
|
+
/** true if the account hasn't interacted with the protocol in ~1 week and has no orders/positions/borrows; off-chain keepers may ignore idle accounts */
|
|
1115
1644
|
idle: boolean;
|
|
1116
1645
|
openOrders: number;
|
|
1117
1646
|
hasOpenOrder: boolean;
|
|
1118
1647
|
openAuctions: number;
|
|
1119
1648
|
hasOpenAuction: boolean;
|
|
1120
1649
|
poolId: number;
|
|
1650
|
+
/** bitmask, see `SpecialUserStatus` */
|
|
1121
1651
|
specialUserStatus: number;
|
|
1122
1652
|
};
|
|
1123
1653
|
|
|
1654
|
+
/** A user's balance in one spot market. Decoded mirror of the on-chain `SpotPosition`. */
|
|
1124
1655
|
export type SpotPosition = {
|
|
1125
1656
|
marketIndex: number;
|
|
1126
1657
|
balanceType: SpotBalanceType;
|
|
1658
|
+
/** SPOT_BALANCE_PRECISION (1e9) scaled balance; multiply by the spot market's cumulative deposit/borrow interest for the token amount */
|
|
1127
1659
|
scaledBalance: BN;
|
|
1128
1660
|
openOrders: number;
|
|
1661
|
+
/** size of non-reduce-only bids resting/triggering, token mint precision */
|
|
1129
1662
|
openBids: BN;
|
|
1663
|
+
/** size of non-reduce-only asks resting/triggering, token mint precision */
|
|
1130
1664
|
openAsks: BN;
|
|
1665
|
+
/** cumulative deposits/borrows into this market, token mint precision */
|
|
1131
1666
|
cumulativeDeposits: BN;
|
|
1132
1667
|
};
|
|
1133
1668
|
|
|
1669
|
+
/** Decoded mirror of an on-chain `Order` slot inside `UserAccount.orders`. */
|
|
1134
1670
|
export type Order = {
|
|
1135
1671
|
status: OrderStatus;
|
|
1136
1672
|
orderType: OrderType;
|
|
@@ -1139,43 +1675,67 @@ export type Order = {
|
|
|
1139
1675
|
orderId: number;
|
|
1140
1676
|
userOrderId: number;
|
|
1141
1677
|
marketIndex: number;
|
|
1678
|
+
/** the limit price; can be 0 for market orders. For orders with an auction, unused until the auction completes. PRICE_PRECISION (1e6) */
|
|
1142
1679
|
price: BN;
|
|
1680
|
+
/** perp: BASE_PRECISION (1e9); spot: token mint precision */
|
|
1143
1681
|
baseAssetAmount: BN;
|
|
1682
|
+
/** perp: BASE_PRECISION (1e9); spot: token mint precision */
|
|
1144
1683
|
baseAssetAmountFilled: BN;
|
|
1684
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1145
1685
|
quoteAssetAmountFilled: BN;
|
|
1146
1686
|
direction: PositionDirection;
|
|
1147
1687
|
reduceOnly: boolean;
|
|
1688
|
+
/** price at which the order becomes active; only relevant for trigger orders, PRICE_PRECISION (1e6) */
|
|
1148
1689
|
triggerPrice: BN;
|
|
1149
1690
|
triggerCondition: OrderTriggerCondition;
|
|
1691
|
+
/** the user's position direction when this order was placed */
|
|
1150
1692
|
existingPositionDirection: PositionDirection;
|
|
1151
1693
|
postOnly: boolean;
|
|
1694
|
+
/** must be canceled the same slot it's placed if not fully filled */
|
|
1152
1695
|
immediateOrCancel: boolean;
|
|
1696
|
+
/** if set, the limit price is `oraclePrice + oraclePriceOffset`; PRICE_PRECISION (1e6), signed */
|
|
1153
1697
|
oraclePriceOffset: BN;
|
|
1698
|
+
/** slots the auction lasts; only relevant for market/oracle orders */
|
|
1154
1699
|
auctionDuration: number;
|
|
1700
|
+
/** PRICE_PRECISION (1e6), signed; only relevant for market/oracle orders */
|
|
1155
1701
|
auctionStartPrice: BN;
|
|
1702
|
+
/** PRICE_PRECISION (1e6), signed; only relevant for market/oracle orders */
|
|
1156
1703
|
auctionEndPrice: BN;
|
|
1704
|
+
/** unix timestamp after which the order expires */
|
|
1157
1705
|
maxTs: BN;
|
|
1706
|
+
/** bitmask, see `OrderBitFlag` */
|
|
1158
1707
|
bitFlags: number;
|
|
1708
|
+
/** low 8 bits of the slot the order was posted on-chain (not the order's `slot` field for signed-msg orders) */
|
|
1159
1709
|
postedSlotTail: number;
|
|
1160
1710
|
};
|
|
1161
1711
|
|
|
1712
|
+
/** Instruction-parameter shape for placing an order (perp or spot). Optional fields default to `null`/unset on-chain unless noted. */
|
|
1162
1713
|
export type OrderParams = {
|
|
1163
1714
|
orderType: OrderType;
|
|
1164
1715
|
marketType: MarketType;
|
|
1165
1716
|
userOrderId: number;
|
|
1166
1717
|
direction: PositionDirection;
|
|
1718
|
+
/** perp: BASE_PRECISION (1e9); spot: token mint precision */
|
|
1167
1719
|
baseAssetAmount: BN;
|
|
1720
|
+
/** limit price, PRICE_PRECISION (1e6); 0 for market orders */
|
|
1168
1721
|
price: BN;
|
|
1169
1722
|
marketIndex: number;
|
|
1170
1723
|
reduceOnly: boolean;
|
|
1171
1724
|
postOnly: PostOnlyParams;
|
|
1725
|
+
/** bitmask, see `OrderParamsBitFlag` (distinct from the on-chain `Order.bitFlags` set of flags) */
|
|
1172
1726
|
bitFlags: number;
|
|
1727
|
+
/** PRICE_PRECISION (1e6); only used for trigger orders */
|
|
1173
1728
|
triggerPrice: BN | null;
|
|
1174
1729
|
triggerCondition: OrderTriggerCondition;
|
|
1730
|
+
/** signed offset from the oracle price, PRICE_PRECISION (1e6); when set, the order's effective limit price tracks the oracle */
|
|
1175
1731
|
oraclePriceOffset: BN | null;
|
|
1732
|
+
/** slots; only used for market/oracle orders */
|
|
1176
1733
|
auctionDuration: number | null;
|
|
1734
|
+
/** unix timestamp after which the order expires */
|
|
1177
1735
|
maxTs: BN | null;
|
|
1736
|
+
/** PRICE_PRECISION (1e6) or oracle-offset units depending on the order, signed; only used for market/oracle orders */
|
|
1178
1737
|
auctionStartPrice: BN | null;
|
|
1738
|
+
/** PRICE_PRECISION (1e6) or oracle-offset units depending on the order, signed; only used for market/oracle orders */
|
|
1179
1739
|
auctionEndPrice: BN | null;
|
|
1180
1740
|
/** index into the placing user's RevenueShareEscrow.approved_builders list (non-swift builder codes) */
|
|
1181
1741
|
builderIdx?: number | null;
|
|
@@ -1183,6 +1743,7 @@ export type OrderParams = {
|
|
|
1183
1743
|
builderFeeTenthBps?: number | null;
|
|
1184
1744
|
};
|
|
1185
1745
|
|
|
1746
|
+
/** Whether/how an order must avoid taking liquidity. `MUST_POST_ONLY` reverts the transaction if the order would cross; `TRY_POST_ONLY` silently drops the order instead of reverting; `SLIDE` adjusts the price to make it post-only. */
|
|
1186
1747
|
export class PostOnlyParams {
|
|
1187
1748
|
static readonly NONE = { none: {} };
|
|
1188
1749
|
static readonly MUST_POST_ONLY = { mustPostOnly: {} }; // Tx fails if order can't be post only
|
|
@@ -1226,16 +1787,19 @@ export type ScaleOrderParams = {
|
|
|
1226
1787
|
maxTs: BN | null;
|
|
1227
1788
|
};
|
|
1228
1789
|
|
|
1790
|
+
/** Bitmask mirror of `OrderParams.bitFlags` (the instruction-parameter flag set; distinct from the on-chain `Order.bitFlags` set of `OrderBitFlag`). */
|
|
1229
1791
|
export class OrderParamsBitFlag {
|
|
1230
1792
|
static readonly ImmediateOrCancel = 1;
|
|
1231
1793
|
}
|
|
1232
1794
|
|
|
1795
|
+
/** Bitmask mirror of `PerpPosition.positionFlag`. Multiple bits can be set (e.g. an isolated position mid-liquidation has both `IsolatedPosition` and `BeingLiquidated`). */
|
|
1233
1796
|
export class PositionFlag {
|
|
1234
1797
|
static readonly IsolatedPosition = 1;
|
|
1235
1798
|
static readonly BeingLiquidated = 2;
|
|
1236
1799
|
static readonly Bankruptcy = 4;
|
|
1237
1800
|
}
|
|
1238
1801
|
|
|
1802
|
+
/** The subset of `OrderParams` an SDK caller must always supply; everything else can be defaulted. */
|
|
1239
1803
|
export type NecessaryOrderParams = {
|
|
1240
1804
|
orderType: OrderType;
|
|
1241
1805
|
marketIndex: number;
|
|
@@ -1243,19 +1807,23 @@ export type NecessaryOrderParams = {
|
|
|
1243
1807
|
direction: PositionDirection;
|
|
1244
1808
|
};
|
|
1245
1809
|
|
|
1810
|
+
/** `OrderParams` with every field optional except `NecessaryOrderParams`; SDK order-placement helpers fill in the rest from `DefaultOrderParams`. */
|
|
1246
1811
|
export type OptionalOrderParams = {
|
|
1247
1812
|
[Property in keyof OrderParams]?: OrderParams[Property];
|
|
1248
1813
|
} & NecessaryOrderParams;
|
|
1249
1814
|
|
|
1815
|
+
/** Fields to change on an existing order via `modifyOrder`. Only the fields present (non-`undefined`) are changed on-chain; the rest of the order is left as-is. `null` explicitly clears an optional on-chain field (e.g. `triggerPrice: null` removes the trigger). */
|
|
1250
1816
|
export type ModifyOrderParams = {
|
|
1251
1817
|
[Property in keyof OrderParams]?: OrderParams[Property] | null;
|
|
1252
1818
|
} & { policy?: ModifyOrderPolicy | null };
|
|
1253
1819
|
|
|
1820
|
+
/** Bitmask passed as `ModifyOrderParams.policy` (combine with `|`). `MustModify`: fail the instruction instead of silently no-op'ing if the target order id can't be found. `ExcludePreviousFill`: when a new `baseAssetAmount` is given, treat it as the new *remaining* size — the already-filled amount is subtracted off it (rather than replacing the order's total size outright). */
|
|
1254
1821
|
export enum ModifyOrderPolicy {
|
|
1255
1822
|
MustModify = 1,
|
|
1256
1823
|
ExcludePreviousFill = 2,
|
|
1257
1824
|
}
|
|
1258
1825
|
|
|
1826
|
+
/** Base `OrderParams` (a market perp long of size 0) that SDK order-building helpers spread their caller-supplied `OptionalOrderParams` over. */
|
|
1259
1827
|
export const DefaultOrderParams: OrderParams = {
|
|
1260
1828
|
orderType: OrderType.MARKET,
|
|
1261
1829
|
marketType: MarketType.PERP,
|
|
@@ -1278,19 +1846,25 @@ export const DefaultOrderParams: OrderParams = {
|
|
|
1278
1846
|
builderFeeTenthBps: null,
|
|
1279
1847
|
};
|
|
1280
1848
|
|
|
1849
|
+
/** The payload signed off-chain by a user (non-delegated) for a swift/signed-msg order, optionally bundling bracket TP/SL orders and an isolated-margin deposit. */
|
|
1281
1850
|
export type SignedMsgOrderParamsMessage = {
|
|
1282
1851
|
signedMsgOrderParams: OrderParams;
|
|
1283
1852
|
subAccountId: number;
|
|
1853
|
+
/** slot the message was signed at; combined with `signedMsgOrderMaxSlot`-style checks to bound message validity */
|
|
1284
1854
|
slot: BN;
|
|
1285
1855
|
uuid: Uint8Array;
|
|
1286
1856
|
takeProfitOrderParams: SignedMsgTriggerOrderParams | null;
|
|
1287
1857
|
stopLossOrderParams: SignedMsgTriggerOrderParams | null;
|
|
1858
|
+
/** MARGIN_PRECISION (1e4); custom max margin ratio applied to the resulting position, if any */
|
|
1288
1859
|
maxMarginRatio?: number | null;
|
|
1289
1860
|
builderIdx?: number | null;
|
|
1861
|
+
/** builder fee on this order, in tenths of a bps, e.g. 100 = 0.01% */
|
|
1290
1862
|
builderFeeTenthBps?: number | null;
|
|
1863
|
+
/** if set, deposits this amount (spot market token-mint precision) into a new isolated-margin position when placing the order */
|
|
1291
1864
|
isolatedPositionDeposit?: BN | null;
|
|
1292
1865
|
};
|
|
1293
1866
|
|
|
1867
|
+
/** Same as `SignedMsgOrderParamsMessage`, but signed by a delegate on the taker's behalf; carries `takerPubkey` explicitly since the signer isn't the taker's own authority. */
|
|
1294
1868
|
export type SignedMsgOrderParamsDelegateMessage = {
|
|
1295
1869
|
signedMsgOrderParams: OrderParams;
|
|
1296
1870
|
slot: BN;
|
|
@@ -1304,11 +1878,15 @@ export type SignedMsgOrderParamsDelegateMessage = {
|
|
|
1304
1878
|
isolatedPositionDeposit?: BN | null;
|
|
1305
1879
|
};
|
|
1306
1880
|
|
|
1881
|
+
/** A bracket take-profit/stop-loss order attached to a signed-msg order message. */
|
|
1307
1882
|
export type SignedMsgTriggerOrderParams = {
|
|
1883
|
+
/** PRICE_PRECISION (1e6) */
|
|
1308
1884
|
triggerPrice: BN;
|
|
1885
|
+
/** perp: BASE_PRECISION (1e9); spot: token mint precision */
|
|
1309
1886
|
baseAssetAmount: BN;
|
|
1310
1887
|
};
|
|
1311
1888
|
|
|
1889
|
+
/** Identifies a resting maker order/account to pass into a fill instruction's remaining accounts. `order` may be omitted when the whole account (not one specific order) is being matched against, e.g. AMM-JIT. */
|
|
1312
1890
|
export type MakerInfo = {
|
|
1313
1891
|
maker: PublicKey;
|
|
1314
1892
|
makerStats: PublicKey;
|
|
@@ -1316,6 +1894,7 @@ export type MakerInfo = {
|
|
|
1316
1894
|
order?: Order;
|
|
1317
1895
|
};
|
|
1318
1896
|
|
|
1897
|
+
/** Identifies the taker order/account being filled, for fill instructions. */
|
|
1319
1898
|
export type TakerInfo = {
|
|
1320
1899
|
taker: PublicKey;
|
|
1321
1900
|
takerStats: PublicKey;
|
|
@@ -1323,11 +1902,13 @@ export type TakerInfo = {
|
|
|
1323
1902
|
order: Order;
|
|
1324
1903
|
};
|
|
1325
1904
|
|
|
1905
|
+
/** Referrer accounts to pass into an instruction so the referrer's reward can be credited. */
|
|
1326
1906
|
export type ReferrerInfo = {
|
|
1327
1907
|
referrer: PublicKey;
|
|
1328
1908
|
referrerStats: PublicKey;
|
|
1329
1909
|
};
|
|
1330
1910
|
|
|
1911
|
+
/** Bitmask mirror of `UserStatsAccount.referrerStatus`. */
|
|
1331
1912
|
export enum ReferrerStatus {
|
|
1332
1913
|
IsReferrer = 1,
|
|
1333
1914
|
IsReferred = 2,
|
|
@@ -1335,6 +1916,7 @@ export enum ReferrerStatus {
|
|
|
1335
1916
|
BuilderReferral = 4,
|
|
1336
1917
|
}
|
|
1337
1918
|
|
|
1919
|
+
/** Which fill outcome counts as "success" for a `placeAndTake*` instruction's on-chain success check. */
|
|
1338
1920
|
export enum PlaceAndTakeOrderSuccessCondition {
|
|
1339
1921
|
PartialFill = 1,
|
|
1340
1922
|
FullFill = 2,
|
|
@@ -1342,27 +1924,39 @@ export enum PlaceAndTakeOrderSuccessCondition {
|
|
|
1342
1924
|
|
|
1343
1925
|
type ExactType<T> = Pick<T, keyof T>;
|
|
1344
1926
|
|
|
1927
|
+
/** Compute-budget overrides accepted by SDK transaction-building helpers. Omit either field to let the SDK compute/skip it. */
|
|
1345
1928
|
export type BaseTxParams = ExactType<{
|
|
1929
|
+
/** explicit compute-unit limit to request; if omitted, may be derived via simulation (see `ProcessingTxParams`) */
|
|
1346
1930
|
computeUnits?: number;
|
|
1931
|
+
/** micro-lamports per compute unit for the priority fee */
|
|
1347
1932
|
computeUnitsPrice?: number;
|
|
1348
1933
|
}>;
|
|
1349
1934
|
|
|
1935
|
+
/** Controls how the SDK derives compute-unit limit/price when not explicitly given in `BaseTxParams`. */
|
|
1350
1936
|
export type ProcessingTxParams = {
|
|
1937
|
+
/** simulate the transaction to determine the compute-unit limit instead of using a static estimate */
|
|
1351
1938
|
useSimulatedComputeUnits?: boolean;
|
|
1939
|
+
/** multiplier applied to the simulated/estimated compute-unit count to leave headroom, e.g. 1.2 = +20% */
|
|
1352
1940
|
computeUnitsBufferMultiplier?: number;
|
|
1941
|
+
/** also use the simulated compute-unit count (rather than the static estimate) as the basis for `getCUPriceFromComputeUnits` */
|
|
1353
1942
|
useSimulatedComputeUnitsForCUPriceCalculation?: boolean;
|
|
1943
|
+
/** custom function mapping a compute-unit count to a compute-unit price (micro-lamports); overrides `computeUnitsPrice` */
|
|
1354
1944
|
getCUPriceFromComputeUnits?: (computeUnits: number) => number;
|
|
1945
|
+
/** floor applied to the computed/simulated compute-unit count before requesting a limit */
|
|
1355
1946
|
lowerBoundCu?: number;
|
|
1356
1947
|
};
|
|
1357
1948
|
|
|
1949
|
+
/** Combined compute-budget + compute-unit-derivation options accepted by SDK transaction-building helpers. */
|
|
1358
1950
|
export type TxParams = BaseTxParams & ProcessingTxParams;
|
|
1359
1951
|
|
|
1952
|
+
/** For `beginSwap`/`endSwap`, whether the reduce-only constraint applies to the `In` (source) or `Out` (destination) side of the swap. */
|
|
1360
1953
|
export class SwapReduceOnly {
|
|
1361
1954
|
static readonly In = { in: {} };
|
|
1362
1955
|
static readonly Out = { out: {} };
|
|
1363
1956
|
}
|
|
1364
1957
|
|
|
1365
1958
|
// # Misc Types
|
|
1959
|
+
/** Minimal wallet adapter the SDK requires for legacy (non-versioned) transaction signing. */
|
|
1366
1960
|
export interface IWallet {
|
|
1367
1961
|
signTransaction(tx: Transaction): Promise<Transaction>;
|
|
1368
1962
|
signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
|
|
@@ -1373,6 +1967,7 @@ export interface IWallet {
|
|
|
1373
1967
|
| null
|
|
1374
1968
|
| undefined;
|
|
1375
1969
|
}
|
|
1970
|
+
/** Wallet adapter capable of signing versioned transactions (v0 message format). */
|
|
1376
1971
|
export interface IVersionedWallet {
|
|
1377
1972
|
signVersionedTransaction(
|
|
1378
1973
|
tx: VersionedTransaction
|
|
@@ -1384,48 +1979,70 @@ export interface IVersionedWallet {
|
|
|
1384
1979
|
payer?: Keypair;
|
|
1385
1980
|
}
|
|
1386
1981
|
|
|
1982
|
+
/** `IWallet` extended with arbitrary-message signing (used for signed-msg/swift order flows). */
|
|
1387
1983
|
export interface IWalletV2 extends IWallet {
|
|
1388
1984
|
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
1389
1985
|
}
|
|
1390
1986
|
|
|
1987
|
+
/** The fee schedule applied to fills in a market category (perp or spot); decoded from `StateAccount.perpFeeStructure`/`spotFeeStructure`. */
|
|
1391
1988
|
export type FeeStructure = {
|
|
1989
|
+
/** volume-based fee tiers, evaluated by the taker's 30-day volume; tier 0 is the base/default tier */
|
|
1392
1990
|
feeTiers: FeeTier[];
|
|
1393
1991
|
fillerRewardStructure: OrderFillerRewardStructure;
|
|
1992
|
+
/** flat portion of the filler (keeper) reward, QUOTE_PRECISION (1e6) */
|
|
1394
1993
|
flatFillerFee: BN;
|
|
1994
|
+
/** FEE_PERCENTAGE_DENOMINATOR (100)-denominated share of the trade-fee remainder provisioned to the AMM as its backstop-of-last-resort tranche; `ammFeeNumerator + ifFeeNumerator` must be <= 100, the protocol keeps the residual */
|
|
1395
1995
|
ammFeeNumerator: number;
|
|
1996
|
+
/** FEE_PERCENTAGE_DENOMINATOR (100)-denominated share of the trade-fee remainder routed to the insurance fund */
|
|
1396
1997
|
ifFeeNumerator: number;
|
|
1397
1998
|
};
|
|
1398
1999
|
|
|
2000
|
+
/** One volume tier of a `FeeStructure`. All `*Numerator`/`*Denominator` pairs form a fraction (e.g. `feeNumerator / feeDenominator`). */
|
|
1399
2001
|
export type FeeTier = {
|
|
2002
|
+
/** taker fee rate */
|
|
1400
2003
|
feeNumerator: number;
|
|
1401
2004
|
feeDenominator: number;
|
|
2005
|
+
/** rebate paid to the resting maker */
|
|
1402
2006
|
makerRebateNumerator: number;
|
|
1403
2007
|
makerRebateDenominator: number;
|
|
2008
|
+
/** share of the taker fee credited to the taker's referrer */
|
|
1404
2009
|
referrerRewardNumerator: number;
|
|
1405
2010
|
referrerRewardDenominator: number;
|
|
2011
|
+
/** discount applied to the taker's own fee when they were referred */
|
|
1406
2012
|
refereeFeeNumerator: number;
|
|
1407
2013
|
refereeFeeDenominator: number;
|
|
1408
2014
|
};
|
|
1409
2015
|
|
|
2016
|
+
/** The reward paid to the keeper (filler) that submits a fill transaction. */
|
|
1410
2017
|
export type OrderFillerRewardStructure = {
|
|
2018
|
+
/** share of the fill's fee/size paid as a variable reward */
|
|
1411
2019
|
rewardNumerator: number;
|
|
1412
2020
|
rewardDenominator: number;
|
|
2021
|
+
/** QUOTE_PRECISION (1e6); floor below which the time-based reward component doesn't apply */
|
|
1413
2022
|
timeBasedRewardLowerBound: BN;
|
|
1414
2023
|
};
|
|
1415
2024
|
|
|
2025
|
+
/** Protocol-wide oracle safety thresholds (`StateAccount.oracleGuardRails`), gating how far an oracle price may diverge from mark and how stale/uncertain it may be before it's rejected for a given action. */
|
|
1416
2026
|
export type OracleGuardRails = {
|
|
1417
2027
|
priceDivergence: {
|
|
2028
|
+
/** PERCENTAGE_PRECISION (1e6); max allowed |mark − oracle| / oracle before divergence checks reject the price */
|
|
1418
2029
|
markOraclePercentDivergence: BN;
|
|
2030
|
+
/** PERCENTAGE_PRECISION (1e6); max allowed divergence between the oracle's live price and its 5-minute TWAP */
|
|
1419
2031
|
oracleTwap5MinPercentDivergence: BN;
|
|
1420
2032
|
};
|
|
1421
2033
|
validity: {
|
|
2034
|
+
/** slots; oracle updates older than this are stale for AMM-facing actions */
|
|
1422
2035
|
slotsBeforeStaleForAmm: BN;
|
|
2036
|
+
/** slots; oracle updates older than this are stale for margin/liquidation actions */
|
|
1423
2037
|
slotsBeforeStaleForMargin: BN;
|
|
2038
|
+
/** PERCENTAGE_PRECISION (1e6)-scaled fraction of price; oracle confidence intervals wider than this are rejected */
|
|
1424
2039
|
confidenceIntervalMaxSize: BN;
|
|
2040
|
+
/** oracle price moves within one update exceeding this multiple of the recent range are rejected as "too volatile" */
|
|
1425
2041
|
tooVolatileRatio: BN;
|
|
1426
2042
|
};
|
|
1427
2043
|
};
|
|
1428
2044
|
|
|
2045
|
+
/** Result of the oracle validity check (`is_oracle_valid_for_action` and friends). Only `Valid` (7) permits using the price; every other variant identifies the specific failure so callers can gate accordingly (stale-for-margin still permits AMM-only actions, etc.). */
|
|
1429
2046
|
export enum OracleValidity {
|
|
1430
2047
|
NonPositive = 0,
|
|
1431
2048
|
TooVolatile = 1,
|
|
@@ -1437,21 +2054,29 @@ export enum OracleValidity {
|
|
|
1437
2054
|
Valid = 7,
|
|
1438
2055
|
}
|
|
1439
2056
|
|
|
2057
|
+
/** Decoded mirror of a `PrelaunchOracle` account — an admin-fed synthetic price feed used before a market has a real external oracle (`OracleSource.Prelaunch`). */
|
|
1440
2058
|
export type PrelaunchOracle = {
|
|
2059
|
+
/** PRICE_PRECISION (1e6) */
|
|
1441
2060
|
price: BN;
|
|
2061
|
+
/** PRICE_PRECISION (1e6); ceiling the admin-set price is clamped to */
|
|
1442
2062
|
maxPrice: BN;
|
|
2063
|
+
/** PRICE_PRECISION (1e6) */
|
|
1443
2064
|
confidence: BN;
|
|
1444
2065
|
ammLastUpdateSlot: BN;
|
|
1445
2066
|
lastUpdateSlot: BN;
|
|
1446
2067
|
perpMarketIndex: number;
|
|
1447
2068
|
};
|
|
1448
2069
|
|
|
2070
|
+
/** Admin instruction params for updating a `PrelaunchOracle`; `null` fields leave the current on-chain value unchanged. */
|
|
1449
2071
|
export type PrelaunchOracleParams = {
|
|
1450
2072
|
perpMarketIndex: number;
|
|
2073
|
+
/** PRICE_PRECISION (1e6) */
|
|
1451
2074
|
price: BN | null;
|
|
2075
|
+
/** PRICE_PRECISION (1e6) */
|
|
1452
2076
|
maxPrice: BN | null;
|
|
1453
2077
|
};
|
|
1454
2078
|
|
|
2079
|
+
/** Decoded mirror of a Pyth Lazer oracle account. `price`/`conf` are in the feed's native `exponent` (a power-of-ten scale factor, typically negative), not a fixed SDK precision — divide by `10^-exponent` to get the human-readable price. */
|
|
1455
2080
|
export type PythLazerOracle = {
|
|
1456
2081
|
price: BN;
|
|
1457
2082
|
publishTime: BN;
|
|
@@ -1460,28 +2085,42 @@ export type PythLazerOracle = {
|
|
|
1460
2085
|
conf: BN;
|
|
1461
2086
|
};
|
|
1462
2087
|
|
|
2088
|
+
/** Admin instruction params for correcting a perp market's cached AMM summary stats; `null` fields leave the current on-chain value unchanged. */
|
|
1463
2089
|
export type UpdatePerpMarketSummaryStatsParams = {
|
|
2090
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1464
2091
|
netUnsettledFundingPnl: BN | null;
|
|
1465
2092
|
updateAmmSummaryStats: boolean | null;
|
|
1466
2093
|
};
|
|
1467
2094
|
|
|
1468
|
-
|
|
2095
|
+
/**
|
|
2096
|
+
* Which margin requirement a calculation is being performed for, mirroring the program's
|
|
2097
|
+
* `MarginRequirementType`: `'Initial'` (opening/maintaining leverage headroom), `'Maintenance'`
|
|
2098
|
+
* (liquidation), or `'Fill'` (fill-time check — weights/ratios are the integer-averaged midpoint
|
|
2099
|
+
* of initial and maintenance).
|
|
2100
|
+
*/
|
|
2101
|
+
export type MarginCategory = 'Initial' | 'Maintenance' | 'Fill';
|
|
1469
2102
|
|
|
2103
|
+
/** Decoded mirror of the on-chain `InsuranceFundStake` account: one user's stake in one spot market's insurance fund. */
|
|
1470
2104
|
export type InsuranceFundStake = {
|
|
2105
|
+
/** signed, spot market token-mint precision; tracks the staker's cost basis for pnl reporting */
|
|
1471
2106
|
costBasis: BN;
|
|
1472
2107
|
|
|
1473
2108
|
marketIndex: number;
|
|
1474
2109
|
authority: PublicKey;
|
|
1475
2110
|
|
|
2111
|
+
/** the staker's share count; multiply by the IF's share price to get token value */
|
|
1476
2112
|
ifShares: BN;
|
|
2113
|
+
/** exponent used to rebase `ifShares` in step with `InsuranceFund.sharesBase` */
|
|
1477
2114
|
ifBase: BN;
|
|
1478
2115
|
lastValidTs: BN;
|
|
1479
2116
|
|
|
1480
2117
|
lastWithdrawRequestShares: BN;
|
|
2118
|
+
/** spot market token-mint precision value of `lastWithdrawRequestShares` at request time */
|
|
1481
2119
|
lastWithdrawRequestValue: BN;
|
|
1482
2120
|
lastWithdrawRequestTs: BN;
|
|
1483
2121
|
};
|
|
1484
2122
|
|
|
2123
|
+
/** Decoded mirror of a `ReferrerName` account, mapping a human-readable referrer name to its user/authority. */
|
|
1485
2124
|
export type ReferrerNameAccount = {
|
|
1486
2125
|
name: number[];
|
|
1487
2126
|
user: PublicKey;
|
|
@@ -1489,6 +2128,7 @@ export type ReferrerNameAccount = {
|
|
|
1489
2128
|
userStats: PublicKey;
|
|
1490
2129
|
};
|
|
1491
2130
|
|
|
2131
|
+
/** SDK-computed convenience summary of a perp market's order-size/margin/insurance limits, derived from `PerpMarketAccount` (not decoded directly from a single on-chain field). */
|
|
1492
2132
|
export type PerpMarketExtendedInfo = {
|
|
1493
2133
|
marketIndex: number;
|
|
1494
2134
|
/**
|
|
@@ -1511,6 +2151,7 @@ export type PerpMarketExtendedInfo = {
|
|
|
1511
2151
|
contractTier: ContractTier;
|
|
1512
2152
|
};
|
|
1513
2153
|
|
|
2154
|
+
/** SDK-computed breakdown of a user's margin-health calculation, grouped by contribution type; each group is a list of the individual `HealthComponent`s that summed into the account's total collateral/margin requirement. */
|
|
1514
2155
|
export type HealthComponents = {
|
|
1515
2156
|
deposits: HealthComponent[];
|
|
1516
2157
|
borrows: HealthComponent[];
|
|
@@ -1518,19 +2159,26 @@ export type HealthComponents = {
|
|
|
1518
2159
|
perpPnl: HealthComponent[];
|
|
1519
2160
|
};
|
|
1520
2161
|
|
|
2162
|
+
/** One market's contribution to a `HealthComponents` group. */
|
|
1521
2163
|
export type HealthComponent = {
|
|
1522
2164
|
marketIndex: number;
|
|
2165
|
+
/** perp: signed BASE_PRECISION (1e9) position size; spot: signed token-mint-precision balance */
|
|
1523
2166
|
size: BN;
|
|
2167
|
+
/** unweighted USD value, QUOTE_PRECISION (1e6) */
|
|
1524
2168
|
value: BN;
|
|
2169
|
+
/** the asset/liability weight applied, SPOT_WEIGHT_PRECISION or MARGIN_PRECISION (1e4) depending on component type */
|
|
1525
2170
|
weight: BN;
|
|
2171
|
+
/** `value` after applying `weight`, QUOTE_PRECISION (1e6); this is what's actually summed into total collateral/margin requirement */
|
|
1526
2172
|
weightedValue: BN;
|
|
1527
2173
|
};
|
|
1528
2174
|
|
|
2175
|
+
/** Event map for `VelocityClient`'s internal metrics emitter. */
|
|
1529
2176
|
export interface VelocityClientMetricsEvents {
|
|
1530
2177
|
txSigned: SignedTxData[];
|
|
1531
2178
|
preTxSigned: void;
|
|
1532
2179
|
}
|
|
1533
2180
|
|
|
2181
|
+
/** A transaction the SDK has signed, returned by transaction-sending helpers before/instead of submission. */
|
|
1534
2182
|
export type SignedTxData = {
|
|
1535
2183
|
txSig: string;
|
|
1536
2184
|
signedTx: Transaction | VersionedTransaction;
|
|
@@ -1538,9 +2186,7 @@ export type SignedTxData = {
|
|
|
1538
2186
|
blockHash: string;
|
|
1539
2187
|
};
|
|
1540
2188
|
|
|
1541
|
-
|
|
1542
|
-
* It can be provided to velocity program to fill a signed msg order
|
|
1543
|
-
*/
|
|
2189
|
+
/** Proof of a signed-msg (swift) taker order, submitted to the program to fill it. */
|
|
1544
2190
|
export interface SignedMsgOrderParams {
|
|
1545
2191
|
/**
|
|
1546
2192
|
* The encoded order params that were signed (borsh encoded then hexified).
|
|
@@ -1552,263 +2198,378 @@ export interface SignedMsgOrderParams {
|
|
|
1552
2198
|
signature: Buffer;
|
|
1553
2199
|
}
|
|
1554
2200
|
|
|
2201
|
+
/** One slot of a `SignedMsgUserOrdersAccount`, recording a signed-msg order's validity window and dedupe key so a replayed/expired signed message can be rejected without an extra RPC round-trip. */
|
|
1555
2202
|
export type SignedMsgOrderId = {
|
|
2203
|
+
/** slot after which this signed message is no longer eligible to be placed */
|
|
1556
2204
|
maxSlot: BN;
|
|
1557
2205
|
uuid: Uint8Array;
|
|
1558
2206
|
orderId: number;
|
|
1559
2207
|
};
|
|
1560
2208
|
|
|
2209
|
+
/** Per-authority account tracking recently-seen signed-msg order UUIDs, used to detect replay/duplicate submission of the same signed message. */
|
|
1561
2210
|
export type SignedMsgUserOrdersAccount = {
|
|
1562
2211
|
authorityPubkey: PublicKey;
|
|
1563
2212
|
signedMsgOrderData: SignedMsgOrderId[];
|
|
1564
2213
|
};
|
|
1565
2214
|
|
|
2215
|
+
/** Account listing the delegate keys authorized to submit signed-msg orders over the swift websocket on a user's behalf. */
|
|
1566
2216
|
export type SignedMsgWsDelegatesAccount = {
|
|
1567
2217
|
delegates: PublicKey[];
|
|
1568
2218
|
};
|
|
1569
2219
|
|
|
2220
|
+
/** Decoded mirror of the on-chain `RevenueShare` account: one per builder/referrer, accumulating their lifetime rewards. */
|
|
1570
2221
|
export type RevenueShareAccount = {
|
|
2222
|
+
/** the builder or referrer that owns this account */
|
|
1571
2223
|
authority: PublicKey;
|
|
2224
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1572
2225
|
totalReferrerRewards: BN;
|
|
2226
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1573
2227
|
totalBuilderRewards: BN;
|
|
1574
2228
|
padding: number[];
|
|
1575
2229
|
};
|
|
1576
2230
|
|
|
2231
|
+
/** Decoded mirror of the on-chain `RevenueShareEscrow` account: one per trading user, holding their referrer link, approved builder codes, and in-flight per-order fee accruals awaiting settlement. Required in remaining accounts when filling an order with a builder code or a referred taker (see `TakerInfo`/fill-instruction docs). */
|
|
1577
2232
|
export type RevenueShareEscrowAccount = {
|
|
2233
|
+
/** the user that owns this escrow */
|
|
1578
2234
|
authority: PublicKey;
|
|
1579
2235
|
referrer: PublicKey;
|
|
1580
2236
|
reservedFixed: number[];
|
|
2237
|
+
/** ring-buffer of in-flight order fee accruals, settled into the builder's/referrer's `RevenueShareAccount` on settle-PnL */
|
|
1581
2238
|
orders: RevenueShareOrder[];
|
|
2239
|
+
/** builders this user has approved to charge a fee, indexed by `builderIdx` on `OrderParams`/`RevenueShareOrder` */
|
|
1582
2240
|
approvedBuilders: BuilderInfo[];
|
|
1583
2241
|
};
|
|
1584
2242
|
|
|
2243
|
+
/** One in-flight order's accrued builder/referral fee inside a `RevenueShareEscrowAccount`. */
|
|
1585
2244
|
export type RevenueShareOrder = {
|
|
2245
|
+
/** QUOTE_PRECISION (1e6); accrued so far for this slot — may include fees from other orders that reused the same slot, not exclusively `orderId` */
|
|
1586
2246
|
feesAccrued: BN;
|
|
2247
|
+
/** the currently-active order's id in this slot; only meaningful while the slot is open */
|
|
1587
2248
|
orderId: number;
|
|
2249
|
+
/** builder fee on this order, in tenths of a bps, e.g. 100 = 0.01% */
|
|
1588
2250
|
feeTenthBps: number;
|
|
1589
2251
|
marketIndex: number;
|
|
2252
|
+
/** only meaningful while the slot is open */
|
|
1590
2253
|
subAccountId: number;
|
|
2254
|
+
/** index into `RevenueShareEscrowAccount.approvedBuilders` this order's fee settles to; ignored for a referral-only slot */
|
|
1591
2255
|
builderIdx: number;
|
|
2256
|
+
/** bitflags describing slot state (init/open/completed) and whether it holds referral rewards rather than a builder fee */
|
|
1592
2257
|
bitFlags: number;
|
|
1593
2258
|
userOrderIndex: number;
|
|
1594
2259
|
marketType: MarketType;
|
|
1595
2260
|
padding: number[];
|
|
1596
2261
|
};
|
|
1597
2262
|
|
|
2263
|
+
/** One builder a user has approved to charge a fee on their orders, inside `RevenueShareEscrowAccount.approvedBuilders`. */
|
|
1598
2264
|
export type BuilderInfo = {
|
|
2265
|
+
/** the builder's authority */
|
|
1599
2266
|
authority: PublicKey;
|
|
2267
|
+
/** ceiling on the fee (tenths of a bps) this builder may charge; `0` means the approval has been revoked */
|
|
1600
2268
|
maxFeeTenthBps: number;
|
|
1601
2269
|
padding: number[];
|
|
1602
2270
|
};
|
|
1603
2271
|
|
|
2272
|
+
/** Emitted when a perp market's fee-ledger pendings are swept into their durable homes (protocol fee pool, quote market revenue pool, AMM fee pool). */
|
|
1604
2273
|
export type PerpMarketFeeSweepRecord = {
|
|
1605
2274
|
ts: BN;
|
|
1606
2275
|
marketIndex: number;
|
|
2276
|
+
/** pending insurance cut moved to the quote spot market's revenue pool, QUOTE_PRECISION (1e6) */
|
|
1607
2277
|
ifSwept: BN;
|
|
2278
|
+
/** pending protocol cut moved to the market's protocol fee pool, QUOTE_PRECISION (1e6) */
|
|
1608
2279
|
protocolSwept: BN;
|
|
2280
|
+
/** AMM fee provision (booked at fill) tokenized into `AMM.feePool`, QUOTE_PRECISION (1e6) */
|
|
1609
2281
|
ammProvisionTokenized: BN;
|
|
1610
2282
|
};
|
|
1611
2283
|
|
|
2284
|
+
/** Emitted when `coldAdmin` withdraws accumulated protocol fees to the configured recipient. */
|
|
1612
2285
|
export type ProtocolFeeWithdrawRecord = {
|
|
1613
2286
|
ts: BN;
|
|
2287
|
+
/** perp market index for a perp-fee withdrawal, else the spot market index */
|
|
1614
2288
|
marketIndex: number;
|
|
2289
|
+
/** true if this withdrawal drained a perp market's `protocolFeePool` (sourced from the quote spot vault); false for a spot market withdrawal */
|
|
1615
2290
|
isPerp: boolean;
|
|
2291
|
+
/** the spot market the tokens were drawn from */
|
|
1616
2292
|
spotMarketIndex: number;
|
|
2293
|
+
/** spot market token-mint precision */
|
|
1617
2294
|
amount: BN;
|
|
1618
2295
|
recipientTokenAccount: PublicKey;
|
|
1619
2296
|
};
|
|
1620
2297
|
|
|
2298
|
+
/** Emitted when a builder's/referrer's accrued `RevenueShareOrder` fees are settled into their `RevenueShareAccount`. */
|
|
1621
2299
|
export type RevenueShareSettleRecord = {
|
|
1622
2300
|
ts: BN;
|
|
2301
|
+
/** set when this settle paid a builder fee */
|
|
1623
2302
|
builder: PublicKey | null;
|
|
2303
|
+
/** set when this settle paid a referral reward */
|
|
1624
2304
|
referrer: PublicKey | null;
|
|
2305
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1625
2306
|
feeSettled: BN;
|
|
1626
2307
|
marketIndex: number;
|
|
1627
2308
|
marketType: MarketType;
|
|
2309
|
+
/** the builder's `RevenueShareAccount.totalReferrerRewards` after this settle, QUOTE_PRECISION (1e6) */
|
|
1628
2310
|
builderTotalReferrerRewards: BN;
|
|
2311
|
+
/** the builder's `RevenueShareAccount.totalBuilderRewards` after this settle, QUOTE_PRECISION (1e6) */
|
|
1629
2312
|
builderTotalBuilderRewards: BN;
|
|
1630
2313
|
builderSubAccountId: number;
|
|
1631
2314
|
};
|
|
1632
2315
|
|
|
2316
|
+
/** Admin instruction params to add one constituent's weight in a perp market's AMM constituent mapping (used to route hedge flow). */
|
|
1633
2317
|
export type AddAmmConstituentMappingDatum = {
|
|
1634
2318
|
constituentIndex: number;
|
|
1635
2319
|
perpMarketIndex: number;
|
|
2320
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
1636
2321
|
weight: BN;
|
|
1637
2322
|
};
|
|
1638
2323
|
|
|
2324
|
+
/** One entry of an `AmmConstituentMapping`, weighting how much of a perp market's hedge flow routes to a given LP-pool constituent. */
|
|
1639
2325
|
export type AmmConstituentDatum = AddAmmConstituentMappingDatum & {
|
|
1640
2326
|
lastSlot: BN;
|
|
1641
2327
|
};
|
|
1642
2328
|
|
|
2329
|
+
/** Decoded mirror of the `AmmConstituentMapping` account: which LP-pool constituents each perp market hedges into, and by how much. */
|
|
1643
2330
|
export type AmmConstituentMapping = {
|
|
1644
2331
|
lpPool: PublicKey;
|
|
1645
2332
|
bump: number;
|
|
1646
2333
|
weights: AmmConstituentDatum[];
|
|
1647
2334
|
};
|
|
1648
2335
|
|
|
2336
|
+
/** One perp market's target-hedge-position entry inside a `ConstituentTargetBaseAccount`. */
|
|
1649
2337
|
export type TargetDatum = {
|
|
2338
|
+
/** bps; estimated cost to trade into/out of the target position */
|
|
1650
2339
|
costToTradeBps: number;
|
|
1651
2340
|
lastOracleSlot: BN;
|
|
1652
2341
|
lastPositionSlot: BN;
|
|
2342
|
+
/** BASE_PRECISION (1e9); the target hedge position size */
|
|
1653
2343
|
targetBase: BN;
|
|
1654
2344
|
};
|
|
1655
2345
|
|
|
2346
|
+
/** Decoded mirror of the `ConstituentTargetBase` account: the LP pool's per-perp-market target hedge positions. */
|
|
1656
2347
|
export type ConstituentTargetBaseAccount = {
|
|
1657
2348
|
lpPool: PublicKey;
|
|
1658
2349
|
bump: number;
|
|
1659
2350
|
targets: TargetDatum[];
|
|
1660
2351
|
};
|
|
1661
2352
|
|
|
2353
|
+
/** Decoded mirror of the `ConstituentCorrelations` account: pairwise correlation coefficients between an LP pool's constituents, used in swap-fee pricing. */
|
|
1662
2354
|
export type ConstituentCorrelations = {
|
|
1663
2355
|
lpPool: PublicKey;
|
|
1664
2356
|
bump: number;
|
|
2357
|
+
/** PERCENTAGE_PRECISION (1e6), signed; flattened row-major correlation matrix */
|
|
1665
2358
|
correlations: BN[];
|
|
1666
2359
|
};
|
|
1667
2360
|
|
|
2361
|
+
/** Decoded mirror of the on-chain `LPPool` account: a hedging vault that mints/redeems LP tokens against a basket of spot-market constituents and hedges perp-market exposure. */
|
|
1668
2362
|
export type LPPoolAccount = {
|
|
1669
2363
|
lpPoolId: number;
|
|
1670
2364
|
pubkey: PublicKey;
|
|
2365
|
+
/** the LP token mint */
|
|
1671
2366
|
mint: PublicKey;
|
|
1672
2367
|
whitelistMint: PublicKey;
|
|
1673
2368
|
constituentTargetBase: PublicKey;
|
|
1674
2369
|
constituentCorrelations: PublicKey;
|
|
2370
|
+
/** QUOTE_PRECISION (1e6); mint requests that would push AUM above this are rejected */
|
|
1675
2371
|
maxAum: BN;
|
|
2372
|
+
/** QUOTE_PRECISION (1e6); AUM of the vault in USD, updated lazily */
|
|
1676
2373
|
lastAum: BN;
|
|
2374
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1677
2375
|
cumulativeQuoteSentToPerpMarkets: BN;
|
|
2376
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1678
2377
|
cumulativeQuoteReceivedFromPerpMarkets: BN;
|
|
2378
|
+
/** signed, QUOTE_PRECISION (1e6); total fees paid for minting and redeeming LP tokens */
|
|
1679
2379
|
totalMintRedeemFeesPaid: BN;
|
|
1680
2380
|
lastAumSlot: BN;
|
|
2381
|
+
/** token-mint precision cap on a single settle's quote transfer */
|
|
1681
2382
|
maxSettleQuoteAmount: BN;
|
|
1682
2383
|
mintRedeemId: BN;
|
|
1683
2384
|
settleId: BN;
|
|
2385
|
+
/** PERCENTAGE_PRECISION (1e6); floor fee charged on mint/redeem */
|
|
1684
2386
|
minMintFee: BN;
|
|
2387
|
+
/** LP token precision; the LP mint's total supply */
|
|
1685
2388
|
tokenSupply: BN;
|
|
2389
|
+
/** PERCENTAGE_PRECISION (1e6); pool-wide volatility parameter feeding swap-fee/target pricing */
|
|
1686
2390
|
volatility: BN;
|
|
1687
2391
|
constituents: number;
|
|
1688
|
-
|
|
2392
|
+
quoteConsituentIndex: number;
|
|
1689
2393
|
bump: number;
|
|
2394
|
+
/** no precision — a raw constant used in swap-fee execution-cost pricing */
|
|
1690
2395
|
gammaExecution: number;
|
|
2396
|
+
/** no precision — a raw constant used in swap-fee pricing */
|
|
1691
2397
|
xi: number;
|
|
2398
|
+
/** bps of fee per 10 slots of oracle-target delay */
|
|
1692
2399
|
targetOracleDelayFeeBpsPer10Slots: number;
|
|
2400
|
+
/** bps of fee per 10 slots of position-target delay */
|
|
1693
2401
|
targetPositionDelayFeeBpsPer10Slots: number;
|
|
1694
2402
|
};
|
|
1695
2403
|
|
|
2404
|
+
/** A constituent's spot-market balance inside an LP pool (parallel to `PoolBalance` but tracking cumulative deposits too). */
|
|
1696
2405
|
export type ConstituentSpotBalance = {
|
|
2406
|
+
/** SPOT_BALANCE_PRECISION (1e9) scaled balance */
|
|
1697
2407
|
scaledBalance: BN;
|
|
2408
|
+
/** token mint precision */
|
|
1698
2409
|
cumulativeDeposits: BN;
|
|
1699
2410
|
marketIndex: number;
|
|
1700
2411
|
balanceType: SpotBalanceType;
|
|
1701
2412
|
};
|
|
1702
2413
|
|
|
2414
|
+
/** Admin instruction params for `initializeConstituent`, configuring a new LP-pool spot-market constituent. */
|
|
1703
2415
|
export type InitializeConstituentParams = {
|
|
1704
2416
|
spotMarketIndex: number;
|
|
1705
2417
|
decimals: number;
|
|
2418
|
+
/** PERCENTAGE_PRECISION (1e6); max allowed deviation from target weight before rebalance pressure kicks in */
|
|
1706
2419
|
maxWeightDeviation: BN;
|
|
2420
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
1707
2421
|
swapFeeMin: BN;
|
|
2422
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
1708
2423
|
swapFeeMax: BN;
|
|
2424
|
+
/** token mint precision; borrow cap for this constituent */
|
|
1709
2425
|
maxBorrowTokenAmount: BN;
|
|
2426
|
+
/** slots; oracle updates older than this are treated as stale for this constituent */
|
|
1710
2427
|
oracleStalenessThreshold: BN;
|
|
2428
|
+
/** bps; estimated cost to trade this constituent */
|
|
1711
2429
|
costToTrade: number;
|
|
2430
|
+
/** PERCENTAGE_PRECISION (1e6); weight applied when this constituent derives its price from another constituent */
|
|
1712
2431
|
derivativeWeight: BN;
|
|
1713
2432
|
constituentDerivativeIndex?: number;
|
|
2433
|
+
/** PERCENTAGE_PRECISION (1e6); max allowed depeg from the derivative reference before the constituent is treated as broken */
|
|
1714
2434
|
constituentDerivativeDepegThreshold?: BN;
|
|
2435
|
+
/** PERCENTAGE_PRECISION (1e6), signed; this constituent's correlation with every other constituent */
|
|
1715
2436
|
constituentCorrelations: BN[];
|
|
2437
|
+
/** PERCENTAGE_PRECISION (1e6) */
|
|
1716
2438
|
volatility: BN;
|
|
1717
2439
|
gammaExecution?: number;
|
|
1718
2440
|
gammaInventory?: number;
|
|
1719
2441
|
xi?: number;
|
|
1720
2442
|
};
|
|
1721
2443
|
|
|
2444
|
+
/** Lifecycle status of an LP-pool `ConstituentAccount`. */
|
|
1722
2445
|
export enum ConstituentStatus {
|
|
1723
2446
|
ACTIVE = 0,
|
|
2447
|
+
/** may only shrink toward its target weight, not grow */
|
|
1724
2448
|
REDUCE_ONLY = 1,
|
|
1725
2449
|
DECOMMISSIONED = 2,
|
|
1726
2450
|
}
|
|
2451
|
+
/** Bitmask mirror of `ConstituentAccount.pausedOperations`, gating which LP-pool operations a constituent allows. */
|
|
1727
2452
|
export enum ConstituentLpOperation {
|
|
1728
2453
|
Swap = 0b00000001,
|
|
1729
2454
|
Deposit = 0b00000010,
|
|
1730
2455
|
Withdraw = 0b00000100,
|
|
1731
2456
|
}
|
|
1732
2457
|
|
|
2458
|
+
/** Decoded mirror of the on-chain `Constituent` account: one spot-market asset inside an LP pool's basket. */
|
|
1733
2459
|
export type ConstituentAccount = {
|
|
1734
2460
|
pubkey: PublicKey;
|
|
1735
2461
|
mint: PublicKey;
|
|
1736
2462
|
lpPool: PublicKey;
|
|
1737
2463
|
vault: PublicKey;
|
|
2464
|
+
/** signed, positive = fees received, negative = fees paid; PERCENTAGE_PRECISION-derived token units */
|
|
1738
2465
|
totalSwapFees: BN;
|
|
1739
2466
|
spotBalance: ConstituentSpotBalance;
|
|
2467
|
+
/** token mint precision */
|
|
1740
2468
|
lastSpotBalanceTokenAmount: BN;
|
|
2469
|
+
/** token mint precision */
|
|
1741
2470
|
cumulativeSpotInterestAccruedTokenAmount: BN;
|
|
2471
|
+
/** PERCENTAGE_PRECISION (1e6); max allowed deviation from target weight */
|
|
1742
2472
|
maxWeightDeviation: BN;
|
|
2473
|
+
/** PERCENTAGE_PRECISION (1e6); min fee charged on swaps to/from this constituent */
|
|
1743
2474
|
swapFeeMin: BN;
|
|
2475
|
+
/** PERCENTAGE_PRECISION (1e6); max fee charged on swaps to/from this constituent */
|
|
1744
2476
|
swapFeeMax: BN;
|
|
2477
|
+
/** token mint precision */
|
|
1745
2478
|
maxBorrowTokenAmount: BN;
|
|
2479
|
+
/** token mint precision; the vault's actual token account balance */
|
|
1746
2480
|
vaultTokenBalance: BN;
|
|
1747
2481
|
lastOraclePrice: BN;
|
|
1748
2482
|
lastOracleSlot: BN;
|
|
2483
|
+
/** slots; delay allowed for a valid AUM calculation before this constituent's price is considered stale */
|
|
1749
2484
|
oracleStalenessThreshold: BN;
|
|
2485
|
+
/** token mint precision; user's token balance snapshotted at `beginSwap`-style flash accounting */
|
|
1750
2486
|
flashLoanInitialTokenAmount: BN;
|
|
1751
2487
|
nextSwapId: BN;
|
|
2488
|
+
/** PERCENTAGE_PRECISION (1e6); share of derivative weight routed to this constituent specifically; 0 if this constituent has no derivative weight */
|
|
1752
2489
|
derivativeWeight: BN;
|
|
2490
|
+
/** PERCENTAGE_PRECISION (1e6); 1 = 1% */
|
|
1753
2491
|
volatility: BN;
|
|
2492
|
+
/** PERCENTAGE_PRECISION (1e6); max allowed depeg from the parent constituent before this derivative is treated as broken */
|
|
1754
2493
|
constituentDerivativeDepegThreshold: BN;
|
|
2494
|
+
/** the parent constituent's index if this is a derivative (e.g. dSOL -> SOL); -1 if this constituent is itself a parent */
|
|
1755
2495
|
constituentDerivativeIndex: number;
|
|
1756
2496
|
spotMarketIndex: number;
|
|
1757
2497
|
constituentIndex: number;
|
|
1758
2498
|
decimals: number;
|
|
1759
2499
|
bump: number;
|
|
1760
2500
|
vaultBump: number;
|
|
2501
|
+
/** no precision — raw constant used in swap-fee inventory-skew pricing */
|
|
1761
2502
|
gammaInventory: number;
|
|
2503
|
+
/** no precision — raw constant used in swap-fee execution-cost pricing */
|
|
1762
2504
|
gammaExecution: number;
|
|
2505
|
+
/** no precision — raw constant used in swap-fee pricing */
|
|
1763
2506
|
xi: number;
|
|
2507
|
+
/** see `ConstituentStatus` */
|
|
1764
2508
|
status: number;
|
|
2509
|
+
/** bitmask, see `ConstituentLpOperation` */
|
|
1765
2510
|
pausedOperations: number;
|
|
1766
2511
|
};
|
|
1767
2512
|
|
|
2513
|
+
/** One perp market's cached AMM/settlement snapshot inside an `AmmCache`, refreshed by the keeper crank so LP-pool settlement doesn't need to reload the full `PerpMarketAccount`. */
|
|
1768
2514
|
export type CacheInfo = {
|
|
1769
2515
|
oracle: PublicKey;
|
|
1770
2516
|
lastFeePoolTokenAmount: BN;
|
|
2517
|
+
/** signed */
|
|
1771
2518
|
lastNetPnlPoolTokenAmount: BN;
|
|
1772
2519
|
lastExchangeFees: BN;
|
|
1773
2520
|
lastSettleAmmExFees: BN;
|
|
2521
|
+
/** signed */
|
|
1774
2522
|
lastSettleAmmPnl: BN;
|
|
2523
|
+
/** BASE_PRECISION (1e9), signed; the AMM's net position at last cache update */
|
|
1775
2524
|
position: BN;
|
|
1776
2525
|
slot: BN;
|
|
1777
2526
|
lastSettleAmount: BN;
|
|
1778
2527
|
lastSettleSlot: BN;
|
|
1779
2528
|
lastSettleTs: BN;
|
|
2529
|
+
/** signed; quote owed from the LP pool to this market (or vice versa if negative) */
|
|
1780
2530
|
quoteOwedFromLpPool: BN;
|
|
2531
|
+
/** signed; cap on the AMM's hedgeable inventory */
|
|
1781
2532
|
ammInventoryLimit: BN;
|
|
2533
|
+
/** PRICE_PRECISION (1e6), signed */
|
|
1782
2534
|
oraclePrice: BN;
|
|
1783
2535
|
oracleSlot: BN;
|
|
2536
|
+
/** numeric `OracleSourceNum` discriminant */
|
|
1784
2537
|
oracleSource: number;
|
|
2538
|
+
/** `OracleValidity` discriminant at last cache update */
|
|
1785
2539
|
oracleValidity: number;
|
|
1786
2540
|
lpStatusForPerpMarket: number;
|
|
1787
2541
|
ammPositionScalar: number;
|
|
1788
2542
|
marketIndex: number;
|
|
1789
2543
|
};
|
|
1790
2544
|
|
|
2545
|
+
/** Decoded mirror of the on-chain `AmmCache` account: one `CacheInfo` per perp market, indexed by `marketIndex`. */
|
|
1791
2546
|
export type AmmCache = {
|
|
1792
2547
|
bump: number;
|
|
1793
2548
|
cache: CacheInfo[];
|
|
1794
2549
|
};
|
|
1795
2550
|
|
|
2551
|
+
/** SDK-computed result of checking whether a user account can currently be liquidated. */
|
|
1796
2552
|
export type AccountLiquidatableStatus = {
|
|
1797
2553
|
canBeLiquidated: boolean;
|
|
2554
|
+
/** QUOTE_PRECISION (1e6); the maintenance margin requirement compared against */
|
|
1798
2555
|
marginRequirement: BN;
|
|
2556
|
+
/** signed, QUOTE_PRECISION (1e6) */
|
|
1799
2557
|
totalCollateral: BN;
|
|
1800
2558
|
};
|
|
1801
2559
|
|
|
2560
|
+
/** Direction of an admin `transferFeeAndPnlPool` action, moving funds between a perp market's protocol fee pool and its pnl pool. */
|
|
1802
2561
|
export class TransferFeeAndPnlPoolDirection {
|
|
1803
2562
|
static readonly FEE_TO_PNL_POOL = { feeToPnlPool: {} };
|
|
1804
2563
|
static readonly PNL_TO_FEE_POOL = { pnlToFeePool: {} };
|
|
1805
2564
|
}
|
|
1806
2565
|
|
|
2566
|
+
/** Emitted when an admin transfers funds between a perp market's fee pool and pnl pool (`transferFeeAndPnlPool`). The two market indices may refer to the same or different perp markets. */
|
|
1807
2567
|
export type TransferFeeAndPnlPoolRecord = {
|
|
1808
2568
|
ts: BN;
|
|
1809
2569
|
slot: BN;
|
|
1810
2570
|
perpMarketIndexWithFeePool: number;
|
|
1811
2571
|
perpMarketIndexWithPnlPool: number;
|
|
1812
2572
|
direction: TransferFeeAndPnlPoolDirection;
|
|
2573
|
+
/** QUOTE_PRECISION (1e6) */
|
|
1813
2574
|
amount: BN;
|
|
1814
2575
|
};
|