@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
package/src/config.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
MainnetSpotMarkets,
|
|
14
14
|
} from './constants/spotMarkets';
|
|
15
15
|
import { OracleInfo } from './oracles/types';
|
|
16
|
-
import { Program, ProgramAccount } from '
|
|
16
|
+
import { Program, ProgramAccount } from './isomorphic/anchor';
|
|
17
17
|
import { getOracleId } from './oracles/oracleId';
|
|
18
18
|
import { Drift } from './idl/drift';
|
|
19
19
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
FIVE,
|
|
11
11
|
} from './numericConstants';
|
|
12
12
|
import { OracleSource } from '../types';
|
|
13
|
-
import { BN } from '
|
|
13
|
+
import { BN } from '../isomorphic/anchor';
|
|
14
14
|
import { DriftEnv } from '../config';
|
|
15
15
|
import { MarketStatus } from '@ellipsis-labs/phoenix-sdk';
|
|
16
16
|
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AccountMeta,
|
|
3
|
+
Connection,
|
|
4
|
+
PublicKey,
|
|
5
|
+
TransactionInstruction,
|
|
6
|
+
} from '@solana/web3.js';
|
|
7
|
+
|
|
8
|
+
import * as pdas from '../addresses/pda';
|
|
9
|
+
import * as constants from '../constants';
|
|
10
|
+
import { decodeUser } from '../decode/user';
|
|
11
|
+
import { CustomBorshCoder } from '../decode/customCoder';
|
|
12
|
+
import driftIDL from '../idl/drift.json';
|
|
13
|
+
import type { Drift } from '../idl/drift';
|
|
14
|
+
import type { UserAccount } from '../types';
|
|
15
|
+
import type { DriftProgram } from '../config';
|
|
16
|
+
import { fetchAccount } from '../accounts/fetch';
|
|
17
|
+
import type { BN } from '@coral-xyz/anchor';
|
|
18
|
+
import { buildDepositInstruction } from './instructions/deposit';
|
|
19
|
+
import { buildWithdrawInstruction } from './instructions/withdraw';
|
|
20
|
+
import {
|
|
21
|
+
buildCancelOrdersInstruction,
|
|
22
|
+
buildPlaceOrdersInstruction,
|
|
23
|
+
} from './instructions/orders';
|
|
24
|
+
import { buildFillPerpOrderInstruction } from './instructions/fill';
|
|
25
|
+
import { buildTriggerOrderInstruction } from './instructions/trigger';
|
|
26
|
+
import { buildSettlePnlInstruction } from './instructions/settlement';
|
|
27
|
+
import { buildLiquidatePerpInstruction } from './instructions/liquidation';
|
|
28
|
+
import { buildUpdateFundingRateInstruction } from './instructions/funding';
|
|
29
|
+
import {
|
|
30
|
+
buildCancelOrderByUserIdInstruction,
|
|
31
|
+
buildCancelOrderInstruction,
|
|
32
|
+
buildCancelOrdersByIdsInstruction,
|
|
33
|
+
buildModifyOrderByUserIdInstruction,
|
|
34
|
+
buildModifyOrderInstruction,
|
|
35
|
+
buildPlaceAndMakePerpOrderInstruction,
|
|
36
|
+
buildPlaceAndTakePerpOrderInstruction,
|
|
37
|
+
buildPlacePerpOrderInstruction,
|
|
38
|
+
} from './instructions/perpOrders';
|
|
39
|
+
import * as remainingAccounts from './remainingAccounts';
|
|
40
|
+
import * as signedMsg from './signedMsg';
|
|
41
|
+
|
|
42
|
+
export type DriftCoreContext = {
|
|
43
|
+
/** Drift program id. */
|
|
44
|
+
programId: PublicKey;
|
|
45
|
+
|
|
46
|
+
/** Anchor IDL json for Drift (defaults to bundled `idl/drift.json`). */
|
|
47
|
+
idl?: Drift;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* DriftCore is the minimal, core SDK surface:
|
|
52
|
+
* - No subscriptions / polling / websockets.
|
|
53
|
+
* - Pure helpers for PDAs, decoding, constants, and instruction building.
|
|
54
|
+
*
|
|
55
|
+
* Transaction/instruction builders will be progressively moved here from `DriftClient`.
|
|
56
|
+
*/
|
|
57
|
+
export class DriftCore {
|
|
58
|
+
/** Re-export PDA helpers (pure). */
|
|
59
|
+
static readonly pdas = pdas;
|
|
60
|
+
|
|
61
|
+
/** Re-export SDK constants (market configs, numeric constants, etc). */
|
|
62
|
+
static readonly constants = constants;
|
|
63
|
+
|
|
64
|
+
/** Re-export remaining-accounts logic (pure). */
|
|
65
|
+
static readonly remainingAccounts = remainingAccounts;
|
|
66
|
+
static readonly signedMsg = signedMsg;
|
|
67
|
+
|
|
68
|
+
static defaultIdl(): Drift {
|
|
69
|
+
return driftIDL as unknown as Drift;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static coder(idl: Drift = DriftCore.defaultIdl()): CustomBorshCoder {
|
|
73
|
+
return new CustomBorshCoder(idl as any);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Decode a Drift `User` account buffer without creating a Program. */
|
|
77
|
+
static decodeUserAccount(buffer: Buffer): UserAccount {
|
|
78
|
+
return decodeUser(buffer);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Fetch and decode a Drift `User` account. */
|
|
82
|
+
static async fetchUserAccount(
|
|
83
|
+
connection: Connection,
|
|
84
|
+
userAccountPublicKey: PublicKey
|
|
85
|
+
): Promise<UserAccount | null> {
|
|
86
|
+
const data = await fetchAccount(connection, userAccountPublicKey);
|
|
87
|
+
return data ? DriftCore.decodeUserAccount(data) : null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static async buildDepositInstruction(args: {
|
|
91
|
+
program: DriftProgram;
|
|
92
|
+
marketIndex: number;
|
|
93
|
+
amount: BN;
|
|
94
|
+
reduceOnly: boolean;
|
|
95
|
+
state: PublicKey;
|
|
96
|
+
spotMarket: PublicKey;
|
|
97
|
+
spotMarketVault: PublicKey;
|
|
98
|
+
user: PublicKey;
|
|
99
|
+
userStats: PublicKey;
|
|
100
|
+
userTokenAccount: PublicKey;
|
|
101
|
+
authority: PublicKey;
|
|
102
|
+
tokenProgram: PublicKey;
|
|
103
|
+
remainingAccounts: AccountMeta[];
|
|
104
|
+
}): Promise<TransactionInstruction> {
|
|
105
|
+
return await buildDepositInstruction(args);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static async buildWithdrawInstruction(args: {
|
|
109
|
+
program: DriftProgram;
|
|
110
|
+
marketIndex: number;
|
|
111
|
+
amount: BN;
|
|
112
|
+
reduceOnly: boolean;
|
|
113
|
+
state: PublicKey;
|
|
114
|
+
spotMarket: PublicKey;
|
|
115
|
+
spotMarketVault: PublicKey;
|
|
116
|
+
driftSigner: PublicKey;
|
|
117
|
+
user: PublicKey;
|
|
118
|
+
userStats: PublicKey;
|
|
119
|
+
userTokenAccount: PublicKey;
|
|
120
|
+
authority: PublicKey;
|
|
121
|
+
tokenProgram: PublicKey;
|
|
122
|
+
remainingAccounts: AccountMeta[];
|
|
123
|
+
}): Promise<TransactionInstruction> {
|
|
124
|
+
return await buildWithdrawInstruction(args);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static async buildPlaceOrdersInstruction(args: {
|
|
128
|
+
program: DriftProgram;
|
|
129
|
+
formattedParams: any[];
|
|
130
|
+
state: PublicKey;
|
|
131
|
+
user: PublicKey;
|
|
132
|
+
userStats: PublicKey;
|
|
133
|
+
authority: PublicKey;
|
|
134
|
+
remainingAccounts: AccountMeta[];
|
|
135
|
+
}): Promise<TransactionInstruction> {
|
|
136
|
+
return await buildPlaceOrdersInstruction(args);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static async buildCancelOrdersInstruction(args: {
|
|
140
|
+
program: DriftProgram;
|
|
141
|
+
marketType: any;
|
|
142
|
+
marketIndex: number | null;
|
|
143
|
+
direction: any;
|
|
144
|
+
user: PublicKey;
|
|
145
|
+
state: PublicKey;
|
|
146
|
+
userStats: PublicKey;
|
|
147
|
+
authority: PublicKey;
|
|
148
|
+
remainingAccounts: AccountMeta[];
|
|
149
|
+
}): Promise<TransactionInstruction> {
|
|
150
|
+
return await buildCancelOrdersInstruction(args);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static async buildFillPerpOrderInstruction(args: {
|
|
154
|
+
program: DriftProgram;
|
|
155
|
+
orderId: number | null;
|
|
156
|
+
state: PublicKey;
|
|
157
|
+
filler: PublicKey;
|
|
158
|
+
fillerStats: PublicKey;
|
|
159
|
+
user: PublicKey;
|
|
160
|
+
userStats: PublicKey;
|
|
161
|
+
authority: PublicKey;
|
|
162
|
+
remainingAccounts: AccountMeta[];
|
|
163
|
+
}): Promise<TransactionInstruction> {
|
|
164
|
+
return await buildFillPerpOrderInstruction(args);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static async buildTriggerOrderInstruction(args: {
|
|
168
|
+
program: DriftProgram;
|
|
169
|
+
orderId: number;
|
|
170
|
+
state: PublicKey;
|
|
171
|
+
filler: PublicKey;
|
|
172
|
+
user: PublicKey;
|
|
173
|
+
authority: PublicKey;
|
|
174
|
+
remainingAccounts: AccountMeta[];
|
|
175
|
+
}): Promise<TransactionInstruction> {
|
|
176
|
+
return await buildTriggerOrderInstruction(args);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static async buildSettlePnlInstruction(args: {
|
|
180
|
+
program: DriftProgram;
|
|
181
|
+
marketIndex: number;
|
|
182
|
+
state: PublicKey;
|
|
183
|
+
authority: PublicKey;
|
|
184
|
+
user: PublicKey;
|
|
185
|
+
spotMarketVault: PublicKey;
|
|
186
|
+
remainingAccounts: AccountMeta[];
|
|
187
|
+
}): Promise<TransactionInstruction> {
|
|
188
|
+
return await buildSettlePnlInstruction(args);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
static async buildLiquidatePerpInstruction(args: {
|
|
192
|
+
program: DriftProgram;
|
|
193
|
+
marketIndex: number;
|
|
194
|
+
maxBaseAssetAmount: any;
|
|
195
|
+
limitPrice: any | null;
|
|
196
|
+
state: PublicKey;
|
|
197
|
+
authority: PublicKey;
|
|
198
|
+
user: PublicKey;
|
|
199
|
+
userStats: PublicKey;
|
|
200
|
+
liquidator: PublicKey;
|
|
201
|
+
liquidatorStats: PublicKey;
|
|
202
|
+
remainingAccounts: AccountMeta[];
|
|
203
|
+
}): Promise<TransactionInstruction> {
|
|
204
|
+
return await buildLiquidatePerpInstruction(args);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
static async buildPlacePerpOrderInstruction(args: {
|
|
208
|
+
program: DriftProgram;
|
|
209
|
+
orderParams: any;
|
|
210
|
+
state: PublicKey;
|
|
211
|
+
user: PublicKey;
|
|
212
|
+
userStats: PublicKey;
|
|
213
|
+
authority: PublicKey;
|
|
214
|
+
remainingAccounts: AccountMeta[];
|
|
215
|
+
}): Promise<TransactionInstruction> {
|
|
216
|
+
return await buildPlacePerpOrderInstruction(args);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
static async buildPlaceAndTakePerpOrderInstruction(args: {
|
|
220
|
+
program: DriftProgram;
|
|
221
|
+
orderParams: any;
|
|
222
|
+
optionalParams: number | null;
|
|
223
|
+
state: PublicKey;
|
|
224
|
+
user: PublicKey;
|
|
225
|
+
userStats: PublicKey;
|
|
226
|
+
authority: PublicKey;
|
|
227
|
+
remainingAccounts: AccountMeta[];
|
|
228
|
+
}): Promise<TransactionInstruction> {
|
|
229
|
+
return await buildPlaceAndTakePerpOrderInstruction(args);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
static async buildPlaceAndMakePerpOrderInstruction(args: {
|
|
233
|
+
program: DriftProgram;
|
|
234
|
+
orderParams: any;
|
|
235
|
+
takerOrderId: number;
|
|
236
|
+
state: PublicKey;
|
|
237
|
+
user: PublicKey;
|
|
238
|
+
userStats: PublicKey;
|
|
239
|
+
taker: PublicKey;
|
|
240
|
+
takerStats: PublicKey;
|
|
241
|
+
authority: PublicKey;
|
|
242
|
+
remainingAccounts: AccountMeta[];
|
|
243
|
+
}): Promise<TransactionInstruction> {
|
|
244
|
+
return await buildPlaceAndMakePerpOrderInstruction(args);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
static async buildCancelOrderInstruction(args: {
|
|
248
|
+
program: DriftProgram;
|
|
249
|
+
orderId: number | null;
|
|
250
|
+
state: PublicKey;
|
|
251
|
+
user: PublicKey;
|
|
252
|
+
authority: PublicKey;
|
|
253
|
+
remainingAccounts: AccountMeta[];
|
|
254
|
+
}): Promise<TransactionInstruction> {
|
|
255
|
+
return await buildCancelOrderInstruction(args);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
static async buildCancelOrderByUserIdInstruction(args: {
|
|
259
|
+
program: DriftProgram;
|
|
260
|
+
userOrderId: number;
|
|
261
|
+
state: PublicKey;
|
|
262
|
+
user: PublicKey;
|
|
263
|
+
authority: PublicKey;
|
|
264
|
+
oracle: PublicKey;
|
|
265
|
+
remainingAccounts: AccountMeta[];
|
|
266
|
+
}): Promise<TransactionInstruction> {
|
|
267
|
+
return await buildCancelOrderByUserIdInstruction(args);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
static async buildCancelOrdersByIdsInstruction(args: {
|
|
271
|
+
program: DriftProgram;
|
|
272
|
+
orderIds: number[] | undefined;
|
|
273
|
+
state: PublicKey;
|
|
274
|
+
user: PublicKey;
|
|
275
|
+
authority: PublicKey;
|
|
276
|
+
remainingAccounts: AccountMeta[];
|
|
277
|
+
}): Promise<TransactionInstruction> {
|
|
278
|
+
return await buildCancelOrdersByIdsInstruction(args);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
static async buildModifyOrderInstruction(args: {
|
|
282
|
+
program: DriftProgram;
|
|
283
|
+
orderId: number;
|
|
284
|
+
modifyParams: any;
|
|
285
|
+
state: PublicKey;
|
|
286
|
+
user: PublicKey;
|
|
287
|
+
userStats: PublicKey;
|
|
288
|
+
authority: PublicKey;
|
|
289
|
+
remainingAccounts: AccountMeta[];
|
|
290
|
+
}): Promise<TransactionInstruction> {
|
|
291
|
+
return await buildModifyOrderInstruction(args);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
static async buildModifyOrderByUserIdInstruction(args: {
|
|
295
|
+
program: DriftProgram;
|
|
296
|
+
userOrderId: number;
|
|
297
|
+
modifyParams: any;
|
|
298
|
+
state: PublicKey;
|
|
299
|
+
user: PublicKey;
|
|
300
|
+
userStats: PublicKey;
|
|
301
|
+
authority: PublicKey;
|
|
302
|
+
remainingAccounts: AccountMeta[];
|
|
303
|
+
}): Promise<TransactionInstruction> {
|
|
304
|
+
return await buildModifyOrderByUserIdInstruction(args);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
static async buildUpdateFundingRateInstruction(args: {
|
|
308
|
+
program: DriftProgram;
|
|
309
|
+
perpMarketIndex: number;
|
|
310
|
+
state: PublicKey;
|
|
311
|
+
perpMarket: PublicKey;
|
|
312
|
+
oracle: PublicKey;
|
|
313
|
+
}): Promise<TransactionInstruction> {
|
|
314
|
+
return await buildUpdateFundingRateInstruction(args);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Placeholder for instruction builders.
|
|
319
|
+
*
|
|
320
|
+
* In follow-up refactors, DriftClient methods like `getDepositInstruction`,
|
|
321
|
+
* `getPlaceOrdersIx`, etc. will be moved here as pure builders.
|
|
322
|
+
*/
|
|
323
|
+
static buildInstructions(_ctx: DriftCoreContext): TransactionInstruction[] {
|
|
324
|
+
return [];
|
|
325
|
+
}
|
|
326
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './DriftCore';
|
|
2
|
+
export * from './remainingAccounts';
|
|
3
|
+
export * from './signedMsg';
|
|
4
|
+
export * from './instructions/deposit';
|
|
5
|
+
export * from './instructions/withdraw';
|
|
6
|
+
export * from './instructions/orders';
|
|
7
|
+
export * from './instructions/fill';
|
|
8
|
+
export * from './instructions/trigger';
|
|
9
|
+
export * from './instructions/settlement';
|
|
10
|
+
export * from './instructions/liquidation';
|
|
11
|
+
export * from './instructions/perpOrders';
|
|
12
|
+
export * from './instructions/funding';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AccountMeta,
|
|
3
|
+
PublicKey,
|
|
4
|
+
TransactionInstruction,
|
|
5
|
+
} from '@solana/web3.js';
|
|
6
|
+
import type { BN } from '../../isomorphic/anchor';
|
|
7
|
+
import type { DriftProgram } from '../../config';
|
|
8
|
+
|
|
9
|
+
export async function buildDepositInstruction(args: {
|
|
10
|
+
program: DriftProgram;
|
|
11
|
+
marketIndex: number;
|
|
12
|
+
amount: BN;
|
|
13
|
+
reduceOnly: boolean;
|
|
14
|
+
state: PublicKey;
|
|
15
|
+
spotMarket: PublicKey;
|
|
16
|
+
spotMarketVault: PublicKey;
|
|
17
|
+
user: PublicKey;
|
|
18
|
+
userStats: PublicKey;
|
|
19
|
+
userTokenAccount: PublicKey;
|
|
20
|
+
authority: PublicKey;
|
|
21
|
+
tokenProgram: PublicKey;
|
|
22
|
+
remainingAccounts: AccountMeta[];
|
|
23
|
+
}): Promise<TransactionInstruction> {
|
|
24
|
+
return await (args.program.instruction as any).deposit(
|
|
25
|
+
args.marketIndex,
|
|
26
|
+
args.amount,
|
|
27
|
+
args.reduceOnly,
|
|
28
|
+
{
|
|
29
|
+
accounts: {
|
|
30
|
+
state: args.state,
|
|
31
|
+
spotMarket: args.spotMarket,
|
|
32
|
+
spotMarketVault: args.spotMarketVault,
|
|
33
|
+
user: args.user,
|
|
34
|
+
userStats: args.userStats,
|
|
35
|
+
userTokenAccount: args.userTokenAccount,
|
|
36
|
+
authority: args.authority,
|
|
37
|
+
tokenProgram: args.tokenProgram,
|
|
38
|
+
},
|
|
39
|
+
remainingAccounts: args.remainingAccounts,
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AccountMeta,
|
|
3
|
+
PublicKey,
|
|
4
|
+
TransactionInstruction,
|
|
5
|
+
} from '@solana/web3.js';
|
|
6
|
+
import type { DriftProgram } from '../../config';
|
|
7
|
+
|
|
8
|
+
export async function buildFillPerpOrderInstruction(args: {
|
|
9
|
+
program: DriftProgram;
|
|
10
|
+
orderId: number | null;
|
|
11
|
+
state: PublicKey;
|
|
12
|
+
filler: PublicKey;
|
|
13
|
+
fillerStats: PublicKey;
|
|
14
|
+
user: PublicKey;
|
|
15
|
+
userStats: PublicKey;
|
|
16
|
+
authority: PublicKey;
|
|
17
|
+
remainingAccounts: AccountMeta[];
|
|
18
|
+
}): Promise<TransactionInstruction> {
|
|
19
|
+
return await (args.program.instruction as any).fillPerpOrder(
|
|
20
|
+
args.orderId,
|
|
21
|
+
null,
|
|
22
|
+
{
|
|
23
|
+
accounts: {
|
|
24
|
+
state: args.state,
|
|
25
|
+
filler: args.filler,
|
|
26
|
+
fillerStats: args.fillerStats,
|
|
27
|
+
user: args.user,
|
|
28
|
+
userStats: args.userStats,
|
|
29
|
+
authority: args.authority,
|
|
30
|
+
},
|
|
31
|
+
remainingAccounts: args.remainingAccounts,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import type { DriftProgram } from '../../config';
|
|
3
|
+
|
|
4
|
+
export async function buildUpdateFundingRateInstruction(args: {
|
|
5
|
+
program: DriftProgram;
|
|
6
|
+
perpMarketIndex: number;
|
|
7
|
+
state: PublicKey;
|
|
8
|
+
perpMarket: PublicKey;
|
|
9
|
+
oracle: PublicKey;
|
|
10
|
+
}): Promise<TransactionInstruction> {
|
|
11
|
+
return await (args.program.instruction as any).updateFundingRate(
|
|
12
|
+
args.perpMarketIndex,
|
|
13
|
+
{
|
|
14
|
+
accounts: {
|
|
15
|
+
state: args.state,
|
|
16
|
+
perpMarket: args.perpMarket,
|
|
17
|
+
oracle: args.oracle,
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AccountMeta,
|
|
3
|
+
PublicKey,
|
|
4
|
+
TransactionInstruction,
|
|
5
|
+
} from '@solana/web3.js';
|
|
6
|
+
import type { DriftProgram } from '../../config';
|
|
7
|
+
|
|
8
|
+
export async function buildLiquidatePerpInstruction(args: {
|
|
9
|
+
program: DriftProgram;
|
|
10
|
+
marketIndex: number;
|
|
11
|
+
maxBaseAssetAmount: any;
|
|
12
|
+
limitPrice: any | null;
|
|
13
|
+
state: PublicKey;
|
|
14
|
+
authority: PublicKey;
|
|
15
|
+
user: PublicKey;
|
|
16
|
+
userStats: PublicKey;
|
|
17
|
+
liquidator: PublicKey;
|
|
18
|
+
liquidatorStats: PublicKey;
|
|
19
|
+
remainingAccounts: AccountMeta[];
|
|
20
|
+
}): Promise<TransactionInstruction> {
|
|
21
|
+
return await (args.program.instruction as any).liquidatePerp(
|
|
22
|
+
args.marketIndex,
|
|
23
|
+
args.maxBaseAssetAmount,
|
|
24
|
+
args.limitPrice,
|
|
25
|
+
{
|
|
26
|
+
accounts: {
|
|
27
|
+
state: args.state,
|
|
28
|
+
authority: args.authority,
|
|
29
|
+
user: args.user,
|
|
30
|
+
userStats: args.userStats,
|
|
31
|
+
liquidator: args.liquidator,
|
|
32
|
+
liquidatorStats: args.liquidatorStats,
|
|
33
|
+
},
|
|
34
|
+
remainingAccounts: args.remainingAccounts,
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AccountMeta,
|
|
3
|
+
PublicKey,
|
|
4
|
+
TransactionInstruction,
|
|
5
|
+
} from '@solana/web3.js';
|
|
6
|
+
import type { DriftProgram } from '../../config';
|
|
7
|
+
|
|
8
|
+
export async function buildPlaceOrdersInstruction(args: {
|
|
9
|
+
program: DriftProgram;
|
|
10
|
+
formattedParams: any[];
|
|
11
|
+
state: PublicKey;
|
|
12
|
+
user: PublicKey;
|
|
13
|
+
userStats: PublicKey;
|
|
14
|
+
authority: PublicKey;
|
|
15
|
+
remainingAccounts: AccountMeta[];
|
|
16
|
+
}): Promise<TransactionInstruction> {
|
|
17
|
+
return await (args.program.instruction as any).placeOrders(
|
|
18
|
+
args.formattedParams,
|
|
19
|
+
{
|
|
20
|
+
accounts: {
|
|
21
|
+
state: args.state,
|
|
22
|
+
user: args.user,
|
|
23
|
+
userStats: args.userStats,
|
|
24
|
+
authority: args.authority,
|
|
25
|
+
},
|
|
26
|
+
remainingAccounts: args.remainingAccounts,
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function buildCancelOrdersInstruction(args: {
|
|
32
|
+
program: DriftProgram;
|
|
33
|
+
marketType: any;
|
|
34
|
+
marketIndex: number | null;
|
|
35
|
+
direction: any;
|
|
36
|
+
user: PublicKey;
|
|
37
|
+
state: PublicKey;
|
|
38
|
+
userStats: PublicKey;
|
|
39
|
+
authority: PublicKey;
|
|
40
|
+
remainingAccounts: AccountMeta[];
|
|
41
|
+
}): Promise<TransactionInstruction> {
|
|
42
|
+
return await (args.program.instruction as any).cancelOrders(
|
|
43
|
+
args.marketType,
|
|
44
|
+
args.marketIndex,
|
|
45
|
+
args.direction,
|
|
46
|
+
{
|
|
47
|
+
accounts: {
|
|
48
|
+
state: args.state,
|
|
49
|
+
user: args.user,
|
|
50
|
+
userStats: args.userStats,
|
|
51
|
+
authority: args.authority,
|
|
52
|
+
},
|
|
53
|
+
remainingAccounts: args.remainingAccounts,
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|