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