@hawksightco/hawk-sdk 1.3.265 → 1.3.267
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/dist/addresses.d.ts +37 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +84 -0
- package/dist/anchor.d.ts +22 -0
- package/dist/anchor.d.ts.map +1 -0
- package/dist/anchor.js +121 -0
- package/dist/classes/AltStorage.d.ts +29 -0
- package/dist/classes/AltStorage.d.ts.map +1 -0
- package/dist/classes/AltStorage.js +58 -0
- package/dist/classes/Atomicity.d.ts +34 -0
- package/dist/classes/Atomicity.d.ts.map +1 -0
- package/dist/classes/Atomicity.js +110 -0
- package/dist/classes/Client.d.ts +35 -0
- package/dist/classes/Client.d.ts.map +1 -0
- package/dist/classes/Client.js +66 -0
- package/dist/classes/CombineTransactions.d.ts +11 -0
- package/dist/classes/CombineTransactions.d.ts.map +1 -0
- package/dist/classes/CombineTransactions.js +58 -0
- package/dist/classes/CreateTxMetadata.d.ts +100 -0
- package/dist/classes/CreateTxMetadata.d.ts.map +1 -0
- package/dist/classes/CreateTxMetadata.js +415 -0
- package/dist/classes/General.d.ts +87 -0
- package/dist/classes/General.d.ts.map +1 -0
- package/dist/classes/General.js +176 -0
- package/dist/classes/GeneralUtility.d.ts +79 -0
- package/dist/classes/GeneralUtility.d.ts.map +1 -0
- package/dist/classes/GeneralUtility.js +121 -0
- package/dist/classes/HawkAPI.d.ts +122 -0
- package/dist/classes/HawkAPI.d.ts.map +1 -0
- package/dist/classes/HawkAPI.js +169 -0
- package/dist/classes/Health.d.ts +29 -0
- package/dist/classes/Health.d.ts.map +1 -0
- package/dist/classes/Health.js +48 -0
- package/dist/classes/JupiterAlts.d.ts +37 -0
- package/dist/classes/JupiterAlts.d.ts.map +1 -0
- package/dist/classes/JupiterAlts.js +114 -0
- package/dist/classes/JupiterSwap.d.ts +21 -0
- package/dist/classes/JupiterSwap.d.ts.map +1 -0
- package/dist/classes/JupiterSwap.js +40 -0
- package/dist/classes/Logging.d.ts +13 -0
- package/dist/classes/Logging.d.ts.map +1 -0
- package/dist/classes/Logging.js +50 -0
- package/dist/classes/MultiTransaction.d.ts +75 -0
- package/dist/classes/MultiTransaction.d.ts.map +1 -0
- package/dist/classes/MultiTransaction.js +296 -0
- package/dist/classes/RaydiumSDK.d.ts +67 -0
- package/dist/classes/RaydiumSDK.d.ts.map +1 -0
- package/dist/classes/RaydiumSDK.js +206 -0
- package/dist/classes/Search.d.ts +100 -0
- package/dist/classes/Search.d.ts.map +1 -0
- package/dist/classes/Search.js +216 -0
- package/dist/classes/SimpleIxGenerator.d.ts +57 -0
- package/dist/classes/SimpleIxGenerator.d.ts.map +1 -0
- package/dist/classes/SimpleIxGenerator.js +62 -0
- package/dist/classes/SimplePdaGenerator.d.ts +28 -0
- package/dist/classes/SimplePdaGenerator.d.ts.map +1 -0
- package/dist/classes/SimplePdaGenerator.js +33 -0
- package/dist/classes/Transaction.d.ts +229 -0
- package/dist/classes/Transaction.d.ts.map +1 -0
- package/dist/classes/Transaction.js +643 -0
- package/dist/classes/Transaction2.d.ts +107 -0
- package/dist/classes/Transaction2.d.ts.map +1 -0
- package/dist/classes/Transaction2.js +249 -0
- package/dist/classes/Transaction3.d.ts +165 -0
- package/dist/classes/Transaction3.d.ts.map +1 -0
- package/dist/classes/Transaction3.js +416 -0
- package/dist/classes/TransactionBatchExecute.d.ts +163 -0
- package/dist/classes/TransactionBatchExecute.d.ts.map +1 -0
- package/dist/classes/TransactionBatchExecute.js +466 -0
- package/dist/classes/TransactionBatchExecute2.d.ts +99 -0
- package/dist/classes/TransactionBatchExecute2.d.ts.map +1 -0
- package/dist/classes/TransactionBatchExecute2.js +357 -0
- package/dist/classes/Transactions.d.ts +586 -0
- package/dist/classes/Transactions.d.ts.map +1 -0
- package/dist/classes/Transactions.js +7667 -0
- package/dist/classes/TxGenerator.d.ts +350 -0
- package/dist/classes/TxGenerator.d.ts.map +1 -0
- package/dist/classes/TxGenerator.js +1957 -0
- package/dist/classes/TxGeneratorAutomations.d.ts +186 -0
- package/dist/classes/TxGeneratorAutomations.d.ts.map +1 -0
- package/dist/classes/TxGeneratorAutomations.js +897 -0
- package/dist/classes/Util.d.ts +87 -0
- package/dist/classes/Util.d.ts.map +1 -0
- package/dist/classes/Util.js +148 -0
- package/dist/classes/account-cache/AccountCache.d.ts +54 -0
- package/dist/classes/account-cache/AccountCache.d.ts.map +1 -0
- package/dist/classes/account-cache/AccountCache.js +143 -0
- package/dist/classes/account-cache/MintCache.d.ts +33 -0
- package/dist/classes/account-cache/MintCache.d.ts.map +1 -0
- package/dist/classes/account-cache/MintCache.js +47 -0
- package/dist/classes/account-cache/TokenCache.d.ts +33 -0
- package/dist/classes/account-cache/TokenCache.d.ts.map +1 -0
- package/dist/classes/account-cache/TokenCache.js +47 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +96 -0
- package/dist/functions.d.ts +514 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +1636 -0
- package/dist/hawksight.d.ts +53 -0
- package/dist/hawksight.d.ts.map +1 -0
- package/dist/hawksight.js +328 -0
- package/dist/hsToMeteora.d.ts +31 -0
- package/dist/hsToMeteora.d.ts.map +1 -0
- package/dist/hsToMeteora.js +3175 -0
- package/dist/idl/iyf-extension-idl.d.ts +14583 -0
- package/dist/idl/iyf-extension-idl.d.ts.map +1 -0
- package/dist/idl/iyf-extension-idl.js +14578 -0
- package/dist/idl/iyf-extension-wrapper.d.ts +112 -0
- package/dist/idl/iyf-extension-wrapper.d.ts.map +1 -0
- package/dist/idl/iyf-extension-wrapper.js +2 -0
- package/dist/idl/iyf-main-idl.d.ts +12078 -0
- package/dist/idl/iyf-main-idl.d.ts.map +1 -0
- package/dist/idl/iyf-main-idl.js +12073 -0
- package/dist/idl/iyf-main-wrapper.d.ts +112 -0
- package/dist/idl/iyf-main-wrapper.d.ts.map +1 -0
- package/dist/idl/iyf-main-wrapper.js +2 -0
- package/dist/idl/jupiter-idl.d.ts +3063 -0
- package/dist/idl/jupiter-idl.d.ts.map +1 -0
- package/dist/idl/jupiter-idl.js +3061 -0
- package/dist/idl/meteora-idl.d.ts +7371 -0
- package/dist/idl/meteora-idl.d.ts.map +1 -0
- package/dist/idl/meteora-idl.js +7372 -0
- package/dist/idl/orca-idl.d.ts +3833 -0
- package/dist/idl/orca-idl.d.ts.map +1 -0
- package/dist/idl/orca-idl.js +3834 -0
- package/dist/idl/raydium-idl.d.ts +3054 -0
- package/dist/idl/raydium-idl.d.ts.map +1 -0
- package/dist/idl/raydium-idl.js +3055 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/ixGenerator/IyfExtensionIxGenerator.d.ts +126 -0
- package/dist/ixGenerator/IyfExtensionIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/IyfExtensionIxGenerator.js +467 -0
- package/dist/ixGenerator/IyfMainIxGenerator.d.ts +330 -0
- package/dist/ixGenerator/IyfMainIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/IyfMainIxGenerator.js +1239 -0
- package/dist/ixGenerator/MeteoraDlmmIxGenerator.d.ts +685 -0
- package/dist/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/MeteoraDlmmIxGenerator.js +3008 -0
- package/dist/ixGenerator/OrcaIxGenerator.d.ts +119 -0
- package/dist/ixGenerator/OrcaIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/OrcaIxGenerator.js +438 -0
- package/dist/ixGenerator/RaydiumIxGenerator.d.ts +99 -0
- package/dist/ixGenerator/RaydiumIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/RaydiumIxGenerator.js +558 -0
- package/dist/ixGenerator/UtilIxGenerator.d.ts +20 -0
- package/dist/ixGenerator/UtilIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/UtilIxGenerator.js +25 -0
- package/dist/meteora/index.d.ts +2 -0
- package/dist/meteora/index.d.ts.map +1 -0
- package/dist/meteora/index.js +17 -0
- package/dist/meteora/liquidityStrategy.d.ts +408 -0
- package/dist/meteora/liquidityStrategy.d.ts.map +1 -0
- package/dist/meteora/liquidityStrategy.js +1325 -0
- package/dist/meteora.d.ts +669 -0
- package/dist/meteora.d.ts.map +1 -0
- package/dist/meteora.js +1932 -0
- package/dist/orca.d.ts +57 -0
- package/dist/orca.d.ts.map +1 -0
- package/dist/orca.js +123 -0
- package/dist/pdaGenerator/HawksightPdaGenerator.d.ts +29 -0
- package/dist/pdaGenerator/HawksightPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/HawksightPdaGenerator.js +75 -0
- package/dist/pdaGenerator/MeteoraPdaGenerator.d.ts +76 -0
- package/dist/pdaGenerator/MeteoraPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/MeteoraPdaGenerator.js +166 -0
- package/dist/pdaGenerator/OrcaPdaGenerator.d.ts +23 -0
- package/dist/pdaGenerator/OrcaPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/OrcaPdaGenerator.js +68 -0
- package/dist/pdaGenerator/RaydiumPdaGenerator.d.ts +49 -0
- package/dist/pdaGenerator/RaydiumPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/RaydiumPdaGenerator.js +114 -0
- package/dist/pdaGenerator/UtilPdaGenerator.d.ts +8 -0
- package/dist/pdaGenerator/UtilPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/UtilPdaGenerator.js +51 -0
- package/dist/types.d.ts +1104 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +95 -0
- package/package.json +6 -5
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
2
|
+
import { IyfMainIxGenerator } from "./IyfMainIxGenerator";
|
|
3
|
+
import { SimplePdaGenerator } from "../classes/SimplePdaGenerator";
|
|
4
|
+
type OrcaLimitClosePositionAutomation = {
|
|
5
|
+
connection: web3.Connection;
|
|
6
|
+
userWallet: web3.PublicKey;
|
|
7
|
+
position: web3.PublicKey;
|
|
8
|
+
minBinId: number;
|
|
9
|
+
maxBinId: number;
|
|
10
|
+
useAta?: boolean;
|
|
11
|
+
is2022Position?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type OrcaAutoOpenPositionWithTokenExtension = {
|
|
14
|
+
connection: web3.Connection;
|
|
15
|
+
userWallet: web3.PublicKey;
|
|
16
|
+
positionMint: web3.PublicKey;
|
|
17
|
+
whirlpool: web3.PublicKey;
|
|
18
|
+
tickLowerIndex: number;
|
|
19
|
+
tickUpperIndex: number;
|
|
20
|
+
withTokenMetadata: boolean;
|
|
21
|
+
is2022Position?: boolean;
|
|
22
|
+
isUsdcFarm?: boolean;
|
|
23
|
+
};
|
|
24
|
+
type OrcaAutoClosePositionWithTokenExtension = {
|
|
25
|
+
connection: web3.Connection;
|
|
26
|
+
userWallet: web3.PublicKey;
|
|
27
|
+
positionMint: web3.PublicKey;
|
|
28
|
+
is2022Position?: boolean;
|
|
29
|
+
};
|
|
30
|
+
type OrcaOpenPositionWithTokenExtension = {
|
|
31
|
+
connection: web3.Connection;
|
|
32
|
+
userWallet: web3.PublicKey;
|
|
33
|
+
positionMint: web3.PublicKey;
|
|
34
|
+
whirlpool: web3.PublicKey;
|
|
35
|
+
tickLowerIndex: number;
|
|
36
|
+
tickUpperIndex: number;
|
|
37
|
+
withTokenMetadata: boolean;
|
|
38
|
+
is2022Position?: boolean;
|
|
39
|
+
};
|
|
40
|
+
type OrcaClosePositionWithTokenExtension = {
|
|
41
|
+
connection: web3.Connection;
|
|
42
|
+
userWallet: web3.PublicKey;
|
|
43
|
+
positionMint: web3.PublicKey;
|
|
44
|
+
is2022Position?: boolean;
|
|
45
|
+
};
|
|
46
|
+
type OrcaLimitClosePositionAutomationTokenExtension = {
|
|
47
|
+
connection: web3.Connection;
|
|
48
|
+
userWallet: web3.PublicKey;
|
|
49
|
+
position: web3.PublicKey;
|
|
50
|
+
minTickIndex: number;
|
|
51
|
+
maxTickIndex: number;
|
|
52
|
+
is2022Position?: boolean;
|
|
53
|
+
useAta?: boolean;
|
|
54
|
+
};
|
|
55
|
+
type CheckRange = {
|
|
56
|
+
minTickIndex: number;
|
|
57
|
+
maxTickIndex: number;
|
|
58
|
+
};
|
|
59
|
+
type OrcaAutoOpenPositionAndDepositRelative = {
|
|
60
|
+
connection: web3.Connection;
|
|
61
|
+
userWallet: web3.PublicKey;
|
|
62
|
+
positionMint: web3.PublicKey;
|
|
63
|
+
whirlpool: web3.PublicKey;
|
|
64
|
+
tokenMintA: web3.PublicKey;
|
|
65
|
+
tokenMintB: web3.PublicKey;
|
|
66
|
+
tokenVaultA: web3.PublicKey;
|
|
67
|
+
tokenVaultB: web3.PublicKey;
|
|
68
|
+
checkRange?: CheckRange;
|
|
69
|
+
tickCurrentIndex: number;
|
|
70
|
+
tickSpacing: number;
|
|
71
|
+
tickLowerOffset: number;
|
|
72
|
+
tickUpperOffset: number;
|
|
73
|
+
withTokenMetadata: boolean;
|
|
74
|
+
useAta?: boolean;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Orca IX Generator
|
|
78
|
+
*/
|
|
79
|
+
export declare class OrcaIxGenerator {
|
|
80
|
+
private iyfMain;
|
|
81
|
+
private pda;
|
|
82
|
+
constructor(iyfMain: IyfMainIxGenerator, pda: SimplePdaGenerator);
|
|
83
|
+
/**
|
|
84
|
+
* Orca limit close position automation
|
|
85
|
+
*/
|
|
86
|
+
orcaLimitClosePositionAutomation({ connection, userWallet, position, minBinId, maxBinId, useAta, is2022Position, }: OrcaLimitClosePositionAutomation): Promise<web3.TransactionInstruction>;
|
|
87
|
+
/**
|
|
88
|
+
* Orca auto open position with Token2022 (Automation)
|
|
89
|
+
*/
|
|
90
|
+
orcaAutoOpenPositionWithTokenExtension({ connection, userWallet, positionMint, whirlpool, tickLowerIndex, tickUpperIndex, withTokenMetadata, is2022Position, isUsdcFarm, }: OrcaAutoOpenPositionWithTokenExtension): Promise<web3.TransactionInstruction>;
|
|
91
|
+
/**
|
|
92
|
+
* Orca auto close position with Token2022 (Automation)
|
|
93
|
+
*/
|
|
94
|
+
orcaAutoClosePositionWithTokenExtension({ connection, userWallet, positionMint, is2022Position, }: OrcaAutoClosePositionWithTokenExtension): Promise<web3.TransactionInstruction>;
|
|
95
|
+
/**
|
|
96
|
+
* Orca open position with Token2022 (User)
|
|
97
|
+
*/
|
|
98
|
+
orcaOpenPositionWithTokenExtension({ connection, userWallet, positionMint, whirlpool, tickLowerIndex, tickUpperIndex, withTokenMetadata, is2022Position, }: OrcaOpenPositionWithTokenExtension): Promise<web3.TransactionInstruction>;
|
|
99
|
+
/**
|
|
100
|
+
* Orca close position with Token2022 (User)
|
|
101
|
+
*/
|
|
102
|
+
orcaClosePositionWithTokenExtension({ connection, userWallet, positionMint, is2022Position, }: OrcaClosePositionWithTokenExtension): Promise<web3.TransactionInstruction>;
|
|
103
|
+
/**
|
|
104
|
+
* Orca limit close position automation with Token2022 support (Automation)
|
|
105
|
+
*/
|
|
106
|
+
orcaLimitClosePositionAutomationTokenExtension({ connection, userWallet, position, minTickIndex, maxTickIndex, is2022Position, useAta }: OrcaLimitClosePositionAutomationTokenExtension): Promise<web3.TransactionInstruction>;
|
|
107
|
+
/**
|
|
108
|
+
* Orca auto open position and deposit with relative tick positioning (Automation)
|
|
109
|
+
*
|
|
110
|
+
* This instruction combines position opening and liquidity deposit in a single transaction,
|
|
111
|
+
* using relative tick offsets from the current whirlpool tick instead of absolute tick indices.
|
|
112
|
+
*
|
|
113
|
+
* Note: This is a simple instruction generator that does not fetch any account data.
|
|
114
|
+
* All required whirlpool data must be passed as parameters.
|
|
115
|
+
*/
|
|
116
|
+
orcaAutoOpenPositionAndDepositRelative({ connection, userWallet, positionMint, whirlpool, tokenMintA, tokenMintB, tokenVaultA, tokenVaultB, checkRange, tickCurrentIndex, tickSpacing, tickLowerOffset, tickUpperOffset, withTokenMetadata, useAta, }: OrcaAutoOpenPositionAndDepositRelative): Promise<web3.TransactionInstruction>;
|
|
117
|
+
}
|
|
118
|
+
export {};
|
|
119
|
+
//# sourceMappingURL=OrcaIxGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrcaIxGenerator.d.ts","sourceRoot":"","sources":["../../src/ixGenerator/OrcaIxGenerator.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.OrcaIxGenerator = void 0;
|
|
46
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
47
|
+
const anchor_1 = require("../anchor");
|
|
48
|
+
const functions_1 = require("../functions");
|
|
49
|
+
const addresses_1 = require("../addresses");
|
|
50
|
+
const orca_1 = require("../orca");
|
|
51
|
+
/**
|
|
52
|
+
* Orca IX Generator
|
|
53
|
+
*/
|
|
54
|
+
class OrcaIxGenerator {
|
|
55
|
+
constructor(iyfMain, pda) {
|
|
56
|
+
this.iyfMain = iyfMain;
|
|
57
|
+
this.pda = pda;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Orca limit close position automation
|
|
61
|
+
*/
|
|
62
|
+
orcaLimitClosePositionAutomation(_a) {
|
|
63
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, position, minBinId, maxBinId, useAta = true, is2022Position = false, }) {
|
|
64
|
+
// Initialize anchor
|
|
65
|
+
anchor_1.Anchor.initialize(connection);
|
|
66
|
+
// Generate user pda
|
|
67
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
68
|
+
const positionInfo = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(position);
|
|
69
|
+
const whirlpoolInfo = yield anchor_1.Anchor.instance().orcaProgram.account.whirlpool.fetch(positionInfo.whirlpool);
|
|
70
|
+
const whirlpool = positionInfo.whirlpool;
|
|
71
|
+
const positionMint = positionInfo.positionMint;
|
|
72
|
+
const positionTokenAccount = this.pda.orca.generatePositionTokenAccount(userPda, positionMint, is2022Position);
|
|
73
|
+
const tokenOwnerAccountA = useAta ? (0, functions_1.generateAta)(userPda, whirlpoolInfo.tokenMintA) : (0, functions_1.generateUserPdaStorageAccount)(userPda, whirlpoolInfo.tokenMintA);
|
|
74
|
+
const tokenOwnerAccountB = useAta ? (0, functions_1.generateAta)(userPda, whirlpoolInfo.tokenMintB) : (0, functions_1.generateUserPdaStorageAccount)(userPda, whirlpoolInfo.tokenMintB);
|
|
75
|
+
const tokenVaultA = whirlpoolInfo.tokenVaultA;
|
|
76
|
+
const tokenVaultB = whirlpoolInfo.tokenVaultB;
|
|
77
|
+
const startIndex = (0, orca_1.getStartTickIndex)(positionInfo.tickLowerIndex, whirlpoolInfo.tickSpacing);
|
|
78
|
+
const nextIndex = (0, orca_1.getStartTickIndex)(positionInfo.tickUpperIndex, whirlpoolInfo.tickSpacing);
|
|
79
|
+
const { publicKey: tickArrayLower } = (0, orca_1.getTickArray)(addresses_1.ORCA_WHIRLPOOL_PROGRAM, whirlpool, startIndex);
|
|
80
|
+
const { publicKey: tickArrayUpper } = (0, orca_1.getTickArray)(addresses_1.ORCA_WHIRLPOOL_PROGRAM, whirlpool, nextIndex);
|
|
81
|
+
const ownerFeeA = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, whirlpoolInfo.tokenMintA);
|
|
82
|
+
const ownerFeeB = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, whirlpoolInfo.tokenMintB);
|
|
83
|
+
const remainingAccounts = [];
|
|
84
|
+
for (const rewardInfo of whirlpoolInfo.rewardInfos) {
|
|
85
|
+
if (rewardInfo.mint.equals(web3.PublicKey.default)) {
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
const rewardAccount = useAta ? (0, functions_1.generateAta)(userPda, rewardInfo.mint) : (0, functions_1.generateUserPdaStorageAccount)(userPda, rewardInfo.mint);
|
|
89
|
+
remainingAccounts.push({ pubkey: rewardAccount, isSigner: false, isWritable: true });
|
|
90
|
+
remainingAccounts.push({ pubkey: rewardInfo.vault, isSigner: false, isWritable: true });
|
|
91
|
+
remainingAccounts.push({ pubkey: (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, rewardInfo.mint), isSigner: false, isWritable: true });
|
|
92
|
+
}
|
|
93
|
+
// Generate move_token instruction
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
const iyfExtensionIx = yield anchor_1.Anchor.instance().iyfExtension
|
|
96
|
+
.methods
|
|
97
|
+
.orcaLimitClosePositionAutomation(minBinId, maxBinId)
|
|
98
|
+
.accounts({
|
|
99
|
+
farm: addresses_1.USDC_FARM,
|
|
100
|
+
userPda,
|
|
101
|
+
authority: userWallet,
|
|
102
|
+
iyfProgram: addresses_1.IYF_MAIN,
|
|
103
|
+
hawksightAuthority: addresses_1.HS_AUTHORITY,
|
|
104
|
+
orcaWhirlpoolProgram: addresses_1.ORCA_WHIRLPOOL_PROGRAM,
|
|
105
|
+
positionMint,
|
|
106
|
+
whirlpool,
|
|
107
|
+
position,
|
|
108
|
+
positionTokenAccount,
|
|
109
|
+
tokenOwnerAccountA,
|
|
110
|
+
tokenOwnerAccountB,
|
|
111
|
+
tokenVaultA,
|
|
112
|
+
tokenVaultB,
|
|
113
|
+
tickArrayLower,
|
|
114
|
+
tickArrayUpper,
|
|
115
|
+
ownerFeeA,
|
|
116
|
+
ownerFeeB,
|
|
117
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
118
|
+
associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
|
|
119
|
+
})
|
|
120
|
+
.remainingAccounts(remainingAccounts)
|
|
121
|
+
.instruction();
|
|
122
|
+
// Wrap instruction in iyf extension (iyf-main)
|
|
123
|
+
return yield this.iyfMain.iyfExtensionExecute(connection, {
|
|
124
|
+
userWallet,
|
|
125
|
+
iyfExtensionIx,
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Orca auto open position with Token2022 (Automation)
|
|
131
|
+
*/
|
|
132
|
+
orcaAutoOpenPositionWithTokenExtension(_a) {
|
|
133
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, positionMint, whirlpool, tickLowerIndex, tickUpperIndex, withTokenMetadata, is2022Position = true, isUsdcFarm = true, }) {
|
|
134
|
+
// Initialize anchor
|
|
135
|
+
anchor_1.Anchor.initialize(connection);
|
|
136
|
+
// Generate user pda
|
|
137
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet, isUsdcFarm ? addresses_1.USDC_FARM : addresses_1.SOL_FARM);
|
|
138
|
+
// Generate position and position token account
|
|
139
|
+
const position = this.pda.orca.generateOrcaPositionPDA(positionMint);
|
|
140
|
+
const positionTokenAccount = this.pda.orca.generatePositionTokenAccount(userPda, positionMint, is2022Position);
|
|
141
|
+
// Generate orca auto open position with token extension instruction
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
const ix = yield anchor_1.Anchor.instance().iyfExtension
|
|
144
|
+
.methods
|
|
145
|
+
.orcaAutoOpenPositionWithTokenExtension(tickLowerIndex, tickUpperIndex, withTokenMetadata)
|
|
146
|
+
.accounts({
|
|
147
|
+
userPda,
|
|
148
|
+
hawksightAuthority: addresses_1.HS_AUTHORITY,
|
|
149
|
+
position,
|
|
150
|
+
positionMint,
|
|
151
|
+
positionTokenAccount,
|
|
152
|
+
whirlpool,
|
|
153
|
+
token2022Program: addresses_1.TOKEN_2022,
|
|
154
|
+
systemProgram: web3.SystemProgram.programId,
|
|
155
|
+
associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
|
|
156
|
+
metadataUpdateAuth: addresses_1.ORCA_METADATA_UPDATE_AUTH,
|
|
157
|
+
orcaWhirlpoolProgram: addresses_1.ORCA_WHIRLPOOL_PROGRAM,
|
|
158
|
+
})
|
|
159
|
+
.instruction();
|
|
160
|
+
// Wrap instruction in iyf extension executeV2 (iyf-main)
|
|
161
|
+
return yield this.iyfMain.iyfExtensionExecuteV2(connection, {
|
|
162
|
+
userPda,
|
|
163
|
+
authority: addresses_1.HS_AUTHORITY,
|
|
164
|
+
ix
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Orca auto close position with Token2022 (Automation)
|
|
170
|
+
*/
|
|
171
|
+
orcaAutoClosePositionWithTokenExtension(_a) {
|
|
172
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, positionMint, is2022Position = true, }) {
|
|
173
|
+
// Initialize anchor
|
|
174
|
+
anchor_1.Anchor.initialize(connection);
|
|
175
|
+
// Generate user pda
|
|
176
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
177
|
+
// Generate position and position token account
|
|
178
|
+
const position = this.pda.orca.generateOrcaPositionPDA(positionMint);
|
|
179
|
+
const positionTokenAccount = this.pda.orca.generatePositionTokenAccount(userPda, positionMint, is2022Position);
|
|
180
|
+
// Generate orca auto close position with token extension instruction
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
const ix = yield anchor_1.Anchor.instance().iyfExtension
|
|
183
|
+
.methods
|
|
184
|
+
.orcaAutoClosePositionWithTokenExtension()
|
|
185
|
+
.accounts({
|
|
186
|
+
userPda,
|
|
187
|
+
hawksightAuthority: addresses_1.HS_AUTHORITY,
|
|
188
|
+
position,
|
|
189
|
+
positionMint,
|
|
190
|
+
positionTokenAccount,
|
|
191
|
+
token2022Program: addresses_1.TOKEN_2022,
|
|
192
|
+
orcaWhirlpoolProgram: addresses_1.ORCA_WHIRLPOOL_PROGRAM,
|
|
193
|
+
})
|
|
194
|
+
.instruction();
|
|
195
|
+
// Wrap instruction in iyf extension executeV2 (iyf-main)
|
|
196
|
+
return yield this.iyfMain.iyfExtensionExecuteV2(connection, {
|
|
197
|
+
userPda,
|
|
198
|
+
authority: addresses_1.HS_AUTHORITY,
|
|
199
|
+
ix
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Orca open position with Token2022 (User)
|
|
205
|
+
*/
|
|
206
|
+
orcaOpenPositionWithTokenExtension(_a) {
|
|
207
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, positionMint, whirlpool, tickLowerIndex, tickUpperIndex, withTokenMetadata, is2022Position = true, }) {
|
|
208
|
+
// Initialize anchor
|
|
209
|
+
anchor_1.Anchor.initialize(connection);
|
|
210
|
+
// Generate user pda
|
|
211
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
212
|
+
// Generate position and position token account
|
|
213
|
+
const position = this.pda.orca.generateOrcaPositionPDA(positionMint);
|
|
214
|
+
const positionTokenAccount = this.pda.orca.generatePositionTokenAccount(userPda, positionMint, is2022Position);
|
|
215
|
+
// Generate orca open position with token extension instruction
|
|
216
|
+
// @ts-ignore
|
|
217
|
+
const ix = yield anchor_1.Anchor.instance().iyfExtension
|
|
218
|
+
.methods
|
|
219
|
+
.orcaOpenPositionWithTokenExtension(tickLowerIndex, tickUpperIndex, withTokenMetadata)
|
|
220
|
+
.accounts({
|
|
221
|
+
userPda,
|
|
222
|
+
authority: userWallet,
|
|
223
|
+
position,
|
|
224
|
+
positionMint,
|
|
225
|
+
positionTokenAccount,
|
|
226
|
+
whirlpool,
|
|
227
|
+
token2022Program: addresses_1.TOKEN_2022,
|
|
228
|
+
systemProgram: web3.SystemProgram.programId,
|
|
229
|
+
associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
|
|
230
|
+
metadataUpdateAuth: addresses_1.ORCA_METADATA_UPDATE_AUTH,
|
|
231
|
+
orcaWhirlpoolProgram: addresses_1.ORCA_WHIRLPOOL_PROGRAM,
|
|
232
|
+
})
|
|
233
|
+
.instruction();
|
|
234
|
+
// Wrap instruction in iyf extension executeV2 (iyf-main)
|
|
235
|
+
return yield this.iyfMain.iyfExtensionExecuteV2(connection, {
|
|
236
|
+
userPda,
|
|
237
|
+
authority: userWallet,
|
|
238
|
+
ix
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Orca close position with Token2022 (User)
|
|
244
|
+
*/
|
|
245
|
+
orcaClosePositionWithTokenExtension(_a) {
|
|
246
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, positionMint, is2022Position = true, }) {
|
|
247
|
+
// Initialize anchor
|
|
248
|
+
anchor_1.Anchor.initialize(connection);
|
|
249
|
+
// Generate user pda
|
|
250
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
251
|
+
// Generate position and position token account
|
|
252
|
+
const position = this.pda.orca.generateOrcaPositionPDA(positionMint);
|
|
253
|
+
const positionTokenAccount = this.pda.orca.generatePositionTokenAccount(userPda, positionMint, is2022Position);
|
|
254
|
+
// Generate orca close position with token extension instruction
|
|
255
|
+
// @ts-ignore
|
|
256
|
+
const ix = yield anchor_1.Anchor.instance().iyfExtension
|
|
257
|
+
.methods
|
|
258
|
+
.orcaClosePositionWithTokenExtension()
|
|
259
|
+
.accounts({
|
|
260
|
+
userPda,
|
|
261
|
+
authority: userWallet,
|
|
262
|
+
position,
|
|
263
|
+
positionMint,
|
|
264
|
+
positionTokenAccount,
|
|
265
|
+
token2022Program: addresses_1.TOKEN_2022,
|
|
266
|
+
orcaWhirlpoolProgram: addresses_1.ORCA_WHIRLPOOL_PROGRAM,
|
|
267
|
+
})
|
|
268
|
+
.instruction();
|
|
269
|
+
// Wrap instruction in iyf extension executeV2 (iyf-main)
|
|
270
|
+
return yield this.iyfMain.iyfExtensionExecuteV2(connection, {
|
|
271
|
+
userPda,
|
|
272
|
+
authority: userWallet,
|
|
273
|
+
ix
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Orca limit close position automation with Token2022 support (Automation)
|
|
279
|
+
*/
|
|
280
|
+
orcaLimitClosePositionAutomationTokenExtension(_a) {
|
|
281
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, position, minTickIndex, maxTickIndex, is2022Position = true, useAta = false }) {
|
|
282
|
+
// Initialize anchor
|
|
283
|
+
anchor_1.Anchor.initialize(connection);
|
|
284
|
+
// Generate user pda
|
|
285
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
286
|
+
const positionInfo = yield anchor_1.Anchor.instance().orcaProgram.account.position.fetch(position);
|
|
287
|
+
const whirlpoolInfo = yield anchor_1.Anchor.instance().orcaProgram.account.whirlpool.fetch(positionInfo.whirlpool);
|
|
288
|
+
const whirlpool = positionInfo.whirlpool;
|
|
289
|
+
const positionMint = positionInfo.positionMint;
|
|
290
|
+
const positionTokenAccount = this.pda.orca.generatePositionTokenAccount(userPda, positionMint, is2022Position);
|
|
291
|
+
const tokenOwnerAccountA = useAta
|
|
292
|
+
? (0, functions_1.generateAta)(userPda, whirlpoolInfo.tokenMintA)
|
|
293
|
+
: (0, functions_1.generateUserPdaStorageAccount)(userPda, whirlpoolInfo.tokenMintA);
|
|
294
|
+
const tokenOwnerAccountB = useAta
|
|
295
|
+
? (0, functions_1.generateAta)(userPda, whirlpoolInfo.tokenMintB)
|
|
296
|
+
: (0, functions_1.generateUserPdaStorageAccount)(userPda, whirlpoolInfo.tokenMintB);
|
|
297
|
+
const tokenVaultA = whirlpoolInfo.tokenVaultA;
|
|
298
|
+
const tokenVaultB = whirlpoolInfo.tokenVaultB;
|
|
299
|
+
const startIndex = (0, orca_1.getStartTickIndex)(positionInfo.tickLowerIndex, whirlpoolInfo.tickSpacing);
|
|
300
|
+
const nextIndex = (0, orca_1.getStartTickIndex)(positionInfo.tickUpperIndex, whirlpoolInfo.tickSpacing);
|
|
301
|
+
const { publicKey: tickArrayLower } = (0, orca_1.getTickArray)(addresses_1.ORCA_WHIRLPOOL_PROGRAM, whirlpool, startIndex);
|
|
302
|
+
const { publicKey: tickArrayUpper } = (0, orca_1.getTickArray)(addresses_1.ORCA_WHIRLPOOL_PROGRAM, whirlpool, nextIndex);
|
|
303
|
+
const ownerFeeA = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, whirlpoolInfo.tokenMintA);
|
|
304
|
+
const ownerFeeB = (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, whirlpoolInfo.tokenMintB);
|
|
305
|
+
// Generate orca limit close position automation token extension instruction
|
|
306
|
+
// @ts-ignore
|
|
307
|
+
const ix = yield anchor_1.Anchor.instance().iyfExtension
|
|
308
|
+
.methods
|
|
309
|
+
.orcaLimitClosePositionAutomationTokenExtension(minTickIndex, maxTickIndex)
|
|
310
|
+
.accounts({
|
|
311
|
+
userPda,
|
|
312
|
+
hawksightAuthority: addresses_1.HS_AUTHORITY,
|
|
313
|
+
authority: userWallet,
|
|
314
|
+
orcaWhirlpoolProgram: addresses_1.ORCA_WHIRLPOOL_PROGRAM,
|
|
315
|
+
positionMint,
|
|
316
|
+
whirlpool,
|
|
317
|
+
position,
|
|
318
|
+
positionTokenAccount,
|
|
319
|
+
tokenOwnerAccountA,
|
|
320
|
+
tokenOwnerAccountB,
|
|
321
|
+
tokenVaultA,
|
|
322
|
+
tokenVaultB,
|
|
323
|
+
tickArrayLower,
|
|
324
|
+
tickArrayUpper,
|
|
325
|
+
ownerFeeA,
|
|
326
|
+
ownerFeeB,
|
|
327
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID, // SPL Token for fees/liquidity
|
|
328
|
+
token2022Program: addresses_1.TOKEN_2022, // Token2022 for position operations
|
|
329
|
+
associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
|
|
330
|
+
})
|
|
331
|
+
.instruction();
|
|
332
|
+
// Wrap instruction in iyf extension executeV2 (iyf-main) - AUTOMATION
|
|
333
|
+
return yield this.iyfMain.iyfExtensionExecuteV2(connection, {
|
|
334
|
+
userPda,
|
|
335
|
+
authority: addresses_1.HS_AUTHORITY, // Automation operation
|
|
336
|
+
ix
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Orca auto open position and deposit with relative tick positioning (Automation)
|
|
342
|
+
*
|
|
343
|
+
* This instruction combines position opening and liquidity deposit in a single transaction,
|
|
344
|
+
* using relative tick offsets from the current whirlpool tick instead of absolute tick indices.
|
|
345
|
+
*
|
|
346
|
+
* Note: This is a simple instruction generator that does not fetch any account data.
|
|
347
|
+
* All required whirlpool data must be passed as parameters.
|
|
348
|
+
*/
|
|
349
|
+
orcaAutoOpenPositionAndDepositRelative(_a) {
|
|
350
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, positionMint, whirlpool, tokenMintA, tokenMintB, tokenVaultA, tokenVaultB, checkRange, tickCurrentIndex, tickSpacing, tickLowerOffset, tickUpperOffset, withTokenMetadata, useAta = false, }) {
|
|
351
|
+
// Initialize anchor
|
|
352
|
+
anchor_1.Anchor.initialize(connection);
|
|
353
|
+
// Generate user pda
|
|
354
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
355
|
+
// Generate position and position token account
|
|
356
|
+
const position = this.pda.orca.generateOrcaPositionPDA(positionMint);
|
|
357
|
+
const positionTokenAccount = this.pda.orca.generatePositionTokenAccount(userPda, positionMint, true);
|
|
358
|
+
// Generate token accounts for liquidity deposit
|
|
359
|
+
const tokenOwnerAccountA = useAta
|
|
360
|
+
? (0, functions_1.generateAta)(userPda, tokenMintA)
|
|
361
|
+
: (0, functions_1.generateUserPdaStorageAccount)(userPda, tokenMintA);
|
|
362
|
+
const tokenOwnerAccountB = useAta
|
|
363
|
+
? (0, functions_1.generateAta)(userPda, tokenMintB)
|
|
364
|
+
: (0, functions_1.generateUserPdaStorageAccount)(userPda, tokenMintB);
|
|
365
|
+
// Calculate absolute tick indices from current tick + offsets
|
|
366
|
+
// Note: The on-chain program will do the actual calculation and validation
|
|
367
|
+
// We calculate them here to determine which tick array pdas to use
|
|
368
|
+
const tickLowerIndex = tickCurrentIndex + tickLowerOffset;
|
|
369
|
+
const tickUpperIndex = tickCurrentIndex + tickUpperOffset;
|
|
370
|
+
// Calculate tick arrays based on calculated tick indices
|
|
371
|
+
const startIndexLower = (0, orca_1.getStartTickIndex)(tickLowerIndex, tickSpacing);
|
|
372
|
+
const startIndexUpper = (0, orca_1.getStartTickIndex)(tickUpperIndex, tickSpacing);
|
|
373
|
+
const { publicKey: tickArrayLower } = (0, orca_1.getTickArray)(addresses_1.ORCA_WHIRLPOOL_PROGRAM, whirlpool, startIndexLower);
|
|
374
|
+
const { publicKey: tickArrayUpper } = (0, orca_1.getTickArray)(addresses_1.ORCA_WHIRLPOOL_PROGRAM, whirlpool, startIndexUpper);
|
|
375
|
+
// Build instruction data manually
|
|
376
|
+
// Format: [discriminator: 8 bytes][tick_lower_offset: i32][tick_upper_offset: i32][with_token_metadata: bool]
|
|
377
|
+
const discriminator = (0, functions_1.sighash)('orca_auto_open_position_and_deposit_relative');
|
|
378
|
+
const tickLowerOffsetBuffer = Buffer.alloc(4);
|
|
379
|
+
tickLowerOffsetBuffer.writeInt32LE(tickLowerOffset, 0);
|
|
380
|
+
const tickUpperOffsetBuffer = Buffer.alloc(4);
|
|
381
|
+
tickUpperOffsetBuffer.writeInt32LE(tickUpperOffset, 0);
|
|
382
|
+
const withTokenMetadataBuffer = Buffer.alloc(1);
|
|
383
|
+
withTokenMetadataBuffer.writeUInt8(withTokenMetadata ? 1 : 0, 0);
|
|
384
|
+
let checkRangeBuffer;
|
|
385
|
+
if (checkRange) {
|
|
386
|
+
checkRangeBuffer = Buffer.alloc(9);
|
|
387
|
+
checkRangeBuffer.writeUInt8(1, 0);
|
|
388
|
+
checkRangeBuffer.writeInt32LE(checkRange.minTickIndex, 1);
|
|
389
|
+
checkRangeBuffer.writeInt32LE(checkRange.maxTickIndex, 5);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
checkRangeBuffer = Buffer.alloc(1);
|
|
393
|
+
checkRangeBuffer.writeUInt8(0, 0);
|
|
394
|
+
}
|
|
395
|
+
const data = Buffer.concat([
|
|
396
|
+
discriminator,
|
|
397
|
+
tickLowerOffsetBuffer,
|
|
398
|
+
tickUpperOffsetBuffer,
|
|
399
|
+
withTokenMetadataBuffer,
|
|
400
|
+
checkRangeBuffer,
|
|
401
|
+
]);
|
|
402
|
+
// Build accounts array following the exact order from the smart contract
|
|
403
|
+
const keys = [
|
|
404
|
+
{ pubkey: userPda, isSigner: false, isWritable: false }, // 1. user_pda
|
|
405
|
+
{ pubkey: addresses_1.HS_AUTHORITY, isSigner: true, isWritable: true }, // 2. hawksight_authority (REBALANCE_AUTHORITY)
|
|
406
|
+
{ pubkey: position, isSigner: false, isWritable: true }, // 3. position (uninitialized)
|
|
407
|
+
{ pubkey: positionMint, isSigner: true, isWritable: true }, // 4. position_mint (signer)
|
|
408
|
+
{ pubkey: positionTokenAccount, isSigner: false, isWritable: true }, // 5. position_token_account (uninitialized)
|
|
409
|
+
{ pubkey: whirlpool, isSigner: false, isWritable: true }, // 6. whirlpool
|
|
410
|
+
{ pubkey: tokenOwnerAccountA, isSigner: false, isWritable: true }, // 7. token_owner_account_a
|
|
411
|
+
{ pubkey: tokenOwnerAccountB, isSigner: false, isWritable: true }, // 8. token_owner_account_b
|
|
412
|
+
{ pubkey: tokenVaultA, isSigner: false, isWritable: true }, // 9. token_vault_a
|
|
413
|
+
{ pubkey: tokenVaultB, isSigner: false, isWritable: true }, // 10. token_vault_b
|
|
414
|
+
{ pubkey: tickArrayLower, isSigner: false, isWritable: true }, // 11. tick_array_lower
|
|
415
|
+
{ pubkey: tickArrayUpper, isSigner: false, isWritable: true }, // 12. tick_array_upper
|
|
416
|
+
{ pubkey: addresses_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false }, // 13. token_program
|
|
417
|
+
{ pubkey: addresses_1.TOKEN_2022, isSigner: false, isWritable: false }, // 14. token_2022_program
|
|
418
|
+
{ pubkey: web3.SystemProgram.programId, isSigner: false, isWritable: false }, // 15. system_program
|
|
419
|
+
{ pubkey: addresses_1.ASSOCIATED_TOKEN_PROGRAM, isSigner: false, isWritable: false }, // 16. associated_token_program
|
|
420
|
+
{ pubkey: addresses_1.ORCA_METADATA_UPDATE_AUTH, isSigner: false, isWritable: false }, // 17. metadata_update_auth
|
|
421
|
+
{ pubkey: addresses_1.ORCA_WHIRLPOOL_PROGRAM, isSigner: false, isWritable: false }, // 18. orca_whirlpool_program
|
|
422
|
+
];
|
|
423
|
+
// Create the raw instruction
|
|
424
|
+
const ix = new web3.TransactionInstruction({
|
|
425
|
+
programId: addresses_1.IYF_EXTENSION,
|
|
426
|
+
keys,
|
|
427
|
+
data,
|
|
428
|
+
});
|
|
429
|
+
// Wrap instruction in iyf extension executeV2 (iyf-main)
|
|
430
|
+
return yield this.iyfMain.iyfExtensionExecuteV2(connection, {
|
|
431
|
+
userPda,
|
|
432
|
+
authority: addresses_1.HS_AUTHORITY,
|
|
433
|
+
ix,
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
exports.OrcaIxGenerator = OrcaIxGenerator;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
2
|
+
import { IyfMainIxGenerator } from "./IyfMainIxGenerator";
|
|
3
|
+
import { RaydiumClosePosition, RaydiumDecreaseLiquidity, RaydiumIncreaseLiquidity, RaydiumOpenPosition, RaydiumSweepDust, TxgenParams, RaydiumOpenPositionAutomation, RaydiumIncreaseLiquidityAutomation, RaydiumDecreaseLiquidityAutomation } from '../types';
|
|
4
|
+
import { IyfExtensionIxGenerator } from "./IyfExtensionIxGenerator";
|
|
5
|
+
import { SimplePdaGenerator } from "../classes/SimplePdaGenerator";
|
|
6
|
+
import BN from "bn.js";
|
|
7
|
+
import { RaydiumClosePositionAutomation, RaydiumFetch, RaydiumFetchParams } from "../types";
|
|
8
|
+
/**
|
|
9
|
+
* Meteora related instructions executed via iyf extension or iyf main
|
|
10
|
+
*/
|
|
11
|
+
export declare class RaydiumIxGenerator {
|
|
12
|
+
private iyfMain;
|
|
13
|
+
private iyfExtension;
|
|
14
|
+
private pda;
|
|
15
|
+
constructor(iyfMain: IyfMainIxGenerator, iyfExtension: IyfExtensionIxGenerator, pda: SimplePdaGenerator);
|
|
16
|
+
raydiumFetch({ personalPosition, poolState }: RaydiumFetchParams): Promise<RaydiumFetch>;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
20
|
+
* @param payer The public key of the payer for transaction fees.
|
|
21
|
+
* @param params Parameters required
|
|
22
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
23
|
+
*/
|
|
24
|
+
raydiumOpenPosition({ connection, params, fetch }: TxgenParams<RaydiumOpenPosition, RaydiumFetch>): Promise<web3.TransactionInstruction>;
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
28
|
+
* @param payer The public key of the payer for transaction fees.
|
|
29
|
+
* @param params Parameters required
|
|
30
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
31
|
+
*/
|
|
32
|
+
raydiumOpenPositionAutomation({ connection, params }: TxgenParams<RaydiumOpenPositionAutomation>): Promise<web3.TransactionInstruction>;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
36
|
+
* @param payer The public key of the payer for transaction fees.
|
|
37
|
+
* @param params Parameters required
|
|
38
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
39
|
+
*/
|
|
40
|
+
raydiumClosePosition({ connection, params, fetch }: TxgenParams<RaydiumClosePosition, RaydiumFetch>): Promise<web3.TransactionInstruction>;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
44
|
+
* @param payer The public key of the payer for transaction fees.
|
|
45
|
+
* @param params Parameters required
|
|
46
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
47
|
+
*/
|
|
48
|
+
raydiumClosePositionAutomation({ connection, params }: TxgenParams<RaydiumClosePositionAutomation>): Promise<web3.TransactionInstruction>;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
52
|
+
* @param payer The public key of the payer for transaction fees.
|
|
53
|
+
* @param params Parameters required
|
|
54
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
55
|
+
*/
|
|
56
|
+
raydiumIncreaseLiquidity({ connection, params, fetch }: TxgenParams<RaydiumIncreaseLiquidity, RaydiumFetch>): Promise<web3.TransactionInstruction>;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
60
|
+
* @param payer The public key of the payer for transaction fees.
|
|
61
|
+
* @param params Parameters required
|
|
62
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
63
|
+
*/
|
|
64
|
+
raydiumIncreaseLiquidityAutomation({ connection, params, fetch }: TxgenParams<RaydiumIncreaseLiquidityAutomation, RaydiumFetch>): Promise<web3.TransactionInstruction>;
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
68
|
+
* @param payer The public key of the payer for transaction fees.
|
|
69
|
+
* @param params Parameters required
|
|
70
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
71
|
+
*/
|
|
72
|
+
raydiumDecreaseLiquidity({ connection, params, fetch }: TxgenParams<RaydiumDecreaseLiquidity, RaydiumFetch>): Promise<web3.TransactionInstruction>;
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
76
|
+
* @param payer The public key of the payer for transaction fees.
|
|
77
|
+
* @param params Parameters required
|
|
78
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
79
|
+
*/
|
|
80
|
+
raydiumDecreaseLiquidityAutomation({ connection, params, fetch }: TxgenParams<RaydiumDecreaseLiquidityAutomation, RaydiumFetch>): Promise<web3.TransactionInstruction>;
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
84
|
+
* @param payer The public key of the payer for transaction fees.
|
|
85
|
+
* @param params Parameters required
|
|
86
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
87
|
+
*/
|
|
88
|
+
raydiumSweepDust({ connection, params, fetch }: TxgenParams<RaydiumSweepDust, RaydiumFetch>): Promise<web3.TransactionInstruction>;
|
|
89
|
+
}
|
|
90
|
+
export declare function getLiquidityFromAmounts(connection: web3.Connection, poolId: web3.PublicKey, amountA: BN, amountB: BN, tickLower: number, tickUpper: number, slippage: number, add: boolean): Promise<{
|
|
91
|
+
liquidity: BN;
|
|
92
|
+
amount0Max: BN;
|
|
93
|
+
amount1Max: BN;
|
|
94
|
+
}>;
|
|
95
|
+
export declare function getAmountsFromLiquidity(connection: web3.Connection, poolId: web3.PublicKey, liquidity: BN, tickLower: number, tickUpper: number, slippage: number, add: boolean): Promise<{
|
|
96
|
+
amount0Min: BN;
|
|
97
|
+
amount1Min: BN;
|
|
98
|
+
}>;
|
|
99
|
+
//# sourceMappingURL=RaydiumIxGenerator.d.ts.map
|