@drift-labs/sdk-browser 2.163.0-beta.11 → 2.163.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -1
- package/bun.lock +26 -13
- package/lib/browser/accounts/fetch.d.ts +9 -0
- package/lib/browser/accounts/fetch.js +14 -1
- package/lib/browser/addresses/pda.d.ts +1 -1
- package/lib/browser/addresses/pda.js +2 -2
- package/lib/browser/adminClient.d.ts +1 -1
- package/lib/browser/adminClient.js +2 -2
- package/lib/browser/bankrun/bankrunConnection.d.ts +1 -1
- package/lib/browser/bankrun/bankrunConnection.js +1 -1
- package/lib/browser/clock/clockSubscriber.js +1 -1
- package/lib/browser/config.d.ts +1 -1
- package/lib/browser/constants/numericConstants.d.ts +1 -1
- package/lib/browser/constants/numericConstants.js +1 -1
- package/lib/browser/constants/perpMarkets.js +1 -1
- package/lib/browser/constants/spotMarkets.d.ts +1 -1
- package/lib/browser/constants/spotMarkets.js +4 -3
- package/lib/browser/core/DriftCore.d.ts +224 -0
- package/lib/browser/core/DriftCore.js +138 -0
- package/lib/browser/core/index.d.ts +12 -0
- package/lib/browser/core/index.js +28 -0
- package/lib/browser/core/instructions/deposit.d.ts +19 -0
- package/lib/browser/core/instructions/deposit.js +19 -0
- package/lib/browser/core/instructions/fill.d.ts +13 -0
- package/lib/browser/core/instructions/fill.js +17 -0
- package/lib/browser/core/instructions/funding.d.ts +9 -0
- package/lib/browser/core/instructions/funding.js +13 -0
- package/lib/browser/core/instructions/liquidation.d.ts +15 -0
- package/lib/browser/core/instructions/liquidation.js +17 -0
- package/lib/browser/core/instructions/orders.d.ts +22 -0
- package/lib/browser/core/instructions/orders.js +27 -0
- package/lib/browser/core/instructions/perpOrders.d.ts +78 -0
- package/lib/browser/core/instructions/perpOrders.js +99 -0
- package/lib/browser/core/instructions/settlement.d.ts +11 -0
- package/lib/browser/core/instructions/settlement.js +15 -0
- package/lib/browser/core/instructions/trigger.d.ts +11 -0
- package/lib/browser/core/instructions/trigger.js +15 -0
- package/lib/browser/core/instructions/withdraw.d.ts +20 -0
- package/lib/browser/core/instructions/withdraw.js +20 -0
- package/lib/browser/core/remainingAccounts.d.ts +27 -0
- package/lib/browser/core/remainingAccounts.js +122 -0
- package/lib/browser/core/signedMsg.d.ts +17 -0
- package/lib/browser/core/signedMsg.js +39 -0
- package/lib/browser/decode/customCoder.d.ts +1 -1
- package/lib/browser/decode/customCoder.js +1 -1
- package/lib/browser/decode/user.js +1 -1
- package/lib/browser/dlob/DLOB.d.ts +1 -1
- package/lib/browser/dlob/DLOB.js +1 -1
- package/lib/browser/dlob/DLOBNode.d.ts +1 -1
- package/lib/browser/dlob/DLOBNode.js +1 -1
- package/lib/browser/dlob/DLOBSubscriber.d.ts +1 -1
- package/lib/browser/dlob/NodeList.d.ts +1 -1
- package/lib/browser/dlob/orderBookLevels.d.ts +1 -1
- package/lib/browser/dlob/orderBookLevels.js +1 -1
- package/lib/browser/driftClient.d.ts +17 -24
- package/lib/browser/driftClient.js +192 -291
- package/lib/browser/driftClientConfig.d.ts +1 -1
- package/lib/browser/events/eventSubscriber.d.ts +1 -1
- package/lib/browser/events/fetchLogs.d.ts +1 -1
- package/lib/browser/events/parse.d.ts +1 -1
- package/lib/browser/factory/bigNum.d.ts +1 -1
- package/lib/browser/factory/bigNum.js +1 -1
- package/lib/browser/factory/oracleClient.js +1 -1
- package/lib/browser/index.d.ts +2 -1
- package/lib/browser/index.js +2 -1
- package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +1 -1
- package/lib/browser/isomorphic/anchor.browser.d.ts +24 -0
- package/lib/browser/isomorphic/anchor.browser.js +60 -0
- package/lib/browser/isomorphic/anchor.d.ts +24 -0
- package/lib/browser/isomorphic/anchor.js +60 -0
- package/lib/browser/isomorphic/anchor29.browser.d.ts +12 -0
- package/lib/browser/isomorphic/anchor29.browser.js +48 -0
- package/lib/browser/isomorphic/anchor29.d.ts +12 -0
- package/lib/browser/isomorphic/anchor29.js +48 -0
- package/lib/browser/jupiter/jupiterClient.d.ts +1 -1
- package/lib/browser/marginCalculation.d.ts +1 -1
- package/lib/browser/marinade/index.d.ts +1 -1
- package/lib/browser/marinade/index.js +2 -2
- package/lib/browser/math/amm.d.ts +1 -1
- package/lib/browser/math/amm.js +1 -1
- package/lib/browser/math/auction.d.ts +1 -1
- package/lib/browser/math/auction.js +1 -1
- package/lib/browser/math/conversion.d.ts +1 -1
- package/lib/browser/math/conversion.js +1 -1
- package/lib/browser/math/exchangeStatus.js +1 -1
- package/lib/browser/math/fuel.d.ts +1 -1
- package/lib/browser/math/fuel.js +1 -1
- package/lib/browser/math/funding.d.ts +1 -1
- package/lib/browser/math/funding.js +1 -1
- package/lib/browser/math/insurance.d.ts +1 -1
- package/lib/browser/math/insurance.js +1 -1
- package/lib/browser/math/liquidation.d.ts +1 -1
- package/lib/browser/math/liquidation.js +1 -1
- package/lib/browser/math/margin.d.ts +1 -1
- package/lib/browser/math/margin.js +1 -1
- package/lib/browser/math/market.d.ts +1 -1
- package/lib/browser/math/market.js +1 -1
- package/lib/browser/math/oracles.d.ts +1 -1
- package/lib/browser/math/oracles.js +1 -1
- package/lib/browser/math/orders.d.ts +1 -1
- package/lib/browser/math/orders.js +1 -1
- package/lib/browser/math/position.d.ts +1 -1
- package/lib/browser/math/position.js +1 -1
- package/lib/browser/math/protectedMakerParams.js +1 -1
- package/lib/browser/math/repeg.d.ts +1 -1
- package/lib/browser/math/repeg.js +1 -1
- package/lib/browser/math/spotBalance.d.ts +1 -1
- package/lib/browser/math/spotBalance.js +1 -1
- package/lib/browser/math/spotMarket.d.ts +1 -1
- package/lib/browser/math/spotMarket.js +1 -1
- package/lib/browser/math/spotPosition.d.ts +1 -1
- package/lib/browser/math/spotPosition.js +1 -1
- package/lib/browser/math/state.d.ts +1 -1
- package/lib/browser/math/state.js +1 -1
- package/lib/browser/math/superStake.d.ts +1 -1
- package/lib/browser/math/superStake.js +1 -1
- package/lib/browser/math/trade.d.ts +1 -1
- package/lib/browser/math/trade.js +1 -1
- package/lib/browser/math/utils.d.ts +1 -1
- package/lib/browser/math/utils.js +1 -1
- package/lib/browser/memcmp.js +8 -8
- package/lib/browser/openbook/openbookV2Subscriber.d.ts +1 -1
- package/lib/browser/openbook/openbookV2Subscriber.js +3 -3
- package/lib/browser/oracles/pythClient.d.ts +1 -1
- package/lib/browser/oracles/pythClient.js +1 -1
- package/lib/browser/oracles/pythLazerClient.d.ts +1 -1
- package/lib/browser/oracles/pythLazerClient.js +1 -1
- package/lib/browser/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/browser/oracles/strictOraclePrice.d.ts +1 -1
- package/lib/browser/oracles/strictOraclePrice.js +1 -1
- package/lib/browser/oracles/types.d.ts +1 -1
- package/lib/browser/oracles/utils.d.ts +1 -1
- package/lib/browser/orderParams.d.ts +1 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.js +1 -1
- package/lib/browser/phoenix/phoenixSubscriber.d.ts +1 -1
- package/lib/browser/phoenix/phoenixSubscriber.js +1 -1
- package/lib/browser/pyth/types.d.ts +1 -1
- package/lib/browser/serum/serumSubscriber.d.ts +1 -1
- package/lib/browser/serum/serumSubscriber.js +1 -1
- package/lib/browser/slot/SlothashSubscriber.js +6 -3
- package/lib/browser/swap/UnifiedSwapClient.d.ts +1 -1
- package/lib/browser/titan/titanClient.d.ts +1 -1
- package/lib/browser/tokenFaucet.d.ts +3 -3
- package/lib/browser/tokenFaucet.js +4 -4
- package/lib/browser/types.d.ts +1 -1
- package/lib/browser/user.d.ts +1 -1
- package/lib/browser/user.js +1 -1
- package/lib/browser/userMap/referrerMap.js +7 -4
- package/lib/browser/userStats.d.ts +1 -1
- package/lib/browser/userStats.js +1 -1
- package/lib/node/accounts/fetch.d.ts +9 -0
- package/lib/node/accounts/fetch.d.ts.map +1 -1
- package/lib/node/accounts/fetch.js +14 -1
- package/lib/node/addresses/pda.d.ts +1 -1
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +2 -2
- package/lib/node/adminClient.d.ts +1 -1
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +2 -2
- package/lib/node/bankrun/bankrunConnection.d.ts +1 -1
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.js +1 -1
- package/lib/node/clock/clockSubscriber.js +1 -1
- package/lib/node/config.d.ts +1 -1
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.d.ts +1 -1
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +1 -1
- package/lib/node/constants/perpMarkets.js +1 -1
- package/lib/node/constants/spotMarkets.d.ts +1 -1
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +4 -3
- package/lib/node/core/DriftCore.d.ts +225 -0
- package/lib/node/core/DriftCore.d.ts.map +1 -0
- package/lib/node/core/DriftCore.js +138 -0
- package/lib/node/core/index.d.ts +13 -0
- package/lib/node/core/index.d.ts.map +1 -0
- package/lib/node/core/index.js +28 -0
- package/lib/node/core/instructions/deposit.d.ts +20 -0
- package/lib/node/core/instructions/deposit.d.ts.map +1 -0
- package/lib/node/core/instructions/deposit.js +19 -0
- package/lib/node/core/instructions/fill.d.ts +14 -0
- package/lib/node/core/instructions/fill.d.ts.map +1 -0
- package/lib/node/core/instructions/fill.js +17 -0
- package/lib/node/core/instructions/funding.d.ts +10 -0
- package/lib/node/core/instructions/funding.d.ts.map +1 -0
- package/lib/node/core/instructions/funding.js +13 -0
- package/lib/node/core/instructions/liquidation.d.ts +16 -0
- package/lib/node/core/instructions/liquidation.d.ts.map +1 -0
- package/lib/node/core/instructions/liquidation.js +17 -0
- package/lib/node/core/instructions/orders.d.ts +23 -0
- package/lib/node/core/instructions/orders.d.ts.map +1 -0
- package/lib/node/core/instructions/orders.js +27 -0
- package/lib/node/core/instructions/perpOrders.d.ts +79 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -0
- package/lib/node/core/instructions/perpOrders.js +99 -0
- package/lib/node/core/instructions/settlement.d.ts +12 -0
- package/lib/node/core/instructions/settlement.d.ts.map +1 -0
- package/lib/node/core/instructions/settlement.js +15 -0
- package/lib/node/core/instructions/trigger.d.ts +12 -0
- package/lib/node/core/instructions/trigger.d.ts.map +1 -0
- package/lib/node/core/instructions/trigger.js +15 -0
- package/lib/node/core/instructions/withdraw.d.ts +21 -0
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -0
- package/lib/node/core/instructions/withdraw.js +20 -0
- package/lib/node/core/remainingAccounts.d.ts +28 -0
- package/lib/node/core/remainingAccounts.d.ts.map +1 -0
- package/lib/node/core/remainingAccounts.js +122 -0
- package/lib/node/core/signedMsg.d.ts +18 -0
- package/lib/node/core/signedMsg.d.ts.map +1 -0
- package/lib/node/core/signedMsg.js +39 -0
- package/lib/node/decode/customCoder.d.ts +1 -1
- package/lib/node/decode/customCoder.d.ts.map +1 -1
- package/lib/node/decode/customCoder.js +1 -1
- package/lib/node/decode/user.js +1 -1
- package/lib/node/dlob/DLOB.d.ts +1 -1
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +1 -1
- package/lib/node/dlob/DLOBNode.d.ts +1 -1
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +1 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts +1 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.d.ts +1 -1
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.d.ts +1 -1
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +1 -1
- package/lib/node/driftClient.d.ts +17 -24
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +192 -291
- package/lib/node/driftClientConfig.d.ts +1 -1
- package/lib/node/driftClientConfig.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.d.ts +1 -1
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.d.ts +1 -1
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/parse.d.ts +1 -1
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/factory/bigNum.d.ts +1 -1
- package/lib/node/factory/bigNum.d.ts.map +1 -1
- package/lib/node/factory/bigNum.js +1 -1
- package/lib/node/factory/oracleClient.js +1 -1
- package/lib/node/index.d.ts +2 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +2 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +1 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -1
- package/lib/node/isomorphic/anchor.browser.d.ts +25 -0
- package/lib/node/isomorphic/anchor.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.browser.js +60 -0
- package/lib/node/isomorphic/anchor.d.ts +25 -0
- package/lib/node/isomorphic/anchor.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.js +60 -0
- package/lib/node/isomorphic/anchor.node.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.browser.d.ts +13 -0
- package/lib/node/isomorphic/anchor29.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.browser.js +48 -0
- package/lib/node/isomorphic/anchor29.d.ts +13 -0
- package/lib/node/isomorphic/anchor29.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.js +48 -0
- package/lib/node/isomorphic/anchor29.node.d.ts.map +1 -0
- package/lib/node/jupiter/jupiterClient.d.ts +1 -1
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/marginCalculation.d.ts +1 -1
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marinade/index.d.ts +1 -1
- package/lib/node/marinade/index.d.ts.map +1 -1
- package/lib/node/marinade/index.js +2 -2
- package/lib/node/math/amm.d.ts +1 -1
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +1 -1
- package/lib/node/math/auction.d.ts +1 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +1 -1
- package/lib/node/math/conversion.d.ts +1 -1
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/conversion.js +1 -1
- package/lib/node/math/exchangeStatus.js +1 -1
- package/lib/node/math/fuel.d.ts +1 -1
- package/lib/node/math/fuel.d.ts.map +1 -1
- package/lib/node/math/fuel.js +1 -1
- package/lib/node/math/funding.d.ts +1 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +1 -1
- package/lib/node/math/insurance.d.ts +1 -1
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +1 -1
- package/lib/node/math/liquidation.d.ts +1 -1
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/liquidation.js +1 -1
- package/lib/node/math/margin.d.ts +1 -1
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +1 -1
- package/lib/node/math/market.d.ts +1 -1
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +1 -1
- package/lib/node/math/oracles.d.ts +1 -1
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +1 -1
- package/lib/node/math/orders.d.ts +1 -1
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +1 -1
- package/lib/node/math/position.d.ts +1 -1
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +1 -1
- package/lib/node/math/protectedMakerParams.js +1 -1
- package/lib/node/math/repeg.d.ts +1 -1
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/repeg.js +1 -1
- package/lib/node/math/spotBalance.d.ts +1 -1
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +1 -1
- package/lib/node/math/spotMarket.d.ts +1 -1
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +1 -1
- package/lib/node/math/spotPosition.d.ts +1 -1
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/spotPosition.js +1 -1
- package/lib/node/math/state.d.ts +1 -1
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/state.js +1 -1
- package/lib/node/math/superStake.d.ts +1 -1
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +1 -1
- package/lib/node/math/trade.d.ts +1 -1
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +1 -1
- package/lib/node/math/utils.d.ts +1 -1
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/math/utils.js +1 -1
- package/lib/node/memcmp.js +8 -8
- package/lib/node/openbook/openbookV2Subscriber.d.ts +1 -1
- package/lib/node/openbook/openbookV2Subscriber.d.ts.map +1 -1
- package/lib/node/openbook/openbookV2Subscriber.js +3 -3
- package/lib/node/oracles/pythClient.d.ts +1 -1
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.js +1 -1
- package/lib/node/oracles/pythLazerClient.d.ts +1 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +1 -1
- package/lib/node/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/node/oracles/strictOraclePrice.d.ts +1 -1
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/strictOraclePrice.js +1 -1
- package/lib/node/oracles/types.d.ts +1 -1
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +1 -1
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/orderParams.d.ts +1 -1
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +1 -1
- package/lib/node/phoenix/phoenixSubscriber.d.ts +1 -1
- package/lib/node/phoenix/phoenixSubscriber.d.ts.map +1 -1
- package/lib/node/phoenix/phoenixSubscriber.js +1 -1
- package/lib/node/pyth/types.d.ts +1 -1
- package/lib/node/pyth/types.d.ts.map +1 -1
- package/lib/node/serum/serumSubscriber.d.ts +1 -1
- package/lib/node/serum/serumSubscriber.d.ts.map +1 -1
- package/lib/node/serum/serumSubscriber.js +1 -1
- package/lib/node/slot/SlothashSubscriber.js +6 -3
- package/lib/node/swap/UnifiedSwapClient.d.ts +1 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/titan/titanClient.d.ts +1 -1
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/tokenFaucet.d.ts +3 -3
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +4 -4
- package/lib/node/types.d.ts +1 -1
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts +1 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +1 -1
- package/lib/node/userMap/referrerMap.js +7 -4
- package/lib/node/userStats.d.ts +1 -1
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +1 -1
- package/package.json +4 -2
- package/scripts/postbuild.js +1 -1
- package/src/accounts/fetch.ts +27 -0
- package/src/accounts/webSocketAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketAccountSubscriberV2.ts +1 -1
- package/src/accounts/webSocketProgramAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +1 -1
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +1 -1
- package/src/addresses/pda.ts +2 -2
- package/src/adminClient.ts +2 -2
- package/src/bankrun/bankrunConnection.ts +1 -1
- package/src/clock/clockSubscriber.ts +1 -1
- package/src/config.ts +1 -1
- package/src/constants/numericConstants.ts +1 -1
- package/src/constants/perpMarkets.ts +1 -1
- package/src/constants/spotMarkets.ts +4 -3
- package/src/core/DriftCore.ts +326 -0
- package/src/core/index.ts +12 -0
- package/src/core/instructions/deposit.ts +42 -0
- package/src/core/instructions/fill.ts +34 -0
- package/src/core/instructions/funding.ts +21 -0
- package/src/core/instructions/liquidation.ts +37 -0
- package/src/core/instructions/orders.ts +56 -0
- package/src/core/instructions/perpOrders.ts +192 -0
- package/src/core/instructions/settlement.ts +26 -0
- package/src/core/instructions/trigger.ts +26 -0
- package/src/core/instructions/withdraw.ts +44 -0
- package/src/core/remainingAccounts.ts +276 -0
- package/src/core/signedMsg.ts +71 -0
- package/src/decode/customCoder.ts +1 -1
- package/src/decode/user.ts +1 -1
- package/src/dlob/DLOB.ts +1 -1
- package/src/dlob/DLOBNode.ts +1 -1
- package/src/dlob/DLOBSubscriber.ts +1 -1
- package/src/dlob/NodeList.ts +1 -1
- package/src/dlob/orderBookLevels.ts +1 -1
- package/src/driftClient.ts +207 -402
- package/src/driftClientConfig.ts +1 -1
- package/src/events/eventSubscriber.ts +1 -1
- package/src/events/fetchLogs.ts +1 -1
- package/src/events/parse.ts +1 -1
- package/src/factory/bigNum.ts +1 -1
- package/src/factory/oracleClient.ts +1 -1
- package/src/index.ts +2 -1
- package/src/indicative-quotes/indicativeQuotesSender.ts +1 -1
- package/src/isomorphic/anchor.browser.ts +44 -0
- package/src/isomorphic/anchor.node.ts +1 -0
- package/src/isomorphic/anchor.ts +1 -0
- package/src/isomorphic/anchor29.browser.ts +24 -0
- package/src/isomorphic/anchor29.node.ts +1 -0
- package/src/isomorphic/anchor29.ts +1 -0
- package/src/jupiter/jupiterClient.ts +1 -1
- package/src/marginCalculation.ts +1 -1
- package/src/marinade/index.ts +1 -1
- package/src/math/amm.ts +1 -1
- package/src/math/auction.ts +1 -1
- package/src/math/conversion.ts +1 -1
- package/src/math/exchangeStatus.ts +1 -1
- package/src/math/fuel.ts +1 -1
- package/src/math/funding.ts +1 -1
- package/src/math/insurance.ts +1 -1
- package/src/math/liquidation.ts +1 -1
- package/src/math/margin.ts +1 -1
- package/src/math/market.ts +1 -1
- package/src/math/oracles.ts +1 -1
- package/src/math/orders.ts +1 -1
- package/src/math/position.ts +1 -1
- package/src/math/protectedMakerParams.ts +1 -1
- package/src/math/repeg.ts +1 -1
- package/src/math/spotBalance.ts +1 -1
- package/src/math/spotMarket.ts +1 -1
- package/src/math/spotPosition.ts +1 -1
- package/src/math/state.ts +1 -1
- package/src/math/superStake.ts +1 -1
- package/src/math/trade.ts +1 -1
- package/src/math/utils.ts +1 -1
- package/src/memcmp.ts +1 -1
- package/src/openbook/openbookV2Subscriber.ts +7 -1
- package/src/oracles/pythClient.ts +1 -1
- package/src/oracles/pythLazerClient.ts +1 -1
- package/src/oracles/quoteAssetOracleClient.ts +1 -1
- package/src/oracles/strictOraclePrice.ts +1 -1
- package/src/oracles/types.ts +1 -1
- package/src/oracles/utils.ts +1 -1
- package/src/orderParams.ts +1 -1
- package/src/orderSubscriber/OrderSubscriber.ts +1 -1
- package/src/phoenix/phoenixSubscriber.ts +1 -1
- package/src/pyth/types.ts +1 -1
- package/src/serum/serumSubscriber.ts +1 -1
- package/src/slot/SlothashSubscriber.ts +2 -2
- package/src/swap/UnifiedSwapClient.ts +1 -1
- package/src/titan/titanClient.ts +1 -1
- package/src/tokenFaucet.ts +3 -3
- package/src/types.ts +1 -1
- package/src/user.ts +1 -1
- package/src/userMap/referrerMap.ts +1 -1
- package/src/userMap/userMap.ts +1 -1
- package/src/userStats.ts +1 -1
- package/tests/DriftCore/decode.test.ts +16 -0
- package/tests/DriftCore/fill_trigger.test.ts +73 -0
- package/tests/DriftCore/instructions.test.ts +46 -0
- package/tests/DriftCore/pdas.test.ts +29 -0
- package/tests/DriftCore/perp_orders.test.ts +205 -0
- package/tests/DriftCore/remainingAccounts.test.ts +70 -0
- package/tests/DriftCore/settlement_liquidation.test.ts +69 -0
package/src/driftClient.ts
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Instruction → on-chain handler mapping: see ARCHITECTURE.md § SDK↔Instruction Mapping.
|
|
14
14
|
*/
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
15
|
+
import { AnchorProvider, BN, Program } from './isomorphic/anchor';
|
|
16
|
+
import type { ProgramAccount } from '@coral-xyz/anchor';
|
|
17
17
|
import bs58 from 'bs58';
|
|
18
18
|
import {
|
|
19
19
|
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
ConstituentTargetBaseAccount,
|
|
77
77
|
AmmCache,
|
|
78
78
|
} from './types';
|
|
79
|
-
import
|
|
79
|
+
import { DriftCore } from './core/DriftCore';
|
|
80
80
|
|
|
81
81
|
/** Client-side guardrail; mirrors on-chain `ErrorCode::SpotDlobTradingDisabled`. */
|
|
82
82
|
const SPOT_DLOB_TRADING_DISABLED_MSG =
|
|
@@ -95,6 +95,7 @@ import {
|
|
|
95
95
|
SystemProgram,
|
|
96
96
|
SYSVAR_CLOCK_PUBKEY,
|
|
97
97
|
SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
98
|
+
SYSVAR_RENT_PUBKEY,
|
|
98
99
|
Transaction,
|
|
99
100
|
TransactionInstruction,
|
|
100
101
|
TransactionSignature,
|
|
@@ -205,8 +206,6 @@ import nacl from 'tweetnacl';
|
|
|
205
206
|
import { getOracleId } from './oracles/oracleId';
|
|
206
207
|
import { SignedMsgOrderParams } from './types';
|
|
207
208
|
import { TakerInfo } from './types';
|
|
208
|
-
// BN is already imported globally in this file via other imports
|
|
209
|
-
import { sha256 } from '@noble/hashes/sha256';
|
|
210
209
|
import { getOracleConfidenceFromMMOracleData } from './oracles/utils';
|
|
211
210
|
import { ConstituentMap } from './constituentMap/constituentMap';
|
|
212
211
|
import { hasBuilder } from './math/orders';
|
|
@@ -223,14 +222,8 @@ import { UnifiedSwapClient } from './swap/UnifiedSwapClient';
|
|
|
223
222
|
*/
|
|
224
223
|
export type SwapClient = TitanClient | JupiterClient;
|
|
225
224
|
|
|
226
|
-
type RemainingAccountParams =
|
|
227
|
-
|
|
228
|
-
writablePerpMarketIndexes?: number[];
|
|
229
|
-
writableSpotMarketIndexes?: number[];
|
|
230
|
-
readablePerpMarketIndex?: number | number[];
|
|
231
|
-
readableSpotMarketIndexes?: number[];
|
|
232
|
-
useMarketLastSlotCache?: boolean;
|
|
233
|
-
};
|
|
225
|
+
type RemainingAccountParams =
|
|
226
|
+
import('./core/remainingAccounts').RemainingAccountParams;
|
|
234
227
|
|
|
235
228
|
/**
|
|
236
229
|
* # DriftClient
|
|
@@ -348,7 +341,7 @@ export class DriftClient {
|
|
|
348
341
|
this.opts
|
|
349
342
|
);
|
|
350
343
|
this.program = new Program<Drift>(
|
|
351
|
-
|
|
344
|
+
DriftCore.defaultIdl() as unknown as Drift,
|
|
352
345
|
this.provider,
|
|
353
346
|
config.coder
|
|
354
347
|
);
|
|
@@ -859,7 +852,10 @@ export class DriftClient {
|
|
|
859
852
|
newWallet,
|
|
860
853
|
this.opts
|
|
861
854
|
);
|
|
862
|
-
const newProgram = new Program<Drift>(
|
|
855
|
+
const newProgram = new Program<Drift>(
|
|
856
|
+
DriftCore.defaultIdl() as unknown as Drift,
|
|
857
|
+
newProvider
|
|
858
|
+
);
|
|
863
859
|
|
|
864
860
|
this.skipLoadUsers = false;
|
|
865
861
|
// Update provider for txSender with new wallet details
|
|
@@ -1178,8 +1174,8 @@ export class DriftClient {
|
|
|
1178
1174
|
),
|
|
1179
1175
|
authority,
|
|
1180
1176
|
payer,
|
|
1181
|
-
rent:
|
|
1182
|
-
systemProgram:
|
|
1177
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
1178
|
+
systemProgram: SystemProgram.programId,
|
|
1183
1179
|
state: await this.getStatePublicKey(),
|
|
1184
1180
|
},
|
|
1185
1181
|
});
|
|
@@ -1226,8 +1222,8 @@ export class DriftClient {
|
|
|
1226
1222
|
signedMsgUserOrders: signedMsgUserAccountPublicKey,
|
|
1227
1223
|
authority,
|
|
1228
1224
|
payer,
|
|
1229
|
-
rent:
|
|
1230
|
-
systemProgram:
|
|
1225
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
1226
|
+
systemProgram: SystemProgram.programId,
|
|
1231
1227
|
},
|
|
1232
1228
|
});
|
|
1233
1229
|
|
|
@@ -1267,7 +1263,7 @@ export class DriftClient {
|
|
|
1267
1263
|
signedMsgUserOrders: signedMsgUserAccountPublicKey,
|
|
1268
1264
|
authority,
|
|
1269
1265
|
payer: this.wallet.publicKey,
|
|
1270
|
-
systemProgram:
|
|
1266
|
+
systemProgram: SystemProgram.programId,
|
|
1271
1267
|
user: await getUserAccountPublicKey(
|
|
1272
1268
|
this.program.programId,
|
|
1273
1269
|
authority,
|
|
@@ -1307,8 +1303,8 @@ export class DriftClient {
|
|
|
1307
1303
|
accounts: {
|
|
1308
1304
|
signedMsgWsDelegates,
|
|
1309
1305
|
authority: this.wallet.publicKey,
|
|
1310
|
-
rent:
|
|
1311
|
-
systemProgram:
|
|
1306
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
1307
|
+
systemProgram: SystemProgram.programId,
|
|
1312
1308
|
},
|
|
1313
1309
|
}
|
|
1314
1310
|
);
|
|
@@ -1340,8 +1336,8 @@ export class DriftClient {
|
|
|
1340
1336
|
revenueShare,
|
|
1341
1337
|
authority,
|
|
1342
1338
|
payer: overrides?.payer ?? this.wallet.publicKey,
|
|
1343
|
-
rent:
|
|
1344
|
-
systemProgram:
|
|
1339
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
1340
|
+
systemProgram: SystemProgram.programId,
|
|
1345
1341
|
},
|
|
1346
1342
|
});
|
|
1347
1343
|
}
|
|
@@ -1381,8 +1377,8 @@ export class DriftClient {
|
|
|
1381
1377
|
authority
|
|
1382
1378
|
),
|
|
1383
1379
|
state: await this.getStatePublicKey(),
|
|
1384
|
-
rent:
|
|
1385
|
-
systemProgram:
|
|
1380
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
1381
|
+
systemProgram: SystemProgram.programId,
|
|
1386
1382
|
},
|
|
1387
1383
|
});
|
|
1388
1384
|
}
|
|
@@ -1445,7 +1441,7 @@ export class DriftClient {
|
|
|
1445
1441
|
escrow,
|
|
1446
1442
|
authority,
|
|
1447
1443
|
payer: this.wallet.publicKey,
|
|
1448
|
-
systemProgram:
|
|
1444
|
+
systemProgram: SystemProgram.programId,
|
|
1449
1445
|
},
|
|
1450
1446
|
});
|
|
1451
1447
|
}
|
|
@@ -1509,7 +1505,7 @@ export class DriftClient {
|
|
|
1509
1505
|
escrow,
|
|
1510
1506
|
authority,
|
|
1511
1507
|
payer,
|
|
1512
|
-
systemProgram:
|
|
1508
|
+
systemProgram: SystemProgram.programId,
|
|
1513
1509
|
},
|
|
1514
1510
|
}
|
|
1515
1511
|
);
|
|
@@ -1541,7 +1537,7 @@ export class DriftClient {
|
|
|
1541
1537
|
accounts: {
|
|
1542
1538
|
signedMsgWsDelegates,
|
|
1543
1539
|
authority: this.wallet.publicKey,
|
|
1544
|
-
systemProgram:
|
|
1540
|
+
systemProgram: SystemProgram.programId,
|
|
1545
1541
|
},
|
|
1546
1542
|
}
|
|
1547
1543
|
);
|
|
@@ -1574,7 +1570,7 @@ export class DriftClient {
|
|
|
1574
1570
|
accounts: {
|
|
1575
1571
|
signedMsgWsDelegates,
|
|
1576
1572
|
authority: this.wallet.publicKey,
|
|
1577
|
-
systemProgram:
|
|
1573
|
+
systemProgram: SystemProgram.programId,
|
|
1578
1574
|
},
|
|
1579
1575
|
}
|
|
1580
1576
|
);
|
|
@@ -1605,8 +1601,8 @@ export class DriftClient {
|
|
|
1605
1601
|
),
|
|
1606
1602
|
authority: authority ?? this.wallet.publicKey,
|
|
1607
1603
|
payer: this.wallet.publicKey,
|
|
1608
|
-
rent:
|
|
1609
|
-
systemProgram:
|
|
1604
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
1605
|
+
systemProgram: SystemProgram.programId,
|
|
1610
1606
|
},
|
|
1611
1607
|
});
|
|
1612
1608
|
}
|
|
@@ -1699,8 +1695,8 @@ export class DriftClient {
|
|
|
1699
1695
|
userStats: this.getUserStatsAccountPublicKey(),
|
|
1700
1696
|
authority: accountAuthority,
|
|
1701
1697
|
payer: payer,
|
|
1702
|
-
rent:
|
|
1703
|
-
systemProgram:
|
|
1698
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
1699
|
+
systemProgram: SystemProgram.programId,
|
|
1704
1700
|
state: await this.getStatePublicKey(),
|
|
1705
1701
|
},
|
|
1706
1702
|
remainingAccounts,
|
|
@@ -1749,8 +1745,8 @@ export class DriftClient {
|
|
|
1749
1745
|
authority: this.wallet.publicKey,
|
|
1750
1746
|
userStats: this.getUserStatsAccountPublicKey(),
|
|
1751
1747
|
payer: this.wallet.publicKey,
|
|
1752
|
-
rent:
|
|
1753
|
-
systemProgram:
|
|
1748
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
1749
|
+
systemProgram: SystemProgram.programId,
|
|
1754
1750
|
},
|
|
1755
1751
|
}
|
|
1756
1752
|
);
|
|
@@ -2407,7 +2403,7 @@ export class DriftClient {
|
|
|
2407
2403
|
userStats: this.getUserStatsAccountPublicKey(),
|
|
2408
2404
|
authority: this.wallet.publicKey,
|
|
2409
2405
|
state: await this.getStatePublicKey(),
|
|
2410
|
-
rent:
|
|
2406
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
2411
2407
|
},
|
|
2412
2408
|
});
|
|
2413
2409
|
}
|
|
@@ -2608,132 +2604,7 @@ export class DriftClient {
|
|
|
2608
2604
|
});
|
|
2609
2605
|
}
|
|
2610
2606
|
getRemainingAccounts(params: RemainingAccountParams): AccountMeta[] {
|
|
2611
|
-
|
|
2612
|
-
this.getRemainingAccountMapsForUsers(params.userAccounts);
|
|
2613
|
-
|
|
2614
|
-
if (params.useMarketLastSlotCache) {
|
|
2615
|
-
const lastUserSlot = this.getUserAccountAndSlot(
|
|
2616
|
-
params.userAccounts.length > 0
|
|
2617
|
-
? params.userAccounts[0].subAccountId
|
|
2618
|
-
: this.activeSubAccountId,
|
|
2619
|
-
params.userAccounts.length > 0
|
|
2620
|
-
? params.userAccounts[0].authority
|
|
2621
|
-
: this.authority
|
|
2622
|
-
)?.slot;
|
|
2623
|
-
|
|
2624
|
-
for (const [
|
|
2625
|
-
marketIndex,
|
|
2626
|
-
slot,
|
|
2627
|
-
] of this.perpMarketLastSlotCache.entries()) {
|
|
2628
|
-
// if cache has more recent slot than user positions account slot, add market to remaining accounts
|
|
2629
|
-
// otherwise remove from slot
|
|
2630
|
-
if (slot > lastUserSlot) {
|
|
2631
|
-
this.addPerpMarketToRemainingAccountMaps(
|
|
2632
|
-
marketIndex,
|
|
2633
|
-
false,
|
|
2634
|
-
oracleAccountMap,
|
|
2635
|
-
spotMarketAccountMap,
|
|
2636
|
-
perpMarketAccountMap
|
|
2637
|
-
);
|
|
2638
|
-
} else {
|
|
2639
|
-
this.perpMarketLastSlotCache.delete(marketIndex);
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
|
|
2643
|
-
for (const [
|
|
2644
|
-
marketIndex,
|
|
2645
|
-
slot,
|
|
2646
|
-
] of this.spotMarketLastSlotCache.entries()) {
|
|
2647
|
-
// if cache has more recent slot than user positions account slot, add market to remaining accounts
|
|
2648
|
-
// otherwise remove from slot
|
|
2649
|
-
if (slot > lastUserSlot) {
|
|
2650
|
-
this.addSpotMarketToRemainingAccountMaps(
|
|
2651
|
-
marketIndex,
|
|
2652
|
-
false,
|
|
2653
|
-
oracleAccountMap,
|
|
2654
|
-
spotMarketAccountMap
|
|
2655
|
-
);
|
|
2656
|
-
} else {
|
|
2657
|
-
this.spotMarketLastSlotCache.delete(marketIndex);
|
|
2658
|
-
}
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
|
|
2662
|
-
if (params.readablePerpMarketIndex !== undefined) {
|
|
2663
|
-
const readablePerpMarketIndexes = Array.isArray(
|
|
2664
|
-
params.readablePerpMarketIndex
|
|
2665
|
-
)
|
|
2666
|
-
? params.readablePerpMarketIndex
|
|
2667
|
-
: [params.readablePerpMarketIndex];
|
|
2668
|
-
for (const marketIndex of readablePerpMarketIndexes) {
|
|
2669
|
-
this.addPerpMarketToRemainingAccountMaps(
|
|
2670
|
-
marketIndex,
|
|
2671
|
-
false,
|
|
2672
|
-
oracleAccountMap,
|
|
2673
|
-
spotMarketAccountMap,
|
|
2674
|
-
perpMarketAccountMap
|
|
2675
|
-
);
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
|
|
2679
|
-
for (const perpMarketIndex of this.mustIncludePerpMarketIndexes.values()) {
|
|
2680
|
-
this.addPerpMarketToRemainingAccountMaps(
|
|
2681
|
-
perpMarketIndex,
|
|
2682
|
-
false,
|
|
2683
|
-
oracleAccountMap,
|
|
2684
|
-
spotMarketAccountMap,
|
|
2685
|
-
perpMarketAccountMap
|
|
2686
|
-
);
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
|
-
if (params.readableSpotMarketIndexes !== undefined) {
|
|
2690
|
-
for (const readableSpotMarketIndex of params.readableSpotMarketIndexes) {
|
|
2691
|
-
this.addSpotMarketToRemainingAccountMaps(
|
|
2692
|
-
readableSpotMarketIndex,
|
|
2693
|
-
false,
|
|
2694
|
-
oracleAccountMap,
|
|
2695
|
-
spotMarketAccountMap
|
|
2696
|
-
);
|
|
2697
|
-
}
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
|
-
for (const spotMarketIndex of this.mustIncludeSpotMarketIndexes.values()) {
|
|
2701
|
-
this.addSpotMarketToRemainingAccountMaps(
|
|
2702
|
-
spotMarketIndex,
|
|
2703
|
-
false,
|
|
2704
|
-
oracleAccountMap,
|
|
2705
|
-
spotMarketAccountMap
|
|
2706
|
-
);
|
|
2707
|
-
}
|
|
2708
|
-
|
|
2709
|
-
if (params.writablePerpMarketIndexes !== undefined) {
|
|
2710
|
-
for (const writablePerpMarketIndex of params.writablePerpMarketIndexes) {
|
|
2711
|
-
this.addPerpMarketToRemainingAccountMaps(
|
|
2712
|
-
writablePerpMarketIndex,
|
|
2713
|
-
true,
|
|
2714
|
-
oracleAccountMap,
|
|
2715
|
-
spotMarketAccountMap,
|
|
2716
|
-
perpMarketAccountMap
|
|
2717
|
-
);
|
|
2718
|
-
}
|
|
2719
|
-
}
|
|
2720
|
-
|
|
2721
|
-
if (params.writableSpotMarketIndexes !== undefined) {
|
|
2722
|
-
for (const writableSpotMarketIndex of params.writableSpotMarketIndexes) {
|
|
2723
|
-
this.addSpotMarketToRemainingAccountMaps(
|
|
2724
|
-
writableSpotMarketIndex,
|
|
2725
|
-
true,
|
|
2726
|
-
oracleAccountMap,
|
|
2727
|
-
spotMarketAccountMap
|
|
2728
|
-
);
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
|
|
2732
|
-
return [
|
|
2733
|
-
...oracleAccountMap.values(),
|
|
2734
|
-
...spotMarketAccountMap.values(),
|
|
2735
|
-
...perpMarketAccountMap.values(),
|
|
2736
|
-
];
|
|
2607
|
+
return DriftCore.remainingAccounts.getRemainingAccounts(this, params);
|
|
2737
2608
|
}
|
|
2738
2609
|
|
|
2739
2610
|
addPerpMarketToRemainingAccountMaps(
|
|
@@ -2921,7 +2792,7 @@ export class DriftClient {
|
|
|
2921
2792
|
{ pubkey: owner, isSigner: false, isWritable: false },
|
|
2922
2793
|
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
2923
2794
|
{
|
|
2924
|
-
pubkey:
|
|
2795
|
+
pubkey: SystemProgram.programId,
|
|
2925
2796
|
isSigner: false,
|
|
2926
2797
|
isWritable: false,
|
|
2927
2798
|
},
|
|
@@ -3173,24 +3044,21 @@ export class DriftClient {
|
|
|
3173
3044
|
|
|
3174
3045
|
const authority = overrides?.authority ?? this.wallet.publicKey;
|
|
3175
3046
|
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
3176
|
-
return await
|
|
3047
|
+
return await DriftCore.buildDepositInstruction({
|
|
3048
|
+
program: this.program,
|
|
3177
3049
|
marketIndex,
|
|
3178
3050
|
amount,
|
|
3179
3051
|
reduceOnly,
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
},
|
|
3191
|
-
remainingAccounts,
|
|
3192
|
-
}
|
|
3193
|
-
);
|
|
3052
|
+
state: await this.getStatePublicKey(),
|
|
3053
|
+
spotMarket: spotMarketAccount.pubkey,
|
|
3054
|
+
spotMarketVault: spotMarketAccount.vault,
|
|
3055
|
+
user: userAccountPublicKey,
|
|
3056
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
3057
|
+
userTokenAccount,
|
|
3058
|
+
authority,
|
|
3059
|
+
tokenProgram,
|
|
3060
|
+
remainingAccounts,
|
|
3061
|
+
});
|
|
3194
3062
|
}
|
|
3195
3063
|
|
|
3196
3064
|
private async checkIfAccountExists(account: PublicKey): Promise<boolean> {
|
|
@@ -3210,7 +3078,7 @@ export class DriftClient {
|
|
|
3210
3078
|
authority?: PublicKey;
|
|
3211
3079
|
}
|
|
3212
3080
|
): Promise<{
|
|
3213
|
-
ixs:
|
|
3081
|
+
ixs: TransactionInstruction[];
|
|
3214
3082
|
/** @deprecated - this array is always going to be empty, in the current implementation */
|
|
3215
3083
|
signers: Signer[];
|
|
3216
3084
|
pubkey: PublicKey;
|
|
@@ -3346,7 +3214,7 @@ export class DriftClient {
|
|
|
3346
3214
|
tokenMintAddress: PublicKey,
|
|
3347
3215
|
associatedTokenAddress: PublicKey,
|
|
3348
3216
|
tokenProgram: PublicKey
|
|
3349
|
-
):
|
|
3217
|
+
): TransactionInstruction {
|
|
3350
3218
|
return createAssociatedTokenAccountInstruction(
|
|
3351
3219
|
this.wallet.publicKey,
|
|
3352
3220
|
associatedTokenAddress,
|
|
@@ -3692,7 +3560,7 @@ export class DriftClient {
|
|
|
3692
3560
|
subAccountId?: number,
|
|
3693
3561
|
_updateFuel = false
|
|
3694
3562
|
): Promise<TransactionInstruction[]> {
|
|
3695
|
-
const withdrawIxs:
|
|
3563
|
+
const withdrawIxs: TransactionInstruction[] = [];
|
|
3696
3564
|
|
|
3697
3565
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
3698
3566
|
|
|
@@ -3817,7 +3685,7 @@ export class DriftClient {
|
|
|
3817
3685
|
|
|
3818
3686
|
opts?.dustPositionCountCallback?.(dustPositionSpotMarketAccounts.length);
|
|
3819
3687
|
|
|
3820
|
-
let allWithdrawIxs:
|
|
3688
|
+
let allWithdrawIxs: TransactionInstruction[] = [];
|
|
3821
3689
|
|
|
3822
3690
|
for (const position of dustPositionSpotMarketAccounts) {
|
|
3823
3691
|
const tokenAccount = await getAssociatedTokenAddress(
|
|
@@ -3876,25 +3744,22 @@ export class DriftClient {
|
|
|
3876
3744
|
|
|
3877
3745
|
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarketAccount);
|
|
3878
3746
|
|
|
3879
|
-
return await
|
|
3747
|
+
return await DriftCore.buildWithdrawInstruction({
|
|
3748
|
+
program: this.program,
|
|
3880
3749
|
marketIndex,
|
|
3881
3750
|
amount,
|
|
3882
3751
|
reduceOnly,
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
},
|
|
3895
|
-
remainingAccounts,
|
|
3896
|
-
}
|
|
3897
|
-
);
|
|
3752
|
+
state: await this.getStatePublicKey(),
|
|
3753
|
+
spotMarket: spotMarketAccount.pubkey,
|
|
3754
|
+
spotMarketVault: spotMarketAccount.vault,
|
|
3755
|
+
driftSigner: this.getSignerPublicKey(),
|
|
3756
|
+
user,
|
|
3757
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
3758
|
+
userTokenAccount,
|
|
3759
|
+
authority: this.wallet.publicKey,
|
|
3760
|
+
tokenProgram,
|
|
3761
|
+
remainingAccounts,
|
|
3762
|
+
});
|
|
3898
3763
|
}
|
|
3899
3764
|
|
|
3900
3765
|
/**
|
|
@@ -5044,13 +4909,13 @@ export class DriftClient {
|
|
|
5044
4909
|
: undefined,
|
|
5045
4910
|
});
|
|
5046
4911
|
|
|
5047
|
-
return await
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
4912
|
+
return await DriftCore.buildPlacePerpOrderInstruction({
|
|
4913
|
+
program: this.program,
|
|
4914
|
+
orderParams,
|
|
4915
|
+
state: await this.getStatePublicKey(),
|
|
4916
|
+
user,
|
|
4917
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
4918
|
+
authority: this.wallet.publicKey,
|
|
5054
4919
|
remainingAccounts,
|
|
5055
4920
|
});
|
|
5056
4921
|
}
|
|
@@ -5226,12 +5091,12 @@ export class DriftClient {
|
|
|
5226
5091
|
useMarketLastSlotCache: true,
|
|
5227
5092
|
});
|
|
5228
5093
|
|
|
5229
|
-
return await
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5094
|
+
return await DriftCore.buildCancelOrderInstruction({
|
|
5095
|
+
program: this.program,
|
|
5096
|
+
orderId: orderId ?? null,
|
|
5097
|
+
state: await this.getStatePublicKey(),
|
|
5098
|
+
user,
|
|
5099
|
+
authority: this.wallet.publicKey,
|
|
5235
5100
|
remainingAccounts,
|
|
5236
5101
|
});
|
|
5237
5102
|
}
|
|
@@ -5266,18 +5131,15 @@ export class DriftClient {
|
|
|
5266
5131
|
useMarketLastSlotCache: true,
|
|
5267
5132
|
});
|
|
5268
5133
|
|
|
5269
|
-
return await
|
|
5134
|
+
return await DriftCore.buildCancelOrderByUserIdInstruction({
|
|
5135
|
+
program: this.program,
|
|
5270
5136
|
userOrderId,
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
},
|
|
5278
|
-
remainingAccounts,
|
|
5279
|
-
}
|
|
5280
|
-
);
|
|
5137
|
+
state: await this.getStatePublicKey(),
|
|
5138
|
+
user,
|
|
5139
|
+
authority: this.wallet.publicKey,
|
|
5140
|
+
oracle,
|
|
5141
|
+
remainingAccounts,
|
|
5142
|
+
});
|
|
5281
5143
|
}
|
|
5282
5144
|
|
|
5283
5145
|
/**
|
|
@@ -5343,12 +5205,12 @@ export class DriftClient {
|
|
|
5343
5205
|
|
|
5344
5206
|
const authority = overrides?.authority ?? this.wallet.publicKey;
|
|
5345
5207
|
|
|
5346
|
-
return await
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5208
|
+
return await DriftCore.buildCancelOrdersByIdsInstruction({
|
|
5209
|
+
program: this.program,
|
|
5210
|
+
orderIds,
|
|
5211
|
+
state: await this.getStatePublicKey(),
|
|
5212
|
+
user: userAccountPubKey,
|
|
5213
|
+
authority,
|
|
5352
5214
|
remainingAccounts,
|
|
5353
5215
|
});
|
|
5354
5216
|
}
|
|
@@ -5402,19 +5264,17 @@ export class DriftClient {
|
|
|
5402
5264
|
useMarketLastSlotCache: true,
|
|
5403
5265
|
});
|
|
5404
5266
|
|
|
5405
|
-
return await
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
}
|
|
5417
|
-
);
|
|
5267
|
+
return await DriftCore.buildCancelOrdersInstruction({
|
|
5268
|
+
program: this.program,
|
|
5269
|
+
marketType: marketType ?? null,
|
|
5270
|
+
marketIndex: marketIndex ?? null,
|
|
5271
|
+
direction: direction ?? null,
|
|
5272
|
+
user,
|
|
5273
|
+
state: await this.getStatePublicKey(),
|
|
5274
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
5275
|
+
authority: this.wallet.publicKey,
|
|
5276
|
+
remainingAccounts,
|
|
5277
|
+
});
|
|
5418
5278
|
}
|
|
5419
5279
|
|
|
5420
5280
|
public async cancelAndPlaceOrders(
|
|
@@ -5538,18 +5398,15 @@ export class DriftClient {
|
|
|
5538
5398
|
const formattedParams = params.map((item) => getOrderParams(item));
|
|
5539
5399
|
const authority = overrides?.authority ?? this.wallet.publicKey;
|
|
5540
5400
|
|
|
5541
|
-
return await
|
|
5401
|
+
return await DriftCore.buildPlaceOrdersInstruction({
|
|
5402
|
+
program: this.program,
|
|
5542
5403
|
formattedParams,
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
},
|
|
5550
|
-
remainingAccounts,
|
|
5551
|
-
}
|
|
5552
|
-
);
|
|
5404
|
+
state: await this.getStatePublicKey(),
|
|
5405
|
+
user,
|
|
5406
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
5407
|
+
authority,
|
|
5408
|
+
remainingAccounts,
|
|
5409
|
+
});
|
|
5553
5410
|
}
|
|
5554
5411
|
|
|
5555
5412
|
public async getPlaceOrdersAndSetPositionMaxLevIx(
|
|
@@ -5847,15 +5704,15 @@ export class DriftClient {
|
|
|
5847
5704
|
}
|
|
5848
5705
|
|
|
5849
5706
|
const orderId = isSignedMsg ? null : order.orderId;
|
|
5850
|
-
return await
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5707
|
+
return await DriftCore.buildFillPerpOrderInstruction({
|
|
5708
|
+
program: this.program,
|
|
5709
|
+
orderId,
|
|
5710
|
+
state: await this.getStatePublicKey(),
|
|
5711
|
+
filler,
|
|
5712
|
+
fillerStats: fillerStatsPublicKey,
|
|
5713
|
+
user: userAccountPublicKey,
|
|
5714
|
+
userStats: userStatsPublicKey,
|
|
5715
|
+
authority: this.wallet.publicKey,
|
|
5859
5716
|
remainingAccounts,
|
|
5860
5717
|
});
|
|
5861
5718
|
}
|
|
@@ -6718,7 +6575,7 @@ export class DriftClient {
|
|
|
6718
6575
|
outTokenAccount,
|
|
6719
6576
|
tokenProgram: inTokenProgram,
|
|
6720
6577
|
driftSigner: this.getStateAccount().signer,
|
|
6721
|
-
instructions:
|
|
6578
|
+
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6722
6579
|
},
|
|
6723
6580
|
remainingAccounts,
|
|
6724
6581
|
}
|
|
@@ -6741,7 +6598,7 @@ export class DriftClient {
|
|
|
6741
6598
|
outTokenAccount,
|
|
6742
6599
|
tokenProgram: inTokenProgram,
|
|
6743
6600
|
driftSigner: this.getStateAccount().signer,
|
|
6744
|
-
instructions:
|
|
6601
|
+
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6745
6602
|
},
|
|
6746
6603
|
remainingAccounts,
|
|
6747
6604
|
}
|
|
@@ -7002,13 +6859,13 @@ export class DriftClient {
|
|
|
7002
6859
|
);
|
|
7003
6860
|
|
|
7004
6861
|
const orderId = order.orderId;
|
|
7005
|
-
return await
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
6862
|
+
return await DriftCore.buildTriggerOrderInstruction({
|
|
6863
|
+
program: this.program,
|
|
6864
|
+
orderId,
|
|
6865
|
+
state: await this.getStatePublicKey(),
|
|
6866
|
+
filler,
|
|
6867
|
+
user: userAccountPublicKey,
|
|
6868
|
+
authority: this.wallet.publicKey,
|
|
7012
6869
|
remainingAccounts,
|
|
7013
6870
|
});
|
|
7014
6871
|
}
|
|
@@ -7609,19 +7466,16 @@ export class DriftClient {
|
|
|
7609
7466
|
|
|
7610
7467
|
const authority = overrides?.authority ?? this.wallet.publicKey;
|
|
7611
7468
|
|
|
7612
|
-
return await
|
|
7469
|
+
return await DriftCore.buildPlaceAndTakePerpOrderInstruction({
|
|
7470
|
+
program: this.program,
|
|
7613
7471
|
orderParams,
|
|
7614
7472
|
optionalParams,
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
},
|
|
7622
|
-
remainingAccounts,
|
|
7623
|
-
}
|
|
7624
|
-
);
|
|
7473
|
+
state: await this.getStatePublicKey(),
|
|
7474
|
+
user,
|
|
7475
|
+
userStats: userStatsPublicKey,
|
|
7476
|
+
authority,
|
|
7477
|
+
remainingAccounts,
|
|
7478
|
+
});
|
|
7625
7479
|
}
|
|
7626
7480
|
|
|
7627
7481
|
public async placeAndMakePerpOrder(
|
|
@@ -7693,21 +7547,18 @@ export class DriftClient {
|
|
|
7693
7547
|
isSigner: false,
|
|
7694
7548
|
});
|
|
7695
7549
|
}
|
|
7696
|
-
return await
|
|
7550
|
+
return await DriftCore.buildPlaceAndMakePerpOrderInstruction({
|
|
7551
|
+
program: this.program,
|
|
7697
7552
|
orderParams,
|
|
7698
7553
|
takerOrderId,
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
},
|
|
7708
|
-
remainingAccounts,
|
|
7709
|
-
}
|
|
7710
|
-
);
|
|
7554
|
+
state: await this.getStatePublicKey(),
|
|
7555
|
+
user,
|
|
7556
|
+
userStats: userStatsPublicKey,
|
|
7557
|
+
taker: takerInfo.taker,
|
|
7558
|
+
takerStats: takerInfo.takerStats,
|
|
7559
|
+
authority: this.wallet.publicKey,
|
|
7560
|
+
remainingAccounts,
|
|
7561
|
+
});
|
|
7711
7562
|
}
|
|
7712
7563
|
|
|
7713
7564
|
public signSignedMsgOrderParamsMessage(
|
|
@@ -7770,43 +7621,11 @@ export class DriftClient {
|
|
|
7770
7621
|
| SignedMsgOrderParamsDelegateMessage,
|
|
7771
7622
|
delegateSigner?: boolean
|
|
7772
7623
|
): Buffer {
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
}
|
|
7779
|
-
|
|
7780
|
-
const anchorIxName = delegateSigner
|
|
7781
|
-
? 'global' + ':' + 'SignedMsgOrderParamsDelegateMessage'
|
|
7782
|
-
: 'global' + ':' + 'SignedMsgOrderParamsMessage';
|
|
7783
|
-
const prefix = Buffer.from(sha256(anchorIxName).slice(0, 8));
|
|
7784
|
-
|
|
7785
|
-
// Backwards-compat: normalize optional builder fields to null for encoding
|
|
7786
|
-
const withBuilderDefaults = {
|
|
7787
|
-
...orderParamsMessage,
|
|
7788
|
-
builderIdx:
|
|
7789
|
-
orderParamsMessage.builderIdx !== undefined
|
|
7790
|
-
? orderParamsMessage.builderIdx
|
|
7791
|
-
: null,
|
|
7792
|
-
builderFeeTenthBps:
|
|
7793
|
-
orderParamsMessage.builderFeeTenthBps !== undefined
|
|
7794
|
-
? orderParamsMessage.builderFeeTenthBps
|
|
7795
|
-
: null,
|
|
7796
|
-
};
|
|
7797
|
-
const buf = Buffer.concat([
|
|
7798
|
-
prefix,
|
|
7799
|
-
delegateSigner
|
|
7800
|
-
? this.program.coder.types.encode(
|
|
7801
|
-
'signedMsgOrderParamsDelegateMessage',
|
|
7802
|
-
withBuilderDefaults as SignedMsgOrderParamsDelegateMessage
|
|
7803
|
-
)
|
|
7804
|
-
: this.program.coder.types.encode(
|
|
7805
|
-
'signedMsgOrderParamsMessage',
|
|
7806
|
-
withBuilderDefaults as SignedMsgOrderParamsMessage
|
|
7807
|
-
),
|
|
7808
|
-
]);
|
|
7809
|
-
return buf;
|
|
7624
|
+
return DriftCore.signedMsg.encodeSignedMsgOrderParamsMessage({
|
|
7625
|
+
coderTypes: this.program.coder.types as any,
|
|
7626
|
+
orderParamsMessage,
|
|
7627
|
+
delegateSigner,
|
|
7628
|
+
});
|
|
7810
7629
|
}
|
|
7811
7630
|
|
|
7812
7631
|
/*
|
|
@@ -7819,16 +7638,11 @@ export class DriftClient {
|
|
|
7819
7638
|
encodedMessage: Buffer,
|
|
7820
7639
|
delegateSigner?: boolean
|
|
7821
7640
|
): SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage {
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
Buffer.concat([
|
|
7828
|
-
encodedMessage.slice(8), // strip out discriminator
|
|
7829
|
-
Buffer.alloc(128), // pad on 128 bytes, this is most efficient way to messages that are too small
|
|
7830
|
-
])
|
|
7831
|
-
);
|
|
7641
|
+
return DriftCore.signedMsg.decodeSignedMsgOrderParamsMessage({
|
|
7642
|
+
coderTypes: this.program.coder.types as any,
|
|
7643
|
+
encodedMessage,
|
|
7644
|
+
delegateSigner,
|
|
7645
|
+
});
|
|
7832
7646
|
}
|
|
7833
7647
|
|
|
7834
7648
|
public signMessage(
|
|
@@ -8359,19 +8173,16 @@ export class DriftClient {
|
|
|
8359
8173
|
overrides?.authority ??
|
|
8360
8174
|
overrides?.user?.getUserAccount().authority ??
|
|
8361
8175
|
this.wallet.publicKey;
|
|
8362
|
-
return await
|
|
8176
|
+
return await DriftCore.buildModifyOrderInstruction({
|
|
8177
|
+
program: this.program,
|
|
8363
8178
|
orderId,
|
|
8364
|
-
orderParams,
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
},
|
|
8372
|
-
remainingAccounts,
|
|
8373
|
-
}
|
|
8374
|
-
);
|
|
8179
|
+
modifyParams: orderParams,
|
|
8180
|
+
state: await this.getStatePublicKey(),
|
|
8181
|
+
user: userPubKey,
|
|
8182
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
8183
|
+
authority,
|
|
8184
|
+
remainingAccounts,
|
|
8185
|
+
});
|
|
8375
8186
|
}
|
|
8376
8187
|
|
|
8377
8188
|
/**
|
|
@@ -8484,19 +8295,16 @@ export class DriftClient {
|
|
|
8484
8295
|
maxTs: maxTs || null,
|
|
8485
8296
|
};
|
|
8486
8297
|
|
|
8487
|
-
return await
|
|
8298
|
+
return await DriftCore.buildModifyOrderByUserIdInstruction({
|
|
8299
|
+
program: this.program,
|
|
8488
8300
|
userOrderId,
|
|
8489
|
-
orderParams,
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
},
|
|
8497
|
-
remainingAccounts,
|
|
8498
|
-
}
|
|
8499
|
-
);
|
|
8301
|
+
modifyParams: orderParams,
|
|
8302
|
+
state: await this.getStatePublicKey(),
|
|
8303
|
+
user,
|
|
8304
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
8305
|
+
authority: this.wallet.publicKey,
|
|
8306
|
+
remainingAccounts,
|
|
8307
|
+
});
|
|
8500
8308
|
}
|
|
8501
8309
|
|
|
8502
8310
|
public async settlePNLs(
|
|
@@ -8703,14 +8511,14 @@ export class DriftClient {
|
|
|
8703
8511
|
}
|
|
8704
8512
|
}
|
|
8705
8513
|
|
|
8706
|
-
return await
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
remainingAccounts
|
|
8514
|
+
return await DriftCore.buildSettlePnlInstruction({
|
|
8515
|
+
program: this.program,
|
|
8516
|
+
marketIndex,
|
|
8517
|
+
state: await this.getStatePublicKey(),
|
|
8518
|
+
authority: this.wallet.publicKey,
|
|
8519
|
+
user: settleeUserAccountPublicKey,
|
|
8520
|
+
spotMarketVault: this.getQuoteSpotMarketAccount().vault,
|
|
8521
|
+
remainingAccounts,
|
|
8714
8522
|
});
|
|
8715
8523
|
}
|
|
8716
8524
|
|
|
@@ -9006,22 +8814,19 @@ export class DriftClient {
|
|
|
9006
8814
|
writablePerpMarketIndexes: [marketIndex],
|
|
9007
8815
|
});
|
|
9008
8816
|
|
|
9009
|
-
return await
|
|
8817
|
+
return await DriftCore.buildLiquidatePerpInstruction({
|
|
8818
|
+
program: this.program,
|
|
9010
8819
|
marketIndex,
|
|
9011
8820
|
maxBaseAssetAmount,
|
|
9012
|
-
limitPrice ?? null,
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
},
|
|
9022
|
-
remainingAccounts: remainingAccounts,
|
|
9023
|
-
}
|
|
9024
|
-
);
|
|
8821
|
+
limitPrice: limitPrice ?? null,
|
|
8822
|
+
state: await this.getStatePublicKey(),
|
|
8823
|
+
authority: this.wallet.publicKey,
|
|
8824
|
+
user: userAccountPublicKey,
|
|
8825
|
+
userStats: userStatsPublicKey,
|
|
8826
|
+
liquidator,
|
|
8827
|
+
liquidatorStats: liquidatorStatsPublicKey,
|
|
8828
|
+
remainingAccounts,
|
|
8829
|
+
});
|
|
9025
8830
|
}
|
|
9026
8831
|
|
|
9027
8832
|
public async liquidatePerpWithFill(
|
|
@@ -9157,7 +8962,7 @@ export class DriftClient {
|
|
|
9157
8962
|
writableSpotMarketIndexes: [liabilityMarketIndex, assetMarketIndex],
|
|
9158
8963
|
});
|
|
9159
8964
|
|
|
9160
|
-
return await this.program.instruction.liquidateSpot(
|
|
8965
|
+
return await (this.program.instruction as any).liquidateSpot(
|
|
9161
8966
|
assetMarketIndex,
|
|
9162
8967
|
liabilityMarketIndex,
|
|
9163
8968
|
maxLiabilityTransfer,
|
|
@@ -9171,7 +8976,7 @@ export class DriftClient {
|
|
|
9171
8976
|
liquidator,
|
|
9172
8977
|
liquidatorStats: liquidatorStatsPublicKey,
|
|
9173
8978
|
},
|
|
9174
|
-
remainingAccounts
|
|
8979
|
+
remainingAccounts,
|
|
9175
8980
|
}
|
|
9176
8981
|
);
|
|
9177
8982
|
}
|
|
@@ -9424,7 +9229,7 @@ export class DriftClient {
|
|
|
9424
9229
|
liabilityTokenAccount: liabilityTokenAccount,
|
|
9425
9230
|
tokenProgram: assetTokenProgram,
|
|
9426
9231
|
driftSigner: this.getStateAccount().signer,
|
|
9427
|
-
instructions:
|
|
9232
|
+
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
9428
9233
|
},
|
|
9429
9234
|
remainingAccounts,
|
|
9430
9235
|
}
|
|
@@ -9447,7 +9252,7 @@ export class DriftClient {
|
|
|
9447
9252
|
liabilityTokenAccount: liabilityTokenAccount,
|
|
9448
9253
|
tokenProgram: assetTokenProgram,
|
|
9449
9254
|
driftSigner: this.getStateAccount().signer,
|
|
9450
|
-
instructions:
|
|
9255
|
+
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
9451
9256
|
},
|
|
9452
9257
|
remainingAccounts,
|
|
9453
9258
|
}
|
|
@@ -9526,7 +9331,7 @@ export class DriftClient {
|
|
|
9526
9331
|
ifRebalanceConfig: ifRebalanceConfig,
|
|
9527
9332
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
9528
9333
|
driftSigner: this.getStateAccount().signer,
|
|
9529
|
-
instructions:
|
|
9334
|
+
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
9530
9335
|
},
|
|
9531
9336
|
remainingAccounts,
|
|
9532
9337
|
}
|
|
@@ -9546,7 +9351,7 @@ export class DriftClient {
|
|
|
9546
9351
|
ifRebalanceConfig: ifRebalanceConfig,
|
|
9547
9352
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
9548
9353
|
driftSigner: this.getStateAccount().signer,
|
|
9549
|
-
instructions:
|
|
9354
|
+
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
9550
9355
|
},
|
|
9551
9356
|
remainingAccounts,
|
|
9552
9357
|
}
|
|
@@ -9868,12 +9673,12 @@ export class DriftClient {
|
|
|
9868
9673
|
this.program.programId,
|
|
9869
9674
|
perpMarketIndex
|
|
9870
9675
|
);
|
|
9871
|
-
return await
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
9676
|
+
return await DriftCore.buildUpdateFundingRateInstruction({
|
|
9677
|
+
program: this.program,
|
|
9678
|
+
perpMarketIndex,
|
|
9679
|
+
state: await this.getStatePublicKey(),
|
|
9680
|
+
perpMarket: perpMarketPublicKey,
|
|
9681
|
+
oracle,
|
|
9877
9682
|
});
|
|
9878
9683
|
}
|
|
9879
9684
|
|
|
@@ -10118,8 +9923,8 @@ export class DriftClient {
|
|
|
10118
9923
|
),
|
|
10119
9924
|
authority: this.wallet.publicKey,
|
|
10120
9925
|
payer: this.wallet.publicKey,
|
|
10121
|
-
rent:
|
|
10122
|
-
systemProgram:
|
|
9926
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
9927
|
+
systemProgram: SystemProgram.programId,
|
|
10123
9928
|
state: await this.getStatePublicKey(),
|
|
10124
9929
|
};
|
|
10125
9930
|
|