@drift-labs/sdk 2.162.0-beta.2 → 2.163.0-beta.10
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 +2 -2
- package/VERSION +1 -1
- package/bun.lock +47 -79
- package/lib/browser/accounts/fetch.d.ts +6 -6
- package/lib/browser/accounts/fetch.js +4 -4
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcDriftClientAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.js +2 -2
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.js +2 -2
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +1 -1
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +2 -2
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +1 -1
- package/lib/browser/accounts/testBulkAccountLoader.js +3 -5
- package/lib/browser/accounts/types.d.ts +11 -14
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketAccountSubscriber.js +1 -2
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +5 -5
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.js +2 -2
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriberV2.js +2 -2
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +3 -3
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +2 -2
- package/lib/browser/addresses/pda.d.ts +6 -2
- package/lib/browser/addresses/pda.js +7 -12
- package/lib/browser/adminClient.d.ts +11 -9
- package/lib/browser/adminClient.js +30 -72
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
- package/lib/browser/config.d.ts +7 -3
- package/lib/browser/config.js +9 -7
- package/lib/browser/constants/index.d.ts +5 -0
- package/lib/browser/constants/index.js +5 -0
- package/lib/browser/constants/numericConstants.d.ts +1 -1
- package/lib/browser/constants/numericConstants.js +3 -3
- package/lib/browser/constants/perpMarkets.js +3 -412
- package/lib/browser/constants/spotMarkets.js +7 -91
- package/lib/browser/constituentMap/constituentMap.js +2 -2
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.d.ts +3 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +3 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +1 -1
- package/lib/browser/decode/customCoder.d.ts +7 -9
- package/lib/browser/decode/customCoder.js +17 -28
- package/lib/browser/decode/user.js +7 -25
- package/lib/browser/dlob/DLOB.d.ts +12 -0
- package/lib/browser/dlob/DLOB.js +12 -0
- package/lib/browser/dlob/orderBookLevels.js +1 -1
- package/lib/browser/driftClient.d.ts +32 -59
- package/lib/browser/driftClient.js +85 -562
- package/lib/browser/driftClientConfig.d.ts +7 -0
- package/lib/browser/events/eventSubscriber.d.ts +8 -0
- package/lib/browser/events/eventSubscriber.js +5 -2
- package/lib/browser/events/parse.d.ts +1 -1
- package/lib/browser/factory/oracleClient.d.ts +2 -2
- package/lib/browser/factory/oracleClient.js +9 -21
- package/lib/browser/idl/drift.d.ts +21406 -0
- package/lib/browser/idl/drift.js +2 -0
- package/lib/browser/idl/drift.json +20850 -15287
- 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 +148 -61
- package/lib/browser/index.d.ts +13 -6
- package/lib/browser/index.js +12 -5
- package/lib/browser/marinade/index.d.ts +1 -1
- package/lib/browser/marinade/index.js +2 -2
- package/lib/browser/math/amm.d.ts +4 -5
- package/lib/browser/math/amm.js +8 -35
- package/lib/browser/math/funding.js +6 -1
- package/lib/browser/math/margin.d.ts +3 -4
- package/lib/browser/math/margin.js +16 -47
- package/lib/browser/math/market.d.ts +2 -2
- package/lib/browser/math/market.js +10 -42
- package/lib/browser/math/oracles.js +14 -19
- package/lib/browser/math/position.js +1 -1
- package/lib/browser/math/trade.js +4 -4
- package/lib/browser/memcmp.js +8 -8
- package/lib/browser/openbook/openbookV2Subscriber.d.ts +1 -1
- package/lib/browser/openbook/openbookV2Subscriber.js +3 -3
- package/lib/browser/oracles/oracleClientCache.d.ts +2 -2
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +2 -2
- package/lib/browser/oracles/prelaunchOracleClient.js +1 -1
- package/lib/browser/oracles/pythLazerClient.js +3 -5
- package/lib/browser/oracles/types.d.ts +6 -0
- package/lib/browser/orderParams.d.ts +0 -1
- package/lib/browser/orderParams.js +1 -5
- package/lib/browser/orderSubscriber/OrderSubscriber.js +3 -4
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/browser/orderSubscriber/index.d.ts +5 -0
- package/lib/browser/orderSubscriber/index.js +5 -0
- package/lib/browser/priorityFee/index.d.ts +5 -0
- package/lib/browser/priorityFee/index.js +5 -0
- package/lib/browser/pyth/index.d.ts +2 -2
- package/lib/browser/pyth/types.d.ts +1 -1
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
- package/lib/browser/swift/index.d.ts +7 -0
- package/lib/browser/swift/index.js +7 -0
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +4 -3
- package/lib/browser/tokenFaucet.d.ts +2 -2
- package/lib/browser/tokenFaucet.js +4 -4
- package/lib/browser/tx/txHandler.d.ts +12 -0
- package/lib/browser/tx/txHandler.js +12 -0
- package/lib/browser/types.d.ts +19 -31
- package/lib/browser/types.js +6 -11
- package/lib/browser/user.d.ts +27 -18
- package/lib/browser/user.js +64 -100
- package/lib/browser/userMap/WebsocketSubscription.js +1 -1
- package/lib/browser/userMap/grpcSubscription.js +1 -1
- package/lib/browser/userMap/revenueShareEscrowMap.js +4 -4
- package/lib/browser/userMap/userMap.js +4 -5
- package/lib/browser/userMap/userStatsMap.js +2 -3
- package/lib/browser/userStats.d.ts +5 -0
- package/lib/node/accounts/fetch.d.ts +6 -6
- package/lib/node/accounts/fetch.d.ts.map +1 -1
- package/lib/node/accounts/fetch.js +4 -4
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.js +2 -2
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.js +2 -2
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +2 -2
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +1 -1
- package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/testBulkAccountLoader.js +3 -5
- package/lib/node/accounts/types.d.ts +11 -14
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +1 -2
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +5 -5
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.js +2 -2
- package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.js +2 -2
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +3 -3
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/addresses/pda.d.ts +6 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +7 -12
- package/lib/node/adminClient.d.ts +11 -9
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +30 -72
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
- package/lib/node/config.d.ts +7 -3
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +9 -7
- package/lib/node/constants/index.d.ts +5 -0
- package/lib/node/constants/index.d.ts.map +1 -1
- package/lib/node/constants/index.js +5 -0
- package/lib/node/constants/numericConstants.d.ts +1 -1
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +3 -3
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +3 -412
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +7 -91
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +2 -2
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts +3 -3
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +3 -3
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +1 -1
- package/lib/node/decode/customCoder.d.ts +7 -9
- package/lib/node/decode/customCoder.d.ts.map +1 -1
- package/lib/node/decode/customCoder.js +17 -28
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +7 -25
- package/lib/node/dlob/DLOB.d.ts +12 -0
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +12 -0
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +1 -1
- package/lib/node/driftClient.d.ts +32 -59
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +85 -562
- package/lib/node/driftClientConfig.d.ts +7 -0
- package/lib/node/driftClientConfig.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.d.ts +8 -0
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +5 -2
- package/lib/node/events/parse.d.ts +1 -1
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/factory/oracleClient.d.ts +2 -2
- package/lib/node/factory/oracleClient.d.ts.map +1 -1
- package/lib/node/factory/oracleClient.js +9 -21
- package/lib/node/idl/drift.d.ts +21407 -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 +20850 -15287
- 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 +148 -61
- package/lib/node/index.d.ts +13 -6
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +12 -5
- package/lib/node/marinade/index.d.ts +1 -1
- package/lib/node/marinade/index.d.ts.map +1 -1
- package/lib/node/marinade/index.js +2 -2
- package/lib/node/math/amm.d.ts +4 -5
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +8 -35
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +6 -1
- package/lib/node/math/margin.d.ts +3 -4
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +16 -47
- package/lib/node/math/market.d.ts +2 -2
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +10 -42
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +14 -19
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +1 -1
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +4 -4
- package/lib/node/memcmp.js +8 -8
- package/lib/node/openbook/openbookV2Subscriber.d.ts +1 -1
- package/lib/node/openbook/openbookV2Subscriber.d.ts.map +1 -1
- package/lib/node/openbook/openbookV2Subscriber.js +3 -3
- package/lib/node/oracles/oracleClientCache.d.ts +2 -2
- package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.d.ts +2 -2
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +1 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +3 -5
- package/lib/node/oracles/types.d.ts +6 -0
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/orderParams.d.ts +0 -1
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderParams.js +1 -5
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +3 -4
- package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/node/orderSubscriber/index.d.ts +5 -0
- package/lib/node/orderSubscriber/index.d.ts.map +1 -1
- package/lib/node/orderSubscriber/index.js +5 -0
- package/lib/node/priorityFee/index.d.ts +5 -0
- package/lib/node/priorityFee/index.d.ts.map +1 -1
- package/lib/node/priorityFee/index.js +5 -0
- package/lib/node/pyth/index.d.ts +2 -2
- package/lib/node/pyth/index.d.ts.map +1 -1
- package/lib/node/pyth/types.d.ts +1 -1
- package/lib/node/pyth/types.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
- package/lib/node/swift/index.d.ts +7 -0
- package/lib/node/swift/index.d.ts.map +1 -1
- package/lib/node/swift/index.js +7 -0
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +4 -3
- package/lib/node/tokenFaucet.d.ts +2 -2
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +4 -4
- package/lib/node/tx/txHandler.d.ts +12 -0
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +12 -0
- package/lib/node/types.d.ts +19 -31
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +6 -11
- package/lib/node/user.d.ts +27 -18
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +64 -100
- package/lib/node/userMap/WebsocketSubscription.js +1 -1
- package/lib/node/userMap/grpcSubscription.js +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +4 -4
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +4 -5
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +2 -3
- package/lib/node/userStats.d.ts +5 -0
- package/lib/node/userStats.d.ts.map +1 -1
- package/package.json +5 -7
- package/src/accounts/fetch.ts +18 -17
- package/src/accounts/grpcAccountSubscriber.ts +3 -3
- package/src/accounts/grpcDriftClientAccountSubscriber.ts +2 -3
- package/src/accounts/grpcDriftClientAccountSubscriberV2.ts +5 -6
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +2 -2
- package/src/accounts/grpcMultiAccountSubscriber.ts +4 -4
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +4 -4
- package/src/accounts/grpcProgramAccountSubscriber.ts +3 -3
- package/src/accounts/grpcUserAccountSubscriber.ts +2 -2
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +2 -2
- package/src/accounts/laserProgramAccountSubscriber.ts +3 -3
- package/src/accounts/oneShotUserAccountSubscriber.ts +6 -7
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +10 -9
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +12 -11
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -10
- package/src/accounts/pollingOracleAccountSubscriber.ts +2 -2
- package/src/accounts/pollingTokenAccountSubscriber.ts +2 -2
- package/src/accounts/pollingUserAccountSubscriber.ts +2 -2
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +14 -14
- package/src/accounts/testBulkAccountLoader.ts +3 -5
- package/src/accounts/types.ts +10 -25
- package/src/accounts/webSocketAccountSubscriber.ts +5 -5
- package/src/accounts/webSocketAccountSubscriberV2.ts +4 -3
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +9 -10
- package/src/accounts/webSocketDriftClientAccountSubscriberV2.ts +13 -10
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +3 -3
- package/src/accounts/webSocketProgramAccountSubscriber.ts +4 -3
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +4 -3
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +4 -3
- package/src/accounts/webSocketUserAccountSubscriber.ts +3 -3
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +3 -3
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +4 -4
- package/src/addresses/pda.ts +6 -22
- package/src/adminClient.ts +154 -239
- package/src/auctionSubscriber/auctionSubscriber.ts +5 -3
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +5 -3
- package/src/config.ts +24 -16
- package/src/constants/index.ts +5 -0
- package/src/constants/numericConstants.ts +2 -3
- package/src/constants/perpMarkets.ts +3 -445
- package/src/constants/spotMarkets.ts +7 -102
- package/src/constituentMap/constituentMap.ts +5 -6
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +3 -3
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +6 -6
- package/src/decode/customCoder.ts +26 -35
- package/src/decode/user.ts +7 -25
- package/src/dlob/DLOB.ts +12 -0
- package/src/dlob/orderBookLevels.ts +0 -1
- package/src/driftClient.ts +245 -1091
- package/src/driftClientConfig.ts +7 -0
- package/src/events/eventSubscriber.ts +14 -2
- package/src/events/parse.ts +2 -2
- package/src/factory/oracleClient.ts +17 -28
- package/src/idl/drift.json +20850 -15287
- package/src/idl/drift.ts +21406 -0
- package/src/idl/pyth.ts +97 -0
- package/src/idl/token_faucet.json +148 -61
- package/src/idl/token_faucet.ts +197 -0
- package/src/index.ts +13 -12
- package/src/margin/README.md +0 -1
- package/src/marinade/index.ts +2 -2
- package/src/math/amm.ts +2 -48
- package/src/math/funding.ts +8 -3
- package/src/math/margin.ts +12 -67
- package/src/math/market.ts +15 -69
- package/src/math/oracles.ts +14 -30
- package/src/math/position.ts +0 -1
- package/src/math/trade.ts +0 -4
- package/src/memcmp.ts +1 -1
- package/src/openbook/openbookV2Subscriber.ts +1 -1
- package/src/oracles/oracleClientCache.ts +2 -2
- package/src/oracles/prelaunchOracleClient.ts +9 -8
- package/src/oracles/pythLazerClient.ts +10 -12
- package/src/oracles/types.ts +6 -0
- package/src/orderParams.ts +0 -5
- package/src/orderSubscriber/OrderSubscriber.ts +7 -6
- package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
- package/src/orderSubscriber/grpcSubscription.ts +2 -2
- package/src/orderSubscriber/index.ts +5 -0
- package/src/priorityFee/index.ts +5 -0
- package/src/pyth/index.ts +4 -4
- package/src/pyth/types.ts +1 -1
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +1 -1
- package/src/swift/index.ts +7 -0
- package/src/swift/signedMsgUserAccountSubscriber.ts +7 -4
- package/src/tokenFaucet.ts +8 -4
- package/src/tx/txHandler.ts +12 -0
- package/src/types.ts +16 -20
- package/src/user.ts +66 -144
- package/src/userMap/WebsocketSubscription.ts +1 -1
- package/src/userMap/grpcSubscription.ts +1 -1
- package/src/userMap/revenueShareEscrowMap.ts +24 -20
- package/src/userMap/userMap.ts +8 -7
- package/src/userMap/userStatsMap.ts +6 -5
- package/src/userStats.ts +5 -0
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +5 -4
- package/tests/amm/test.ts +45 -64
- package/tests/ci/verifyConstants.ts +23 -26
- package/tests/decode/test.ts +2 -4
- package/tests/dlob/helpers.ts +8 -15
- package/tests/user/helpers.ts +0 -2
- package/tests/user/marginCalculations.test.ts +2 -3
- package/tests/user/test.ts +18 -15
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +0 -29
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +0 -111
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +0 -23
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +0 -69
- package/lib/browser/idl/pyth_solana_receiver.json +0 -628
- package/lib/browser/idl/switchboard.json +0 -8354
- package/lib/browser/idl/switchboard_on_demand_30.json +0 -5849
- package/lib/browser/oracles/pythPullClient.d.ts +0 -19
- package/lib/browser/oracles/pythPullClient.js +0 -65
- package/lib/browser/oracles/switchboardClient.d.ts +0 -12
- package/lib/browser/oracles/switchboardClient.js +0 -40
- package/lib/browser/oracles/switchboardOnDemandClient.d.ts +0 -12
- package/lib/browser/oracles/switchboardOnDemandClient.js +0 -33
- package/lib/browser/util/pythOracleUtils.d.ts +0 -2
- package/lib/browser/util/pythOracleUtils.js +0 -15
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +0 -30
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts.map +0 -1
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +0 -111
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +0 -24
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts.map +0 -1
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +0 -69
- package/lib/node/idl/pyth_solana_receiver.json +0 -628
- package/lib/node/idl/switchboard.json +0 -8354
- package/lib/node/idl/switchboard_on_demand_30.json +0 -5849
- package/lib/node/oracles/pythPullClient.d.ts +0 -20
- package/lib/node/oracles/pythPullClient.d.ts.map +0 -1
- package/lib/node/oracles/pythPullClient.js +0 -65
- package/lib/node/oracles/switchboardClient.d.ts +0 -13
- package/lib/node/oracles/switchboardClient.d.ts.map +0 -1
- package/lib/node/oracles/switchboardClient.js +0 -40
- package/lib/node/oracles/switchboardOnDemandClient.d.ts +0 -13
- package/lib/node/oracles/switchboardOnDemandClient.d.ts.map +0 -1
- package/lib/node/oracles/switchboardOnDemandClient.js +0 -33
- package/lib/node/util/pythOracleUtils.d.ts +0 -3
- package/lib/node/util/pythOracleUtils.d.ts.map +0 -1
- package/lib/node/util/pythOracleUtils.js +0 -15
- package/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +0 -189
- package/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +0 -131
- package/src/idl/switchboard.json +0 -8354
- package/src/idl/switchboard_on_demand_30.json +0 -5849
- package/src/oracles/pythPullClient.ts +0 -112
- package/src/oracles/switchboardClient.ts +0 -77
- package/src/oracles/switchboardOnDemandClient.ts +0 -64
- package/src/util/pythOracleUtils.ts +0 -11
package/src/userMap/userMap.ts
CHANGED
|
@@ -133,10 +133,11 @@ export class UserMap implements UserMapInterface {
|
|
|
133
133
|
if (config.fastDecode ?? true) {
|
|
134
134
|
decodeFn = (name, buffer) => decodeUser(buffer);
|
|
135
135
|
} else {
|
|
136
|
-
decodeFn =
|
|
137
|
-
this.driftClient.program.account
|
|
138
|
-
|
|
139
|
-
)
|
|
136
|
+
decodeFn = (
|
|
137
|
+
this.driftClient.program.account as any
|
|
138
|
+
).user.coder.accounts.decodeUnchecked.bind(
|
|
139
|
+
(this.driftClient.program.account as any).user.coder.accounts
|
|
140
|
+
);
|
|
140
141
|
}
|
|
141
142
|
this.decode = decodeFn;
|
|
142
143
|
|
|
@@ -484,11 +485,11 @@ export class UserMap implements UserMapInterface {
|
|
|
484
485
|
const currAccountWithSlot = this.getWithSlot(key);
|
|
485
486
|
if (currAccountWithSlot) {
|
|
486
487
|
if (slot >= currAccountWithSlot.slot) {
|
|
487
|
-
const userAccount = this.decode('
|
|
488
|
+
const userAccount = this.decode('user', buffer);
|
|
488
489
|
this.updateUserAccount(key, userAccount, slot);
|
|
489
490
|
}
|
|
490
491
|
} else {
|
|
491
|
-
const userAccount = this.decode('
|
|
492
|
+
const userAccount = this.decode('user', buffer);
|
|
492
493
|
await this.addPubkey(new PublicKey(key), userAccount, slot);
|
|
493
494
|
}
|
|
494
495
|
})()
|
|
@@ -590,7 +591,7 @@ export class UserMap implements UserMapInterface {
|
|
|
590
591
|
const buffer = Buffer.from(accountInfo.data);
|
|
591
592
|
programAccountBufferMap.set(publicKeyString, buffer);
|
|
592
593
|
|
|
593
|
-
const decodedUser = this.decode('
|
|
594
|
+
const decodedUser = this.decode('user', buffer);
|
|
594
595
|
|
|
595
596
|
const currAccountWithSlot = this.getWithSlot(publicKeyString);
|
|
596
597
|
if (
|
|
@@ -60,10 +60,11 @@ export class UserStatsMap {
|
|
|
60
60
|
type: 'default',
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
this.decode =
|
|
64
|
-
this.driftClient.program.account
|
|
65
|
-
|
|
66
|
-
)
|
|
63
|
+
this.decode = (
|
|
64
|
+
this.driftClient.program.account as any
|
|
65
|
+
).userStats.coder.accounts.decodeUnchecked.bind(
|
|
66
|
+
(this.driftClient.program.account as any).userStats.coder.accounts
|
|
67
|
+
);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
public async subscribe(authorities: PublicKey[]) {
|
|
@@ -317,7 +318,7 @@ export class UserStatsMap {
|
|
|
317
318
|
if (!this.has(publicKeyString)) {
|
|
318
319
|
const buffer = Buffer.from(accountInfo.data);
|
|
319
320
|
const decodedUserStats = this.decode(
|
|
320
|
-
'
|
|
321
|
+
'userStats',
|
|
321
322
|
buffer
|
|
322
323
|
) as UserStatsAccount;
|
|
323
324
|
programAccountBufferMap.add(
|
package/src/userStats.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UserStats — abstraction over the on-chain `UserStats` account.
|
|
3
|
+
* Tracks referral links, 30-day maker/taker volume, fuel rewards, and IF staking stats.
|
|
4
|
+
* One `UserStats` account exists per authority (shared across all subaccounts).
|
|
5
|
+
*/
|
|
1
6
|
import { DriftClient } from './driftClient';
|
|
2
7
|
import { PublicKey } from '@solana/web3.js';
|
|
3
8
|
import { DataAndSlot, UserStatsAccountSubscriber } from './accounts/types';
|
|
@@ -123,7 +123,8 @@ describe('CustomizedCadenceBulkAccountLoader', () => {
|
|
|
123
123
|
expect(loader.getAccountCadence(pubkey3)).to.equal(initialFrequency);
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
it('accounts in different polling groups fire at appropriate intervals', async ()
|
|
126
|
+
it('accounts in different polling groups fire at appropriate intervals', async function () {
|
|
127
|
+
this.timeout(10000);
|
|
127
128
|
const loader = new CustomizedCadenceBulkAccountLoader(
|
|
128
129
|
connection,
|
|
129
130
|
'processed',
|
|
@@ -188,13 +189,13 @@ describe('CustomizedCadenceBulkAccountLoader', () => {
|
|
|
188
189
|
// 3s group should have fired ~2 times
|
|
189
190
|
for (const account of threeSecGroup) {
|
|
190
191
|
expect(account.callCount).to.be.greaterThanOrEqual(1);
|
|
191
|
-
expect(account.callCount).to.be.lessThanOrEqual(
|
|
192
|
+
expect(account.callCount).to.be.lessThanOrEqual(4);
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
//
|
|
195
|
+
// 4s group: custom frequency > default (1s), so fires at default ~4 times in 4.5s
|
|
195
196
|
for (const account of fourSecGroup) {
|
|
196
197
|
expect(account.callCount).to.be.greaterThanOrEqual(1);
|
|
197
|
-
expect(account.callCount).to.be.lessThanOrEqual(
|
|
198
|
+
expect(account.callCount).to.be.lessThanOrEqual(5);
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
loader.stopPolling();
|
package/tests/amm/test.ts
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
OracleGuardRails,
|
|
33
33
|
getNewOracleConfPct,
|
|
34
34
|
MMOraclePriceData,
|
|
35
|
+
OraclePriceData,
|
|
35
36
|
// calculateReservePrice,
|
|
36
37
|
} from '../../src';
|
|
37
38
|
import { mockPerpMarkets } from '../dlob/helpers';
|
|
@@ -312,7 +313,7 @@ describe('AMM Tests', () => {
|
|
|
312
313
|
// console.log(terms1);
|
|
313
314
|
|
|
314
315
|
console.log('long/short spread:', l1, s1);
|
|
315
|
-
assert(l1 ==
|
|
316
|
+
assert(l1 == 12500);
|
|
316
317
|
assert(s1 == 12500);
|
|
317
318
|
assert(l1 == terms1.longSpread);
|
|
318
319
|
assert(s1 == terms1.shortSpread);
|
|
@@ -343,11 +344,10 @@ describe('AMM Tests', () => {
|
|
|
343
344
|
true
|
|
344
345
|
);
|
|
345
346
|
|
|
346
|
-
// console.log(terms2);
|
|
347
347
|
assert(terms2.effectiveLeverageCapped >= 1.0002);
|
|
348
|
-
assert(terms2.inventorySpreadScale ==
|
|
349
|
-
assert(terms2.longSpread ==
|
|
350
|
-
assert(terms2.shortSpread ==
|
|
348
|
+
assert(terms2.inventorySpreadScale == 8.443219);
|
|
349
|
+
assert(terms2.longSpread == 150);
|
|
350
|
+
assert(terms2.shortSpread == 3960);
|
|
351
351
|
|
|
352
352
|
// add spread offset
|
|
353
353
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -378,10 +378,10 @@ describe('AMM Tests', () => {
|
|
|
378
378
|
|
|
379
379
|
// console.log(terms3);
|
|
380
380
|
assert(terms3.effectiveLeverageCapped >= 1.0002);
|
|
381
|
-
assert(terms3.inventorySpreadScale ==
|
|
382
|
-
assert(terms3.longSpread ==
|
|
383
|
-
assert(terms3.shortSpread ==
|
|
384
|
-
assert(terms3.longSpread + terms3.shortSpread ==
|
|
381
|
+
assert(terms3.inventorySpreadScale == 8.443219);
|
|
382
|
+
assert(terms3.longSpread == 150);
|
|
383
|
+
assert(terms3.shortSpread == 3960);
|
|
384
|
+
assert(terms3.longSpread + terms3.shortSpread == 3960 + 150);
|
|
385
385
|
|
|
386
386
|
// add spread offset
|
|
387
387
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -410,7 +410,6 @@ describe('AMM Tests', () => {
|
|
|
410
410
|
true
|
|
411
411
|
);
|
|
412
412
|
|
|
413
|
-
console.log(terms4);
|
|
414
413
|
assert(terms4.effectiveLeverageCapped >= 1.0002);
|
|
415
414
|
assert(terms4.inventorySpreadScale == 1.73492);
|
|
416
415
|
assert(terms4.longSpread == 89746);
|
|
@@ -445,11 +444,10 @@ describe('AMM Tests', () => {
|
|
|
445
444
|
true
|
|
446
445
|
);
|
|
447
446
|
|
|
448
|
-
// console.log(terms2);
|
|
449
447
|
assert(terms2.effectiveLeverageCapped <= 1.000001);
|
|
450
448
|
assert(terms2.inventorySpreadScale == 1.0306);
|
|
451
449
|
assert(terms2.longSpread == 515);
|
|
452
|
-
assert(terms2.shortSpread ==
|
|
450
|
+
assert(terms2.shortSpread == 5611);
|
|
453
451
|
|
|
454
452
|
const suiExample = {
|
|
455
453
|
status: 'active',
|
|
@@ -618,15 +616,14 @@ describe('AMM Tests', () => {
|
|
|
618
616
|
true
|
|
619
617
|
);
|
|
620
618
|
|
|
621
|
-
// console.log(termsSuiExample);
|
|
622
619
|
assert(termsSuiExample.effectiveLeverageCapped <= 1.000001);
|
|
623
620
|
assert(termsSuiExample.inventorySpreadScale == 1.00007);
|
|
624
621
|
assert(
|
|
625
|
-
termsSuiExample.longSpread ==
|
|
622
|
+
termsSuiExample.longSpread == 269813,
|
|
626
623
|
`SUI long spread got ${termsSuiExample.longSpread}`
|
|
627
624
|
);
|
|
628
625
|
assert(
|
|
629
|
-
termsSuiExample.shortSpread ==
|
|
626
|
+
termsSuiExample.shortSpread == 3925,
|
|
630
627
|
`SUI short spread got ${termsSuiExample.shortSpread}`
|
|
631
628
|
);
|
|
632
629
|
|
|
@@ -795,10 +792,10 @@ describe('AMM Tests', () => {
|
|
|
795
792
|
console.log(reserves2[0].baseAssetReserve.toString());
|
|
796
793
|
console.log(reserves2[0].quoteAssetReserve.toString());
|
|
797
794
|
|
|
798
|
-
assert(reserves2[0].baseAssetReserve.eq(new BN('
|
|
799
|
-
assert(reserves2[0].quoteAssetReserve.eq(new BN('
|
|
800
|
-
assert(reserves2[1].baseAssetReserve.eq(new BN('
|
|
801
|
-
assert(reserves2[1].quoteAssetReserve.eq(new BN('
|
|
795
|
+
assert(reserves2[0].baseAssetReserve.eq(new BN('1006289308')));
|
|
796
|
+
assert(reserves2[0].quoteAssetReserve.eq(new BN('993750000')));
|
|
797
|
+
assert(reserves2[1].baseAssetReserve.eq(new BN('993788819')));
|
|
798
|
+
assert(reserves2[1].quoteAssetReserve.eq(new BN('1006250000')));
|
|
802
799
|
|
|
803
800
|
// create imbalance for reference price offset
|
|
804
801
|
mockAmm.baseAssetReserve = new BN(1000000000 * 1.1);
|
|
@@ -848,8 +845,8 @@ describe('AMM Tests', () => {
|
|
|
848
845
|
console.log(reserves3[0].baseAssetReserve.toString());
|
|
849
846
|
console.log(reserves3[0].quoteAssetReserve.toString());
|
|
850
847
|
|
|
851
|
-
assert(reserves3[0].baseAssetReserve.eq(new BN('
|
|
852
|
-
assert(reserves3[0].quoteAssetReserve.eq(new BN('
|
|
848
|
+
assert(reserves3[0].baseAssetReserve.eq(new BN('1100068201')));
|
|
849
|
+
assert(reserves3[0].quoteAssetReserve.eq(new BN('909034546')));
|
|
853
850
|
assert(reserves3[1].baseAssetReserve.eq(new BN('989999998')));
|
|
854
851
|
assert(reserves3[1].quoteAssetReserve.eq(new BN('1010101010')));
|
|
855
852
|
|
|
@@ -864,18 +861,15 @@ describe('AMM Tests', () => {
|
|
|
864
861
|
reserves3[1].quoteAssetReserve,
|
|
865
862
|
mockAmm.pegMultiplier
|
|
866
863
|
);
|
|
867
|
-
console.log(p1.toString(), p2.toString());
|
|
868
864
|
|
|
869
|
-
assert(p1.eq(new BN(
|
|
865
|
+
assert(p1.eq(new BN(11199437)));
|
|
870
866
|
assert(p2.eq(new BN(13828180)));
|
|
871
867
|
|
|
872
868
|
mockAmm.curveUpdateIntensity = 110;
|
|
873
869
|
const reserves4 = calculateSpreadReserves(mockAmm, oraclePriceData, now);
|
|
874
|
-
console.log(reserves4[1].baseAssetReserve.toString());
|
|
875
|
-
console.log(reserves4[1].quoteAssetReserve.toString());
|
|
876
870
|
|
|
877
|
-
assert(reserves4[0].baseAssetReserve.eq(new BN('
|
|
878
|
-
assert(reserves4[0].quoteAssetReserve.eq(new BN('
|
|
871
|
+
assert(reserves4[0].baseAssetReserve.eq(new BN('1100068201')));
|
|
872
|
+
assert(reserves4[0].quoteAssetReserve.eq(new BN('909034546')));
|
|
879
873
|
assert(reserves4[1].baseAssetReserve.eq(new BN('989999998')));
|
|
880
874
|
assert(reserves4[1].quoteAssetReserve.eq(new BN('1010101010')));
|
|
881
875
|
|
|
@@ -890,15 +884,12 @@ describe('AMM Tests', () => {
|
|
|
890
884
|
reserves4[1].quoteAssetReserve,
|
|
891
885
|
mockAmm.pegMultiplier
|
|
892
886
|
);
|
|
893
|
-
console.log(p1RF.toString(), p2RF.toString());
|
|
894
887
|
|
|
895
|
-
assert(p1RF.eq(new BN(
|
|
888
|
+
assert(p1RF.eq(new BN(11199437)));
|
|
896
889
|
assert(p2RF.eq(new BN(13828180)));
|
|
897
890
|
// no ref price offset at 100
|
|
898
891
|
mockAmm.curveUpdateIntensity = 100;
|
|
899
892
|
const reserves5 = calculateSpreadReserves(mockAmm, oraclePriceData, now);
|
|
900
|
-
console.log(reserves5[0].baseAssetReserve.toString());
|
|
901
|
-
console.log(reserves5[0].quoteAssetReserve.toString());
|
|
902
893
|
|
|
903
894
|
assert(reserves5[0].baseAssetReserve.eq(new BN('1100068201')));
|
|
904
895
|
assert(reserves5[0].quoteAssetReserve.eq(new BN('909034546')));
|
|
@@ -916,11 +907,10 @@ describe('AMM Tests', () => {
|
|
|
916
907
|
reserves5[1].quoteAssetReserve,
|
|
917
908
|
mockAmm.pegMultiplier
|
|
918
909
|
);
|
|
919
|
-
console.log(p1RFNone.toString(), p2RFNone.toString());
|
|
920
910
|
|
|
921
911
|
assert(p1RFNone.eq(new BN(11199437)));
|
|
922
912
|
assert(p2RFNone.eq(new BN(13828180)));
|
|
923
|
-
assert(p1RF.sub(p1RFNone).eq(new BN(
|
|
913
|
+
assert(p1RF.sub(p1RFNone).eq(new BN(0)));
|
|
924
914
|
assert(p2RF.sub(p2RFNone).eq(new BN(0))); // todo?
|
|
925
915
|
});
|
|
926
916
|
it('Spread Reserves (with negative offset)', () => {
|
|
@@ -1062,10 +1052,10 @@ describe('AMM Tests', () => {
|
|
|
1062
1052
|
console.log(reserves3[0].baseAssetReserve.toString());
|
|
1063
1053
|
console.log(reserves3[0].quoteAssetReserve.toString());
|
|
1064
1054
|
|
|
1065
|
-
assert(reserves3[0].baseAssetReserve.eq(new BN('
|
|
1066
|
-
assert(reserves3[0].quoteAssetReserve.eq(new BN('
|
|
1067
|
-
assert(reserves3[1].baseAssetReserve.eq(new BN('
|
|
1068
|
-
assert(reserves3[1].quoteAssetReserve.eq(new BN('
|
|
1055
|
+
assert(reserves3[0].baseAssetReserve.eq(new BN('999999998')));
|
|
1056
|
+
assert(reserves3[0].quoteAssetReserve.eq(new BN('1000000000')));
|
|
1057
|
+
assert(reserves3[1].baseAssetReserve.eq(new BN('909034547')));
|
|
1058
|
+
assert(reserves3[1].quoteAssetReserve.eq(new BN('1100068200')));
|
|
1069
1059
|
|
|
1070
1060
|
const p1 = calculatePrice(
|
|
1071
1061
|
reserves3[0].baseAssetReserve,
|
|
@@ -1078,20 +1068,17 @@ describe('AMM Tests', () => {
|
|
|
1078
1068
|
reserves3[1].quoteAssetReserve,
|
|
1079
1069
|
mockAmm.pegMultiplier
|
|
1080
1070
|
);
|
|
1081
|
-
console.log(p1.toString(), p2.toString());
|
|
1082
1071
|
|
|
1083
|
-
assert(p1.eq(new BN(
|
|
1084
|
-
assert(p2.eq(new BN(
|
|
1072
|
+
assert(p1.eq(new BN(13553000)));
|
|
1073
|
+
assert(p2.eq(new BN(16401163)));
|
|
1085
1074
|
|
|
1086
1075
|
mockAmm.curveUpdateIntensity = 110;
|
|
1087
1076
|
const reserves4 = calculateSpreadReserves(mockAmm, oraclePriceData, now);
|
|
1088
|
-
console.log(reserves4[1].baseAssetReserve.toString());
|
|
1089
|
-
console.log(reserves4[1].quoteAssetReserve.toString());
|
|
1090
1077
|
|
|
1091
1078
|
assert(reserves4[0].baseAssetReserve.eq(new BN('999999998')));
|
|
1092
1079
|
assert(reserves4[0].quoteAssetReserve.eq(new BN('1000000000')));
|
|
1093
|
-
assert(reserves4[1].baseAssetReserve.eq(new BN('
|
|
1094
|
-
assert(reserves4[1].quoteAssetReserve.eq(new BN('
|
|
1080
|
+
assert(reserves4[1].baseAssetReserve.eq(new BN('909034547')));
|
|
1081
|
+
assert(reserves4[1].quoteAssetReserve.eq(new BN('1100068200')));
|
|
1095
1082
|
|
|
1096
1083
|
const p1RF = calculatePrice(
|
|
1097
1084
|
reserves4[0].baseAssetReserve,
|
|
@@ -1104,16 +1091,13 @@ describe('AMM Tests', () => {
|
|
|
1104
1091
|
reserves4[1].quoteAssetReserve,
|
|
1105
1092
|
mockAmm.pegMultiplier
|
|
1106
1093
|
);
|
|
1107
|
-
console.log(p1RF.toString(), p2RF.toString());
|
|
1108
1094
|
|
|
1109
1095
|
assert(p1RF.eq(new BN(13553000)));
|
|
1110
|
-
assert(p2RF.eq(new BN(
|
|
1096
|
+
assert(p2RF.eq(new BN(16401163)));
|
|
1111
1097
|
|
|
1112
1098
|
// no ref price offset at 100
|
|
1113
1099
|
mockAmm.curveUpdateIntensity = 100;
|
|
1114
1100
|
const reserves5 = calculateSpreadReserves(mockAmm, oraclePriceData, now);
|
|
1115
|
-
console.log(reserves5[0].baseAssetReserve.toString());
|
|
1116
|
-
console.log(reserves5[0].quoteAssetReserve.toString());
|
|
1117
1101
|
|
|
1118
1102
|
assert(reserves5[0].baseAssetReserve.eq(new BN('999999998')));
|
|
1119
1103
|
assert(reserves5[0].quoteAssetReserve.eq(new BN('1000000000')));
|
|
@@ -1131,14 +1115,12 @@ describe('AMM Tests', () => {
|
|
|
1131
1115
|
reserves5[1].quoteAssetReserve,
|
|
1132
1116
|
mockAmm.pegMultiplier
|
|
1133
1117
|
);
|
|
1134
|
-
console.log(p1RFNone.toString(), p2RFNone.toString());
|
|
1135
1118
|
|
|
1136
1119
|
const rr = p2RF.sub(p2RFNone).mul(PERCENTAGE_PRECISION).div(p2RF);
|
|
1137
|
-
console.log(rr.toNumber());
|
|
1138
1120
|
assert(p1RFNone.eq(new BN(13553000)));
|
|
1139
1121
|
assert(p2RFNone.eq(new BN(16401163)));
|
|
1140
1122
|
assert(p1RF.sub(p1RFNone).eq(new BN(0))); // todo?
|
|
1141
|
-
assert(rr.eq(new BN(
|
|
1123
|
+
assert(rr.eq(new BN(0)));
|
|
1142
1124
|
});
|
|
1143
1125
|
|
|
1144
1126
|
it('live update functions', () => {
|
|
@@ -1172,8 +1154,7 @@ describe('AMM Tests', () => {
|
|
|
1172
1154
|
assert(liveOracleTwap.eq(new BN(13539488)));
|
|
1173
1155
|
|
|
1174
1156
|
const liveOracleStd = calculateLiveOracleStd(mockAmm, oraclePriceData, now);
|
|
1175
|
-
|
|
1176
|
-
assert(liveOracleStd.eq(new BN(192962)));
|
|
1157
|
+
assert(liveOracleStd.eq(new BN(13732450)));
|
|
1177
1158
|
|
|
1178
1159
|
mockAmm.lastOracleConfPct = new BN(150000);
|
|
1179
1160
|
const reservePrice = new BN(13.553 * PRICE_PRECISION.toNumber());
|
|
@@ -1373,7 +1354,7 @@ describe('AMM Tests', () => {
|
|
|
1373
1354
|
] = calculateAllEstimatedFundingRate(
|
|
1374
1355
|
mockMarket1,
|
|
1375
1356
|
mmOraclePriceData,
|
|
1376
|
-
|
|
1357
|
+
mmOraclePriceData as unknown as OraclePriceData,
|
|
1377
1358
|
currentMarkPrice,
|
|
1378
1359
|
now
|
|
1379
1360
|
);
|
|
@@ -1382,7 +1363,7 @@ describe('AMM Tests', () => {
|
|
|
1382
1363
|
calculateLongShortFundingRateAndLiveTwaps(
|
|
1383
1364
|
mockMarket1,
|
|
1384
1365
|
mmOraclePriceData,
|
|
1385
|
-
|
|
1366
|
+
mmOraclePriceData as unknown as OraclePriceData,
|
|
1386
1367
|
currentMarkPrice,
|
|
1387
1368
|
now
|
|
1388
1369
|
);
|
|
@@ -1394,8 +1375,8 @@ describe('AMM Tests', () => {
|
|
|
1394
1375
|
|
|
1395
1376
|
assert(markTwapLive.eq(new BN('1949826')));
|
|
1396
1377
|
assert(oracleTwapLive.eq(new BN('1942510')));
|
|
1397
|
-
assert(est1.eq(new BN('
|
|
1398
|
-
assert(est2.eq(new BN('
|
|
1378
|
+
assert(est1.eq(new BN('16941')));
|
|
1379
|
+
assert(est2.eq(new BN('16941')));
|
|
1399
1380
|
});
|
|
1400
1381
|
|
|
1401
1382
|
it('predicted funding rate mock2', () => {
|
|
@@ -1449,7 +1430,7 @@ describe('AMM Tests', () => {
|
|
|
1449
1430
|
] = calculateAllEstimatedFundingRate(
|
|
1450
1431
|
mockMarket1,
|
|
1451
1432
|
mmOraclePriceData,
|
|
1452
|
-
|
|
1433
|
+
mmOraclePriceData as unknown as OraclePriceData,
|
|
1453
1434
|
currentMarkPrice,
|
|
1454
1435
|
now
|
|
1455
1436
|
);
|
|
@@ -1465,7 +1446,7 @@ describe('AMM Tests', () => {
|
|
|
1465
1446
|
calculateLongShortFundingRateAndLiveTwaps(
|
|
1466
1447
|
mockMarket1,
|
|
1467
1448
|
mmOraclePriceData,
|
|
1468
|
-
|
|
1449
|
+
mmOraclePriceData as unknown as OraclePriceData,
|
|
1469
1450
|
currentMarkPrice,
|
|
1470
1451
|
now
|
|
1471
1452
|
);
|
|
@@ -1487,7 +1468,7 @@ describe('AMM Tests', () => {
|
|
|
1487
1468
|
assert(markTwapLive.eq(new BN('1222131')));
|
|
1488
1469
|
assert(oracleTwapLive.eq(new BN('1222586')));
|
|
1489
1470
|
assert(est1.eq(est2));
|
|
1490
|
-
assert(est2.eq(new BN('
|
|
1471
|
+
assert(est2.eq(new BN('1247')));
|
|
1491
1472
|
});
|
|
1492
1473
|
|
|
1493
1474
|
it('predicted funding rate mock clamp', () => {
|
|
@@ -1542,7 +1523,7 @@ describe('AMM Tests', () => {
|
|
|
1542
1523
|
] = calculateAllEstimatedFundingRate(
|
|
1543
1524
|
mockMarket1,
|
|
1544
1525
|
mmOraclePriceData,
|
|
1545
|
-
|
|
1526
|
+
mmOraclePriceData as unknown as OraclePriceData,
|
|
1546
1527
|
currentMarkPrice,
|
|
1547
1528
|
now
|
|
1548
1529
|
);
|
|
@@ -1558,7 +1539,7 @@ describe('AMM Tests', () => {
|
|
|
1558
1539
|
calculateLongShortFundingRateAndLiveTwaps(
|
|
1559
1540
|
mockMarket1,
|
|
1560
1541
|
mmOraclePriceData,
|
|
1561
|
-
|
|
1542
|
+
mmOraclePriceData as unknown as OraclePriceData,
|
|
1562
1543
|
currentMarkPrice,
|
|
1563
1544
|
now
|
|
1564
1545
|
);
|
|
@@ -1588,7 +1569,7 @@ describe('AMM Tests', () => {
|
|
|
1588
1569
|
calculateLongShortFundingRateAndLiveTwaps(
|
|
1589
1570
|
mockMarket1,
|
|
1590
1571
|
mmOraclePriceData,
|
|
1591
|
-
|
|
1572
|
+
mmOraclePriceData as unknown as OraclePriceData,
|
|
1592
1573
|
currentMarkPrice,
|
|
1593
1574
|
now
|
|
1594
1575
|
);
|
|
@@ -1618,7 +1599,7 @@ describe('AMM Tests', () => {
|
|
|
1618
1599
|
calculateLongShortFundingRateAndLiveTwaps(
|
|
1619
1600
|
mockMarket1,
|
|
1620
1601
|
mmOraclePriceData,
|
|
1621
|
-
|
|
1602
|
+
mmOraclePriceData as unknown as OraclePriceData,
|
|
1622
1603
|
currentMarkPrice,
|
|
1623
1604
|
now
|
|
1624
1605
|
);
|
|
@@ -26,6 +26,13 @@ describe('Verify Constants', function () {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const wallet = new Wallet(Keypair.generate());
|
|
29
|
+
const isPullOracleSource = (oracleSource: unknown) =>
|
|
30
|
+
isOneOfVariant(oracleSource, [
|
|
31
|
+
'pythPull',
|
|
32
|
+
'pyth1KPull',
|
|
33
|
+
'pyth1MPull',
|
|
34
|
+
'pythStableCoinPull',
|
|
35
|
+
]);
|
|
29
36
|
|
|
30
37
|
const devnetConnection = new Connection(DEVNET_RPC_ENDPOINT);
|
|
31
38
|
const mainnetConnection = new Connection(MAINNET_RPC_ENDPOINT);
|
|
@@ -92,6 +99,10 @@ describe('Verify Constants', function () {
|
|
|
92
99
|
spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
|
|
93
100
|
|
|
94
101
|
for (const market of spotMarkets) {
|
|
102
|
+
if (isPullOracleSource(market.oracleSource)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
95
106
|
const correspondingConfigMarket = MainnetSpotMarkets.find(
|
|
96
107
|
(configMarket) => configMarket.marketIndex === market.marketIndex
|
|
97
108
|
);
|
|
@@ -157,25 +168,16 @@ describe('Verify Constants', function () {
|
|
|
157
168
|
description: 'oracle',
|
|
158
169
|
});
|
|
159
170
|
}
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
isOneOfVariant(market.oracleSource, [
|
|
163
|
-
'pythPull',
|
|
164
|
-
'pyth1KPull',
|
|
165
|
-
'pyth1MPull',
|
|
166
|
-
'pythStableCoinPull',
|
|
167
|
-
])
|
|
168
|
-
) {
|
|
169
|
-
if (!correspondingConfigMarket.pythFeedId) {
|
|
170
|
-
errors.push(`spot market ${market.marketIndex} missing feed id`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
171
|
}
|
|
174
172
|
|
|
175
173
|
const perpMarkets = mainnetDriftClient.getPerpMarketAccounts();
|
|
176
174
|
perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
|
|
177
175
|
|
|
178
176
|
for (const market of perpMarkets) {
|
|
177
|
+
if (isPullOracleSource(market.amm.oracleSource)) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
|
|
179
181
|
const correspondingConfigMarket = MainnetPerpMarkets.find(
|
|
180
182
|
(configMarket) => configMarket.marketIndex === market.marketIndex
|
|
181
183
|
);
|
|
@@ -234,19 +236,6 @@ describe('Verify Constants', function () {
|
|
|
234
236
|
description: 'oracle',
|
|
235
237
|
});
|
|
236
238
|
}
|
|
237
|
-
|
|
238
|
-
if (
|
|
239
|
-
isOneOfVariant(market.amm.oracleSource, [
|
|
240
|
-
'pythPull',
|
|
241
|
-
'pyth1KPull',
|
|
242
|
-
'pyth1MPull',
|
|
243
|
-
'pythStableCoinPull',
|
|
244
|
-
])
|
|
245
|
-
) {
|
|
246
|
-
if (!correspondingConfigMarket.pythFeedId) {
|
|
247
|
-
errors.push(`perp market ${market.marketIndex} missing feed id`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
239
|
}
|
|
251
240
|
|
|
252
241
|
// Print all missing LUT addresses
|
|
@@ -290,6 +279,10 @@ describe('Verify Constants', function () {
|
|
|
290
279
|
spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
|
|
291
280
|
|
|
292
281
|
for (const market of spotMarkets) {
|
|
282
|
+
if (isPullOracleSource(market.oracleSource)) {
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
|
|
293
286
|
const correspondingConfigMarket = DevnetSpotMarkets.find(
|
|
294
287
|
(configMarket) => configMarket.marketIndex === market.marketIndex
|
|
295
288
|
);
|
|
@@ -341,6 +334,10 @@ describe('Verify Constants', function () {
|
|
|
341
334
|
perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
|
|
342
335
|
|
|
343
336
|
for (const market of perpMarkets) {
|
|
337
|
+
if (isPullOracleSource(market.amm.oracleSource)) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
|
|
344
341
|
const correspondingConfigMarket = DevnetPerpMarkets.find(
|
|
345
342
|
(configMarket) => configMarket.marketIndex === market.marketIndex
|
|
346
343
|
);
|
package/tests/decode/test.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { Connection, Keypair } from '@solana/web3.js';
|
|
|
4
4
|
import {
|
|
5
5
|
decodeUser,
|
|
6
6
|
Wallet,
|
|
7
|
-
DRIFT_PROGRAM_ID,
|
|
8
7
|
isSpotPositionAvailable,
|
|
9
8
|
isVariant,
|
|
10
9
|
Order,
|
|
@@ -22,7 +21,7 @@ describe('Custom user decode', () => {
|
|
|
22
21
|
const wallet = new Wallet(new Keypair());
|
|
23
22
|
// @ts-ignore
|
|
24
23
|
const provider = new AnchorProvider(connection, wallet);
|
|
25
|
-
const program = new Program(driftIDL as Idl,
|
|
24
|
+
const program = new Program(driftIDL as Idl, provider);
|
|
26
25
|
|
|
27
26
|
let totalAnchorSize = 0;
|
|
28
27
|
let totalCustomSize = 0;
|
|
@@ -52,7 +51,7 @@ function testUserAccountDecode(program: Program, buffer: Buffer, i: number) {
|
|
|
52
51
|
console.log(`Testing user account decode ${i}`);
|
|
53
52
|
|
|
54
53
|
const anchorStartTimestamp = Date.now();
|
|
55
|
-
const anchorUserAccount = program.coder.accounts.decode('
|
|
54
|
+
const anchorUserAccount = program.coder.accounts.decode('user', buffer);
|
|
56
55
|
const anchorEndTimestamp = Date.now();
|
|
57
56
|
const anchorTime = anchorEndTimestamp - anchorStartTimestamp;
|
|
58
57
|
|
|
@@ -189,7 +188,6 @@ function testPerpPosition(anchor: PerpPosition, custom: PerpPosition) {
|
|
|
189
188
|
assert(anchor.lpShares.eq(custom.lpShares));
|
|
190
189
|
assert(anchor.lastQuoteAssetAmountPerLp.eq(custom.lastQuoteAssetAmountPerLp));
|
|
191
190
|
assert(anchor.openOrders === custom.openOrders);
|
|
192
|
-
assert(anchor.perLpBase === custom.perLpBase);
|
|
193
191
|
assert(
|
|
194
192
|
anchor.isolatedPositionScaledBalance.eq(
|
|
195
193
|
custom.isolatedPositionScaledBalance
|
package/tests/dlob/helpers.ts
CHANGED
|
@@ -42,7 +42,6 @@ export const mockPerpPosition: PerpPosition = {
|
|
|
42
42
|
lpShares: new BN(0),
|
|
43
43
|
remainderBaseAssetAmount: 0,
|
|
44
44
|
lastQuoteAssetAmountPerLp: new BN(0),
|
|
45
|
-
perLpBase: 0,
|
|
46
45
|
maxMarginRatio: 1,
|
|
47
46
|
isolatedPositionScaledBalance: new BN(0),
|
|
48
47
|
positionFlag: 0,
|
|
@@ -76,7 +75,7 @@ export const mockAMM: AMM = {
|
|
|
76
75
|
lastOracleReservePriceSpreadPct: new BN(0),
|
|
77
76
|
lastOracleConfPct: new BN(0),
|
|
78
77
|
oracle: PublicKey.default,
|
|
79
|
-
oracleSource: OracleSource.
|
|
78
|
+
oracleSource: OracleSource.PYTH_LAZER,
|
|
80
79
|
fundingPeriod: new BN(0),
|
|
81
80
|
cumulativeFundingRateLong: new BN(0),
|
|
82
81
|
cumulativeFundingRateShort: new BN(0),
|
|
@@ -85,7 +84,7 @@ export const mockAMM: AMM = {
|
|
|
85
84
|
totalFee: new BN(0),
|
|
86
85
|
userLpShares: new BN(0),
|
|
87
86
|
baseAssetAmountWithUnsettledLp: new BN(0),
|
|
88
|
-
orderStepSize: new BN(
|
|
87
|
+
orderStepSize: new BN(1),
|
|
89
88
|
orderTickSize: new BN(1),
|
|
90
89
|
last24HAvgFundingRate: new BN(0),
|
|
91
90
|
lastFundingRateShort: new BN(0),
|
|
@@ -173,8 +172,6 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
173
172
|
numberOfUsers: 0,
|
|
174
173
|
marginRatioInitial: 2000,
|
|
175
174
|
marginRatioMaintenance: 1000,
|
|
176
|
-
highLeverageMarginRatioInitial: 0,
|
|
177
|
-
highLeverageMarginRatioMaintenance: 0,
|
|
178
175
|
nextFillRecordId: new BN(0),
|
|
179
176
|
pnlPool: {
|
|
180
177
|
scaledBalance: new BN(0),
|
|
@@ -228,8 +225,6 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
228
225
|
numberOfUsers: 0,
|
|
229
226
|
marginRatioInitial: 0,
|
|
230
227
|
marginRatioMaintenance: 0,
|
|
231
|
-
highLeverageMarginRatioInitial: 0,
|
|
232
|
-
highLeverageMarginRatioMaintenance: 0,
|
|
233
228
|
nextFillRecordId: new BN(0),
|
|
234
229
|
pnlPool: {
|
|
235
230
|
scaledBalance: new BN(0),
|
|
@@ -281,8 +276,6 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
281
276
|
numberOfUsers: 0,
|
|
282
277
|
marginRatioInitial: 0,
|
|
283
278
|
marginRatioMaintenance: 0,
|
|
284
|
-
highLeverageMarginRatioInitial: 0,
|
|
285
|
-
highLeverageMarginRatioMaintenance: 0,
|
|
286
279
|
nextFillRecordId: new BN(0),
|
|
287
280
|
pnlPool: {
|
|
288
281
|
scaledBalance: new BN(0),
|
|
@@ -371,7 +364,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
371
364
|
depositTokenTwap: new BN(0),
|
|
372
365
|
borrowTokenTwap: new BN(0),
|
|
373
366
|
utilizationTwap: new BN(0),
|
|
374
|
-
orderStepSize: new BN(
|
|
367
|
+
orderStepSize: new BN(1),
|
|
375
368
|
orderTickSize: new BN(0),
|
|
376
369
|
nextFillRecordId: new BN(0),
|
|
377
370
|
nextDepositRecordId: new BN(0),
|
|
@@ -384,7 +377,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
384
377
|
totalSwapFee: new BN(0),
|
|
385
378
|
flashLoanAmount: new BN(0),
|
|
386
379
|
flashLoanInitialTokenAmount: new BN(0),
|
|
387
|
-
oracleSource: OracleSource.
|
|
380
|
+
oracleSource: OracleSource.PYTH_LAZER,
|
|
388
381
|
historicalOracleData: {
|
|
389
382
|
lastOraclePrice: PRICE_PRECISION,
|
|
390
383
|
lastOracleConf: new BN(0),
|
|
@@ -463,7 +456,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
463
456
|
depositTokenTwap: new BN(0),
|
|
464
457
|
borrowTokenTwap: new BN(0),
|
|
465
458
|
utilizationTwap: new BN(0),
|
|
466
|
-
orderStepSize: new BN(
|
|
459
|
+
orderStepSize: new BN(1),
|
|
467
460
|
orderTickSize: new BN(0),
|
|
468
461
|
nextFillRecordId: new BN(0),
|
|
469
462
|
nextDepositRecordId: new BN(0),
|
|
@@ -476,7 +469,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
476
469
|
totalSwapFee: new BN(0),
|
|
477
470
|
flashLoanAmount: new BN(0),
|
|
478
471
|
flashLoanInitialTokenAmount: new BN(0),
|
|
479
|
-
oracleSource: OracleSource.
|
|
472
|
+
oracleSource: OracleSource.PYTH_LAZER,
|
|
480
473
|
historicalOracleData: {
|
|
481
474
|
lastOraclePrice: new BN(0),
|
|
482
475
|
lastOracleConf: new BN(0),
|
|
@@ -555,7 +548,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
555
548
|
depositTokenTwap: new BN(0),
|
|
556
549
|
borrowTokenTwap: new BN(0),
|
|
557
550
|
utilizationTwap: new BN(0),
|
|
558
|
-
orderStepSize: new BN(
|
|
551
|
+
orderStepSize: new BN(1),
|
|
559
552
|
orderTickSize: new BN(0),
|
|
560
553
|
nextFillRecordId: new BN(0),
|
|
561
554
|
nextDepositRecordId: new BN(0),
|
|
@@ -568,7 +561,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
568
561
|
totalSwapFee: new BN(0),
|
|
569
562
|
flashLoanAmount: new BN(0),
|
|
570
563
|
flashLoanInitialTokenAmount: new BN(0),
|
|
571
|
-
oracleSource: OracleSource.
|
|
564
|
+
oracleSource: OracleSource.PYTH_LAZER,
|
|
572
565
|
historicalOracleData: {
|
|
573
566
|
lastOraclePrice: new BN(0),
|
|
574
567
|
lastOracleConf: new BN(0),
|
package/tests/user/helpers.ts
CHANGED
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
PositionDirection,
|
|
18
18
|
OrderTriggerCondition,
|
|
19
19
|
ZERO,
|
|
20
|
-
MarginMode,
|
|
21
20
|
MMOraclePriceData,
|
|
22
21
|
} from '../../src';
|
|
23
22
|
|
|
@@ -96,7 +95,6 @@ export const mockUserAccount: UserAccount = {
|
|
|
96
95
|
openAuctions: 0,
|
|
97
96
|
hasOpenAuction: false,
|
|
98
97
|
lastFuelBonusUpdateTs: 0,
|
|
99
|
-
marginMode: MarginMode.DEFAULT,
|
|
100
98
|
poolId: 0,
|
|
101
99
|
};
|
|
102
100
|
|