@drift-labs/sdk 2.24.0 → 2.25.0-beta.0
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/README.md +1 -1
- package/lib/accounts/fetch.d.ts +1 -1
- package/lib/accounts/pollingDriftClientAccountSubscriber.d.ts +1 -1
- package/lib/accounts/pollingOracleAccountSubscriber.d.ts +1 -1
- package/lib/accounts/pollingTokenAccountSubscriber.d.ts +1 -1
- package/lib/accounts/pollingUserAccountSubscriber.d.ts +1 -1
- package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +1 -1
- package/lib/accounts/webSocketAccountSubscriber.d.ts +1 -1
- package/lib/accounts/webSocketDriftClientAccountSubscriber.d.ts +1 -1
- package/lib/accounts/webSocketUserAccountSubscriber.d.ts +1 -1
- package/lib/accounts/webSocketUserStatsAccountSubsriber.d.ts +1 -1
- package/lib/addresses/pda.d.ts +1 -2
- package/lib/addresses/pda.js +1 -1
- package/lib/adminClient.d.ts +1 -2
- package/lib/adminClient.js +2 -2
- package/lib/constants/numericConstants.d.ts +59 -61
- package/lib/constants/spotMarkets.d.ts +0 -1
- package/lib/dlob/DLOB.d.ts +0 -1
- package/lib/dlob/DLOBNode.d.ts +0 -1
- package/lib/dlob/DLOBOrders.d.ts +1 -1
- package/lib/dlob/DLOBOrders.js +1 -1
- package/lib/dlob/NodeList.d.ts +0 -1
- package/lib/driftClient.d.ts +38 -23
- package/lib/driftClient.js +85 -131
- package/lib/events/eventSubscriber.d.ts +1 -1
- package/lib/events/eventSubscriber.js +3 -2
- package/lib/events/fetchLogs.d.ts +1 -1
- package/lib/events/fetchLogs.js +3 -2
- package/lib/examples/loadDlob.js +1 -1
- package/lib/examples/makeTradeExample.js +1 -1
- package/lib/factory/bigNum.d.ts +8 -9
- package/lib/factory/bigNum.js +1 -1
- package/lib/factory/oracleClient.js +1 -1
- package/lib/idl/drift.json +181 -14
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/math/amm.d.ts +2 -3
- package/lib/math/amm.js +1 -1
- package/lib/math/auction.d.ts +0 -1
- package/lib/math/conversion.d.ts +1 -2
- package/lib/math/funding.d.ts +1 -2
- package/lib/math/funding.js +1 -1
- package/lib/math/insurance.d.ts +1 -1
- package/lib/math/insurance.js +17 -1
- package/lib/math/margin.d.ts +1 -2
- package/lib/math/margin.js +1 -1
- package/lib/math/market.d.ts +1 -2
- package/lib/math/market.js +1 -1
- package/lib/math/oracles.d.ts +0 -1
- package/lib/math/oracles.js +2 -3
- package/lib/math/orders.d.ts +1 -2
- package/lib/math/orders.js +1 -1
- package/lib/math/position.d.ts +0 -1
- package/lib/math/repeg.d.ts +1 -2
- package/lib/math/repeg.js +1 -1
- package/lib/math/spotBalance.d.ts +1 -2
- package/lib/math/spotBalance.js +1 -1
- package/lib/math/spotMarket.d.ts +1 -2
- package/lib/math/spotMarket.js +1 -1
- package/lib/math/spotPosition.d.ts +1 -2
- package/lib/math/trade.d.ts +1 -2
- package/lib/math/trade.js +1 -1
- package/lib/math/utils.d.ts +0 -1
- package/lib/oracles/pythClient.d.ts +2 -3
- package/lib/oracles/pythClient.js +1 -1
- package/lib/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/oracles/types.d.ts +1 -2
- package/lib/orderParams.d.ts +1 -2
- package/lib/serum/serumSubscriber.d.ts +1 -2
- package/lib/serum/serumSubscriber.js +1 -1
- package/lib/tokenFaucet.d.ts +2 -3
- package/lib/tokenFaucet.js +2 -2
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/types.d.ts +1 -1
- package/lib/types.d.ts +8 -3
- package/lib/types.js +2 -1
- package/lib/user.d.ts +0 -1
- package/package.json +2 -2
- package/src/accounts/fetch.ts +1 -1
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +1 -1
- package/src/accounts/pollingOracleAccountSubscriber.ts +1 -1
- package/src/accounts/pollingTokenAccountSubscriber.ts +1 -1
- package/src/accounts/pollingUserAccountSubscriber.ts +1 -1
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketUserAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +1 -1
- package/src/addresses/pda.ts +2 -2
- package/src/adminClient.ts +2 -2
- package/src/dlob/DLOBOrders.ts +2 -2
- package/src/driftClient.ts +136 -153
- package/src/events/eventSubscriber.ts +7 -3
- package/src/events/fetchLogs.ts +7 -3
- package/src/examples/loadDlob.ts +1 -1
- package/src/examples/makeTradeExample.ts +1 -1
- package/src/factory/bigNum.ts +1 -1
- package/src/factory/oracleClient.ts +1 -1
- package/src/idl/drift.json +181 -14
- package/src/index.ts +1 -1
- package/src/math/amm.ts +1 -1
- package/src/math/funding.ts +1 -1
- package/src/math/insurance.ts +29 -0
- package/src/math/margin.ts +1 -1
- package/src/math/market.ts +1 -1
- package/src/math/oracles.ts +2 -3
- package/src/math/orders.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/trade.ts +1 -1
- package/src/oracles/pythClient.ts +1 -1
- package/src/oracles/quoteAssetOracleClient.ts +1 -1
- package/src/oracles/types.ts +1 -1
- package/src/orderParams.ts +1 -1
- package/src/serum/serumSubscriber.ts +1 -1
- package/src/tokenFaucet.ts +2 -2
- package/src/tx/retryTxSender.ts +1 -1
- package/src/tx/types.ts +1 -1
- package/src/types.ts +6 -1
- package/src/userMap/userStatsMap.ts +1 -1
package/lib/driftClient.js
CHANGED
|
@@ -27,11 +27,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.DriftClient = void 0;
|
|
30
|
-
const anchor_1 = require("@
|
|
30
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
31
31
|
const bs58_1 = __importDefault(require("bs58"));
|
|
32
32
|
const spl_token_1 = require("@solana/spl-token");
|
|
33
33
|
const types_1 = require("./types");
|
|
34
|
-
const anchor = __importStar(require("@
|
|
34
|
+
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
35
35
|
const drift_json_1 = __importDefault(require("./idl/drift.json"));
|
|
36
36
|
const web3_js_1 = require("@solana/web3.js");
|
|
37
37
|
const pda_1 = require("./addresses/pda");
|
|
@@ -2000,153 +2000,107 @@ class DriftClient {
|
|
|
2000
2000
|
/**
|
|
2001
2001
|
* Modifies an open order (spot or perp) by closing it and replacing it with a new order.
|
|
2002
2002
|
* @param orderId: The open order to modify
|
|
2003
|
-
* @param
|
|
2004
|
-
* @param
|
|
2005
|
-
* @param
|
|
2006
|
-
* @param
|
|
2003
|
+
* @param newDirection: The new direction for the order
|
|
2004
|
+
* @param newBaseAmount: The new base amount for the order
|
|
2005
|
+
* @param newLimitPice: The new limit price for the order
|
|
2006
|
+
* @param newOraclePriceOffset: The new oracle price offset for the order
|
|
2007
2007
|
* @param newTriggerPrice: Optional - Thew new trigger price for the order.
|
|
2008
|
-
* @param
|
|
2009
|
-
* @param
|
|
2010
|
-
* @param
|
|
2011
|
-
* @param
|
|
2008
|
+
* @param auctionDuration:
|
|
2009
|
+
* @param auctionStartPrice:
|
|
2010
|
+
* @param auctionEndPrice:
|
|
2011
|
+
* @param reduceOnly:
|
|
2012
|
+
* @param postOnly:
|
|
2013
|
+
* @param immediateOrCancel:
|
|
2014
|
+
* @param maxTs:
|
|
2012
2015
|
* @returns
|
|
2013
2016
|
*/
|
|
2014
|
-
async modifyOrder({ orderId, newBaseAmount, newLimitPrice, newOraclePriceOffset,
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
:
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
:
|
|
2029
|
-
const newOrderParams = {
|
|
2030
|
-
orderType: newOrderType || openOrder.orderType,
|
|
2031
|
-
marketType: openOrder.marketType,
|
|
2032
|
-
direction: openOrder.direction,
|
|
2033
|
-
baseAssetAmount: newBaseAmount || openOrder.baseAssetAmount,
|
|
2034
|
-
price: orderTypeHasLimitPrice
|
|
2035
|
-
? newLimitPrice || openOrder.price
|
|
2036
|
-
: undefined,
|
|
2037
|
-
marketIndex: openOrder.marketIndex,
|
|
2038
|
-
reduceOnly: openOrder.reduceOnly,
|
|
2039
|
-
postOnly: openOrder.postOnly
|
|
2040
|
-
? types_1.PostOnlyParams.MUST_POST_ONLY
|
|
2041
|
-
: types_1.PostOnlyParams.NONE,
|
|
2042
|
-
immediateOrCancel: openOrder.immediateOrCancel,
|
|
2043
|
-
triggerPrice: orderTypeHasTrigger
|
|
2044
|
-
? newTriggerPrice || openOrder.triggerPrice
|
|
2045
|
-
: undefined,
|
|
2046
|
-
triggerCondition: orderTypeHasTrigger
|
|
2047
|
-
? newTriggerCondition || openOrder.triggerCondition
|
|
2048
|
-
: undefined,
|
|
2049
|
-
oraclePriceOffset: newOraclePriceOffset || openOrder.oraclePriceOffset,
|
|
2050
|
-
auctionDuration: auctionDuration !== null && auctionDuration !== void 0 ? auctionDuration : openOrder.auctionDuration,
|
|
2051
|
-
maxTs: openOrder.maxTs,
|
|
2052
|
-
auctionStartPrice: auctionStartPrice || openOrder.auctionStartPrice,
|
|
2053
|
-
auctionEndPrice: auctionEndPrice || openOrder.auctionEndPrice,
|
|
2054
|
-
userOrderId: openOrder.userOrderId,
|
|
2017
|
+
async modifyOrder({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, txParams, }) {
|
|
2018
|
+
const orderParams = {
|
|
2019
|
+
baseAssetAmount: newBaseAmount || null,
|
|
2020
|
+
direction: newDirection || null,
|
|
2021
|
+
price: newLimitPrice || null,
|
|
2022
|
+
oraclePriceOffset: newOraclePriceOffset || null,
|
|
2023
|
+
triggerPrice: newTriggerPrice || null,
|
|
2024
|
+
triggerCondition: newTriggerCondition || null,
|
|
2025
|
+
auctionDuration: auctionDuration || null,
|
|
2026
|
+
auctionStartPrice: auctionStartPrice || null,
|
|
2027
|
+
auctionEndPrice: auctionEndPrice || null,
|
|
2028
|
+
reduceOnly: reduceOnly || null,
|
|
2029
|
+
postOnly: postOnly || null,
|
|
2030
|
+
immediateOrCancel: immediateOrCancel || null,
|
|
2031
|
+
maxTs: maxTs || null,
|
|
2055
2032
|
};
|
|
2056
|
-
const
|
|
2057
|
-
? await this.getPlaceSpotOrderIx(newOrderParams)
|
|
2058
|
-
: await this.getPlacePerpOrderIx(newOrderParams);
|
|
2059
|
-
const tx = new web3_js_1.Transaction();
|
|
2060
|
-
tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
2061
|
-
units: 1000000,
|
|
2062
|
-
}));
|
|
2063
|
-
tx.add(cancelOrderIx);
|
|
2064
|
-
tx.add(placeOrderIx);
|
|
2065
|
-
const { txSig, slot } = await this.sendTransaction(tx, [], this.opts);
|
|
2066
|
-
if (isSpot) {
|
|
2067
|
-
this.spotMarketLastSlotCache.set(newOrderParams.marketIndex, slot);
|
|
2068
|
-
this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
|
|
2069
|
-
}
|
|
2070
|
-
else {
|
|
2071
|
-
this.perpMarketLastSlotCache.set(newOrderParams.marketIndex, slot);
|
|
2072
|
-
}
|
|
2033
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getModifyOrderIx(orderId, orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
2073
2034
|
return txSig;
|
|
2074
2035
|
}
|
|
2036
|
+
async getModifyOrderIx(orderId, orderParams) {
|
|
2037
|
+
const userAccountPublicKey = await this.getUserAccountPublicKey();
|
|
2038
|
+
const remainingAccounts = this.getRemainingAccounts({
|
|
2039
|
+
userAccounts: [this.getUserAccount()],
|
|
2040
|
+
useMarketLastSlotCache: true,
|
|
2041
|
+
});
|
|
2042
|
+
return await this.program.instruction.modifyOrder(orderId, orderParams, {
|
|
2043
|
+
accounts: {
|
|
2044
|
+
state: await this.getStatePublicKey(),
|
|
2045
|
+
user: userAccountPublicKey,
|
|
2046
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
2047
|
+
authority: this.wallet.publicKey,
|
|
2048
|
+
},
|
|
2049
|
+
remainingAccounts,
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2075
2052
|
/**
|
|
2076
2053
|
* Modifies an open order by closing it and replacing it with a new order.
|
|
2077
2054
|
* @param userOrderId: The open order to modify
|
|
2078
|
-
* @param
|
|
2079
|
-
* @param
|
|
2080
|
-
* @param
|
|
2081
|
-
* @param
|
|
2055
|
+
* @param newDirection: The new direction for the order
|
|
2056
|
+
* @param newBaseAmount: The new base amount for the order
|
|
2057
|
+
* @param newLimitPice: The new limit price for the order
|
|
2058
|
+
* @param newOraclePriceOffset: The new oracle price offset for the order
|
|
2082
2059
|
* @param newTriggerPrice: Optional - Thew new trigger price for the order.
|
|
2083
|
-
* @param isSpot: Set to true if the order is a spot order
|
|
2084
2060
|
* @param auctionDuration: Only required if order type changed to market from something else
|
|
2085
2061
|
* @param auctionStartPrice: Only required if order type changed to market from something else
|
|
2086
2062
|
* @param auctionEndPrice: Only required if order type changed to market from something else
|
|
2063
|
+
* @param reduceOnly:
|
|
2064
|
+
* @param postOnly:
|
|
2065
|
+
* @param immediateOrCancel:
|
|
2066
|
+
* @param maxTs:
|
|
2087
2067
|
* @returns
|
|
2088
2068
|
*/
|
|
2089
|
-
async modifyOrderByUserOrderId({ userOrderId, newBaseAmount, newLimitPrice, newOraclePriceOffset,
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
:
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
:
|
|
2104
|
-
const newOrderParams = {
|
|
2105
|
-
orderType: newOrderType || openOrder.orderType,
|
|
2106
|
-
marketType: openOrder.marketType,
|
|
2107
|
-
direction: openOrder.direction,
|
|
2108
|
-
baseAssetAmount: newBaseAmount || openOrder.baseAssetAmount,
|
|
2109
|
-
price: orderTypeHasLimitPrice
|
|
2110
|
-
? newLimitPrice || openOrder.price
|
|
2111
|
-
: undefined,
|
|
2112
|
-
marketIndex: openOrder.marketIndex,
|
|
2113
|
-
reduceOnly: openOrder.reduceOnly,
|
|
2114
|
-
postOnly: openOrder.postOnly
|
|
2115
|
-
? types_1.PostOnlyParams.MUST_POST_ONLY
|
|
2116
|
-
: types_1.PostOnlyParams.NONE,
|
|
2117
|
-
immediateOrCancel: openOrder.immediateOrCancel,
|
|
2118
|
-
triggerPrice: orderTypeHasTrigger
|
|
2119
|
-
? newTriggerPrice || openOrder.triggerPrice
|
|
2120
|
-
: undefined,
|
|
2121
|
-
triggerCondition: orderTypeHasTrigger
|
|
2122
|
-
? newTriggerCondition || openOrder.triggerCondition
|
|
2123
|
-
: undefined,
|
|
2124
|
-
oraclePriceOffset: newOraclePriceOffset || openOrder.oraclePriceOffset,
|
|
2125
|
-
auctionDuration: auctionDuration || openOrder.auctionDuration,
|
|
2126
|
-
maxTs: openOrder.maxTs,
|
|
2127
|
-
auctionStartPrice: auctionStartPrice || openOrder.auctionStartPrice,
|
|
2128
|
-
auctionEndPrice: auctionEndPrice || openOrder.auctionEndPrice,
|
|
2129
|
-
userOrderId: openOrder.userOrderId,
|
|
2069
|
+
async modifyOrderByUserOrderId({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, txParams, }) {
|
|
2070
|
+
const orderParams = {
|
|
2071
|
+
baseAssetAmount: newBaseAmount || null,
|
|
2072
|
+
direction: newDirection || null,
|
|
2073
|
+
price: newLimitPrice || null,
|
|
2074
|
+
oraclePriceOffset: newOraclePriceOffset || null,
|
|
2075
|
+
triggerPrice: newTriggerPrice || null,
|
|
2076
|
+
triggerCondition: newTriggerCondition || null,
|
|
2077
|
+
auctionDuration: auctionDuration || null,
|
|
2078
|
+
auctionStartPrice: auctionStartPrice || null,
|
|
2079
|
+
auctionEndPrice: auctionEndPrice || null,
|
|
2080
|
+
reduceOnly: reduceOnly || null,
|
|
2081
|
+
postOnly: postOnly || null,
|
|
2082
|
+
immediateOrCancel: immediateOrCancel || null,
|
|
2083
|
+
maxTs: maxTs || null,
|
|
2130
2084
|
};
|
|
2131
|
-
const
|
|
2132
|
-
? await this.getPlaceSpotOrderIx(newOrderParams)
|
|
2133
|
-
: await this.getPlacePerpOrderIx(newOrderParams);
|
|
2134
|
-
const tx = new web3_js_1.Transaction();
|
|
2135
|
-
tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
2136
|
-
units: 1000000,
|
|
2137
|
-
}));
|
|
2138
|
-
tx.add(cancelOrderIx);
|
|
2139
|
-
tx.add(placeOrderIx);
|
|
2140
|
-
const { txSig, slot } = await this.sendTransaction(tx, [], this.opts);
|
|
2141
|
-
if (isSpot) {
|
|
2142
|
-
this.spotMarketLastSlotCache.set(newOrderParams.marketIndex, slot);
|
|
2143
|
-
this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
|
|
2144
|
-
}
|
|
2145
|
-
else {
|
|
2146
|
-
this.perpMarketLastSlotCache.set(newOrderParams.marketIndex, slot);
|
|
2147
|
-
}
|
|
2085
|
+
const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getModifyOrderByUserIdIx(userOrderId, orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
|
|
2148
2086
|
return txSig;
|
|
2149
2087
|
}
|
|
2088
|
+
async getModifyOrderByUserIdIx(userOrderId, orderParams) {
|
|
2089
|
+
const userAccountPublicKey = await this.getUserAccountPublicKey();
|
|
2090
|
+
const remainingAccounts = this.getRemainingAccounts({
|
|
2091
|
+
userAccounts: [this.getUserAccount()],
|
|
2092
|
+
useMarketLastSlotCache: true,
|
|
2093
|
+
});
|
|
2094
|
+
return await this.program.instruction.modifyOrderByUserId(userOrderId, orderParams, {
|
|
2095
|
+
accounts: {
|
|
2096
|
+
state: await this.getStatePublicKey(),
|
|
2097
|
+
user: userAccountPublicKey,
|
|
2098
|
+
userStats: this.getUserStatsAccountPublicKey(),
|
|
2099
|
+
authority: this.wallet.publicKey,
|
|
2100
|
+
},
|
|
2101
|
+
remainingAccounts,
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2150
2104
|
async settlePNLs(users, marketIndexes) {
|
|
2151
2105
|
const ixs = [];
|
|
2152
2106
|
for (const { settleeUserAccountPublicKey, settleeUserAccount } of users) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Connection, TransactionSignature } from '@solana/web3.js';
|
|
3
|
-
import { Program } from '@
|
|
3
|
+
import { Program } from '@coral-xyz/anchor';
|
|
4
4
|
import { EventSubscriptionOptions, EventType, WrappedEvents, EventMap, EventSubscriberEvents } from './types';
|
|
5
5
|
import { EventList } from './eventList';
|
|
6
6
|
import { EventEmitter } from 'events';
|
|
@@ -97,7 +97,8 @@ class EventSubscriber {
|
|
|
97
97
|
parseEventsFromLogs(txSig, slot, logs) {
|
|
98
98
|
const records = [];
|
|
99
99
|
// @ts-ignore
|
|
100
|
-
this.program._events._eventParser.parseLogs(logs,
|
|
100
|
+
const eventGenerator = this.program._events._eventParser.parseLogs(logs, false);
|
|
101
|
+
for (const event of eventGenerator) {
|
|
101
102
|
const expectRecordType = this.eventListMap.has(event.name);
|
|
102
103
|
if (expectRecordType) {
|
|
103
104
|
event.data.txSig = txSig;
|
|
@@ -105,7 +106,7 @@ class EventSubscriber {
|
|
|
105
106
|
event.data.eventType = event.name;
|
|
106
107
|
records.push(event.data);
|
|
107
108
|
}
|
|
108
|
-
}
|
|
109
|
+
}
|
|
109
110
|
return records;
|
|
110
111
|
}
|
|
111
112
|
awaitTx(txSig) {
|
package/lib/events/fetchLogs.js
CHANGED
|
@@ -61,12 +61,13 @@ class LogParser {
|
|
|
61
61
|
parseEventsFromLogs(event) {
|
|
62
62
|
const records = [];
|
|
63
63
|
// @ts-ignore
|
|
64
|
-
this.program._events._eventParser.parseLogs(event.logs,
|
|
64
|
+
const eventGenerator = this.program._events._eventParser.parseLogs(event.logs, false);
|
|
65
|
+
for (const eventLog of eventGenerator) {
|
|
65
66
|
eventLog.data.txSig = event.txSig;
|
|
66
67
|
eventLog.data.slot = event.slot;
|
|
67
68
|
eventLog.data.eventType = eventLog.name;
|
|
68
69
|
records.push(eventLog.data);
|
|
69
|
-
}
|
|
70
|
+
}
|
|
70
71
|
return records;
|
|
71
72
|
}
|
|
72
73
|
}
|
package/lib/examples/loadDlob.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const anchor_1 = require("@
|
|
3
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
const __2 = require("..");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTokenAddress = void 0;
|
|
4
|
-
const anchor_1 = require("@
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
5
|
const __1 = require("..");
|
|
6
6
|
const spl_token_1 = require("@solana/spl-token");
|
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
package/lib/factory/bigNum.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { BN } from '@project-serum/anchor';
|
|
1
|
+
import { BN } from '@coral-xyz/anchor';
|
|
3
2
|
export declare class BigNum {
|
|
4
3
|
val: BN;
|
|
5
4
|
precision: BN;
|
|
@@ -44,11 +43,11 @@ export declare class BigNum {
|
|
|
44
43
|
gte(bn: BigNum | BN, ignorePrecision?: boolean): boolean;
|
|
45
44
|
lte(bn: BigNum | BN, ignorePrecision?: boolean): boolean;
|
|
46
45
|
eq(bn: BigNum | BN, ignorePrecision?: boolean): boolean;
|
|
47
|
-
eqZero():
|
|
48
|
-
gtZero():
|
|
49
|
-
ltZero():
|
|
50
|
-
gteZero():
|
|
51
|
-
lteZero():
|
|
46
|
+
eqZero(): any;
|
|
47
|
+
gtZero(): any;
|
|
48
|
+
ltZero(): any;
|
|
49
|
+
gteZero(): any;
|
|
50
|
+
lteZero(): any;
|
|
52
51
|
abs(): BigNum;
|
|
53
52
|
neg(): BigNum;
|
|
54
53
|
toString: (base?: number | 'hex', length?: number) => string;
|
|
@@ -88,8 +87,8 @@ export declare class BigNum {
|
|
|
88
87
|
toNotional(useTradePrecision?: boolean, precisionOverride?: number): string;
|
|
89
88
|
toMillified(precision?: number, rounded?: boolean): string;
|
|
90
89
|
toJSON(): {
|
|
91
|
-
val:
|
|
92
|
-
precision:
|
|
90
|
+
val: any;
|
|
91
|
+
precision: any;
|
|
93
92
|
};
|
|
94
93
|
isNeg(): boolean;
|
|
95
94
|
isPos(): boolean;
|
package/lib/factory/bigNum.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BigNum = void 0;
|
|
4
|
-
const anchor_1 = require("@
|
|
4
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
5
|
const assert_1 = require("../assert/assert");
|
|
6
6
|
const numericConstants_1 = require("./../constants/numericConstants");
|
|
7
7
|
class BigNum {
|
|
@@ -5,7 +5,7 @@ const types_1 = require("../types");
|
|
|
5
5
|
const pythClient_1 = require("../oracles/pythClient");
|
|
6
6
|
// import { SwitchboardClient } from '../oracles/switchboardClient';
|
|
7
7
|
const quoteAssetOracleClient_1 = require("../oracles/quoteAssetOracleClient");
|
|
8
|
-
const anchor_1 = require("@
|
|
8
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
9
9
|
function getOracleClient(oracleSource, connection) {
|
|
10
10
|
if ((0, types_1.isVariant)(oracleSource, 'pyth')) {
|
|
11
11
|
return new pythClient_1.PythClient(connection);
|
package/lib/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.25.0-beta.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -428,6 +428,72 @@
|
|
|
428
428
|
}
|
|
429
429
|
]
|
|
430
430
|
},
|
|
431
|
+
{
|
|
432
|
+
"name": "modifyOrder",
|
|
433
|
+
"accounts": [
|
|
434
|
+
{
|
|
435
|
+
"name": "state",
|
|
436
|
+
"isMut": false,
|
|
437
|
+
"isSigner": false
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"name": "user",
|
|
441
|
+
"isMut": true,
|
|
442
|
+
"isSigner": false
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"name": "authority",
|
|
446
|
+
"isMut": false,
|
|
447
|
+
"isSigner": true
|
|
448
|
+
}
|
|
449
|
+
],
|
|
450
|
+
"args": [
|
|
451
|
+
{
|
|
452
|
+
"name": "orderId",
|
|
453
|
+
"type": {
|
|
454
|
+
"option": "u32"
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
"name": "modifyOrderParams",
|
|
459
|
+
"type": {
|
|
460
|
+
"defined": "ModifyOrderParams"
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
]
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
"name": "modifyOrderByUserId",
|
|
467
|
+
"accounts": [
|
|
468
|
+
{
|
|
469
|
+
"name": "state",
|
|
470
|
+
"isMut": false,
|
|
471
|
+
"isSigner": false
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
"name": "user",
|
|
475
|
+
"isMut": true,
|
|
476
|
+
"isSigner": false
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"name": "authority",
|
|
480
|
+
"isMut": false,
|
|
481
|
+
"isSigner": true
|
|
482
|
+
}
|
|
483
|
+
],
|
|
484
|
+
"args": [
|
|
485
|
+
{
|
|
486
|
+
"name": "userOrderId",
|
|
487
|
+
"type": "u8"
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
"name": "modifyOrderParams",
|
|
491
|
+
"type": {
|
|
492
|
+
"defined": "ModifyOrderParams"
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
]
|
|
496
|
+
},
|
|
431
497
|
{
|
|
432
498
|
"name": "placeAndTakePerpOrder",
|
|
433
499
|
"accounts": [
|
|
@@ -4882,6 +4948,98 @@
|
|
|
4882
4948
|
]
|
|
4883
4949
|
}
|
|
4884
4950
|
},
|
|
4951
|
+
{
|
|
4952
|
+
"name": "ModifyOrderParams",
|
|
4953
|
+
"type": {
|
|
4954
|
+
"kind": "struct",
|
|
4955
|
+
"fields": [
|
|
4956
|
+
{
|
|
4957
|
+
"name": "direction",
|
|
4958
|
+
"type": {
|
|
4959
|
+
"option": {
|
|
4960
|
+
"defined": "PositionDirection"
|
|
4961
|
+
}
|
|
4962
|
+
}
|
|
4963
|
+
},
|
|
4964
|
+
{
|
|
4965
|
+
"name": "baseAssetAmount",
|
|
4966
|
+
"type": {
|
|
4967
|
+
"option": "u64"
|
|
4968
|
+
}
|
|
4969
|
+
},
|
|
4970
|
+
{
|
|
4971
|
+
"name": "price",
|
|
4972
|
+
"type": {
|
|
4973
|
+
"option": "u64"
|
|
4974
|
+
}
|
|
4975
|
+
},
|
|
4976
|
+
{
|
|
4977
|
+
"name": "reduceOnly",
|
|
4978
|
+
"type": {
|
|
4979
|
+
"option": "bool"
|
|
4980
|
+
}
|
|
4981
|
+
},
|
|
4982
|
+
{
|
|
4983
|
+
"name": "postOnly",
|
|
4984
|
+
"type": {
|
|
4985
|
+
"option": {
|
|
4986
|
+
"defined": "PostOnlyParam"
|
|
4987
|
+
}
|
|
4988
|
+
}
|
|
4989
|
+
},
|
|
4990
|
+
{
|
|
4991
|
+
"name": "immediateOrCancel",
|
|
4992
|
+
"type": {
|
|
4993
|
+
"option": "bool"
|
|
4994
|
+
}
|
|
4995
|
+
},
|
|
4996
|
+
{
|
|
4997
|
+
"name": "maxTs",
|
|
4998
|
+
"type": {
|
|
4999
|
+
"option": "i64"
|
|
5000
|
+
}
|
|
5001
|
+
},
|
|
5002
|
+
{
|
|
5003
|
+
"name": "triggerPrice",
|
|
5004
|
+
"type": {
|
|
5005
|
+
"option": "u64"
|
|
5006
|
+
}
|
|
5007
|
+
},
|
|
5008
|
+
{
|
|
5009
|
+
"name": "triggerCondition",
|
|
5010
|
+
"type": {
|
|
5011
|
+
"option": {
|
|
5012
|
+
"defined": "OrderTriggerCondition"
|
|
5013
|
+
}
|
|
5014
|
+
}
|
|
5015
|
+
},
|
|
5016
|
+
{
|
|
5017
|
+
"name": "oraclePriceOffset",
|
|
5018
|
+
"type": {
|
|
5019
|
+
"option": "i32"
|
|
5020
|
+
}
|
|
5021
|
+
},
|
|
5022
|
+
{
|
|
5023
|
+
"name": "auctionDuration",
|
|
5024
|
+
"type": {
|
|
5025
|
+
"option": "u8"
|
|
5026
|
+
}
|
|
5027
|
+
},
|
|
5028
|
+
{
|
|
5029
|
+
"name": "auctionStartPrice",
|
|
5030
|
+
"type": {
|
|
5031
|
+
"option": "i64"
|
|
5032
|
+
}
|
|
5033
|
+
},
|
|
5034
|
+
{
|
|
5035
|
+
"name": "auctionEndPrice",
|
|
5036
|
+
"type": {
|
|
5037
|
+
"option": "i64"
|
|
5038
|
+
}
|
|
5039
|
+
}
|
|
5040
|
+
]
|
|
5041
|
+
}
|
|
5042
|
+
},
|
|
4885
5043
|
{
|
|
4886
5044
|
"name": "LiquidatePerpRecord",
|
|
4887
5045
|
"type": {
|
|
@@ -5157,7 +5315,7 @@
|
|
|
5157
5315
|
"fields": [
|
|
5158
5316
|
{
|
|
5159
5317
|
"name": "revenueWithdrawSinceLastSettle",
|
|
5160
|
-
"type": "
|
|
5318
|
+
"type": "i64"
|
|
5161
5319
|
},
|
|
5162
5320
|
{
|
|
5163
5321
|
"name": "maxRevenueWithdrawPerPeriod",
|
|
@@ -6011,31 +6169,35 @@
|
|
|
6011
6169
|
}
|
|
6012
6170
|
},
|
|
6013
6171
|
{
|
|
6014
|
-
"name": "
|
|
6172
|
+
"name": "ModifyOrderId",
|
|
6015
6173
|
"type": {
|
|
6016
6174
|
"kind": "enum",
|
|
6017
6175
|
"variants": [
|
|
6018
6176
|
{
|
|
6019
|
-
"name": "
|
|
6177
|
+
"name": "UserOrderId",
|
|
6178
|
+
"fields": [
|
|
6179
|
+
"u8"
|
|
6180
|
+
]
|
|
6020
6181
|
},
|
|
6021
6182
|
{
|
|
6022
|
-
"name": "
|
|
6183
|
+
"name": "OrderId",
|
|
6184
|
+
"fields": [
|
|
6185
|
+
"u32"
|
|
6186
|
+
]
|
|
6023
6187
|
}
|
|
6024
6188
|
]
|
|
6025
6189
|
}
|
|
6026
6190
|
},
|
|
6027
6191
|
{
|
|
6028
|
-
"name": "
|
|
6192
|
+
"name": "PositionDirection",
|
|
6029
6193
|
"type": {
|
|
6030
6194
|
"kind": "enum",
|
|
6031
6195
|
"variants": [
|
|
6032
6196
|
{
|
|
6033
|
-
"name": "
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
}
|
|
6038
|
-
]
|
|
6197
|
+
"name": "Long"
|
|
6198
|
+
},
|
|
6199
|
+
{
|
|
6200
|
+
"name": "Short"
|
|
6039
6201
|
}
|
|
6040
6202
|
]
|
|
6041
6203
|
}
|
|
@@ -6049,7 +6211,7 @@
|
|
|
6049
6211
|
"name": "SerumV3"
|
|
6050
6212
|
},
|
|
6051
6213
|
{
|
|
6052
|
-
"name": "
|
|
6214
|
+
"name": "Match"
|
|
6053
6215
|
}
|
|
6054
6216
|
]
|
|
6055
6217
|
}
|
|
@@ -6410,7 +6572,7 @@
|
|
|
6410
6572
|
"kind": "enum",
|
|
6411
6573
|
"variants": [
|
|
6412
6574
|
{
|
|
6413
|
-
"name": "
|
|
6575
|
+
"name": "ExternalMarket"
|
|
6414
6576
|
},
|
|
6415
6577
|
{
|
|
6416
6578
|
"name": "Match"
|
|
@@ -8861,6 +9023,11 @@
|
|
|
8861
9023
|
"code": 6240,
|
|
8862
9024
|
"name": "InvalidMarketAccountforDeletion",
|
|
8863
9025
|
"msg": "Invalid MarketAccount for Deletion"
|
|
9026
|
+
},
|
|
9027
|
+
{
|
|
9028
|
+
"code": 6241,
|
|
9029
|
+
"name": "InvalidSpotFulfillmentParams",
|
|
9030
|
+
"msg": "Invalid Spot Fulfillment Params"
|
|
8864
9031
|
}
|
|
8865
9032
|
]
|
|
8866
9033
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.pyth = exports.PublicKey = exports.BN = void 0;
|
|
21
|
-
const anchor_1 = require("@
|
|
21
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
22
22
|
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return anchor_1.BN; } });
|
|
23
23
|
const web3_js_1 = require("@solana/web3.js");
|
|
24
24
|
Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return web3_js_1.PublicKey; } });
|