@hawksightco/hawk-sdk 1.3.39 → 1.3.40
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.
|
@@ -850,7 +850,7 @@ class Transactions {
|
|
|
850
850
|
}
|
|
851
851
|
// Re-deposit fees (TODO: How to re-deposit reward tokens that is not X or Y token?)
|
|
852
852
|
const { userWallet, newPosition, relativeBinRange, distribution, checkRange, } = params;
|
|
853
|
-
const redepositIx = yield this.ix.meteoraDlmm.
|
|
853
|
+
const redepositIx = yield this.ix.meteoraDlmm.redepositAutomation2(connection, {
|
|
854
854
|
userWallet,
|
|
855
855
|
lbPair: position.lbPair,
|
|
856
856
|
position: newPosition,
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import * as web3 from "@solana/web3.js";
|
|
2
|
-
import {
|
|
2
|
+
import { TokenType, StrategyType as OldStrategyType } from "../types";
|
|
3
3
|
import BN from "bn.js";
|
|
4
4
|
import { SimpleIxGenerator } from "../classes/SimpleIxGenerator";
|
|
5
|
+
export declare enum StrategyType {
|
|
6
|
+
Spot = 0,
|
|
7
|
+
Curve = 1,
|
|
8
|
+
BidAsk = 2
|
|
9
|
+
}
|
|
10
|
+
export declare function mapOldStrategyTypeToNew(oldStrategyType: OldStrategyType): StrategyType;
|
|
5
11
|
type InitializePositionAutomation = {
|
|
6
12
|
userWallet: web3.PublicKey;
|
|
7
13
|
lbPair: web3.PublicKey;
|
|
@@ -15,7 +21,19 @@ type OpenPositionAndDepositAutomation = {
|
|
|
15
21
|
position: web3.PublicKey;
|
|
16
22
|
relativeLowerBinId: number;
|
|
17
23
|
relativeUpperBinId: number;
|
|
18
|
-
strategyType:
|
|
24
|
+
strategyType: OldStrategyType;
|
|
25
|
+
checkRange: {
|
|
26
|
+
minBinId: number;
|
|
27
|
+
maxBinId: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type RedepositAutomation = {
|
|
31
|
+
userWallet: web3.PublicKey;
|
|
32
|
+
lbPair: web3.PublicKey;
|
|
33
|
+
position: web3.PublicKey;
|
|
34
|
+
relativeLowerBinId: number;
|
|
35
|
+
relativeUpperBinId: number;
|
|
36
|
+
strategyType: OldStrategyType;
|
|
19
37
|
checkRange: {
|
|
20
38
|
minBinId: number;
|
|
21
39
|
maxBinId: number;
|
|
@@ -73,6 +91,7 @@ export declare class MeteoraDlmmIxGenerator {
|
|
|
73
91
|
constructor(ix: SimpleIxGenerator);
|
|
74
92
|
initializePositionAutomation(connection: web3.Connection, { userWallet, lbPair, position, lowerBinId, upperBinId }: InitializePositionAutomation): Promise<web3.TransactionInstruction>;
|
|
75
93
|
redepositAutomation(connection: web3.Connection, { userWallet, lbPair, position, relativeLowerBinId, relativeUpperBinId, strategyType, checkRange }: OpenPositionAndDepositAutomation): Promise<web3.TransactionInstruction>;
|
|
94
|
+
redepositAutomation2(connection: web3.Connection, { userWallet, lbPair, position, relativeLowerBinId, relativeUpperBinId, strategyType, checkRange }: RedepositAutomation): Promise<web3.TransactionInstruction>;
|
|
76
95
|
claimFee(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
77
96
|
claimReward(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
78
97
|
claimFeeAutomation(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
@@ -90,6 +109,13 @@ export declare class MeteoraDlmmIxGenerator {
|
|
|
90
109
|
* @returns
|
|
91
110
|
*/
|
|
92
111
|
private meteora;
|
|
112
|
+
/**
|
|
113
|
+
* Meteora IDL
|
|
114
|
+
*
|
|
115
|
+
* @param connection
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
private dlmm;
|
|
93
119
|
}
|
|
94
120
|
export {};
|
|
95
121
|
//# sourceMappingURL=MeteoraDlmmIxGenerator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MeteoraDlmmIxGenerator.d.ts","sourceRoot":"","sources":["../../../src/ixGenerator/MeteoraDlmmIxGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAKxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"MeteoraDlmmIxGenerator.d.ts","sourceRoot":"","sources":["../../../src/ixGenerator/MeteoraDlmmIxGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAKxC,OAAO,EAAE,SAAS,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAajE,oBAAY,YAAY;IACtB,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,MAAM,IAAA;CACP;AAGD,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,eAAe,GAAG,YAAY,CAmBtF;AAED,KAAK,4BAA4B,GAAG;IAClC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAA;AAED,KAAK,gCAAgC,GAAG;IACtC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,eAAe,CAAC;IAC9B,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAA;CACF,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,MAAM,E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,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAWtG,oBAAoB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAWzG;;;;;OAKG;YACW,OAAO;IAIrB;;;;;OAKG;YACW,IAAI;CAGnB"}
|
|
@@ -45,7 +45,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.MeteoraDlmmIxGenerator = void 0;
|
|
48
|
+
exports.MeteoraDlmmIxGenerator = exports.StrategyType = void 0;
|
|
49
|
+
exports.mapOldStrategyTypeToNew = mapOldStrategyTypeToNew;
|
|
49
50
|
const web3 = __importStar(require("@solana/web3.js"));
|
|
50
51
|
const anchor_1 = require("../anchor");
|
|
51
52
|
const functions_1 = require("../functions");
|
|
@@ -61,6 +62,33 @@ const METEORA_EVENT_AUTHORITY = new web3.PublicKey('D1ZN9Wj1fRSUQfCjhvnu1hqDMT7h
|
|
|
61
62
|
* Meteora Program ID
|
|
62
63
|
*/
|
|
63
64
|
const METEORA_DLMM_PROGRAM = new web3.PublicKey('LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo');
|
|
65
|
+
var StrategyType;
|
|
66
|
+
(function (StrategyType) {
|
|
67
|
+
StrategyType[StrategyType["Spot"] = 0] = "Spot";
|
|
68
|
+
StrategyType[StrategyType["Curve"] = 1] = "Curve";
|
|
69
|
+
StrategyType[StrategyType["BidAsk"] = 2] = "BidAsk";
|
|
70
|
+
})(StrategyType || (exports.StrategyType = StrategyType = {}));
|
|
71
|
+
// Backwards-compatible mapping from old StrategyType to new StrategyType
|
|
72
|
+
function mapOldStrategyTypeToNew(oldStrategyType) {
|
|
73
|
+
// Handle the old enum values (0-8) and map them to the new simplified enum
|
|
74
|
+
switch (oldStrategyType) {
|
|
75
|
+
case 0: // SpotOneSide
|
|
76
|
+
case 3: // SpotBalanced
|
|
77
|
+
case 6: // SpotImBalanced
|
|
78
|
+
return StrategyType.Spot;
|
|
79
|
+
case 1: // CurveOneSide
|
|
80
|
+
case 4: // CurveBalanced
|
|
81
|
+
case 7: // CurveImBalanced
|
|
82
|
+
return StrategyType.Curve;
|
|
83
|
+
case 2: // BidAskOneSide
|
|
84
|
+
case 5: // BidAskBalanced
|
|
85
|
+
case 8: // BidAskImBalanced
|
|
86
|
+
return StrategyType.BidAsk;
|
|
87
|
+
default:
|
|
88
|
+
// Default fallback
|
|
89
|
+
return StrategyType.Spot;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
64
92
|
/**
|
|
65
93
|
* Meteora related instructions executed via iyf extension or iyf main
|
|
66
94
|
*/
|
|
@@ -153,7 +181,7 @@ class MeteoraDlmmIxGenerator {
|
|
|
153
181
|
// @ts-ignore
|
|
154
182
|
iyfExtensionIx: yield anchor_1.Anchor.instance().iyfExtension
|
|
155
183
|
.methods
|
|
156
|
-
.meteoraDlmmRedepositAutomation(relativeLowerBinId, relativeUpperBinId, strategyType, _checkRange)
|
|
184
|
+
.meteoraDlmmRedepositAutomation(relativeLowerBinId, relativeUpperBinId, mapOldStrategyTypeToNew(strategyType), _checkRange)
|
|
157
185
|
.accounts({
|
|
158
186
|
farm: addresses_1.USDC_FARM,
|
|
159
187
|
userPda,
|
|
@@ -183,6 +211,109 @@ class MeteoraDlmmIxGenerator {
|
|
|
183
211
|
});
|
|
184
212
|
});
|
|
185
213
|
}
|
|
214
|
+
redepositAutomation2(connection_1, _a) {
|
|
215
|
+
return __awaiter(this, arguments, void 0, function* (connection, { userWallet, lbPair, position, relativeLowerBinId, relativeUpperBinId, strategyType, checkRange }) {
|
|
216
|
+
// Initialize anchor
|
|
217
|
+
anchor_1.Anchor.initialize(connection);
|
|
218
|
+
// Meteora utility function
|
|
219
|
+
// const fn = new MeteoraFunctions(this.ix);
|
|
220
|
+
// Generate user pda
|
|
221
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
222
|
+
// Get meteora pool
|
|
223
|
+
const lbPairInfo = yield anchor_1.Anchor.instance().meteoraProgram.account.lbPair.fetch(lbPair);
|
|
224
|
+
const tokenXMint = lbPairInfo.tokenXMint;
|
|
225
|
+
const tokenYMint = lbPairInfo.tokenYMint;
|
|
226
|
+
const reserveX = lbPairInfo.reserveX;
|
|
227
|
+
const reserveY = lbPairInfo.reserveY;
|
|
228
|
+
const userTokenX = (0, functions_1.generateAta)(userPda, tokenXMint);
|
|
229
|
+
const userTokenY = (0, functions_1.generateAta)(userPda, tokenYMint);
|
|
230
|
+
const activeBinId = lbPairInfo.activeId;
|
|
231
|
+
// const MAX_BIN_ARRAY_SIZE = new BN(Anchor.instance().meteoraProgram.idl.constants[1].value);
|
|
232
|
+
// Get min and max bin id values from checkRange threshold
|
|
233
|
+
const { minBinId, maxBinId } = checkRange;
|
|
234
|
+
let _checkRange = [minBinId, maxBinId];
|
|
235
|
+
// Note: relative lower & upper bins can be positive or negative
|
|
236
|
+
const expectedMinBinId = activeBinId + relativeLowerBinId;
|
|
237
|
+
const expectedMaxBinId = activeBinId + relativeUpperBinId;
|
|
238
|
+
if (expectedMaxBinId < expectedMinBinId) {
|
|
239
|
+
throw new Error("Invalid bin range");
|
|
240
|
+
}
|
|
241
|
+
// get min and max bin +- 3
|
|
242
|
+
// this is to ensure that we allow for some buffer
|
|
243
|
+
// let lowerTickArrays = fn.findMeteoraTickArrays(lbPair, expectedMinBinId - 3, expectedMinBinId + 3);
|
|
244
|
+
// let upperTickArrays = fn.findMeteoraTickArrays(lbPair, expectedMaxBinId - 3, expectedMaxBinId + 3);
|
|
245
|
+
// Merge and remove duplicates
|
|
246
|
+
// it will handle overlapping tick arrays
|
|
247
|
+
// if lower is 1 2 3 4 5 6 7 and upper is 3 4 5 6 7 8 9
|
|
248
|
+
// we want to merge it to 1 2 3 4 5 6 7 8 9
|
|
249
|
+
// const tickArrays: web3.PublicKey[] = [...new Set([...lowerTickArrays, ...upperTickArrays])];
|
|
250
|
+
// comment out for reference
|
|
251
|
+
// const lowerBinArrayIndex = fn.binIdToBinArrayIndex(MAX_BIN_ARRAY_SIZE, new BN(activeBinId - relativeLowerBinId));
|
|
252
|
+
// const binArrayLower = fn.deriveBinArray(lbPair, lowerBinArrayIndex);
|
|
253
|
+
// const binArrayUpper = fn.deriveBinArray(lbPair, lowerBinArrayIndex.add(new BN(1)));
|
|
254
|
+
// comment out for reference
|
|
255
|
+
// let _checkRange: null | [number, number];
|
|
256
|
+
// if (!!checkRange) {
|
|
257
|
+
// const { minBinId, maxBinId } = checkRange;
|
|
258
|
+
// _checkRange = [minBinId, maxBinId];
|
|
259
|
+
// } else {
|
|
260
|
+
// _checkRange = null;
|
|
261
|
+
// }
|
|
262
|
+
let DLMM = yield this.dlmm(connection, lbPair);
|
|
263
|
+
const addLiquidityByStrategyTx = yield DLMM.dlmm.addLiquidityByStrategy({
|
|
264
|
+
positionPubKey: position,
|
|
265
|
+
totalXAmount: new bn_js_1.default(0),
|
|
266
|
+
totalYAmount: new bn_js_1.default(0),
|
|
267
|
+
strategy: {
|
|
268
|
+
maxBinId: expectedMinBinId,
|
|
269
|
+
minBinId: expectedMaxBinId,
|
|
270
|
+
strategyType: mapOldStrategyTypeToNew(strategyType),
|
|
271
|
+
},
|
|
272
|
+
user: userWallet,
|
|
273
|
+
});
|
|
274
|
+
// const addLiquidityByStrategyIxs = addLiquidityByStrategyTx.instructions.filter((ix) => ix.programId.equals(METEORA_DLMM_PROGRAM))
|
|
275
|
+
const addLiquidityByStrategyIx = addLiquidityByStrategyTx.instructions.filter((ix) => {
|
|
276
|
+
return ix.programId.equals(METEORA_DLMM_PROGRAM) &&
|
|
277
|
+
ix.data.subarray(0, 8).equals(Buffer.from([3, 221, 149, 218, 111, 141, 118, 213]));
|
|
278
|
+
})[0];
|
|
279
|
+
// index 14 onwards are remaining accounts
|
|
280
|
+
const remainingAccountMeta = addLiquidityByStrategyIx.keys.slice(14);
|
|
281
|
+
// index 97 onwards are remaining accounts info
|
|
282
|
+
const remainingAccountsInfo = addLiquidityByStrategyIx.data.subarray(97);
|
|
283
|
+
// Generate instruction
|
|
284
|
+
return this.ix.iyfMain.iyfExtensionExecute(connection, {
|
|
285
|
+
userWallet,
|
|
286
|
+
// @ts-ignore
|
|
287
|
+
iyfExtensionIx: yield anchor_1.Anchor.instance().iyfExtension
|
|
288
|
+
.methods
|
|
289
|
+
.meteoraDlmmRedepositAutomation2(relativeLowerBinId, relativeUpperBinId, mapOldStrategyTypeToNew(strategyType), _checkRange, remainingAccountsInfo)
|
|
290
|
+
.accounts({
|
|
291
|
+
farm: addresses_1.USDC_FARM,
|
|
292
|
+
userPda,
|
|
293
|
+
authority: userWallet,
|
|
294
|
+
iyfProgram: addresses_1.IYF_MAIN,
|
|
295
|
+
hawksightAuthority: addresses_1.HS_AUTHORITY,
|
|
296
|
+
position,
|
|
297
|
+
lbPair,
|
|
298
|
+
userTokenX,
|
|
299
|
+
userTokenY,
|
|
300
|
+
reserveX,
|
|
301
|
+
reserveY,
|
|
302
|
+
tokenXMint,
|
|
303
|
+
tokenYMint,
|
|
304
|
+
// binArrayLower,
|
|
305
|
+
// binArrayUpper,
|
|
306
|
+
systemProgram: web3.SystemProgram.programId,
|
|
307
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
308
|
+
rent: web3.SYSVAR_RENT_PUBKEY,
|
|
309
|
+
eventAuthority: METEORA_EVENT_AUTHORITY,
|
|
310
|
+
meteoraDlmmProgram: METEORA_DLMM_PROGRAM,
|
|
311
|
+
})
|
|
312
|
+
.remainingAccounts(remainingAccountMeta)
|
|
313
|
+
.instruction(),
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
}
|
|
186
317
|
claimFee(connection, params) {
|
|
187
318
|
return __awaiter(this, void 0, void 0, function* () {
|
|
188
319
|
// Initialize anchor
|
|
@@ -383,5 +514,16 @@ class MeteoraDlmmIxGenerator {
|
|
|
383
514
|
return yield meteora_1.MeteoraDLMM.program(connection);
|
|
384
515
|
});
|
|
385
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Meteora IDL
|
|
519
|
+
*
|
|
520
|
+
* @param connection
|
|
521
|
+
* @returns
|
|
522
|
+
*/
|
|
523
|
+
dlmm(connection, poolAddress) {
|
|
524
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
525
|
+
return yield meteora_1.MeteoraDLMM.create(connection, poolAddress, this.ix);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
386
528
|
}
|
|
387
529
|
exports.MeteoraDlmmIxGenerator = MeteoraDlmmIxGenerator;
|