@drift-labs/sdk-browser 2.163.0-beta.11 → 2.163.0-beta.13
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/VERSION +1 -1
- package/bun.lock +26 -13
- package/lib/browser/accounts/fetch.d.ts +9 -0
- package/lib/browser/accounts/fetch.js +14 -1
- package/lib/browser/addresses/pda.d.ts +1 -1
- package/lib/browser/addresses/pda.js +2 -2
- package/lib/browser/adminClient.d.ts +1 -1
- package/lib/browser/adminClient.js +2 -2
- package/lib/browser/bankrun/bankrunConnection.d.ts +1 -1
- package/lib/browser/bankrun/bankrunConnection.js +1 -1
- package/lib/browser/clock/clockSubscriber.js +1 -1
- package/lib/browser/config.d.ts +1 -1
- package/lib/browser/constants/numericConstants.d.ts +1 -1
- package/lib/browser/constants/numericConstants.js +1 -1
- package/lib/browser/constants/perpMarkets.js +1 -1
- package/lib/browser/constants/spotMarkets.d.ts +1 -1
- package/lib/browser/constants/spotMarkets.js +4 -3
- package/lib/browser/core/DriftCore.d.ts +224 -0
- package/lib/browser/core/DriftCore.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 +1 -1
- package/lib/browser/decode/customCoder.js +1 -1
- package/lib/browser/decode/user.js +1 -1
- package/lib/browser/dlob/DLOB.d.ts +1 -1
- package/lib/browser/dlob/DLOB.js +1 -1
- package/lib/browser/dlob/DLOBNode.d.ts +1 -1
- package/lib/browser/dlob/DLOBNode.js +1 -1
- package/lib/browser/dlob/DLOBSubscriber.d.ts +1 -1
- package/lib/browser/dlob/NodeList.d.ts +1 -1
- package/lib/browser/dlob/orderBookLevels.d.ts +1 -1
- package/lib/browser/dlob/orderBookLevels.js +1 -1
- package/lib/browser/driftClient.d.ts +17 -24
- package/lib/browser/driftClient.js +192 -291
- package/lib/browser/driftClientConfig.d.ts +1 -1
- package/lib/browser/events/eventSubscriber.d.ts +1 -1
- package/lib/browser/events/fetchLogs.d.ts +1 -1
- package/lib/browser/events/parse.d.ts +1 -1
- package/lib/browser/factory/bigNum.d.ts +1 -1
- package/lib/browser/factory/bigNum.js +1 -1
- package/lib/browser/factory/oracleClient.js +1 -1
- package/lib/browser/index.d.ts +2 -1
- package/lib/browser/index.js +2 -1
- package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +1 -1
- 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/jupiter/jupiterClient.d.ts +1 -1
- package/lib/browser/marginCalculation.d.ts +1 -1
- package/lib/browser/marinade/index.d.ts +1 -1
- package/lib/browser/marinade/index.js +2 -2
- package/lib/browser/math/amm.d.ts +1 -1
- package/lib/browser/math/amm.js +1 -1
- package/lib/browser/math/auction.d.ts +1 -1
- package/lib/browser/math/auction.js +1 -1
- package/lib/browser/math/conversion.d.ts +1 -1
- package/lib/browser/math/conversion.js +1 -1
- package/lib/browser/math/exchangeStatus.js +1 -1
- package/lib/browser/math/fuel.d.ts +1 -1
- package/lib/browser/math/fuel.js +1 -1
- package/lib/browser/math/funding.d.ts +1 -1
- package/lib/browser/math/funding.js +1 -1
- package/lib/browser/math/insurance.d.ts +1 -1
- package/lib/browser/math/insurance.js +1 -1
- package/lib/browser/math/liquidation.d.ts +1 -1
- package/lib/browser/math/liquidation.js +1 -1
- package/lib/browser/math/margin.d.ts +1 -1
- package/lib/browser/math/margin.js +1 -1
- package/lib/browser/math/market.d.ts +1 -1
- package/lib/browser/math/market.js +1 -1
- package/lib/browser/math/oracles.d.ts +1 -1
- package/lib/browser/math/oracles.js +1 -1
- package/lib/browser/math/orders.d.ts +1 -1
- package/lib/browser/math/orders.js +1 -1
- package/lib/browser/math/position.d.ts +1 -1
- package/lib/browser/math/position.js +1 -1
- package/lib/browser/math/protectedMakerParams.js +1 -1
- package/lib/browser/math/repeg.d.ts +1 -1
- package/lib/browser/math/repeg.js +1 -1
- package/lib/browser/math/spotBalance.d.ts +1 -1
- package/lib/browser/math/spotBalance.js +1 -1
- package/lib/browser/math/spotMarket.d.ts +1 -1
- package/lib/browser/math/spotMarket.js +1 -1
- package/lib/browser/math/spotPosition.d.ts +1 -1
- package/lib/browser/math/spotPosition.js +1 -1
- package/lib/browser/math/state.d.ts +1 -1
- package/lib/browser/math/state.js +1 -1
- package/lib/browser/math/superStake.d.ts +1 -1
- package/lib/browser/math/superStake.js +1 -1
- package/lib/browser/math/trade.d.ts +1 -1
- package/lib/browser/math/trade.js +1 -1
- package/lib/browser/math/utils.d.ts +1 -1
- package/lib/browser/math/utils.js +1 -1
- 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/pythClient.d.ts +1 -1
- package/lib/browser/oracles/pythClient.js +1 -1
- package/lib/browser/oracles/pythLazerClient.d.ts +1 -1
- package/lib/browser/oracles/pythLazerClient.js +1 -1
- package/lib/browser/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/browser/oracles/strictOraclePrice.d.ts +1 -1
- package/lib/browser/oracles/strictOraclePrice.js +1 -1
- package/lib/browser/oracles/types.d.ts +1 -1
- package/lib/browser/oracles/utils.d.ts +1 -1
- package/lib/browser/orderParams.d.ts +1 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.js +1 -1
- package/lib/browser/phoenix/phoenixSubscriber.d.ts +1 -1
- package/lib/browser/phoenix/phoenixSubscriber.js +1 -1
- package/lib/browser/pyth/types.d.ts +1 -1
- package/lib/browser/serum/serumSubscriber.d.ts +1 -1
- package/lib/browser/serum/serumSubscriber.js +1 -1
- package/lib/browser/slot/SlothashSubscriber.js +6 -3
- package/lib/browser/swap/UnifiedSwapClient.d.ts +1 -1
- package/lib/browser/titan/titanClient.d.ts +1 -1
- package/lib/browser/tokenFaucet.d.ts +3 -3
- package/lib/browser/tokenFaucet.js +4 -4
- package/lib/browser/types.d.ts +1 -1
- package/lib/browser/user.d.ts +1 -1
- package/lib/browser/user.js +1 -1
- package/lib/browser/userMap/referrerMap.js +7 -4
- package/lib/browser/userStats.d.ts +1 -1
- package/lib/browser/userStats.js +1 -1
- package/lib/node/accounts/fetch.d.ts +9 -0
- package/lib/node/accounts/fetch.d.ts.map +1 -1
- package/lib/node/accounts/fetch.js +14 -1
- package/lib/node/addresses/pda.d.ts +1 -1
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +2 -2
- package/lib/node/adminClient.d.ts +1 -1
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +2 -2
- package/lib/node/bankrun/bankrunConnection.d.ts +1 -1
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.js +1 -1
- package/lib/node/clock/clockSubscriber.js +1 -1
- package/lib/node/config.d.ts +1 -1
- package/lib/node/config.d.ts.map +1 -1
- 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 +1 -1
- package/lib/node/constants/perpMarkets.js +1 -1
- package/lib/node/constants/spotMarkets.d.ts +1 -1
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +4 -3
- package/lib/node/core/DriftCore.d.ts +225 -0
- package/lib/node/core/DriftCore.d.ts.map +1 -0
- package/lib/node/core/DriftCore.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 +1 -1
- package/lib/node/decode/customCoder.d.ts.map +1 -1
- package/lib/node/decode/customCoder.js +1 -1
- package/lib/node/decode/user.js +1 -1
- package/lib/node/dlob/DLOB.d.ts +1 -1
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +1 -1
- package/lib/node/dlob/DLOBNode.d.ts +1 -1
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +1 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts +1 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.d.ts +1 -1
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.d.ts +1 -1
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +1 -1
- package/lib/node/driftClient.d.ts +17 -24
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +192 -291
- package/lib/node/driftClientConfig.d.ts +1 -1
- package/lib/node/driftClientConfig.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.d.ts +1 -1
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.d.ts +1 -1
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/parse.d.ts +1 -1
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/factory/bigNum.d.ts +1 -1
- package/lib/node/factory/bigNum.d.ts.map +1 -1
- package/lib/node/factory/bigNum.js +1 -1
- package/lib/node/factory/oracleClient.js +1 -1
- package/lib/node/index.d.ts +2 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +2 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +1 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -1
- package/lib/node/isomorphic/anchor.browser.d.ts +25 -0
- package/lib/node/isomorphic/anchor.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.browser.js +60 -0
- package/lib/node/isomorphic/anchor.d.ts +25 -0
- package/lib/node/isomorphic/anchor.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.js +60 -0
- package/lib/node/isomorphic/anchor.node.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.browser.d.ts +13 -0
- package/lib/node/isomorphic/anchor29.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.browser.js +48 -0
- package/lib/node/isomorphic/anchor29.d.ts +13 -0
- package/lib/node/isomorphic/anchor29.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.js +48 -0
- package/lib/node/isomorphic/anchor29.node.d.ts.map +1 -0
- package/lib/node/jupiter/jupiterClient.d.ts +1 -1
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/marginCalculation.d.ts +1 -1
- package/lib/node/marginCalculation.d.ts.map +1 -1
- 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 +1 -1
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +1 -1
- package/lib/node/math/auction.d.ts +1 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +1 -1
- package/lib/node/math/conversion.d.ts +1 -1
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/conversion.js +1 -1
- package/lib/node/math/exchangeStatus.js +1 -1
- package/lib/node/math/fuel.d.ts +1 -1
- package/lib/node/math/fuel.d.ts.map +1 -1
- package/lib/node/math/fuel.js +1 -1
- package/lib/node/math/funding.d.ts +1 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +1 -1
- package/lib/node/math/insurance.d.ts +1 -1
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +1 -1
- package/lib/node/math/liquidation.d.ts +1 -1
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/liquidation.js +1 -1
- package/lib/node/math/margin.d.ts +1 -1
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +1 -1
- package/lib/node/math/market.d.ts +1 -1
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +1 -1
- package/lib/node/math/oracles.d.ts +1 -1
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +1 -1
- package/lib/node/math/orders.d.ts +1 -1
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +1 -1
- package/lib/node/math/position.d.ts +1 -1
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +1 -1
- package/lib/node/math/protectedMakerParams.js +1 -1
- package/lib/node/math/repeg.d.ts +1 -1
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/repeg.js +1 -1
- package/lib/node/math/spotBalance.d.ts +1 -1
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +1 -1
- package/lib/node/math/spotMarket.d.ts +1 -1
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +1 -1
- package/lib/node/math/spotPosition.d.ts +1 -1
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/spotPosition.js +1 -1
- package/lib/node/math/state.d.ts +1 -1
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/state.js +1 -1
- package/lib/node/math/superStake.d.ts +1 -1
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +1 -1
- package/lib/node/math/trade.d.ts +1 -1
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +1 -1
- package/lib/node/math/utils.d.ts +1 -1
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/math/utils.js +1 -1
- 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/pythClient.d.ts +1 -1
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.js +1 -1
- package/lib/node/oracles/pythLazerClient.d.ts +1 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +1 -1
- package/lib/node/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/node/oracles/strictOraclePrice.d.ts +1 -1
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/strictOraclePrice.js +1 -1
- package/lib/node/oracles/types.d.ts +1 -1
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +1 -1
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/orderParams.d.ts +1 -1
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +1 -1
- package/lib/node/phoenix/phoenixSubscriber.d.ts +1 -1
- package/lib/node/phoenix/phoenixSubscriber.d.ts.map +1 -1
- package/lib/node/phoenix/phoenixSubscriber.js +1 -1
- package/lib/node/pyth/types.d.ts +1 -1
- package/lib/node/pyth/types.d.ts.map +1 -1
- package/lib/node/serum/serumSubscriber.d.ts +1 -1
- package/lib/node/serum/serumSubscriber.d.ts.map +1 -1
- package/lib/node/serum/serumSubscriber.js +1 -1
- package/lib/node/slot/SlothashSubscriber.js +6 -3
- package/lib/node/swap/UnifiedSwapClient.d.ts +1 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/titan/titanClient.d.ts +1 -1
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/tokenFaucet.d.ts +3 -3
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +4 -4
- package/lib/node/types.d.ts +1 -1
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts +1 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +1 -1
- package/lib/node/userMap/referrerMap.js +7 -4
- package/lib/node/userStats.d.ts +1 -1
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +1 -1
- package/package.json +4 -2
- package/scripts/postbuild.js +1 -1
- package/src/accounts/fetch.ts +27 -0
- package/src/accounts/webSocketAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketAccountSubscriberV2.ts +1 -1
- package/src/accounts/webSocketProgramAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +1 -1
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +1 -1
- package/src/addresses/pda.ts +2 -2
- package/src/adminClient.ts +2 -2
- package/src/bankrun/bankrunConnection.ts +1 -1
- package/src/clock/clockSubscriber.ts +1 -1
- package/src/config.ts +1 -1
- package/src/constants/numericConstants.ts +1 -1
- package/src/constants/perpMarkets.ts +1 -1
- package/src/constants/spotMarkets.ts +4 -3
- package/src/core/DriftCore.ts +326 -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 +1 -1
- package/src/decode/user.ts +1 -1
- package/src/dlob/DLOB.ts +1 -1
- package/src/dlob/DLOBNode.ts +1 -1
- package/src/dlob/DLOBSubscriber.ts +1 -1
- package/src/dlob/NodeList.ts +1 -1
- package/src/dlob/orderBookLevels.ts +1 -1
- package/src/driftClient.ts +207 -402
- package/src/driftClientConfig.ts +1 -1
- package/src/events/eventSubscriber.ts +1 -1
- package/src/events/fetchLogs.ts +1 -1
- package/src/events/parse.ts +1 -1
- package/src/factory/bigNum.ts +1 -1
- package/src/factory/oracleClient.ts +1 -1
- package/src/index.ts +2 -1
- package/src/indicative-quotes/indicativeQuotesSender.ts +1 -1
- 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/jupiter/jupiterClient.ts +1 -1
- package/src/marginCalculation.ts +1 -1
- package/src/marinade/index.ts +1 -1
- package/src/math/amm.ts +1 -1
- package/src/math/auction.ts +1 -1
- package/src/math/conversion.ts +1 -1
- package/src/math/exchangeStatus.ts +1 -1
- package/src/math/fuel.ts +1 -1
- package/src/math/funding.ts +1 -1
- package/src/math/insurance.ts +1 -1
- package/src/math/liquidation.ts +1 -1
- package/src/math/margin.ts +1 -1
- package/src/math/market.ts +1 -1
- package/src/math/oracles.ts +1 -1
- package/src/math/orders.ts +1 -1
- package/src/math/position.ts +1 -1
- package/src/math/protectedMakerParams.ts +1 -1
- package/src/math/repeg.ts +1 -1
- package/src/math/spotBalance.ts +1 -1
- package/src/math/spotMarket.ts +1 -1
- package/src/math/spotPosition.ts +1 -1
- package/src/math/state.ts +1 -1
- package/src/math/superStake.ts +1 -1
- package/src/math/trade.ts +1 -1
- package/src/math/utils.ts +1 -1
- package/src/memcmp.ts +1 -1
- package/src/openbook/openbookV2Subscriber.ts +7 -1
- package/src/oracles/pythClient.ts +1 -1
- package/src/oracles/pythLazerClient.ts +1 -1
- package/src/oracles/quoteAssetOracleClient.ts +1 -1
- package/src/oracles/strictOraclePrice.ts +1 -1
- package/src/oracles/types.ts +1 -1
- package/src/oracles/utils.ts +1 -1
- package/src/orderParams.ts +1 -1
- package/src/orderSubscriber/OrderSubscriber.ts +1 -1
- package/src/phoenix/phoenixSubscriber.ts +1 -1
- package/src/pyth/types.ts +1 -1
- package/src/serum/serumSubscriber.ts +1 -1
- package/src/slot/SlothashSubscriber.ts +2 -2
- package/src/swap/UnifiedSwapClient.ts +1 -1
- package/src/titan/titanClient.ts +1 -1
- package/src/tokenFaucet.ts +3 -3
- package/src/types.ts +1 -1
- package/src/user.ts +1 -1
- package/src/userMap/referrerMap.ts +1 -1
- package/src/userMap/userMap.ts +1 -1
- package/src/userStats.ts +1 -1
- 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 +29 -0
- package/tests/DriftCore/perp_orders.test.ts +205 -0
- package/tests/DriftCore/remainingAccounts.test.ts +70 -0
- package/tests/DriftCore/settlement_liquidation.test.ts +69 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.163.0-beta.
|
|
1
|
+
2.163.0-beta.13
|
package/bun.lock
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"lockfileVersion": 1,
|
|
3
|
+
"configVersion": 0,
|
|
3
4
|
"workspaces": {
|
|
4
5
|
"": {
|
|
5
6
|
"name": "@drift-labs/sdk",
|
|
6
7
|
"dependencies": {
|
|
7
|
-
"@
|
|
8
|
+
"@anchor-lang/core": "1.0.1",
|
|
9
|
+
"@coral-xyz/anchor": "npm:@anchor-lang/core@1.0.1",
|
|
8
10
|
"@coral-xyz/anchor-29": "npm:@coral-xyz/anchor@0.29.0",
|
|
9
11
|
"@ellipsis-labs/phoenix-sdk": "1.4.5",
|
|
10
12
|
"@msgpack/msgpack": "^3.1.2",
|
|
@@ -65,17 +67,32 @@
|
|
|
65
67
|
},
|
|
66
68
|
},
|
|
67
69
|
"overrides": {
|
|
68
|
-
"debug": "<4.4.2",
|
|
69
|
-
"supports-color": "7.2.0",
|
|
70
70
|
"ansi-regex": "5.0.1",
|
|
71
|
-
"color-convert": "<3.1.1",
|
|
72
71
|
"ansi-styles": "4.3.0",
|
|
73
|
-
"
|
|
72
|
+
"backslash": "<0.2.1",
|
|
74
73
|
"chalk": "4.1.2",
|
|
75
|
-
"
|
|
74
|
+
"chalk-template": "<1.1.1",
|
|
75
|
+
"color-convert": "<3.1.1",
|
|
76
76
|
"color-name": "<2.0.1",
|
|
77
|
+
"color-string": "<2.1.1",
|
|
78
|
+
"debug": "<4.4.2",
|
|
79
|
+
"error-ex": "<1.3.3",
|
|
80
|
+
"has-ansi": "<6.0.1",
|
|
81
|
+
"is-arrayish": "<0.3.3",
|
|
82
|
+
"simple-swizzle": "<0.2.3",
|
|
83
|
+
"slice-ansi": "3.0.0",
|
|
84
|
+
"strip-ansi": "6.0.1",
|
|
85
|
+
"supports-color": "7.2.0",
|
|
86
|
+
"supports-hyperlinks": "<4.1.1",
|
|
87
|
+
"wrap-ansi": "7.0.0",
|
|
77
88
|
},
|
|
78
89
|
"packages": {
|
|
90
|
+
"@anchor-lang/borsh": ["@anchor-lang/borsh@1.0.1", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.69.0" } }, "sha512-YnWRh76/3DqF0TSzRpCojRelya9OEQ23LpJQYqkAh+L1xiPcaUaYm1C9Q+W8t363aL45xNJOXMGqb0QPx6kgPw=="],
|
|
91
|
+
|
|
92
|
+
"@anchor-lang/core": ["@anchor-lang/core@1.0.1", "", { "dependencies": { "@anchor-lang/borsh": "^1.0.1", "@anchor-lang/errors": "^1.0.1", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.69.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-SzZRCod5esNCFmOSwwpKp0Qx2tUiheEIR099LC56OED3BP35hLmsr6OX1xVgD2F/itR5j82xciDjFhbgHCaz2w=="],
|
|
93
|
+
|
|
94
|
+
"@anchor-lang/errors": ["@anchor-lang/errors@1.0.1", "", {}, "sha512-1BpLZbSGT8q1BsGlocAX+/hHdh6zAU4VTCEXkisMjxOy5iaMSCOvQuEM6DO1t73463XUXykxdyzuwQ4pAoYfcw=="],
|
|
95
|
+
|
|
79
96
|
"@babel/code-frame": ["@babel/code-frame@7.26.2", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.25.9", "js-tokens": "^4.0.0", "picocolors": "^1.0.0" } }, "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ=="],
|
|
80
97
|
|
|
81
98
|
"@babel/helper-string-parser": ["@babel/helper-string-parser@7.27.1", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
|
|
@@ -90,12 +107,10 @@
|
|
|
90
107
|
|
|
91
108
|
"@bufbuild/protobuf": ["@bufbuild/protobuf@2.10.2", "", {}, "sha512-uFsRXwIGyu+r6AMdz+XijIIZJYpoWeYzILt5yZ2d3mCjQrWUTVpVD9WL/jZAbvp+Ed04rOhrsk7FiTcEDseB5A=="],
|
|
92
109
|
|
|
93
|
-
"@coral-xyz/anchor": ["@
|
|
110
|
+
"@coral-xyz/anchor": ["@anchor-lang/core@1.0.1", "", { "dependencies": { "@anchor-lang/borsh": "^1.0.1", "@anchor-lang/errors": "^1.0.1", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.69.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-SzZRCod5esNCFmOSwwpKp0Qx2tUiheEIR099LC56OED3BP35hLmsr6OX1xVgD2F/itR5j82xciDjFhbgHCaz2w=="],
|
|
94
111
|
|
|
95
112
|
"@coral-xyz/anchor-29": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="],
|
|
96
113
|
|
|
97
|
-
"@coral-xyz/anchor-errors": ["@coral-xyz/anchor-errors@0.31.1", "", {}, "sha512-NhNEku4F3zzUSBtrYz84FzYWm48+9OvmT1Hhnwr6GnPQry2dsEqH/ti/7ASjjpoFTWRnPXrjAIT1qM6Isop+LQ=="],
|
|
98
|
-
|
|
99
114
|
"@coral-xyz/borsh": ["@coral-xyz/borsh@0.31.1", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.69.0" } }, "sha512-9N8AU9F0ubriKfNE3g1WF0/4dtlGXoBN/hd1PvbNBamBNwRgHxH4P+o3Zt7rSEloW1HUs6LfZEchlx9fW7POYw=="],
|
|
100
115
|
|
|
101
116
|
"@cspotcode/source-map-support": ["@cspotcode/source-map-support@0.8.1", "", { "dependencies": { "@jridgewell/trace-mapping": "0.3.9" } }, "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw=="],
|
|
@@ -1280,10 +1295,10 @@
|
|
|
1280
1295
|
|
|
1281
1296
|
"@babel/types/@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.27.1", "", {}, "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow=="],
|
|
1282
1297
|
|
|
1283
|
-
"@coral-xyz/anchor-29/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="],
|
|
1284
|
-
|
|
1285
1298
|
"@coral-xyz/anchor-29/bn.js": ["bn.js@5.2.1", "", {}, "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ=="],
|
|
1286
1299
|
|
|
1300
|
+
"@coral-xyz/borsh/bn.js": ["bn.js@5.2.1", "", {}, "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ=="],
|
|
1301
|
+
|
|
1287
1302
|
"@ellipsis-labs/phoenix-sdk/@solana/spl-token": ["@solana/spl-token@0.3.7", "", { "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", "buffer": "^6.0.3" }, "peerDependencies": { "@solana/web3.js": "^1.47.4" } }, "sha512-bKGxWTtIw6VDdCBngjtsGlKGLSmiu/8ghSt/IOYJV24BsymRbgq7r12GToeetpxmPaZYLddKwAz7+EwprLfkfg=="],
|
|
1288
1303
|
|
|
1289
1304
|
"@ellipsis-labs/phoenix-sdk/@types/node": ["@types/node@18.19.78", "", { "dependencies": { "undici-types": "~5.26.4" } }, "sha512-m1ilZCTwKLkk9rruBJXFeYN0Bc5SbjirwYX/Td3MqPfioYbgun3IvK/m8dQxMCnrPGZPg1kvXjp3SIekCN/ynw=="],
|
|
@@ -1576,8 +1591,6 @@
|
|
|
1576
1591
|
|
|
1577
1592
|
"@metaplex-foundation/solita/@metaplex-foundation/beet/bn.js": ["bn.js@5.2.1", "", {}, "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ=="],
|
|
1578
1593
|
|
|
1579
|
-
"@openbook-dex/openbook-v2/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="],
|
|
1580
|
-
|
|
1581
1594
|
"@openbook-dex/openbook-v2/@coral-xyz/anchor/bn.js": ["bn.js@5.2.1", "", {}, "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ=="],
|
|
1582
1595
|
|
|
1583
1596
|
"@solana/accounts/@solana/addresses/@solana/nominal-types": ["@solana/nominal-types@2.3.0", "", { "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-uKlMnlP4PWW5UTXlhKM8lcgIaNj8dvd8xO4Y9l+FVvh9RvW2TO0GwUO6JCo7JBzCB0PSqRJdWWaQ8pu1Ti/OkA=="],
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
2
4
|
import { RevenueShareAccount, RevenueShareEscrowAccount, UserAccount, UserStatsAccount } from '../types';
|
|
3
5
|
import { DriftProgram } from '../config';
|
|
@@ -6,3 +8,10 @@ export declare function fetchUserAccountsUsingKeys(connection: Connection, progr
|
|
|
6
8
|
export declare function fetchUserStatsAccount(connection: Connection, program: DriftProgram, authority: PublicKey): Promise<UserStatsAccount | undefined>;
|
|
7
9
|
export declare function fetchRevenueShareAccount(connection: Connection, program: DriftProgram, authority: PublicKey): Promise<RevenueShareAccount | null>;
|
|
8
10
|
export declare function fetchRevenueShareEscrowAccount(connection: Connection, program: DriftProgram, authority: PublicKey): Promise<RevenueShareEscrowAccount | null>;
|
|
11
|
+
export type FetchAccountOptions = {
|
|
12
|
+
commitment?: Parameters<Connection['getAccountInfo']>[1];
|
|
13
|
+
};
|
|
14
|
+
/** Raw account data buffer (no Anchor decode). */
|
|
15
|
+
export declare function fetchAccount(connection: Connection, publicKey: PublicKey, opts?: FetchAccountOptions): Promise<Buffer | null>;
|
|
16
|
+
/** Batch variant of {@link fetchAccount}. */
|
|
17
|
+
export declare function fetchAccounts(connection: Connection, publicKeys: PublicKey[], opts?: FetchAccountOptions): Promise<(Buffer | null)[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchRevenueShareEscrowAccount = exports.fetchRevenueShareAccount = exports.fetchUserStatsAccount = exports.fetchUserAccountsUsingKeys = exports.fetchUserAccounts = void 0;
|
|
3
|
+
exports.fetchAccounts = exports.fetchAccount = exports.fetchRevenueShareEscrowAccount = exports.fetchRevenueShareAccount = exports.fetchUserStatsAccount = exports.fetchUserAccountsUsingKeys = exports.fetchUserAccounts = void 0;
|
|
4
4
|
const pda_1 = require("../addresses/pda");
|
|
5
5
|
async function fetchUserAccounts(connection, program, authority, limit = 8) {
|
|
6
6
|
const userAccountPublicKeys = new Array();
|
|
@@ -45,3 +45,16 @@ async function fetchRevenueShareEscrowAccount(connection, program, authority) {
|
|
|
45
45
|
return escrowAccount;
|
|
46
46
|
}
|
|
47
47
|
exports.fetchRevenueShareEscrowAccount = fetchRevenueShareEscrowAccount;
|
|
48
|
+
/** Raw account data buffer (no Anchor decode). */
|
|
49
|
+
async function fetchAccount(connection, publicKey, opts) {
|
|
50
|
+
var _a;
|
|
51
|
+
const info = await connection.getAccountInfo(publicKey, opts === null || opts === void 0 ? void 0 : opts.commitment);
|
|
52
|
+
return (_a = info === null || info === void 0 ? void 0 : info.data) !== null && _a !== void 0 ? _a : null;
|
|
53
|
+
}
|
|
54
|
+
exports.fetchAccount = fetchAccount;
|
|
55
|
+
/** Batch variant of {@link fetchAccount}. */
|
|
56
|
+
async function fetchAccounts(connection, publicKeys, opts) {
|
|
57
|
+
const infos = await connection.getMultipleAccountsInfo(publicKeys, opts === null || opts === void 0 ? void 0 : opts.commitment);
|
|
58
|
+
return infos.map((info) => { var _a; return (_a = info === null || info === void 0 ? void 0 : info.data) !== null && _a !== void 0 ? _a : null; });
|
|
59
|
+
}
|
|
60
|
+
exports.fetchAccounts = fetchAccounts;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* All functions are pure (no RPC calls).
|
|
7
7
|
*/
|
|
8
8
|
import { PublicKey } from '@solana/web3.js';
|
|
9
|
-
import { BN } from '
|
|
9
|
+
import { BN } from '../isomorphic/anchor';
|
|
10
10
|
import { SpotMarketAccount } from '../types';
|
|
11
11
|
export declare function getDriftStateAccountPublicKeyAndNonce(programId: PublicKey): Promise<[PublicKey, number]>;
|
|
12
12
|
export declare function getDriftStateAccountPublicKey(programId: PublicKey): Promise<PublicKey>;
|
|
@@ -31,8 +31,8 @@ exports.getLpPoolTokenTokenAccountPublicKey = exports.getConstituentCorrelations
|
|
|
31
31
|
* All functions are pure (no RPC calls).
|
|
32
32
|
*/
|
|
33
33
|
const web3_js_1 = require("@solana/web3.js");
|
|
34
|
-
const anchor = __importStar(require("
|
|
35
|
-
const anchor_1 = require("
|
|
34
|
+
const anchor = __importStar(require("../isomorphic/anchor"));
|
|
35
|
+
const anchor_1 = require("../isomorphic/anchor");
|
|
36
36
|
const spl_token_1 = require("@solana/spl-token");
|
|
37
37
|
const types_1 = require("../types");
|
|
38
38
|
async function getDriftStateAccountPublicKeyAndNonce(programId) {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { AddressLookupTableAccount, Keypair, PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
|
|
11
11
|
import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus, IfRebalanceConfigParams, TxParams, AddAmmConstituentMappingDatum, SwapReduceOnly, InitializeConstituentParams, ConstituentStatus, LPPoolAccount, TransferFeeAndPnlPoolDirection } from './types';
|
|
12
|
-
import { BN } from '
|
|
12
|
+
import { BN } from './isomorphic/anchor';
|
|
13
13
|
import { DriftClient } from './driftClient';
|
|
14
14
|
import { JupiterClient, QuoteResponse } from './jupiter/jupiterClient';
|
|
15
15
|
import { SwapMode } from './swap/UnifiedSwapClient';
|
|
@@ -35,8 +35,8 @@ exports.AdminClient = void 0;
|
|
|
35
35
|
const web3_js_1 = require("@solana/web3.js");
|
|
36
36
|
const types_1 = require("./types");
|
|
37
37
|
const userName_1 = require("./userName");
|
|
38
|
-
const anchor_1 = require("
|
|
39
|
-
const anchor = __importStar(require("
|
|
38
|
+
const anchor_1 = require("./isomorphic/anchor");
|
|
39
|
+
const anchor = __importStar(require("./isomorphic/anchor"));
|
|
40
40
|
const pda_1 = require("./addresses/pda");
|
|
41
41
|
const utils_1 = require("./math/utils");
|
|
42
42
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { AccountInfo, Keypair, PublicKey, Transaction, RpcResponseAndContext, Commitment, TransactionSignature, SignatureStatusConfig, SignatureStatus, GetVersionedTransactionConfig, GetTransactionConfig, VersionedTransaction, SimulateTransactionConfig, SimulatedTransactionResponse, TransactionError, SignatureResultCallback, Connection as SolanaConnection, Blockhash, LogsFilter, LogsCallback, AccountChangeCallback, AddressLookupTableAccount } from '@solana/web3.js';
|
|
5
5
|
import { ProgramTestContext, BanksClient } from 'solana-bankrun';
|
|
6
6
|
import { BankrunProvider } from 'anchor-bankrun';
|
|
7
|
-
import { BN, Wallet } from '
|
|
7
|
+
import { BN, Wallet } from '../isomorphic/anchor';
|
|
8
8
|
import { Account } from '@solana/spl-token';
|
|
9
9
|
export type ClientSubscriptionId = number;
|
|
10
10
|
export type Connection = SolanaConnection | BankrunConnection;
|
|
@@ -8,7 +8,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
8
8
|
const solana_bankrun_1 = require("solana-bankrun");
|
|
9
9
|
const anchor_bankrun_1 = require("anchor-bankrun");
|
|
10
10
|
const bs58_1 = __importDefault(require("bs58"));
|
|
11
|
-
const anchor_1 = require("
|
|
11
|
+
const anchor_1 = require("../isomorphic/anchor");
|
|
12
12
|
const spl_token_1 = require("@solana/spl-token");
|
|
13
13
|
const utils_1 = require("../tx/utils");
|
|
14
14
|
class BankrunContextWrapper {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ClockSubscriber = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const events_1 = require("events");
|
|
6
|
-
const anchor_1 = require("
|
|
6
|
+
const anchor_1 = require("../isomorphic/anchor");
|
|
7
7
|
class ClockSubscriber {
|
|
8
8
|
get latestSlot() {
|
|
9
9
|
return this._latestSlot;
|
package/lib/browser/config.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { PerpMarketAccount, SpotMarketAccount } from './types';
|
|
|
3
3
|
import { PerpMarketConfig } from './constants/perpMarkets';
|
|
4
4
|
import { SpotMarketConfig } from './constants/spotMarkets';
|
|
5
5
|
import { OracleInfo } from './oracles/types';
|
|
6
|
-
import { Program } from '
|
|
6
|
+
import { Program } from './isomorphic/anchor';
|
|
7
7
|
import { Drift } from './idl/drift';
|
|
8
8
|
export type DriftProgram = Program<Drift>;
|
|
9
9
|
type DriftConfig = {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MARGIN_PRECISION = exports.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO = exports.PRICE_TO_QUOTE_PRECISION = exports.PRICE_DIV_PEG = exports.AMM_TO_QUOTE_PRECISION_RATIO = exports.BASE_PRECISION_EXP = exports.BASE_PRECISION = exports.AMM_RESERVE_PRECISION = exports.PEG_PRECISION = exports.FUNDING_RATE_BUFFER_PRECISION = exports.FUNDING_RATE_PRECISION = exports.PRICE_PRECISION = exports.QUOTE_PRECISION = exports.LIQUIDATION_FEE_PRECISION = exports.SPOT_MARKET_IMF_PRECISION = exports.SPOT_MARKET_IMF_PRECISION_EXP = exports.SPOT_MARKET_BALANCE_PRECISION = exports.SPOT_MARKET_BALANCE_PRECISION_EXP = exports.SPOT_MARKET_WEIGHT_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION_EXP = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION_EXP = exports.SPOT_MARKET_RATE_PRECISION = exports.SPOT_MARKET_RATE_PRECISION_EXP = exports.AMM_RESERVE_PRECISION_EXP = exports.PEG_PRECISION_EXP = exports.FUNDING_RATE_PRECISION_EXP = exports.PRICE_PRECISION_EXP = exports.FUNDING_RATE_BUFFER_PRECISION_EXP = exports.QUOTE_PRECISION_EXP = exports.CONCENTRATION_PRECISION = exports.PERCENTAGE_PRECISION = exports.PERCENTAGE_PRECISION_EXP = exports.MAX_LEVERAGE_ORDER_SIZE = exports.MAX_LEVERAGE = exports.TEN_MILLION = exports.BN_MAX = exports.TEN_THOUSAND = exports.TEN = exports.NINE = exports.EIGHT = exports.SEVEN = exports.SIX = exports.FIVE = exports.FOUR = exports.THREE = exports.TWO = exports.ONE = exports.ZERO = void 0;
|
|
4
4
|
exports.MIN_I64 = exports.MAX_I64 = exports.GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = exports.FUEL_START_TS = exports.FUEL_WINDOW = exports.DUST_POSITION_SIZE = exports.SLOT_TIME_ESTIMATE_MS = exports.IDLE_TIME_SLOTS = exports.ACCOUNT_AGE_DELETION_CUTOFF_SECONDS = exports.DEFAULT_REVENUE_SINCE_LAST_FUNDING_SPREAD_RETREAT = exports.OPEN_ORDER_MARGIN_REQUIREMENT = exports.LAMPORTS_EXP = exports.LAMPORTS_PRECISION = exports.GOV_SPOT_MARKET_INDEX = exports.QUOTE_SPOT_MARKET_INDEX = exports.ONE_YEAR = exports.ONE_HOUR = exports.FIVE_MINUTE = exports.PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO = exports.FUNDING_RATE_CLAMP_DENOMINATOR = exports.FUNDING_RATE_OFFSET_DENOMINATOR = exports.LIQUIDATION_PCT_PRECISION = exports.BID_ASK_SPREAD_PRECISION = void 0;
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
-
const anchor_1 = require("
|
|
6
|
+
const anchor_1 = require("../isomorphic/anchor");
|
|
7
7
|
const bigNum_1 = require("../factory/bigNum");
|
|
8
8
|
exports.ZERO = new anchor_1.BN(0);
|
|
9
9
|
exports.ONE = new anchor_1.BN(1);
|
|
@@ -12,7 +12,7 @@ exports.DevnetPerpMarkets = [
|
|
|
12
12
|
symbol: 'SOL-PERP',
|
|
13
13
|
baseAssetSymbol: 'SOL',
|
|
14
14
|
marketIndex: 0,
|
|
15
|
-
oracle: new web3_js_1.PublicKey('
|
|
15
|
+
oracle: new web3_js_1.PublicKey('2k3UHX6ehRFzx5fTVvbL6FwXhMjkucjJDL9MuVKLo8TV'),
|
|
16
16
|
launchTs: 1655751353000,
|
|
17
17
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
18
18
|
pythLazerId: 6,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { OracleSource } from '../types';
|
|
4
|
-
import { BN } from '
|
|
4
|
+
import { BN } from '../isomorphic/anchor';
|
|
5
5
|
import { DriftEnv } from '../config';
|
|
6
6
|
import { MarketStatus } from '@ellipsis-labs/phoenix-sdk';
|
|
7
7
|
export type SpotMarketConfig = {
|
|
@@ -4,7 +4,7 @@ exports.SpotMarkets = exports.MainnetSpotMarkets = exports.DevnetSpotMarkets = e
|
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const numericConstants_1 = require("./numericConstants");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
|
-
const anchor_1 = require("
|
|
7
|
+
const anchor_1 = require("../isomorphic/anchor");
|
|
8
8
|
exports.WRAPPED_SOL_MINT = new web3_js_1.PublicKey('So11111111111111111111111111111111111111112');
|
|
9
9
|
// Reflects what is actually deployed on devnet (per on-chain enumeration of
|
|
10
10
|
// State.numberOfSpotMarkets). Update when devnet adds/changes a spot market.
|
|
@@ -13,17 +13,18 @@ exports.DevnetSpotMarkets = [
|
|
|
13
13
|
symbol: 'dUSDT',
|
|
14
14
|
marketIndex: 0,
|
|
15
15
|
poolId: 0,
|
|
16
|
-
oracle: new web3_js_1.PublicKey('
|
|
16
|
+
oracle: new web3_js_1.PublicKey('Dai8hT1YRBBm5rBSJUSKcdR11psM55LVAkshbypfC4k4'),
|
|
17
17
|
oracleSource: types_1.OracleSource.PYTH_LAZER_STABLE_COIN,
|
|
18
18
|
mint: new web3_js_1.PublicKey('8FfvSRKMZRDHrCBy142XMUXrKEkXnxDQ4YmJv7xbAw8Q'),
|
|
19
19
|
precision: new anchor_1.BN(10).pow(numericConstants_1.SIX),
|
|
20
20
|
precisionExp: numericConstants_1.SIX,
|
|
21
|
+
pythLazerId: 8,
|
|
21
22
|
},
|
|
22
23
|
{
|
|
23
24
|
symbol: 'SOL',
|
|
24
25
|
marketIndex: 1,
|
|
25
26
|
poolId: 0,
|
|
26
|
-
oracle: new web3_js_1.PublicKey('
|
|
27
|
+
oracle: new web3_js_1.PublicKey('2k3UHX6ehRFzx5fTVvbL6FwXhMjkucjJDL9MuVKLo8TV'),
|
|
27
28
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
28
29
|
mint: exports.WRAPPED_SOL_MINT,
|
|
29
30
|
precision: numericConstants_1.LAMPORTS_PRECISION,
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="bn.js" />
|
|
4
|
+
import type { AccountMeta, Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
5
|
+
import * as pdas from '../addresses/pda';
|
|
6
|
+
import * as constants from '../constants';
|
|
7
|
+
import { CustomBorshCoder } from '../decode/customCoder';
|
|
8
|
+
import type { Drift } from '../idl/drift';
|
|
9
|
+
import type { UserAccount } from '../types';
|
|
10
|
+
import type { DriftProgram } from '../config';
|
|
11
|
+
import type { BN } from '@coral-xyz/anchor';
|
|
12
|
+
import * as remainingAccounts from './remainingAccounts';
|
|
13
|
+
import * as signedMsg from './signedMsg';
|
|
14
|
+
export type DriftCoreContext = {
|
|
15
|
+
/** Drift program id. */
|
|
16
|
+
programId: PublicKey;
|
|
17
|
+
/** Anchor IDL json for Drift (defaults to bundled `idl/drift.json`). */
|
|
18
|
+
idl?: Drift;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* DriftCore is the minimal, core SDK surface:
|
|
22
|
+
* - No subscriptions / polling / websockets.
|
|
23
|
+
* - Pure helpers for PDAs, decoding, constants, and instruction building.
|
|
24
|
+
*
|
|
25
|
+
* Transaction/instruction builders will be progressively moved here from `DriftClient`.
|
|
26
|
+
*/
|
|
27
|
+
export declare class DriftCore {
|
|
28
|
+
/** Re-export PDA helpers (pure). */
|
|
29
|
+
static readonly pdas: typeof pdas;
|
|
30
|
+
/** Re-export SDK constants (market configs, numeric constants, etc). */
|
|
31
|
+
static readonly constants: typeof constants;
|
|
32
|
+
/** Re-export remaining-accounts logic (pure). */
|
|
33
|
+
static readonly remainingAccounts: typeof remainingAccounts;
|
|
34
|
+
static readonly signedMsg: typeof signedMsg;
|
|
35
|
+
static defaultIdl(): Drift;
|
|
36
|
+
static coder(idl?: Drift): CustomBorshCoder;
|
|
37
|
+
/** Decode a Drift `User` account buffer without creating a Program. */
|
|
38
|
+
static decodeUserAccount(buffer: Buffer): UserAccount;
|
|
39
|
+
/** Fetch and decode a Drift `User` account. */
|
|
40
|
+
static fetchUserAccount(connection: Connection, userAccountPublicKey: PublicKey): Promise<UserAccount | null>;
|
|
41
|
+
static buildDepositInstruction(args: {
|
|
42
|
+
program: DriftProgram;
|
|
43
|
+
marketIndex: number;
|
|
44
|
+
amount: BN;
|
|
45
|
+
reduceOnly: boolean;
|
|
46
|
+
state: PublicKey;
|
|
47
|
+
spotMarket: PublicKey;
|
|
48
|
+
spotMarketVault: PublicKey;
|
|
49
|
+
user: PublicKey;
|
|
50
|
+
userStats: PublicKey;
|
|
51
|
+
userTokenAccount: PublicKey;
|
|
52
|
+
authority: PublicKey;
|
|
53
|
+
tokenProgram: PublicKey;
|
|
54
|
+
remainingAccounts: AccountMeta[];
|
|
55
|
+
}): Promise<TransactionInstruction>;
|
|
56
|
+
static buildWithdrawInstruction(args: {
|
|
57
|
+
program: DriftProgram;
|
|
58
|
+
marketIndex: number;
|
|
59
|
+
amount: BN;
|
|
60
|
+
reduceOnly: boolean;
|
|
61
|
+
state: PublicKey;
|
|
62
|
+
spotMarket: PublicKey;
|
|
63
|
+
spotMarketVault: PublicKey;
|
|
64
|
+
driftSigner: PublicKey;
|
|
65
|
+
user: PublicKey;
|
|
66
|
+
userStats: PublicKey;
|
|
67
|
+
userTokenAccount: PublicKey;
|
|
68
|
+
authority: PublicKey;
|
|
69
|
+
tokenProgram: PublicKey;
|
|
70
|
+
remainingAccounts: AccountMeta[];
|
|
71
|
+
}): Promise<TransactionInstruction>;
|
|
72
|
+
static buildPlaceOrdersInstruction(args: {
|
|
73
|
+
program: DriftProgram;
|
|
74
|
+
formattedParams: any[];
|
|
75
|
+
state: PublicKey;
|
|
76
|
+
user: PublicKey;
|
|
77
|
+
userStats: PublicKey;
|
|
78
|
+
authority: PublicKey;
|
|
79
|
+
remainingAccounts: AccountMeta[];
|
|
80
|
+
}): Promise<TransactionInstruction>;
|
|
81
|
+
static buildCancelOrdersInstruction(args: {
|
|
82
|
+
program: DriftProgram;
|
|
83
|
+
marketType: any;
|
|
84
|
+
marketIndex: number | null;
|
|
85
|
+
direction: any;
|
|
86
|
+
user: PublicKey;
|
|
87
|
+
state: PublicKey;
|
|
88
|
+
userStats: PublicKey;
|
|
89
|
+
authority: PublicKey;
|
|
90
|
+
remainingAccounts: AccountMeta[];
|
|
91
|
+
}): Promise<TransactionInstruction>;
|
|
92
|
+
static buildFillPerpOrderInstruction(args: {
|
|
93
|
+
program: DriftProgram;
|
|
94
|
+
orderId: number | null;
|
|
95
|
+
state: PublicKey;
|
|
96
|
+
filler: PublicKey;
|
|
97
|
+
fillerStats: PublicKey;
|
|
98
|
+
user: PublicKey;
|
|
99
|
+
userStats: PublicKey;
|
|
100
|
+
authority: PublicKey;
|
|
101
|
+
remainingAccounts: AccountMeta[];
|
|
102
|
+
}): Promise<TransactionInstruction>;
|
|
103
|
+
static buildTriggerOrderInstruction(args: {
|
|
104
|
+
program: DriftProgram;
|
|
105
|
+
orderId: number;
|
|
106
|
+
state: PublicKey;
|
|
107
|
+
filler: PublicKey;
|
|
108
|
+
user: PublicKey;
|
|
109
|
+
authority: PublicKey;
|
|
110
|
+
remainingAccounts: AccountMeta[];
|
|
111
|
+
}): Promise<TransactionInstruction>;
|
|
112
|
+
static buildSettlePnlInstruction(args: {
|
|
113
|
+
program: DriftProgram;
|
|
114
|
+
marketIndex: number;
|
|
115
|
+
state: PublicKey;
|
|
116
|
+
authority: PublicKey;
|
|
117
|
+
user: PublicKey;
|
|
118
|
+
spotMarketVault: PublicKey;
|
|
119
|
+
remainingAccounts: AccountMeta[];
|
|
120
|
+
}): Promise<TransactionInstruction>;
|
|
121
|
+
static buildLiquidatePerpInstruction(args: {
|
|
122
|
+
program: DriftProgram;
|
|
123
|
+
marketIndex: number;
|
|
124
|
+
maxBaseAssetAmount: any;
|
|
125
|
+
limitPrice: any | null;
|
|
126
|
+
state: PublicKey;
|
|
127
|
+
authority: PublicKey;
|
|
128
|
+
user: PublicKey;
|
|
129
|
+
userStats: PublicKey;
|
|
130
|
+
liquidator: PublicKey;
|
|
131
|
+
liquidatorStats: PublicKey;
|
|
132
|
+
remainingAccounts: AccountMeta[];
|
|
133
|
+
}): Promise<TransactionInstruction>;
|
|
134
|
+
static buildPlacePerpOrderInstruction(args: {
|
|
135
|
+
program: DriftProgram;
|
|
136
|
+
orderParams: any;
|
|
137
|
+
state: PublicKey;
|
|
138
|
+
user: PublicKey;
|
|
139
|
+
userStats: PublicKey;
|
|
140
|
+
authority: PublicKey;
|
|
141
|
+
remainingAccounts: AccountMeta[];
|
|
142
|
+
}): Promise<TransactionInstruction>;
|
|
143
|
+
static buildPlaceAndTakePerpOrderInstruction(args: {
|
|
144
|
+
program: DriftProgram;
|
|
145
|
+
orderParams: any;
|
|
146
|
+
optionalParams: number | null;
|
|
147
|
+
state: PublicKey;
|
|
148
|
+
user: PublicKey;
|
|
149
|
+
userStats: PublicKey;
|
|
150
|
+
authority: PublicKey;
|
|
151
|
+
remainingAccounts: AccountMeta[];
|
|
152
|
+
}): Promise<TransactionInstruction>;
|
|
153
|
+
static buildPlaceAndMakePerpOrderInstruction(args: {
|
|
154
|
+
program: DriftProgram;
|
|
155
|
+
orderParams: any;
|
|
156
|
+
takerOrderId: number;
|
|
157
|
+
state: PublicKey;
|
|
158
|
+
user: PublicKey;
|
|
159
|
+
userStats: PublicKey;
|
|
160
|
+
taker: PublicKey;
|
|
161
|
+
takerStats: PublicKey;
|
|
162
|
+
authority: PublicKey;
|
|
163
|
+
remainingAccounts: AccountMeta[];
|
|
164
|
+
}): Promise<TransactionInstruction>;
|
|
165
|
+
static buildCancelOrderInstruction(args: {
|
|
166
|
+
program: DriftProgram;
|
|
167
|
+
orderId: number | null;
|
|
168
|
+
state: PublicKey;
|
|
169
|
+
user: PublicKey;
|
|
170
|
+
authority: PublicKey;
|
|
171
|
+
remainingAccounts: AccountMeta[];
|
|
172
|
+
}): Promise<TransactionInstruction>;
|
|
173
|
+
static buildCancelOrderByUserIdInstruction(args: {
|
|
174
|
+
program: DriftProgram;
|
|
175
|
+
userOrderId: number;
|
|
176
|
+
state: PublicKey;
|
|
177
|
+
user: PublicKey;
|
|
178
|
+
authority: PublicKey;
|
|
179
|
+
oracle: PublicKey;
|
|
180
|
+
remainingAccounts: AccountMeta[];
|
|
181
|
+
}): Promise<TransactionInstruction>;
|
|
182
|
+
static buildCancelOrdersByIdsInstruction(args: {
|
|
183
|
+
program: DriftProgram;
|
|
184
|
+
orderIds: number[] | undefined;
|
|
185
|
+
state: PublicKey;
|
|
186
|
+
user: PublicKey;
|
|
187
|
+
authority: PublicKey;
|
|
188
|
+
remainingAccounts: AccountMeta[];
|
|
189
|
+
}): Promise<TransactionInstruction>;
|
|
190
|
+
static buildModifyOrderInstruction(args: {
|
|
191
|
+
program: DriftProgram;
|
|
192
|
+
orderId: number;
|
|
193
|
+
modifyParams: any;
|
|
194
|
+
state: PublicKey;
|
|
195
|
+
user: PublicKey;
|
|
196
|
+
userStats: PublicKey;
|
|
197
|
+
authority: PublicKey;
|
|
198
|
+
remainingAccounts: AccountMeta[];
|
|
199
|
+
}): Promise<TransactionInstruction>;
|
|
200
|
+
static buildModifyOrderByUserIdInstruction(args: {
|
|
201
|
+
program: DriftProgram;
|
|
202
|
+
userOrderId: number;
|
|
203
|
+
modifyParams: any;
|
|
204
|
+
state: PublicKey;
|
|
205
|
+
user: PublicKey;
|
|
206
|
+
userStats: PublicKey;
|
|
207
|
+
authority: PublicKey;
|
|
208
|
+
remainingAccounts: AccountMeta[];
|
|
209
|
+
}): Promise<TransactionInstruction>;
|
|
210
|
+
static buildUpdateFundingRateInstruction(args: {
|
|
211
|
+
program: DriftProgram;
|
|
212
|
+
perpMarketIndex: number;
|
|
213
|
+
state: PublicKey;
|
|
214
|
+
perpMarket: PublicKey;
|
|
215
|
+
oracle: PublicKey;
|
|
216
|
+
}): Promise<TransactionInstruction>;
|
|
217
|
+
/**
|
|
218
|
+
* Placeholder for instruction builders.
|
|
219
|
+
*
|
|
220
|
+
* In follow-up refactors, DriftClient methods like `getDepositInstruction`,
|
|
221
|
+
* `getPlaceOrdersIx`, etc. will be moved here as pure builders.
|
|
222
|
+
*/
|
|
223
|
+
static buildInstructions(_ctx: DriftCoreContext): TransactionInstruction[];
|
|
224
|
+
}
|