@hawksightco/hawk-sdk 1.2.74 → 1.2.76
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/classes/Transactions.d.ts +2 -1
- package/dist/src/classes/Transactions.d.ts.map +1 -1
- package/dist/src/classes/Transactions.js +167 -0
- package/dist/src/classes/TxGeneratorAutomations.d.ts +12 -1
- package/dist/src/classes/TxGeneratorAutomations.d.ts.map +1 -1
- package/dist/src/classes/TxGeneratorAutomations.js +37 -0
- package/dist/src/idl/iyf-extension-idl.d.ts +170 -0
- package/dist/src/idl/iyf-extension-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-extension-idl.js +170 -0
- package/dist/src/meteora.d.ts +2 -2
- package/dist/src/meteora.d.ts.map +1 -1
- package/dist/src/meteora.js +12 -8
- package/dist/src/types.d.ts +9 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as web3 from "@solana/web3.js";
|
|
2
|
-
import { MeteoraClaim, MeteoraClaimAll, MeteoraClose, MeteoraCompound, MeteoraCreatePositionAndDeposit, MeteoraCreatePositionAndDepositPda, MeteoraDeposit, MeteoraInitializeBinArrays, MeteoraRebalance, MeteoraWithdraw, Register, TxgenParams, InitializeStorageTokenAccount, MeteoraLimitCloseAutomation, OrcaOpenPosition, OrcaClosePosition, OrcaDeposit, OrcaWithdraw, OrcaSweepDust, OrcaClaimRewards, TransactionMetadataResponse, MeteoraRebalance2, ClaimTokenFromSTA, ClaimTokensFromSTA, RaydiumClosePosition, OpenAutomationIx, RaydiumWithdrawAndClosePosition } from "../types";
|
|
2
|
+
import { MeteoraClaim, MeteoraClaimAll, MeteoraClose, MeteoraCompound, MeteoraCreatePositionAndDeposit, MeteoraCreatePositionAndDepositPda, MeteoraDeposit, MeteoraInitializeBinArrays, MeteoraRebalance, MeteoraWithdraw, Register, TxgenParams, InitializeStorageTokenAccount, MeteoraLimitCloseAutomation, MeteoraLimitCloseAutomation2, OrcaOpenPosition, OrcaClosePosition, OrcaDeposit, OrcaWithdraw, OrcaSweepDust, OrcaClaimRewards, TransactionMetadataResponse, MeteoraRebalance2, ClaimTokenFromSTA, ClaimTokensFromSTA, RaydiumClosePosition, OpenAutomationIx, RaydiumWithdrawAndClosePosition } from "../types";
|
|
3
3
|
import { RaydiumIncreaseLiquidity, RaydiumOpenPosition, RaydiumDecreaseLiquidity } from "../types";
|
|
4
4
|
import { GeneralUtility } from "./GeneralUtility";
|
|
5
5
|
import { MultiTransaction } from "./MultiTransaction";
|
|
@@ -152,6 +152,7 @@ export declare class Transactions {
|
|
|
152
152
|
openAutomationIx({ connection, params, }: TxgenParams<OpenAutomationIx>): Promise<TransactionMetadataResponse>;
|
|
153
153
|
closeAutomationIx({ connection, params }: TxgenParams<MeteoraClose>): Promise<TransactionMetadataResponse>;
|
|
154
154
|
limitCloseAutomationIx({ connection, params, }: TxgenParams<MeteoraLimitCloseAutomation>): Promise<TransactionMetadataResponse>;
|
|
155
|
+
limitCloseAutomationIx2({ connection, params, }: TxgenParams<MeteoraLimitCloseAutomation2>): Promise<TransactionMetadataResponse>;
|
|
155
156
|
private removeLiquidityByRangeInfo;
|
|
156
157
|
/**
|
|
157
158
|
* Creates orca instruction that opens new position
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/classes/Transactions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAoBxC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,+BAA+B,EAC/B,kCAAkC,EAClC,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,eAAe,EACf,QAAQ,EAGR,WAAW,EACX,6BAA6B,EAC7B,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EA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;;OAOG;IACG,0BAA0B,CAAC,EAC/B,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,0BAA0B,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAwBjF;;;;;;;OAOG;IACG,cAAc,CAAC,EACnB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgDrE;;;;;;;OAOG;IACG,eAAe,CAAC,EACpB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgEtE;;;;;;;OAOG;IACG,kBAAkB,CAAC,EACvB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/classes/Transactions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAoBxC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,+BAA+B,EAC/B,kCAAkC,EAClC,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,eAAe,EACf,QAAQ,EAGR,WAAW,EACX,6BAA6B,EAC7B,2BAA2B,EAC3B,4BAA4B,EAC5B,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EAEpB,gBAAgB,EAChB,+BAA+B,EAChC,MAAM,UAAU,CAAC;AA6BlB,OAAO,EAEL,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAKlB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBA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P,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAmOnE;;;;;;;OAOG;IACG,gBAAgB,CAAC,EACrB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA8IvE;;;;;;OAMG;IACG,mBAAmB,CAAC,EACxB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAsH1E;;;;;;;OAOG;IACG,+BAA+B,CAAC,EACpC,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,+BAA+B,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA8GtF;;;;;;OAMG;IACG,oBAAoB,CAAC,EACzB,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAuB3E;;;;;;OAMG;IACG,wBAAwB,CAAC,EAC7B,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA2F/E;;;;;;OAMG;IACG,wBAAwB,CAAC,EAC7B,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAmFhF;AAED,eAAO,MAAM,KAAK,cAA6B,CAAC"}
|
|
@@ -425,6 +425,7 @@ class Transactions {
|
|
|
425
425
|
binIds: binIdsToRemove,
|
|
426
426
|
bps: amountBps,
|
|
427
427
|
shouldClaimAndClose: params.shouldClaimAndClose,
|
|
428
|
+
pdaTokenType: params.pdaTokenType,
|
|
428
429
|
}, hsToMeteora_1.meteoraToHawksight);
|
|
429
430
|
//if useAta is false, then we want to use STA
|
|
430
431
|
if (params.useAta !== undefined && !params.useAta) {
|
|
@@ -1074,6 +1075,172 @@ class Transactions {
|
|
|
1074
1075
|
});
|
|
1075
1076
|
});
|
|
1076
1077
|
}
|
|
1078
|
+
limitCloseAutomationIx2(_a) {
|
|
1079
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, }) {
|
|
1080
|
+
const program = yield meteora_1.MeteoraDLMM.program(connection);
|
|
1081
|
+
const position = yield program.account.positionV2.fetch(params.position);
|
|
1082
|
+
const dlmmPool = yield meteora_1.MeteoraDLMM.create(connection, position.lbPair);
|
|
1083
|
+
const userPda = (0, functions_1.generateUserPda)(params.userWallet);
|
|
1084
|
+
// Step 1: Claim all fees/rewards, remove all liquidity and close current position
|
|
1085
|
+
// const { userPositions } = await dlmmPool.getPositionsByUserAndLbPair(
|
|
1086
|
+
// userPda
|
|
1087
|
+
// );
|
|
1088
|
+
// const binIdsToRemove = userPositions[0].positionData.positionBinData.map(
|
|
1089
|
+
// (bin) => bin.binId
|
|
1090
|
+
// );
|
|
1091
|
+
const binIdsToRemove = [];
|
|
1092
|
+
for (let i = position.lowerBinId; i <= position.upperBinId; i++) {
|
|
1093
|
+
binIdsToRemove.push(i);
|
|
1094
|
+
}
|
|
1095
|
+
// Claim fees and/or rewards, remove liquidity, and possibly close position from Meteora API (if set)
|
|
1096
|
+
const txn = yield dlmmPool.dlmm.removeLiquidity({
|
|
1097
|
+
user: userPda,
|
|
1098
|
+
position: params.position,
|
|
1099
|
+
binIds: binIdsToRemove,
|
|
1100
|
+
bps: new bn_js_1.default(10000),
|
|
1101
|
+
shouldClaimAndClose: true,
|
|
1102
|
+
});
|
|
1103
|
+
// Filter out non-meteora instructions
|
|
1104
|
+
const ixs = (0, functions_1.getIxs)(txn).filter((ix) => ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM));
|
|
1105
|
+
const farm = addresses_1.USDC_FARM;
|
|
1106
|
+
const authority = params.userWallet;
|
|
1107
|
+
const iyfProgram = addresses_1.IYF_MAIN;
|
|
1108
|
+
const hawksightAuthority = addresses_1.HS_AUTHORITY;
|
|
1109
|
+
const { params: _params, data } = this.removeLiquidityByRangeInfo(ixs);
|
|
1110
|
+
const { position: _position, lbPair, binArrayBitmapExtension, reserveX, reserveY, tokenXMint, tokenYMint, tokenXProgram, tokenYProgram, binArrayLower, binArrayUpper, eventAuthority, program: meteoraDlmmProgram, } = _params;
|
|
1111
|
+
let userTokenX;
|
|
1112
|
+
let userTokenY;
|
|
1113
|
+
if (params.pdaTokenType === types_1.TokenType.STA) {
|
|
1114
|
+
userTokenX = (0, functions_1.generateUserPdaStorageAccount)(userPda, tokenXMint.pubkey);
|
|
1115
|
+
userTokenY = (0, functions_1.generateUserPdaStorageAccount)(userPda, tokenYMint.pubkey);
|
|
1116
|
+
}
|
|
1117
|
+
else if (params.pdaTokenType === types_1.TokenType.LTA) {
|
|
1118
|
+
userTokenX = (0, functions_1.generateLimitToken)(userPda, tokenXMint.pubkey);
|
|
1119
|
+
userTokenY = (0, functions_1.generateLimitToken)(userPda, tokenYMint.pubkey);
|
|
1120
|
+
}
|
|
1121
|
+
else {
|
|
1122
|
+
userTokenX = (0, functions_1.generateAta)(userPda, tokenXMint.pubkey);
|
|
1123
|
+
userTokenY = (0, functions_1.generateAta)(userPda, tokenYMint.pubkey);
|
|
1124
|
+
}
|
|
1125
|
+
let ix;
|
|
1126
|
+
if (params.isLimitOrder) {
|
|
1127
|
+
const limitTokenX = (0, functions_1.generateLimitToken)(userPda, tokenXMint.pubkey);
|
|
1128
|
+
const limitTokenY = (0, functions_1.generateLimitToken)(userPda, tokenYMint.pubkey);
|
|
1129
|
+
const authorityTokenX = (0, functions_1.generateAta)(hawksightAuthority, tokenXMint.pubkey);
|
|
1130
|
+
const authorityTokenY = (0, functions_1.generateAta)(hawksightAuthority, tokenYMint.pubkey);
|
|
1131
|
+
// @ts-ignore
|
|
1132
|
+
const limitCloseAutomationIx = yield anchor_1.Anchor.instance()
|
|
1133
|
+
.iyfExtension.methods.limitOrderClose(data, params.minBinId, params.maxBinId)
|
|
1134
|
+
.accounts({
|
|
1135
|
+
userPda,
|
|
1136
|
+
hawksightAuthority,
|
|
1137
|
+
authority,
|
|
1138
|
+
position: _position.pubkey,
|
|
1139
|
+
lbPair: lbPair.pubkey,
|
|
1140
|
+
binArrayBitmapExtension: binArrayBitmapExtension.pubkey,
|
|
1141
|
+
limitTokenX,
|
|
1142
|
+
limitTokenY,
|
|
1143
|
+
authorityTokenX,
|
|
1144
|
+
authorityTokenY,
|
|
1145
|
+
systemProgram: web3.SystemProgram.programId,
|
|
1146
|
+
reserveX: reserveX.pubkey,
|
|
1147
|
+
reserveY: reserveY.pubkey,
|
|
1148
|
+
tokenXMint: tokenXMint.pubkey,
|
|
1149
|
+
tokenYMint: tokenYMint.pubkey,
|
|
1150
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
1151
|
+
rent: web3.SYSVAR_RENT_PUBKEY,
|
|
1152
|
+
binArrayLower: binArrayLower.pubkey,
|
|
1153
|
+
binArrayUpper: binArrayUpper.pubkey,
|
|
1154
|
+
eventAuthority: eventAuthority.pubkey,
|
|
1155
|
+
meteoraDlmmProgram: addresses_1.METEORA_DLMM_PROGRAM,
|
|
1156
|
+
ownerFeeX: (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, tokenXMint.pubkey),
|
|
1157
|
+
ownerFeeY: (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, tokenYMint.pubkey),
|
|
1158
|
+
})
|
|
1159
|
+
.instruction();
|
|
1160
|
+
// Instruction via main hawksight contract
|
|
1161
|
+
ix = yield anchor_1.Anchor.instance()
|
|
1162
|
+
.iyfMain.methods.iyfExtensionExecuteV2(limitCloseAutomationIx.data)
|
|
1163
|
+
.accounts({
|
|
1164
|
+
userPda,
|
|
1165
|
+
authority,
|
|
1166
|
+
iyfExtensionProgram: addresses_1.IYF_EXTENSION,
|
|
1167
|
+
})
|
|
1168
|
+
.remainingAccounts([...limitCloseAutomationIx.keys.slice(2)])
|
|
1169
|
+
.instruction();
|
|
1170
|
+
}
|
|
1171
|
+
else {
|
|
1172
|
+
// @ts-ignore
|
|
1173
|
+
const limitCloseAutomationIx = yield anchor_1.Anchor.instance()
|
|
1174
|
+
.iyfExtension.methods.meteoraDlmmLimitCloseAutomation2(data, params.minBinId, params.maxBinId, params.isHawkRefund)
|
|
1175
|
+
.accounts({
|
|
1176
|
+
farm,
|
|
1177
|
+
userPda,
|
|
1178
|
+
authority,
|
|
1179
|
+
iyfProgram,
|
|
1180
|
+
hawksightAuthority,
|
|
1181
|
+
position: _position.pubkey,
|
|
1182
|
+
lbPair: lbPair.pubkey,
|
|
1183
|
+
binArrayBitmapExtension: binArrayBitmapExtension.pubkey,
|
|
1184
|
+
userTokenX,
|
|
1185
|
+
userTokenY,
|
|
1186
|
+
reserveX: reserveX.pubkey,
|
|
1187
|
+
reserveY: reserveY.pubkey,
|
|
1188
|
+
tokenXMint: tokenXMint.pubkey,
|
|
1189
|
+
tokenYMint: tokenYMint.pubkey,
|
|
1190
|
+
tokenXProgram: tokenXProgram.pubkey,
|
|
1191
|
+
tokenYProgram: tokenYProgram.pubkey,
|
|
1192
|
+
binArrayLower: binArrayLower.pubkey,
|
|
1193
|
+
binArrayUpper: binArrayUpper.pubkey,
|
|
1194
|
+
eventAuthority: eventAuthority.pubkey,
|
|
1195
|
+
meteoraDlmmProgram: meteoraDlmmProgram.pubkey,
|
|
1196
|
+
ownerFeeX: (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, tokenXMint.pubkey),
|
|
1197
|
+
ownerFeeY: (0, functions_1.generateAta)(addresses_1.SITE_FEE_OWNER, tokenYMint.pubkey),
|
|
1198
|
+
})
|
|
1199
|
+
.instruction();
|
|
1200
|
+
// Instruction via main hawksight contract
|
|
1201
|
+
ix = yield anchor_1.Anchor.instance()
|
|
1202
|
+
.iyfMain.methods.iyfExtensionExecute(limitCloseAutomationIx.data)
|
|
1203
|
+
.accounts({
|
|
1204
|
+
farm,
|
|
1205
|
+
userPda,
|
|
1206
|
+
authority,
|
|
1207
|
+
iyfProgram,
|
|
1208
|
+
iyfExtensionProgram: addresses_1.IYF_EXTENSION,
|
|
1209
|
+
})
|
|
1210
|
+
.remainingAccounts([
|
|
1211
|
+
limitCloseAutomationIx.keys[4],
|
|
1212
|
+
limitCloseAutomationIx.keys[5],
|
|
1213
|
+
limitCloseAutomationIx.keys[6],
|
|
1214
|
+
limitCloseAutomationIx.keys[7],
|
|
1215
|
+
limitCloseAutomationIx.keys[8],
|
|
1216
|
+
limitCloseAutomationIx.keys[9],
|
|
1217
|
+
limitCloseAutomationIx.keys[10],
|
|
1218
|
+
limitCloseAutomationIx.keys[11],
|
|
1219
|
+
limitCloseAutomationIx.keys[12],
|
|
1220
|
+
limitCloseAutomationIx.keys[13],
|
|
1221
|
+
limitCloseAutomationIx.keys[14],
|
|
1222
|
+
limitCloseAutomationIx.keys[15],
|
|
1223
|
+
limitCloseAutomationIx.keys[16],
|
|
1224
|
+
limitCloseAutomationIx.keys[17],
|
|
1225
|
+
limitCloseAutomationIx.keys[18],
|
|
1226
|
+
limitCloseAutomationIx.keys[19],
|
|
1227
|
+
limitCloseAutomationIx.keys[20],
|
|
1228
|
+
limitCloseAutomationIx.keys[21],
|
|
1229
|
+
])
|
|
1230
|
+
.instruction();
|
|
1231
|
+
}
|
|
1232
|
+
const mainInstructions = [
|
|
1233
|
+
// Limit Close Automation Instruction (Hawksight CPI)
|
|
1234
|
+
ix,
|
|
1235
|
+
];
|
|
1236
|
+
return (0, functions_1.createTransactionMeta)({
|
|
1237
|
+
payer: params.userWallet,
|
|
1238
|
+
description: "Automation IX: Meteora limit close instruction (Full withdraw and close on to specific bin id)",
|
|
1239
|
+
addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
|
|
1240
|
+
mainInstructions,
|
|
1241
|
+
});
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1077
1244
|
removeLiquidityByRangeInfo(ixs) {
|
|
1078
1245
|
for (const ix of ixs) {
|
|
1079
1246
|
const programIdMatch = ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as web3 from "@solana/web3.js";
|
|
2
2
|
import * as _client from "@hawksightco/swagger-client";
|
|
3
|
-
import { MeteoraClose, MeteoraCompound, MeteoraLimitCloseAutomation, MeteoraRebalance, MeteoraRebalance2, OpenAutomationIx, ResponseWithStatus, TransactionMetadata } from "../types";
|
|
3
|
+
import { MeteoraClose, MeteoraCompound, MeteoraLimitCloseAutomation, MeteoraLimitCloseAutomation2, MeteoraRebalance, MeteoraRebalance2, OpenAutomationIx, ResponseWithStatus, TransactionMetadata } from "../types";
|
|
4
4
|
import { Client } from "./Client";
|
|
5
5
|
import { GeneralUtility } from "./GeneralUtility";
|
|
6
6
|
/**
|
|
@@ -82,6 +82,17 @@ export declare class TxGeneratorAutomations {
|
|
|
82
82
|
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
83
83
|
*/
|
|
84
84
|
meteoraLimitCloseIxs(connection: web3.Connection, payer: string, params: MeteoraLimitCloseAutomation): Promise<ResponseWithStatus<TransactionMetadata>>;
|
|
85
|
+
/**
|
|
86
|
+
* Creates meteora close limit instruction (combination of claim fees/rewards + remove liquidity + close position)
|
|
87
|
+
*
|
|
88
|
+
* NOTE: For hawksight devs only.
|
|
89
|
+
*
|
|
90
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
91
|
+
* @param payer The public key of the payer for transaction fees.
|
|
92
|
+
* @param params Parameters required
|
|
93
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
94
|
+
*/
|
|
95
|
+
meteoraLimitCloseIxs2(connection: web3.Connection, payer: string, params: MeteoraLimitCloseAutomation2): Promise<ResponseWithStatus<TransactionMetadata>>;
|
|
85
96
|
/**
|
|
86
97
|
* Creates meteora close instruction (combination of claim fees/rewards + remove liquidity + close position)
|
|
87
98
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxGeneratorAutomations.d.ts","sourceRoot":"","sources":["../../../src/classes/TxGeneratorAutomations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAmC,2BAA2B,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAoD,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"TxGeneratorAutomations.d.ts","sourceRoot":"","sources":["../../../src/classes/TxGeneratorAutomations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAmC,2BAA2B,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAoD,MAAM,UAAU,CAAC;AACvS,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD;;;;;;GAMG;AACH,qBAAa,sBAAsB;IAkB/B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAjBjC;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IAE/C;;OAEG;IACH,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IAEjC;;;;OAIG;gBAEgB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc;IAMjD;;;;;;;;;OASG;IACG,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IA8B/I;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241,6 +241,43 @@ class TxGeneratorAutomations {
|
|
|
241
241
|
}
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Creates meteora close limit instruction (combination of claim fees/rewards + remove liquidity + close position)
|
|
246
|
+
*
|
|
247
|
+
* NOTE: For hawksight devs only.
|
|
248
|
+
*
|
|
249
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
250
|
+
* @param payer The public key of the payer for transaction fees.
|
|
251
|
+
* @param params Parameters required
|
|
252
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
253
|
+
*/
|
|
254
|
+
meteoraLimitCloseIxs2(connection, payer, params) {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
// Initialize anchor
|
|
257
|
+
anchor_1.Anchor.initialize(connection);
|
|
258
|
+
try {
|
|
259
|
+
const result = yield Transactions_1.txgen.limitCloseAutomationIx2({
|
|
260
|
+
connection,
|
|
261
|
+
params,
|
|
262
|
+
fetch: undefined,
|
|
263
|
+
});
|
|
264
|
+
return {
|
|
265
|
+
status: 200,
|
|
266
|
+
data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
catch (e) {
|
|
270
|
+
return {
|
|
271
|
+
status: 400,
|
|
272
|
+
data: {
|
|
273
|
+
code: "custom",
|
|
274
|
+
message: e,
|
|
275
|
+
path: [],
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
244
281
|
/**
|
|
245
282
|
* Creates meteora close instruction (combination of claim fees/rewards + remove liquidity + close position)
|
|
246
283
|
*
|
|
@@ -3472,6 +3472,176 @@ export type IyfExtension = {
|
|
|
3472
3472
|
}
|
|
3473
3473
|
];
|
|
3474
3474
|
},
|
|
3475
|
+
{
|
|
3476
|
+
"name": "meteoraDlmmLimitCloseAutomation2";
|
|
3477
|
+
"docs": [
|
|
3478
|
+
"Meteora Limit Close Position"
|
|
3479
|
+
];
|
|
3480
|
+
"discriminator": [
|
|
3481
|
+
78,
|
|
3482
|
+
30,
|
|
3483
|
+
202,
|
|
3484
|
+
240,
|
|
3485
|
+
110,
|
|
3486
|
+
103,
|
|
3487
|
+
85,
|
|
3488
|
+
227
|
|
3489
|
+
];
|
|
3490
|
+
"accounts": [
|
|
3491
|
+
{
|
|
3492
|
+
"name": "farm";
|
|
3493
|
+
"docs": [
|
|
3494
|
+
"Hawksight multi-index farm"
|
|
3495
|
+
];
|
|
3496
|
+
},
|
|
3497
|
+
{
|
|
3498
|
+
"name": "userPda";
|
|
3499
|
+
"docs": [
|
|
3500
|
+
"Hawksight user pda"
|
|
3501
|
+
];
|
|
3502
|
+
"pda": {
|
|
3503
|
+
"seeds": [
|
|
3504
|
+
{
|
|
3505
|
+
"kind": "const";
|
|
3506
|
+
"value": [
|
|
3507
|
+
109,
|
|
3508
|
+
117,
|
|
3509
|
+
108,
|
|
3510
|
+
116,
|
|
3511
|
+
105,
|
|
3512
|
+
45,
|
|
3513
|
+
117,
|
|
3514
|
+
115,
|
|
3515
|
+
101,
|
|
3516
|
+
114
|
|
3517
|
+
];
|
|
3518
|
+
},
|
|
3519
|
+
{
|
|
3520
|
+
"kind": "account";
|
|
3521
|
+
"path": "farm";
|
|
3522
|
+
},
|
|
3523
|
+
{
|
|
3524
|
+
"kind": "account";
|
|
3525
|
+
"path": "authority";
|
|
3526
|
+
}
|
|
3527
|
+
];
|
|
3528
|
+
"program": {
|
|
3529
|
+
"kind": "account";
|
|
3530
|
+
"path": "iyfProgram";
|
|
3531
|
+
};
|
|
3532
|
+
};
|
|
3533
|
+
},
|
|
3534
|
+
{
|
|
3535
|
+
"name": "authority";
|
|
3536
|
+
"docs": [
|
|
3537
|
+
"User wallet",
|
|
3538
|
+
"* No need to check"
|
|
3539
|
+
];
|
|
3540
|
+
"writable": true;
|
|
3541
|
+
"relations": [
|
|
3542
|
+
"userPda"
|
|
3543
|
+
];
|
|
3544
|
+
},
|
|
3545
|
+
{
|
|
3546
|
+
"name": "iyfProgram";
|
|
3547
|
+
"docs": [
|
|
3548
|
+
"Main index yield farming program"
|
|
3549
|
+
];
|
|
3550
|
+
"address": "FqGg2Y1FNxMiGd51Q6UETixQWkF5fB92MysbYogRJb3P";
|
|
3551
|
+
},
|
|
3552
|
+
{
|
|
3553
|
+
"name": "hawksightAuthority";
|
|
3554
|
+
"docs": [
|
|
3555
|
+
"Rebalancer which is hard coded to be a Hawksight rebalance wallet"
|
|
3556
|
+
];
|
|
3557
|
+
"writable": true;
|
|
3558
|
+
"signer": true;
|
|
3559
|
+
},
|
|
3560
|
+
{
|
|
3561
|
+
"name": "position";
|
|
3562
|
+
"writable": true;
|
|
3563
|
+
},
|
|
3564
|
+
{
|
|
3565
|
+
"name": "lbPair";
|
|
3566
|
+
"writable": true;
|
|
3567
|
+
},
|
|
3568
|
+
{
|
|
3569
|
+
"name": "binArrayBitmapExtension";
|
|
3570
|
+
"address": "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
|
|
3571
|
+
},
|
|
3572
|
+
{
|
|
3573
|
+
"name": "userTokenX";
|
|
3574
|
+
"writable": true;
|
|
3575
|
+
},
|
|
3576
|
+
{
|
|
3577
|
+
"name": "userTokenY";
|
|
3578
|
+
"writable": true;
|
|
3579
|
+
},
|
|
3580
|
+
{
|
|
3581
|
+
"name": "reserveX";
|
|
3582
|
+
"writable": true;
|
|
3583
|
+
},
|
|
3584
|
+
{
|
|
3585
|
+
"name": "reserveY";
|
|
3586
|
+
"writable": true;
|
|
3587
|
+
},
|
|
3588
|
+
{
|
|
3589
|
+
"name": "tokenXMint";
|
|
3590
|
+
},
|
|
3591
|
+
{
|
|
3592
|
+
"name": "tokenYMint";
|
|
3593
|
+
},
|
|
3594
|
+
{
|
|
3595
|
+
"name": "tokenXProgram";
|
|
3596
|
+
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
3597
|
+
},
|
|
3598
|
+
{
|
|
3599
|
+
"name": "tokenYProgram";
|
|
3600
|
+
"address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
3601
|
+
},
|
|
3602
|
+
{
|
|
3603
|
+
"name": "binArrayLower";
|
|
3604
|
+
"writable": true;
|
|
3605
|
+
},
|
|
3606
|
+
{
|
|
3607
|
+
"name": "binArrayUpper";
|
|
3608
|
+
"writable": true;
|
|
3609
|
+
},
|
|
3610
|
+
{
|
|
3611
|
+
"name": "eventAuthority";
|
|
3612
|
+
},
|
|
3613
|
+
{
|
|
3614
|
+
"name": "meteoraDlmmProgram";
|
|
3615
|
+
"address": "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
|
|
3616
|
+
},
|
|
3617
|
+
{
|
|
3618
|
+
"name": "ownerFeeX";
|
|
3619
|
+
"writable": true;
|
|
3620
|
+
},
|
|
3621
|
+
{
|
|
3622
|
+
"name": "ownerFeeY";
|
|
3623
|
+
"writable": true;
|
|
3624
|
+
}
|
|
3625
|
+
];
|
|
3626
|
+
"args": [
|
|
3627
|
+
{
|
|
3628
|
+
"name": "param";
|
|
3629
|
+
"type": "bytes";
|
|
3630
|
+
},
|
|
3631
|
+
{
|
|
3632
|
+
"name": "minBinId";
|
|
3633
|
+
"type": "i32";
|
|
3634
|
+
},
|
|
3635
|
+
{
|
|
3636
|
+
"name": "maxBinId";
|
|
3637
|
+
"type": "i32";
|
|
3638
|
+
},
|
|
3639
|
+
{
|
|
3640
|
+
"name": "isHawkRefund";
|
|
3641
|
+
"type": "bool";
|
|
3642
|
+
}
|
|
3643
|
+
];
|
|
3644
|
+
},
|
|
3475
3645
|
{
|
|
3476
3646
|
"name": "meteoraDlmmOneSideDeposit";
|
|
3477
3647
|
"discriminator": [
|