@hawksightco/hawk-sdk 0.0.5 → 0.0.7
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/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +358 -0
- package/dist/types.d.ts +253 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/package.json +7 -3
- package/jest.config.js +0 -5
- package/src/index.ts +0 -382
- package/src/types.ts +0 -248
- package/test/index.spec.ts +0 -213
- package/tsconfig.json +0 -109
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
2
|
+
import * as client from "@hawksightco/swagger-client";
|
|
3
|
+
import { HealthResponse, MeteoraDlmmActiveBin, ResponseWithStatus, TransactionMetadata, TransactionMetadataResponse, UserPortfolioOut } from "./types";
|
|
4
|
+
declare class Client {
|
|
5
|
+
readonly url: string;
|
|
6
|
+
readonly config: client.Configuration;
|
|
7
|
+
readonly healthCheck: client.HealthCheckApi;
|
|
8
|
+
readonly generalEndpoints: client.GeneralEndpointsApi;
|
|
9
|
+
readonly meteoraDLMMUtilityFunctionsApi: client.MeteoraDLMMUtilityFunctionsApi;
|
|
10
|
+
readonly meteoraDLMMInstructionsApi: client.MeteoraDLMMInstructionsApi;
|
|
11
|
+
readonly meteoraDLMMAutomationInstructionsApi: client.MeteoraDLMMAutomationInstructionsApi;
|
|
12
|
+
readonly orcaUtilityFunctionsApi: client.OrcaUtilityFunctionsApi;
|
|
13
|
+
readonly orcaCLMMInstructionsApi: client.OrcaCLMMInstructionsApi;
|
|
14
|
+
constructor(url?: string);
|
|
15
|
+
}
|
|
16
|
+
declare class Health {
|
|
17
|
+
private readonly client;
|
|
18
|
+
constructor(client: Client);
|
|
19
|
+
health(): Promise<ResponseWithStatus<HealthResponse>>;
|
|
20
|
+
}
|
|
21
|
+
declare class General {
|
|
22
|
+
private readonly client;
|
|
23
|
+
constructor(client: Client);
|
|
24
|
+
portfolio(params: {
|
|
25
|
+
wallet: string;
|
|
26
|
+
pool?: string;
|
|
27
|
+
}): Promise<ResponseWithStatus<UserPortfolioOut>>;
|
|
28
|
+
pools(): Promise<ResponseWithStatus<client.InlineResponse2002[]>>;
|
|
29
|
+
tokens(): Promise<ResponseWithStatus<client.InlineResponse2003[]>>;
|
|
30
|
+
register(connection: web3.Connection, payer: string, params: client.RegisterBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
31
|
+
}
|
|
32
|
+
declare class Util {
|
|
33
|
+
private readonly client;
|
|
34
|
+
constructor(client: Client);
|
|
35
|
+
meteoraDlmmPools(): Promise<ResponseWithStatus<client.InlineResponse2005[]>>;
|
|
36
|
+
meteoraDlmmPositions(params: {
|
|
37
|
+
wallet: string;
|
|
38
|
+
pool?: string;
|
|
39
|
+
}): Promise<ResponseWithStatus<any>>;
|
|
40
|
+
meteoraDlmmActiveBin(params: client.UtilActiveBinBody): Promise<ResponseWithStatus<MeteoraDlmmActiveBin>>;
|
|
41
|
+
orcaClmmPools(): Promise<ResponseWithStatus<any>>;
|
|
42
|
+
orcaPositions(params: {
|
|
43
|
+
wallet: string;
|
|
44
|
+
pool?: string;
|
|
45
|
+
}): Promise<ResponseWithStatus<any>>;
|
|
46
|
+
orcaGetPositionMint(params: {
|
|
47
|
+
position: string;
|
|
48
|
+
}): Promise<ResponseWithStatus<any>>;
|
|
49
|
+
}
|
|
50
|
+
declare class TxGenerator {
|
|
51
|
+
private readonly client;
|
|
52
|
+
constructor(client: Client);
|
|
53
|
+
meteoraCreatePositionAndDeposit(connection: web3.Connection, payer: string, params: client.TxCreatePositionAndDepositBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
54
|
+
meteoraDeposit(connection: web3.Connection, payer: string, params: client.TxDepositBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
55
|
+
meteoraWithdraw(connection: web3.Connection, payer: string, params: client.TxWithdrawBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
56
|
+
meteoraClaim(connection: web3.Connection, payer: string, params: client.TxClaimBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
57
|
+
meteoraClosePosition(connection: web3.Connection, payer: string, params: client.TxClosePositionBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
58
|
+
orcaOpenPosition(connection: web3.Connection, payer: string, params: client.TxOpenPositionBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
59
|
+
orcaClosePosition(connection: web3.Connection, payer: string, params: client.TxClosePositionBody1): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
60
|
+
orcaDeposit(connection: web3.Connection, payer: string, params: client.TxDepositBody1): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
61
|
+
orcaWithdraw(connection: web3.Connection, payer: string, params: client.TxWithdrawBody1): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
62
|
+
orcaClaimRewards(connection: web3.Connection, payer: string, params: client.TxClaimRewardsBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
63
|
+
}
|
|
64
|
+
declare class TxGeneratorAutomations {
|
|
65
|
+
private readonly client;
|
|
66
|
+
constructor(client: Client);
|
|
67
|
+
meteoraClaimFeeAndRewards(connection: web3.Connection, payer: string, params: client.AutomationClaimFeeAndRewardsAutomationIxBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
68
|
+
meteoraFullWithdrawalAndClosePosition(connection: web3.Connection, payer: string, params: client.AutomationFullWithdrawAndClosePositionAutomationIxBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
69
|
+
meteoraCreatePositionAndDeposit(connection: web3.Connection, payer: string, params: client.AutomationCreatePositionAndDepositAutomationIxBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
70
|
+
}
|
|
71
|
+
declare class HawkAPI {
|
|
72
|
+
protected readonly url: string;
|
|
73
|
+
readonly health: Health;
|
|
74
|
+
readonly general: General;
|
|
75
|
+
readonly util: Util;
|
|
76
|
+
readonly txGenerator: TxGenerator;
|
|
77
|
+
readonly txGeneratorAutomation: TxGeneratorAutomations;
|
|
78
|
+
constructor(url?: string);
|
|
79
|
+
}
|
|
80
|
+
export default HawkAPI;
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEvJ,cAAM,MAAM;aAUQ,GAAG,EAAE,MAAM;IAT7B,SAAgB,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;IAC7C,SAAgB,WAAW,EAAE,MAAM,CAAC,cAAc,CAAC;IACnD,SAAgB,gBAAgB,EAAE,MAAM,CAAC,mBAAmB,CAAC;IAC7D,SAAgB,8BAA8B,EAAE,MAAM,CAAC,8BAA8B,CAAC;IACtF,SAAgB,0BAA0B,EAAE,MAAM,CAAC,0BAA0B,CAAC;IAC9E,SAAgB,oCAAoC,EAAE,MAAM,CAAC,oCAAoC,CAAC;IAClG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AG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CAU1M;AAED,cAAM,sBAAsB;IAExB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAG3B,yBAAyB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,4CAA4C,GAAG,OAAO,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAWtO,qCAAqC,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,sDAAsD,GAAG,OAAO,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAW5P,+BAA+B,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,kDAAkD,GAAG,OAAO,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CAUzP;AAED,cAAM,OAAO;IAOT,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;IANhC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,IAAI,EAAE,IAAI,CAAC;IAC3B,SAAgB,WAAW,EAAE,WAAW,CAAC;IACzC,SAAgB,qBAAqB,EAAE,sBAAsB,CAAC;gBAEzC,GAAG,GAAE,MAAoC;CAS/D;AAED,eAAe,OAAO,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
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
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
36
|
+
const client = __importStar(require("@hawksightco/swagger-client"));
|
|
37
|
+
class Client {
|
|
38
|
+
constructor(url = "https://api2.hawksight.co") {
|
|
39
|
+
this.url = url;
|
|
40
|
+
this.config = new client.Configuration({
|
|
41
|
+
basePath: url
|
|
42
|
+
});
|
|
43
|
+
this.healthCheck = new client.HealthCheckApi(this.config);
|
|
44
|
+
this.generalEndpoints = new client.GeneralEndpointsApi(this.config);
|
|
45
|
+
this.meteoraDLMMUtilityFunctionsApi = new client.MeteoraDLMMUtilityFunctionsApi(this.config);
|
|
46
|
+
this.meteoraDLMMInstructionsApi = new client.MeteoraDLMMInstructionsApi(this.config);
|
|
47
|
+
this.meteoraDLMMAutomationInstructionsApi = new client.MeteoraDLMMAutomationInstructionsApi(this.config);
|
|
48
|
+
this.orcaUtilityFunctionsApi = new client.OrcaUtilityFunctionsApi(this.config);
|
|
49
|
+
this.orcaCLMMInstructionsApi = new client.OrcaCLMMInstructionsApi(this.config);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class Health {
|
|
53
|
+
constructor(client) {
|
|
54
|
+
this.client = client;
|
|
55
|
+
}
|
|
56
|
+
health() {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const result = yield this.client.healthCheck.healthGet().catch(e => e.response);
|
|
59
|
+
return {
|
|
60
|
+
status: result.status,
|
|
61
|
+
data: result.data,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
class General {
|
|
67
|
+
constructor(client) {
|
|
68
|
+
this.client = client;
|
|
69
|
+
}
|
|
70
|
+
portfolio(params) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const result = yield this.client.generalEndpoints.portfolioGet(params.wallet, params.pool).catch(e => e.response);
|
|
73
|
+
return {
|
|
74
|
+
status: result.status,
|
|
75
|
+
data: result.data,
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
pools() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const result = yield this.client.generalEndpoints.poolsGet().catch(e => e.response);
|
|
82
|
+
return {
|
|
83
|
+
status: result.status,
|
|
84
|
+
data: result.data,
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
tokens() {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const result = yield this.client.generalEndpoints.tokensGet().catch(e => e.response);
|
|
91
|
+
return {
|
|
92
|
+
status: result.status,
|
|
93
|
+
data: result.data,
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
register(connection, payer, params) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const result = yield this.client.generalEndpoints.registerPost(params).catch(e => e.response);
|
|
100
|
+
return resultOrError({
|
|
101
|
+
status: result.status,
|
|
102
|
+
data: result.data,
|
|
103
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
class Util {
|
|
108
|
+
constructor(client) {
|
|
109
|
+
this.client = client;
|
|
110
|
+
}
|
|
111
|
+
meteoraDlmmPools() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const result = yield this.client.meteoraDLMMUtilityFunctionsApi.meteoraDlmmUtilPoolsGet().catch(e => e.response);
|
|
114
|
+
return {
|
|
115
|
+
status: result.status,
|
|
116
|
+
data: result.data,
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
meteoraDlmmPositions(params) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const result = yield this.client.meteoraDLMMUtilityFunctionsApi.meteoraDlmmUtilPositionsGet(params.wallet, params.pool).catch(e => e.response);
|
|
123
|
+
return {
|
|
124
|
+
status: result.status,
|
|
125
|
+
data: result.data,
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
meteoraDlmmActiveBin(params) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const result = yield this.client.meteoraDLMMUtilityFunctionsApi.meteoraDlmmUtilActiveBinPost(params).catch(e => e.response);
|
|
132
|
+
return {
|
|
133
|
+
status: result.status,
|
|
134
|
+
data: result.data,
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
orcaClmmPools() {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
const result = yield this.client.orcaUtilityFunctionsApi.orcaUtilPoolsGet().catch(e => e.response);
|
|
141
|
+
return {
|
|
142
|
+
status: result.status,
|
|
143
|
+
data: result.data,
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
orcaPositions(params) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const result = yield this.client.orcaUtilityFunctionsApi.orcaUtilPositionsGet(params.wallet, params.pool).catch(e => e.response);
|
|
150
|
+
return {
|
|
151
|
+
status: result.status,
|
|
152
|
+
data: result.data,
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
orcaGetPositionMint(params) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
const result = yield this.client.orcaUtilityFunctionsApi.orcaUtilGetPositionMintGet(params.position).catch(e => e.response);
|
|
159
|
+
return {
|
|
160
|
+
status: result.status,
|
|
161
|
+
data: result.data,
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
class TxGenerator {
|
|
167
|
+
constructor(client) {
|
|
168
|
+
this.client = client;
|
|
169
|
+
}
|
|
170
|
+
meteoraCreatePositionAndDeposit(connection, payer, params) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxCreatePositionAndDepositPost(params).catch(e => e.response);
|
|
173
|
+
return resultOrError({
|
|
174
|
+
status: result.status,
|
|
175
|
+
data: result.data,
|
|
176
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
meteoraDeposit(connection, payer, params) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxDepositPost(params).catch(e => e.response);
|
|
182
|
+
return resultOrError({
|
|
183
|
+
status: result.status,
|
|
184
|
+
data: result.data,
|
|
185
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
meteoraWithdraw(connection, payer, params) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxWithdrawPost(params).catch(e => e.response);
|
|
191
|
+
return resultOrError({
|
|
192
|
+
status: result.status,
|
|
193
|
+
data: result.data,
|
|
194
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
meteoraClaim(connection, payer, params) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxClaimPost(params).catch(e => e.response);
|
|
200
|
+
return resultOrError({
|
|
201
|
+
status: result.status,
|
|
202
|
+
data: result.data,
|
|
203
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
meteoraClosePosition(connection, payer, params) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxClosePositionPost(params).catch(e => e.response);
|
|
209
|
+
return resultOrError({
|
|
210
|
+
status: result.status,
|
|
211
|
+
data: result.data,
|
|
212
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
orcaOpenPosition(connection, payer, params) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxOpenPositionPost(params).catch(e => e.response);
|
|
218
|
+
return resultOrError({
|
|
219
|
+
status: result.status,
|
|
220
|
+
data: result.data,
|
|
221
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
orcaClosePosition(connection, payer, params) {
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxClosePositionPost(params).catch(e => e.response);
|
|
227
|
+
return resultOrError({
|
|
228
|
+
status: result.status,
|
|
229
|
+
data: result.data,
|
|
230
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
orcaDeposit(connection, payer, params) {
|
|
234
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
+
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxDepositPost(params).catch(e => e.response);
|
|
236
|
+
return resultOrError({
|
|
237
|
+
status: result.status,
|
|
238
|
+
data: result.data,
|
|
239
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
orcaWithdraw(connection, payer, params) {
|
|
243
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxWithdrawPost(params).catch(e => e.response);
|
|
245
|
+
return resultOrError({
|
|
246
|
+
status: result.status,
|
|
247
|
+
data: result.data,
|
|
248
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
orcaClaimRewards(connection, payer, params) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxClaimRewardsPost(params).catch(e => e.response);
|
|
254
|
+
return resultOrError({
|
|
255
|
+
status: result.status,
|
|
256
|
+
data: result.data,
|
|
257
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
class TxGeneratorAutomations {
|
|
262
|
+
constructor(client) {
|
|
263
|
+
this.client = client;
|
|
264
|
+
}
|
|
265
|
+
meteoraClaimFeeAndRewards(connection, payer, params) {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
const result = yield this.client.meteoraDLMMAutomationInstructionsApi.meteoraDlmmAutomationClaimFeeAndRewardsAutomationIxPost(params).catch(e => e.response);
|
|
268
|
+
return resultOrError({
|
|
269
|
+
status: result.status,
|
|
270
|
+
data: result.data,
|
|
271
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
meteoraFullWithdrawalAndClosePosition(connection, payer, params) {
|
|
275
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
const result = yield this.client.meteoraDLMMAutomationInstructionsApi.meteoraDlmmAutomationFullWithdrawAndClosePositionAutomationIxPost(params).catch(e => e.response);
|
|
277
|
+
return resultOrError({
|
|
278
|
+
status: result.status,
|
|
279
|
+
data: result.data,
|
|
280
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
meteoraCreatePositionAndDeposit(connection, payer, params) {
|
|
284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
const result = yield this.client.meteoraDLMMAutomationInstructionsApi.meteoraDlmmAutomationCreatePositionAndDepositAutomationIxPost(params).catch(e => e.response);
|
|
286
|
+
return resultOrError({
|
|
287
|
+
status: result.status,
|
|
288
|
+
data: result.data,
|
|
289
|
+
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield createTxMetadata(connection, payer, data); }));
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
class HawkAPI {
|
|
294
|
+
constructor(url = "https://api2.hawksight.co") {
|
|
295
|
+
this.url = url;
|
|
296
|
+
const client = new Client(url);
|
|
297
|
+
this.health = new Health(client);
|
|
298
|
+
this.general = new General(client);
|
|
299
|
+
this.util = new Util(client);
|
|
300
|
+
this.txGenerator = new TxGenerator(client);
|
|
301
|
+
this.txGeneratorAutomation = new TxGeneratorAutomations(client);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
exports.default = HawkAPI;
|
|
305
|
+
function createTxMetadata(connection, payer, data) {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
+
const alts = [];
|
|
308
|
+
for (const alt of data.addressLookupTableAddresses) {
|
|
309
|
+
alts.push((yield connection.getAddressLookupTable(new web3.PublicKey(alt))).value);
|
|
310
|
+
}
|
|
311
|
+
const computeIxs = data.computeBudgetInstructions.map(ix => {
|
|
312
|
+
return new web3.TransactionInstruction({
|
|
313
|
+
keys: ix.accounts.map(meta => {
|
|
314
|
+
return { pubkey: new web3.PublicKey(meta.pubkey), isSigner: meta.isSigner, isWritable: meta.isWritable };
|
|
315
|
+
}),
|
|
316
|
+
programId: new web3.PublicKey(ix.programId),
|
|
317
|
+
data: Buffer.from(ix.data, 'base64'),
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
const mainIxs = data.computeBudgetInstructions.map(ix => {
|
|
321
|
+
return new web3.TransactionInstruction({
|
|
322
|
+
keys: ix.accounts.map(meta => {
|
|
323
|
+
return { pubkey: new web3.PublicKey(meta.pubkey), isSigner: meta.isSigner, isWritable: meta.isWritable };
|
|
324
|
+
}),
|
|
325
|
+
programId: new web3.PublicKey(ix.programId),
|
|
326
|
+
data: Buffer.from(ix.data, 'base64'),
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
const { blockhash: recentBlockhash } = yield connection.getLatestBlockhash();
|
|
330
|
+
const txMessage = new web3.TransactionMessage({
|
|
331
|
+
payerKey: new web3.PublicKey(payer),
|
|
332
|
+
instructions: [...computeIxs, ...mainIxs],
|
|
333
|
+
recentBlockhash,
|
|
334
|
+
});
|
|
335
|
+
const tx = new web3.VersionedTransaction(txMessage.compileToV0Message(alts));
|
|
336
|
+
return {
|
|
337
|
+
description: data.description,
|
|
338
|
+
estimatedFeeInSOL: data.estimatedFeeInSOL,
|
|
339
|
+
transaction: tx.serialize(),
|
|
340
|
+
};
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
function resultOrError(result, successFn) {
|
|
344
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
345
|
+
if (result.status === 200) {
|
|
346
|
+
return {
|
|
347
|
+
status: result.status,
|
|
348
|
+
data: yield successFn(result.data),
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
return {
|
|
353
|
+
status: result.status,
|
|
354
|
+
data: result.data,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|