@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 @@
|
|
|
1
|
+
{"version":3,"file":"RaydiumIxGenerator.d.ts","sourceRoot":"","sources":["../../src/ixGenerator/RaydiumIxGenerator.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,558 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.RaydiumIxGenerator = void 0;
|
|
49
|
+
exports.getLiquidityFromAmounts = getLiquidityFromAmounts;
|
|
50
|
+
exports.getAmountsFromLiquidity = getAmountsFromLiquidity;
|
|
51
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
52
|
+
const anchor_1 = require("../anchor");
|
|
53
|
+
const functions_1 = require("../functions");
|
|
54
|
+
const addresses_1 = require("../addresses");
|
|
55
|
+
const raydium_sdk_v2_1 = require("@raydium-io/raydium-sdk-v2");
|
|
56
|
+
const RaydiumSDK_1 = require("../classes/RaydiumSDK");
|
|
57
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
58
|
+
/**
|
|
59
|
+
* Meteora related instructions executed via iyf extension or iyf main
|
|
60
|
+
*/
|
|
61
|
+
class RaydiumIxGenerator {
|
|
62
|
+
constructor(iyfMain, iyfExtension, pda) {
|
|
63
|
+
this.iyfMain = iyfMain;
|
|
64
|
+
this.iyfExtension = iyfExtension;
|
|
65
|
+
this.pda = pda;
|
|
66
|
+
}
|
|
67
|
+
raydiumFetch(_a) {
|
|
68
|
+
return __awaiter(this, arguments, void 0, function* ({ personalPosition, poolState }) {
|
|
69
|
+
if (personalPosition !== undefined) {
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
const f0 = anchor_1.Anchor.instance().raydiumProgram.account.personalPositionState;
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
const f1 = anchor_1.Anchor.instance().raydiumProgram.account.poolState;
|
|
74
|
+
const positionInfo = yield f0.fetch(personalPosition);
|
|
75
|
+
const poolStateInfo = yield f1.fetch(positionInfo.poolId);
|
|
76
|
+
return { positionInfo, poolStateInfo };
|
|
77
|
+
}
|
|
78
|
+
else if (poolState !== undefined) {
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
const f = anchor_1.Anchor.instance().raydiumProgram.account.poolState;
|
|
81
|
+
const poolStateInfo = yield f.fetch(poolState);
|
|
82
|
+
return { poolStateInfo };
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw new Error('RaydiumIxGenerator: Unexpected error: personalPosition or poolState parameter must be present');
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
92
|
+
* @param payer The public key of the payer for transaction fees.
|
|
93
|
+
* @param params Parameters required
|
|
94
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
95
|
+
*/
|
|
96
|
+
raydiumOpenPosition(_a) {
|
|
97
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
98
|
+
const farm = addresses_1.USDC_FARM;
|
|
99
|
+
const payer = params.userWallet;
|
|
100
|
+
const positionNftOwner = (0, functions_1.generateUserPdaLamport)(params.userWallet, farm);
|
|
101
|
+
const positionNftMint = params.nftMint;
|
|
102
|
+
const positionNftAccount = (0, functions_1.generateAta2022)(positionNftOwner, positionNftMint);
|
|
103
|
+
const poolState = params.poolState;
|
|
104
|
+
const protocolPosition = this.pda.raydium.generateRaydiumProtocolPosition(poolState, params.tickLowerIndex, params.tickUpperIndex);
|
|
105
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(positionNftMint);
|
|
106
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
107
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
108
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
109
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
110
|
+
const tokenAccount0 = (0, functions_1.generateAta)(positionNftOwner, vault0Mint);
|
|
111
|
+
const tokenAccount1 = (0, functions_1.generateAta)(positionNftOwner, vault1Mint);
|
|
112
|
+
const tickArrayLowerStartIndex = (0, functions_1.raydiumStartTickIndex)(params.tickLowerIndex, fetch.poolStateInfo.tickSpacing);
|
|
113
|
+
const tickArrayUpperStartIndex = (0, functions_1.raydiumStartTickIndex)(params.tickUpperIndex, fetch.poolStateInfo.tickSpacing);
|
|
114
|
+
const tickArrayLower = this.pda.raydium.generateRaydiumTickArrayPda(poolState, tickArrayLowerStartIndex);
|
|
115
|
+
const tickArrayUpper = this.pda.raydium.generateRaydiumTickArrayPda(poolState, tickArrayUpperStartIndex);
|
|
116
|
+
const { liquidity, amount0Max, amount1Max } = params.getLiquidityFromAmounts ? params.getLiquidityFromAmounts : yield getLiquidityFromAmounts(connection, poolState, params.amountX, params.amountY, params.tickLowerIndex, params.tickUpperIndex, params.slippage, true);
|
|
117
|
+
const raydiumIx = yield anchor_1.Anchor.instance().raydiumProgram.methods
|
|
118
|
+
.openPositionWithToken22Nft(params.tickLowerIndex, params.tickUpperIndex, tickArrayLowerStartIndex, tickArrayUpperStartIndex, liquidity, amount0Max, amount1Max, false, null)
|
|
119
|
+
.accounts({
|
|
120
|
+
payer: positionNftOwner,
|
|
121
|
+
positionNftOwner,
|
|
122
|
+
positionNftMint,
|
|
123
|
+
positionNftAccount,
|
|
124
|
+
poolState,
|
|
125
|
+
protocolPosition,
|
|
126
|
+
tickArrayLower,
|
|
127
|
+
tickArrayUpper,
|
|
128
|
+
personalPosition,
|
|
129
|
+
tokenAccount0,
|
|
130
|
+
tokenAccount1,
|
|
131
|
+
tokenVault0,
|
|
132
|
+
tokenVault1,
|
|
133
|
+
rent: web3.SYSVAR_RENT_PUBKEY,
|
|
134
|
+
systemProgram: web3.SystemProgram.programId,
|
|
135
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
136
|
+
associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
|
|
137
|
+
tokenProgram2022: addresses_1.TOKEN_2022,
|
|
138
|
+
vault0Mint,
|
|
139
|
+
vault1Mint,
|
|
140
|
+
})
|
|
141
|
+
.instruction();
|
|
142
|
+
raydiumIx.keys[0].isSigner = false;
|
|
143
|
+
return yield this.iyfMain.raydiumDynamicCpi(connection, {
|
|
144
|
+
userWallet: params.userWallet,
|
|
145
|
+
raydiumIx,
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
*
|
|
151
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
152
|
+
* @param payer The public key of the payer for transaction fees.
|
|
153
|
+
* @param params Parameters required
|
|
154
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
155
|
+
*/
|
|
156
|
+
raydiumOpenPositionAutomation(_a) {
|
|
157
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params }) {
|
|
158
|
+
const fetch = yield this.raydiumFetch({ poolState: params.poolState });
|
|
159
|
+
const poolState = params.poolState;
|
|
160
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
161
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
162
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
163
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
164
|
+
let liquidity = null;
|
|
165
|
+
let amount0Max = null;
|
|
166
|
+
let amount1Max = null;
|
|
167
|
+
if (params.amountX && params.amountY && params.slippage) {
|
|
168
|
+
const { liquidity: a, amount0Max: b, amount1Max: c } = yield getLiquidityFromAmounts(connection, poolState, params.amountX, params.amountY, params.tickLowerIndex, params.tickUpperIndex, params.slippage, true);
|
|
169
|
+
liquidity = a;
|
|
170
|
+
amount0Max = b;
|
|
171
|
+
amount1Max = c;
|
|
172
|
+
}
|
|
173
|
+
return yield this.iyfExtension.raydiumOpenPositionAutomation({
|
|
174
|
+
connection,
|
|
175
|
+
userWallet: params.userWallet,
|
|
176
|
+
nftMint: params.nftMint,
|
|
177
|
+
poolState,
|
|
178
|
+
tokenVault0,
|
|
179
|
+
tokenVault1,
|
|
180
|
+
vault0Mint,
|
|
181
|
+
vault1Mint,
|
|
182
|
+
tickSpacing: fetch.poolStateInfo.tickSpacing,
|
|
183
|
+
tickLowerIndex: params.tickLowerIndex,
|
|
184
|
+
tickUpperIndex: params.tickUpperIndex,
|
|
185
|
+
liquidity,
|
|
186
|
+
amount0Max,
|
|
187
|
+
amount1Max,
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
*
|
|
193
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
194
|
+
* @param payer The public key of the payer for transaction fees.
|
|
195
|
+
* @param params Parameters required
|
|
196
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
197
|
+
*/
|
|
198
|
+
raydiumClosePosition(_a) {
|
|
199
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
200
|
+
const farm = addresses_1.USDC_FARM;
|
|
201
|
+
const nftOwner = (0, functions_1.generateUserPdaLamport)(params.userWallet, farm);
|
|
202
|
+
const positionNftMint = fetch.positionInfo.nftMint;
|
|
203
|
+
const positionNftAccount = (0, functions_1.generateAta2022)(nftOwner, positionNftMint);
|
|
204
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(positionNftMint);
|
|
205
|
+
const raydiumIx = yield anchor_1.Anchor.instance().raydiumProgram.methods
|
|
206
|
+
.closePosition()
|
|
207
|
+
.accounts({
|
|
208
|
+
nftOwner,
|
|
209
|
+
positionNftMint,
|
|
210
|
+
positionNftAccount,
|
|
211
|
+
personalPosition,
|
|
212
|
+
systemProgram: web3.SystemProgram.programId,
|
|
213
|
+
tokenProgram: addresses_1.TOKEN_2022,
|
|
214
|
+
})
|
|
215
|
+
.instruction();
|
|
216
|
+
raydiumIx.keys[0].isSigner = false;
|
|
217
|
+
return this.iyfMain.raydiumDynamicCpi(connection, {
|
|
218
|
+
userWallet: params.userWallet,
|
|
219
|
+
raydiumIx
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
*
|
|
225
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
226
|
+
* @param payer The public key of the payer for transaction fees.
|
|
227
|
+
* @param params Parameters required
|
|
228
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
229
|
+
*/
|
|
230
|
+
raydiumClosePositionAutomation(_a) {
|
|
231
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params }) {
|
|
232
|
+
return yield this.iyfExtension.raydiumClosePositionAutomation({
|
|
233
|
+
connection,
|
|
234
|
+
userWallet: params.userWallet,
|
|
235
|
+
positionNftMint: params.positionNftMint,
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
*
|
|
241
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
242
|
+
* @param payer The public key of the payer for transaction fees.
|
|
243
|
+
* @param params Parameters required
|
|
244
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
245
|
+
*/
|
|
246
|
+
raydiumIncreaseLiquidity(_a) {
|
|
247
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
248
|
+
const farm = addresses_1.USDC_FARM;
|
|
249
|
+
const nftOwner = (0, functions_1.generateUserPdaLamport)(params.userWallet, farm);
|
|
250
|
+
const poolState = fetch.positionInfo.poolId;
|
|
251
|
+
const protocolPosition = this.pda.raydium.generateRaydiumProtocolPosition(poolState, fetch.positionInfo.tickLowerIndex, fetch.positionInfo.tickUpperIndex);
|
|
252
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
253
|
+
const nftAccount = (0, functions_1.generateAta2022)(nftOwner, nftMint);
|
|
254
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(nftMint);
|
|
255
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
256
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
257
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
258
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
259
|
+
const tokenAccount0 = (0, functions_1.generateAta)(nftOwner, vault0Mint);
|
|
260
|
+
const tickLowerIndex = fetch.positionInfo.tickLowerIndex;
|
|
261
|
+
const tickUpperIndex = fetch.positionInfo.tickUpperIndex;
|
|
262
|
+
const tickArrayLowerStartIndex = (0, functions_1.raydiumStartTickIndex)(tickLowerIndex, fetch.poolStateInfo.tickSpacing);
|
|
263
|
+
const tickArrayUpperStartIndex = (0, functions_1.raydiumStartTickIndex)(tickUpperIndex, fetch.poolStateInfo.tickSpacing);
|
|
264
|
+
const tokenAccount1 = (0, functions_1.generateAta)(nftOwner, vault1Mint);
|
|
265
|
+
const tickArrayLower = this.pda.raydium.generateRaydiumTickArrayPda(poolState, tickArrayLowerStartIndex);
|
|
266
|
+
const tickArrayUpper = this.pda.raydium.generateRaydiumTickArrayPda(poolState, tickArrayUpperStartIndex);
|
|
267
|
+
const { liquidity, amount0Max, amount1Max } = params.getLiquidityFromAmounts ? params.getLiquidityFromAmounts : yield getLiquidityFromAmounts(connection, poolState, params.amountX, params.amountY, tickLowerIndex, tickUpperIndex, params.slippage, true);
|
|
268
|
+
const raydiumIx = yield anchor_1.Anchor.instance().raydiumProgram.methods
|
|
269
|
+
.increaseLiquidityV2(liquidity, amount0Max, amount1Max, false)
|
|
270
|
+
.accounts({
|
|
271
|
+
nftOwner,
|
|
272
|
+
nftAccount,
|
|
273
|
+
poolState,
|
|
274
|
+
protocolPosition,
|
|
275
|
+
personalPosition,
|
|
276
|
+
tickArrayLower,
|
|
277
|
+
tickArrayUpper,
|
|
278
|
+
tokenAccount0,
|
|
279
|
+
tokenAccount1,
|
|
280
|
+
tokenVault0,
|
|
281
|
+
tokenVault1,
|
|
282
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
283
|
+
tokenProgram2022: addresses_1.TOKEN_2022,
|
|
284
|
+
vault0Mint,
|
|
285
|
+
vault1Mint,
|
|
286
|
+
})
|
|
287
|
+
.instruction();
|
|
288
|
+
raydiumIx.keys[0].isSigner = false;
|
|
289
|
+
return this.iyfMain.raydiumDynamicCpi(connection, {
|
|
290
|
+
userWallet: params.userWallet,
|
|
291
|
+
raydiumIx
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
*
|
|
297
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
298
|
+
* @param payer The public key of the payer for transaction fees.
|
|
299
|
+
* @param params Parameters required
|
|
300
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
301
|
+
*/
|
|
302
|
+
raydiumIncreaseLiquidityAutomation(_a) {
|
|
303
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
304
|
+
const poolState = fetch.positionInfo.poolId;
|
|
305
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
306
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
307
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
308
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
309
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
310
|
+
const tickLowerIndex = fetch.positionInfo.tickLowerIndex;
|
|
311
|
+
const tickUpperIndex = fetch.positionInfo.tickUpperIndex;
|
|
312
|
+
let liquidity = null;
|
|
313
|
+
let amount0Max = null;
|
|
314
|
+
let amount1Max = null;
|
|
315
|
+
if (params.amountX && params.amountY && params.slippage) {
|
|
316
|
+
const { liquidity: a, amount0Max: b, amount1Max: c } = params.getLiquidityFromAmounts ? params.getLiquidityFromAmounts : yield getLiquidityFromAmounts(connection, poolState, params.amountX, params.amountY, tickLowerIndex, tickUpperIndex, params.slippage, true);
|
|
317
|
+
liquidity = a;
|
|
318
|
+
amount0Max = b;
|
|
319
|
+
amount1Max = c;
|
|
320
|
+
}
|
|
321
|
+
return yield this.iyfExtension.raydiumIncreaseLiquidityAutomation({
|
|
322
|
+
connection,
|
|
323
|
+
userWallet: params.userWallet,
|
|
324
|
+
nftMint,
|
|
325
|
+
poolState,
|
|
326
|
+
tokenVault0,
|
|
327
|
+
tokenVault1,
|
|
328
|
+
vault0Mint,
|
|
329
|
+
vault1Mint,
|
|
330
|
+
tickSpacing: fetch.poolStateInfo.tickSpacing,
|
|
331
|
+
tickLowerIndex,
|
|
332
|
+
tickUpperIndex,
|
|
333
|
+
liquidity,
|
|
334
|
+
amount0Max,
|
|
335
|
+
amount1Max,
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
*
|
|
341
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
342
|
+
* @param payer The public key of the payer for transaction fees.
|
|
343
|
+
* @param params Parameters required
|
|
344
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
345
|
+
*/
|
|
346
|
+
raydiumDecreaseLiquidity(_a) {
|
|
347
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
348
|
+
const poolState = fetch.positionInfo.poolId;
|
|
349
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
350
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(nftMint);
|
|
351
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
352
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
353
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
354
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
355
|
+
let amount0Min;
|
|
356
|
+
let amount1Min;
|
|
357
|
+
if (params.liquidity.gt(new bn_js_1.default(0))) {
|
|
358
|
+
const { amount0Min: a, amount1Min: b } = yield getAmountsFromLiquidity(connection, fetch.positionInfo.poolId, params.liquidity, fetch.positionInfo.tickLowerIndex, fetch.positionInfo.tickUpperIndex, params.slippage, false);
|
|
359
|
+
amount0Min = a;
|
|
360
|
+
amount1Min = b;
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
amount0Min = new bn_js_1.default(0);
|
|
364
|
+
amount1Min = new bn_js_1.default(0);
|
|
365
|
+
}
|
|
366
|
+
return yield this.iyfExtension.raydiumDecreaseLiquidity({
|
|
367
|
+
connection,
|
|
368
|
+
liquidity: params.liquidity,
|
|
369
|
+
amount0Min: amount0Min,
|
|
370
|
+
amount1Min: amount1Min,
|
|
371
|
+
userWallet: params.userWallet,
|
|
372
|
+
nftMint,
|
|
373
|
+
poolState,
|
|
374
|
+
personalPosition,
|
|
375
|
+
tokenVault0,
|
|
376
|
+
tokenVault1,
|
|
377
|
+
vault0Mint,
|
|
378
|
+
vault1Mint,
|
|
379
|
+
tickSpacing: fetch.poolStateInfo.tickSpacing,
|
|
380
|
+
tickLowerIndex: fetch.positionInfo.tickLowerIndex,
|
|
381
|
+
tickUpperIndex: fetch.positionInfo.tickUpperIndex,
|
|
382
|
+
rewardInfos: fetch.poolStateInfo.rewardInfos,
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
*
|
|
388
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
389
|
+
* @param payer The public key of the payer for transaction fees.
|
|
390
|
+
* @param params Parameters required
|
|
391
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
392
|
+
*/
|
|
393
|
+
raydiumDecreaseLiquidityAutomation(_a) {
|
|
394
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
395
|
+
var _b, _c, _d;
|
|
396
|
+
const poolState = fetch.positionInfo.poolId;
|
|
397
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
398
|
+
const personalPosition = this.pda.raydium.generateRaydiumPersonalPosition(nftMint);
|
|
399
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
400
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
401
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
402
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
403
|
+
let amount0Min = null;
|
|
404
|
+
let amount1Min = null;
|
|
405
|
+
if (params.liquidity && params.liquidity.gt(new bn_js_1.default(0))) {
|
|
406
|
+
const { amount0Min: a, amount1Min: b } = yield getAmountsFromLiquidity(connection, fetch.positionInfo.poolId, params.liquidity, fetch.positionInfo.tickLowerIndex, fetch.positionInfo.tickUpperIndex, (_b = params.slippage) !== null && _b !== void 0 ? _b : 0.01, false);
|
|
407
|
+
amount0Min = a;
|
|
408
|
+
amount1Min = b;
|
|
409
|
+
}
|
|
410
|
+
if (params.liquidity && params.liquidity.eq(new bn_js_1.default(0))) {
|
|
411
|
+
amount0Min = new bn_js_1.default(0);
|
|
412
|
+
amount1Min = new bn_js_1.default(0);
|
|
413
|
+
}
|
|
414
|
+
return yield this.iyfExtension.raydiumDecreaseLiquidityAutomation({
|
|
415
|
+
connection,
|
|
416
|
+
liquidity: (_c = params.liquidity) !== null && _c !== void 0 ? _c : null,
|
|
417
|
+
amount0Min,
|
|
418
|
+
amount1Min,
|
|
419
|
+
userWallet: params.userWallet,
|
|
420
|
+
nftMint,
|
|
421
|
+
poolState,
|
|
422
|
+
personalPosition,
|
|
423
|
+
tokenVault0,
|
|
424
|
+
tokenVault1,
|
|
425
|
+
vault0Mint,
|
|
426
|
+
vault1Mint,
|
|
427
|
+
tickSpacing: fetch.poolStateInfo.tickSpacing,
|
|
428
|
+
tickLowerIndex: fetch.positionInfo.tickLowerIndex,
|
|
429
|
+
tickUpperIndex: fetch.positionInfo.tickUpperIndex,
|
|
430
|
+
rewardInfos: fetch.poolStateInfo.rewardInfos,
|
|
431
|
+
slippage: (_d = params.slippage) !== null && _d !== void 0 ? _d : null,
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
*
|
|
437
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
438
|
+
* @param payer The public key of the payer for transaction fees.
|
|
439
|
+
* @param params Parameters required
|
|
440
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
441
|
+
*/
|
|
442
|
+
raydiumSweepDust(_a) {
|
|
443
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, fetch }) {
|
|
444
|
+
const userWallet = params.userWallet;
|
|
445
|
+
const poolState = fetch.positionInfo.poolId;
|
|
446
|
+
const nftMint = fetch.positionInfo.nftMint;
|
|
447
|
+
const vault0Mint = fetch.poolStateInfo.tokenMint0;
|
|
448
|
+
const vault1Mint = fetch.poolStateInfo.tokenMint1;
|
|
449
|
+
const tokenVault0 = fetch.poolStateInfo.tokenVault0;
|
|
450
|
+
const tokenVault1 = fetch.poolStateInfo.tokenVault1;
|
|
451
|
+
const ammConfig = fetch.poolStateInfo.ammConfig;
|
|
452
|
+
const observationKey = fetch.poolStateInfo.observationKey;
|
|
453
|
+
const tickCurrent = fetch.poolStateInfo.tickCurrent;
|
|
454
|
+
const tickSpacing = fetch.poolStateInfo.tickSpacing;
|
|
455
|
+
const tickLowerIndex = fetch.positionInfo.tickLowerIndex;
|
|
456
|
+
const tickUpperIndex = fetch.positionInfo.tickUpperIndex;
|
|
457
|
+
return yield this.iyfExtension.raydiumSweepDust({
|
|
458
|
+
connection,
|
|
459
|
+
userWallet,
|
|
460
|
+
nftMint,
|
|
461
|
+
poolState,
|
|
462
|
+
tokenVault0,
|
|
463
|
+
tokenVault1,
|
|
464
|
+
vault0Mint,
|
|
465
|
+
vault1Mint,
|
|
466
|
+
ammConfig,
|
|
467
|
+
observationKey,
|
|
468
|
+
tickCurrent,
|
|
469
|
+
tickSpacing,
|
|
470
|
+
tickLowerIndex,
|
|
471
|
+
tickUpperIndex,
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
exports.RaydiumIxGenerator = RaydiumIxGenerator;
|
|
477
|
+
function getLiquidityFromAmounts(connection, poolId, amountA, amountB, tickLower, tickUpper, slippage, add) {
|
|
478
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
479
|
+
// Load the Raydium SDK
|
|
480
|
+
yield RaydiumSDK_1.RaydiumSDK.load(connection);
|
|
481
|
+
// // Get the Raydium SDK instance
|
|
482
|
+
// const sdk = RaydiumSDK.instance().sdk;
|
|
483
|
+
// Benchmark the getPoolInfoFromRpc function
|
|
484
|
+
(0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getPoolInfoFromRpc` });
|
|
485
|
+
// Get the pool info
|
|
486
|
+
// let { poolInfo } = await sdk.clmm.getPoolInfoFromRpc(poolId.toString());
|
|
487
|
+
let poolInfo = yield RaydiumSDK_1.RaydiumSDK.instance().getPoolInfoFromRpc(poolId);
|
|
488
|
+
// Fallback in case poolInfo is undefined
|
|
489
|
+
// poolInfo = poolInfo ? poolInfo : (await sdk.clmm.getPoolInfoFromRpc(poolId.toString()))[poolInfo];
|
|
490
|
+
// Benchmark the getPoolInfoFromRpc function (end)
|
|
491
|
+
(0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getPoolInfoFromRpc`, end: true });
|
|
492
|
+
// Benchmark the getEpochInfo function
|
|
493
|
+
(0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getEpochInfo` });
|
|
494
|
+
// Get the epoch info
|
|
495
|
+
let epochInfo = yield connection.getEpochInfo();
|
|
496
|
+
// Benchmark the getEpochInfo function (end)
|
|
497
|
+
(0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getEpochInfo`, end: true });
|
|
498
|
+
// Benchmark the getLiquidityFromAmounts function
|
|
499
|
+
(0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getLiquidityFromAmounts` });
|
|
500
|
+
const { liquidity, amountSlippageA, amountSlippageB, amountA: _amountA, amountB: _amountB, } = (0, raydium_sdk_v2_1.getLiquidityFromAmounts)({
|
|
501
|
+
poolInfo,
|
|
502
|
+
tickLower,
|
|
503
|
+
tickUpper,
|
|
504
|
+
amountA,
|
|
505
|
+
amountB,
|
|
506
|
+
slippage,
|
|
507
|
+
add: true,
|
|
508
|
+
epochInfo,
|
|
509
|
+
amountHasFee: false,
|
|
510
|
+
});
|
|
511
|
+
// Benchmark the getLiquidityFromAmounts function (end)
|
|
512
|
+
(0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getLiquidityFromAmounts`, end: true });
|
|
513
|
+
return {
|
|
514
|
+
liquidity,
|
|
515
|
+
amount0Max: amountSlippageA.amount,
|
|
516
|
+
amount1Max: amountSlippageB.amount,
|
|
517
|
+
};
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
function getAmountsFromLiquidity(connection, poolId, liquidity, tickLower, tickUpper, slippage, add) {
|
|
521
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
522
|
+
// Load the Raydium SDK
|
|
523
|
+
yield RaydiumSDK_1.RaydiumSDK.load(connection);
|
|
524
|
+
// // Get the Raydium SDK instance
|
|
525
|
+
// const sdk = RaydiumSDK.sdk();
|
|
526
|
+
// Benchmark the getPoolInfoFromRpc function
|
|
527
|
+
(0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getPoolInfoFromRpc` });
|
|
528
|
+
// Get the pool info
|
|
529
|
+
// let { poolInfo } = await sdk.clmm.getPoolInfoFromRpc(poolId.toString());
|
|
530
|
+
let poolInfo = yield RaydiumSDK_1.RaydiumSDK.instance().getPoolInfoFromRpc(poolId);
|
|
531
|
+
// Benchmark the getPoolInfoFromRpc function (end)
|
|
532
|
+
(0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getPoolInfoFromRpc`, end: true });
|
|
533
|
+
// Benchmark the getEpochInfo function
|
|
534
|
+
(0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getEpochInfo` });
|
|
535
|
+
// Get the epoch info
|
|
536
|
+
let epochInfo = yield connection.getEpochInfo();
|
|
537
|
+
// Benchmark the getEpochInfo function (end)
|
|
538
|
+
(0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getEpochInfo`, end: true });
|
|
539
|
+
// Benchmark the getAmountsFromLiquidity function
|
|
540
|
+
(0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getAmountsFromLiquidity` });
|
|
541
|
+
// Get the amounts from liquidity
|
|
542
|
+
const { amountSlippageA, amountSlippageB, amountA, amountB, } = yield raydium_sdk_v2_1.PoolUtils.getAmountsFromLiquidity({
|
|
543
|
+
epochInfo,
|
|
544
|
+
poolInfo,
|
|
545
|
+
tickLower,
|
|
546
|
+
tickUpper,
|
|
547
|
+
liquidity,
|
|
548
|
+
slippage,
|
|
549
|
+
add,
|
|
550
|
+
});
|
|
551
|
+
// Benchmark the getAmountsFromLiquidity function (end)
|
|
552
|
+
(0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getAmountsFromLiquidity`, end: true });
|
|
553
|
+
return {
|
|
554
|
+
amount0Min: amountSlippageA.amount,
|
|
555
|
+
amount1Min: amountSlippageB.amount,
|
|
556
|
+
};
|
|
557
|
+
});
|
|
558
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
2
|
+
type CreateAssociatedTokenAccountInstruction = {
|
|
3
|
+
payer: web3.PublicKey;
|
|
4
|
+
owner: web3.PublicKey;
|
|
5
|
+
mint: web3.PublicKey;
|
|
6
|
+
tokenProgram?: web3.PublicKey;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Iyf Main IX Generator
|
|
10
|
+
*/
|
|
11
|
+
export declare class UtilIxGenerator {
|
|
12
|
+
/**
|
|
13
|
+
* Create associated token account instruction
|
|
14
|
+
*
|
|
15
|
+
* @returns Create ATA instruction
|
|
16
|
+
*/
|
|
17
|
+
createAssociatedTokenAccountInstruction({ payer, owner, mint, tokenProgram }: CreateAssociatedTokenAccountInstruction): web3.TransactionInstruction;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=UtilIxGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UtilIxGenerator.d.ts","sourceRoot":"","sources":["../../src/ixGenerator/UtilIxGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAKxC,KAAK,uCAAuC,GAAG;IAC7C,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;IACtB,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;CAC/B,CAAA;AAED;;GAEG;AACH,qBAAa,eAAe;IAE1B;;;;OAIG;IACH,uCAAuC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,uCAAuC;CAkBtH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UtilIxGenerator = void 0;
|
|
4
|
+
const addresses_1 = require("../addresses");
|
|
5
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
6
|
+
const functions_1 = require("../functions");
|
|
7
|
+
/**
|
|
8
|
+
* Iyf Main IX Generator
|
|
9
|
+
*/
|
|
10
|
+
class UtilIxGenerator {
|
|
11
|
+
/**
|
|
12
|
+
* Create associated token account instruction
|
|
13
|
+
*
|
|
14
|
+
* @returns Create ATA instruction
|
|
15
|
+
*/
|
|
16
|
+
createAssociatedTokenAccountInstruction({ payer, owner, mint, tokenProgram }) {
|
|
17
|
+
// Designed to allow token2022
|
|
18
|
+
if (tokenProgram === undefined) {
|
|
19
|
+
tokenProgram = addresses_1.TOKEN_PROGRAM_ID;
|
|
20
|
+
}
|
|
21
|
+
const associatedToken = (0, functions_1.generateAta)(owner, mint, tokenProgram);
|
|
22
|
+
return (0, spl_token_1.createAssociatedTokenAccountInstruction)(payer, associatedToken, owner, mint, tokenProgram, addresses_1.ASSOCIATED_TOKEN_PROGRAM);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.UtilIxGenerator = UtilIxGenerator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/meteora/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./liquidityStrategy"), exports);
|