@hawksightco/hawk-sdk 1.1.61 → 1.1.63

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.
@@ -177,6 +177,24 @@ export declare class Transactions {
177
177
  * @returns A ResponseWithStatus containing either TransactionMetadataResponse.
178
178
  */
179
179
  orcaDeposit({ connection, params }: TxgenParams<OrcaDeposit>): Promise<TransactionMetadataResponse>;
180
+ /**
181
+ * Creates orca instruction that deposits to a position
182
+ *
183
+ * @param connection The Solana web3 connection object for blockchain interactions.
184
+ * @param payer The public key of the payer for transaction fees.
185
+ * @param params Parameters required
186
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse.
187
+ */
188
+ orcaDepositPda({ connection, params }: TxgenParams<OrcaDeposit>): Promise<TransactionMetadataResponse>;
189
+ /**
190
+ * Creates orca instruction that sweeps dust into a position
191
+ *
192
+ * @param connection The Solana web3 connection object for blockchain interactions.
193
+ * @param payer The public key of the payer for transaction fees.
194
+ * @param params Parameters required
195
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse.
196
+ */
197
+ orcaSweepDust({ connection, params }: TxgenParams<OrcaDeposit>): Promise<TransactionMetadataResponse>;
180
198
  /**
181
199
  * Creates orca instruction that withdraws from a position
182
200
  *
@@ -186,6 +204,15 @@ export declare class Transactions {
186
204
  * @returns A ResponseWithStatus containing either TransactionMetadataResponse.
187
205
  */
188
206
  orcaWithdraw({ connection, params }: TxgenParams<OrcaWithdraw>): Promise<TransactionMetadataResponse>;
207
+ /**
208
+ * Creates orca instruction that withdraws from a position
209
+ *
210
+ * @param connection The Solana web3 connection object for blockchain interactions.
211
+ * @param payer The public key of the payer for transaction fees.
212
+ * @param params Parameters required
213
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse.
214
+ */
215
+ orcaWithdrawPda({ connection, params }: TxgenParams<OrcaWithdraw>): Promise<TransactionMetadataResponse>;
189
216
  /**
190
217
  * Creates orca instruction that claims fees and rewards
191
218
  *
@@ -1 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W,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA6IzG;;;;;;;OAOG;IACG,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA6I5G;;;;;;;OAOG;IACG,aAAa,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA6J3G;;;;;;;OAOG;IACG,YAAY,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA4F3G;;;;;;;OAOG;IACG,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA4F9G;;;;;;;OAOG;IACG,gBAAgB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;CA0GpH;AAED,eAAO,MAAM,KAAK,cAA6B,CAAC"}
@@ -53,6 +53,8 @@ const TransactionBatchExecute2_1 = require("./TransactionBatchExecute2");
53
53
  const CreateTxMetadata_1 = require("./CreateTxMetadata");
54
54
  const SimpleIxGenerator_1 = require("./SimpleIxGenerator");
55
55
  const spl_token_1 = require("@solana/spl-token");
56
+ const whirlpools_sdk_1 = require("@orca-so/whirlpools-sdk");
57
+ const anchor = __importStar(require("@coral-xyz/anchor"));
56
58
  class Transactions {
57
59
  /**
58
60
  * Prohibit creating instance other than getInstance
@@ -1233,6 +1235,315 @@ class Transactions {
1233
1235
  });
1234
1236
  });
1235
1237
  }
1238
+ /**
1239
+ * Creates orca instruction that deposits to a position
1240
+ *
1241
+ * @param connection The Solana web3 connection object for blockchain interactions.
1242
+ * @param payer The public key of the payer for transaction fees.
1243
+ * @param params Parameters required
1244
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse.
1245
+ */
1246
+ orcaDepositPda(_a) {
1247
+ return __awaiter(this, arguments, void 0, function* ({ connection, params }) {
1248
+ const farm = addresses_1.USDC_FARM;
1249
+ const userPda = (0, functions_1.generateUserPda)(params.userWallet, farm);
1250
+ let position;
1251
+ let positionMint;
1252
+ let positionData;
1253
+ if (params.mintOrPosition.position !== undefined) {
1254
+ position = params.mintOrPosition.position;
1255
+ positionData = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(position);
1256
+ positionMint = positionData.positionMint;
1257
+ }
1258
+ else if (params.mintOrPosition.positionMint !== undefined) {
1259
+ positionMint = params.mintOrPosition.positionMint;
1260
+ position = (0, functions_1.generateOrcaPositionPDA)(positionMint);
1261
+ }
1262
+ else {
1263
+ throw new Error('Position mint or orca position needs to be provided.');
1264
+ }
1265
+ const positionTokenAccount = (0, functions_1.generateAta)(userPda, positionMint);
1266
+ if (params.newPosition) {
1267
+ positionData = {
1268
+ positionMint,
1269
+ whirlpool: params.newPosition.whirlpool,
1270
+ tickLowerIndex: params.newPosition.tickLowerIndex,
1271
+ tickUpperIndex: params.newPosition.tickUpperIndex,
1272
+ };
1273
+ }
1274
+ else {
1275
+ positionData = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(position);
1276
+ }
1277
+ if (positionData === null) {
1278
+ throw new Error(`Position: ${position} does not exist or already closed. Position mint: ${positionMint}`);
1279
+ }
1280
+ const whirlpool = positionData.whirlpool;
1281
+ const whirlpoolData = yield anchor_1.Anchor.instance().orcaProgram.account.whirlpool.fetch(whirlpool);
1282
+ const mintA = whirlpoolData.tokenMintA;
1283
+ const mintB = whirlpoolData.tokenMintB;
1284
+ const tokenSeeds = [
1285
+ { owner: params.userWallet, mint: mintA },
1286
+ { owner: params.userWallet, mint: mintB },
1287
+ ];
1288
+ const resultMap = yield (0, functions_1.tokenAccountExists)(connection, tokenSeeds);
1289
+ resultMap.map((result, index) => {
1290
+ const tokenKey = result.tokenKey;
1291
+ const token = tokenSeeds[index];
1292
+ if (!result.exists && `${token.mint}` !== 'So11111111111111111111111111111111111111112') {
1293
+ throw new Error(`Token: ${tokenKey} owned by ${token.owner} does not exist. Mint: ${token.mint}`);
1294
+ }
1295
+ });
1296
+ const tokenOwnerAccountA = (0, functions_1.generateAta)(userPda, mintA);
1297
+ const tokenOwnerAccountB = (0, functions_1.generateAta)(userPda, mintB);
1298
+ const { publicKey: tickArrayLower } = (0, orca_1.getTickArrayFromTickIndex)(positionData.tickLowerIndex, whirlpoolData.tickSpacing, whirlpool, addresses_1.ORCA_WHIRLPOOL_PROGRAM);
1299
+ const { publicKey: tickArrayUpper } = (0, orca_1.getTickArrayFromTickIndex)(positionData.tickUpperIndex, whirlpoolData.tickSpacing, whirlpool, addresses_1.ORCA_WHIRLPOOL_PROGRAM);
1300
+ const ownerFeeA = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, mintA);
1301
+ const ownerFeeB = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, mintB);
1302
+ // Step 1: Init wSOL token account for user wallet (if X or Y token is wSOL)
1303
+ // const wrapSolIx = wrapSolIfMintIsWsol(params.userWallet, params.userWallet, [
1304
+ // { mint: mintA, amount: params.totalXAmount },
1305
+ // { mint: mintB, amount: params.totalYAmount },
1306
+ // ]);
1307
+ // const depositIx = await depositMultipleToken({
1308
+ // payer: params.userWallet,
1309
+ // deposit: [
1310
+ // {
1311
+ // mint: mintA,
1312
+ // amount: params.totalXAmount,
1313
+ // },
1314
+ // {
1315
+ // mint: mintB,
1316
+ // amount: params.totalYAmount,
1317
+ // },
1318
+ // ]
1319
+ // });
1320
+ // @ts-ignore
1321
+ const extensionIx = yield anchor_1.Anchor.instance().iyfExtension.methods
1322
+ .orcaDeposit()
1323
+ .accounts({
1324
+ farm,
1325
+ userPda,
1326
+ authority: params.userWallet,
1327
+ iyfProgram: addresses_1.IYF_MAIN,
1328
+ positionMint,
1329
+ whirlpool,
1330
+ position,
1331
+ positionTokenAccount,
1332
+ tokenOwnerAccountA,
1333
+ tokenOwnerAccountB,
1334
+ tokenVaultA: whirlpoolData.tokenVaultA,
1335
+ tokenVaultB: whirlpoolData.tokenVaultB,
1336
+ tickArrayLower,
1337
+ tickArrayUpper,
1338
+ ownerFeeA,
1339
+ ownerFeeB,
1340
+ orcaWhirlpoolProgram: addresses_1.ORCA_WHIRLPOOL_PROGRAM,
1341
+ tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
1342
+ associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
1343
+ })
1344
+ .instruction();
1345
+ const orcaIx = yield anchor_1.Anchor.instance().iyfMain.methods
1346
+ .iyfExtensionExecute(extensionIx.data)
1347
+ .accounts({
1348
+ farm,
1349
+ userPda,
1350
+ authority: params.userWallet,
1351
+ iyfProgram: addresses_1.IYF_MAIN,
1352
+ iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1353
+ })
1354
+ .remainingAccounts([
1355
+ extensionIx.keys[4],
1356
+ extensionIx.keys[5],
1357
+ extensionIx.keys[6],
1358
+ extensionIx.keys[7],
1359
+ extensionIx.keys[8],
1360
+ extensionIx.keys[9],
1361
+ extensionIx.keys[10],
1362
+ extensionIx.keys[11],
1363
+ extensionIx.keys[12],
1364
+ extensionIx.keys[13],
1365
+ extensionIx.keys[14],
1366
+ extensionIx.keys[15],
1367
+ extensionIx.keys[16],
1368
+ extensionIx.keys[17],
1369
+ extensionIx.keys[18],
1370
+ ])
1371
+ .instruction();
1372
+ // const clearRemainingTokensIxs = await withdrawMultipleToken({
1373
+ // payer: params.userWallet,
1374
+ // withdraw: [
1375
+ // { mint: mintA },
1376
+ // { mint: mintB },
1377
+ // ],
1378
+ // });
1379
+ orcaIx.keys[2].isSigner = true; // authority must be signer.
1380
+ const mainInstructions = [orcaIx];
1381
+ return (0, functions_1.createTransactionMeta)({
1382
+ payer: params.userWallet,
1383
+ description: `Deposit to Orca Position via PDA: ${position}`,
1384
+ addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
1385
+ mainInstructions,
1386
+ });
1387
+ });
1388
+ }
1389
+ /**
1390
+ * Creates orca instruction that sweeps dust into a position
1391
+ *
1392
+ * @param connection The Solana web3 connection object for blockchain interactions.
1393
+ * @param payer The public key of the payer for transaction fees.
1394
+ * @param params Parameters required
1395
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse.
1396
+ */
1397
+ orcaSweepDust(_a) {
1398
+ return __awaiter(this, arguments, void 0, function* ({ connection, params }) {
1399
+ const farm = addresses_1.USDC_FARM;
1400
+ const userPda = (0, functions_1.generateUserPda)(params.userWallet, farm);
1401
+ let position;
1402
+ let positionMint;
1403
+ let positionData;
1404
+ if (params.mintOrPosition.position !== undefined) {
1405
+ position = params.mintOrPosition.position;
1406
+ positionData = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(position);
1407
+ positionMint = positionData.positionMint;
1408
+ }
1409
+ else if (params.mintOrPosition.positionMint !== undefined) {
1410
+ positionMint = params.mintOrPosition.positionMint;
1411
+ position = (0, functions_1.generateOrcaPositionPDA)(positionMint);
1412
+ }
1413
+ else {
1414
+ throw new Error('Position mint or orca position needs to be provided.');
1415
+ }
1416
+ const positionTokenAccount = (0, functions_1.generateAta)(userPda, positionMint);
1417
+ if (params.newPosition) {
1418
+ positionData = {
1419
+ positionMint,
1420
+ whirlpool: params.newPosition.whirlpool,
1421
+ tickLowerIndex: params.newPosition.tickLowerIndex,
1422
+ tickUpperIndex: params.newPosition.tickUpperIndex,
1423
+ };
1424
+ }
1425
+ else {
1426
+ positionData = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(position);
1427
+ }
1428
+ if (positionData === null) {
1429
+ throw new Error(`Position: ${position} does not exist or already closed. Position mint: ${positionMint}`);
1430
+ }
1431
+ const whirlpool = positionData.whirlpool;
1432
+ const whirlpoolData = yield anchor_1.Anchor.instance().orcaProgram.account.whirlpool.fetch(whirlpool);
1433
+ const mintA = whirlpoolData.tokenMintA;
1434
+ const mintB = whirlpoolData.tokenMintB;
1435
+ const tokenSeeds = [
1436
+ { owner: params.userWallet, mint: mintA },
1437
+ { owner: params.userWallet, mint: mintB },
1438
+ ];
1439
+ const resultMap = yield (0, functions_1.tokenAccountExists)(connection, tokenSeeds);
1440
+ resultMap.map((result, index) => {
1441
+ const tokenKey = result.tokenKey;
1442
+ const token = tokenSeeds[index];
1443
+ if (!result.exists && `${token.mint}` !== 'So11111111111111111111111111111111111111112') {
1444
+ throw new Error(`Token: ${tokenKey} owned by ${token.owner} does not exist. Mint: ${token.mint}`);
1445
+ }
1446
+ });
1447
+ const tokenOwnerAccountA = (0, functions_1.generateAta)(userPda, mintA);
1448
+ const tokenOwnerAccountB = (0, functions_1.generateAta)(userPda, mintB);
1449
+ const { publicKey: tickArrayLower } = (0, orca_1.getTickArrayFromTickIndex)(positionData.tickLowerIndex, whirlpoolData.tickSpacing, whirlpool, addresses_1.ORCA_WHIRLPOOL_PROGRAM);
1450
+ const { publicKey: tickArrayUpper } = (0, orca_1.getTickArrayFromTickIndex)(positionData.tickUpperIndex, whirlpoolData.tickSpacing, whirlpool, addresses_1.ORCA_WHIRLPOOL_PROGRAM);
1451
+ const ownerFeeA = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, mintA);
1452
+ const ownerFeeB = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, mintB);
1453
+ const [oracle] = web3.PublicKey.findProgramAddressSync([anchor.utils.bytes.utf8.encode("oracle"), whirlpool.toBuffer()], addresses_1.ORCA_WHIRLPOOL_PROGRAM);
1454
+ // TODO: Derive based on amountToSwap calculation
1455
+ let aToB = true;
1456
+ const tickArrays = whirlpools_sdk_1.SwapUtils.getTickArrayPublicKeys(whirlpoolData.tickCurrentIndex, whirlpoolData.tickSpacing, aToB, addresses_1.ORCA_WHIRLPOOL_PROGRAM, whirlpool);
1457
+ // Step 1: Init wSOL token account for user wallet (if X or Y token is wSOL)
1458
+ // const wrapSolIx = wrapSolIfMintIsWsol(params.userWallet, params.userWallet, [
1459
+ // { mint: mintA, amount: params.totalXAmount },
1460
+ // { mint: mintB, amount: params.totalYAmount },
1461
+ // ]);
1462
+ // const depositIx = await depositMultipleToken({
1463
+ // payer: params.userWallet,
1464
+ // deposit: [
1465
+ // {
1466
+ // mint: mintA,
1467
+ // amount: params.totalXAmount,
1468
+ // },
1469
+ // {
1470
+ // mint: mintB,
1471
+ // amount: params.totalYAmount,
1472
+ // },
1473
+ // ]
1474
+ // });
1475
+ // @ts-ignore
1476
+ const extensionIx = yield anchor_1.Anchor.instance().iyfExtension.methods
1477
+ .orcaSweepDust()
1478
+ .accounts({
1479
+ farm,
1480
+ userPda,
1481
+ authority: params.userWallet,
1482
+ iyfProgram: addresses_1.IYF_MAIN,
1483
+ rebalanceAuthority: params.userWallet,
1484
+ whirlpool,
1485
+ positionMintDst: positionMint,
1486
+ positionDst: position,
1487
+ tickArrayLowerDst: tickArrayLower,
1488
+ tickArrayUpperDst: tickArrayUpper,
1489
+ positionTokenAccountDst: positionTokenAccount,
1490
+ tokenVaultA: whirlpoolData.tokenVaultA,
1491
+ tokenVaultB: whirlpoolData.tokenVaultB,
1492
+ tokenOwnerAccountA,
1493
+ tokenOwnerAccountB,
1494
+ tickArray0: tickArrays[0],
1495
+ tickArray1: tickArrays[1],
1496
+ tickArray2: tickArrays[2],
1497
+ oracle,
1498
+ orcaWhirlpoolProgram: addresses_1.ORCA_WHIRLPOOL_PROGRAM,
1499
+ tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
1500
+ associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
1501
+ })
1502
+ .instruction();
1503
+ const orcaIx = yield anchor_1.Anchor.instance().iyfMain.methods
1504
+ .iyfExtensionExecute(extensionIx.data)
1505
+ .accounts({
1506
+ farm,
1507
+ userPda,
1508
+ authority: params.userWallet,
1509
+ iyfProgram: addresses_1.IYF_MAIN,
1510
+ iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1511
+ })
1512
+ .remainingAccounts([
1513
+ extensionIx.keys[4],
1514
+ extensionIx.keys[5],
1515
+ extensionIx.keys[6],
1516
+ extensionIx.keys[7],
1517
+ extensionIx.keys[8],
1518
+ extensionIx.keys[9],
1519
+ extensionIx.keys[10],
1520
+ extensionIx.keys[11],
1521
+ extensionIx.keys[12],
1522
+ extensionIx.keys[13],
1523
+ extensionIx.keys[14],
1524
+ extensionIx.keys[15],
1525
+ extensionIx.keys[16],
1526
+ extensionIx.keys[17],
1527
+ extensionIx.keys[18],
1528
+ ])
1529
+ .instruction();
1530
+ // const clearRemainingTokensIxs = await withdrawMultipleToken({
1531
+ // payer: params.userWallet,
1532
+ // withdraw: [
1533
+ // { mint: mintA },
1534
+ // { mint: mintB },
1535
+ // ],
1536
+ // });
1537
+ orcaIx.keys[2].isSigner = true; // authority must be signer.
1538
+ const mainInstructions = [orcaIx];
1539
+ return (0, functions_1.createTransactionMeta)({
1540
+ payer: params.userWallet,
1541
+ description: `Sweep Dust to Orca Position via PDA: ${position}`,
1542
+ addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
1543
+ mainInstructions,
1544
+ });
1545
+ });
1546
+ }
1236
1547
  /**
1237
1548
  * Creates orca instruction that withdraws from a position
1238
1549
  *
@@ -1332,6 +1643,105 @@ class Transactions {
1332
1643
  });
1333
1644
  });
1334
1645
  }
1646
+ /**
1647
+ * Creates orca instruction that withdraws from a position
1648
+ *
1649
+ * @param connection The Solana web3 connection object for blockchain interactions.
1650
+ * @param payer The public key of the payer for transaction fees.
1651
+ * @param params Parameters required
1652
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse.
1653
+ */
1654
+ orcaWithdrawPda(_a) {
1655
+ return __awaiter(this, arguments, void 0, function* ({ connection, params }) {
1656
+ const farm = addresses_1.USDC_FARM;
1657
+ const userPda = (0, functions_1.generateUserPda)(params.userWallet, farm);
1658
+ const positionData = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(params.position);
1659
+ if (positionData === null) {
1660
+ throw new Error(`Position: ${params.position} does not exist or already closed.`);
1661
+ }
1662
+ const liquidityAmount = positionData.liquidity
1663
+ .mul(new bn_js_1.default(Math.round(params.percentage * 100)))
1664
+ .div(new bn_js_1.default(10000));
1665
+ const positionTokenAccount = (0, functions_1.generateAta)(userPda, positionData.positionMint);
1666
+ const whirlpool = positionData.whirlpool;
1667
+ const whirlpoolData = yield anchor_1.Anchor.instance().orcaProgram.account.whirlpool.fetch(whirlpool);
1668
+ const mintA = whirlpoolData.tokenMintA;
1669
+ const mintB = whirlpoolData.tokenMintB;
1670
+ const tokenOwnerAccountA = (0, functions_1.generateAta)(userPda, mintA);
1671
+ const tokenOwnerAccountB = (0, functions_1.generateAta)(userPda, mintB);
1672
+ const { publicKey: tickArrayLower } = (0, orca_1.getTickArrayFromTickIndex)(positionData.tickLowerIndex, whirlpoolData.tickSpacing, whirlpool, addresses_1.ORCA_WHIRLPOOL_PROGRAM);
1673
+ const { publicKey: tickArrayUpper } = (0, orca_1.getTickArrayFromTickIndex)(positionData.tickUpperIndex, whirlpoolData.tickSpacing, whirlpool, addresses_1.ORCA_WHIRLPOOL_PROGRAM);
1674
+ const ownerFeeA = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, mintA);
1675
+ const ownerFeeB = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, mintB);
1676
+ // @ts-ignore
1677
+ const extensionIx = yield anchor_1.Anchor.instance().iyfExtension.methods
1678
+ .orcaWithdraw(liquidityAmount)
1679
+ .accounts({
1680
+ farm,
1681
+ userPda,
1682
+ authority: params.userWallet,
1683
+ iyfProgram: addresses_1.IYF_MAIN,
1684
+ positionMint: positionData.positionMint,
1685
+ whirlpool,
1686
+ position: params.position,
1687
+ positionTokenAccount,
1688
+ tokenOwnerAccountA,
1689
+ tokenOwnerAccountB,
1690
+ tokenVaultA: whirlpoolData.tokenVaultA,
1691
+ tokenVaultB: whirlpoolData.tokenVaultB,
1692
+ tickArrayLower,
1693
+ tickArrayUpper,
1694
+ ownerFeeA,
1695
+ ownerFeeB,
1696
+ orcaWhirlpoolProgram: addresses_1.ORCA_WHIRLPOOL_PROGRAM,
1697
+ tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
1698
+ associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
1699
+ })
1700
+ .instruction();
1701
+ const orcaIx = yield anchor_1.Anchor.instance().iyfMain.methods
1702
+ .iyfExtensionExecute(extensionIx.data)
1703
+ .accounts({
1704
+ farm,
1705
+ userPda,
1706
+ authority: params.userWallet,
1707
+ iyfProgram: addresses_1.IYF_MAIN,
1708
+ iyfExtensionProgram: addresses_1.IYF_EXTENSION,
1709
+ })
1710
+ .remainingAccounts([
1711
+ extensionIx.keys[4],
1712
+ extensionIx.keys[5],
1713
+ extensionIx.keys[6],
1714
+ extensionIx.keys[7],
1715
+ extensionIx.keys[8],
1716
+ extensionIx.keys[9],
1717
+ extensionIx.keys[10],
1718
+ extensionIx.keys[11],
1719
+ extensionIx.keys[12],
1720
+ extensionIx.keys[13],
1721
+ extensionIx.keys[14],
1722
+ extensionIx.keys[15],
1723
+ extensionIx.keys[16],
1724
+ extensionIx.keys[17],
1725
+ extensionIx.keys[18],
1726
+ ])
1727
+ .instruction();
1728
+ // const withdrawFromPda = await withdrawMultipleToken({
1729
+ // payer: params.userWallet,
1730
+ // withdraw: [
1731
+ // { mint: mintA },
1732
+ // { mint: mintB },
1733
+ // ],
1734
+ // });
1735
+ orcaIx.keys[2].isSigner = true; // authority must be signer.
1736
+ const mainInstructions = [orcaIx];
1737
+ return (0, functions_1.createTransactionMeta)({
1738
+ payer: params.userWallet,
1739
+ description: `Withdraw deposits from Orca Position to Pda: ${params.position}`,
1740
+ addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
1741
+ mainInstructions,
1742
+ });
1743
+ });
1744
+ }
1335
1745
  /**
1336
1746
  * Creates orca instruction that claims fees and rewards
1337
1747
  *
@@ -165,6 +165,15 @@ export declare class TxGenerator {
165
165
  * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
166
166
  */
167
167
  orcaDeposit(connection: web3.Connection, payer: string, params: OrcaDeposit): Promise<ResponseWithStatus<TransactionMetadata>>;
168
+ /**
169
+ * Creates orca instruction that deposits to a position
170
+ *
171
+ * @param connection The Solana web3 connection object for blockchain interactions.
172
+ * @param payer The public key of the payer for transaction fees.
173
+ * @param params Parameters required
174
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
175
+ */
176
+ orcaDepositPda(connection: web3.Connection, payer: string, params: OrcaDeposit): Promise<ResponseWithStatus<TransactionMetadata>>;
168
177
  /**
169
178
  * Creates orca instruction that withdraws from a position
170
179
  *
@@ -174,6 +183,24 @@ export declare class TxGenerator {
174
183
  * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
175
184
  */
176
185
  orcaWithdraw(connection: web3.Connection, payer: string, params: OrcaWithdraw): Promise<ResponseWithStatus<TransactionMetadata>>;
186
+ /**
187
+ * Creates orca instruction that withdraws from a position
188
+ *
189
+ * @param connection The Solana web3 connection object for blockchain interactions.
190
+ * @param payer The public key of the payer for transaction fees.
191
+ * @param params Parameters required
192
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
193
+ */
194
+ orcaWithdrawPda(connection: web3.Connection, payer: string, params: OrcaWithdraw): Promise<ResponseWithStatus<TransactionMetadata>>;
195
+ /**
196
+ * Creates orca instruction that withdraws from a position
197
+ *
198
+ * @param connection The Solana web3 connection object for blockchain interactions.
199
+ * @param payer The public key of the payer for transaction fees.
200
+ * @param params Parameters required
201
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
202
+ */
203
+ orcaSweepDust(connection: web3.Connection, payer: string, params: OrcaDeposit): Promise<ResponseWithStatus<TransactionMetadata>>;
177
204
  /**
178
205
  * Creates orca instruction that claims fees and rewards
179
206
  *
@@ -1 +1 @@
1
- {"version":3,"file":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,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAmCpI;;;;;;;OAOG;IACG,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAmCvI;;;;;;;OAOG;IACG,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAiCtI;;;;;;;OAOG;IACG,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAiCzI;;;;;;;OAOG;IACG,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IA6BtI;;;;;;;OAOG;IACG,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CA+B/I"}
@@ -641,6 +641,46 @@ class TxGenerator {
641
641
  }
642
642
  });
643
643
  }
644
+ /**
645
+ * Creates orca instruction that deposits to a position
646
+ *
647
+ * @param connection The Solana web3 connection object for blockchain interactions.
648
+ * @param payer The public key of the payer for transaction fees.
649
+ * @param params Parameters required
650
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
651
+ */
652
+ orcaDepositPda(connection, payer, params) {
653
+ return __awaiter(this, void 0, void 0, function* () {
654
+ // Initialize anchor
655
+ anchor_1.Anchor.initialize(connection);
656
+ try {
657
+ const result = yield Transactions_1.txgen.orcaDepositPda({
658
+ connection,
659
+ params: {
660
+ userWallet: params.userWallet,
661
+ mintOrPosition: params.mintOrPosition,
662
+ totalXAmount: params.totalXAmount,
663
+ totalYAmount: params.totalYAmount,
664
+ newPosition: params.newPosition,
665
+ }
666
+ });
667
+ return {
668
+ status: 200,
669
+ data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
670
+ };
671
+ }
672
+ catch (e) {
673
+ return {
674
+ status: 400,
675
+ data: {
676
+ code: "custom",
677
+ message: e,
678
+ path: [],
679
+ },
680
+ };
681
+ }
682
+ });
683
+ }
644
684
  /**
645
685
  * Creates orca instruction that withdraws from a position
646
686
  *
@@ -679,6 +719,78 @@ class TxGenerator {
679
719
  }
680
720
  });
681
721
  }
722
+ /**
723
+ * Creates orca instruction that withdraws from a position
724
+ *
725
+ * @param connection The Solana web3 connection object for blockchain interactions.
726
+ * @param payer The public key of the payer for transaction fees.
727
+ * @param params Parameters required
728
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
729
+ */
730
+ orcaWithdrawPda(connection, payer, params) {
731
+ return __awaiter(this, void 0, void 0, function* () {
732
+ // Initialize anchor
733
+ anchor_1.Anchor.initialize(connection);
734
+ try {
735
+ const result = yield Transactions_1.txgen.orcaWithdrawPda({
736
+ connection,
737
+ params: {
738
+ userWallet: params.userWallet,
739
+ position: params.position,
740
+ percentage: params.percentage,
741
+ }
742
+ });
743
+ return {
744
+ status: 200,
745
+ data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
746
+ };
747
+ }
748
+ catch (e) {
749
+ return {
750
+ status: 400,
751
+ data: {
752
+ code: "custom",
753
+ message: e,
754
+ path: [],
755
+ },
756
+ };
757
+ }
758
+ });
759
+ }
760
+ /**
761
+ * Creates orca instruction that withdraws from a position
762
+ *
763
+ * @param connection The Solana web3 connection object for blockchain interactions.
764
+ * @param payer The public key of the payer for transaction fees.
765
+ * @param params Parameters required
766
+ * @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
767
+ */
768
+ orcaSweepDust(connection, payer, params) {
769
+ return __awaiter(this, void 0, void 0, function* () {
770
+ // Initialize anchor
771
+ anchor_1.Anchor.initialize(connection);
772
+ try {
773
+ const result = yield Transactions_1.txgen.orcaSweepDust({
774
+ connection,
775
+ params: params,
776
+ });
777
+ return {
778
+ status: 200,
779
+ data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
780
+ };
781
+ }
782
+ catch (e) {
783
+ return {
784
+ status: 400,
785
+ data: {
786
+ code: "custom",
787
+ message: e,
788
+ path: [],
789
+ },
790
+ };
791
+ }
792
+ });
793
+ }
682
794
  /**
683
795
  * Creates orca instruction that claims fees and rewards
684
796
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hawksightco/hawk-sdk",
3
- "version": "1.1.61",
3
+ "version": "1.1.63",
4
4
  "description": "Hawksight v2 SDK",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": "https://github.com/ghabxph/hawk-api-client.git",
@@ -26,6 +26,7 @@
26
26
  "@coral-xyz/anchor": "~0.29.0",
27
27
  "@hawksightco/swagger-client": "^0.0.34",
28
28
  "@meteora-ag/dlmm": "^1.0.51",
29
+ "@orca-so/whirlpools-sdk": "^0.13.17",
29
30
  "@solana/spl-token": "^0.4.6",
30
31
  "@solana/web3.js": "^1.89.1",
31
32
  "bn.js": "^5.2.1",