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