@drift-labs/sdk 2.36.1-beta.5 → 2.36.1-beta.7
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/lib/dlob/DLOB.d.ts +8 -0
- package/lib/dlob/DLOB.js +15 -0
- package/lib/driftClient.d.ts +1 -0
- package/lib/driftClient.js +15 -0
- package/lib/idl/drift.json +41 -0
- package/package.json +1 -1
- package/src/dlob/DLOB.ts +38 -0
- package/src/driftClient.ts +24 -0
- package/src/idl/drift.json +41 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.36.1-beta.
|
|
1
|
+
2.36.1-beta.7
|
package/lib/dlob/DLOB.d.ts
CHANGED
|
@@ -154,5 +154,13 @@ export declare class DLOB {
|
|
|
154
154
|
slot: number;
|
|
155
155
|
oraclePriceData: OraclePriceData;
|
|
156
156
|
}): BN;
|
|
157
|
+
getBestMakers({ marketIndex, marketType, direction, slot, oraclePriceData, numMakers, }: {
|
|
158
|
+
marketIndex: number;
|
|
159
|
+
marketType: MarketType;
|
|
160
|
+
direction: PositionDirection;
|
|
161
|
+
slot: number;
|
|
162
|
+
oraclePriceData: OraclePriceData;
|
|
163
|
+
numMakers: number;
|
|
164
|
+
}): PublicKey[];
|
|
157
165
|
}
|
|
158
166
|
export {};
|
package/lib/dlob/DLOB.js
CHANGED
|
@@ -1063,5 +1063,20 @@ class DLOB {
|
|
|
1063
1063
|
return this.estimateFillExactBaseAmountInForSide(baseAmount, oraclePriceData, slot, this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData));
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
|
+
getBestMakers({ marketIndex, marketType, direction, slot, oraclePriceData, numMakers, }) {
|
|
1067
|
+
const makers = new Map();
|
|
1068
|
+
const generator = (0, __1.isVariant)(direction, 'long')
|
|
1069
|
+
? this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData)
|
|
1070
|
+
: this.getRestingLimitAsks(marketIndex, slot, marketType, oraclePriceData);
|
|
1071
|
+
for (const node of generator) {
|
|
1072
|
+
if (!makers.has(node.userAccount.toString())) {
|
|
1073
|
+
makers.set(node.userAccount.toString(), node.userAccount);
|
|
1074
|
+
}
|
|
1075
|
+
if (makers.size === numMakers) {
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
return Array.from(makers.values());
|
|
1080
|
+
}
|
|
1066
1081
|
}
|
|
1067
1082
|
exports.DLOB = DLOB;
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -588,6 +588,7 @@ export declare class DriftClient {
|
|
|
588
588
|
settleRevenueToInsuranceFund(marketIndex: number): Promise<TransactionSignature>;
|
|
589
589
|
resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
590
590
|
getResolvePerpPnlDeficitIx(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
591
|
+
depositIntoSpotMarketRevenuePool(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
591
592
|
getPerpMarketExtendedInfo(marketIndex: number): PerpMarketExtendedInfo;
|
|
592
593
|
/**
|
|
593
594
|
* Returns the market index and type for a given market name
|
package/lib/driftClient.js
CHANGED
|
@@ -3094,6 +3094,21 @@ class DriftClient {
|
|
|
3094
3094
|
remainingAccounts: remainingAccounts,
|
|
3095
3095
|
});
|
|
3096
3096
|
}
|
|
3097
|
+
async depositIntoSpotMarketRevenuePool(marketIndex, amount, userTokenAccountPublicKey) {
|
|
3098
|
+
const spotMarket = await this.getSpotMarketAccount(marketIndex);
|
|
3099
|
+
const tx = await this.program.transaction.depositIntoSpotMarketRevenuePool(amount, {
|
|
3100
|
+
accounts: {
|
|
3101
|
+
state: await this.getStatePublicKey(),
|
|
3102
|
+
spotMarket: spotMarket.vault,
|
|
3103
|
+
userTokenAccount: userTokenAccountPublicKey,
|
|
3104
|
+
authority: this.wallet.publicKey,
|
|
3105
|
+
spotMarketVault: spotMarket.vault,
|
|
3106
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3107
|
+
},
|
|
3108
|
+
});
|
|
3109
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3110
|
+
return txSig;
|
|
3111
|
+
}
|
|
3097
3112
|
getPerpMarketExtendedInfo(marketIndex) {
|
|
3098
3113
|
var _a, _b;
|
|
3099
3114
|
const marketAccount = this.getPerpMarketAccount(marketIndex);
|
package/lib/idl/drift.json
CHANGED
|
@@ -2964,6 +2964,47 @@
|
|
|
2964
2964
|
}
|
|
2965
2965
|
]
|
|
2966
2966
|
},
|
|
2967
|
+
{
|
|
2968
|
+
"name": "depositIntoSpotMarketRevenuePool",
|
|
2969
|
+
"accounts": [
|
|
2970
|
+
{
|
|
2971
|
+
"name": "spotMarket",
|
|
2972
|
+
"isMut": true,
|
|
2973
|
+
"isSigner": false
|
|
2974
|
+
},
|
|
2975
|
+
{
|
|
2976
|
+
"name": "state",
|
|
2977
|
+
"isMut": false,
|
|
2978
|
+
"isSigner": false
|
|
2979
|
+
},
|
|
2980
|
+
{
|
|
2981
|
+
"name": "authority",
|
|
2982
|
+
"isMut": true,
|
|
2983
|
+
"isSigner": true
|
|
2984
|
+
},
|
|
2985
|
+
{
|
|
2986
|
+
"name": "spotMarketVault",
|
|
2987
|
+
"isMut": true,
|
|
2988
|
+
"isSigner": false
|
|
2989
|
+
},
|
|
2990
|
+
{
|
|
2991
|
+
"name": "userTokenAccount",
|
|
2992
|
+
"isMut": true,
|
|
2993
|
+
"isSigner": false
|
|
2994
|
+
},
|
|
2995
|
+
{
|
|
2996
|
+
"name": "tokenProgram",
|
|
2997
|
+
"isMut": false,
|
|
2998
|
+
"isSigner": false
|
|
2999
|
+
}
|
|
3000
|
+
],
|
|
3001
|
+
"args": [
|
|
3002
|
+
{
|
|
3003
|
+
"name": "amount",
|
|
3004
|
+
"type": "u64"
|
|
3005
|
+
}
|
|
3006
|
+
]
|
|
3007
|
+
},
|
|
2967
3008
|
{
|
|
2968
3009
|
"name": "repegAmmCurve",
|
|
2969
3010
|
"accounts": [
|
package/package.json
CHANGED
package/src/dlob/DLOB.ts
CHANGED
|
@@ -1925,4 +1925,42 @@ export class DLOB {
|
|
|
1925
1925
|
);
|
|
1926
1926
|
}
|
|
1927
1927
|
}
|
|
1928
|
+
|
|
1929
|
+
public getBestMakers({
|
|
1930
|
+
marketIndex,
|
|
1931
|
+
marketType,
|
|
1932
|
+
direction,
|
|
1933
|
+
slot,
|
|
1934
|
+
oraclePriceData,
|
|
1935
|
+
numMakers,
|
|
1936
|
+
}: {
|
|
1937
|
+
marketIndex: number;
|
|
1938
|
+
marketType: MarketType;
|
|
1939
|
+
direction: PositionDirection;
|
|
1940
|
+
slot: number;
|
|
1941
|
+
oraclePriceData: OraclePriceData;
|
|
1942
|
+
numMakers: number;
|
|
1943
|
+
}): PublicKey[] {
|
|
1944
|
+
const makers = new Map<string, PublicKey>();
|
|
1945
|
+
const generator = isVariant(direction, 'long')
|
|
1946
|
+
? this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData)
|
|
1947
|
+
: this.getRestingLimitAsks(
|
|
1948
|
+
marketIndex,
|
|
1949
|
+
slot,
|
|
1950
|
+
marketType,
|
|
1951
|
+
oraclePriceData
|
|
1952
|
+
);
|
|
1953
|
+
|
|
1954
|
+
for (const node of generator) {
|
|
1955
|
+
if (!makers.has(node.userAccount.toString())) {
|
|
1956
|
+
makers.set(node.userAccount.toString(), node.userAccount);
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
if (makers.size === numMakers) {
|
|
1960
|
+
break;
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
return Array.from(makers.values());
|
|
1965
|
+
}
|
|
1928
1966
|
}
|
package/src/driftClient.ts
CHANGED
|
@@ -5587,6 +5587,30 @@ export class DriftClient {
|
|
|
5587
5587
|
);
|
|
5588
5588
|
}
|
|
5589
5589
|
|
|
5590
|
+
public async depositIntoSpotMarketRevenuePool(
|
|
5591
|
+
marketIndex: number,
|
|
5592
|
+
amount: BN,
|
|
5593
|
+
userTokenAccountPublicKey: PublicKey
|
|
5594
|
+
): Promise<TransactionSignature> {
|
|
5595
|
+
const spotMarket = await this.getSpotMarketAccount(marketIndex);
|
|
5596
|
+
const tx = await this.program.transaction.depositIntoSpotMarketRevenuePool(
|
|
5597
|
+
amount,
|
|
5598
|
+
{
|
|
5599
|
+
accounts: {
|
|
5600
|
+
state: await this.getStatePublicKey(),
|
|
5601
|
+
spotMarket: spotMarket.vault,
|
|
5602
|
+
userTokenAccount: userTokenAccountPublicKey,
|
|
5603
|
+
authority: this.wallet.publicKey,
|
|
5604
|
+
spotMarketVault: spotMarket.vault,
|
|
5605
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
5606
|
+
},
|
|
5607
|
+
}
|
|
5608
|
+
);
|
|
5609
|
+
|
|
5610
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
5611
|
+
return txSig;
|
|
5612
|
+
}
|
|
5613
|
+
|
|
5590
5614
|
public getPerpMarketExtendedInfo(
|
|
5591
5615
|
marketIndex: number
|
|
5592
5616
|
): PerpMarketExtendedInfo {
|
package/src/idl/drift.json
CHANGED
|
@@ -2964,6 +2964,47 @@
|
|
|
2964
2964
|
}
|
|
2965
2965
|
]
|
|
2966
2966
|
},
|
|
2967
|
+
{
|
|
2968
|
+
"name": "depositIntoSpotMarketRevenuePool",
|
|
2969
|
+
"accounts": [
|
|
2970
|
+
{
|
|
2971
|
+
"name": "spotMarket",
|
|
2972
|
+
"isMut": true,
|
|
2973
|
+
"isSigner": false
|
|
2974
|
+
},
|
|
2975
|
+
{
|
|
2976
|
+
"name": "state",
|
|
2977
|
+
"isMut": false,
|
|
2978
|
+
"isSigner": false
|
|
2979
|
+
},
|
|
2980
|
+
{
|
|
2981
|
+
"name": "authority",
|
|
2982
|
+
"isMut": true,
|
|
2983
|
+
"isSigner": true
|
|
2984
|
+
},
|
|
2985
|
+
{
|
|
2986
|
+
"name": "spotMarketVault",
|
|
2987
|
+
"isMut": true,
|
|
2988
|
+
"isSigner": false
|
|
2989
|
+
},
|
|
2990
|
+
{
|
|
2991
|
+
"name": "userTokenAccount",
|
|
2992
|
+
"isMut": true,
|
|
2993
|
+
"isSigner": false
|
|
2994
|
+
},
|
|
2995
|
+
{
|
|
2996
|
+
"name": "tokenProgram",
|
|
2997
|
+
"isMut": false,
|
|
2998
|
+
"isSigner": false
|
|
2999
|
+
}
|
|
3000
|
+
],
|
|
3001
|
+
"args": [
|
|
3002
|
+
{
|
|
3003
|
+
"name": "amount",
|
|
3004
|
+
"type": "u64"
|
|
3005
|
+
}
|
|
3006
|
+
]
|
|
3007
|
+
},
|
|
2967
3008
|
{
|
|
2968
3009
|
"name": "repegAmmCurve",
|
|
2969
3010
|
"accounts": [
|