@drift-labs/sdk-browser 2.163.0-beta.12 → 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/spotMarkets.d.ts +1 -1
- package/lib/browser/constants/spotMarkets.js +1 -1
- 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/spotMarkets.d.ts +1 -1
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +1 -1
- 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/spotMarkets.ts +1 -1
- 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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./DriftCore"), exports);
|
|
18
|
+
__exportStar(require("./remainingAccounts"), exports);
|
|
19
|
+
__exportStar(require("./signedMsg"), exports);
|
|
20
|
+
__exportStar(require("./instructions/deposit"), exports);
|
|
21
|
+
__exportStar(require("./instructions/withdraw"), exports);
|
|
22
|
+
__exportStar(require("./instructions/orders"), exports);
|
|
23
|
+
__exportStar(require("./instructions/fill"), exports);
|
|
24
|
+
__exportStar(require("./instructions/trigger"), exports);
|
|
25
|
+
__exportStar(require("./instructions/settlement"), exports);
|
|
26
|
+
__exportStar(require("./instructions/liquidation"), exports);
|
|
27
|
+
__exportStar(require("./instructions/perpOrders"), exports);
|
|
28
|
+
__exportStar(require("./instructions/funding"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import type { AccountMeta, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
import type { BN } from '../../isomorphic/anchor';
|
|
4
|
+
import type { DriftProgram } from '../../config';
|
|
5
|
+
export declare function buildDepositInstruction(args: {
|
|
6
|
+
program: DriftProgram;
|
|
7
|
+
marketIndex: number;
|
|
8
|
+
amount: BN;
|
|
9
|
+
reduceOnly: boolean;
|
|
10
|
+
state: PublicKey;
|
|
11
|
+
spotMarket: PublicKey;
|
|
12
|
+
spotMarketVault: PublicKey;
|
|
13
|
+
user: PublicKey;
|
|
14
|
+
userStats: PublicKey;
|
|
15
|
+
userTokenAccount: PublicKey;
|
|
16
|
+
authority: PublicKey;
|
|
17
|
+
tokenProgram: PublicKey;
|
|
18
|
+
remainingAccounts: AccountMeta[];
|
|
19
|
+
}): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildDepositInstruction = void 0;
|
|
4
|
+
async function buildDepositInstruction(args) {
|
|
5
|
+
return await args.program.instruction.deposit(args.marketIndex, args.amount, args.reduceOnly, {
|
|
6
|
+
accounts: {
|
|
7
|
+
state: args.state,
|
|
8
|
+
spotMarket: args.spotMarket,
|
|
9
|
+
spotMarketVault: args.spotMarketVault,
|
|
10
|
+
user: args.user,
|
|
11
|
+
userStats: args.userStats,
|
|
12
|
+
userTokenAccount: args.userTokenAccount,
|
|
13
|
+
authority: args.authority,
|
|
14
|
+
tokenProgram: args.tokenProgram,
|
|
15
|
+
},
|
|
16
|
+
remainingAccounts: args.remainingAccounts,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.buildDepositInstruction = buildDepositInstruction;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AccountMeta, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import type { DriftProgram } from '../../config';
|
|
3
|
+
export declare function buildFillPerpOrderInstruction(args: {
|
|
4
|
+
program: DriftProgram;
|
|
5
|
+
orderId: number | null;
|
|
6
|
+
state: PublicKey;
|
|
7
|
+
filler: PublicKey;
|
|
8
|
+
fillerStats: PublicKey;
|
|
9
|
+
user: PublicKey;
|
|
10
|
+
userStats: PublicKey;
|
|
11
|
+
authority: PublicKey;
|
|
12
|
+
remainingAccounts: AccountMeta[];
|
|
13
|
+
}): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildFillPerpOrderInstruction = void 0;
|
|
4
|
+
async function buildFillPerpOrderInstruction(args) {
|
|
5
|
+
return await args.program.instruction.fillPerpOrder(args.orderId, null, {
|
|
6
|
+
accounts: {
|
|
7
|
+
state: args.state,
|
|
8
|
+
filler: args.filler,
|
|
9
|
+
fillerStats: args.fillerStats,
|
|
10
|
+
user: args.user,
|
|
11
|
+
userStats: args.userStats,
|
|
12
|
+
authority: args.authority,
|
|
13
|
+
},
|
|
14
|
+
remainingAccounts: args.remainingAccounts,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.buildFillPerpOrderInstruction = buildFillPerpOrderInstruction;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import type { DriftProgram } from '../../config';
|
|
3
|
+
export declare function buildUpdateFundingRateInstruction(args: {
|
|
4
|
+
program: DriftProgram;
|
|
5
|
+
perpMarketIndex: number;
|
|
6
|
+
state: PublicKey;
|
|
7
|
+
perpMarket: PublicKey;
|
|
8
|
+
oracle: PublicKey;
|
|
9
|
+
}): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildUpdateFundingRateInstruction = void 0;
|
|
4
|
+
async function buildUpdateFundingRateInstruction(args) {
|
|
5
|
+
return await args.program.instruction.updateFundingRate(args.perpMarketIndex, {
|
|
6
|
+
accounts: {
|
|
7
|
+
state: args.state,
|
|
8
|
+
perpMarket: args.perpMarket,
|
|
9
|
+
oracle: args.oracle,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.buildUpdateFundingRateInstruction = buildUpdateFundingRateInstruction;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AccountMeta, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import type { DriftProgram } from '../../config';
|
|
3
|
+
export declare function buildLiquidatePerpInstruction(args: {
|
|
4
|
+
program: DriftProgram;
|
|
5
|
+
marketIndex: number;
|
|
6
|
+
maxBaseAssetAmount: any;
|
|
7
|
+
limitPrice: any | null;
|
|
8
|
+
state: PublicKey;
|
|
9
|
+
authority: PublicKey;
|
|
10
|
+
user: PublicKey;
|
|
11
|
+
userStats: PublicKey;
|
|
12
|
+
liquidator: PublicKey;
|
|
13
|
+
liquidatorStats: PublicKey;
|
|
14
|
+
remainingAccounts: AccountMeta[];
|
|
15
|
+
}): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildLiquidatePerpInstruction = void 0;
|
|
4
|
+
async function buildLiquidatePerpInstruction(args) {
|
|
5
|
+
return await args.program.instruction.liquidatePerp(args.marketIndex, args.maxBaseAssetAmount, args.limitPrice, {
|
|
6
|
+
accounts: {
|
|
7
|
+
state: args.state,
|
|
8
|
+
authority: args.authority,
|
|
9
|
+
user: args.user,
|
|
10
|
+
userStats: args.userStats,
|
|
11
|
+
liquidator: args.liquidator,
|
|
12
|
+
liquidatorStats: args.liquidatorStats,
|
|
13
|
+
},
|
|
14
|
+
remainingAccounts: args.remainingAccounts,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.buildLiquidatePerpInstruction = buildLiquidatePerpInstruction;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AccountMeta, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import type { DriftProgram } from '../../config';
|
|
3
|
+
export declare function buildPlaceOrdersInstruction(args: {
|
|
4
|
+
program: DriftProgram;
|
|
5
|
+
formattedParams: any[];
|
|
6
|
+
state: PublicKey;
|
|
7
|
+
user: PublicKey;
|
|
8
|
+
userStats: PublicKey;
|
|
9
|
+
authority: PublicKey;
|
|
10
|
+
remainingAccounts: AccountMeta[];
|
|
11
|
+
}): Promise<TransactionInstruction>;
|
|
12
|
+
export declare function buildCancelOrdersInstruction(args: {
|
|
13
|
+
program: DriftProgram;
|
|
14
|
+
marketType: any;
|
|
15
|
+
marketIndex: number | null;
|
|
16
|
+
direction: any;
|
|
17
|
+
user: PublicKey;
|
|
18
|
+
state: PublicKey;
|
|
19
|
+
userStats: PublicKey;
|
|
20
|
+
authority: PublicKey;
|
|
21
|
+
remainingAccounts: AccountMeta[];
|
|
22
|
+
}): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildCancelOrdersInstruction = exports.buildPlaceOrdersInstruction = void 0;
|
|
4
|
+
async function buildPlaceOrdersInstruction(args) {
|
|
5
|
+
return await args.program.instruction.placeOrders(args.formattedParams, {
|
|
6
|
+
accounts: {
|
|
7
|
+
state: args.state,
|
|
8
|
+
user: args.user,
|
|
9
|
+
userStats: args.userStats,
|
|
10
|
+
authority: args.authority,
|
|
11
|
+
},
|
|
12
|
+
remainingAccounts: args.remainingAccounts,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.buildPlaceOrdersInstruction = buildPlaceOrdersInstruction;
|
|
16
|
+
async function buildCancelOrdersInstruction(args) {
|
|
17
|
+
return await args.program.instruction.cancelOrders(args.marketType, args.marketIndex, args.direction, {
|
|
18
|
+
accounts: {
|
|
19
|
+
state: args.state,
|
|
20
|
+
user: args.user,
|
|
21
|
+
userStats: args.userStats,
|
|
22
|
+
authority: args.authority,
|
|
23
|
+
},
|
|
24
|
+
remainingAccounts: args.remainingAccounts,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.buildCancelOrdersInstruction = buildCancelOrdersInstruction;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { AccountMeta, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import type { DriftProgram } from '../../config';
|
|
3
|
+
export declare function buildPlacePerpOrderInstruction(args: {
|
|
4
|
+
program: DriftProgram;
|
|
5
|
+
orderParams: any;
|
|
6
|
+
state: PublicKey;
|
|
7
|
+
user: PublicKey;
|
|
8
|
+
userStats: PublicKey;
|
|
9
|
+
authority: PublicKey;
|
|
10
|
+
remainingAccounts: AccountMeta[];
|
|
11
|
+
}): Promise<TransactionInstruction>;
|
|
12
|
+
export declare function buildPlaceAndTakePerpOrderInstruction(args: {
|
|
13
|
+
program: DriftProgram;
|
|
14
|
+
orderParams: any;
|
|
15
|
+
optionalParams: number | null;
|
|
16
|
+
state: PublicKey;
|
|
17
|
+
user: PublicKey;
|
|
18
|
+
userStats: PublicKey;
|
|
19
|
+
authority: PublicKey;
|
|
20
|
+
remainingAccounts: AccountMeta[];
|
|
21
|
+
}): Promise<TransactionInstruction>;
|
|
22
|
+
export declare function buildPlaceAndMakePerpOrderInstruction(args: {
|
|
23
|
+
program: DriftProgram;
|
|
24
|
+
orderParams: any;
|
|
25
|
+
takerOrderId: number;
|
|
26
|
+
state: PublicKey;
|
|
27
|
+
user: PublicKey;
|
|
28
|
+
userStats: PublicKey;
|
|
29
|
+
taker: PublicKey;
|
|
30
|
+
takerStats: PublicKey;
|
|
31
|
+
authority: PublicKey;
|
|
32
|
+
remainingAccounts: AccountMeta[];
|
|
33
|
+
}): Promise<TransactionInstruction>;
|
|
34
|
+
export declare function buildCancelOrderInstruction(args: {
|
|
35
|
+
program: DriftProgram;
|
|
36
|
+
orderId: number | null;
|
|
37
|
+
state: PublicKey;
|
|
38
|
+
user: PublicKey;
|
|
39
|
+
authority: PublicKey;
|
|
40
|
+
remainingAccounts: AccountMeta[];
|
|
41
|
+
}): Promise<TransactionInstruction>;
|
|
42
|
+
export declare function buildCancelOrderByUserIdInstruction(args: {
|
|
43
|
+
program: DriftProgram;
|
|
44
|
+
userOrderId: number;
|
|
45
|
+
state: PublicKey;
|
|
46
|
+
user: PublicKey;
|
|
47
|
+
authority: PublicKey;
|
|
48
|
+
oracle: PublicKey;
|
|
49
|
+
remainingAccounts: AccountMeta[];
|
|
50
|
+
}): Promise<TransactionInstruction>;
|
|
51
|
+
export declare function buildCancelOrdersByIdsInstruction(args: {
|
|
52
|
+
program: DriftProgram;
|
|
53
|
+
orderIds: number[] | undefined;
|
|
54
|
+
state: PublicKey;
|
|
55
|
+
user: PublicKey;
|
|
56
|
+
authority: PublicKey;
|
|
57
|
+
remainingAccounts: AccountMeta[];
|
|
58
|
+
}): Promise<TransactionInstruction>;
|
|
59
|
+
export declare function buildModifyOrderInstruction(args: {
|
|
60
|
+
program: DriftProgram;
|
|
61
|
+
orderId: number;
|
|
62
|
+
modifyParams: any;
|
|
63
|
+
state: PublicKey;
|
|
64
|
+
user: PublicKey;
|
|
65
|
+
userStats: PublicKey;
|
|
66
|
+
authority: PublicKey;
|
|
67
|
+
remainingAccounts: AccountMeta[];
|
|
68
|
+
}): Promise<TransactionInstruction>;
|
|
69
|
+
export declare function buildModifyOrderByUserIdInstruction(args: {
|
|
70
|
+
program: DriftProgram;
|
|
71
|
+
userOrderId: number;
|
|
72
|
+
modifyParams: any;
|
|
73
|
+
state: PublicKey;
|
|
74
|
+
user: PublicKey;
|
|
75
|
+
userStats: PublicKey;
|
|
76
|
+
authority: PublicKey;
|
|
77
|
+
remainingAccounts: AccountMeta[];
|
|
78
|
+
}): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildModifyOrderByUserIdInstruction = exports.buildModifyOrderInstruction = exports.buildCancelOrdersByIdsInstruction = exports.buildCancelOrderByUserIdInstruction = exports.buildCancelOrderInstruction = exports.buildPlaceAndMakePerpOrderInstruction = exports.buildPlaceAndTakePerpOrderInstruction = exports.buildPlacePerpOrderInstruction = void 0;
|
|
4
|
+
async function buildPlacePerpOrderInstruction(args) {
|
|
5
|
+
return await args.program.instruction.placePerpOrder(args.orderParams, {
|
|
6
|
+
accounts: {
|
|
7
|
+
state: args.state,
|
|
8
|
+
user: args.user,
|
|
9
|
+
userStats: args.userStats,
|
|
10
|
+
authority: args.authority,
|
|
11
|
+
},
|
|
12
|
+
remainingAccounts: args.remainingAccounts,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.buildPlacePerpOrderInstruction = buildPlacePerpOrderInstruction;
|
|
16
|
+
async function buildPlaceAndTakePerpOrderInstruction(args) {
|
|
17
|
+
return await args.program.instruction.placeAndTakePerpOrder(args.orderParams, args.optionalParams, {
|
|
18
|
+
accounts: {
|
|
19
|
+
state: args.state,
|
|
20
|
+
user: args.user,
|
|
21
|
+
userStats: args.userStats,
|
|
22
|
+
authority: args.authority,
|
|
23
|
+
},
|
|
24
|
+
remainingAccounts: args.remainingAccounts,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.buildPlaceAndTakePerpOrderInstruction = buildPlaceAndTakePerpOrderInstruction;
|
|
28
|
+
async function buildPlaceAndMakePerpOrderInstruction(args) {
|
|
29
|
+
return await args.program.instruction.placeAndMakePerpOrder(args.orderParams, args.takerOrderId, {
|
|
30
|
+
accounts: {
|
|
31
|
+
state: args.state,
|
|
32
|
+
user: args.user,
|
|
33
|
+
userStats: args.userStats,
|
|
34
|
+
taker: args.taker,
|
|
35
|
+
takerStats: args.takerStats,
|
|
36
|
+
authority: args.authority,
|
|
37
|
+
},
|
|
38
|
+
remainingAccounts: args.remainingAccounts,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.buildPlaceAndMakePerpOrderInstruction = buildPlaceAndMakePerpOrderInstruction;
|
|
42
|
+
async function buildCancelOrderInstruction(args) {
|
|
43
|
+
return await args.program.instruction.cancelOrder(args.orderId, {
|
|
44
|
+
accounts: {
|
|
45
|
+
state: args.state,
|
|
46
|
+
user: args.user,
|
|
47
|
+
authority: args.authority,
|
|
48
|
+
},
|
|
49
|
+
remainingAccounts: args.remainingAccounts,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.buildCancelOrderInstruction = buildCancelOrderInstruction;
|
|
53
|
+
async function buildCancelOrderByUserIdInstruction(args) {
|
|
54
|
+
return await args.program.instruction.cancelOrderByUserId(args.userOrderId, {
|
|
55
|
+
accounts: {
|
|
56
|
+
state: args.state,
|
|
57
|
+
user: args.user,
|
|
58
|
+
authority: args.authority,
|
|
59
|
+
oracle: args.oracle,
|
|
60
|
+
},
|
|
61
|
+
remainingAccounts: args.remainingAccounts,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.buildCancelOrderByUserIdInstruction = buildCancelOrderByUserIdInstruction;
|
|
65
|
+
async function buildCancelOrdersByIdsInstruction(args) {
|
|
66
|
+
return await args.program.instruction.cancelOrdersByIds(args.orderIds, {
|
|
67
|
+
accounts: {
|
|
68
|
+
state: args.state,
|
|
69
|
+
user: args.user,
|
|
70
|
+
authority: args.authority,
|
|
71
|
+
},
|
|
72
|
+
remainingAccounts: args.remainingAccounts,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.buildCancelOrdersByIdsInstruction = buildCancelOrdersByIdsInstruction;
|
|
76
|
+
async function buildModifyOrderInstruction(args) {
|
|
77
|
+
return await args.program.instruction.modifyOrder(args.orderId, args.modifyParams, {
|
|
78
|
+
accounts: {
|
|
79
|
+
state: args.state,
|
|
80
|
+
user: args.user,
|
|
81
|
+
userStats: args.userStats,
|
|
82
|
+
authority: args.authority,
|
|
83
|
+
},
|
|
84
|
+
remainingAccounts: args.remainingAccounts,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
exports.buildModifyOrderInstruction = buildModifyOrderInstruction;
|
|
88
|
+
async function buildModifyOrderByUserIdInstruction(args) {
|
|
89
|
+
return await args.program.instruction.modifyOrderByUserId(args.userOrderId, args.modifyParams, {
|
|
90
|
+
accounts: {
|
|
91
|
+
state: args.state,
|
|
92
|
+
user: args.user,
|
|
93
|
+
userStats: args.userStats,
|
|
94
|
+
authority: args.authority,
|
|
95
|
+
},
|
|
96
|
+
remainingAccounts: args.remainingAccounts,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
exports.buildModifyOrderByUserIdInstruction = buildModifyOrderByUserIdInstruction;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AccountMeta, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import type { DriftProgram } from '../../config';
|
|
3
|
+
export declare function buildSettlePnlInstruction(args: {
|
|
4
|
+
program: DriftProgram;
|
|
5
|
+
marketIndex: number;
|
|
6
|
+
state: PublicKey;
|
|
7
|
+
authority: PublicKey;
|
|
8
|
+
user: PublicKey;
|
|
9
|
+
spotMarketVault: PublicKey;
|
|
10
|
+
remainingAccounts: AccountMeta[];
|
|
11
|
+
}): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSettlePnlInstruction = void 0;
|
|
4
|
+
async function buildSettlePnlInstruction(args) {
|
|
5
|
+
return await args.program.instruction.settlePnl(args.marketIndex, {
|
|
6
|
+
accounts: {
|
|
7
|
+
state: args.state,
|
|
8
|
+
authority: args.authority,
|
|
9
|
+
user: args.user,
|
|
10
|
+
spotMarketVault: args.spotMarketVault,
|
|
11
|
+
},
|
|
12
|
+
remainingAccounts: args.remainingAccounts,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.buildSettlePnlInstruction = buildSettlePnlInstruction;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AccountMeta, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import type { DriftProgram } from '../../config';
|
|
3
|
+
export declare function buildTriggerOrderInstruction(args: {
|
|
4
|
+
program: DriftProgram;
|
|
5
|
+
orderId: number;
|
|
6
|
+
state: PublicKey;
|
|
7
|
+
filler: PublicKey;
|
|
8
|
+
user: PublicKey;
|
|
9
|
+
authority: PublicKey;
|
|
10
|
+
remainingAccounts: AccountMeta[];
|
|
11
|
+
}): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildTriggerOrderInstruction = void 0;
|
|
4
|
+
async function buildTriggerOrderInstruction(args) {
|
|
5
|
+
return await args.program.instruction.triggerOrder(args.orderId, {
|
|
6
|
+
accounts: {
|
|
7
|
+
state: args.state,
|
|
8
|
+
filler: args.filler,
|
|
9
|
+
user: args.user,
|
|
10
|
+
authority: args.authority,
|
|
11
|
+
},
|
|
12
|
+
remainingAccounts: args.remainingAccounts,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.buildTriggerOrderInstruction = buildTriggerOrderInstruction;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import type { AccountMeta, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
import type { BN } from '../../isomorphic/anchor';
|
|
4
|
+
import type { DriftProgram } from '../../config';
|
|
5
|
+
export declare function buildWithdrawInstruction(args: {
|
|
6
|
+
program: DriftProgram;
|
|
7
|
+
marketIndex: number;
|
|
8
|
+
amount: BN;
|
|
9
|
+
reduceOnly: boolean;
|
|
10
|
+
state: PublicKey;
|
|
11
|
+
spotMarket: PublicKey;
|
|
12
|
+
spotMarketVault: PublicKey;
|
|
13
|
+
driftSigner: PublicKey;
|
|
14
|
+
user: PublicKey;
|
|
15
|
+
userStats: PublicKey;
|
|
16
|
+
userTokenAccount: PublicKey;
|
|
17
|
+
authority: PublicKey;
|
|
18
|
+
tokenProgram: PublicKey;
|
|
19
|
+
remainingAccounts: AccountMeta[];
|
|
20
|
+
}): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildWithdrawInstruction = void 0;
|
|
4
|
+
async function buildWithdrawInstruction(args) {
|
|
5
|
+
return await args.program.instruction.withdraw(args.marketIndex, args.amount, args.reduceOnly, {
|
|
6
|
+
accounts: {
|
|
7
|
+
state: args.state,
|
|
8
|
+
spotMarket: args.spotMarket,
|
|
9
|
+
spotMarketVault: args.spotMarketVault,
|
|
10
|
+
driftSigner: args.driftSigner,
|
|
11
|
+
user: args.user,
|
|
12
|
+
userStats: args.userStats,
|
|
13
|
+
userTokenAccount: args.userTokenAccount,
|
|
14
|
+
authority: args.authority,
|
|
15
|
+
tokenProgram: args.tokenProgram,
|
|
16
|
+
},
|
|
17
|
+
remainingAccounts: args.remainingAccounts,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.buildWithdrawInstruction = buildWithdrawInstruction;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PublicKey, type AccountMeta } from '@solana/web3.js';
|
|
2
|
+
import type { UserAccount, SpotMarketAccount, PerpMarketAccount } from '../types';
|
|
3
|
+
export type RemainingAccountParams = {
|
|
4
|
+
userAccounts: UserAccount[];
|
|
5
|
+
writablePerpMarketIndexes?: number[];
|
|
6
|
+
writableSpotMarketIndexes?: number[];
|
|
7
|
+
readablePerpMarketIndex?: number | number[];
|
|
8
|
+
readableSpotMarketIndexes?: number[];
|
|
9
|
+
useMarketLastSlotCache?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type RemainingAccountsContext = {
|
|
12
|
+
/** Used to resolve market accounts. */
|
|
13
|
+
getPerpMarketAccount: (marketIndex: number) => PerpMarketAccount;
|
|
14
|
+
getSpotMarketAccount: (marketIndex: number) => SpotMarketAccount;
|
|
15
|
+
/** Used to resolve user's last slot for cache invalidation. */
|
|
16
|
+
getUserAccountAndSlot: (subAccountId: number, authority: PublicKey) => {
|
|
17
|
+
slot: number;
|
|
18
|
+
} | undefined;
|
|
19
|
+
activeSubAccountId: number;
|
|
20
|
+
authority: PublicKey;
|
|
21
|
+
/** Mutable caches + forced-market sets (owned by caller). */
|
|
22
|
+
perpMarketLastSlotCache: Map<number, number>;
|
|
23
|
+
spotMarketLastSlotCache: Map<number, number>;
|
|
24
|
+
mustIncludePerpMarketIndexes: Set<number>;
|
|
25
|
+
mustIncludeSpotMarketIndexes: Set<number>;
|
|
26
|
+
};
|
|
27
|
+
export declare function getRemainingAccounts(ctx: RemainingAccountsContext, params: RemainingAccountParams): AccountMeta[];
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRemainingAccounts = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const numericConstants_1 = require("../constants/numericConstants");
|
|
7
|
+
const spotPosition_1 = require("../math/spotPosition");
|
|
8
|
+
const position_1 = require("../math/position");
|
|
9
|
+
function getRemainingAccounts(ctx, params) {
|
|
10
|
+
var _a;
|
|
11
|
+
const { oracleAccountMap, spotMarketAccountMap, perpMarketAccountMap } = getRemainingAccountMapsForUsers(ctx, params.userAccounts);
|
|
12
|
+
if (params.useMarketLastSlotCache) {
|
|
13
|
+
const lastUserSlot = (_a = ctx.getUserAccountAndSlot(params.userAccounts.length > 0
|
|
14
|
+
? params.userAccounts[0].subAccountId
|
|
15
|
+
: ctx.activeSubAccountId, params.userAccounts.length > 0
|
|
16
|
+
? params.userAccounts[0].authority
|
|
17
|
+
: ctx.authority)) === null || _a === void 0 ? void 0 : _a.slot;
|
|
18
|
+
for (const [marketIndex, slot] of ctx.perpMarketLastSlotCache.entries()) {
|
|
19
|
+
if (slot > lastUserSlot) {
|
|
20
|
+
addPerpMarketToRemainingAccountMaps(ctx, marketIndex, false, oracleAccountMap, spotMarketAccountMap, perpMarketAccountMap);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
ctx.perpMarketLastSlotCache.delete(marketIndex);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
for (const [marketIndex, slot] of ctx.spotMarketLastSlotCache.entries()) {
|
|
27
|
+
if (slot > lastUserSlot) {
|
|
28
|
+
addSpotMarketToRemainingAccountMaps(ctx, marketIndex, false, oracleAccountMap, spotMarketAccountMap);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
ctx.spotMarketLastSlotCache.delete(marketIndex);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (params.readablePerpMarketIndex !== undefined) {
|
|
36
|
+
const readablePerpMarketIndexes = Array.isArray(params.readablePerpMarketIndex)
|
|
37
|
+
? params.readablePerpMarketIndex
|
|
38
|
+
: [params.readablePerpMarketIndex];
|
|
39
|
+
for (const marketIndex of readablePerpMarketIndexes) {
|
|
40
|
+
addPerpMarketToRemainingAccountMaps(ctx, marketIndex, false, oracleAccountMap, spotMarketAccountMap, perpMarketAccountMap);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
for (const perpMarketIndex of ctx.mustIncludePerpMarketIndexes.values()) {
|
|
44
|
+
addPerpMarketToRemainingAccountMaps(ctx, perpMarketIndex, false, oracleAccountMap, spotMarketAccountMap, perpMarketAccountMap);
|
|
45
|
+
}
|
|
46
|
+
if (params.readableSpotMarketIndexes !== undefined) {
|
|
47
|
+
for (const readableSpotMarketIndex of params.readableSpotMarketIndexes) {
|
|
48
|
+
addSpotMarketToRemainingAccountMaps(ctx, readableSpotMarketIndex, false, oracleAccountMap, spotMarketAccountMap);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (const spotMarketIndex of ctx.mustIncludeSpotMarketIndexes.values()) {
|
|
52
|
+
addSpotMarketToRemainingAccountMaps(ctx, spotMarketIndex, false, oracleAccountMap, spotMarketAccountMap);
|
|
53
|
+
}
|
|
54
|
+
if (params.writablePerpMarketIndexes !== undefined) {
|
|
55
|
+
for (const writablePerpMarketIndex of params.writablePerpMarketIndexes) {
|
|
56
|
+
addPerpMarketToRemainingAccountMaps(ctx, writablePerpMarketIndex, true, oracleAccountMap, spotMarketAccountMap, perpMarketAccountMap);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (params.writableSpotMarketIndexes !== undefined) {
|
|
60
|
+
for (const writableSpotMarketIndex of params.writableSpotMarketIndexes) {
|
|
61
|
+
addSpotMarketToRemainingAccountMaps(ctx, writableSpotMarketIndex, true, oracleAccountMap, spotMarketAccountMap);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return [
|
|
65
|
+
...oracleAccountMap.values(),
|
|
66
|
+
...spotMarketAccountMap.values(),
|
|
67
|
+
...perpMarketAccountMap.values(),
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
exports.getRemainingAccounts = getRemainingAccounts;
|
|
71
|
+
function addPerpMarketToRemainingAccountMaps(ctx, marketIndex, writable, oracleAccountMap, spotMarketAccountMap, perpMarketAccountMap) {
|
|
72
|
+
const perpMarketAccount = ctx.getPerpMarketAccount(marketIndex);
|
|
73
|
+
perpMarketAccountMap.set(marketIndex, {
|
|
74
|
+
pubkey: perpMarketAccount.pubkey,
|
|
75
|
+
isSigner: false,
|
|
76
|
+
isWritable: writable,
|
|
77
|
+
});
|
|
78
|
+
const oracleWritable = writable && (0, types_1.isVariant)(perpMarketAccount.amm.oracleSource, 'prelaunch');
|
|
79
|
+
oracleAccountMap.set(perpMarketAccount.amm.oracle.toString(), {
|
|
80
|
+
pubkey: perpMarketAccount.amm.oracle,
|
|
81
|
+
isSigner: false,
|
|
82
|
+
isWritable: oracleWritable,
|
|
83
|
+
});
|
|
84
|
+
addSpotMarketToRemainingAccountMaps(ctx, perpMarketAccount.quoteSpotMarketIndex, false, oracleAccountMap, spotMarketAccountMap);
|
|
85
|
+
}
|
|
86
|
+
function addSpotMarketToRemainingAccountMaps(ctx, marketIndex, writable, oracleAccountMap, spotMarketAccountMap) {
|
|
87
|
+
const spotMarketAccount = ctx.getSpotMarketAccount(marketIndex);
|
|
88
|
+
spotMarketAccountMap.set(spotMarketAccount.marketIndex, {
|
|
89
|
+
pubkey: spotMarketAccount.pubkey,
|
|
90
|
+
isSigner: false,
|
|
91
|
+
isWritable: writable,
|
|
92
|
+
});
|
|
93
|
+
if (!spotMarketAccount.oracle.equals(web3_js_1.PublicKey.default)) {
|
|
94
|
+
oracleAccountMap.set(spotMarketAccount.oracle.toString(), {
|
|
95
|
+
pubkey: spotMarketAccount.oracle,
|
|
96
|
+
isSigner: false,
|
|
97
|
+
isWritable: false,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function getRemainingAccountMapsForUsers(ctx, userAccounts) {
|
|
102
|
+
const oracleAccountMap = new Map();
|
|
103
|
+
const spotMarketAccountMap = new Map();
|
|
104
|
+
const perpMarketAccountMap = new Map();
|
|
105
|
+
for (const userAccount of userAccounts) {
|
|
106
|
+
for (const spotPosition of userAccount.spotPositions) {
|
|
107
|
+
if (!(0, spotPosition_1.isSpotPositionAvailable)(spotPosition)) {
|
|
108
|
+
addSpotMarketToRemainingAccountMaps(ctx, spotPosition.marketIndex, false, oracleAccountMap, spotMarketAccountMap);
|
|
109
|
+
if (!spotPosition.openAsks.eq(numericConstants_1.ZERO) ||
|
|
110
|
+
!spotPosition.openBids.eq(numericConstants_1.ZERO)) {
|
|
111
|
+
addSpotMarketToRemainingAccountMaps(ctx, numericConstants_1.QUOTE_SPOT_MARKET_INDEX, false, oracleAccountMap, spotMarketAccountMap);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (const position of userAccount.perpPositions) {
|
|
116
|
+
if (!(0, position_1.positionIsAvailable)(position)) {
|
|
117
|
+
addPerpMarketToRemainingAccountMaps(ctx, position.marketIndex, false, oracleAccountMap, spotMarketAccountMap, perpMarketAccountMap);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return { oracleAccountMap, spotMarketAccountMap, perpMarketAccountMap };
|
|
122
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { SignedMsgOrderParamsDelegateMessage, SignedMsgOrderParamsMessage } from '../types';
|
|
4
|
+
export type AnchorTypesCoder = {
|
|
5
|
+
encode: (typeName: string, value: any) => Buffer;
|
|
6
|
+
decode: (typeName: string, buffer: Buffer) => any;
|
|
7
|
+
};
|
|
8
|
+
export declare function encodeSignedMsgOrderParamsMessage(args: {
|
|
9
|
+
coderTypes: AnchorTypesCoder;
|
|
10
|
+
orderParamsMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage;
|
|
11
|
+
delegateSigner?: boolean;
|
|
12
|
+
}): Buffer;
|
|
13
|
+
export declare function decodeSignedMsgOrderParamsMessage(args: {
|
|
14
|
+
coderTypes: AnchorTypesCoder;
|
|
15
|
+
encodedMessage: Buffer;
|
|
16
|
+
delegateSigner?: boolean;
|
|
17
|
+
}): SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage;
|