@velocity-exchange/sdk 0.0.1
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/.prettierignore +1 -0
- package/.yarn/install-state.gz +0 -0
- package/README.md +275 -0
- package/VERSION +1 -0
- package/build-browser.js +58 -0
- package/bun.lock +1885 -0
- package/esbuild-shims.js +12 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.js +38 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +38 -0
- package/lib/browser/accounts/bulkAccountLoader.d.ts +37 -0
- package/lib/browser/accounts/bulkAccountLoader.js +222 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/browser/accounts/bulkUserSubscription.d.ts +7 -0
- package/lib/browser/accounts/bulkUserSubscription.js +21 -0
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.d.ts +44 -0
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.js +152 -0
- package/lib/browser/accounts/fetch.d.ts +17 -0
- package/lib/browser/accounts/fetch.js +60 -0
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +17 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +162 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +37 -0
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +378 -0
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +25 -0
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +203 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +179 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.js +28 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +28 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +16 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +101 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +69 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +457 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +162 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +48 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +48 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +78 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +26 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +78 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +102 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +94 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +73 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +420 -0
- package/lib/browser/accounts/testBulkAccountLoader.d.ts +4 -0
- package/lib/browser/accounts/testBulkAccountLoader.js +43 -0
- package/lib/browser/accounts/types.d.ts +205 -0
- package/lib/browser/accounts/types.js +16 -0
- package/lib/browser/accounts/utils.d.ts +8 -0
- package/lib/browser/accounts/utils.js +49 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.js +170 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +109 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +395 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +31 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +120 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +145 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +744 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +145 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +744 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +61 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +22 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +77 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +400 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +91 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +446 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +54 -0
- package/lib/browser/addresses/marketAddresses.d.ts +2 -0
- package/lib/browser/addresses/marketAddresses.js +15 -0
- package/lib/browser/addresses/pda.d.ts +47 -0
- package/lib/browser/addresses/pda.js +263 -0
- package/lib/browser/adminClient.d.ts +402 -0
- package/lib/browser/adminClient.js +2798 -0
- package/lib/browser/assert/assert.d.ts +1 -0
- package/lib/browser/assert/assert.js +9 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +14 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +32 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/browser/auctionSubscriber/index.d.ts +3 -0
- package/lib/browser/auctionSubscriber/index.js +19 -0
- package/lib/browser/auctionSubscriber/types.d.ts +14 -0
- package/lib/browser/auctionSubscriber/types.js +2 -0
- package/lib/browser/bankrun/bankrunConnection.d.ts +76 -0
- package/lib/browser/bankrun/bankrunConnection.js +348 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +27 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +89 -0
- package/lib/browser/blockhashSubscriber/index.d.ts +1 -0
- package/lib/browser/blockhashSubscriber/index.js +17 -0
- package/lib/browser/blockhashSubscriber/types.d.ts +7 -0
- package/lib/browser/blockhashSubscriber/types.js +2 -0
- package/lib/browser/clock/clockSubscriber.d.ts +31 -0
- package/lib/browser/clock/clockSubscriber.js +80 -0
- package/lib/browser/config.d.ts +75 -0
- package/lib/browser/config.js +164 -0
- package/lib/browser/constants/index.d.ts +10 -0
- package/lib/browser/constants/index.js +26 -0
- package/lib/browser/constants/insuranceFund.d.ts +5 -0
- package/lib/browser/constants/insuranceFund.js +9 -0
- package/lib/browser/constants/numericConstants.d.ts +73 -0
- package/lib/browser/constants/numericConstants.js +79 -0
- package/lib/browser/constants/perpMarkets.d.ts +21 -0
- package/lib/browser/constants/perpMarkets.js +971 -0
- package/lib/browser/constants/spotMarkets.d.ts +24 -0
- package/lib/browser/constants/spotMarkets.js +797 -0
- package/lib/browser/constants/txConstants.d.ts +1 -0
- package/lib/browser/constants/txConstants.js +4 -0
- package/lib/browser/constituentMap/constituentMap.d.ts +66 -0
- package/lib/browser/constituentMap/constituentMap.js +177 -0
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.d.ts +24 -0
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +60 -0
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +24 -0
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +58 -0
- package/lib/browser/core/VelocityCore.d.ts +226 -0
- package/lib/browser/core/VelocityCore.js +138 -0
- package/lib/browser/core/index.d.ts +12 -0
- package/lib/browser/core/index.js +28 -0
- package/lib/browser/core/instructions/deposit.d.ts +19 -0
- package/lib/browser/core/instructions/deposit.js +19 -0
- package/lib/browser/core/instructions/fill.d.ts +13 -0
- package/lib/browser/core/instructions/fill.js +17 -0
- package/lib/browser/core/instructions/funding.d.ts +9 -0
- package/lib/browser/core/instructions/funding.js +13 -0
- package/lib/browser/core/instructions/liquidation.d.ts +15 -0
- package/lib/browser/core/instructions/liquidation.js +17 -0
- package/lib/browser/core/instructions/orders.d.ts +22 -0
- package/lib/browser/core/instructions/orders.js +27 -0
- package/lib/browser/core/instructions/perpOrders.d.ts +78 -0
- package/lib/browser/core/instructions/perpOrders.js +99 -0
- package/lib/browser/core/instructions/settlement.d.ts +11 -0
- package/lib/browser/core/instructions/settlement.js +15 -0
- package/lib/browser/core/instructions/trigger.d.ts +11 -0
- package/lib/browser/core/instructions/trigger.js +15 -0
- package/lib/browser/core/instructions/withdraw.d.ts +20 -0
- package/lib/browser/core/instructions/withdraw.js +20 -0
- package/lib/browser/core/remainingAccounts.d.ts +27 -0
- package/lib/browser/core/remainingAccounts.js +122 -0
- package/lib/browser/core/signedMsg.d.ts +17 -0
- package/lib/browser/core/signedMsg.js +39 -0
- package/lib/browser/decode/customCoder.d.ts +44 -0
- package/lib/browser/decode/customCoder.js +64 -0
- package/lib/browser/decode/user.d.ts +4 -0
- package/lib/browser/decode/user.js +337 -0
- package/lib/browser/dlob/DLOB.d.ts +253 -0
- package/lib/browser/dlob/DLOB.js +1137 -0
- package/lib/browser/dlob/DLOBNode.d.ts +70 -0
- package/lib/browser/dlob/DLOBNode.js +103 -0
- package/lib/browser/dlob/DLOBSubscriber.d.ts +57 -0
- package/lib/browser/dlob/DLOBSubscriber.js +143 -0
- package/lib/browser/dlob/NodeList.d.ts +27 -0
- package/lib/browser/dlob/NodeList.js +126 -0
- package/lib/browser/dlob/orderBookLevels.d.ts +77 -0
- package/lib/browser/dlob/orderBookLevels.js +404 -0
- package/lib/browser/dlob/types.d.ts +18 -0
- package/lib/browser/dlob/types.js +2 -0
- package/lib/browser/events/eventList.d.ts +22 -0
- package/lib/browser/events/eventList.js +80 -0
- package/lib/browser/events/eventSubscriber.d.ts +55 -0
- package/lib/browser/events/eventSubscriber.js +229 -0
- package/lib/browser/events/eventsServerLogProvider.d.ts +21 -0
- package/lib/browser/events/eventsServerLogProvider.js +121 -0
- package/lib/browser/events/fetchLogs.d.ts +25 -0
- package/lib/browser/events/fetchLogs.js +99 -0
- package/lib/browser/events/parse.d.ts +8 -0
- package/lib/browser/events/parse.js +199 -0
- package/lib/browser/events/pollingLogProvider.d.ts +17 -0
- package/lib/browser/events/pollingLogProvider.js +58 -0
- package/lib/browser/events/sort.d.ts +2 -0
- package/lib/browser/events/sort.js +24 -0
- package/lib/browser/events/txEventCache.d.ts +24 -0
- package/lib/browser/events/txEventCache.js +71 -0
- package/lib/browser/events/types.d.ts +104 -0
- package/lib/browser/events/types.js +36 -0
- package/lib/browser/events/webSocketLogProvider.d.ts +24 -0
- package/lib/browser/events/webSocketLogProvider.js +96 -0
- package/lib/browser/factory/bigNum.d.ts +122 -0
- package/lib/browser/factory/bigNum.js +500 -0
- package/lib/browser/factory/oracleClient.d.ts +5 -0
- package/lib/browser/factory/oracleClient.js +53 -0
- package/lib/browser/idl/drift.d.ts +23894 -0
- package/lib/browser/idl/drift.js +2 -0
- package/lib/browser/idl/drift.json +18698 -0
- package/lib/browser/idl/pyth.d.ts +97 -0
- package/lib/browser/idl/pyth.js +2 -0
- package/lib/browser/idl/token_faucet.d.ts +197 -0
- package/lib/browser/idl/token_faucet.js +2 -0
- package/lib/browser/idl/token_faucet.json +229 -0
- package/lib/browser/index.d.ts +144 -0
- package/lib/browser/index.js +175 -0
- package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +35 -0
- package/lib/browser/indicative-quotes/indicativeQuotesSender.js +192 -0
- package/lib/browser/isomorphic/anchor.browser.d.ts +24 -0
- package/lib/browser/isomorphic/anchor.browser.js +60 -0
- package/lib/browser/isomorphic/anchor.d.ts +24 -0
- package/lib/browser/isomorphic/anchor.js +60 -0
- package/lib/browser/isomorphic/anchor29.browser.d.ts +12 -0
- package/lib/browser/isomorphic/anchor29.browser.js +48 -0
- package/lib/browser/isomorphic/anchor29.d.ts +12 -0
- package/lib/browser/isomorphic/anchor29.js +48 -0
- package/lib/browser/isomorphic/grpc.browser.d.ts +1 -0
- package/lib/browser/isomorphic/grpc.browser.js +8 -0
- package/lib/browser/isomorphic/grpc.d.ts +1 -0
- package/lib/browser/isomorphic/grpc.js +8 -0
- package/lib/browser/jupiter/jupiterClient.d.ts +291 -0
- package/lib/browser/jupiter/jupiterClient.js +164 -0
- package/lib/browser/keypair.d.ts +2 -0
- package/lib/browser/keypair.js +28 -0
- package/lib/browser/marginCalculation.d.ts +67 -0
- package/lib/browser/marginCalculation.js +176 -0
- package/lib/browser/marinade/index.d.ts +12 -0
- package/lib/browser/marinade/index.js +36 -0
- package/lib/browser/marinade/types.d.ts +1963 -0
- package/lib/browser/marinade/types.js +1965 -0
- package/lib/browser/math/amm.d.ts +98 -0
- package/lib/browser/math/amm.js +671 -0
- package/lib/browser/math/auction.d.ts +65 -0
- package/lib/browser/math/auction.js +261 -0
- package/lib/browser/math/bankruptcy.d.ts +2 -0
- package/lib/browser/math/bankruptcy.js +32 -0
- package/lib/browser/math/builder.d.ts +5 -0
- package/lib/browser/math/builder.js +22 -0
- package/lib/browser/math/conversion.d.ts +4 -0
- package/lib/browser/math/conversion.js +21 -0
- package/lib/browser/math/exchangeStatus.d.ts +8 -0
- package/lib/browser/math/exchangeStatus.js +85 -0
- package/lib/browser/math/funding.d.ts +44 -0
- package/lib/browser/math/funding.js +260 -0
- package/lib/browser/math/insurance.d.ts +8 -0
- package/lib/browser/math/insurance.js +74 -0
- package/lib/browser/math/liquidation.d.ts +7 -0
- package/lib/browser/math/liquidation.js +134 -0
- package/lib/browser/math/margin.d.ts +45 -0
- package/lib/browser/math/margin.js +205 -0
- package/lib/browser/math/market.d.ts +50 -0
- package/lib/browser/math/market.js +234 -0
- package/lib/browser/math/oracles.d.ts +19 -0
- package/lib/browser/math/oracles.js +215 -0
- package/lib/browser/math/orders.d.ts +36 -0
- package/lib/browser/math/orders.js +294 -0
- package/lib/browser/math/position.d.ts +71 -0
- package/lib/browser/math/position.js +232 -0
- package/lib/browser/math/repeg.d.ts +22 -0
- package/lib/browser/math/repeg.js +164 -0
- package/lib/browser/math/spotBalance.d.ts +85 -0
- package/lib/browser/math/spotBalance.js +438 -0
- package/lib/browser/math/spotMarket.d.ts +11 -0
- package/lib/browser/math/spotMarket.js +49 -0
- package/lib/browser/math/spotPosition.d.ts +19 -0
- package/lib/browser/math/spotPosition.js +79 -0
- package/lib/browser/math/state.d.ts +8 -0
- package/lib/browser/math/state.js +44 -0
- package/lib/browser/math/superStake.d.ts +168 -0
- package/lib/browser/math/superStake.js +308 -0
- package/lib/browser/math/tiers.d.ts +4 -0
- package/lib/browser/math/tiers.js +52 -0
- package/lib/browser/math/trade.d.ts +93 -0
- package/lib/browser/math/trade.js +503 -0
- package/lib/browser/math/utils.d.ts +23 -0
- package/lib/browser/math/utils.js +113 -0
- package/lib/browser/memcmp.d.ts +18 -0
- package/lib/browser/memcmp.js +162 -0
- package/lib/browser/oracles/oracleClientCache.d.ts +9 -0
- package/lib/browser/oracles/oracleClientCache.js +19 -0
- package/lib/browser/oracles/oracleId.d.ts +9 -0
- package/lib/browser/oracles/oracleId.js +89 -0
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +12 -0
- package/lib/browser/oracles/prelaunchOracleClient.js +24 -0
- package/lib/browser/oracles/pythClient.d.ts +14 -0
- package/lib/browser/oracles/pythClient.js +51 -0
- package/lib/browser/oracles/pythLazerClient.d.ts +16 -0
- package/lib/browser/oracles/pythLazerClient.js +61 -0
- package/lib/browser/oracles/quoteAssetOracleClient.d.ts +10 -0
- package/lib/browser/oracles/quoteAssetOracleClient.js +21 -0
- package/lib/browser/oracles/strictOraclePrice.d.ts +9 -0
- package/lib/browser/oracles/strictOraclePrice.js +17 -0
- package/lib/browser/oracles/types.d.ts +33 -0
- package/lib/browser/oracles/types.js +2 -0
- package/lib/browser/oracles/utils.d.ts +4 -0
- package/lib/browser/oracles/utils.js +8 -0
- package/lib/browser/orderParams.d.ts +29 -0
- package/lib/browser/orderParams.js +44 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +45 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.js +193 -0
- package/lib/browser/orderSubscriber/PollingSubscription.d.ts +12 -0
- package/lib/browser/orderSubscriber/PollingSubscription.js +23 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +23 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +67 -0
- package/lib/browser/orderSubscriber/grpcSubscription.d.ts +22 -0
- package/lib/browser/orderSubscriber/grpcSubscription.js +75 -0
- package/lib/browser/orderSubscriber/index.d.ts +7 -0
- package/lib/browser/orderSubscriber/index.js +23 -0
- package/lib/browser/orderSubscriber/types.d.ts +35 -0
- package/lib/browser/orderSubscriber/types.js +2 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +5 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.js +16 -0
- package/lib/browser/priorityFee/averageStrategy.d.ts +5 -0
- package/lib/browser/priorityFee/averageStrategy.js +11 -0
- package/lib/browser/priorityFee/ewmaStrategy.d.ts +11 -0
- package/lib/browser/priorityFee/ewmaStrategy.js +33 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +20 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +46 -0
- package/lib/browser/priorityFee/index.d.ts +16 -0
- package/lib/browser/priorityFee/index.js +32 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +5 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.js +17 -0
- package/lib/browser/priorityFee/maxStrategy.d.ts +7 -0
- package/lib/browser/priorityFee/maxStrategy.js +9 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +48 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +193 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +50 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +96 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +6 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +21 -0
- package/lib/browser/priorityFee/types.d.ts +35 -0
- package/lib/browser/priorityFee/types.js +10 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +21 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +28 -0
- package/lib/browser/pyth/constants.d.ts +3 -0
- package/lib/browser/pyth/constants.js +6 -0
- package/lib/browser/pyth/index.d.ts +4 -0
- package/lib/browser/pyth/index.js +12 -0
- package/lib/browser/pyth/pythLazerSubscriber.d.ts +91 -0
- package/lib/browser/pyth/pythLazerSubscriber.js +276 -0
- package/lib/browser/pyth/types.d.ts +2226 -0
- package/lib/browser/pyth/types.js +2224 -0
- package/lib/browser/pyth/utils.d.ts +2 -0
- package/lib/browser/pyth/utils.js +10 -0
- package/lib/browser/slot/SlotSubscriber.d.ts +27 -0
- package/lib/browser/slot/SlotSubscriber.js +76 -0
- package/lib/browser/slot/SlothashSubscriber.d.ts +25 -0
- package/lib/browser/slot/SlothashSubscriber.js +88 -0
- package/lib/browser/swap/UnifiedSwapClient.d.ts +120 -0
- package/lib/browser/swap/UnifiedSwapClient.js +179 -0
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +22 -0
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +57 -0
- package/lib/browser/swift/index.d.ts +10 -0
- package/lib/browser/swift/index.js +26 -0
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +42 -0
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +118 -0
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +63 -0
- package/lib/browser/swift/swiftOrderSubscriber.js +187 -0
- package/lib/browser/testClient.d.ts +8 -0
- package/lib/browser/testClient.js +24 -0
- package/lib/browser/titan/titanClient.d.ts +90 -0
- package/lib/browser/titan/titanClient.js +227 -0
- package/lib/browser/token/index.d.ts +5 -0
- package/lib/browser/token/index.js +15 -0
- package/lib/browser/tokenFaucet.d.ts +41 -0
- package/lib/browser/tokenFaucet.js +188 -0
- package/lib/browser/tx/baseTxSender.d.ts +59 -0
- package/lib/browser/tx/baseTxSender.js +292 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +8 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +28 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
- package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/browser/tx/blockhashFetcher/types.js +2 -0
- package/lib/browser/tx/fastSingleTxSender.d.ts +41 -0
- package/lib/browser/tx/fastSingleTxSender.js +86 -0
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +37 -0
- package/lib/browser/tx/forwardOnlyTxSender.js +92 -0
- package/lib/browser/tx/priorityFeeCalculator.d.ts +44 -0
- package/lib/browser/tx/priorityFeeCalculator.js +85 -0
- package/lib/browser/tx/reportTransactionError.d.ts +20 -0
- package/lib/browser/tx/reportTransactionError.js +103 -0
- package/lib/browser/tx/retryTxSender.d.ts +37 -0
- package/lib/browser/tx/retryTxSender.js +86 -0
- package/lib/browser/tx/txHandler.d.ts +173 -0
- package/lib/browser/tx/txHandler.js +522 -0
- package/lib/browser/tx/txParamProcessor.d.ts +26 -0
- package/lib/browser/tx/txParamProcessor.js +92 -0
- package/lib/browser/tx/types.d.ts +29 -0
- package/lib/browser/tx/types.js +20 -0
- package/lib/browser/tx/utils.d.ts +6 -0
- package/lib/browser/tx/utils.js +78 -0
- package/lib/browser/tx/whileValidTxSender.d.ts +45 -0
- package/lib/browser/tx/whileValidTxSender.js +168 -0
- package/lib/browser/types.d.ts +1747 -0
- package/lib/browser/types.js +427 -0
- package/lib/browser/user.d.ts +446 -0
- package/lib/browser/user.js +2372 -0
- package/lib/browser/userConfig.d.ts +31 -0
- package/lib/browser/userConfig.js +2 -0
- package/lib/browser/userMap/PollingSubscription.d.ts +15 -0
- package/lib/browser/userMap/PollingSubscription.js +30 -0
- package/lib/browser/userMap/WebsocketSubscription.d.ts +27 -0
- package/lib/browser/userMap/WebsocketSubscription.js +45 -0
- package/lib/browser/userMap/grpcSubscription.d.ts +27 -0
- package/lib/browser/userMap/grpcSubscription.js +44 -0
- package/lib/browser/userMap/referrerMap.d.ts +45 -0
- package/lib/browser/userMap/referrerMap.js +184 -0
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +66 -0
- package/lib/browser/userMap/revenueShareEscrowMap.js +210 -0
- package/lib/browser/userMap/userMap.d.ts +114 -0
- package/lib/browser/userMap/userMap.js +486 -0
- package/lib/browser/userMap/userMapConfig.d.ts +40 -0
- package/lib/browser/userMap/userMapConfig.js +2 -0
- package/lib/browser/userMap/userStatsMap.d.ts +66 -0
- package/lib/browser/userMap/userStatsMap.js +266 -0
- package/lib/browser/userName.d.ts +5 -0
- package/lib/browser/userName.js +21 -0
- package/lib/browser/userStats.d.ts +24 -0
- package/lib/browser/userStats.js +70 -0
- package/lib/browser/userStatsConfig.d.ts +26 -0
- package/lib/browser/userStatsConfig.js +2 -0
- package/lib/browser/util/TransactionConfirmationManager.d.ts +16 -0
- package/lib/browser/util/TransactionConfirmationManager.js +174 -0
- package/lib/browser/util/chainClock.d.ts +17 -0
- package/lib/browser/util/chainClock.js +29 -0
- package/lib/browser/util/computeUnits.d.ts +8 -0
- package/lib/browser/util/computeUnits.js +48 -0
- package/lib/browser/util/digest.d.ts +5 -0
- package/lib/browser/util/digest.js +19 -0
- package/lib/browser/util/ed25519Utils.d.ts +10 -0
- package/lib/browser/util/ed25519Utils.js +80 -0
- package/lib/browser/util/promiseTimeout.d.ts +1 -0
- package/lib/browser/util/promiseTimeout.js +14 -0
- package/lib/browser/util/tps.d.ts +2 -0
- package/lib/browser/util/tps.js +16 -0
- package/lib/browser/velocityClient.d.ts +1230 -0
- package/lib/browser/velocityClient.js +5778 -0
- package/lib/browser/velocityClientConfig.d.ts +84 -0
- package/lib/browser/velocityClientConfig.js +2 -0
- package/lib/browser/wallet.d.ts +16 -0
- package/lib/browser/wallet.js +46 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/basicUserAccountSubscriber.js +38 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +38 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts +38 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -0
- package/lib/node/accounts/bulkAccountLoader.js +222 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts +8 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts.map +1 -0
- package/lib/node/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/node/accounts/bulkUserSubscription.d.ts +8 -0
- package/lib/node/accounts/bulkUserSubscription.d.ts.map +1 -0
- package/lib/node/accounts/bulkUserSubscription.js +21 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts +45 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts.map +1 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.js +152 -0
- package/lib/node/accounts/fetch.d.ts +18 -0
- package/lib/node/accounts/fetch.d.ts.map +1 -0
- package/lib/node/accounts/fetch.js +60 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcAccountSubscriber.js +162 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +11 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +38 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +378 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +26 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +203 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +179 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +11 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.js +28 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +11 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +28 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +17 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +101 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +70 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +457 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +24 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.js +162 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +48 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +48 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.js +102 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +94 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +74 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +420 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts +5 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -0
- package/lib/node/accounts/testBulkAccountLoader.js +43 -0
- package/lib/node/accounts/types.d.ts +206 -0
- package/lib/node/accounts/types.d.ts.map +1 -0
- package/lib/node/accounts/types.js +16 -0
- package/lib/node/accounts/utils.d.ts +9 -0
- package/lib/node/accounts/utils.d.ts.map +1 -0
- package/lib/node/accounts/utils.js +49 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketAccountSubscriber.js +170 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +110 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +395 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +24 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +120 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +146 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +744 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +146 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +744 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +24 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +61 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +23 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +78 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +400 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +92 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +446 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +54 -0
- package/lib/node/addresses/marketAddresses.d.ts +3 -0
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -0
- package/lib/node/addresses/marketAddresses.js +15 -0
- package/lib/node/addresses/pda.d.ts +48 -0
- package/lib/node/addresses/pda.d.ts.map +1 -0
- package/lib/node/addresses/pda.js +263 -0
- package/lib/node/adminClient.d.ts +403 -0
- package/lib/node/adminClient.d.ts.map +1 -0
- package/lib/node/adminClient.js +2798 -0
- package/lib/node/assert/assert.d.ts +2 -0
- package/lib/node/assert/assert.d.ts.map +1 -0
- package/lib/node/assert/assert.js +9 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.js +32 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +16 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/node/auctionSubscriber/index.d.ts +4 -0
- package/lib/node/auctionSubscriber/index.d.ts.map +1 -0
- package/lib/node/auctionSubscriber/index.js +19 -0
- package/lib/node/auctionSubscriber/types.d.ts +15 -0
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -0
- package/lib/node/auctionSubscriber/types.js +2 -0
- package/lib/node/bankrun/bankrunConnection.d.ts +77 -0
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -0
- package/lib/node/bankrun/bankrunConnection.js +348 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +28 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +89 -0
- package/lib/node/blockhashSubscriber/index.d.ts +2 -0
- package/lib/node/blockhashSubscriber/index.d.ts.map +1 -0
- package/lib/node/blockhashSubscriber/index.js +17 -0
- package/lib/node/blockhashSubscriber/types.d.ts +8 -0
- package/lib/node/blockhashSubscriber/types.d.ts.map +1 -0
- package/lib/node/blockhashSubscriber/types.js +2 -0
- package/lib/node/clock/clockSubscriber.d.ts +32 -0
- package/lib/node/clock/clockSubscriber.d.ts.map +1 -0
- package/lib/node/clock/clockSubscriber.js +80 -0
- package/lib/node/config.d.ts +76 -0
- package/lib/node/config.d.ts.map +1 -0
- package/lib/node/config.js +164 -0
- package/lib/node/constants/index.d.ts +11 -0
- package/lib/node/constants/index.d.ts.map +1 -0
- package/lib/node/constants/index.js +26 -0
- package/lib/node/constants/insuranceFund.d.ts +6 -0
- package/lib/node/constants/insuranceFund.d.ts.map +1 -0
- package/lib/node/constants/insuranceFund.js +9 -0
- package/lib/node/constants/numericConstants.d.ts +74 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -0
- package/lib/node/constants/numericConstants.js +79 -0
- package/lib/node/constants/perpMarkets.d.ts +22 -0
- package/lib/node/constants/perpMarkets.d.ts.map +1 -0
- package/lib/node/constants/perpMarkets.js +971 -0
- package/lib/node/constants/spotMarkets.d.ts +25 -0
- package/lib/node/constants/spotMarkets.d.ts.map +1 -0
- package/lib/node/constants/spotMarkets.js +797 -0
- package/lib/node/constants/txConstants.d.ts +2 -0
- package/lib/node/constants/txConstants.d.ts.map +1 -0
- package/lib/node/constants/txConstants.js +4 -0
- package/lib/node/constituentMap/constituentMap.d.ts +67 -0
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -0
- package/lib/node/constituentMap/constituentMap.js +177 -0
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts +25 -0
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -0
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +60 -0
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +25 -0
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -0
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +58 -0
- package/lib/node/core/VelocityCore.d.ts +227 -0
- package/lib/node/core/VelocityCore.d.ts.map +1 -0
- package/lib/node/core/VelocityCore.js +138 -0
- package/lib/node/core/index.d.ts +13 -0
- package/lib/node/core/index.d.ts.map +1 -0
- package/lib/node/core/index.js +28 -0
- package/lib/node/core/instructions/deposit.d.ts +20 -0
- package/lib/node/core/instructions/deposit.d.ts.map +1 -0
- package/lib/node/core/instructions/deposit.js +19 -0
- package/lib/node/core/instructions/fill.d.ts +14 -0
- package/lib/node/core/instructions/fill.d.ts.map +1 -0
- package/lib/node/core/instructions/fill.js +17 -0
- package/lib/node/core/instructions/funding.d.ts +10 -0
- package/lib/node/core/instructions/funding.d.ts.map +1 -0
- package/lib/node/core/instructions/funding.js +13 -0
- package/lib/node/core/instructions/liquidation.d.ts +16 -0
- package/lib/node/core/instructions/liquidation.d.ts.map +1 -0
- package/lib/node/core/instructions/liquidation.js +17 -0
- package/lib/node/core/instructions/orders.d.ts +23 -0
- package/lib/node/core/instructions/orders.d.ts.map +1 -0
- package/lib/node/core/instructions/orders.js +27 -0
- package/lib/node/core/instructions/perpOrders.d.ts +79 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -0
- package/lib/node/core/instructions/perpOrders.js +99 -0
- package/lib/node/core/instructions/settlement.d.ts +12 -0
- package/lib/node/core/instructions/settlement.d.ts.map +1 -0
- package/lib/node/core/instructions/settlement.js +15 -0
- package/lib/node/core/instructions/trigger.d.ts +12 -0
- package/lib/node/core/instructions/trigger.d.ts.map +1 -0
- 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 -0
- package/lib/node/core/instructions/withdraw.js +20 -0
- package/lib/node/core/remainingAccounts.d.ts +28 -0
- package/lib/node/core/remainingAccounts.d.ts.map +1 -0
- package/lib/node/core/remainingAccounts.js +122 -0
- package/lib/node/core/signedMsg.d.ts +18 -0
- package/lib/node/core/signedMsg.d.ts.map +1 -0
- package/lib/node/core/signedMsg.js +39 -0
- package/lib/node/decode/customCoder.d.ts +45 -0
- package/lib/node/decode/customCoder.d.ts.map +1 -0
- package/lib/node/decode/customCoder.js +64 -0
- package/lib/node/decode/user.d.ts +5 -0
- package/lib/node/decode/user.d.ts.map +1 -0
- package/lib/node/decode/user.js +337 -0
- package/lib/node/dlob/DLOB.d.ts +254 -0
- package/lib/node/dlob/DLOB.d.ts.map +1 -0
- package/lib/node/dlob/DLOB.js +1137 -0
- package/lib/node/dlob/DLOBNode.d.ts +71 -0
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -0
- package/lib/node/dlob/DLOBNode.js +103 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts +58 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -0
- package/lib/node/dlob/DLOBSubscriber.js +143 -0
- package/lib/node/dlob/NodeList.d.ts +28 -0
- package/lib/node/dlob/NodeList.d.ts.map +1 -0
- package/lib/node/dlob/NodeList.js +126 -0
- package/lib/node/dlob/orderBookLevels.d.ts +78 -0
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -0
- package/lib/node/dlob/orderBookLevels.js +404 -0
- package/lib/node/dlob/types.d.ts +19 -0
- package/lib/node/dlob/types.d.ts.map +1 -0
- package/lib/node/dlob/types.js +2 -0
- package/lib/node/events/eventList.d.ts +23 -0
- package/lib/node/events/eventList.d.ts.map +1 -0
- package/lib/node/events/eventList.js +80 -0
- package/lib/node/events/eventSubscriber.d.ts +56 -0
- package/lib/node/events/eventSubscriber.d.ts.map +1 -0
- package/lib/node/events/eventSubscriber.js +229 -0
- package/lib/node/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -0
- package/lib/node/events/eventsServerLogProvider.js +121 -0
- package/lib/node/events/fetchLogs.d.ts +26 -0
- package/lib/node/events/fetchLogs.d.ts.map +1 -0
- package/lib/node/events/fetchLogs.js +99 -0
- package/lib/node/events/parse.d.ts +9 -0
- package/lib/node/events/parse.d.ts.map +1 -0
- package/lib/node/events/parse.js +199 -0
- package/lib/node/events/pollingLogProvider.d.ts +18 -0
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -0
- package/lib/node/events/pollingLogProvider.js +58 -0
- package/lib/node/events/sort.d.ts +3 -0
- package/lib/node/events/sort.d.ts.map +1 -0
- package/lib/node/events/sort.js +24 -0
- package/lib/node/events/txEventCache.d.ts +25 -0
- package/lib/node/events/txEventCache.d.ts.map +1 -0
- package/lib/node/events/txEventCache.js +71 -0
- package/lib/node/events/types.d.ts +105 -0
- package/lib/node/events/types.d.ts.map +1 -0
- package/lib/node/events/types.js +36 -0
- package/lib/node/events/webSocketLogProvider.d.ts +25 -0
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -0
- package/lib/node/events/webSocketLogProvider.js +96 -0
- package/lib/node/factory/bigNum.d.ts +123 -0
- package/lib/node/factory/bigNum.d.ts.map +1 -0
- package/lib/node/factory/bigNum.js +500 -0
- package/lib/node/factory/oracleClient.d.ts +6 -0
- package/lib/node/factory/oracleClient.d.ts.map +1 -0
- package/lib/node/factory/oracleClient.js +53 -0
- package/lib/node/idl/drift.d.ts +23895 -0
- package/lib/node/idl/drift.d.ts.map +1 -0
- package/lib/node/idl/drift.js +2 -0
- package/lib/node/idl/drift.json +18698 -0
- package/lib/node/idl/pyth.d.ts +98 -0
- package/lib/node/idl/pyth.d.ts.map +1 -0
- package/lib/node/idl/pyth.js +2 -0
- package/lib/node/idl/token_faucet.d.ts +198 -0
- package/lib/node/idl/token_faucet.d.ts.map +1 -0
- package/lib/node/idl/token_faucet.js +2 -0
- package/lib/node/idl/token_faucet.json +229 -0
- package/lib/node/index.d.ts +145 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +175 -0
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +36 -0
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -0
- package/lib/node/indicative-quotes/indicativeQuotesSender.js +192 -0
- package/lib/node/isomorphic/anchor.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.d.ts +2 -0
- package/lib/node/isomorphic/anchor.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.js +17 -0
- package/lib/node/isomorphic/anchor.node.d.ts +2 -0
- package/lib/node/isomorphic/anchor.node.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.node.js +17 -0
- package/lib/node/isomorphic/anchor29.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.d.ts +2 -0
- package/lib/node/isomorphic/anchor29.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.js +17 -0
- package/lib/node/isomorphic/anchor29.node.d.ts +2 -0
- package/lib/node/isomorphic/anchor29.node.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.node.js +17 -0
- package/lib/node/isomorphic/grpc.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/grpc.d.ts +18 -0
- package/lib/node/isomorphic/grpc.d.ts.map +1 -0
- package/lib/node/isomorphic/grpc.js +109 -0
- package/lib/node/isomorphic/grpc.node.d.ts +18 -0
- package/lib/node/isomorphic/grpc.node.d.ts.map +1 -0
- package/lib/node/isomorphic/grpc.node.js +109 -0
- package/lib/node/jupiter/jupiterClient.d.ts +292 -0
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -0
- package/lib/node/jupiter/jupiterClient.js +164 -0
- package/lib/node/keypair.d.ts +3 -0
- package/lib/node/keypair.d.ts.map +1 -0
- package/lib/node/keypair.js +28 -0
- package/lib/node/marginCalculation.d.ts +68 -0
- package/lib/node/marginCalculation.d.ts.map +1 -0
- package/lib/node/marginCalculation.js +176 -0
- package/lib/node/marinade/index.d.ts +13 -0
- package/lib/node/marinade/index.d.ts.map +1 -0
- package/lib/node/marinade/index.js +36 -0
- package/lib/node/marinade/types.d.ts +1964 -0
- package/lib/node/marinade/types.d.ts.map +1 -0
- package/lib/node/marinade/types.js +1965 -0
- package/lib/node/math/amm.d.ts +99 -0
- package/lib/node/math/amm.d.ts.map +1 -0
- package/lib/node/math/amm.js +671 -0
- package/lib/node/math/auction.d.ts +66 -0
- package/lib/node/math/auction.d.ts.map +1 -0
- package/lib/node/math/auction.js +261 -0
- package/lib/node/math/bankruptcy.d.ts +3 -0
- package/lib/node/math/bankruptcy.d.ts.map +1 -0
- package/lib/node/math/bankruptcy.js +32 -0
- package/lib/node/math/builder.d.ts +6 -0
- package/lib/node/math/builder.d.ts.map +1 -0
- package/lib/node/math/builder.js +22 -0
- package/lib/node/math/conversion.d.ts +5 -0
- package/lib/node/math/conversion.d.ts.map +1 -0
- package/lib/node/math/conversion.js +21 -0
- package/lib/node/math/exchangeStatus.d.ts +9 -0
- package/lib/node/math/exchangeStatus.d.ts.map +1 -0
- package/lib/node/math/exchangeStatus.js +85 -0
- package/lib/node/math/funding.d.ts +45 -0
- package/lib/node/math/funding.d.ts.map +1 -0
- package/lib/node/math/funding.js +260 -0
- package/lib/node/math/insurance.d.ts +9 -0
- package/lib/node/math/insurance.d.ts.map +1 -0
- package/lib/node/math/insurance.js +74 -0
- package/lib/node/math/liquidation.d.ts +8 -0
- package/lib/node/math/liquidation.d.ts.map +1 -0
- package/lib/node/math/liquidation.js +134 -0
- package/lib/node/math/margin.d.ts +46 -0
- package/lib/node/math/margin.d.ts.map +1 -0
- package/lib/node/math/margin.js +205 -0
- package/lib/node/math/market.d.ts +51 -0
- package/lib/node/math/market.d.ts.map +1 -0
- package/lib/node/math/market.js +234 -0
- package/lib/node/math/oracles.d.ts +20 -0
- package/lib/node/math/oracles.d.ts.map +1 -0
- package/lib/node/math/oracles.js +215 -0
- package/lib/node/math/orders.d.ts +37 -0
- package/lib/node/math/orders.d.ts.map +1 -0
- package/lib/node/math/orders.js +294 -0
- package/lib/node/math/position.d.ts +72 -0
- package/lib/node/math/position.d.ts.map +1 -0
- package/lib/node/math/position.js +232 -0
- package/lib/node/math/repeg.d.ts +23 -0
- package/lib/node/math/repeg.d.ts.map +1 -0
- package/lib/node/math/repeg.js +164 -0
- package/lib/node/math/spotBalance.d.ts +86 -0
- package/lib/node/math/spotBalance.d.ts.map +1 -0
- package/lib/node/math/spotBalance.js +438 -0
- package/lib/node/math/spotMarket.d.ts +12 -0
- package/lib/node/math/spotMarket.d.ts.map +1 -0
- package/lib/node/math/spotMarket.js +49 -0
- package/lib/node/math/spotPosition.d.ts +20 -0
- package/lib/node/math/spotPosition.d.ts.map +1 -0
- package/lib/node/math/spotPosition.js +79 -0
- package/lib/node/math/state.d.ts +9 -0
- package/lib/node/math/state.d.ts.map +1 -0
- package/lib/node/math/state.js +44 -0
- package/lib/node/math/superStake.d.ts +169 -0
- package/lib/node/math/superStake.d.ts.map +1 -0
- package/lib/node/math/superStake.js +308 -0
- package/lib/node/math/tiers.d.ts +5 -0
- package/lib/node/math/tiers.d.ts.map +1 -0
- package/lib/node/math/tiers.js +52 -0
- package/lib/node/math/trade.d.ts +94 -0
- package/lib/node/math/trade.d.ts.map +1 -0
- package/lib/node/math/trade.js +503 -0
- package/lib/node/math/utils.d.ts +24 -0
- package/lib/node/math/utils.d.ts.map +1 -0
- package/lib/node/math/utils.js +113 -0
- package/lib/node/memcmp.d.ts +19 -0
- package/lib/node/memcmp.d.ts.map +1 -0
- package/lib/node/memcmp.js +162 -0
- package/lib/node/oracles/oracleClientCache.d.ts +10 -0
- package/lib/node/oracles/oracleClientCache.d.ts.map +1 -0
- package/lib/node/oracles/oracleClientCache.js +19 -0
- package/lib/node/oracles/oracleId.d.ts +10 -0
- package/lib/node/oracles/oracleId.d.ts.map +1 -0
- package/lib/node/oracles/oracleId.js +89 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts +13 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -0
- package/lib/node/oracles/prelaunchOracleClient.js +24 -0
- package/lib/node/oracles/pythClient.d.ts +15 -0
- package/lib/node/oracles/pythClient.d.ts.map +1 -0
- package/lib/node/oracles/pythClient.js +51 -0
- package/lib/node/oracles/pythLazerClient.d.ts +17 -0
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -0
- package/lib/node/oracles/pythLazerClient.js +61 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts +11 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts.map +1 -0
- package/lib/node/oracles/quoteAssetOracleClient.js +21 -0
- package/lib/node/oracles/strictOraclePrice.d.ts +10 -0
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -0
- package/lib/node/oracles/strictOraclePrice.js +17 -0
- package/lib/node/oracles/types.d.ts +34 -0
- package/lib/node/oracles/types.d.ts.map +1 -0
- package/lib/node/oracles/types.js +2 -0
- package/lib/node/oracles/utils.d.ts +5 -0
- package/lib/node/oracles/utils.d.ts.map +1 -0
- package/lib/node/oracles/utils.js +8 -0
- package/lib/node/orderParams.d.ts +30 -0
- package/lib/node/orderParams.d.ts.map +1 -0
- package/lib/node/orderParams.js +44 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +46 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -0
- package/lib/node/orderSubscriber/OrderSubscriber.js +193 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts +13 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts.map +1 -0
- package/lib/node/orderSubscriber/PollingSubscription.js +23 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +24 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts.map +1 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.js +67 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts +23 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -0
- package/lib/node/orderSubscriber/grpcSubscription.js +75 -0
- package/lib/node/orderSubscriber/index.d.ts +8 -0
- package/lib/node/orderSubscriber/index.d.ts.map +1 -0
- package/lib/node/orderSubscriber/index.js +23 -0
- package/lib/node/orderSubscriber/types.d.ts +36 -0
- package/lib/node/orderSubscriber/types.d.ts.map +1 -0
- package/lib/node/orderSubscriber/types.js +2 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +6 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.js +16 -0
- package/lib/node/priorityFee/averageStrategy.d.ts +6 -0
- package/lib/node/priorityFee/averageStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/averageStrategy.js +11 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts +12 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/ewmaStrategy.js +33 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +21 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.js +46 -0
- package/lib/node/priorityFee/index.d.ts +17 -0
- package/lib/node/priorityFee/index.d.ts.map +1 -0
- package/lib/node/priorityFee/index.js +32 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +6 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.js +17 -0
- package/lib/node/priorityFee/maxStrategy.d.ts +8 -0
- package/lib/node/priorityFee/maxStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/maxStrategy.js +9 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +49 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.js +193 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +51 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +96 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +7 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.js +21 -0
- package/lib/node/priorityFee/types.d.ts +36 -0
- package/lib/node/priorityFee/types.d.ts.map +1 -0
- package/lib/node/priorityFee/types.js +10 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +22 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.js +28 -0
- package/lib/node/pyth/constants.d.ts +4 -0
- package/lib/node/pyth/constants.d.ts.map +1 -0
- package/lib/node/pyth/constants.js +6 -0
- package/lib/node/pyth/index.d.ts +5 -0
- package/lib/node/pyth/index.d.ts.map +1 -0
- package/lib/node/pyth/index.js +12 -0
- package/lib/node/pyth/pythLazerSubscriber.d.ts +92 -0
- package/lib/node/pyth/pythLazerSubscriber.d.ts.map +1 -0
- package/lib/node/pyth/pythLazerSubscriber.js +276 -0
- package/lib/node/pyth/types.d.ts +2227 -0
- package/lib/node/pyth/types.d.ts.map +1 -0
- package/lib/node/pyth/types.js +2224 -0
- package/lib/node/pyth/utils.d.ts +3 -0
- package/lib/node/pyth/utils.d.ts.map +1 -0
- package/lib/node/pyth/utils.js +10 -0
- package/lib/node/slot/SlotSubscriber.d.ts +28 -0
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -0
- package/lib/node/slot/SlotSubscriber.js +76 -0
- package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -0
- package/lib/node/slot/SlothashSubscriber.js +88 -0
- package/lib/node/swap/UnifiedSwapClient.d.ts +121 -0
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -0
- package/lib/node/swap/UnifiedSwapClient.js +179 -0
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +23 -0
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +57 -0
- package/lib/node/swift/index.d.ts +11 -0
- package/lib/node/swift/index.d.ts.map +1 -0
- package/lib/node/swift/index.js +26 -0
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +43 -0
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +118 -0
- package/lib/node/swift/swiftOrderSubscriber.d.ts +64 -0
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -0
- package/lib/node/swift/swiftOrderSubscriber.js +187 -0
- package/lib/node/testClient.d.ts +9 -0
- package/lib/node/testClient.d.ts.map +1 -0
- package/lib/node/testClient.js +24 -0
- package/lib/node/titan/titanClient.d.ts +91 -0
- package/lib/node/titan/titanClient.d.ts.map +1 -0
- package/lib/node/titan/titanClient.js +227 -0
- package/lib/node/token/index.d.ts +6 -0
- package/lib/node/token/index.d.ts.map +1 -0
- package/lib/node/token/index.js +15 -0
- package/lib/node/tokenFaucet.d.ts +42 -0
- package/lib/node/tokenFaucet.d.ts.map +1 -0
- package/lib/node/tokenFaucet.js +188 -0
- package/lib/node/tx/baseTxSender.d.ts +60 -0
- package/lib/node/tx/baseTxSender.d.ts.map +1 -0
- package/lib/node/tx/baseTxSender.js +292 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +9 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts.map +1 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +29 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts.map +1 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts +5 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts.map +1 -0
- package/lib/node/tx/blockhashFetcher/types.js +2 -0
- package/lib/node/tx/fastSingleTxSender.d.ts +42 -0
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -0
- package/lib/node/tx/fastSingleTxSender.js +86 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts +38 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -0
- package/lib/node/tx/forwardOnlyTxSender.js +92 -0
- package/lib/node/tx/priorityFeeCalculator.d.ts +45 -0
- package/lib/node/tx/priorityFeeCalculator.d.ts.map +1 -0
- package/lib/node/tx/priorityFeeCalculator.js +85 -0
- package/lib/node/tx/reportTransactionError.d.ts +21 -0
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -0
- package/lib/node/tx/reportTransactionError.js +103 -0
- package/lib/node/tx/retryTxSender.d.ts +38 -0
- package/lib/node/tx/retryTxSender.d.ts.map +1 -0
- package/lib/node/tx/retryTxSender.js +86 -0
- package/lib/node/tx/txHandler.d.ts +174 -0
- package/lib/node/tx/txHandler.d.ts.map +1 -0
- package/lib/node/tx/txHandler.js +522 -0
- package/lib/node/tx/txParamProcessor.d.ts +27 -0
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -0
- package/lib/node/tx/txParamProcessor.js +92 -0
- package/lib/node/tx/types.d.ts +30 -0
- package/lib/node/tx/types.d.ts.map +1 -0
- package/lib/node/tx/types.js +20 -0
- package/lib/node/tx/utils.d.ts +7 -0
- package/lib/node/tx/utils.d.ts.map +1 -0
- package/lib/node/tx/utils.js +78 -0
- package/lib/node/tx/whileValidTxSender.d.ts +46 -0
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -0
- package/lib/node/tx/whileValidTxSender.js +168 -0
- package/lib/node/types.d.ts +1748 -0
- package/lib/node/types.d.ts.map +1 -0
- package/lib/node/types.js +427 -0
- package/lib/node/user.d.ts +447 -0
- package/lib/node/user.d.ts.map +1 -0
- package/lib/node/user.js +2372 -0
- package/lib/node/userConfig.d.ts +32 -0
- package/lib/node/userConfig.d.ts.map +1 -0
- package/lib/node/userConfig.js +2 -0
- package/lib/node/userMap/PollingSubscription.d.ts +16 -0
- package/lib/node/userMap/PollingSubscription.d.ts.map +1 -0
- package/lib/node/userMap/PollingSubscription.js +30 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts +28 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -0
- package/lib/node/userMap/WebsocketSubscription.js +45 -0
- package/lib/node/userMap/grpcSubscription.d.ts +28 -0
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -0
- package/lib/node/userMap/grpcSubscription.js +44 -0
- package/lib/node/userMap/referrerMap.d.ts +46 -0
- package/lib/node/userMap/referrerMap.d.ts.map +1 -0
- package/lib/node/userMap/referrerMap.js +184 -0
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +67 -0
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -0
- package/lib/node/userMap/revenueShareEscrowMap.js +210 -0
- package/lib/node/userMap/userMap.d.ts +115 -0
- package/lib/node/userMap/userMap.d.ts.map +1 -0
- package/lib/node/userMap/userMap.js +486 -0
- package/lib/node/userMap/userMapConfig.d.ts +41 -0
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -0
- package/lib/node/userMap/userMapConfig.js +2 -0
- package/lib/node/userMap/userStatsMap.d.ts +67 -0
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -0
- package/lib/node/userMap/userStatsMap.js +266 -0
- package/lib/node/userName.d.ts +6 -0
- package/lib/node/userName.d.ts.map +1 -0
- package/lib/node/userName.js +21 -0
- package/lib/node/userStats.d.ts +25 -0
- package/lib/node/userStats.d.ts.map +1 -0
- package/lib/node/userStats.js +70 -0
- package/lib/node/userStatsConfig.d.ts +27 -0
- package/lib/node/userStatsConfig.d.ts.map +1 -0
- package/lib/node/userStatsConfig.js +2 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts +17 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -0
- package/lib/node/util/TransactionConfirmationManager.js +174 -0
- package/lib/node/util/chainClock.d.ts +18 -0
- package/lib/node/util/chainClock.d.ts.map +1 -0
- package/lib/node/util/chainClock.js +29 -0
- package/lib/node/util/computeUnits.d.ts +9 -0
- package/lib/node/util/computeUnits.d.ts.map +1 -0
- package/lib/node/util/computeUnits.js +48 -0
- package/lib/node/util/digest.d.ts +6 -0
- package/lib/node/util/digest.d.ts.map +1 -0
- package/lib/node/util/digest.js +19 -0
- package/lib/node/util/ed25519Utils.d.ts +11 -0
- package/lib/node/util/ed25519Utils.d.ts.map +1 -0
- package/lib/node/util/ed25519Utils.js +80 -0
- package/lib/node/util/promiseTimeout.d.ts +2 -0
- package/lib/node/util/promiseTimeout.d.ts.map +1 -0
- package/lib/node/util/promiseTimeout.js +14 -0
- package/lib/node/util/tps.d.ts +3 -0
- package/lib/node/util/tps.d.ts.map +1 -0
- package/lib/node/util/tps.js +16 -0
- package/lib/node/velocityClient.d.ts +1231 -0
- package/lib/node/velocityClient.d.ts.map +1 -0
- package/lib/node/velocityClient.js +5778 -0
- package/lib/node/velocityClientConfig.d.ts +85 -0
- package/lib/node/velocityClientConfig.d.ts.map +1 -0
- package/lib/node/velocityClientConfig.js +2 -0
- package/lib/node/wallet.d.ts +17 -0
- package/lib/node/wallet.d.ts.map +1 -0
- package/lib/node/wallet.js +46 -0
- package/package.json +157 -0
- package/scripts/deposit-isolated-positions.ts +110 -0
- package/scripts/find-flagged-users.ts +213 -0
- package/scripts/grpc-client-test-comparison.ts +372 -0
- package/scripts/grpc-multiuser-client-test-comparison.ts +158 -0
- package/scripts/postbuild.js +95 -0
- package/scripts/single-grpc-client-test.ts +284 -0
- package/scripts/updateVersion.js +28 -0
- package/scripts/withdraw-isolated-positions.ts +174 -0
- package/src/accounts/README_WebSocketAccountSubscriberV2.md +95 -0
- package/src/accounts/README_WebSocketProgramAccountSubscriberV2.md +135 -0
- package/src/accounts/basicUserAccountSubscriber.ts +59 -0
- package/src/accounts/basicUserStatsAccountSubscriber.ts +65 -0
- package/src/accounts/bulkAccountLoader.ts +293 -0
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +33 -0
- package/src/accounts/customizedCadenceBulkAccountLoader.ts +213 -0
- package/src/accounts/fetch.ts +143 -0
- package/src/accounts/grpcAccountSubscriber.ts +187 -0
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +57 -0
- package/src/accounts/grpcMultiAccountSubscriber.ts +476 -0
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +281 -0
- package/src/accounts/grpcProgramAccountSubscriber.ts +223 -0
- package/src/accounts/grpcUserAccountSubscriber.ts +48 -0
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +50 -0
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +213 -0
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +762 -0
- package/src/accounts/laserProgramAccountSubscriber.ts +229 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +67 -0
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +70 -0
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +186 -0
- package/src/accounts/pollingOracleAccountSubscriber.ts +125 -0
- package/src/accounts/pollingTokenAccountSubscriber.ts +118 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +160 -0
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +156 -0
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +652 -0
- package/src/accounts/testBulkAccountLoader.ts +51 -0
- package/src/accounts/types.ts +284 -0
- package/src/accounts/utils.ts +62 -0
- package/src/accounts/webSocketAccountSubscriber.ts +250 -0
- package/src/accounts/webSocketAccountSubscriberV2.ts +517 -0
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +129 -0
- package/src/accounts/webSocketProgramAccountSubscriber.ts +183 -0
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +996 -0
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +996 -0
- package/src/accounts/webSocketUserAccountSubscriber.ts +104 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +98 -0
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +719 -0
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +755 -0
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +94 -0
- package/src/addresses/marketAddresses.ts +17 -0
- package/src/addresses/pda.ts +439 -0
- package/src/adminClient.ts +5936 -0
- package/src/assert/assert.ts +5 -0
- package/src/auctionSubscriber/auctionSubscriber.ts +68 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +72 -0
- package/src/auctionSubscriber/index.ts +3 -0
- package/src/auctionSubscriber/types.ts +20 -0
- package/src/bankrun/bankrunConnection.ts +560 -0
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +126 -0
- package/src/blockhashSubscriber/index.ts +1 -0
- package/src/blockhashSubscriber/types.ts +12 -0
- package/src/clock/clockSubscriber.ts +121 -0
- package/src/config.ts +268 -0
- package/src/constants/index.ts +10 -0
- package/src/constants/insuranceFund.ts +8 -0
- package/src/constants/numericConstants.ts +119 -0
- package/src/constants/perpMarkets.ts +1042 -0
- package/src/constants/spotMarkets.ts +874 -0
- package/src/constants/txConstants.ts +1 -0
- package/src/constituentMap/constituentMap.ts +294 -0
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +97 -0
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +112 -0
- package/src/core/VelocityCore.ts +331 -0
- package/src/core/index.ts +12 -0
- package/src/core/instructions/deposit.ts +42 -0
- package/src/core/instructions/fill.ts +34 -0
- package/src/core/instructions/funding.ts +21 -0
- package/src/core/instructions/liquidation.ts +37 -0
- package/src/core/instructions/orders.ts +56 -0
- package/src/core/instructions/perpOrders.ts +192 -0
- package/src/core/instructions/settlement.ts +26 -0
- package/src/core/instructions/trigger.ts +26 -0
- package/src/core/instructions/withdraw.ts +44 -0
- package/src/core/remainingAccounts.ts +276 -0
- package/src/core/signedMsg.ts +71 -0
- package/src/decode/customCoder.ts +105 -0
- package/src/decode/user.ts +372 -0
- package/src/dlob/DLOB.ts +2098 -0
- package/src/dlob/DLOBNode.ts +193 -0
- package/src/dlob/DLOBSubscriber.ts +211 -0
- package/src/dlob/NodeList.ts +174 -0
- package/src/dlob/orderBookLevels.ts +575 -0
- package/src/dlob/types.ts +22 -0
- package/src/events/eventList.ts +97 -0
- package/src/events/eventSubscriber.ts +382 -0
- package/src/events/eventsServerLogProvider.ts +152 -0
- package/src/events/fetchLogs.ts +169 -0
- package/src/events/parse.ts +248 -0
- package/src/events/pollingLogProvider.ts +89 -0
- package/src/events/sort.ts +39 -0
- package/src/events/txEventCache.ts +74 -0
- package/src/events/types.ts +228 -0
- package/src/events/webSocketLogProvider.ts +121 -0
- package/src/factory/bigNum.ts +709 -0
- package/src/factory/oracleClient.ts +73 -0
- package/src/idl/drift.json +18698 -0
- package/src/idl/drift.ts +23894 -0
- package/src/idl/pyth.json +142 -0
- package/src/idl/pyth.ts +97 -0
- package/src/idl/pyth_solana_receiver.json +628 -0
- package/src/idl/token_faucet.json +229 -0
- package/src/idl/token_faucet.ts +197 -0
- package/src/index.ts +150 -0
- package/src/indicative-quotes/indicativeQuotesSender.ts +233 -0
- package/src/isomorphic/README.md +19 -0
- package/src/isomorphic/anchor.browser.ts +44 -0
- package/src/isomorphic/anchor.node.ts +1 -0
- package/src/isomorphic/anchor.ts +1 -0
- package/src/isomorphic/anchor29.browser.ts +24 -0
- package/src/isomorphic/anchor29.node.ts +1 -0
- package/src/isomorphic/anchor29.ts +1 -0
- package/src/isomorphic/grpc.browser.ts +4 -0
- package/src/isomorphic/grpc.node.ts +130 -0
- package/src/isomorphic/grpc.ts +1 -0
- package/src/jupiter/jupiterClient.ts +482 -0
- package/src/keypair.ts +24 -0
- package/src/margin/README.md +138 -0
- package/src/marginCalculation.ts +255 -0
- package/src/marinade/idl/idl.json +1962 -0
- package/src/marinade/index.ts +64 -0
- package/src/marinade/types.ts +3925 -0
- package/src/math/amm.ts +1246 -0
- package/src/math/auction.ts +374 -0
- package/src/math/bankruptcy.ts +35 -0
- package/src/math/builder.ts +20 -0
- package/src/math/conversion.ts +24 -0
- package/src/math/exchangeStatus.ts +136 -0
- package/src/math/funding.ts +436 -0
- package/src/math/insurance.ts +111 -0
- package/src/math/liquidation.ts +209 -0
- package/src/math/margin.ts +368 -0
- package/src/math/market.ts +438 -0
- package/src/math/oracles.ts +367 -0
- package/src/math/orders.ts +473 -0
- package/src/math/position.ts +340 -0
- package/src/math/repeg.ts +214 -0
- package/src/math/spotBalance.ts +752 -0
- package/src/math/spotMarket.ts +82 -0
- package/src/math/spotPosition.ts +191 -0
- package/src/math/state.ts +48 -0
- package/src/math/superStake.ts +528 -0
- package/src/math/tiers.ts +44 -0
- package/src/math/trade.ts +805 -0
- package/src/math/utils.ts +121 -0
- package/src/memcmp.ts +164 -0
- package/src/oracles/oracleClientCache.ts +25 -0
- package/src/oracles/oracleId.ts +66 -0
- package/src/oracles/prelaunchOracleClient.ts +38 -0
- package/src/oracles/pythClient.ts +85 -0
- package/src/oracles/pythLazerClient.ts +102 -0
- package/src/oracles/quoteAssetOracleClient.ts +25 -0
- package/src/oracles/strictOraclePrice.ts +19 -0
- package/src/oracles/types.ts +37 -0
- package/src/oracles/utils.ts +10 -0
- package/src/orderParams.ts +79 -0
- package/src/orderSubscriber/OrderSubscriber.ts +296 -0
- package/src/orderSubscriber/PollingSubscription.ts +39 -0
- package/src/orderSubscriber/WebsocketSubscription.ts +119 -0
- package/src/orderSubscriber/grpcSubscription.ts +139 -0
- package/src/orderSubscriber/index.ts +7 -0
- package/src/orderSubscriber/types.ts +55 -0
- package/src/priorityFee/averageOverSlotsStrategy.ts +16 -0
- package/src/priorityFee/averageStrategy.ts +12 -0
- package/src/priorityFee/ewmaStrategy.ts +41 -0
- package/src/priorityFee/heliusPriorityFeeMethod.ts +57 -0
- package/src/priorityFee/index.ts +16 -0
- package/src/priorityFee/maxOverSlotsStrategy.ts +17 -0
- package/src/priorityFee/maxStrategy.ts +7 -0
- package/src/priorityFee/priorityFeeSubscriber.ts +256 -0
- package/src/priorityFee/priorityFeeSubscriberMap.ts +125 -0
- package/src/priorityFee/solanaPriorityFeeMethod.ts +34 -0
- package/src/priorityFee/types.ts +64 -0
- package/src/priorityFee/velocityPriorityFeeMethod.ts +54 -0
- package/src/pyth/constants.ts +9 -0
- package/src/pyth/index.ts +15 -0
- package/src/pyth/pythLazerSubscriber.ts +365 -0
- package/src/pyth/types.ts +4453 -0
- package/src/pyth/utils.ts +13 -0
- package/src/slot/SlotSubscriber.ts +108 -0
- package/src/slot/SlothashSubscriber.ts +126 -0
- package/src/swap/UnifiedSwapClient.ts +315 -0
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +95 -0
- package/src/swift/index.ts +10 -0
- package/src/swift/signedMsgUserAccountSubscriber.ts +241 -0
- package/src/swift/swiftOrderSubscriber.ts +347 -0
- package/src/testClient.ts +42 -0
- package/src/titan/titanClient.ts +438 -0
- package/src/token/index.ts +13 -0
- package/src/tokenFaucet.ts +274 -0
- package/src/tx/baseTxSender.ts +471 -0
- package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +19 -0
- package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +90 -0
- package/src/tx/blockhashFetcher/types.ts +5 -0
- package/src/tx/fastSingleTxSender.ts +142 -0
- package/src/tx/forwardOnlyTxSender.ts +145 -0
- package/src/tx/priorityFeeCalculator.ts +117 -0
- package/src/tx/reportTransactionError.ts +159 -0
- package/src/tx/retryTxSender.ts +135 -0
- package/src/tx/txHandler.ts +853 -0
- package/src/tx/txParamProcessor.ts +163 -0
- package/src/tx/types.ts +71 -0
- package/src/tx/utils.ts +107 -0
- package/src/tx/whileValidTxSender.ts +266 -0
- package/src/types.ts +1793 -0
- package/src/user.ts +4487 -0
- package/src/userConfig.ts +37 -0
- package/src/userMap/PollingSubscription.ts +47 -0
- package/src/userMap/WebsocketSubscription.ts +84 -0
- package/src/userMap/grpcSubscription.ts +85 -0
- package/src/userMap/referrerMap.ts +267 -0
- package/src/userMap/revenueShareEscrowMap.ts +310 -0
- package/src/userMap/userMap.ts +683 -0
- package/src/userMap/userMapConfig.ts +66 -0
- package/src/userMap/userStatsMap.ts +358 -0
- package/src/userName.ts +21 -0
- package/src/userStats.ts +117 -0
- package/src/userStatsConfig.ts +32 -0
- package/src/util/TransactionConfirmationManager.ts +292 -0
- package/src/util/chainClock.ts +41 -0
- package/src/util/computeUnits.ts +65 -0
- package/src/util/digest.ts +16 -0
- package/src/util/ed25519Utils.ts +85 -0
- package/src/util/promiseTimeout.ts +14 -0
- package/src/util/tps.ts +27 -0
- package/src/velocityClient.ts +11364 -0
- package/src/velocityClientConfig.ts +144 -0
- package/src/wallet.ts +54 -0
- package/tests/DriftCore/decode.test.ts +16 -0
- package/tests/DriftCore/fill_trigger.test.ts +73 -0
- package/tests/DriftCore/instructions.test.ts +46 -0
- package/tests/DriftCore/pdas.test.ts +28 -0
- package/tests/DriftCore/perp_orders.test.ts +205 -0
- package/tests/DriftCore/remainingAccounts.test.ts +73 -0
- package/tests/DriftCore/settlement_liquidation.test.ts +69 -0
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +203 -0
- package/tests/amm/test.ts +2095 -0
- package/tests/auctions/test.ts +81 -0
- package/tests/bn/test.ts +355 -0
- package/tests/ci/verifyConstants.ts +396 -0
- package/tests/decode/phoenix.ts +71 -0
- package/tests/decode/test.ts +262 -0
- package/tests/decode/userAccountBufferStrings.ts +102 -0
- package/tests/dlob/helpers.ts +740 -0
- package/tests/dlob/test.ts +6920 -0
- package/tests/events/parseLogsForCuUsage.ts +139 -0
- package/tests/insurance/test.ts +40 -0
- package/tests/spot/test.ts +226 -0
- package/tests/tx/TransactionConfirmationManager.test.ts +305 -0
- package/tests/tx/cachedBlockhashFetcher.test.ts +96 -0
- package/tests/tx/priorityFeeCalculator.ts +77 -0
- package/tests/tx/priorityFeeStrategy.ts +95 -0
- package/tests/user/getMarginCalculation.ts +361 -0
- package/tests/user/helpers.ts +185 -0
- package/tests/user/liquidations.ts +129 -0
- package/tests/user/marginCalculations.test.ts +321 -0
- package/tests/user/test.ts +826 -0
- package/tsconfig.browser.json +16 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateFundingPool = exports.calculateLongShortFundingRateAndLiveTwaps = exports.calculateLongShortFundingRate = exports.calculateFormattedLiveFundingRate = exports.calculateAllEstimatedFundingRate = void 0;
|
|
4
|
+
const anchor_1 = require("../isomorphic/anchor");
|
|
5
|
+
const numericConstants_1 = require("../constants/numericConstants");
|
|
6
|
+
const bigNum_1 = require("../factory/bigNum");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const amm_1 = require("./amm");
|
|
9
|
+
const oracles_1 = require("./oracles");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const numericConstants_2 = require("../constants/numericConstants");
|
|
12
|
+
function calculateLiveMarkTwap(market, mmOraclePriceData, markPrice, now, period = new anchor_1.BN(3600)) {
|
|
13
|
+
now = now || new anchor_1.BN((Date.now() / 1000).toFixed(0));
|
|
14
|
+
const lastMarkTwapWithMantissa = market.amm.lastMarkPriceTwap;
|
|
15
|
+
const lastMarkPriceTwapTs = market.amm.lastMarkPriceTwapTs;
|
|
16
|
+
const timeSinceLastMarkChange = now.sub(lastMarkPriceTwapTs);
|
|
17
|
+
const markTwapTimeSinceLastUpdate = anchor_1.BN.max(period, anchor_1.BN.max(numericConstants_1.ZERO, period.sub(timeSinceLastMarkChange)));
|
|
18
|
+
if (!markPrice) {
|
|
19
|
+
const [bid, ask] = (0, amm_1.calculateBidAskPrice)(market.amm, mmOraclePriceData);
|
|
20
|
+
markPrice = bid.add(ask).div(new anchor_1.BN(2));
|
|
21
|
+
}
|
|
22
|
+
const markTwapWithMantissa = markTwapTimeSinceLastUpdate
|
|
23
|
+
.mul(lastMarkTwapWithMantissa)
|
|
24
|
+
.add(timeSinceLastMarkChange.mul(markPrice))
|
|
25
|
+
.div(timeSinceLastMarkChange.add(markTwapTimeSinceLastUpdate));
|
|
26
|
+
return markTwapWithMantissa;
|
|
27
|
+
}
|
|
28
|
+
function shrinkStaleTwaps(market, markTwapWithMantissa, oracleTwapWithMantissa, now) {
|
|
29
|
+
now = now || new anchor_1.BN((Date.now() / 1000).toFixed(0));
|
|
30
|
+
let newMarkTwap = markTwapWithMantissa;
|
|
31
|
+
let newOracleTwap = oracleTwapWithMantissa;
|
|
32
|
+
if (market.amm.lastMarkPriceTwapTs.gt(market.amm.historicalOracleData.lastOraclePriceTwapTs)) {
|
|
33
|
+
// shrink oracle based on invalid intervals
|
|
34
|
+
const oracleInvalidDuration = anchor_1.BN.max(numericConstants_1.ZERO, market.amm.lastMarkPriceTwapTs.sub(market.amm.historicalOracleData.lastOraclePriceTwapTs));
|
|
35
|
+
const timeSinceLastOracleTwapUpdate = now.sub(market.amm.historicalOracleData.lastOraclePriceTwapTs);
|
|
36
|
+
const oracleTwapTimeSinceLastUpdate = anchor_1.BN.max(numericConstants_1.ONE, anchor_1.BN.min(market.amm.fundingPeriod, anchor_1.BN.max(numericConstants_1.ONE, market.amm.fundingPeriod.sub(timeSinceLastOracleTwapUpdate))));
|
|
37
|
+
newOracleTwap = oracleTwapTimeSinceLastUpdate
|
|
38
|
+
.mul(oracleTwapWithMantissa)
|
|
39
|
+
.add(oracleInvalidDuration.mul(markTwapWithMantissa))
|
|
40
|
+
.div(oracleTwapTimeSinceLastUpdate.add(oracleInvalidDuration));
|
|
41
|
+
}
|
|
42
|
+
else if (market.amm.lastMarkPriceTwapTs.lt(market.amm.historicalOracleData.lastOraclePriceTwapTs)) {
|
|
43
|
+
// shrink mark to oracle twap over tradless intervals
|
|
44
|
+
const tradelessDuration = anchor_1.BN.max(numericConstants_1.ZERO, market.amm.historicalOracleData.lastOraclePriceTwapTs.sub(market.amm.lastMarkPriceTwapTs));
|
|
45
|
+
const timeSinceLastMarkTwapUpdate = now.sub(market.amm.lastMarkPriceTwapTs);
|
|
46
|
+
const markTwapTimeSinceLastUpdate = anchor_1.BN.max(numericConstants_1.ONE, anchor_1.BN.min(market.amm.fundingPeriod, anchor_1.BN.max(numericConstants_1.ONE, market.amm.fundingPeriod.sub(timeSinceLastMarkTwapUpdate))));
|
|
47
|
+
newMarkTwap = markTwapTimeSinceLastUpdate
|
|
48
|
+
.mul(markTwapWithMantissa)
|
|
49
|
+
.add(tradelessDuration.mul(oracleTwapWithMantissa))
|
|
50
|
+
.div(markTwapTimeSinceLastUpdate.add(tradelessDuration));
|
|
51
|
+
}
|
|
52
|
+
return [newMarkTwap, newOracleTwap];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param market
|
|
57
|
+
* @param oraclePriceData
|
|
58
|
+
* @param periodAdjustment
|
|
59
|
+
* @returns Estimated funding rate. : Precision //TODO-PRECISION
|
|
60
|
+
*/
|
|
61
|
+
function calculateAllEstimatedFundingRate(market, mmOraclePriceData, oraclePriceData, markPrice, now) {
|
|
62
|
+
if ((0, types_1.isVariant)(market.status, 'uninitialized')) {
|
|
63
|
+
return [numericConstants_1.ZERO, numericConstants_1.ZERO, numericConstants_1.ZERO, numericConstants_1.ZERO, numericConstants_1.ZERO];
|
|
64
|
+
}
|
|
65
|
+
// todo: sufficiently differs from blockchain timestamp?
|
|
66
|
+
now = now || new anchor_1.BN((Date.now() / 1000).toFixed(0));
|
|
67
|
+
// calculate real-time mark and oracle twap
|
|
68
|
+
const liveMarkTwap = calculateLiveMarkTwap(market, mmOraclePriceData, markPrice, now, market.amm.fundingPeriod);
|
|
69
|
+
const liveOracleTwap = (0, oracles_1.calculateLiveOracleTwap)(market.amm.historicalOracleData, oraclePriceData, now, market.amm.fundingPeriod);
|
|
70
|
+
const [markTwap, oracleTwap] = shrinkStaleTwaps(market, liveMarkTwap, liveOracleTwap, now);
|
|
71
|
+
// if(!markTwap.eq(liveMarkTwap)){
|
|
72
|
+
// console.log('shrink mark:', liveMarkTwap.toString(), '->', markTwap.toString());
|
|
73
|
+
// }
|
|
74
|
+
// if(!oracleTwap.eq(liveOracleTwap)){
|
|
75
|
+
// console.log('shrink orac:', liveOracleTwap.toString(), '->', oracleTwap.toString());
|
|
76
|
+
// }
|
|
77
|
+
const twapSpread = markTwap.sub(oracleTwap);
|
|
78
|
+
const offset = oracleTwap.abs().div(numericConstants_1.FUNDING_RATE_OFFSET_DENOMINATOR);
|
|
79
|
+
const twapSpreadWithOffset = twapSpread
|
|
80
|
+
.abs()
|
|
81
|
+
.lte(oracleTwap.abs().div(numericConstants_1.FUNDING_RATE_CLAMP_DENOMINATOR))
|
|
82
|
+
? offset
|
|
83
|
+
: twapSpread.add(offset);
|
|
84
|
+
const maxSpread = getMaxPriceDivergenceForFundingRate(market, oracleTwap);
|
|
85
|
+
const clampedSpreadWithOffset = (0, utils_1.clampBN)(twapSpreadWithOffset, maxSpread.mul(new anchor_1.BN(-1)), maxSpread);
|
|
86
|
+
const twapSpreadPct = clampedSpreadWithOffset
|
|
87
|
+
.mul(numericConstants_1.PRICE_PRECISION)
|
|
88
|
+
.mul(new anchor_1.BN(100))
|
|
89
|
+
.div(oracleTwap);
|
|
90
|
+
const secondsInHour = new anchor_1.BN(3600);
|
|
91
|
+
const hoursInDay = new anchor_1.BN(24);
|
|
92
|
+
const timeSinceLastUpdate = now.sub(market.amm.lastFundingRateTs);
|
|
93
|
+
const lowerboundEst = twapSpreadPct
|
|
94
|
+
.mul(market.amm.fundingPeriod)
|
|
95
|
+
.mul(anchor_1.BN.min(secondsInHour, timeSinceLastUpdate))
|
|
96
|
+
.div(secondsInHour)
|
|
97
|
+
.div(secondsInHour)
|
|
98
|
+
.div(hoursInDay);
|
|
99
|
+
const interpEst = twapSpreadPct.div(hoursInDay);
|
|
100
|
+
const interpRateQuote = twapSpreadPct
|
|
101
|
+
.div(hoursInDay)
|
|
102
|
+
.div(numericConstants_1.PRICE_PRECISION.div(numericConstants_1.QUOTE_PRECISION));
|
|
103
|
+
let feePoolSize = calculateFundingPool(market);
|
|
104
|
+
if (interpRateQuote.lt(new anchor_1.BN(0))) {
|
|
105
|
+
feePoolSize = feePoolSize.mul(new anchor_1.BN(-1));
|
|
106
|
+
}
|
|
107
|
+
let cappedAltEst;
|
|
108
|
+
let largerSide;
|
|
109
|
+
let smallerSide;
|
|
110
|
+
if (market.amm.baseAssetAmountLong.gt(market.amm.baseAssetAmountShort.abs())) {
|
|
111
|
+
largerSide = market.amm.baseAssetAmountLong.abs();
|
|
112
|
+
smallerSide = market.amm.baseAssetAmountShort.abs();
|
|
113
|
+
if (twapSpread.gt(new anchor_1.BN(0))) {
|
|
114
|
+
return [markTwap, oracleTwap, lowerboundEst, interpEst, interpEst];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (market.amm.baseAssetAmountLong.lt(market.amm.baseAssetAmountShort.abs())) {
|
|
118
|
+
largerSide = market.amm.baseAssetAmountShort.abs();
|
|
119
|
+
smallerSide = market.amm.baseAssetAmountLong.abs();
|
|
120
|
+
if (twapSpread.lt(new anchor_1.BN(0))) {
|
|
121
|
+
return [markTwap, oracleTwap, lowerboundEst, interpEst, interpEst];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return [markTwap, oracleTwap, lowerboundEst, interpEst, interpEst];
|
|
126
|
+
}
|
|
127
|
+
if (largerSide.gt(numericConstants_1.ZERO)) {
|
|
128
|
+
// funding smaller flow
|
|
129
|
+
cappedAltEst = smallerSide.mul(twapSpread).div(hoursInDay);
|
|
130
|
+
const feePoolTopOff = feePoolSize
|
|
131
|
+
.mul(numericConstants_1.PRICE_PRECISION.div(numericConstants_1.QUOTE_PRECISION))
|
|
132
|
+
.mul(numericConstants_1.AMM_RESERVE_PRECISION);
|
|
133
|
+
cappedAltEst = cappedAltEst.add(feePoolTopOff).div(largerSide);
|
|
134
|
+
cappedAltEst = cappedAltEst
|
|
135
|
+
.mul(numericConstants_1.PRICE_PRECISION)
|
|
136
|
+
.mul(new anchor_1.BN(100))
|
|
137
|
+
.div(oracleTwap);
|
|
138
|
+
if (cappedAltEst.abs().gte(interpEst.abs())) {
|
|
139
|
+
cappedAltEst = interpEst;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
cappedAltEst = interpEst;
|
|
144
|
+
}
|
|
145
|
+
return [markTwap, oracleTwap, lowerboundEst, cappedAltEst, interpEst];
|
|
146
|
+
}
|
|
147
|
+
exports.calculateAllEstimatedFundingRate = calculateAllEstimatedFundingRate;
|
|
148
|
+
/**
|
|
149
|
+
* To get funding rate as a percentage, you need to multiply by the funding rate buffer precision
|
|
150
|
+
* @param rawFundingRate
|
|
151
|
+
* @returns
|
|
152
|
+
*/
|
|
153
|
+
const getFundingRatePct = (rawFundingRate) => {
|
|
154
|
+
return bigNum_1.BigNum.from(rawFundingRate.mul(numericConstants_2.FUNDING_RATE_BUFFER_PRECISION), numericConstants_2.FUNDING_RATE_PRECISION_EXP).toNum();
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Calculate funding rates in human-readable form. Values will have some lost precision and shouldn't be used in strict accounting.
|
|
158
|
+
* @param period : 'hour' | 'year' :: Use 'hour' for the hourly payment as a percentage, 'year' for the payment as an estimated APR.
|
|
159
|
+
*/
|
|
160
|
+
function calculateFormattedLiveFundingRate(market, mmOraclePriceData, oraclePriceData, period) {
|
|
161
|
+
const nowBN = new anchor_1.BN(Date.now() / 1000);
|
|
162
|
+
const [_markTwapLive, _oracleTwapLive, longFundingRate, shortFundingRate] = calculateLongShortFundingRateAndLiveTwaps(market, mmOraclePriceData, oraclePriceData, undefined, nowBN);
|
|
163
|
+
let longFundingRateNum = getFundingRatePct(longFundingRate);
|
|
164
|
+
let shortFundingRateNum = getFundingRatePct(shortFundingRate);
|
|
165
|
+
if (period == 'year') {
|
|
166
|
+
const paymentsPerYear = 24 * 365.25;
|
|
167
|
+
longFundingRateNum *= paymentsPerYear;
|
|
168
|
+
shortFundingRateNum *= paymentsPerYear;
|
|
169
|
+
}
|
|
170
|
+
const longsArePaying = longFundingRateNum > 0;
|
|
171
|
+
const shortsArePaying = !(shortFundingRateNum > 0);
|
|
172
|
+
const longsAreString = longsArePaying ? 'pay' : 'receive';
|
|
173
|
+
const shortsAreString = !shortsArePaying ? 'receive' : 'pay';
|
|
174
|
+
const absoluteLongFundingRateNum = Math.abs(longFundingRateNum);
|
|
175
|
+
const absoluteShortFundingRateNum = Math.abs(shortFundingRateNum);
|
|
176
|
+
const formattedLongRatePct = absoluteLongFundingRateNum.toFixed(period == 'hour' ? 5 : 2);
|
|
177
|
+
const formattedShortRatePct = absoluteShortFundingRateNum.toFixed(period == 'hour' ? 5 : 2);
|
|
178
|
+
const fundingRateUnit = period == 'year' ? '% APR' : '%';
|
|
179
|
+
const formattedFundingRateSummary = `At this rate, longs would ${longsAreString} ${formattedLongRatePct} ${fundingRateUnit} and shorts would ${shortsAreString} ${formattedShortRatePct} ${fundingRateUnit} at the end of the hour.`;
|
|
180
|
+
return {
|
|
181
|
+
longRate: longsArePaying
|
|
182
|
+
? -absoluteLongFundingRateNum
|
|
183
|
+
: absoluteLongFundingRateNum,
|
|
184
|
+
shortRate: shortsArePaying
|
|
185
|
+
? -absoluteShortFundingRateNum
|
|
186
|
+
: absoluteShortFundingRateNum,
|
|
187
|
+
fundingRateUnit: fundingRateUnit,
|
|
188
|
+
formattedFundingRateSummary,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
exports.calculateFormattedLiveFundingRate = calculateFormattedLiveFundingRate;
|
|
192
|
+
function getMaxPriceDivergenceForFundingRate(market, oracleTwap) {
|
|
193
|
+
if ((0, types_1.isVariant)(market.contractTier, 'a')) {
|
|
194
|
+
return oracleTwap.divn(33);
|
|
195
|
+
}
|
|
196
|
+
else if ((0, types_1.isVariant)(market.contractTier, 'b')) {
|
|
197
|
+
return oracleTwap.divn(33);
|
|
198
|
+
}
|
|
199
|
+
else if ((0, types_1.isVariant)(market.contractTier, 'c')) {
|
|
200
|
+
return oracleTwap.divn(20);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
return oracleTwap.divn(10);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
*
|
|
208
|
+
* @param market
|
|
209
|
+
* @param oraclePriceData
|
|
210
|
+
* @param periodAdjustment
|
|
211
|
+
* @returns Estimated funding rate. : Precision //TODO-PRECISION
|
|
212
|
+
*/
|
|
213
|
+
function calculateLongShortFundingRate(market, mmOraclePriceData, oraclePriceData, markPrice, now) {
|
|
214
|
+
const [_1, _2, _, cappedAltEst, interpEst] = calculateAllEstimatedFundingRate(market, mmOraclePriceData, oraclePriceData, markPrice, now);
|
|
215
|
+
if (market.amm.baseAssetAmountLong.gt(market.amm.baseAssetAmountShort)) {
|
|
216
|
+
return [cappedAltEst, interpEst];
|
|
217
|
+
}
|
|
218
|
+
else if (market.amm.baseAssetAmountLong.lt(market.amm.baseAssetAmountShort)) {
|
|
219
|
+
return [interpEst, cappedAltEst];
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
return [interpEst, interpEst];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.calculateLongShortFundingRate = calculateLongShortFundingRate;
|
|
226
|
+
/**
|
|
227
|
+
*
|
|
228
|
+
* @param market
|
|
229
|
+
* @param oraclePriceData
|
|
230
|
+
* @param periodAdjustment
|
|
231
|
+
* @returns Estimated funding rate. : Precision //TODO-PRECISION
|
|
232
|
+
*/
|
|
233
|
+
function calculateLongShortFundingRateAndLiveTwaps(market, mmOraclePriceData, oraclePriceData, markPrice, now) {
|
|
234
|
+
const [markTwapLive, oracleTwapLive, _2, cappedAltEst, interpEst] = calculateAllEstimatedFundingRate(market, mmOraclePriceData, oraclePriceData, markPrice, now);
|
|
235
|
+
if (market.amm.baseAssetAmountLong.gt(market.amm.baseAssetAmountShort.abs())) {
|
|
236
|
+
return [markTwapLive, oracleTwapLive, cappedAltEst, interpEst];
|
|
237
|
+
}
|
|
238
|
+
else if (market.amm.baseAssetAmountLong.lt(market.amm.baseAssetAmountShort.abs())) {
|
|
239
|
+
return [markTwapLive, oracleTwapLive, interpEst, cappedAltEst];
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
return [markTwapLive, oracleTwapLive, interpEst, interpEst];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
exports.calculateLongShortFundingRateAndLiveTwaps = calculateLongShortFundingRateAndLiveTwaps;
|
|
246
|
+
/**
|
|
247
|
+
*
|
|
248
|
+
* @param market
|
|
249
|
+
* @returns Estimated fee pool size
|
|
250
|
+
*/
|
|
251
|
+
function calculateFundingPool(market) {
|
|
252
|
+
// todo
|
|
253
|
+
const totalFeeLB = market.amm.totalExchangeFee.div(new anchor_1.BN(2));
|
|
254
|
+
const feePool = anchor_1.BN.max(numericConstants_1.ZERO, market.amm.totalFeeMinusDistributions
|
|
255
|
+
.sub(totalFeeLB)
|
|
256
|
+
.mul(new anchor_1.BN(1))
|
|
257
|
+
.div(new anchor_1.BN(3)));
|
|
258
|
+
return feePool;
|
|
259
|
+
}
|
|
260
|
+
exports.calculateFundingPool = calculateFundingPool;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN } from '../isomorphic/anchor';
|
|
3
|
+
import { SpotMarketAccount } from '../types';
|
|
4
|
+
export declare function nextRevenuePoolSettleApr(spotMarket: SpotMarketAccount, vaultBalance: BN, // vault token amount
|
|
5
|
+
amount?: BN): number;
|
|
6
|
+
export declare function stakeAmountToShares(amount: BN, totalIfShares: BN, insuranceFundVaultBalance: BN): BN;
|
|
7
|
+
export declare function unstakeSharesToAmount(nShares: BN, totalIfShares: BN, insuranceFundVaultBalance: BN): BN;
|
|
8
|
+
export declare function unstakeSharesToAmountWithOpenRequest(nShares: BN, withdrawRequestShares: BN, withdrawRequestAmount: BN, totalIfShares: BN, insuranceFundVaultBalance: BN): BN;
|
|
9
|
+
//# sourceMappingURL=insurance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insurance.d.ts","sourceRoot":"","sources":["../../../src/math/insurance.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAmB,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE9D,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,iBAAiB,EAC7B,YAAY,EAAE,EAAE,EAAE,qBAAqB;AACvC,MAAM,CAAC,EAAE,EAAE,GACT,MAAM,CAuCR;AAED,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,EAAE,EACV,aAAa,EAAE,EAAE,EACjB,yBAAyB,EAAE,EAAE,GAC3B,EAAE,CASJ;AAED,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,EAAE,EACX,aAAa,EAAE,EAAE,EACjB,yBAAyB,EAAE,EAAE,GAC3B,EAAE,CAYJ;AAED,wBAAgB,oCAAoC,CACnD,OAAO,EAAE,EAAE,EACX,qBAAqB,EAAE,EAAE,EACzB,qBAAqB,EAAE,EAAE,EACzB,aAAa,EAAE,EAAE,EACjB,yBAAyB,EAAE,EAAE,GAC3B,EAAE,CAqBJ"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unstakeSharesToAmountWithOpenRequest = exports.unstakeSharesToAmount = exports.stakeAmountToShares = exports.nextRevenuePoolSettleApr = void 0;
|
|
4
|
+
const numericConstants_1 = require("../constants/numericConstants");
|
|
5
|
+
const spotBalance_1 = require("../math/spotBalance");
|
|
6
|
+
const anchor_1 = require("../isomorphic/anchor");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
function nextRevenuePoolSettleApr(spotMarket, vaultBalance, // vault token amount
|
|
9
|
+
amount // delta token amount
|
|
10
|
+
) {
|
|
11
|
+
const MAX_APR = new anchor_1.BN(10).mul(numericConstants_1.PERCENTAGE_PRECISION); // 1000% APR
|
|
12
|
+
// Conmputing the APR:
|
|
13
|
+
const revenuePoolBN = (0, spotBalance_1.getTokenAmount)(spotMarket.revenuePool.scaledBalance, spotMarket, types_1.SpotBalanceType.DEPOSIT);
|
|
14
|
+
const payoutRatio = 0.1;
|
|
15
|
+
const ratioForStakers = spotMarket.insuranceFund.totalFactor > 0 &&
|
|
16
|
+
spotMarket.insuranceFund.userFactor > 0 &&
|
|
17
|
+
spotMarket.insuranceFund.revenueSettlePeriod.gt(numericConstants_1.ZERO)
|
|
18
|
+
? spotMarket.insuranceFund.userFactor /
|
|
19
|
+
spotMarket.insuranceFund.totalFactor
|
|
20
|
+
: 0;
|
|
21
|
+
// Settle periods from on-chain data:
|
|
22
|
+
const revSettlePeriod = spotMarket.insuranceFund.revenueSettlePeriod.toNumber() * 1000;
|
|
23
|
+
const settlesPerYear = 31536000000 / revSettlePeriod;
|
|
24
|
+
const projectedAnnualRev = revenuePoolBN
|
|
25
|
+
.muln(settlesPerYear)
|
|
26
|
+
.muln(payoutRatio);
|
|
27
|
+
const uncappedApr = vaultBalance.add(amount).eq(numericConstants_1.ZERO)
|
|
28
|
+
? 0
|
|
29
|
+
: projectedAnnualRev.muln(1000).div(vaultBalance.add(amount)).toNumber() *
|
|
30
|
+
100 *
|
|
31
|
+
1000;
|
|
32
|
+
const cappedApr = Math.min(uncappedApr, MAX_APR.toNumber());
|
|
33
|
+
const nextApr = cappedApr * ratioForStakers;
|
|
34
|
+
return nextApr;
|
|
35
|
+
}
|
|
36
|
+
exports.nextRevenuePoolSettleApr = nextRevenuePoolSettleApr;
|
|
37
|
+
function stakeAmountToShares(amount, totalIfShares, insuranceFundVaultBalance) {
|
|
38
|
+
let nShares;
|
|
39
|
+
if (insuranceFundVaultBalance.gt(numericConstants_1.ZERO)) {
|
|
40
|
+
nShares = amount.mul(totalIfShares).div(insuranceFundVaultBalance);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
nShares = amount;
|
|
44
|
+
}
|
|
45
|
+
return nShares;
|
|
46
|
+
}
|
|
47
|
+
exports.stakeAmountToShares = stakeAmountToShares;
|
|
48
|
+
function unstakeSharesToAmount(nShares, totalIfShares, insuranceFundVaultBalance) {
|
|
49
|
+
let amount;
|
|
50
|
+
if (totalIfShares.gt(numericConstants_1.ZERO)) {
|
|
51
|
+
amount = anchor_1.BN.max(numericConstants_1.ZERO, nShares.mul(insuranceFundVaultBalance).div(totalIfShares));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
amount = numericConstants_1.ZERO;
|
|
55
|
+
}
|
|
56
|
+
return amount;
|
|
57
|
+
}
|
|
58
|
+
exports.unstakeSharesToAmount = unstakeSharesToAmount;
|
|
59
|
+
function unstakeSharesToAmountWithOpenRequest(nShares, withdrawRequestShares, withdrawRequestAmount, totalIfShares, insuranceFundVaultBalance) {
|
|
60
|
+
let stakedAmount;
|
|
61
|
+
if (totalIfShares.gt(numericConstants_1.ZERO)) {
|
|
62
|
+
stakedAmount = anchor_1.BN.max(numericConstants_1.ZERO, nShares
|
|
63
|
+
.sub(withdrawRequestShares)
|
|
64
|
+
.mul(insuranceFundVaultBalance)
|
|
65
|
+
.div(totalIfShares));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
stakedAmount = numericConstants_1.ZERO;
|
|
69
|
+
}
|
|
70
|
+
const withdrawAmount = anchor_1.BN.min(withdrawRequestAmount, withdrawRequestShares.mul(insuranceFundVaultBalance).div(totalIfShares));
|
|
71
|
+
const amount = withdrawAmount.add(stakedAmount);
|
|
72
|
+
return amount;
|
|
73
|
+
}
|
|
74
|
+
exports.unstakeSharesToAmountWithOpenRequest = unstakeSharesToAmountWithOpenRequest;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN } from '../isomorphic/anchor';
|
|
3
|
+
export declare function calculateBaseAssetAmountToCoverMarginShortage(marginShortage: BN, marginRatio: number, liquidationFee: number, ifLiquidationFee: number, oraclePrice: BN, quoteOraclePrice: BN): BN | undefined;
|
|
4
|
+
export declare function calculateLiabilityTransferToCoverMarginShortage(marginShortage: BN, assetWeight: number, assetLiquidationMultiplier: number, liabilityWeight: number, liabilityLiquidationMultiplier: number, liabilityDecimals: number, liabilityPrice: BN, ifLiquidationFee: number): BN | undefined;
|
|
5
|
+
export declare function calculateAssetTransferForLiabilityTransfer(assetAmount: BN, assetLiquidationMultiplier: number, assetDecimals: number, assetPrice: BN, liabilityAmount: BN, liabilityLiquidationMultiplier: number, liabilityDecimals: number, liabilityPrice: BN): BN | undefined;
|
|
6
|
+
export declare function calculateMaxPctToLiquidate(userLastActiveSlot: BN, userLiquidationMarginFreed: BN, marginShortage: BN, slot: BN, initialPctToLiquidate: BN, liquidationDuration: BN): BN;
|
|
7
|
+
export declare function getMarginShortage(maintenanceMarginRequirementPlusBuffer: BN, maintenanceTotalCollateral: BN): BN;
|
|
8
|
+
//# sourceMappingURL=liquidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liquidation.d.ts","sourceRoot":"","sources":["../../../src/math/liquidation.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAa1C,wBAAgB,6CAA6C,CAC5D,cAAc,EAAE,EAAE,EAClB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,EAAE,EACf,gBAAgB,EAAE,EAAE,GAClB,EAAE,GAAG,SAAS,CAqBhB;AAED,wBAAgB,+CAA+C,CAC9D,cAAc,EAAE,EAAE,EAClB,WAAW,EAAE,MAAM,EACnB,0BAA0B,EAAE,MAAM,EAClC,eAAe,EAAE,MAAM,EACvB,8BAA8B,EAAE,MAAM,EACtC,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,EAAE,EAClB,gBAAgB,EAAE,MAAM,GACtB,EAAE,GAAG,SAAS,CA8ChB;AAED,wBAAgB,0CAA0C,CACzD,WAAW,EAAE,EAAE,EACf,0BAA0B,EAAE,MAAM,EAClC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,EAAE,EACd,eAAe,EAAE,EAAE,EACnB,8BAA8B,EAAE,MAAM,EACtC,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,EAAE,GAChB,EAAE,GAAG,SAAS,CAkDhB;AAED,wBAAgB,0BAA0B,CACzC,kBAAkB,EAAE,EAAE,EACtB,0BAA0B,EAAE,EAAE,EAC9B,cAAc,EAAE,EAAE,EAClB,IAAI,EAAE,EAAE,EACR,qBAAqB,EAAE,EAAE,EACzB,mBAAmB,EAAE,EAAE,GACrB,EAAE,CA+BJ;AAED,wBAAgB,iBAAiB,CAChC,sCAAsC,EAAE,EAAE,EAC1C,0BAA0B,EAAE,EAAE,GAC5B,EAAE,CAIJ"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMarginShortage = exports.calculateMaxPctToLiquidate = exports.calculateAssetTransferForLiabilityTransfer = exports.calculateLiabilityTransferToCoverMarginShortage = exports.calculateBaseAssetAmountToCoverMarginShortage = void 0;
|
|
4
|
+
const anchor_1 = require("../isomorphic/anchor");
|
|
5
|
+
const numericConstants_1 = require("../constants/numericConstants");
|
|
6
|
+
function calculateBaseAssetAmountToCoverMarginShortage(marginShortage, marginRatio, liquidationFee, ifLiquidationFee, oraclePrice, quoteOraclePrice) {
|
|
7
|
+
const marginRatioBN = new anchor_1.BN(marginRatio)
|
|
8
|
+
.mul(numericConstants_1.LIQUIDATION_FEE_PRECISION)
|
|
9
|
+
.div(numericConstants_1.MARGIN_PRECISION);
|
|
10
|
+
const liquidationFeeBN = new anchor_1.BN(liquidationFee);
|
|
11
|
+
if (oraclePrice.eq(new anchor_1.BN(0)) || marginRatioBN.lte(liquidationFeeBN)) {
|
|
12
|
+
// undefined is max
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return marginShortage.mul(numericConstants_1.PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO).div(oraclePrice
|
|
16
|
+
.mul(quoteOraclePrice)
|
|
17
|
+
.div(numericConstants_1.PRICE_PRECISION)
|
|
18
|
+
.mul(marginRatioBN.sub(liquidationFeeBN))
|
|
19
|
+
.div(numericConstants_1.LIQUIDATION_FEE_PRECISION)
|
|
20
|
+
.sub(oraclePrice.mul(new anchor_1.BN(ifLiquidationFee)).div(numericConstants_1.LIQUIDATION_FEE_PRECISION)));
|
|
21
|
+
}
|
|
22
|
+
exports.calculateBaseAssetAmountToCoverMarginShortage = calculateBaseAssetAmountToCoverMarginShortage;
|
|
23
|
+
function calculateLiabilityTransferToCoverMarginShortage(marginShortage, assetWeight, assetLiquidationMultiplier, liabilityWeight, liabilityLiquidationMultiplier, liabilityDecimals, liabilityPrice, ifLiquidationFee) {
|
|
24
|
+
if (assetWeight >= liabilityWeight) {
|
|
25
|
+
// undefined is max
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
let numeratorScale;
|
|
29
|
+
let denominatorScale;
|
|
30
|
+
if (liabilityDecimals > 6) {
|
|
31
|
+
numeratorScale = new anchor_1.BN(10).pow(new anchor_1.BN(liabilityDecimals - 6));
|
|
32
|
+
denominatorScale = new anchor_1.BN(1);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
numeratorScale = new anchor_1.BN(1);
|
|
36
|
+
denominatorScale = new anchor_1.BN(10).pow(new anchor_1.BN(6 - liabilityDecimals));
|
|
37
|
+
}
|
|
38
|
+
// multiply market weights by extra 10 to increase precision
|
|
39
|
+
const liabilityWeightComponent = liabilityWeight * 10;
|
|
40
|
+
const assetWeightComponent = (assetWeight * 10 * assetLiquidationMultiplier) /
|
|
41
|
+
liabilityLiquidationMultiplier;
|
|
42
|
+
if (assetWeightComponent >= liabilityWeightComponent) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return anchor_1.BN.max(marginShortage
|
|
46
|
+
.mul(numeratorScale)
|
|
47
|
+
.mul(numericConstants_1.PRICE_PRECISION.mul(numericConstants_1.SPOT_MARKET_WEIGHT_PRECISION).mul(numericConstants_1.TEN))
|
|
48
|
+
.div(liabilityPrice
|
|
49
|
+
.mul(new anchor_1.BN(liabilityWeightComponent).sub(new anchor_1.BN(assetWeightComponent)))
|
|
50
|
+
.sub(liabilityPrice
|
|
51
|
+
.mul(new anchor_1.BN(ifLiquidationFee))
|
|
52
|
+
.div(numericConstants_1.LIQUIDATION_FEE_PRECISION)
|
|
53
|
+
.mul(new anchor_1.BN(liabilityWeight))
|
|
54
|
+
.mul(new anchor_1.BN(10))))
|
|
55
|
+
.div(denominatorScale), numericConstants_1.ONE);
|
|
56
|
+
}
|
|
57
|
+
exports.calculateLiabilityTransferToCoverMarginShortage = calculateLiabilityTransferToCoverMarginShortage;
|
|
58
|
+
function calculateAssetTransferForLiabilityTransfer(assetAmount, assetLiquidationMultiplier, assetDecimals, assetPrice, liabilityAmount, liabilityLiquidationMultiplier, liabilityDecimals, liabilityPrice) {
|
|
59
|
+
let numeratorScale;
|
|
60
|
+
let denominatorScale;
|
|
61
|
+
if (assetDecimals > liabilityDecimals) {
|
|
62
|
+
numeratorScale = new anchor_1.BN(10).pow(new anchor_1.BN(assetDecimals - liabilityDecimals));
|
|
63
|
+
denominatorScale = new anchor_1.BN(1);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
numeratorScale = new anchor_1.BN(1);
|
|
67
|
+
denominatorScale = new anchor_1.BN(10).pow(new anchor_1.BN(liabilityDecimals - assetDecimals));
|
|
68
|
+
}
|
|
69
|
+
let assetTransfer = liabilityAmount
|
|
70
|
+
.mul(numeratorScale)
|
|
71
|
+
.mul(liabilityPrice)
|
|
72
|
+
.mul(new anchor_1.BN(assetLiquidationMultiplier))
|
|
73
|
+
.div(assetPrice.mul(new anchor_1.BN(liabilityLiquidationMultiplier)))
|
|
74
|
+
.div(denominatorScale);
|
|
75
|
+
assetTransfer = anchor_1.BN.max(assetTransfer, numericConstants_1.ONE);
|
|
76
|
+
// Need to check if asset_transfer should be rounded to asset amount
|
|
77
|
+
let assetValueNumeratorScale;
|
|
78
|
+
let assetValueDenominatorScale;
|
|
79
|
+
if (assetDecimals > 6) {
|
|
80
|
+
assetValueNumeratorScale = new anchor_1.BN(10).pow(new anchor_1.BN(assetDecimals - 6));
|
|
81
|
+
assetValueDenominatorScale = new anchor_1.BN(1);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
assetValueNumeratorScale = new anchor_1.BN(1);
|
|
85
|
+
assetValueDenominatorScale = new anchor_1.BN(10).pow(new anchor_1.BN(6 - assetDecimals));
|
|
86
|
+
}
|
|
87
|
+
let assetDelta;
|
|
88
|
+
if (assetTransfer > assetAmount) {
|
|
89
|
+
assetDelta = assetTransfer.sub(assetAmount);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
assetDelta = assetAmount.sub(assetTransfer);
|
|
93
|
+
}
|
|
94
|
+
const assetValueDelta = assetDelta
|
|
95
|
+
.mul(assetPrice)
|
|
96
|
+
.div(numericConstants_1.PRICE_PRECISION)
|
|
97
|
+
.mul(assetValueNumeratorScale)
|
|
98
|
+
.div(assetValueDenominatorScale);
|
|
99
|
+
if (assetValueDelta.lt(numericConstants_1.QUOTE_PRECISION)) {
|
|
100
|
+
assetTransfer = assetAmount;
|
|
101
|
+
}
|
|
102
|
+
return assetTransfer;
|
|
103
|
+
}
|
|
104
|
+
exports.calculateAssetTransferForLiabilityTransfer = calculateAssetTransferForLiabilityTransfer;
|
|
105
|
+
function calculateMaxPctToLiquidate(userLastActiveSlot, userLiquidationMarginFreed, marginShortage, slot, initialPctToLiquidate, liquidationDuration) {
|
|
106
|
+
// if margin shortage is tiny, accelerate liquidation
|
|
107
|
+
if (marginShortage.lt(new anchor_1.BN(50).mul(numericConstants_1.QUOTE_PRECISION))) {
|
|
108
|
+
return numericConstants_1.LIQUIDATION_PCT_PRECISION;
|
|
109
|
+
}
|
|
110
|
+
let slotsElapsed;
|
|
111
|
+
if (userLiquidationMarginFreed.gt(new anchor_1.BN(0))) {
|
|
112
|
+
slotsElapsed = anchor_1.BN.max(slot.sub(userLastActiveSlot), new anchor_1.BN(0));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
slotsElapsed = new anchor_1.BN(0);
|
|
116
|
+
}
|
|
117
|
+
const pctFreeable = anchor_1.BN.min(slotsElapsed
|
|
118
|
+
.mul(numericConstants_1.LIQUIDATION_PCT_PRECISION)
|
|
119
|
+
.div(liquidationDuration) // ~ 1 minute if per slot is 400ms
|
|
120
|
+
.add(initialPctToLiquidate), numericConstants_1.LIQUIDATION_PCT_PRECISION);
|
|
121
|
+
const totalMarginShortage = marginShortage.add(userLiquidationMarginFreed);
|
|
122
|
+
const maxMarginFreed = totalMarginShortage
|
|
123
|
+
.mul(pctFreeable)
|
|
124
|
+
.div(numericConstants_1.LIQUIDATION_PCT_PRECISION);
|
|
125
|
+
const marginFreeable = anchor_1.BN.max(maxMarginFreed.sub(userLiquidationMarginFreed), new anchor_1.BN(0));
|
|
126
|
+
return marginFreeable.mul(numericConstants_1.LIQUIDATION_PCT_PRECISION).div(marginShortage);
|
|
127
|
+
}
|
|
128
|
+
exports.calculateMaxPctToLiquidate = calculateMaxPctToLiquidate;
|
|
129
|
+
function getMarginShortage(maintenanceMarginRequirementPlusBuffer, maintenanceTotalCollateral) {
|
|
130
|
+
return maintenanceMarginRequirementPlusBuffer
|
|
131
|
+
.sub(maintenanceTotalCollateral)
|
|
132
|
+
.abs();
|
|
133
|
+
}
|
|
134
|
+
exports.getMarginShortage = getMarginShortage;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN } from '../isomorphic/anchor';
|
|
3
|
+
import { OraclePriceData } from '../oracles/types';
|
|
4
|
+
import { VelocityClient } from '../velocityClient';
|
|
5
|
+
import { PerpMarketAccount, PerpPosition, PositionDirection, UserAccount } from '../types';
|
|
6
|
+
import { PublicKey } from '@solana/web3.js';
|
|
7
|
+
export declare function calculateSizePremiumLiabilityWeight(size: BN, // AMM_RESERVE_PRECISION
|
|
8
|
+
imfFactor: BN, liabilityWeight: BN, precision: BN, isBounded?: boolean): BN;
|
|
9
|
+
export declare function calculateSizeDiscountAssetWeight(size: BN, // AMM_RESERVE_PRECISION
|
|
10
|
+
imfFactor: BN, assetWeight: BN): BN;
|
|
11
|
+
export declare function calculateOraclePriceForPerpMargin(perpPosition: PerpPosition, market: PerpMarketAccount, oraclePriceData: OraclePriceData): BN;
|
|
12
|
+
/**
|
|
13
|
+
* This is _not_ the same as liability value as for prediction markets, the liability for the short in prediction market is (1 - oracle price) * base
|
|
14
|
+
* See {@link calculatePerpLiabilityValue} to get the liabiltiy value
|
|
15
|
+
* @param market
|
|
16
|
+
* @param perpPosition
|
|
17
|
+
* @param oraclePriceData
|
|
18
|
+
* @param includeOpenOrders
|
|
19
|
+
*/
|
|
20
|
+
export declare function calculateBaseAssetValueWithOracle(market: PerpMarketAccount, perpPosition: PerpPosition, oraclePriceData: Pick<OraclePriceData, 'price'>, includeOpenOrders?: boolean): BN;
|
|
21
|
+
export declare function calculateWorstCaseBaseAssetAmount(perpPosition: PerpPosition, perpMarket: PerpMarketAccount, oraclePrice: BN): BN;
|
|
22
|
+
export declare function calculateWorstCasePerpLiabilityValue(perpPosition: PerpPosition, perpMarket: PerpMarketAccount, oraclePrice: BN, includeOpenOrders?: boolean): {
|
|
23
|
+
worstCaseBaseAssetAmount: BN;
|
|
24
|
+
worstCaseLiabilityValue: BN;
|
|
25
|
+
};
|
|
26
|
+
export declare function calculatePerpLiabilityValue(baseAssetAmount: BN, price: BN): BN;
|
|
27
|
+
/**
|
|
28
|
+
* Calculates the margin required to open a trade, in quote amount. Only accounts for the trade size as a scalar value, does not account for the trade direction or current open positions and whether the trade would _actually_ be risk-increasing and use any extra collateral.
|
|
29
|
+
* @param targetMarketIndex
|
|
30
|
+
* @param baseSize
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare function calculateMarginUSDCRequiredForTrade(driftClient: VelocityClient, targetMarketIndex: number, baseSize: BN, userMaxMarginRatio?: number, entryPrice?: BN): BN;
|
|
34
|
+
/**
|
|
35
|
+
* Similar to calculatetMarginUSDCRequiredForTrade, but calculates how much of a given collateral is required to cover the margin requirements for a given trade. Basically does the same thing as getMarginUSDCRequiredForTrade but also accounts for asset weight of the selected collateral.
|
|
36
|
+
*
|
|
37
|
+
* Returns collateral required in the precision of the target collateral market.
|
|
38
|
+
*/
|
|
39
|
+
export declare function calculateCollateralDepositRequiredForTrade(driftClient: VelocityClient, targetMarketIndex: number, baseSize: BN, collateralIndex: number, userMaxMarginRatio?: number, estEntryPrice?: BN): BN;
|
|
40
|
+
export declare function calculateCollateralValueOfDeposit(driftClient: VelocityClient, collateralIndex: number, baseSize: BN): BN;
|
|
41
|
+
export declare function calculateLiquidationPrice(freeCollateral: BN, freeCollateralDelta: BN, oraclePrice: BN): BN;
|
|
42
|
+
export declare function calculateUserMaxPerpOrderSize(driftClient: VelocityClient, userAccountKey: PublicKey, userAccount: UserAccount, targetMarketIndex: number, tradeSide: PositionDirection): {
|
|
43
|
+
tradeSize: BN;
|
|
44
|
+
oppositeSideTradeSize: BN;
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=margin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"margin.d.ts","sourceRoot":"","sources":["../../../src/math/margin.ts"],"names":[],"mappings":";AAiBA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACN,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,wBAAgB,mCAAmC,CAClD,IAAI,EAAE,EAAE,EAAE,wBAAwB;AAClC,SAAS,EAAE,EAAE,EACb,eAAe,EAAE,EAAE,EACnB,SAAS,EAAE,EAAE,EACb,SAAS,UAAO,GACd,EAAE,CA4BJ;AAED,wBAAgB,gCAAgC,CAC/C,IAAI,EAAE,EAAE,EAAE,wBAAwB;AAClC,SAAS,EAAE,EAAE,EACb,WAAW,EAAE,EAAE,GACb,EAAE,CAuBJ;AAED,wBAAgB,iCAAiC,CAChD,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,iBAAiB,EACzB,eAAe,EAAE,eAAe,GAC9B,EAAE,CAoBJ;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAChD,MAAM,EAAE,iBAAiB,EACzB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,EAC/C,iBAAiB,UAAQ,GACvB,EAAE,CAeJ;AAED,wBAAgB,iCAAiC,CAChD,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,iBAAiB,EAC7B,WAAW,EAAE,EAAE,GACb,EAAE,CAMJ;AAED,wBAAgB,oCAAoC,CACnD,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,iBAAiB,EAC7B,WAAW,EAAE,EAAE,EACf,iBAAiB,GAAE,OAAc,GAC/B;IAAE,wBAAwB,EAAE,EAAE,CAAC;IAAC,uBAAuB,EAAE,EAAE,CAAA;CAAE,CAkC/D;AAED,wBAAgB,2BAA2B,CAC1C,eAAe,EAAE,EAAE,EACnB,KAAK,EAAE,EAAE,GACP,EAAE,CAEJ;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAClD,WAAW,EAAE,cAAc,EAC3B,iBAAiB,EAAE,MAAM,EACzB,QAAQ,EAAE,EAAE,EACZ,kBAAkB,CAAC,EAAE,MAAM,EAC3B,UAAU,CAAC,EAAE,EAAE,GACb,EAAE,CAqBJ;AAED;;;;GAIG;AACH,wBAAgB,0CAA0C,CACzD,WAAW,EAAE,cAAc,EAC3B,iBAAiB,EAAE,MAAM,EACzB,QAAQ,EAAE,EAAE,EACZ,eAAe,EAAE,MAAM,EACvB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,aAAa,CAAC,EAAE,EAAE,GAChB,EAAE,CA+BJ;AAED,wBAAgB,iCAAiC,CAChD,WAAW,EAAE,cAAc,EAC3B,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,EAAE,GACV,EAAE,CAuBJ;AAED,wBAAgB,yBAAyB,CACxC,cAAc,EAAE,EAAE,EAClB,mBAAmB,EAAE,EAAE,EACvB,WAAW,EAAE,EAAE,GACb,EAAE,CAYJ;AAED,wBAAgB,6BAA6B,CAC5C,WAAW,EAAE,cAAc,EAC3B,cAAc,EAAE,SAAS,EACzB,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,MAAM,EACzB,SAAS,EAAE,iBAAiB,GAC1B;IAAE,SAAS,EAAE,EAAE,CAAC;IAAC,qBAAqB,EAAE,EAAE,CAAA;CAAE,CAmB9C"}
|