@hawksightco/hawk-sdk 1.1.74 → 1.2.1
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/src/addresses.d.ts +3 -0
- package/dist/src/addresses.d.ts.map +1 -1
- package/dist/src/addresses.js +4 -1
- package/dist/src/anchor.d.ts +2 -0
- package/dist/src/anchor.d.ts.map +1 -1
- package/dist/src/anchor.js +2 -0
- package/dist/src/classes/HawkAPI.js +1 -2
- package/dist/src/classes/SimpleIxGenerator.d.ts +28 -5
- package/dist/src/classes/SimpleIxGenerator.d.ts.map +1 -1
- package/dist/src/classes/SimpleIxGenerator.js +29 -6
- package/dist/src/classes/Transactions.d.ts +34 -1
- package/dist/src/classes/Transactions.d.ts.map +1 -1
- package/dist/src/classes/Transactions.js +123 -0
- package/dist/src/classes/TxGenerator.d.ts +17 -1
- package/dist/src/classes/TxGenerator.d.ts.map +1 -1
- package/dist/src/classes/TxGenerator.js +135 -10
- package/dist/src/classes/TxGeneratorAutomations.d.ts.map +1 -1
- package/dist/src/classes/TxGeneratorAutomations.js +5 -0
- package/dist/src/functions.d.ts +10 -0
- package/dist/src/functions.d.ts.map +1 -1
- package/dist/src/functions.js +53 -1
- package/dist/src/idl/iyf-extension-idl.d.ts +166 -210
- package/dist/src/idl/iyf-extension-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-extension-idl.js +168 -212
- package/dist/src/idl/iyf-main-idl.d.ts +288 -0
- package/dist/src/idl/iyf-main-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-main-idl.js +288 -0
- package/dist/src/idl/raydium-idl.d.ts +3054 -0
- package/dist/src/idl/raydium-idl.d.ts.map +1 -0
- package/dist/src/idl/raydium-idl.js +3055 -0
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts +80 -1
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts.map +1 -1
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.js +288 -1
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts +31 -0
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts.map +1 -1
- package/dist/src/ixGenerator/IyfMainIxGenerator.js +183 -0
- package/dist/src/ixGenerator/RaydiumIxGenerator.d.ts +114 -0
- package/dist/src/ixGenerator/RaydiumIxGenerator.d.ts.map +1 -0
- package/dist/src/ixGenerator/RaydiumIxGenerator.js +398 -0
- package/dist/src/pdaGenerator/RaydiumPdaGenerator.d.ts +44 -1
- package/dist/src/pdaGenerator/RaydiumPdaGenerator.d.ts.map +1 -1
- package/dist/src/pdaGenerator/RaydiumPdaGenerator.js +96 -1
- package/dist/src/types.d.ts +35 -1
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,398 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.RaydiumIxGenerator = void 0;
|
|
36
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
37
|
+
const anchor_1 = require("../anchor");
|
|
38
|
+
const functions_1 = require("../functions");
|
|
39
|
+
const addresses_1 = require("../addresses");
|
|
40
|
+
/**
|
|
41
|
+
* Meteora related instructions executed via iyf extension or iyf main
|
|
42
|
+
*/
|
|
43
|
+
class RaydiumIxGenerator {
|
|
44
|
+
constructor(iyfMain, iyfExtension, pda) {
|
|
45
|
+
this.iyfMain = iyfMain;
|
|
46
|
+
this.iyfExtension = iyfExtension;
|
|
47
|
+
this.pda = pda;
|
|
48
|
+
}
|
|
49
|
+
raydiumFetch(_a) {
|
|
50
|
+
return __awaiter(this, arguments, void 0, function* ({ personalPosition, poolState }) {
|
|
51
|
+
if (personalPosition !== undefined) {
|
|
52
|
+
const positionInfo = yield anchor_1.Anchor.instance().raydiumProgram.account.PersonalPositionState.fetch(personalPosition);
|
|
53
|
+
const poolStateInfo = yield anchor_1.Anchor.instance().raydiumProgram.account.PoolState.fetch(positionInfo.poolId);
|
|
54
|
+
return { positionInfo, poolStateInfo };
|
|
55
|
+
}
|
|
56
|
+
else if (poolState !== undefined) {
|
|
57
|
+
const poolStateInfo = yield anchor_1.Anchor.instance().raydiumProgram.account.PoolState.fetch(poolState);
|
|
58
|
+
return { poolStateInfo };
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new Error('RaydiumIxGenerator: Unexpected error: personalPosition or poolState parameter must be present');
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
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
|
+
raydiumOpenPosition(_a) {
|
|
73
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
74
|
+
const farm = addresses_1.USDC_FARM;
|
|
75
|
+
const payer = params.userWallet;
|
|
76
|
+
const positionNftOwner = (0, functions_1.generateUserPdaLamport)(params.userWallet, farm);
|
|
77
|
+
const positionNftMint = params.nftMint;
|
|
78
|
+
const positionNftAccount = (0, functions_1.generateAta2022)(positionNftOwner, positionNftMint);
|
|
79
|
+
const poolState = params.poolState;
|
|
80
|
+
const protocolPosition = this.pda.raydium.generateRaydiumProtocolPosition(poolState, params.tickLowerIndex, params.tickUpperIndex);
|
|
81
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(positionNftMint);
|
|
82
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
83
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
84
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
85
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
86
|
+
const tokenAccount0 = (0, functions_1.generateAta)(positionNftOwner, vault0Mint);
|
|
87
|
+
const tokenAccount1 = (0, functions_1.generateAta)(positionNftOwner, vault1Mint);
|
|
88
|
+
const tickArrayLowerStartIndex = (0, functions_1.raydiumStartTickIndex)(params.tickLowerIndex, fetch.poolStateInfo.tickSpacing);
|
|
89
|
+
const tickArrayUpperStartIndex = (0, functions_1.raydiumStartTickIndex)(params.tickUpperIndex, fetch.poolStateInfo.tickSpacing);
|
|
90
|
+
const tickArrayLower = this.pda.raydium.generateRaydiumTickArrayPda(poolState, tickArrayLowerStartIndex);
|
|
91
|
+
const tickArrayUpper = this.pda.raydium.generateRaydiumTickArrayPda(poolState, tickArrayUpperStartIndex);
|
|
92
|
+
return this.iyfMain.raydiumDynamicCpi(connection, {
|
|
93
|
+
userWallet: params.userWallet,
|
|
94
|
+
raydiumIx: yield anchor_1.Anchor.instance().raydiumProgram.methods
|
|
95
|
+
.openPositionWithToken22Nft(params.tickLowerIndex, params.tickUpperIndex, tickArrayLowerStartIndex, tickArrayUpperStartIndex, params.liquidity, params.amount0Max, params.amount1Max, false, null)
|
|
96
|
+
.accounts({
|
|
97
|
+
payer,
|
|
98
|
+
positionNftOwner,
|
|
99
|
+
positionNftMint,
|
|
100
|
+
positionNftAccount,
|
|
101
|
+
poolState,
|
|
102
|
+
protocolPosition,
|
|
103
|
+
tickArrayLower,
|
|
104
|
+
tickArrayUpper,
|
|
105
|
+
personalPosition,
|
|
106
|
+
tokenAccount0,
|
|
107
|
+
tokenAccount1,
|
|
108
|
+
tokenVault0,
|
|
109
|
+
tokenVault1,
|
|
110
|
+
rent: web3.SYSVAR_RENT_PUBKEY,
|
|
111
|
+
systemProgram: web3.SystemProgram.programId,
|
|
112
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
113
|
+
associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
|
|
114
|
+
tokenProgram2022: addresses_1.TOKEN_2022,
|
|
115
|
+
vault0Mint,
|
|
116
|
+
vault1Mint,
|
|
117
|
+
})
|
|
118
|
+
.instruction()
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
125
|
+
* @param payer The public key of the payer for transaction fees.
|
|
126
|
+
* @param params Parameters required
|
|
127
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
128
|
+
*/
|
|
129
|
+
raydiumOpenPositionAutomation(_a) {
|
|
130
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params }) {
|
|
131
|
+
const fetch = yield this.raydiumFetch({ poolState: params.poolState });
|
|
132
|
+
const poolState = params.poolState;
|
|
133
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
134
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
135
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
136
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
137
|
+
return yield this.iyfExtension.raydiumOpenPositionAutomation({
|
|
138
|
+
connection,
|
|
139
|
+
userWallet: params.userWallet,
|
|
140
|
+
nftMint: params.nftMint,
|
|
141
|
+
poolState,
|
|
142
|
+
tokenVault0,
|
|
143
|
+
tokenVault1,
|
|
144
|
+
vault0Mint,
|
|
145
|
+
vault1Mint,
|
|
146
|
+
tickSpacing: fetch.poolStateInfo.tickSpacing,
|
|
147
|
+
tickLowerIndex: params.tickLowerIndex,
|
|
148
|
+
tickUpperIndex: params.tickUpperIndex,
|
|
149
|
+
liquidity: params.liquidity,
|
|
150
|
+
amount0Max: params.amount0Max,
|
|
151
|
+
amount1Max: params.amount1Max,
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
*
|
|
157
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
158
|
+
* @param payer The public key of the payer for transaction fees.
|
|
159
|
+
* @param params Parameters required
|
|
160
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
161
|
+
*/
|
|
162
|
+
raydiumClosePosition(_a) {
|
|
163
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
164
|
+
const farm = addresses_1.USDC_FARM;
|
|
165
|
+
const nftOwner = (0, functions_1.generateUserPdaLamport)(params.userWallet, farm);
|
|
166
|
+
const positionNftMint = fetch.positionInfo.nftMint;
|
|
167
|
+
const positionNftAccount = (0, functions_1.generateAta2022)(nftOwner, positionNftMint);
|
|
168
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(positionNftMint);
|
|
169
|
+
return this.iyfMain.raydiumDynamicCpi(connection, {
|
|
170
|
+
userWallet: params.userWallet,
|
|
171
|
+
raydiumIx: yield anchor_1.Anchor.instance().raydiumProgram.methods
|
|
172
|
+
.closePosition()
|
|
173
|
+
.accounts({
|
|
174
|
+
nftOwner,
|
|
175
|
+
positionNftMint,
|
|
176
|
+
positionNftAccount,
|
|
177
|
+
personalPosition,
|
|
178
|
+
systemProgram: web3.SystemProgram.programId,
|
|
179
|
+
tokenProgram: addresses_1.TOKEN_2022,
|
|
180
|
+
})
|
|
181
|
+
.instruction()
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
*
|
|
187
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
188
|
+
* @param payer The public key of the payer for transaction fees.
|
|
189
|
+
* @param params Parameters required
|
|
190
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
191
|
+
*/
|
|
192
|
+
raydiumClosePositionAutomation(_a) {
|
|
193
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params }) {
|
|
194
|
+
return yield this.iyfExtension.raydiumClosePositionAutomation({
|
|
195
|
+
connection,
|
|
196
|
+
userWallet: params.userWallet,
|
|
197
|
+
positionNftMint: params.nftMint,
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
*
|
|
203
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
204
|
+
* @param payer The public key of the payer for transaction fees.
|
|
205
|
+
* @param params Parameters required
|
|
206
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
207
|
+
*/
|
|
208
|
+
raydiumIncreaseLiquidity(_a) {
|
|
209
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
210
|
+
const farm = addresses_1.USDC_FARM;
|
|
211
|
+
const nftOwner = (0, functions_1.generateUserPdaLamport)(params.userWallet, farm);
|
|
212
|
+
const poolState = fetch.positionInfo.poolId;
|
|
213
|
+
const protocolPosition = this.pda.raydium.generateRaydiumProtocolPosition(poolState, fetch.positionInfo.tickLowerIndex, fetch.positionInfo.tickUpperIndex);
|
|
214
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
215
|
+
const nftAccount = (0, functions_1.generateAta2022)(nftOwner, nftMint);
|
|
216
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(nftMint);
|
|
217
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
218
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
219
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
220
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
221
|
+
const tokenAccount0 = (0, functions_1.generateAta)(nftOwner, vault0Mint);
|
|
222
|
+
const tickArrayLowerStartIndex = (0, functions_1.raydiumStartTickIndex)(fetch.positionInfo.tickLowerIndex, fetch.poolStateInfo.tickSpacing);
|
|
223
|
+
const tickArrayUpperStartIndex = (0, functions_1.raydiumStartTickIndex)(fetch.positionInfo.tickUpperIndex, fetch.poolStateInfo.tickSpacing);
|
|
224
|
+
const tokenAccount1 = (0, functions_1.generateAta)(nftOwner, vault1Mint);
|
|
225
|
+
const tickArrayLower = this.pda.raydium.generateRaydiumTickArrayPda(poolState, tickArrayLowerStartIndex);
|
|
226
|
+
const tickArrayUpper = this.pda.raydium.generateRaydiumTickArrayPda(poolState, tickArrayUpperStartIndex);
|
|
227
|
+
return this.iyfMain.raydiumDynamicCpi(connection, {
|
|
228
|
+
userWallet: params.userWallet,
|
|
229
|
+
raydiumIx: yield anchor_1.Anchor.instance().raydiumProgram.methods
|
|
230
|
+
.increaseLiquidityV2(params.liquidity, params.amount0Max, params.amount1Max, false)
|
|
231
|
+
.accounts({
|
|
232
|
+
nftOwner,
|
|
233
|
+
nftAccount,
|
|
234
|
+
poolState,
|
|
235
|
+
protocolPosition,
|
|
236
|
+
personalPosition,
|
|
237
|
+
tickArrayLower,
|
|
238
|
+
tickArrayUpper,
|
|
239
|
+
tokenAccount0,
|
|
240
|
+
tokenAccount1,
|
|
241
|
+
tokenVault0,
|
|
242
|
+
tokenVault1,
|
|
243
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
244
|
+
tokenProgram2022: addresses_1.TOKEN_2022,
|
|
245
|
+
vault0Mint,
|
|
246
|
+
vault1Mint,
|
|
247
|
+
})
|
|
248
|
+
.instruction()
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
*
|
|
254
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
255
|
+
* @param payer The public key of the payer for transaction fees.
|
|
256
|
+
* @param params Parameters required
|
|
257
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
258
|
+
*/
|
|
259
|
+
raydiumIncreaseLiquidityAutomation(_a) {
|
|
260
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
261
|
+
const poolState = fetch.positionInfo.poolId;
|
|
262
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
263
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
264
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
265
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
266
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
267
|
+
return yield this.iyfExtension.raydiumIncreaseLiquidityAutomation({
|
|
268
|
+
connection,
|
|
269
|
+
userWallet: params.userWallet,
|
|
270
|
+
nftMint,
|
|
271
|
+
poolState,
|
|
272
|
+
tokenVault0,
|
|
273
|
+
tokenVault1,
|
|
274
|
+
vault0Mint,
|
|
275
|
+
vault1Mint,
|
|
276
|
+
tickSpacing: fetch.poolStateInfo.tickSpacing,
|
|
277
|
+
tickLowerIndex: fetch.positionInfo.tickLowerIndex,
|
|
278
|
+
tickUpperIndex: fetch.positionInfo.tickLowerIndex,
|
|
279
|
+
liquidity: params.liquidity,
|
|
280
|
+
amount0Max: params.amount0Max,
|
|
281
|
+
amount1Max: params.amount1Max,
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
*
|
|
287
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
288
|
+
* @param payer The public key of the payer for transaction fees.
|
|
289
|
+
* @param params Parameters required
|
|
290
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
291
|
+
*/
|
|
292
|
+
raydiumDecreaseLiquidity(_a) {
|
|
293
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
294
|
+
const poolState = fetch.positionInfo.poolId;
|
|
295
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
296
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(nftMint);
|
|
297
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
298
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
299
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
300
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
301
|
+
return yield this.iyfExtension.raydiumDecreaseLiquidity({
|
|
302
|
+
connection,
|
|
303
|
+
liquidity: params.liquidity,
|
|
304
|
+
amount0Min: params.amount0Min,
|
|
305
|
+
amount1Min: params.amount1Min,
|
|
306
|
+
userWallet: params.userWallet,
|
|
307
|
+
nftMint,
|
|
308
|
+
poolState,
|
|
309
|
+
personalPosition,
|
|
310
|
+
tokenVault0,
|
|
311
|
+
tokenVault1,
|
|
312
|
+
vault0Mint,
|
|
313
|
+
vault1Mint,
|
|
314
|
+
tickSpacing: fetch.poolStateInfo.tickSpacing,
|
|
315
|
+
tickLowerIndex: fetch.positionInfo.tickLowerIndex,
|
|
316
|
+
tickUpperIndex: fetch.positionInfo.tickUpperIndex,
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
*
|
|
322
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
323
|
+
* @param payer The public key of the payer for transaction fees.
|
|
324
|
+
* @param params Parameters required
|
|
325
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
326
|
+
*/
|
|
327
|
+
raydiumDecreaseLiquidityAutomation(_a) {
|
|
328
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
329
|
+
const poolState = fetch.positionInfo.poolId;
|
|
330
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
331
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(nftMint);
|
|
332
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
333
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
334
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
335
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
336
|
+
return yield this.iyfExtension.raydiumDecreaseLiquidityAutomation({
|
|
337
|
+
connection,
|
|
338
|
+
liquidity: params.liquidity,
|
|
339
|
+
amount0Min: params.amount0Min,
|
|
340
|
+
amount1Min: params.amount1Min,
|
|
341
|
+
userWallet: params.userWallet,
|
|
342
|
+
nftMint,
|
|
343
|
+
poolState,
|
|
344
|
+
personalPosition,
|
|
345
|
+
tokenVault0,
|
|
346
|
+
tokenVault1,
|
|
347
|
+
vault0Mint,
|
|
348
|
+
vault1Mint,
|
|
349
|
+
tickSpacing: fetch.poolStateInfo.tickSpacing,
|
|
350
|
+
tickLowerIndex: fetch.positionInfo.tickLowerIndex,
|
|
351
|
+
tickUpperIndex: fetch.positionInfo.tickUpperIndex,
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
*
|
|
357
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
358
|
+
* @param payer The public key of the payer for transaction fees.
|
|
359
|
+
* @param params Parameters required
|
|
360
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
361
|
+
*/
|
|
362
|
+
raydiumSweepDust(_a) {
|
|
363
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
364
|
+
const userWallet = params.userWallet;
|
|
365
|
+
const poolState = fetch.positionInfo.poolId;
|
|
366
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
367
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
368
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
369
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
370
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
371
|
+
const ammConfig = fetch.poolStateInfo.ammConfig;
|
|
372
|
+
const observationKey = fetch.poolStateInfo.observationKey;
|
|
373
|
+
const tickCurrent = fetch.poolStateInfo.tickCurrent;
|
|
374
|
+
const tickSpacing = fetch.poolStateInfo.tickSpacing;
|
|
375
|
+
const tickLowerIndex = fetch.positionInfo.tickLowerIndex;
|
|
376
|
+
const tickUpperIndex = fetch.positionInfo.tickUpperIndex;
|
|
377
|
+
const slippage = params.slippage;
|
|
378
|
+
return yield this.iyfExtension.raydiumSweepDust({
|
|
379
|
+
connection,
|
|
380
|
+
userWallet,
|
|
381
|
+
nftMint,
|
|
382
|
+
poolState,
|
|
383
|
+
tokenVault0,
|
|
384
|
+
tokenVault1,
|
|
385
|
+
vault0Mint,
|
|
386
|
+
vault1Mint,
|
|
387
|
+
ammConfig,
|
|
388
|
+
observationKey,
|
|
389
|
+
tickCurrent,
|
|
390
|
+
tickSpacing,
|
|
391
|
+
tickLowerIndex,
|
|
392
|
+
tickUpperIndex,
|
|
393
|
+
slippage,
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
exports.RaydiumIxGenerator = RaydiumIxGenerator;
|
|
@@ -1,6 +1,49 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Raydium PDA Generator
|
|
4
|
+
*
|
|
5
|
+
* This class provides methods to generate Program Derived Addresses (PDAs) for various
|
|
6
|
+
* Raydium protocol components. It handles the derivation of addresses for positions,
|
|
7
|
+
* tick arrays, and other protocol-specific accounts using the Raydium program ID.
|
|
3
8
|
*/
|
|
4
9
|
export declare class RaydiumPdaGenerator {
|
|
10
|
+
/**
|
|
11
|
+
* Generates a PDA for a Raydium protocol position account.
|
|
12
|
+
* This account stores information about a liquidity position in a Raydium pool.
|
|
13
|
+
*
|
|
14
|
+
* @param poolState - The public key of the pool state account
|
|
15
|
+
* @param tickLowerIndex - The lower tick index of the position
|
|
16
|
+
* @param tickUpperIndex - The upper tick index of the position
|
|
17
|
+
* @returns The public key of the position PDA
|
|
18
|
+
*/
|
|
19
|
+
generateRaydiumProtocolPosition(poolState: web3.PublicKey, tickLowerIndex: number, tickUpperIndex: number): web3.PublicKey;
|
|
20
|
+
/**
|
|
21
|
+
* Generates a PDA for a personal position account in Raydium.
|
|
22
|
+
* This account is associated with a specific NFT mint and represents a user's
|
|
23
|
+
* individual position in a Raydium pool.
|
|
24
|
+
*
|
|
25
|
+
* @param nftMint - The public key of the NFT mint associated with the position
|
|
26
|
+
* @returns The public key of the personal position PDA
|
|
27
|
+
*/
|
|
28
|
+
generateRaydiumPersonalPosition(nftMint: web3.PublicKey): web3.PublicKey;
|
|
29
|
+
/**
|
|
30
|
+
* Generates a PDA for a tick array account in Raydium.
|
|
31
|
+
* Tick arrays store price and liquidity information for specific price ranges
|
|
32
|
+
* in a concentrated liquidity pool.
|
|
33
|
+
*
|
|
34
|
+
* @param poolState - The public key of the pool state account
|
|
35
|
+
* @param startIndex - The starting tick index for the tick array
|
|
36
|
+
* @returns The public key of the tick array PDA
|
|
37
|
+
*/
|
|
38
|
+
generateRaydiumTickArrayPda(poolState: web3.PublicKey, startIndex: number): web3.PublicKey;
|
|
39
|
+
/**
|
|
40
|
+
* Generates a PDA for a tick array bitmap extension account in Raydium.
|
|
41
|
+
* This account extends the tick array bitmap to support larger price ranges
|
|
42
|
+
* in concentrated liquidity pools.
|
|
43
|
+
*
|
|
44
|
+
* @param poolState - The public key of the pool state account
|
|
45
|
+
* @returns The public key of the tick array bitmap extension PDA
|
|
46
|
+
*/
|
|
47
|
+
generateRaydiumTickArrayBitmapExtension(poolState: web3.PublicKey): web3.PublicKey;
|
|
5
48
|
}
|
|
6
49
|
//# sourceMappingURL=RaydiumPdaGenerator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RaydiumPdaGenerator.d.ts","sourceRoot":"","sources":["../../../src/pdaGenerator/RaydiumPdaGenerator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RaydiumPdaGenerator.d.ts","sourceRoot":"","sources":["../../../src/pdaGenerator/RaydiumPdaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAIxC;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAE9B;;;;;;;;OAQG;IACH,+BAA+B,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC,SAAS;IAa1H;;;;;;;OAOG;IACH,+BAA+B,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS;IAWvD;;;;;;;;OAQG;IACH,2BAA2B,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM;IAYzE;;;;;;;OAOG;IACH,uCAAuC,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS;CAUlE"}
|
|
@@ -1,9 +1,104 @@
|
|
|
1
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.RaydiumPdaGenerator = void 0;
|
|
27
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
28
|
+
const addresses_1 = require("../addresses");
|
|
29
|
+
const bn_js_1 = require("bn.js");
|
|
4
30
|
/**
|
|
5
|
-
*
|
|
31
|
+
* Raydium PDA Generator
|
|
32
|
+
*
|
|
33
|
+
* This class provides methods to generate Program Derived Addresses (PDAs) for various
|
|
34
|
+
* Raydium protocol components. It handles the derivation of addresses for positions,
|
|
35
|
+
* tick arrays, and other protocol-specific accounts using the Raydium program ID.
|
|
6
36
|
*/
|
|
7
37
|
class RaydiumPdaGenerator {
|
|
38
|
+
/**
|
|
39
|
+
* Generates a PDA for a Raydium protocol position account.
|
|
40
|
+
* This account stores information about a liquidity position in a Raydium pool.
|
|
41
|
+
*
|
|
42
|
+
* @param poolState - The public key of the pool state account
|
|
43
|
+
* @param tickLowerIndex - The lower tick index of the position
|
|
44
|
+
* @param tickUpperIndex - The upper tick index of the position
|
|
45
|
+
* @returns The public key of the position PDA
|
|
46
|
+
*/
|
|
47
|
+
generateRaydiumProtocolPosition(poolState, tickLowerIndex, tickUpperIndex) {
|
|
48
|
+
const [pda] = web3.PublicKey.findProgramAddressSync([
|
|
49
|
+
Buffer.from("position"),
|
|
50
|
+
poolState.toBuffer(),
|
|
51
|
+
new bn_js_1.BN(tickLowerIndex).toBuffer('be', 4),
|
|
52
|
+
new bn_js_1.BN(tickUpperIndex).toBuffer('be', 4),
|
|
53
|
+
], addresses_1.RAYDIUM_PROGRAM);
|
|
54
|
+
return pda;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generates a PDA for a personal position account in Raydium.
|
|
58
|
+
* This account is associated with a specific NFT mint and represents a user's
|
|
59
|
+
* individual position in a Raydium pool.
|
|
60
|
+
*
|
|
61
|
+
* @param nftMint - The public key of the NFT mint associated with the position
|
|
62
|
+
* @returns The public key of the personal position PDA
|
|
63
|
+
*/
|
|
64
|
+
generateRaydiumPersonalPosition(nftMint) {
|
|
65
|
+
const [pda] = web3.PublicKey.findProgramAddressSync([
|
|
66
|
+
Buffer.from("position"),
|
|
67
|
+
nftMint.toBuffer(),
|
|
68
|
+
], addresses_1.RAYDIUM_PROGRAM);
|
|
69
|
+
return pda;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Generates a PDA for a tick array account in Raydium.
|
|
73
|
+
* Tick arrays store price and liquidity information for specific price ranges
|
|
74
|
+
* in a concentrated liquidity pool.
|
|
75
|
+
*
|
|
76
|
+
* @param poolState - The public key of the pool state account
|
|
77
|
+
* @param startIndex - The starting tick index for the tick array
|
|
78
|
+
* @returns The public key of the tick array PDA
|
|
79
|
+
*/
|
|
80
|
+
generateRaydiumTickArrayPda(poolState, startIndex) {
|
|
81
|
+
const [pda] = web3.PublicKey.findProgramAddressSync([
|
|
82
|
+
Buffer.from("tick_array"),
|
|
83
|
+
poolState.toBuffer(),
|
|
84
|
+
new bn_js_1.BN(startIndex).toBuffer('be', 4),
|
|
85
|
+
], addresses_1.RAYDIUM_PROGRAM);
|
|
86
|
+
return pda;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Generates a PDA for a tick array bitmap extension account in Raydium.
|
|
90
|
+
* This account extends the tick array bitmap to support larger price ranges
|
|
91
|
+
* in concentrated liquidity pools.
|
|
92
|
+
*
|
|
93
|
+
* @param poolState - The public key of the pool state account
|
|
94
|
+
* @returns The public key of the tick array bitmap extension PDA
|
|
95
|
+
*/
|
|
96
|
+
generateRaydiumTickArrayBitmapExtension(poolState) {
|
|
97
|
+
const [pda] = web3.PublicKey.findProgramAddressSync([
|
|
98
|
+
Buffer.from("pool_tick_array_bitmap_extension"),
|
|
99
|
+
poolState.toBuffer(),
|
|
100
|
+
], addresses_1.RAYDIUM_PROGRAM);
|
|
101
|
+
return pda;
|
|
102
|
+
}
|
|
8
103
|
}
|
|
9
104
|
exports.RaydiumPdaGenerator = RaydiumPdaGenerator;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -275,9 +275,10 @@ export interface SearchTokenStore {
|
|
|
275
275
|
}
|
|
276
276
|
export type LoadFromPersistenceFn = () => Promise<[SearchIndices | undefined, Token[] | undefined]>;
|
|
277
277
|
export type StoreToPersistenceFn = (tokenIndices: SearchIndices, tokens: Token[]) => Promise<void>;
|
|
278
|
-
export type TxgenParams<T> = {
|
|
278
|
+
export type TxgenParams<T, DeserializedAccounts = undefined> = {
|
|
279
279
|
connection: web3.Connection;
|
|
280
280
|
params: T;
|
|
281
|
+
fetch: DeserializedAccounts;
|
|
281
282
|
};
|
|
282
283
|
export type Register = {
|
|
283
284
|
authority: web3.PublicKey;
|
|
@@ -487,4 +488,37 @@ export type InsertNonceAtOpt = {
|
|
|
487
488
|
export type SignerPlugin = (transaction: web3.VersionedTransaction) => Promise<web3.VersionedTransaction>;
|
|
488
489
|
export type SignerPlugin2 = (transaction: web3.VersionedTransaction[]) => Promise<web3.VersionedTransaction[]>;
|
|
489
490
|
export type SendSignedTx = (signedTx: web3.VersionedTransaction, lastValidBlockHeight: number) => Promise<string>;
|
|
491
|
+
export type RaydiumOpenPosition = {
|
|
492
|
+
userWallet: web3.PublicKey;
|
|
493
|
+
nftMint: web3.PublicKey;
|
|
494
|
+
poolState: web3.PublicKey;
|
|
495
|
+
tickLowerIndex: number;
|
|
496
|
+
tickUpperIndex: number;
|
|
497
|
+
liquidity: BN;
|
|
498
|
+
amount0Max: BN;
|
|
499
|
+
amount1Max: BN;
|
|
500
|
+
};
|
|
501
|
+
export type RaydiumClosePosition = {
|
|
502
|
+
userWallet: web3.PublicKey;
|
|
503
|
+
personalPosition: web3.PublicKey;
|
|
504
|
+
};
|
|
505
|
+
export type RaydiumIncreaseLiquidity = {
|
|
506
|
+
userWallet: web3.PublicKey;
|
|
507
|
+
personalPosition: web3.PublicKey;
|
|
508
|
+
liquidity: BN;
|
|
509
|
+
amount0Max: BN;
|
|
510
|
+
amount1Max: BN;
|
|
511
|
+
};
|
|
512
|
+
export type RaydiumDecreaseLiquidity = {
|
|
513
|
+
userWallet: web3.PublicKey;
|
|
514
|
+
personalPosition: web3.PublicKey;
|
|
515
|
+
liquidity: BN;
|
|
516
|
+
amount0Min: BN;
|
|
517
|
+
amount1Min: BN;
|
|
518
|
+
};
|
|
519
|
+
export type RaydiumSweepDust = {
|
|
520
|
+
userWallet: web3.PublicKey;
|
|
521
|
+
personalPosition: web3.PublicKey;
|
|
522
|
+
slippage: BN;
|
|
523
|
+
};
|
|
490
524
|
//# sourceMappingURL=types.d.ts.map
|