@drift-labs/sdk 0.2.0-master.18 → 0.2.0-master.19
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/lib/clearingHouse.js +6 -1
- package/package.json +1 -1
- package/src/clearingHouse.ts +9 -1
- package/src/types.js +0 -125
package/lib/clearingHouse.js
CHANGED
|
@@ -1074,7 +1074,12 @@ class ClearingHouse {
|
|
|
1074
1074
|
for (const { settleeUserAccountPublicKey, settleeUserAccount } of users) {
|
|
1075
1075
|
ixs.push(await this.settlePNLIx(settleeUserAccountPublicKey, settleeUserAccount, marketIndex));
|
|
1076
1076
|
}
|
|
1077
|
-
const tx = new web3_js_1.Transaction()
|
|
1077
|
+
const tx = new web3_js_1.Transaction()
|
|
1078
|
+
.add(web3_js_1.ComputeBudgetProgram.requestUnits({
|
|
1079
|
+
units: 1200000,
|
|
1080
|
+
additionalFee: 0,
|
|
1081
|
+
}))
|
|
1082
|
+
.add(...ixs);
|
|
1078
1083
|
const { txSig } = await this.txSender.send(tx, [], this.opts);
|
|
1079
1084
|
return txSig;
|
|
1080
1085
|
}
|
package/package.json
CHANGED
package/src/clearingHouse.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
LAMPORTS_PER_SOL,
|
|
32
32
|
Signer,
|
|
33
33
|
SystemProgram,
|
|
34
|
+
ComputeBudgetProgram,
|
|
34
35
|
} from '@solana/web3.js';
|
|
35
36
|
|
|
36
37
|
import { TokenFaucet } from './tokenFaucet';
|
|
@@ -1754,7 +1755,14 @@ export class ClearingHouse {
|
|
|
1754
1755
|
);
|
|
1755
1756
|
}
|
|
1756
1757
|
|
|
1757
|
-
const tx = new Transaction()
|
|
1758
|
+
const tx = new Transaction()
|
|
1759
|
+
.add(
|
|
1760
|
+
ComputeBudgetProgram.requestUnits({
|
|
1761
|
+
units: 1_200_000,
|
|
1762
|
+
additionalFee: 0,
|
|
1763
|
+
})
|
|
1764
|
+
)
|
|
1765
|
+
.add(...ixs);
|
|
1758
1766
|
|
|
1759
1767
|
const { txSig } = await this.txSender.send(tx, [], this.opts);
|
|
1760
1768
|
return txSig;
|
package/src/types.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DefaultOrderParams = exports.LiquidationType = exports.TradeSide = exports.isOneOfVariant = exports.isVariant = exports.OrderTriggerCondition = exports.OrderActionExplanation = exports.OrderAction = exports.OrderDiscountTier = exports.OrderStatus = exports.OrderType = exports.OracleSource = exports.DepositDirection = exports.PositionDirection = exports.BankBalanceType = exports.SwapDirection = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
// # Utility Types / Enums / Constants
|
|
6
|
-
class SwapDirection {
|
|
7
|
-
}
|
|
8
|
-
exports.SwapDirection = SwapDirection;
|
|
9
|
-
SwapDirection.ADD = { add: {} };
|
|
10
|
-
SwapDirection.REMOVE = { remove: {} };
|
|
11
|
-
class BankBalanceType {
|
|
12
|
-
}
|
|
13
|
-
exports.BankBalanceType = BankBalanceType;
|
|
14
|
-
BankBalanceType.DEPOSIT = { deposit: {} };
|
|
15
|
-
BankBalanceType.BORROW = { borrow: {} };
|
|
16
|
-
class PositionDirection {
|
|
17
|
-
}
|
|
18
|
-
exports.PositionDirection = PositionDirection;
|
|
19
|
-
PositionDirection.LONG = { long: {} };
|
|
20
|
-
PositionDirection.SHORT = { short: {} };
|
|
21
|
-
class DepositDirection {
|
|
22
|
-
}
|
|
23
|
-
exports.DepositDirection = DepositDirection;
|
|
24
|
-
DepositDirection.DEPOSIT = { deposit: {} };
|
|
25
|
-
DepositDirection.WITHDRAW = { withdraw: {} };
|
|
26
|
-
class OracleSource {
|
|
27
|
-
}
|
|
28
|
-
exports.OracleSource = OracleSource;
|
|
29
|
-
OracleSource.PYTH = { pyth: {} };
|
|
30
|
-
OracleSource.SWITCHBOARD = { switchboard: {} };
|
|
31
|
-
OracleSource.QUOTE_ASSET = { quoteAsset: {} };
|
|
32
|
-
class OrderType {
|
|
33
|
-
}
|
|
34
|
-
exports.OrderType = OrderType;
|
|
35
|
-
OrderType.LIMIT = { limit: {} };
|
|
36
|
-
OrderType.TRIGGER_MARKET = { triggerMarket: {} };
|
|
37
|
-
OrderType.TRIGGER_LIMIT = { triggerLimit: {} };
|
|
38
|
-
OrderType.MARKET = { market: {} };
|
|
39
|
-
class OrderStatus {
|
|
40
|
-
}
|
|
41
|
-
exports.OrderStatus = OrderStatus;
|
|
42
|
-
OrderStatus.INIT = { init: {} };
|
|
43
|
-
OrderStatus.OPEN = { open: {} };
|
|
44
|
-
class OrderDiscountTier {
|
|
45
|
-
}
|
|
46
|
-
exports.OrderDiscountTier = OrderDiscountTier;
|
|
47
|
-
OrderDiscountTier.NONE = { none: {} };
|
|
48
|
-
OrderDiscountTier.FIRST = { first: {} };
|
|
49
|
-
OrderDiscountTier.SECOND = { second: {} };
|
|
50
|
-
OrderDiscountTier.THIRD = { third: {} };
|
|
51
|
-
OrderDiscountTier.FOURTH = { fourth: {} };
|
|
52
|
-
class OrderAction {
|
|
53
|
-
}
|
|
54
|
-
exports.OrderAction = OrderAction;
|
|
55
|
-
OrderAction.PLACE = { place: {} };
|
|
56
|
-
OrderAction.CANCEL = { cancel: {} };
|
|
57
|
-
OrderAction.EXPIRE = { expire: {} };
|
|
58
|
-
OrderAction.FILL = { fill: {} };
|
|
59
|
-
OrderAction.TRIGGER = { trigger: {} };
|
|
60
|
-
class OrderActionExplanation {
|
|
61
|
-
}
|
|
62
|
-
exports.OrderActionExplanation = OrderActionExplanation;
|
|
63
|
-
OrderActionExplanation.NONE = { none: {} };
|
|
64
|
-
OrderActionExplanation.BREACHED_MARGIN_REQUIREMENT = {
|
|
65
|
-
breachedMarginRequirement: {},
|
|
66
|
-
};
|
|
67
|
-
OrderActionExplanation.ORACLE_PRICE_BREACHED_LIMIT_PRICE = {
|
|
68
|
-
oraclePriceBreachedLimitPrice: {},
|
|
69
|
-
};
|
|
70
|
-
OrderActionExplanation.MARKET_ORDER_FILLED_TO_LIMIT_PRICE = {
|
|
71
|
-
marketOrderFilledToLimitPrice: {},
|
|
72
|
-
};
|
|
73
|
-
class OrderTriggerCondition {
|
|
74
|
-
}
|
|
75
|
-
exports.OrderTriggerCondition = OrderTriggerCondition;
|
|
76
|
-
OrderTriggerCondition.ABOVE = { above: {} };
|
|
77
|
-
OrderTriggerCondition.BELOW = { below: {} };
|
|
78
|
-
function isVariant(object, type) {
|
|
79
|
-
return object.hasOwnProperty(type);
|
|
80
|
-
}
|
|
81
|
-
exports.isVariant = isVariant;
|
|
82
|
-
function isOneOfVariant(object, types) {
|
|
83
|
-
return types.reduce((result, type) => {
|
|
84
|
-
return result || object.hasOwnProperty(type);
|
|
85
|
-
}, false);
|
|
86
|
-
}
|
|
87
|
-
exports.isOneOfVariant = isOneOfVariant;
|
|
88
|
-
var TradeSide;
|
|
89
|
-
(function (TradeSide) {
|
|
90
|
-
TradeSide[TradeSide["None"] = 0] = "None";
|
|
91
|
-
TradeSide[TradeSide["Buy"] = 1] = "Buy";
|
|
92
|
-
TradeSide[TradeSide["Sell"] = 2] = "Sell";
|
|
93
|
-
})(TradeSide = exports.TradeSide || (exports.TradeSide = {}));
|
|
94
|
-
class LiquidationType {
|
|
95
|
-
}
|
|
96
|
-
exports.LiquidationType = LiquidationType;
|
|
97
|
-
LiquidationType.LIQUIDATE_PERP = { liquidatePerp: {} };
|
|
98
|
-
LiquidationType.LIQUIDATE_BORROW = { liquidateBorrow: {} };
|
|
99
|
-
LiquidationType.LIQUIDATE_BORROW_FOR_PERP_PNL = {
|
|
100
|
-
liquidateBorrowForPerpPnl: {},
|
|
101
|
-
};
|
|
102
|
-
LiquidationType.LIQUIDATE_PERP_PNL_FOR_DEPOSIT = {
|
|
103
|
-
liquidatePerpPnlForDeposit: {},
|
|
104
|
-
};
|
|
105
|
-
exports.DefaultOrderParams = {
|
|
106
|
-
orderType: OrderType.MARKET,
|
|
107
|
-
userOrderId: 0,
|
|
108
|
-
direction: PositionDirection.LONG,
|
|
109
|
-
baseAssetAmount: _1.ZERO,
|
|
110
|
-
price: _1.ZERO,
|
|
111
|
-
marketIndex: _1.ZERO,
|
|
112
|
-
reduceOnly: false,
|
|
113
|
-
postOnly: false,
|
|
114
|
-
immediateOrCancel: false,
|
|
115
|
-
triggerPrice: _1.ZERO,
|
|
116
|
-
triggerCondition: OrderTriggerCondition.ABOVE,
|
|
117
|
-
positionLimit: _1.ZERO,
|
|
118
|
-
oraclePriceOffset: _1.ZERO,
|
|
119
|
-
padding0: _1.ZERO,
|
|
120
|
-
padding1: _1.ZERO,
|
|
121
|
-
optionalAccounts: {
|
|
122
|
-
discountToken: false,
|
|
123
|
-
referrer: false,
|
|
124
|
-
},
|
|
125
|
-
};
|