@hawksightco/hawk-sdk 1.1.2 → 1.1.4-8.2
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 +2 -0
- package/dist/src/addresses.d.ts.map +1 -1
- package/dist/src/addresses.js +3 -1
- package/dist/src/anchor.d.ts +113 -1
- package/dist/src/anchor.d.ts.map +1 -1
- package/dist/src/anchor.js +33 -1
- package/dist/src/classes/Atomicity.d.ts +35 -0
- package/dist/src/classes/Atomicity.d.ts.map +1 -0
- package/dist/src/classes/Atomicity.js +110 -0
- package/dist/src/classes/CreateTxMetadata.d.ts +16 -0
- package/dist/src/classes/CreateTxMetadata.d.ts.map +1 -1
- package/dist/src/classes/CreateTxMetadata.js +115 -6
- package/dist/src/classes/General.d.ts +16 -0
- package/dist/src/classes/General.d.ts.map +1 -1
- package/dist/src/classes/General.js +32 -0
- package/dist/src/classes/HawkAPI.d.ts +29 -0
- package/dist/src/classes/HawkAPI.d.ts.map +1 -1
- package/dist/src/classes/HawkAPI.js +35 -0
- package/dist/src/classes/JupiterAlts.d.ts +38 -0
- package/dist/src/classes/JupiterAlts.d.ts.map +1 -0
- package/dist/src/classes/JupiterAlts.js +104 -0
- package/dist/src/classes/JupiterSwap.d.ts +20 -0
- package/dist/src/classes/JupiterSwap.d.ts.map +1 -0
- package/dist/src/classes/JupiterSwap.js +37 -0
- package/dist/src/classes/Logging.d.ts +13 -0
- package/dist/src/classes/Logging.d.ts.map +1 -0
- package/dist/src/classes/Logging.js +51 -0
- package/dist/src/classes/MultiTransaction.d.ts +76 -0
- package/dist/src/classes/MultiTransaction.d.ts.map +1 -0
- package/dist/src/classes/MultiTransaction.js +286 -0
- package/dist/src/classes/SimpleIxGenerator.d.ts +24 -0
- package/dist/src/classes/SimpleIxGenerator.d.ts.map +1 -0
- package/dist/src/classes/SimpleIxGenerator.js +29 -0
- package/dist/src/classes/Transaction.d.ts +42 -12
- package/dist/src/classes/Transaction.d.ts.map +1 -1
- package/dist/src/classes/Transaction.js +37 -15
- package/dist/src/classes/Transaction2.d.ts +108 -0
- package/dist/src/classes/Transaction2.d.ts.map +1 -0
- package/dist/src/classes/Transaction2.js +239 -0
- package/dist/src/classes/Transaction3.d.ts +166 -0
- package/dist/src/classes/Transaction3.d.ts.map +1 -0
- package/dist/src/classes/Transaction3.js +406 -0
- package/dist/src/classes/TransactionBatchExecute.d.ts +164 -0
- package/dist/src/classes/TransactionBatchExecute.d.ts.map +1 -0
- package/dist/src/classes/TransactionBatchExecute.js +456 -0
- package/dist/src/classes/TransactionBatchExecute2.d.ts +100 -0
- package/dist/src/classes/TransactionBatchExecute2.d.ts.map +1 -0
- package/dist/src/classes/TransactionBatchExecute2.js +347 -0
- package/dist/src/classes/Transactions.d.ts +51 -1
- package/dist/src/classes/Transactions.d.ts.map +1 -1
- package/dist/src/classes/Transactions.js +318 -54
- package/dist/src/classes/TxGenerator.d.ts +29 -1
- package/dist/src/classes/TxGenerator.d.ts.map +1 -1
- package/dist/src/classes/TxGenerator.js +123 -5
- package/dist/src/classes/TxGeneratorAutomations.d.ts +23 -1
- package/dist/src/classes/TxGeneratorAutomations.d.ts.map +1 -1
- package/dist/src/classes/TxGeneratorAutomations.js +72 -0
- package/dist/src/classes/Util.d.ts +22 -0
- package/dist/src/classes/Util.d.ts.map +1 -1
- package/dist/src/classes/Util.js +33 -0
- package/dist/src/functions.d.ts +61 -3
- package/dist/src/functions.d.ts.map +1 -1
- package/dist/src/functions.js +237 -3
- package/dist/src/hawksight.d.ts +8 -0
- package/dist/src/hawksight.d.ts.map +1 -1
- package/dist/src/hawksight.js +29 -1
- package/dist/src/hsToMeteora.d.ts +7 -0
- package/dist/src/hsToMeteora.d.ts.map +1 -1
- package/dist/src/hsToMeteora.js +541 -30
- package/dist/src/idl/iyf-extension-idl.d.ts +6620 -4193
- package/dist/src/idl/iyf-extension-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-extension-idl.js +6614 -4193
- package/dist/src/idl/iyf-main-idl.d.ts +244 -5
- package/dist/src/idl/iyf-main-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-main-idl.js +244 -5
- package/dist/src/idl/meteora-idl.d.ts +5251 -0
- package/dist/src/idl/meteora-idl.d.ts.map +1 -0
- package/dist/src/idl/meteora-idl.js +5252 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -1
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts +27 -0
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts.map +1 -0
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.js +71 -0
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts +64 -0
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts.map +1 -0
- package/dist/src/ixGenerator/IyfMainIxGenerator.js +203 -0
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts +50 -0
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +1 -0
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.js +271 -0
- package/dist/src/meteora.d.ts +230 -1
- package/dist/src/meteora.d.ts.map +1 -1
- package/dist/src/meteora.js +708 -15
- package/dist/src/types.d.ts +40 -14
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +3 -0
- package/package.json +3 -3
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
|
+
export * from "./functions";
|
|
2
3
|
export { HawkAPI } from "./classes/HawkAPI";
|
|
3
4
|
export { TxGenerator } from "./classes/TxGenerator";
|
|
4
5
|
export { Client } from "./classes/Client";
|
|
5
6
|
export { CreateTxMetadata } from "./classes/CreateTxMetadata";
|
|
7
|
+
export { TransactionBatchExecute2 } from "./classes/TransactionBatchExecute2";
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -14,8 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.CreateTxMetadata = exports.Client = exports.TxGenerator = exports.HawkAPI = void 0;
|
|
17
|
+
exports.TransactionBatchExecute2 = exports.CreateTxMetadata = exports.Client = exports.TxGenerator = exports.HawkAPI = void 0;
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./functions"), exports);
|
|
19
20
|
var HawkAPI_1 = require("./classes/HawkAPI");
|
|
20
21
|
Object.defineProperty(exports, "HawkAPI", { enumerable: true, get: function () { return HawkAPI_1.HawkAPI; } });
|
|
21
22
|
var TxGenerator_1 = require("./classes/TxGenerator");
|
|
@@ -24,3 +25,5 @@ var Client_1 = require("./classes/Client");
|
|
|
24
25
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return Client_1.Client; } });
|
|
25
26
|
var CreateTxMetadata_1 = require("./classes/CreateTxMetadata");
|
|
26
27
|
Object.defineProperty(exports, "CreateTxMetadata", { enumerable: true, get: function () { return CreateTxMetadata_1.CreateTxMetadata; } });
|
|
28
|
+
var TransactionBatchExecute2_1 = require("./classes/TransactionBatchExecute2");
|
|
29
|
+
Object.defineProperty(exports, "TransactionBatchExecute2", { enumerable: true, get: function () { return TransactionBatchExecute2_1.TransactionBatchExecute2; } });
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
|
+
import * as web3 from "@solana/web3.js";
|
|
3
|
+
import BN from "bn.js";
|
|
4
|
+
import { IyfMainIxGenerator } from "./IyfMainIxGenerator";
|
|
5
|
+
type MoveTokenIx = {
|
|
6
|
+
connection: web3.Connection;
|
|
7
|
+
userWallet: web3.PublicKey;
|
|
8
|
+
mint: web3.PublicKey;
|
|
9
|
+
useSourceAmount: boolean;
|
|
10
|
+
amount?: BN;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Iyf Extension IX Generator
|
|
14
|
+
*/
|
|
15
|
+
export declare class IyfExtensionIxGenerator {
|
|
16
|
+
private iyfMain;
|
|
17
|
+
constructor(iyfMain: IyfMainIxGenerator);
|
|
18
|
+
/**
|
|
19
|
+
* Move token from ATA to STA
|
|
20
|
+
*
|
|
21
|
+
* @param param0
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
moveTokenIx({ connection, userWallet, mint, useSourceAmount, amount, }: MoveTokenIx): Promise<web3.TransactionInstruction>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=IyfExtensionIxGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IyfExtensionIxGenerator.d.ts","sourceRoot":"","sources":["../../../src/ixGenerator/IyfExtensionIxGenerator.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAIxC,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;IAC5B,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,EAAE,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,qBAAa,uBAAuB;IAGhC,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,kBAAkB;IAGrC;;;;;OAKG;IACG,WAAW,CAAC,EAChB,UAAU,EACV,UAAU,EACV,IAAI,EACJ,eAAe,EACf,MAAM,GACP,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;CAwCtD"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.IyfExtensionIxGenerator = void 0;
|
|
16
|
+
const anchor_1 = require("../anchor");
|
|
17
|
+
const functions_1 = require("../functions");
|
|
18
|
+
const addresses_1 = require("../addresses");
|
|
19
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
20
|
+
/**
|
|
21
|
+
* Iyf Extension IX Generator
|
|
22
|
+
*/
|
|
23
|
+
class IyfExtensionIxGenerator {
|
|
24
|
+
constructor(iyfMain) {
|
|
25
|
+
this.iyfMain = iyfMain;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Move token from ATA to STA
|
|
29
|
+
*
|
|
30
|
+
* @param param0
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
moveTokenIx(_a) {
|
|
34
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, mint, useSourceAmount, amount, }) {
|
|
35
|
+
// Initialize anchor
|
|
36
|
+
anchor_1.Anchor.initialize(connection);
|
|
37
|
+
// Generate user pda
|
|
38
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
39
|
+
const sourceToken = (0, functions_1.generateAta)(userPda, mint);
|
|
40
|
+
const destinationToken = (0, functions_1.generateUserPdaStorageAccount)(userPda, mint);
|
|
41
|
+
if (!useSourceAmount && amount === undefined) {
|
|
42
|
+
throw new Error('Source amount cannot be undefined if `useSourceAmount` is false');
|
|
43
|
+
}
|
|
44
|
+
if (amount === undefined) {
|
|
45
|
+
amount = new bn_js_1.default(0);
|
|
46
|
+
}
|
|
47
|
+
// Generate move_token instruction
|
|
48
|
+
const iyfExtensionIx = yield anchor_1.Anchor.instance().iyfExtension
|
|
49
|
+
.methods
|
|
50
|
+
.moveToken(useSourceAmount, amount)
|
|
51
|
+
.accounts({
|
|
52
|
+
farm: addresses_1.USDC_FARM,
|
|
53
|
+
userPda,
|
|
54
|
+
authority: userWallet,
|
|
55
|
+
iyfProgram: addresses_1.IYF_MAIN,
|
|
56
|
+
hawksightAuthority: addresses_1.HS_AUTHORITY,
|
|
57
|
+
sourceToken,
|
|
58
|
+
destinationToken,
|
|
59
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
60
|
+
associatedTokenProgram: addresses_1.ASSOCIATED_TOKEN_PROGRAM,
|
|
61
|
+
})
|
|
62
|
+
.instruction();
|
|
63
|
+
// Wrap instruction in iyf extension (iyf-main)
|
|
64
|
+
return yield this.iyfMain.iyfExtensionExecute(connection, {
|
|
65
|
+
userWallet,
|
|
66
|
+
iyfExtensionIx,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.IyfExtensionIxGenerator = IyfExtensionIxGenerator;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
3
|
+
import * as web3 from "@solana/web3.js";
|
|
4
|
+
import { AtomicityContextParams } from "../hawksight";
|
|
5
|
+
import BN from "bn.js";
|
|
6
|
+
type IyfExtensionExecute = {
|
|
7
|
+
userWallet: web3.PublicKey;
|
|
8
|
+
iyfExtensionIx: web3.TransactionInstruction;
|
|
9
|
+
};
|
|
10
|
+
type JupiterRouteIx = {
|
|
11
|
+
connection: web3.Connection;
|
|
12
|
+
userWallet?: web3.PublicKey;
|
|
13
|
+
userPda?: web3.PublicKey;
|
|
14
|
+
sourceTokenAccount: web3.PublicKey;
|
|
15
|
+
destinationTokenAccount: web3.PublicKey;
|
|
16
|
+
destinationMint: web3.PublicKey;
|
|
17
|
+
platformFeeAccount: web3.PublicKey;
|
|
18
|
+
eventAuthority: web3.PublicKey;
|
|
19
|
+
remainingAccounts: web3.AccountMeta[];
|
|
20
|
+
data: Buffer;
|
|
21
|
+
quotedOutAmount?: BN;
|
|
22
|
+
slippageBps?: number;
|
|
23
|
+
platformFeeBps?: number;
|
|
24
|
+
checkDestinationTokenAccount?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type JupiterRouteIxReturn = {
|
|
27
|
+
swapIx: web3.TransactionInstruction;
|
|
28
|
+
createAtaIx: web3.TransactionInstruction;
|
|
29
|
+
closeAtaIx: web3.TransactionInstruction;
|
|
30
|
+
ataExists: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Iyf Main IX Generator
|
|
34
|
+
*/
|
|
35
|
+
export declare class IyfMainIxGenerator {
|
|
36
|
+
/**
|
|
37
|
+
* Generates a transaction instruction that sets the current blockchain clock
|
|
38
|
+
* to the user's PDA (Program Derived Address) account.
|
|
39
|
+
*
|
|
40
|
+
* @param connection - A Solana web3.js Connection object for interacting with the blockchain.
|
|
41
|
+
* @param params - AtomicityContextParams containing the context and parameters for setting the transaction slot.
|
|
42
|
+
* @returns A Promise that resolves to a TransactionInstruction object for setting the current clock in the PDA.
|
|
43
|
+
*/
|
|
44
|
+
setTransactionSlot(connection: web3.Connection, params: AtomicityContextParams): Promise<web3.TransactionInstruction>;
|
|
45
|
+
/**
|
|
46
|
+
* Generates a transaction instruction that verifies whether the current blockchain
|
|
47
|
+
* clock matches the value that has been previously set in the user's PDA (Program Derived Address) account.
|
|
48
|
+
*
|
|
49
|
+
* @param connection - A Solana web3.js Connection object for interacting with the blockchain.
|
|
50
|
+
* @param params - AtomicityContextParams containing the context and parameters for verifying the transaction slot.
|
|
51
|
+
* @returns A Promise that resolves to a TransactionInstruction object for verifying the clock in the PDA.
|
|
52
|
+
*/
|
|
53
|
+
verifyTransactionSlot(connection: web3.Connection, params: AtomicityContextParams): Promise<web3.TransactionInstruction>;
|
|
54
|
+
/**
|
|
55
|
+
* Invoke iyf extension
|
|
56
|
+
*
|
|
57
|
+
* @param connection
|
|
58
|
+
* @param params
|
|
59
|
+
*/
|
|
60
|
+
iyfExtensionExecute(connection: web3.Connection, { userWallet, iyfExtensionIx, }: IyfExtensionExecute): Promise<web3.TransactionInstruction>;
|
|
61
|
+
jupiterRouteIx({ connection, userWallet, userPda, sourceTokenAccount, destinationTokenAccount, destinationMint, platformFeeAccount, eventAuthority, remainingAccounts, data, quotedOutAmount, slippageBps, platformFeeBps, checkDestinationTokenAccount, }: JupiterRouteIx): Promise<JupiterRouteIxReturn>;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=IyfMainIxGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IyfMainIxGenerator.d.ts","sourceRoot":"","sources":["../../../src/ixGenerator/IyfMainIxGenerator.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAA6C,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAKjG,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,cAAc,EAAE,IAAI,CAAC,sBAAsB,CAAC;CAC7C,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;IAC5B,UAAU,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACzB,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC;IACnC,uBAAuB,EAAE,IAAI,CAAC,SAAS,CAAC;IACxC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC;IAChC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC;IACnC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC;IAC/B,iBAAiB,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,IAAI,CAAC,sBAAsB,CAAC;IACpC,WAAW,EAAE,IAAI,CAAC,sBAAsB,CAAC;IACzC,UAAU,EAAE,IAAI,CAAC,sBAAsB,CAAC;IACxC,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,qBAAa,kBAAkB;IAC7B;;;;;;;OAOG;IACG,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAQ3H;;;;;;;OAOG;IACG,qBAAqB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAQ9H;;;;;OAKG;IACG,mBAAmB,CACvB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,EACE,UAAU,EACV,cAAc,GACf,EAAE,mBAAmB,GACrB,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAqCjC,cAAc,CAAC,EACnB,UAAU,EACV,UAAU,EACV,OAAO,EACP,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,IAAI,EACJ,eAAe,EACf,WAAW,EACX,cAAc,EACd,4BAA4B,GAC7B,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAwGlD"}
|
|
@@ -0,0 +1,203 @@
|
|
|
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.IyfMainIxGenerator = void 0;
|
|
36
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
37
|
+
const anchor_1 = require("../anchor");
|
|
38
|
+
const hawksight_1 = require("../hawksight");
|
|
39
|
+
const functions_1 = require("../functions");
|
|
40
|
+
const addresses_1 = require("../addresses");
|
|
41
|
+
/**
|
|
42
|
+
* Iyf Main IX Generator
|
|
43
|
+
*/
|
|
44
|
+
class IyfMainIxGenerator {
|
|
45
|
+
/**
|
|
46
|
+
* Generates a transaction instruction that sets the current blockchain clock
|
|
47
|
+
* to the user's PDA (Program Derived Address) account.
|
|
48
|
+
*
|
|
49
|
+
* @param connection - A Solana web3.js Connection object for interacting with the blockchain.
|
|
50
|
+
* @param params - AtomicityContextParams containing the context and parameters for setting the transaction slot.
|
|
51
|
+
* @returns A Promise that resolves to a TransactionInstruction object for setting the current clock in the PDA.
|
|
52
|
+
*/
|
|
53
|
+
setTransactionSlot(connection, params) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
// Initialize anchor
|
|
56
|
+
anchor_1.Anchor.initialize(connection);
|
|
57
|
+
// Get set transaction slot instruction
|
|
58
|
+
return yield (0, hawksight_1.setTransactionSlot)(params);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Generates a transaction instruction that verifies whether the current blockchain
|
|
63
|
+
* clock matches the value that has been previously set in the user's PDA (Program Derived Address) account.
|
|
64
|
+
*
|
|
65
|
+
* @param connection - A Solana web3.js Connection object for interacting with the blockchain.
|
|
66
|
+
* @param params - AtomicityContextParams containing the context and parameters for verifying the transaction slot.
|
|
67
|
+
* @returns A Promise that resolves to a TransactionInstruction object for verifying the clock in the PDA.
|
|
68
|
+
*/
|
|
69
|
+
verifyTransactionSlot(connection, params) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
// Initialize anchor
|
|
72
|
+
anchor_1.Anchor.initialize(connection);
|
|
73
|
+
// Get verify transaction slot instruction
|
|
74
|
+
return yield (0, hawksight_1.verifyTransactionSlot)(params);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Invoke iyf extension
|
|
79
|
+
*
|
|
80
|
+
* @param connection
|
|
81
|
+
* @param params
|
|
82
|
+
*/
|
|
83
|
+
iyfExtensionExecute(connection_1, _a) {
|
|
84
|
+
return __awaiter(this, arguments, void 0, function* (connection, { userWallet, iyfExtensionIx, }) {
|
|
85
|
+
// Initialize anchor
|
|
86
|
+
anchor_1.Anchor.initialize(connection);
|
|
87
|
+
// Generate user pda
|
|
88
|
+
const userPda = (0, functions_1.generateUserPda)(userWallet);
|
|
89
|
+
// Validate whether instruction is valid
|
|
90
|
+
const invalidInstruction = !iyfExtensionIx.programId.equals(addresses_1.IYF_EXTENSION) ||
|
|
91
|
+
iyfExtensionIx.keys.length < 4 ||
|
|
92
|
+
iyfExtensionIx.data.length < 8 ||
|
|
93
|
+
!iyfExtensionIx.keys[0].pubkey.equals(addresses_1.USDC_FARM) ||
|
|
94
|
+
!iyfExtensionIx.keys[1].pubkey.equals(userPda) ||
|
|
95
|
+
!iyfExtensionIx.keys[2].pubkey.equals(userWallet) ||
|
|
96
|
+
!iyfExtensionIx.keys[3].pubkey.equals(addresses_1.IYF_MAIN);
|
|
97
|
+
if (invalidInstruction) {
|
|
98
|
+
throw new Error('The given instruction is not a valid iyf extension instruction.');
|
|
99
|
+
}
|
|
100
|
+
// Generate iyf extension instruction
|
|
101
|
+
const ix = yield anchor_1.Anchor.instance().iyfMain
|
|
102
|
+
.methods
|
|
103
|
+
.iyfExtensionExecute(iyfExtensionIx.data)
|
|
104
|
+
.accounts({
|
|
105
|
+
farm: addresses_1.USDC_FARM,
|
|
106
|
+
userPda,
|
|
107
|
+
authority: userWallet,
|
|
108
|
+
iyfProgram: addresses_1.IYF_MAIN,
|
|
109
|
+
iyfExtensionProgram: iyfExtensionIx.programId
|
|
110
|
+
})
|
|
111
|
+
.remainingAccounts(iyfExtensionIx.keys.slice(4))
|
|
112
|
+
.instruction();
|
|
113
|
+
return ix;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
jupiterRouteIx(_a) {
|
|
117
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, userWallet, userPda, sourceTokenAccount, destinationTokenAccount, destinationMint, platformFeeAccount, eventAuthority, remainingAccounts, data, quotedOutAmount, slippageBps, platformFeeBps, checkDestinationTokenAccount, }) {
|
|
118
|
+
// Initialize anchor
|
|
119
|
+
anchor_1.Anchor.initialize(connection);
|
|
120
|
+
const { routePlan, quotedOutAmount: quotedOutAmount_default, slippageBps: slippageBps_default, platformFeeBps: platformFeeBps_default, } = (0, functions_1.getJupiterRouteIxParams)(data);
|
|
121
|
+
quotedOutAmount = quotedOutAmount === undefined ? quotedOutAmount_default : quotedOutAmount;
|
|
122
|
+
slippageBps = slippageBps === undefined ? slippageBps_default : slippageBps;
|
|
123
|
+
platformFeeBps = platformFeeBps === undefined ? platformFeeBps_default : platformFeeBps;
|
|
124
|
+
// Generate user pda from given user wallet
|
|
125
|
+
userPda = userWallet !== undefined ? (0, functions_1.generateUserPda)(userWallet) : userPda;
|
|
126
|
+
if (userPda === undefined) {
|
|
127
|
+
throw new Error("Either one of `userWallet` or `userPda` parameter must be defined!");
|
|
128
|
+
}
|
|
129
|
+
// Defaults to false
|
|
130
|
+
let ataExists = false;
|
|
131
|
+
// Generate STA and ATA
|
|
132
|
+
const destATA = (0, functions_1.generateAta)(userPda, destinationMint);
|
|
133
|
+
const destSTA = (0, functions_1.generateUserPdaStorageAccount)(userPda, destinationMint);
|
|
134
|
+
// createAtaIx
|
|
135
|
+
let createAtaIx;
|
|
136
|
+
if (destATA.equals(destinationTokenAccount)) {
|
|
137
|
+
[createAtaIx] = (0, functions_1.createAtaIdempotentIxs)({
|
|
138
|
+
accounts: [{
|
|
139
|
+
payer: addresses_1.HS_AUTHORITY,
|
|
140
|
+
mint: destinationMint,
|
|
141
|
+
owner: userPda,
|
|
142
|
+
}]
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else if (destSTA.equals(destinationTokenAccount)) {
|
|
146
|
+
createAtaIx = yield anchor_1.Anchor.instance().iyfMain
|
|
147
|
+
.methods
|
|
148
|
+
.initializeStorageTokenAccount()
|
|
149
|
+
.accounts({
|
|
150
|
+
userPda,
|
|
151
|
+
payer: addresses_1.HS_AUTHORITY,
|
|
152
|
+
mint: destinationMint,
|
|
153
|
+
storageTokenAccount: destSTA,
|
|
154
|
+
rent: web3.SYSVAR_RENT_PUBKEY,
|
|
155
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
156
|
+
systemProgram: web3.SystemProgram.programId,
|
|
157
|
+
})
|
|
158
|
+
.instruction();
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
throw new Error(`destinationTokenAccount: ${destinationTokenAccount} is neither ATA(${destATA}) or STA${destSTA}`);
|
|
162
|
+
}
|
|
163
|
+
// Flag must be enabled first to check ATA onchain
|
|
164
|
+
if (checkDestinationTokenAccount) {
|
|
165
|
+
const info = yield connection.getAccountInfo(destinationTokenAccount);
|
|
166
|
+
ataExists = !(info === null || info === undefined);
|
|
167
|
+
}
|
|
168
|
+
const closeAtaIx = yield anchor_1.Anchor.instance().iyfMain
|
|
169
|
+
.methods
|
|
170
|
+
.closeAta()
|
|
171
|
+
.accounts({
|
|
172
|
+
userPda,
|
|
173
|
+
hsAuthority: addresses_1.HS_AUTHORITY,
|
|
174
|
+
userTokenAccount: destinationTokenAccount,
|
|
175
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
176
|
+
})
|
|
177
|
+
.instruction();
|
|
178
|
+
const ix = yield anchor_1.Anchor.instance().iyfMain
|
|
179
|
+
.methods
|
|
180
|
+
.jupiterRouteIx(routePlan, quotedOutAmount, slippageBps, platformFeeBps)
|
|
181
|
+
.accounts({
|
|
182
|
+
authority: addresses_1.HS_AUTHORITY,
|
|
183
|
+
tokenProgram: addresses_1.TOKEN_PROGRAM_ID,
|
|
184
|
+
userPda,
|
|
185
|
+
userSourceTokenAccount: sourceTokenAccount,
|
|
186
|
+
userDestinationTokenAccount: destinationTokenAccount,
|
|
187
|
+
destinationMint,
|
|
188
|
+
platformFeeAccount,
|
|
189
|
+
eventAuthority,
|
|
190
|
+
jupiterProgram: addresses_1.JUPITER_PROGRAM
|
|
191
|
+
})
|
|
192
|
+
.remainingAccounts(remainingAccounts)
|
|
193
|
+
.instruction();
|
|
194
|
+
return {
|
|
195
|
+
swapIx: ix,
|
|
196
|
+
createAtaIx,
|
|
197
|
+
closeAtaIx,
|
|
198
|
+
ataExists,
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.IyfMainIxGenerator = IyfMainIxGenerator;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
|
+
import * as web3 from "@solana/web3.js";
|
|
3
|
+
import { IyfMainIxGenerator } from "./IyfMainIxGenerator";
|
|
4
|
+
import { StrategyType } from "@meteora-ag/dlmm";
|
|
5
|
+
type InitializePositionAutomation = {
|
|
6
|
+
userWallet: web3.PublicKey;
|
|
7
|
+
lbPair: web3.PublicKey;
|
|
8
|
+
position: web3.PublicKey;
|
|
9
|
+
lowerBinId: number;
|
|
10
|
+
upperBinId: number;
|
|
11
|
+
};
|
|
12
|
+
type OpenPositionAndDepositAutomation = {
|
|
13
|
+
userWallet: web3.PublicKey;
|
|
14
|
+
lbPair: web3.PublicKey;
|
|
15
|
+
position: web3.PublicKey;
|
|
16
|
+
relativeLowerBinId: number;
|
|
17
|
+
relativeUpperBinId: number;
|
|
18
|
+
strategyType: StrategyType;
|
|
19
|
+
checkRange: {
|
|
20
|
+
minBinId: number;
|
|
21
|
+
maxBinId: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Meteora related instructions executed via iyf extension or iyf main
|
|
26
|
+
*/
|
|
27
|
+
export declare class MeteoraDlmmIxGenerator {
|
|
28
|
+
private iyfMain;
|
|
29
|
+
constructor(iyfMain: IyfMainIxGenerator);
|
|
30
|
+
initializePositionAutomation(connection: web3.Connection, { userWallet, lbPair, position, lowerBinId, upperBinId }: InitializePositionAutomation): Promise<web3.TransactionInstruction>;
|
|
31
|
+
redepositAutomation(connection: web3.Connection, { userWallet, lbPair, position, relativeLowerBinId, relativeUpperBinId, strategyType, checkRange }: OpenPositionAndDepositAutomation): Promise<web3.TransactionInstruction>;
|
|
32
|
+
claimFee(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
33
|
+
claimReward(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
34
|
+
claimFeeAutomation(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
35
|
+
claimRewardAutomation(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
36
|
+
depositAutomation(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
37
|
+
oneSideDeposit(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
38
|
+
withdrawAutomation(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
39
|
+
closePositionAutomation(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
40
|
+
limitCloseAutomation(connection: web3.Connection, params: {}): Promise<web3.TransactionInstruction>;
|
|
41
|
+
/**
|
|
42
|
+
* Meteora IDL
|
|
43
|
+
*
|
|
44
|
+
* @param connection
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
private meteora;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=MeteoraDlmmIxGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeteoraDlmmIxGenerator.d.ts","sourceRoot":"","sources":["../../../src/ixGenerator/MeteoraDlmmIxGenerator.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAGxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAK1D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAYhD,KAAK,4BAA4B,GAAG;IAClC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAA;AAED,KAAK,gCAAgC,GAAG;IACtC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;IAC3B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAA;CACF,CAAA;AAED;;GAEG;AACH,qBAAa,sBAAsB;IAG/B,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,kBAAkB;IAG/B,4BAA4B,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAqCvL,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,gCAAgC,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAsF5N,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAWvF,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAW1F,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAWjG,qBAAqB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAWpG,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAWhG,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAW7F,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAWjG,uBAAuB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAWtG,oBAAoB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAWzG;;;;;OAKG;YACW,OAAO;CAGtB"}
|