@pyron-finance/pyron-client 1.0.6 → 1.0.9-pre.0
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/README.md +15 -0
- package/dist/common/index.cjs +68 -0
- package/dist/common/{index.d.mts → index.d.cts} +1 -1
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +2 -67
- package/dist/{common-BDe3qLlR.js → common-B23MHZHG.cjs} +5 -4
- package/dist/{common-BtUtEjzZ.mjs → common-CsZ-YSuW.js} +7 -6
- package/dist/common-CsZ-YSuW.js.map +1 -0
- package/dist/{index-BAC0ffmc.d.mts → index-Bi6sw5qC.d.cts} +117 -69
- package/dist/index-Bi6sw5qC.d.cts.map +1 -0
- package/dist/{index-Bx-zRXFQ.d.ts → index-DcGyKuPI.d.ts} +132 -88
- package/dist/index-DcGyKuPI.d.ts.map +1 -0
- package/dist/{index.mjs → index.cjs} +1079 -735
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +861 -958
- package/dist/index.js.map +1 -0
- package/package.json +28 -4
- package/dist/common/index.mjs +0 -3
- package/dist/common-BtUtEjzZ.mjs.map +0 -1
- package/dist/index-BAC0ffmc.d.mts.map +0 -1
- package/dist/index-Bx-zRXFQ.d.ts.map +0 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs.map +0 -1
- /package/dist/{chunk-B9dir_RE.mjs → chunk-Cl8Af3a2.js} +0 -0
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
const require_common = require('./common-B23MHZHG.cjs');
|
|
2
|
+
const __coral_xyz_anchor = require_common.__toESM(require("@coral-xyz/anchor"));
|
|
3
|
+
const __solana_spl_token = require_common.__toESM(require("@solana/spl-token"));
|
|
4
|
+
const __solana_web3_js = require_common.__toESM(require("@solana/web3.js"));
|
|
5
|
+
const bignumber_js = require_common.__toESM(require("bignumber.js"));
|
|
6
|
+
const bn_js = require_common.__toESM(require("bn.js"));
|
|
7
|
+
const bs58 = require_common.__toESM(require("bs58"));
|
|
8
|
+
const unstorage = require_common.__toESM(require("unstorage"));
|
|
9
|
+
const zod_v4_mini = require_common.__toESM(require("zod/v4-mini"));
|
|
10
|
+
const __metaplex_foundation_mpl_token_metadata = require_common.__toESM(require("@metaplex-foundation/mpl-token-metadata"));
|
|
11
|
+
const __metaplex_foundation_umi = require_common.__toESM(require("@metaplex-foundation/umi"));
|
|
12
|
+
const __metaplex_foundation_umi_bundle_defaults = require_common.__toESM(require("@metaplex-foundation/umi-bundle-defaults"));
|
|
13
|
+
const borsh = require_common.__toESM(require("borsh"));
|
|
14
|
+
const __coral_xyz_borsh = require_common.__toESM(require("@coral-xyz/borsh"));
|
|
15
|
+
const big_js = require_common.__toESM(require("big.js"));
|
|
15
16
|
|
|
16
17
|
//#region src/logger.ts
|
|
17
18
|
var NoopLogger = class {
|
|
@@ -53,19 +54,80 @@ var DataFetcher = class {
|
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
//#endregion
|
|
56
|
-
//#region src/services/metadata/
|
|
57
|
-
|
|
58
|
-
name
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
//#region src/services/metadata/dummy.ts
|
|
58
|
+
var DummyMetadataFetcher = class {
|
|
59
|
+
name = "DummyMetadataFetcher";
|
|
60
|
+
async fetch(mints) {
|
|
61
|
+
return mints.reduce((prev, mint) => {
|
|
62
|
+
prev[mint] = {
|
|
63
|
+
name: require_common.shortenAddress(mint),
|
|
64
|
+
symbol: mint.slice(0, 4),
|
|
65
|
+
image: ""
|
|
66
|
+
};
|
|
67
|
+
return prev;
|
|
68
|
+
}, {});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/services/metadata/metaplex.ts
|
|
74
|
+
const imageEndpointSchema = zod_v4_mini.object({ image: zod_v4_mini.string() });
|
|
75
|
+
var MetaplexMetadataFetcher = class {
|
|
76
|
+
name = "MetaplexMetadataFetcher";
|
|
77
|
+
_umi;
|
|
78
|
+
constructor(rpcEndpoint) {
|
|
79
|
+
this._umi = (0, __metaplex_foundation_umi_bundle_defaults.createUmi)(rpcEndpoint).use((0, __metaplex_foundation_mpl_token_metadata.mplTokenMetadata)());
|
|
80
|
+
}
|
|
81
|
+
async fetch(mints) {
|
|
82
|
+
const pdaList = mints.map((mint) => (0, __metaplex_foundation_mpl_token_metadata.findMetadataPda)(this._umi, { mint: (0, __metaplex_foundation_umi.publicKey)(mint) }));
|
|
83
|
+
const fetched = await (0, __metaplex_foundation_mpl_token_metadata.safeFetchAllMetadata)(this._umi, pdaList);
|
|
84
|
+
const metas = await Promise.all(fetched.map(async (meta) => {
|
|
85
|
+
return {
|
|
86
|
+
mint: meta.mint,
|
|
87
|
+
data: {
|
|
88
|
+
name: meta.name,
|
|
89
|
+
symbol: meta.symbol,
|
|
90
|
+
image: await this._getImage(meta),
|
|
91
|
+
uri: meta.uri
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}));
|
|
95
|
+
const result = {};
|
|
96
|
+
for (const { mint, data } of metas) {
|
|
97
|
+
result[mint] = data;
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
async _getImage(metadata$2) {
|
|
102
|
+
try {
|
|
103
|
+
const result = await fetch(metadata$2.uri).then((r) => r.json());
|
|
104
|
+
const parsed = await imageEndpointSchema.parseAsync(result);
|
|
105
|
+
return parsed.image;
|
|
106
|
+
} catch (_) {
|
|
107
|
+
return "";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/services/metadata/service.ts
|
|
114
|
+
const metadataSchema = zod_v4_mini.object({
|
|
115
|
+
name: zod_v4_mini.string(),
|
|
116
|
+
symbol: zod_v4_mini.string(),
|
|
117
|
+
image: zod_v4_mini.string(),
|
|
118
|
+
uri: zod_v4_mini.optional(zod_v4_mini.string())
|
|
61
119
|
});
|
|
62
|
-
var
|
|
120
|
+
var MetadataService = class {
|
|
63
121
|
/** NOTE: record key is base58 of mint public key */
|
|
64
122
|
overrides;
|
|
65
123
|
_storage;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
124
|
+
_fetchers;
|
|
125
|
+
_logger;
|
|
126
|
+
constructor({ storage, logger, fetchers, overrides }) {
|
|
127
|
+
this._storage = (0, unstorage.prefixStorage)(storage, "banks:metadata");
|
|
128
|
+
this.overrides = overrides ?? {};
|
|
129
|
+
this._fetchers = fetchers;
|
|
130
|
+
this._logger = logger;
|
|
69
131
|
}
|
|
70
132
|
async forMints(mints) {
|
|
71
133
|
if (mints.length === 0) return {};
|
|
@@ -87,7 +149,8 @@ var IMetadataService = class {
|
|
|
87
149
|
const meta = {
|
|
88
150
|
name: override?.name ?? fetched[key].name,
|
|
89
151
|
symbol: override?.symbol ?? fetched[key].symbol,
|
|
90
|
-
image: override?.logoURI ?? fetched[key].image
|
|
152
|
+
image: override?.logoURI ?? fetched[key].image,
|
|
153
|
+
uri: fetched[key].uri
|
|
91
154
|
};
|
|
92
155
|
metas[key] = meta;
|
|
93
156
|
await this._storage.set(key, meta);
|
|
@@ -112,13 +175,42 @@ var IMetadataService = class {
|
|
|
112
175
|
});
|
|
113
176
|
return meta;
|
|
114
177
|
}
|
|
178
|
+
async _fetch(mints) {
|
|
179
|
+
const meta = {};
|
|
180
|
+
let remaining = [...mints];
|
|
181
|
+
for (const fetcher of this._fetchers) {
|
|
182
|
+
if (remaining.length === 0) break;
|
|
183
|
+
try {
|
|
184
|
+
const fetched = await fetcher.fetch(remaining);
|
|
185
|
+
for (const key in fetched) {
|
|
186
|
+
meta[key] = fetched[key];
|
|
187
|
+
}
|
|
188
|
+
remaining = remaining.filter((key) => !Object.hasOwn(fetched, key));
|
|
189
|
+
} catch (err) {
|
|
190
|
+
this._logger.debug({
|
|
191
|
+
err,
|
|
192
|
+
remaining,
|
|
193
|
+
mints,
|
|
194
|
+
fetcher: fetcher.name
|
|
195
|
+
}, "failed to fetch metadata");
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (remaining.length > 0) {
|
|
199
|
+
this._logger.warn({
|
|
200
|
+
remaining,
|
|
201
|
+
mints
|
|
202
|
+
}, "failed to fetch metadata for some mints");
|
|
203
|
+
}
|
|
204
|
+
return meta;
|
|
205
|
+
}
|
|
115
206
|
};
|
|
116
207
|
|
|
117
208
|
//#endregion
|
|
118
209
|
//#region src/services/metadata/fogo.ts
|
|
119
|
-
const endpointSchema = z.record(z.string(), metadataSchema);
|
|
120
|
-
var
|
|
121
|
-
|
|
210
|
+
const endpointSchema = zod_v4_mini.z.record(zod_v4_mini.z.string(), metadataSchema);
|
|
211
|
+
var FogoMetadataFetcher = class {
|
|
212
|
+
name = "FogoMetadataFetcher";
|
|
213
|
+
async fetch(mints) {
|
|
122
214
|
if (mints.length === 0) {
|
|
123
215
|
return {};
|
|
124
216
|
}
|
|
@@ -136,9 +228,9 @@ var FogoMetadataService = class extends IMetadataService {
|
|
|
136
228
|
function getConfig({ environment = "production", overrides } = {}) {
|
|
137
229
|
return {
|
|
138
230
|
environment,
|
|
139
|
-
cluster: overrides?.cluster ?? DEFAULT_CLUSTER,
|
|
140
|
-
programId: overrides?.programId ?? PROGRAM_ID,
|
|
141
|
-
groupPk: overrides?.groupPk ?? GROUP_PK
|
|
231
|
+
cluster: overrides?.cluster ?? require_common.DEFAULT_CLUSTER,
|
|
232
|
+
programId: overrides?.programId ?? require_common.PROGRAM_ID,
|
|
233
|
+
groupPk: overrides?.groupPk ?? require_common.GROUP_PK
|
|
142
234
|
};
|
|
143
235
|
}
|
|
144
236
|
|
|
@@ -6168,7 +6260,7 @@ function parseCustomProgramError(logs, ldrProgramId) {
|
|
|
6168
6260
|
};
|
|
6169
6261
|
}
|
|
6170
6262
|
}
|
|
6171
|
-
errorMsg = LangErrorMessage.get(error.code);
|
|
6263
|
+
errorMsg = __coral_xyz_anchor.LangErrorMessage.get(error.code);
|
|
6172
6264
|
if (errorMsg !== undefined) {
|
|
6173
6265
|
return {
|
|
6174
6266
|
code: error.code,
|
|
@@ -6278,7 +6370,7 @@ const JupiterErrorCodeMap = new Map([
|
|
|
6278
6370
|
[JupiterErrorCode.ExactOutAmountNotMatched, "Exact out amount doesn't match"],
|
|
6279
6371
|
[JupiterErrorCode.SourceAndDestinationMintCannotBeTheSame, "Source mint and destination mint cannot the same"]
|
|
6280
6372
|
]);
|
|
6281
|
-
const ERROR_CODE_MAPS = new Map([[TOKEN_PROGRAM_ID.toBase58(), TokenErrorCodeMap], [JUPITER_V6_PROGRAM.toBase58(), JupiterErrorCodeMap]]);
|
|
6373
|
+
const ERROR_CODE_MAPS = new Map([[__solana_spl_token.TOKEN_PROGRAM_ID.toBase58(), TokenErrorCodeMap], [require_common.JUPITER_V6_PROGRAM.toBase58(), JupiterErrorCodeMap]]);
|
|
6282
6374
|
|
|
6283
6375
|
//#endregion
|
|
6284
6376
|
//#region src/idl/idl.utils.ts
|
|
@@ -6452,8 +6544,8 @@ async function makeLendingPoolConfigureBankOracleIx(ldProgram, accounts$2, args,
|
|
|
6452
6544
|
* @param args - Optional arguments for this instruction
|
|
6453
6545
|
*/
|
|
6454
6546
|
async function makePoolAddPermissionlessStakedBankIx(ldProgram, accounts$2, remainingAccounts = [], args) {
|
|
6455
|
-
const { stakedSettings, feePayer, bankMint, solPool, stakePool, tokenProgram = TOKEN_PROGRAM_ID,...optionalAccounts } = accounts$2;
|
|
6456
|
-
return ldProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new
|
|
6547
|
+
const { stakedSettings, feePayer, bankMint, solPool, stakePool, tokenProgram = __solana_spl_token.TOKEN_PROGRAM_ID,...optionalAccounts } = accounts$2;
|
|
6548
|
+
return ldProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new bn_js.default(0)).accounts({
|
|
6457
6549
|
stakedSettings,
|
|
6458
6550
|
feePayer,
|
|
6459
6551
|
bankMint,
|
|
@@ -6627,13 +6719,13 @@ var HealthCache = class HealthCache {
|
|
|
6627
6719
|
this.simulationFailed = simulationFailed;
|
|
6628
6720
|
}
|
|
6629
6721
|
static from(healthCacheRaw) {
|
|
6630
|
-
const assetValue = wrappedI80F48toBigNumber(healthCacheRaw.assetValue);
|
|
6631
|
-
const liabilityValue = wrappedI80F48toBigNumber(healthCacheRaw.liabilityValue);
|
|
6632
|
-
const assetValueMaint = wrappedI80F48toBigNumber(healthCacheRaw.assetValueMaint);
|
|
6633
|
-
const liabilityValueMaint = wrappedI80F48toBigNumber(healthCacheRaw.liabilityValueMaint);
|
|
6634
|
-
const assetValueEquity = wrappedI80F48toBigNumber(healthCacheRaw.assetValueEquity);
|
|
6635
|
-
const liabilityValueEquity = wrappedI80F48toBigNumber(healthCacheRaw.liabilityValueEquity);
|
|
6636
|
-
const timestamp = toBigNumber(healthCacheRaw.timestamp);
|
|
6722
|
+
const assetValue = require_common.wrappedI80F48toBigNumber(healthCacheRaw.assetValue);
|
|
6723
|
+
const liabilityValue = require_common.wrappedI80F48toBigNumber(healthCacheRaw.liabilityValue);
|
|
6724
|
+
const assetValueMaint = require_common.wrappedI80F48toBigNumber(healthCacheRaw.assetValueMaint);
|
|
6725
|
+
const liabilityValueMaint = require_common.wrappedI80F48toBigNumber(healthCacheRaw.liabilityValueMaint);
|
|
6726
|
+
const assetValueEquity = require_common.wrappedI80F48toBigNumber(healthCacheRaw.assetValueEquity);
|
|
6727
|
+
const liabilityValueEquity = require_common.wrappedI80F48toBigNumber(healthCacheRaw.liabilityValueEquity);
|
|
6728
|
+
const timestamp = require_common.toBigNumber(healthCacheRaw.timestamp);
|
|
6637
6729
|
const flags = getActiveHealthCacheFlags(healthCacheRaw.flags);
|
|
6638
6730
|
const prices = healthCacheRaw.prices;
|
|
6639
6731
|
return new HealthCache(assetValue, liabilityValue, assetValueMaint, liabilityValueMaint, assetValueEquity, liabilityValueEquity, timestamp, flags, prices);
|
|
@@ -8961,9 +9053,9 @@ const PYTH_SOLANA_RECEIVER_PROGRAM_IDL = {
|
|
|
8961
9053
|
|
|
8962
9054
|
//#endregion
|
|
8963
9055
|
//#region src/vendor/pyth_crank/pyth.consts.ts
|
|
8964
|
-
const DEFAULT_RECEIVER_PROGRAM_ID = new PublicKey("rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ");
|
|
8965
|
-
const DEFAULT_WORMHOLE_PROGRAM_ID = new PublicKey("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ");
|
|
8966
|
-
const DEFAULT_PUSH_ORACLE_PROGRAM_ID = new PublicKey("pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT");
|
|
9056
|
+
const DEFAULT_RECEIVER_PROGRAM_ID = new __solana_web3_js.PublicKey("rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ");
|
|
9057
|
+
const DEFAULT_WORMHOLE_PROGRAM_ID = new __solana_web3_js.PublicKey("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ");
|
|
9058
|
+
const DEFAULT_PUSH_ORACLE_PROGRAM_ID = new __solana_web3_js.PublicKey("pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT");
|
|
8967
9059
|
const ACCUMULATOR_MAGIC = "504e4155";
|
|
8968
9060
|
const MAJOR_VERSION = 1;
|
|
8969
9061
|
const MINOR_VERSION = 0;
|
|
@@ -9077,7 +9169,7 @@ async function buildPostEncodedVaaInstructions(wormhole, vaa) {
|
|
|
9077
9169
|
};
|
|
9078
9170
|
}
|
|
9079
9171
|
async function generateVaaInstructionGroups(wormhole, vaa) {
|
|
9080
|
-
const encodedVaaKeypair = new Keypair();
|
|
9172
|
+
const encodedVaaKeypair = new __solana_web3_js.Keypair();
|
|
9081
9173
|
const initInstructions = [await buildEncodedVaaCreateInstruction(wormhole, vaa, encodedVaaKeypair), {
|
|
9082
9174
|
instruction: await wormhole.methods.initEncodedVaa().accounts({ encodedVaa: encodedVaaKeypair.publicKey }).instruction(),
|
|
9083
9175
|
signers: [],
|
|
@@ -9137,7 +9229,7 @@ async function buildEncodedVaaCreateInstruction(wormhole, vaa, encodedVaaKeypair
|
|
|
9137
9229
|
const getGuardianSetPda = (guardianSetIndex, wormholeProgramId) => {
|
|
9138
9230
|
const guardianSetIndexBuf = Buffer.alloc(4);
|
|
9139
9231
|
guardianSetIndexBuf.writeUInt32BE(guardianSetIndex, 0);
|
|
9140
|
-
return PublicKey.findProgramAddressSync([Buffer.from("GuardianSet"), guardianSetIndexBuf], wormholeProgramId)[0];
|
|
9232
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("GuardianSet"), guardianSetIndexBuf], wormholeProgramId)[0];
|
|
9141
9233
|
};
|
|
9142
9234
|
function parsePriceFeedMessage(message) {
|
|
9143
9235
|
let cursor = 0;
|
|
@@ -9148,19 +9240,19 @@ function parsePriceFeedMessage(message) {
|
|
|
9148
9240
|
cursor += 1;
|
|
9149
9241
|
const feedId = message.subarray(cursor, cursor + 32);
|
|
9150
9242
|
cursor += 32;
|
|
9151
|
-
const price = new
|
|
9243
|
+
const price = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9152
9244
|
cursor += 8;
|
|
9153
|
-
const confidence = new
|
|
9245
|
+
const confidence = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9154
9246
|
cursor += 8;
|
|
9155
9247
|
const exponent = message.readInt32BE(cursor);
|
|
9156
9248
|
cursor += 4;
|
|
9157
|
-
const publishTime = new
|
|
9249
|
+
const publishTime = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9158
9250
|
cursor += 8;
|
|
9159
|
-
const prevPublishTime = new
|
|
9251
|
+
const prevPublishTime = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9160
9252
|
cursor += 8;
|
|
9161
|
-
const emaPrice = new
|
|
9253
|
+
const emaPrice = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9162
9254
|
cursor += 8;
|
|
9163
|
-
const emaConf = new
|
|
9255
|
+
const emaConf = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9164
9256
|
cursor += 8;
|
|
9165
9257
|
return {
|
|
9166
9258
|
feedId,
|
|
@@ -9222,7 +9314,7 @@ function readBigUInt64LE(buffer, offset = 0) {
|
|
|
9222
9314
|
/** Number of slots that can pass before a publisher's price is no longer included in the aggregate. */
|
|
9223
9315
|
const MAX_SLOT_DIFFERENCE = 25;
|
|
9224
9316
|
const empty32Buffer = Buffer.alloc(32);
|
|
9225
|
-
const PKorNull = (data) => data.equals(empty32Buffer) ? null : new PublicKey(data);
|
|
9317
|
+
const PKorNull = (data) => data.equals(empty32Buffer) ? null : new __solana_web3_js.PublicKey(data);
|
|
9226
9318
|
let PriceStatus = /* @__PURE__ */ function(PriceStatus$1) {
|
|
9227
9319
|
PriceStatus$1[PriceStatus$1["Unknown"] = 0] = "Unknown";
|
|
9228
9320
|
PriceStatus$1[PriceStatus$1["Trading"] = 1] = "Trading";
|
|
@@ -9285,7 +9377,7 @@ const parsePriceData = (data, currentSlot) => {
|
|
|
9285
9377
|
const drv2 = data.readInt8(105);
|
|
9286
9378
|
const drv3 = data.readInt16LE(106);
|
|
9287
9379
|
const drv4 = data.readInt32LE(108);
|
|
9288
|
-
const productAccountKey = new PublicKey(data.slice(112, 144));
|
|
9380
|
+
const productAccountKey = new __solana_web3_js.PublicKey(data.slice(112, 144));
|
|
9289
9381
|
const nextPriceAccountKey = PKorNull(data.slice(144, 176));
|
|
9290
9382
|
const previousSlot = readBigUInt64LE(data, 176);
|
|
9291
9383
|
const previousPriceComponent = readBigInt64LE(data, 184);
|
|
@@ -9309,7 +9401,7 @@ const parsePriceData = (data, currentSlot) => {
|
|
|
9309
9401
|
const priceComponents = [];
|
|
9310
9402
|
let offset = 240;
|
|
9311
9403
|
while (priceComponents.length < numComponentPrices) {
|
|
9312
|
-
const publisher = new PublicKey(data.slice(offset, offset + 32));
|
|
9404
|
+
const publisher = new __solana_web3_js.PublicKey(data.slice(offset, offset + 32));
|
|
9313
9405
|
offset += 32;
|
|
9314
9406
|
const componentAggregate = parsePriceInfo$1(data.slice(offset, offset + 32), exponent);
|
|
9315
9407
|
offset += 32;
|
|
@@ -9391,12 +9483,12 @@ const priceUpdateV2Schema = { struct: {
|
|
|
9391
9483
|
postedSlot: "u64"
|
|
9392
9484
|
} };
|
|
9393
9485
|
const parsePriceInfo = (data) => {
|
|
9394
|
-
const decoded = borsh
|
|
9486
|
+
const decoded = borsh.deserialize(priceUpdateV2Schema, data);
|
|
9395
9487
|
return decoded;
|
|
9396
9488
|
};
|
|
9397
9489
|
function capConfidenceInterval$1(price, confidence, maxConfidence) {
|
|
9398
9490
|
const maxConfidenceInterval = price.times(maxConfidence);
|
|
9399
|
-
return
|
|
9491
|
+
return bignumber_js.default.min(confidence, maxConfidenceInterval);
|
|
9400
9492
|
}
|
|
9401
9493
|
|
|
9402
9494
|
//#endregion
|
|
@@ -9411,7 +9503,7 @@ var Account = class {
|
|
|
9411
9503
|
*/
|
|
9412
9504
|
constructor(program, publicKey) {
|
|
9413
9505
|
this.program = program;
|
|
9414
|
-
this.publicKey = typeof publicKey === "string" ? new
|
|
9506
|
+
this.publicKey = typeof publicKey === "string" ? new __coral_xyz_anchor.web3.PublicKey(publicKey) : publicKey;
|
|
9415
9507
|
}
|
|
9416
9508
|
};
|
|
9417
9509
|
const BUFFER_DISCRIMINATOR = Buffer.from([
|
|
@@ -9486,7 +9578,7 @@ function fromJSON(obj) {
|
|
|
9486
9578
|
}
|
|
9487
9579
|
}
|
|
9488
9580
|
function layout(property) {
|
|
9489
|
-
const ret =
|
|
9581
|
+
const ret = __coral_xyz_borsh.rustEnum([__coral_xyz_borsh.struct([], "ModeRoundResolution"), __coral_xyz_borsh.struct([], "ModeSlidingResolution")]);
|
|
9490
9582
|
if (property !== undefined) {
|
|
9491
9583
|
return ret.replicate(property);
|
|
9492
9584
|
}
|
|
@@ -9508,7 +9600,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9508
9600
|
this.scale = fields.scale;
|
|
9509
9601
|
}
|
|
9510
9602
|
static layout(property) {
|
|
9511
|
-
return
|
|
9603
|
+
return __coral_xyz_borsh.struct([__coral_xyz_borsh.i128("mantissa"), __coral_xyz_borsh.u32("scale")], property);
|
|
9512
9604
|
}
|
|
9513
9605
|
static fromDecoded(obj) {
|
|
9514
9606
|
return new SwitchboardDecimal({
|
|
@@ -9530,7 +9622,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9530
9622
|
}
|
|
9531
9623
|
static fromJSON(obj) {
|
|
9532
9624
|
return new SwitchboardDecimal({
|
|
9533
|
-
mantissa: new
|
|
9625
|
+
mantissa: new bn_js.default(obj.mantissa),
|
|
9534
9626
|
scale: obj.scale
|
|
9535
9627
|
});
|
|
9536
9628
|
}
|
|
@@ -9541,7 +9633,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9541
9633
|
*/
|
|
9542
9634
|
static from(obj) {
|
|
9543
9635
|
return new SwitchboardDecimal({
|
|
9544
|
-
mantissa: new
|
|
9636
|
+
mantissa: new bn_js.default(obj.mantissa),
|
|
9545
9637
|
scale: obj.scale
|
|
9546
9638
|
});
|
|
9547
9639
|
}
|
|
@@ -9552,10 +9644,10 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9552
9644
|
*/
|
|
9553
9645
|
static fromBig(big) {
|
|
9554
9646
|
big = big.round(20);
|
|
9555
|
-
let mantissa = new
|
|
9647
|
+
let mantissa = new bn_js.default(big.c.join(""), 10);
|
|
9556
9648
|
let scale = big.c.slice(1).length - big.e;
|
|
9557
9649
|
if (scale < 0) {
|
|
9558
|
-
mantissa = mantissa.mul(new
|
|
9650
|
+
mantissa = mantissa.mul(new bn_js.default(10, 10).pow(new bn_js.default(Math.abs(scale), 10)));
|
|
9559
9651
|
scale = 0;
|
|
9560
9652
|
}
|
|
9561
9653
|
if (scale < 0) {
|
|
@@ -9564,7 +9656,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9564
9656
|
if (scale >= 28) {
|
|
9565
9657
|
throw new Error("SwitchboardDecimalExcessiveScaleError");
|
|
9566
9658
|
}
|
|
9567
|
-
mantissa = mantissa.mul(new
|
|
9659
|
+
mantissa = mantissa.mul(new bn_js.default(big.s, 10));
|
|
9568
9660
|
const result = new SwitchboardDecimal({
|
|
9569
9661
|
mantissa,
|
|
9570
9662
|
scale
|
|
@@ -9584,11 +9676,11 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9584
9676
|
* @return Big representation
|
|
9585
9677
|
*/
|
|
9586
9678
|
toBig() {
|
|
9587
|
-
let mantissa = new
|
|
9679
|
+
let mantissa = new bn_js.default(this.mantissa, 10);
|
|
9588
9680
|
let s = 1;
|
|
9589
9681
|
const c = [];
|
|
9590
|
-
const ZERO = new
|
|
9591
|
-
const TEN = new
|
|
9682
|
+
const ZERO = new bn_js.default(0, 10);
|
|
9683
|
+
const TEN = new bn_js.default(10, 10);
|
|
9592
9684
|
if (mantissa.lt(ZERO)) {
|
|
9593
9685
|
s = -1;
|
|
9594
9686
|
mantissa = mantissa.abs();
|
|
@@ -9598,7 +9690,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9598
9690
|
mantissa = mantissa.div(TEN);
|
|
9599
9691
|
}
|
|
9600
9692
|
const e = c.length - this.scale - 1;
|
|
9601
|
-
const result = new
|
|
9693
|
+
const result = new big_js.default(0);
|
|
9602
9694
|
if (c.length === 0) {
|
|
9603
9695
|
return result;
|
|
9604
9696
|
}
|
|
@@ -9660,21 +9752,21 @@ var AggregatorRound = class AggregatorRound {
|
|
|
9660
9752
|
this.errorsFulfilled = fields.errorsFulfilled;
|
|
9661
9753
|
}
|
|
9662
9754
|
static layout(property) {
|
|
9663
|
-
return
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9755
|
+
return __coral_xyz_borsh.struct([
|
|
9756
|
+
__coral_xyz_borsh.u32("numSuccess"),
|
|
9757
|
+
__coral_xyz_borsh.u32("numError"),
|
|
9758
|
+
__coral_xyz_borsh.bool("isClosed"),
|
|
9759
|
+
__coral_xyz_borsh.u64("roundOpenSlot"),
|
|
9760
|
+
__coral_xyz_borsh.i64("roundOpenTimestamp"),
|
|
9669
9761
|
SwitchboardDecimal.layout("result"),
|
|
9670
9762
|
SwitchboardDecimal.layout("stdDeviation"),
|
|
9671
9763
|
SwitchboardDecimal.layout("minResponse"),
|
|
9672
9764
|
SwitchboardDecimal.layout("maxResponse"),
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9765
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.publicKey(), 16, "oraclePubkeysData"),
|
|
9766
|
+
__coral_xyz_borsh.array(SwitchboardDecimal.layout({}), 16, "mediansData"),
|
|
9767
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.i64(), 16, "currentPayout"),
|
|
9768
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.bool(), 16, "mediansFulfilled"),
|
|
9769
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.bool(), 16, "errorsFulfilled")
|
|
9678
9770
|
], property);
|
|
9679
9771
|
}
|
|
9680
9772
|
static fromDecoded(obj) {
|
|
@@ -9736,15 +9828,15 @@ var AggregatorRound = class AggregatorRound {
|
|
|
9736
9828
|
numSuccess: obj.numSuccess,
|
|
9737
9829
|
numError: obj.numError,
|
|
9738
9830
|
isClosed: obj.isClosed,
|
|
9739
|
-
roundOpenSlot: new
|
|
9740
|
-
roundOpenTimestamp: new
|
|
9831
|
+
roundOpenSlot: new bn_js.default(obj.roundOpenSlot),
|
|
9832
|
+
roundOpenTimestamp: new bn_js.default(obj.roundOpenTimestamp),
|
|
9741
9833
|
result: SwitchboardDecimal.fromJSON(obj.result),
|
|
9742
9834
|
stdDeviation: SwitchboardDecimal.fromJSON(obj.stdDeviation),
|
|
9743
9835
|
minResponse: SwitchboardDecimal.fromJSON(obj.minResponse),
|
|
9744
9836
|
maxResponse: SwitchboardDecimal.fromJSON(obj.maxResponse),
|
|
9745
|
-
oraclePubkeysData: obj.oraclePubkeysData.map((item) => new PublicKey(item)),
|
|
9837
|
+
oraclePubkeysData: obj.oraclePubkeysData.map((item) => new __solana_web3_js.PublicKey(item)),
|
|
9746
9838
|
mediansData: obj.mediansData.map((item) => SwitchboardDecimal.fromJSON(item)),
|
|
9747
|
-
currentPayout: obj.currentPayout.map((item) => new
|
|
9839
|
+
currentPayout: obj.currentPayout.map((item) => new bn_js.default(item)),
|
|
9748
9840
|
mediansFulfilled: obj.mediansFulfilled,
|
|
9749
9841
|
errorsFulfilled: obj.errorsFulfilled
|
|
9750
9842
|
});
|
|
@@ -9763,7 +9855,7 @@ var Hash = class Hash {
|
|
|
9763
9855
|
this.data = fields.data;
|
|
9764
9856
|
}
|
|
9765
9857
|
static layout(property) {
|
|
9766
|
-
return
|
|
9858
|
+
return __coral_xyz_borsh.struct([__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 32, "data")], property);
|
|
9767
9859
|
}
|
|
9768
9860
|
static fromDecoded(obj) {
|
|
9769
9861
|
return new Hash({ data: obj.data });
|
|
@@ -9867,42 +9959,42 @@ var AggregatorAccountData = class AggregatorAccountData {
|
|
|
9867
9959
|
27,
|
|
9868
9960
|
125
|
|
9869
9961
|
]);
|
|
9870
|
-
static layout =
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9962
|
+
static layout = __coral_xyz_borsh.struct([
|
|
9963
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 32, "name"),
|
|
9964
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 128, "metadata"),
|
|
9965
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 32, "reserved1"),
|
|
9966
|
+
__coral_xyz_borsh.publicKey("queuePubkey"),
|
|
9967
|
+
__coral_xyz_borsh.u32("oracleRequestBatchSize"),
|
|
9968
|
+
__coral_xyz_borsh.u32("minOracleResults"),
|
|
9969
|
+
__coral_xyz_borsh.u32("minJobResults"),
|
|
9970
|
+
__coral_xyz_borsh.u32("minUpdateDelaySeconds"),
|
|
9971
|
+
__coral_xyz_borsh.i64("startAfter"),
|
|
9880
9972
|
SwitchboardDecimal.layout("varianceThreshold"),
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9973
|
+
__coral_xyz_borsh.i64("forceReportPeriod"),
|
|
9974
|
+
__coral_xyz_borsh.i64("expiration"),
|
|
9975
|
+
__coral_xyz_borsh.u64("consecutiveFailureCount"),
|
|
9976
|
+
__coral_xyz_borsh.i64("nextAllowedUpdateTime"),
|
|
9977
|
+
__coral_xyz_borsh.bool("isLocked"),
|
|
9978
|
+
__coral_xyz_borsh.publicKey("crankPubkey"),
|
|
9887
9979
|
AggregatorRound.layout("latestConfirmedRound"),
|
|
9888
9980
|
AggregatorRound.layout("currentRound"),
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9981
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.publicKey(), 16, "jobPubkeysData"),
|
|
9982
|
+
__coral_xyz_borsh.array(Hash.layout({}), 16, "jobHashes"),
|
|
9983
|
+
__coral_xyz_borsh.u32("jobPubkeysSize"),
|
|
9984
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 32, "jobsChecksum"),
|
|
9985
|
+
__coral_xyz_borsh.publicKey("authority"),
|
|
9986
|
+
__coral_xyz_borsh.publicKey("historyBuffer"),
|
|
9895
9987
|
SwitchboardDecimal.layout("previousConfirmedRoundResult"),
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9988
|
+
__coral_xyz_borsh.u64("previousConfirmedRoundSlot"),
|
|
9989
|
+
__coral_xyz_borsh.bool("disableCrank"),
|
|
9990
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 16, "jobWeights"),
|
|
9991
|
+
__coral_xyz_borsh.i64("creationTimestamp"),
|
|
9900
9992
|
layout("resolutionMode"),
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9993
|
+
__coral_xyz_borsh.u32("basePriorityFee"),
|
|
9994
|
+
__coral_xyz_borsh.u32("priorityFeeBump"),
|
|
9995
|
+
__coral_xyz_borsh.u32("priorityFeeBumpPeriod"),
|
|
9996
|
+
__coral_xyz_borsh.u32("maxPriorityFeeMultiplier"),
|
|
9997
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 122, "ebuf")
|
|
9906
9998
|
]);
|
|
9907
9999
|
constructor(fields) {
|
|
9908
10000
|
this.name = fields.name;
|
|
@@ -13652,9 +13744,9 @@ var idl_default = {
|
|
|
13652
13744
|
//#endregion
|
|
13653
13745
|
//#region src/vendor/switchboard_pull/index.ts
|
|
13654
13746
|
const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
|
|
13655
|
-
const switchboardAccountCoder = new BorshCoder(idl_default);
|
|
13747
|
+
const switchboardAccountCoder = new __coral_xyz_anchor.BorshCoder(idl_default);
|
|
13656
13748
|
function getSwitchboardProgram(provider) {
|
|
13657
|
-
return new Program(idl_default, provider);
|
|
13749
|
+
return new __coral_xyz_anchor.Program(idl_default, provider);
|
|
13658
13750
|
}
|
|
13659
13751
|
function decodeSwitchboardPullFeedData(data) {
|
|
13660
13752
|
const pullFeedDAta = switchboardAccountCoder.accounts.decode("PullFeedAccountData", data);
|
|
@@ -13676,7 +13768,17 @@ function getPrice(oraclePrice, priceBias = PriceBias.None, weightedPrice = false
|
|
|
13676
13768
|
}
|
|
13677
13769
|
function capConfidenceInterval(price, confidence, maxConfidence) {
|
|
13678
13770
|
const maxConfidenceInterval = price.times(maxConfidence);
|
|
13679
|
-
return
|
|
13771
|
+
return bignumber_js.default.min(confidence, maxConfidenceInterval);
|
|
13772
|
+
}
|
|
13773
|
+
const supportedOracleSetups = [
|
|
13774
|
+
OracleSetup.PythLegacy,
|
|
13775
|
+
OracleSetup.PythPushOracle,
|
|
13776
|
+
OracleSetup.StakedWithPythPush,
|
|
13777
|
+
OracleSetup.SwitchboardV2,
|
|
13778
|
+
OracleSetup.SwitchboardPull
|
|
13779
|
+
];
|
|
13780
|
+
function isOracleSetupSupported(oracleSetup) {
|
|
13781
|
+
return supportedOracleSetups.includes(oracleSetup);
|
|
13680
13782
|
}
|
|
13681
13783
|
function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), shardId) {
|
|
13682
13784
|
switch (oracleSetup) {
|
|
@@ -13690,14 +13792,14 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13690
13792
|
if (confidenceData === undefined) {
|
|
13691
13793
|
confidenceData = pythPriceData.previousConfidence;
|
|
13692
13794
|
}
|
|
13693
|
-
const pythPriceRealtime = new
|
|
13694
|
-
const pythConfidenceRealtime = new
|
|
13695
|
-
const pythConfidenceRealtimeCapped = capConfidenceInterval(pythPriceRealtime, pythConfidenceRealtime, PYTH_PRICE_CONF_INTERVALS);
|
|
13795
|
+
const pythPriceRealtime = new bignumber_js.default(priceData);
|
|
13796
|
+
const pythConfidenceRealtime = new bignumber_js.default(confidenceData).times(require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13797
|
+
const pythConfidenceRealtimeCapped = capConfidenceInterval(pythPriceRealtime, pythConfidenceRealtime, require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13696
13798
|
const pythLowestPriceRealtime = pythPriceRealtime.minus(pythConfidenceRealtimeCapped);
|
|
13697
13799
|
const pythHighestPriceRealtime = pythPriceRealtime.plus(pythConfidenceRealtimeCapped);
|
|
13698
|
-
const pythPriceWeighted = new
|
|
13699
|
-
const pythConfIntervalWeighted = new
|
|
13700
|
-
const pythConfIntervalWeightedCapped = capConfidenceInterval(pythPriceWeighted, pythConfIntervalWeighted, PYTH_PRICE_CONF_INTERVALS);
|
|
13800
|
+
const pythPriceWeighted = new bignumber_js.default(pythPriceData.emaPrice.value);
|
|
13801
|
+
const pythConfIntervalWeighted = new bignumber_js.default(pythPriceData.emaConfidence.value).times(require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13802
|
+
const pythConfIntervalWeightedCapped = capConfidenceInterval(pythPriceWeighted, pythConfIntervalWeighted, require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13701
13803
|
const pythLowestPrice = pythPriceWeighted.minus(pythConfIntervalWeightedCapped);
|
|
13702
13804
|
const pythHighestPrice = pythPriceWeighted.plus(pythConfIntervalWeightedCapped);
|
|
13703
13805
|
logger.debug({
|
|
@@ -13719,7 +13821,7 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13719
13821
|
lowestPrice: pythLowestPrice,
|
|
13720
13822
|
highestPrice: pythHighestPrice
|
|
13721
13823
|
},
|
|
13722
|
-
timestamp: new
|
|
13824
|
+
timestamp: new bignumber_js.default(Number(pythPriceData.timestamp)),
|
|
13723
13825
|
pythShardId: shardId
|
|
13724
13826
|
};
|
|
13725
13827
|
}
|
|
@@ -13727,15 +13829,15 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13727
13829
|
case OracleSetup.StakedWithPythPush: {
|
|
13728
13830
|
const bytesWithoutDiscriminator = rawData.slice(8);
|
|
13729
13831
|
const data = parsePriceInfo(bytesWithoutDiscriminator);
|
|
13730
|
-
const exponent = new
|
|
13731
|
-
const priceRealTime = new
|
|
13732
|
-
const confidenceRealTime = new
|
|
13733
|
-
const cappedConfidenceRealTime = capConfidenceInterval(priceRealTime, confidenceRealTime, MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13832
|
+
const exponent = new bignumber_js.default(10 ** data.priceMessage.exponent);
|
|
13833
|
+
const priceRealTime = new bignumber_js.default(Number(data.priceMessage.price)).times(exponent);
|
|
13834
|
+
const confidenceRealTime = new bignumber_js.default(Number(data.priceMessage.conf)).times(exponent).times(require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13835
|
+
const cappedConfidenceRealTime = capConfidenceInterval(priceRealTime, confidenceRealTime, require_common.MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13734
13836
|
const lowestPriceRealTime = priceRealTime.minus(cappedConfidenceRealTime);
|
|
13735
13837
|
const highestPriceRealTime = priceRealTime.plus(cappedConfidenceRealTime);
|
|
13736
|
-
const priceTimeWeighted = new
|
|
13737
|
-
const confidenceTimeWeighted = new
|
|
13738
|
-
const cappedConfidenceWeighted = capConfidenceInterval(priceTimeWeighted, confidenceTimeWeighted, MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13838
|
+
const priceTimeWeighted = new bignumber_js.default(Number(data.priceMessage.emaPrice)).times(exponent);
|
|
13839
|
+
const confidenceTimeWeighted = new bignumber_js.default(Number(data.priceMessage.emaConf)).times(exponent).times(require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13840
|
+
const cappedConfidenceWeighted = capConfidenceInterval(priceTimeWeighted, confidenceTimeWeighted, require_common.MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13739
13841
|
const lowestPriceWeighted = priceTimeWeighted.minus(cappedConfidenceWeighted);
|
|
13740
13842
|
const highestPriceWeighted = priceTimeWeighted.plus(cappedConfidenceWeighted);
|
|
13741
13843
|
return {
|
|
@@ -13751,15 +13853,15 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13751
13853
|
lowestPrice: lowestPriceWeighted,
|
|
13752
13854
|
highestPrice: highestPriceWeighted
|
|
13753
13855
|
},
|
|
13754
|
-
timestamp: new
|
|
13856
|
+
timestamp: new bignumber_js.default(Number(data.priceMessage.publishTime)),
|
|
13755
13857
|
pythShardId: shardId
|
|
13756
13858
|
};
|
|
13757
13859
|
}
|
|
13758
13860
|
case OracleSetup.SwitchboardV2: {
|
|
13759
13861
|
const aggData = AggregatorAccountData.decode(rawData);
|
|
13760
|
-
const swbPrice = new
|
|
13761
|
-
const swbConfidence = new
|
|
13762
|
-
const swbConfidenceCapped = capConfidenceInterval(swbPrice, swbConfidence, MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13862
|
+
const swbPrice = new bignumber_js.default(AggregatorAccount.decodeLatestValue(aggData).toString());
|
|
13863
|
+
const swbConfidence = new bignumber_js.default(aggData.latestConfirmedRound.stdDeviation.toBig().toString()).times(require_common.SWB_PRICE_CONF_INTERVALS);
|
|
13864
|
+
const swbConfidenceCapped = capConfidenceInterval(swbPrice, swbConfidence, require_common.MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13763
13865
|
const swbLowestPrice = swbPrice.minus(swbConfidenceCapped);
|
|
13764
13866
|
const swbHighestPrice = swbPrice.plus(swbConfidenceCapped);
|
|
13765
13867
|
logger.debug({
|
|
@@ -13779,14 +13881,14 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13779
13881
|
lowestPrice: swbLowestPrice,
|
|
13780
13882
|
highestPrice: swbHighestPrice
|
|
13781
13883
|
},
|
|
13782
|
-
timestamp: new
|
|
13884
|
+
timestamp: new bignumber_js.default(aggData.latestConfirmedRound.roundOpenTimestamp)
|
|
13783
13885
|
};
|
|
13784
13886
|
}
|
|
13785
13887
|
case OracleSetup.SwitchboardPull: {
|
|
13786
13888
|
const pullFeedDAta = decodeSwitchboardPullFeedData(rawData);
|
|
13787
|
-
const swbPrice = new
|
|
13788
|
-
const swbConfidence = new
|
|
13789
|
-
const swbConfidenceCapped = capConfidenceInterval(swbPrice, swbConfidence, MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13889
|
+
const swbPrice = new bignumber_js.default(pullFeedDAta.result.value.toString()).div(10 ** SWITCHBOARD_ONDEMANDE_PRICE_PRECISION);
|
|
13890
|
+
const swbConfidence = new bignumber_js.default(pullFeedDAta.result.std_dev.toString()).times(require_common.SWB_PRICE_CONF_INTERVALS);
|
|
13891
|
+
const swbConfidenceCapped = capConfidenceInterval(swbPrice, swbConfidence, require_common.MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13790
13892
|
const swbLowestPrice = swbPrice.minus(swbConfidenceCapped);
|
|
13791
13893
|
const swbHighestPrice = swbPrice.plus(swbConfidenceCapped);
|
|
13792
13894
|
logger.debug({
|
|
@@ -13806,7 +13908,7 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13806
13908
|
lowestPrice: swbLowestPrice,
|
|
13807
13909
|
highestPrice: swbHighestPrice
|
|
13808
13910
|
},
|
|
13809
|
-
timestamp: new
|
|
13911
|
+
timestamp: new bignumber_js.default(pullFeedDAta.last_update_timestamp.toString())
|
|
13810
13912
|
};
|
|
13811
13913
|
}
|
|
13812
13914
|
default:
|
|
@@ -13820,18 +13922,18 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13820
13922
|
function dtoToOraclePrice(dto) {
|
|
13821
13923
|
return {
|
|
13822
13924
|
priceRealtime: {
|
|
13823
|
-
price: new
|
|
13824
|
-
confidence: new
|
|
13825
|
-
lowestPrice: new
|
|
13826
|
-
highestPrice: new
|
|
13925
|
+
price: new bignumber_js.default(dto.priceRealtime.price),
|
|
13926
|
+
confidence: new bignumber_js.default(dto.priceRealtime.confidence),
|
|
13927
|
+
lowestPrice: new bignumber_js.default(dto.priceRealtime.lowestPrice),
|
|
13928
|
+
highestPrice: new bignumber_js.default(dto.priceRealtime.highestPrice)
|
|
13827
13929
|
},
|
|
13828
13930
|
priceWeighted: {
|
|
13829
|
-
price: new
|
|
13830
|
-
confidence: new
|
|
13831
|
-
lowestPrice: new
|
|
13832
|
-
highestPrice: new
|
|
13931
|
+
price: new bignumber_js.default(dto.priceWeighted.price),
|
|
13932
|
+
confidence: new bignumber_js.default(dto.priceWeighted.confidence),
|
|
13933
|
+
lowestPrice: new bignumber_js.default(dto.priceWeighted.lowestPrice),
|
|
13934
|
+
highestPrice: new bignumber_js.default(dto.priceWeighted.highestPrice)
|
|
13833
13935
|
},
|
|
13834
|
-
timestamp: new
|
|
13936
|
+
timestamp: new bignumber_js.default(dto.timestamp),
|
|
13835
13937
|
pythShardId: dto.pythShardId
|
|
13836
13938
|
};
|
|
13837
13939
|
}
|
|
@@ -13870,7 +13972,7 @@ const fetchPythDataViaAPI = async (pythPushBanks, voteAccMintTuples) => {
|
|
|
13870
13972
|
const pythFeedMap = new Map();
|
|
13871
13973
|
Object.entries(pythFeedMapJson).forEach(([feedId, { feedId: feedIdStr, shardId }]) => {
|
|
13872
13974
|
pythFeedMap.set(feedId, {
|
|
13873
|
-
feedId: new PublicKey(feedIdStr),
|
|
13975
|
+
feedId: new __solana_web3_js.PublicKey(feedIdStr),
|
|
13874
13976
|
shardId
|
|
13875
13977
|
});
|
|
13876
13978
|
});
|
|
@@ -13928,18 +14030,18 @@ const fetchPythOraclePricesViaAPI = async (pythOracleKeys) => {
|
|
|
13928
14030
|
const responseBody = await response.json();
|
|
13929
14031
|
return Object.fromEntries(Object.entries(responseBody).map(([key, oraclePrice]) => [key, {
|
|
13930
14032
|
priceRealtime: {
|
|
13931
|
-
price:
|
|
13932
|
-
confidence:
|
|
13933
|
-
lowestPrice:
|
|
13934
|
-
highestPrice:
|
|
14033
|
+
price: (0, bignumber_js.default)(oraclePrice.priceRealtime.price),
|
|
14034
|
+
confidence: (0, bignumber_js.default)(oraclePrice.priceRealtime.confidence),
|
|
14035
|
+
lowestPrice: (0, bignumber_js.default)(oraclePrice.priceRealtime.lowestPrice),
|
|
14036
|
+
highestPrice: (0, bignumber_js.default)(oraclePrice.priceRealtime.highestPrice)
|
|
13935
14037
|
},
|
|
13936
14038
|
priceWeighted: {
|
|
13937
|
-
price:
|
|
13938
|
-
confidence:
|
|
13939
|
-
lowestPrice:
|
|
13940
|
-
highestPrice:
|
|
14039
|
+
price: (0, bignumber_js.default)(oraclePrice.priceWeighted.price),
|
|
14040
|
+
confidence: (0, bignumber_js.default)(oraclePrice.priceWeighted.confidence),
|
|
14041
|
+
lowestPrice: (0, bignumber_js.default)(oraclePrice.priceWeighted.lowestPrice),
|
|
14042
|
+
highestPrice: (0, bignumber_js.default)(oraclePrice.priceWeighted.highestPrice)
|
|
13941
14043
|
},
|
|
13942
|
-
timestamp: oraclePrice.timestamp ?
|
|
14044
|
+
timestamp: oraclePrice.timestamp ? (0, bignumber_js.default)(oraclePrice.timestamp) : null,
|
|
13943
14045
|
pythShardId: oraclePrice.pythShardId
|
|
13944
14046
|
}]));
|
|
13945
14047
|
};
|
|
@@ -14058,18 +14160,18 @@ const fetchSwbOraclePricesViaAPI = async (swbFeedIds) => {
|
|
|
14058
14160
|
const responseBody = await response.json();
|
|
14059
14161
|
return Object.fromEntries(Object.entries(responseBody).map(([key, oraclePrice]) => [key, {
|
|
14060
14162
|
priceRealtime: {
|
|
14061
|
-
price:
|
|
14062
|
-
confidence:
|
|
14063
|
-
lowestPrice:
|
|
14064
|
-
highestPrice:
|
|
14163
|
+
price: (0, bignumber_js.default)(oraclePrice.priceRealtime.price),
|
|
14164
|
+
confidence: (0, bignumber_js.default)(oraclePrice.priceRealtime.confidence),
|
|
14165
|
+
lowestPrice: (0, bignumber_js.default)(oraclePrice.priceRealtime.lowestPrice),
|
|
14166
|
+
highestPrice: (0, bignumber_js.default)(oraclePrice.priceRealtime.highestPrice)
|
|
14065
14167
|
},
|
|
14066
14168
|
priceWeighted: {
|
|
14067
|
-
price:
|
|
14068
|
-
confidence:
|
|
14069
|
-
lowestPrice:
|
|
14070
|
-
highestPrice:
|
|
14169
|
+
price: (0, bignumber_js.default)(oraclePrice.priceWeighted.price),
|
|
14170
|
+
confidence: (0, bignumber_js.default)(oraclePrice.priceWeighted.confidence),
|
|
14171
|
+
lowestPrice: (0, bignumber_js.default)(oraclePrice.priceWeighted.lowestPrice),
|
|
14172
|
+
highestPrice: (0, bignumber_js.default)(oraclePrice.priceWeighted.highestPrice)
|
|
14071
14173
|
},
|
|
14072
|
-
timestamp: oraclePrice.timestamp ?
|
|
14174
|
+
timestamp: oraclePrice.timestamp ? (0, bignumber_js.default)(oraclePrice.timestamp) : null
|
|
14073
14175
|
}]));
|
|
14074
14176
|
};
|
|
14075
14177
|
/**
|
|
@@ -14108,18 +14210,18 @@ const fetchOracleData = async (banks, bankMetadataMap, connection, opts) => {
|
|
|
14108
14210
|
console.error(`Bank ${bank.address.toBase58()} is missing an oracle price`);
|
|
14109
14211
|
bankOraclePriceMap.set(bank.address.toBase58(), {
|
|
14110
14212
|
priceRealtime: {
|
|
14111
|
-
price:
|
|
14112
|
-
confidence:
|
|
14113
|
-
lowestPrice:
|
|
14114
|
-
highestPrice:
|
|
14213
|
+
price: (0, bignumber_js.default)(0),
|
|
14214
|
+
confidence: (0, bignumber_js.default)(0),
|
|
14215
|
+
lowestPrice: (0, bignumber_js.default)(0),
|
|
14216
|
+
highestPrice: (0, bignumber_js.default)(0)
|
|
14115
14217
|
},
|
|
14116
14218
|
priceWeighted: {
|
|
14117
|
-
price:
|
|
14118
|
-
confidence:
|
|
14119
|
-
lowestPrice:
|
|
14120
|
-
highestPrice:
|
|
14219
|
+
price: (0, bignumber_js.default)(0),
|
|
14220
|
+
confidence: (0, bignumber_js.default)(0),
|
|
14221
|
+
lowestPrice: (0, bignumber_js.default)(0),
|
|
14222
|
+
highestPrice: (0, bignumber_js.default)(0)
|
|
14121
14223
|
},
|
|
14122
|
-
timestamp:
|
|
14224
|
+
timestamp: (0, bignumber_js.default)(0)
|
|
14123
14225
|
});
|
|
14124
14226
|
}
|
|
14125
14227
|
});
|
|
@@ -14163,7 +14265,7 @@ function computeMaxLeverage(depositBank, borrowBank, opts) {
|
|
|
14163
14265
|
};
|
|
14164
14266
|
}
|
|
14165
14267
|
function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank, depositOracleInfo, borrowOracleInfo) {
|
|
14166
|
-
const initialCollateral = toBigNumber(principal);
|
|
14268
|
+
const initialCollateral = require_common.toBigNumber(principal);
|
|
14167
14269
|
const { maxLeverage } = computeMaxLeverage(depositBank, borrowBank);
|
|
14168
14270
|
if (targetLeverage < 1) {
|
|
14169
14271
|
throw Error(`Target leverage ${targetLeverage} needs to be greater than 1`);
|
|
@@ -14171,7 +14273,7 @@ function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank
|
|
|
14171
14273
|
if (targetLeverage > maxLeverage) {
|
|
14172
14274
|
throw Error(`Target leverage ${targetLeverage} exceeds max leverage for banks ${maxLeverage}`);
|
|
14173
14275
|
}
|
|
14174
|
-
const totalDepositAmount = initialCollateral.times(new
|
|
14276
|
+
const totalDepositAmount = initialCollateral.times(new bignumber_js.default(targetLeverage));
|
|
14175
14277
|
const additionalDepositAmount = totalDepositAmount.minus(initialCollateral);
|
|
14176
14278
|
const borrowAmount = additionalDepositAmount.times(depositOracleInfo.priceWeighted.lowestPrice).div(borrowOracleInfo.priceWeighted.highestPrice);
|
|
14177
14279
|
return {
|
|
@@ -14212,7 +14314,7 @@ function getAssetWeight(bank, lendrRequirementType, oraclePrice, opts) {
|
|
|
14212
14314
|
}
|
|
14213
14315
|
}
|
|
14214
14316
|
case LendrRequirementType.Maintenance: return bank.config.assetWeightMaint;
|
|
14215
|
-
case LendrRequirementType.Equity: return new
|
|
14317
|
+
case LendrRequirementType.Equity: return new bignumber_js.default(1);
|
|
14216
14318
|
default: throw new Error("Invalid lendr requirement type");
|
|
14217
14319
|
}
|
|
14218
14320
|
}
|
|
@@ -14220,7 +14322,7 @@ function getLiabilityWeight(config, lendrRequirementType) {
|
|
|
14220
14322
|
switch (lendrRequirementType) {
|
|
14221
14323
|
case LendrRequirementType.Initial: return config.liabilityWeightInit;
|
|
14222
14324
|
case LendrRequirementType.Maintenance: return config.liabilityWeightMaint;
|
|
14223
|
-
case LendrRequirementType.Equity: return new
|
|
14325
|
+
case LendrRequirementType.Equity: return new bignumber_js.default(1);
|
|
14224
14326
|
default: throw new Error("Invalid lendr requirement type");
|
|
14225
14327
|
}
|
|
14226
14328
|
}
|
|
@@ -14251,7 +14353,7 @@ function computeInterestRates(bank) {
|
|
|
14251
14353
|
const baseInterestRate = computeBaseInterestRate(bank);
|
|
14252
14354
|
const utilizationRate = computeUtilizationRate(bank);
|
|
14253
14355
|
const lendingRate = baseInterestRate.times(utilizationRate);
|
|
14254
|
-
const borrowingRate = baseInterestRate.times(new
|
|
14356
|
+
const borrowingRate = baseInterestRate.times(new bignumber_js.default(1).plus(rateFee)).plus(fixedFee);
|
|
14255
14357
|
return {
|
|
14256
14358
|
lendingRate,
|
|
14257
14359
|
borrowingRate
|
|
@@ -14263,22 +14365,22 @@ function computeBaseInterestRate(bank) {
|
|
|
14263
14365
|
if (utilizationRate.lte(optimalUtilizationRate)) {
|
|
14264
14366
|
return utilizationRate.times(plateauInterestRate).div(optimalUtilizationRate);
|
|
14265
14367
|
} else {
|
|
14266
|
-
return utilizationRate.minus(optimalUtilizationRate).div(new
|
|
14368
|
+
return utilizationRate.minus(optimalUtilizationRate).div(new bignumber_js.default(1).minus(optimalUtilizationRate)).times(maxInterestRate.minus(plateauInterestRate)).plus(plateauInterestRate);
|
|
14267
14369
|
}
|
|
14268
14370
|
}
|
|
14269
14371
|
function computeUtilizationRate(bank) {
|
|
14270
14372
|
const assets = getTotalAssetQuantity(bank);
|
|
14271
14373
|
const liabilities = getTotalLiabilityQuantity(bank);
|
|
14272
|
-
if (assets.isZero()) return new
|
|
14374
|
+
if (assets.isZero()) return new bignumber_js.default(0);
|
|
14273
14375
|
return liabilities.div(assets);
|
|
14274
14376
|
}
|
|
14275
14377
|
const SECONDS_PER_DAY$1 = 24 * 60 * 60;
|
|
14276
14378
|
const SECONDS_PER_YEAR$1 = SECONDS_PER_DAY$1 * 365.25;
|
|
14277
14379
|
function computeRemainingCapacity(bank) {
|
|
14278
14380
|
const totalDeposits = getTotalAssetQuantity(bank);
|
|
14279
|
-
const remainingCapacity =
|
|
14381
|
+
const remainingCapacity = bignumber_js.default.max(0, bank.config.depositLimit.minus(totalDeposits));
|
|
14280
14382
|
const totalBorrows = getTotalLiabilityQuantity(bank);
|
|
14281
|
-
const remainingBorrowCapacity =
|
|
14383
|
+
const remainingBorrowCapacity = bignumber_js.default.max(0, bank.config.borrowLimit.minus(totalBorrows));
|
|
14282
14384
|
const durationSinceLastAccrual = Date.now() / 1e3 - bank.lastUpdate;
|
|
14283
14385
|
const { lendingRate, borrowingRate } = computeInterestRates(bank);
|
|
14284
14386
|
const outstandingLendingInterest = lendingRate.times(durationSinceLastAccrual).dividedBy(SECONDS_PER_YEAR$1).times(totalDeposits);
|
|
@@ -14301,7 +14403,7 @@ const fetchMultipleBanks = async (program, opts) => {
|
|
|
14301
14403
|
data.forEach((d, idx) => {
|
|
14302
14404
|
if (d) {
|
|
14303
14405
|
bankDatas.push({
|
|
14304
|
-
address: new PublicKey(addresses[idx]),
|
|
14406
|
+
address: new __solana_web3_js.PublicKey(addresses[idx]),
|
|
14305
14407
|
data: d
|
|
14306
14408
|
});
|
|
14307
14409
|
} else {
|
|
@@ -14325,8 +14427,8 @@ const fetchMultipleBanks = async (program, opts) => {
|
|
|
14325
14427
|
//#endregion
|
|
14326
14428
|
//#region src/services/bank/utils/serialize.utils.ts
|
|
14327
14429
|
function serializeBankConfigOpt(bankConfigOpt) {
|
|
14328
|
-
const toWrappedI80F48 = (value) => value && bigNumberToWrappedI80F48(value);
|
|
14329
|
-
const toBN = (value) => value && new
|
|
14430
|
+
const toWrappedI80F48 = (value) => value && require_common.bigNumberToWrappedI80F48(value);
|
|
14431
|
+
const toBN = (value) => value && new bn_js.default(value.toString());
|
|
14330
14432
|
return {
|
|
14331
14433
|
assetWeightInit: toWrappedI80F48(bankConfigOpt.assetWeightInit),
|
|
14332
14434
|
assetWeightMaint: toWrappedI80F48(bankConfigOpt.assetWeightMaint),
|
|
@@ -14596,20 +14698,20 @@ function getPriceFeedAccountForProgram(shardId, priceFeedId, pushOracleProgramId
|
|
|
14596
14698
|
}
|
|
14597
14699
|
const shardBuffer = Buffer.alloc(2);
|
|
14598
14700
|
shardBuffer.writeUint16LE(shardId, 0);
|
|
14599
|
-
return PublicKey.findProgramAddressSync([shardBuffer, priceFeedId], pushOracleProgramId ?? DEFAULT_PUSH_ORACLE_PROGRAM_ID)[0];
|
|
14701
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([shardBuffer, priceFeedId], pushOracleProgramId ?? DEFAULT_PUSH_ORACLE_PROGRAM_ID)[0];
|
|
14600
14702
|
}
|
|
14601
14703
|
const getTreasuryPda = (treasuryId, receiverProgramId) => {
|
|
14602
|
-
return PublicKey.findProgramAddressSync([Buffer.from("treasury"), Buffer.from([treasuryId])], receiverProgramId)[0];
|
|
14704
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("treasury"), Buffer.from([treasuryId])], receiverProgramId)[0];
|
|
14603
14705
|
};
|
|
14604
14706
|
const getConfigPda = (receiverProgramId) => {
|
|
14605
|
-
return PublicKey.findProgramAddressSync([Buffer.from("config")], receiverProgramId)[0];
|
|
14707
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("config")], receiverProgramId)[0];
|
|
14606
14708
|
};
|
|
14607
14709
|
async function crankPythOracleIx(oracles, provider) {
|
|
14608
14710
|
const feedIdsByShardId = {};
|
|
14609
|
-
const wormholeProgram = new Program(PYTH_WORMHOLE_IDL, provider);
|
|
14610
|
-
const pushOracleProgram = new Program(PYTH_PUSH_ORACLE_IDL, provider);
|
|
14611
|
-
const receiverProgram = new Program(PYTH_SOLANA_RECEIVER_PROGRAM_IDL, provider);
|
|
14612
|
-
const addressLookupTableAccount = new PublicKey("5DNCErWQFBdvCxWQXaC1mrEFsvL3ftrzZ2gVZWNybaSX");
|
|
14711
|
+
const wormholeProgram = new __coral_xyz_anchor.Program(PYTH_WORMHOLE_IDL, provider);
|
|
14712
|
+
const pushOracleProgram = new __coral_xyz_anchor.Program(PYTH_PUSH_ORACLE_IDL, provider);
|
|
14713
|
+
const receiverProgram = new __coral_xyz_anchor.Program(PYTH_SOLANA_RECEIVER_PROGRAM_IDL, provider);
|
|
14714
|
+
const addressLookupTableAccount = new __solana_web3_js.PublicKey("5DNCErWQFBdvCxWQXaC1mrEFsvL3ftrzZ2gVZWNybaSX");
|
|
14613
14715
|
const lookupTableAccount = (await provider.connection.getAddressLookupTable(addressLookupTableAccount)).value;
|
|
14614
14716
|
const buildURL = (endpoint) => {
|
|
14615
14717
|
return new URL(`./v2/${endpoint}`, `https://hermes.pyth.network/`);
|
|
@@ -14650,7 +14752,7 @@ async function crankPythOracleIx(oracles, provider) {
|
|
|
14650
14752
|
priceFeedAccount: getPriceFeedAccountForProgram(Number(shardId), feedId, pushOracleProgram.programId),
|
|
14651
14753
|
treasury: getTreasuryPda(treasuryId, receiverProgram.programId),
|
|
14652
14754
|
config: getConfigPda(receiverProgram.programId),
|
|
14653
|
-
systemProgram: SYSTEM_PROGRAM_ID
|
|
14755
|
+
systemProgram: require_common.SYSTEM_PROGRAM_ID
|
|
14654
14756
|
}).instruction(),
|
|
14655
14757
|
signers: [],
|
|
14656
14758
|
computeUnits: UPDATE_PRICE_FEED_COMPUTE_BUDGET
|
|
@@ -14722,7 +14824,7 @@ async function sendTransactionAsBundle(connection, base58Txs, throwError = false
|
|
|
14722
14824
|
throw new SendBundleError(`${API_ERROR_TAG} ${sendBundleResult.error.message}`);
|
|
14723
14825
|
}
|
|
14724
14826
|
const bundleId = sendBundleResult.result;
|
|
14725
|
-
await sleep(500);
|
|
14827
|
+
await require_common.sleep(500);
|
|
14726
14828
|
for (let attempt = 0; attempt < 10; attempt++) {
|
|
14727
14829
|
const getBundleStatusResponse = await fetch("https://mainnet.block-engine.jito.wtf/api/v1/bundles", {
|
|
14728
14830
|
method: "POST",
|
|
@@ -14755,7 +14857,7 @@ async function sendTransactionAsBundle(connection, base58Txs, throwError = false
|
|
|
14755
14857
|
await confirmBundle(connection, bundleId);
|
|
14756
14858
|
return bundleId;
|
|
14757
14859
|
}
|
|
14758
|
-
await sleep(1e3);
|
|
14860
|
+
await require_common.sleep(1e3);
|
|
14759
14861
|
}
|
|
14760
14862
|
} catch (error) {
|
|
14761
14863
|
if (throwError) {
|
|
@@ -14769,7 +14871,7 @@ async function confirmBundle(connection, bundleId, commitment = "confirmed") {
|
|
|
14769
14871
|
let attempts = 0;
|
|
14770
14872
|
const maxAttempts = 5;
|
|
14771
14873
|
while (attempts < maxAttempts) {
|
|
14772
|
-
await sleep(2e3);
|
|
14874
|
+
await require_common.sleep(2e3);
|
|
14773
14875
|
attempts += 1;
|
|
14774
14876
|
const getBundleStatus = await fetch("https://mainnet.block-engine.jito.wtf/api/v1/bundles", {
|
|
14775
14877
|
method: "POST",
|
|
@@ -14795,7 +14897,7 @@ async function confirmBundle(connection, bundleId, commitment = "confirmed") {
|
|
|
14795
14897
|
console.log("❌ Transaction failed to confirm in time.");
|
|
14796
14898
|
throw new Error("Transaction failed to confirm in time.");
|
|
14797
14899
|
};
|
|
14798
|
-
const result = await Promise.race([getStatus(), setTimeoutPromise(2e4, `Transaction failed to confirm in time.`)]);
|
|
14900
|
+
const result = await Promise.race([getStatus(), require_common.setTimeoutPromise(2e4, `Transaction failed to confirm in time.`)]);
|
|
14799
14901
|
if (result instanceof Error) {
|
|
14800
14902
|
throw result;
|
|
14801
14903
|
}
|
|
@@ -14831,7 +14933,7 @@ async function simulateBundle(rpcEndpoint, transactions, includeAccounts) {
|
|
|
14831
14933
|
const result = await executeBundleSimulation(rpcEndpoint, encodedTransactions, config);
|
|
14832
14934
|
return result;
|
|
14833
14935
|
} catch (error) {
|
|
14834
|
-
if (error instanceof SolanaJSONRPCError || error instanceof BundleSimulationError) {
|
|
14936
|
+
if (error instanceof __solana_web3_js.SolanaJSONRPCError || error instanceof BundleSimulationError) {
|
|
14835
14937
|
throw error;
|
|
14836
14938
|
} else {
|
|
14837
14939
|
throw new BundleSimulationError("Failed to execute bundle simulation", undefined, error);
|
|
@@ -14937,7 +15039,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
14937
15039
|
...DEFAULT_PROCESS_TX_OPTS,
|
|
14938
15040
|
...processOptsArgs
|
|
14939
15041
|
};
|
|
14940
|
-
const commitment = connection.commitment ?? DEFAULT_CONFIRM_OPTS.commitment;
|
|
15042
|
+
const commitment = connection.commitment ?? require_common.DEFAULT_CONFIRM_OPTS.commitment;
|
|
14941
15043
|
if (processOpts?.broadcastType === "BUNDLE" && processOpts?.bundleTipUi === 0) {
|
|
14942
15044
|
throw new Error("A bundle tip is required for a bundled transactions");
|
|
14943
15045
|
}
|
|
@@ -14973,7 +15075,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
14973
15075
|
lastValidBlockHeight = getLatestBlockhashAndContext.value.lastValidBlockHeight;
|
|
14974
15076
|
} catch (error) {
|
|
14975
15077
|
console.error("Failed to get latest blockhash and context", error);
|
|
14976
|
-
if (error instanceof SolanaJSONRPCError) {
|
|
15078
|
+
if (error instanceof __solana_web3_js.SolanaJSONRPCError) {
|
|
14977
15079
|
throw error;
|
|
14978
15080
|
}
|
|
14979
15081
|
throw new ProcessTransactionError({
|
|
@@ -14983,7 +15085,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
14983
15085
|
});
|
|
14984
15086
|
}
|
|
14985
15087
|
const mergedOpts = {
|
|
14986
|
-
...DEFAULT_CONFIRM_OPTS,
|
|
15088
|
+
...require_common.DEFAULT_CONFIRM_OPTS,
|
|
14987
15089
|
commitment,
|
|
14988
15090
|
preflightCommitment: commitment,
|
|
14989
15091
|
minContextSlot,
|
|
@@ -14996,7 +15098,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
14996
15098
|
blockhash
|
|
14997
15099
|
});
|
|
14998
15100
|
const unitsConsumed = isSimulatedTransactionResponse(simulationResult) ? [simulationResult.unitsConsumed] : simulationResult.map((tx) => tx.unitsConsumed ? Number(tx.unitsConsumed) : undefined);
|
|
14999
|
-
updatedTransactions = transactions.map((tx, idx) => addTransactionMetadata(tx, {
|
|
15101
|
+
updatedTransactions = transactions.map((tx, idx) => require_common.addTransactionMetadata(tx, {
|
|
15000
15102
|
...tx,
|
|
15001
15103
|
unitsConsumed: unitsConsumed[idx]
|
|
15002
15104
|
}));
|
|
@@ -15009,8 +15111,8 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15009
15111
|
console.log(`💸 Bundle tip: ${maxCapUi ? Math.min(processOpts.bundleTipUi ?? 0, maxCapUi) : processOpts.bundleTipUi} SOL`);
|
|
15010
15112
|
} else {
|
|
15011
15113
|
updatedTransactions.forEach((tx, idx) => {
|
|
15012
|
-
const cu = tx.unitsConsumed ? Math.min(tx.unitsConsumed + 5e4, 14e5) : getComputeBudgetUnits(tx);
|
|
15013
|
-
const priorityFeeUi = maxCapUi ? Math.min(processOpts.priorityFeeMicro ? microLamportsToUi(processOpts.priorityFeeMicro, cu) : 0, maxCapUi) : processOpts.priorityFeeMicro ? microLamportsToUi(processOpts.priorityFeeMicro, cu) : 0;
|
|
15114
|
+
const cu = tx.unitsConsumed ? Math.min(tx.unitsConsumed + 5e4, 14e5) : require_common.getComputeBudgetUnits(tx);
|
|
15115
|
+
const priorityFeeUi = maxCapUi ? Math.min(processOpts.priorityFeeMicro ? require_common.microLamportsToUi(processOpts.priorityFeeMicro, cu) : 0, maxCapUi) : processOpts.priorityFeeMicro ? require_common.microLamportsToUi(processOpts.priorityFeeMicro, cu) : 0;
|
|
15014
15116
|
console.log(`💸 Priority fee for tx ${idx}: ${priorityFeeUi} SOL`);
|
|
15015
15117
|
});
|
|
15016
15118
|
}
|
|
@@ -15030,11 +15132,11 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15030
15132
|
let base58Txs = [];
|
|
15031
15133
|
if (wallet.signAllTransactions) {
|
|
15032
15134
|
versionedTransactions = await wallet.signAllTransactions(versionedTransactions);
|
|
15033
|
-
base58Txs = versionedTransactions.map((signedTx) => bs58.encode(signedTx.serialize()));
|
|
15135
|
+
base58Txs = versionedTransactions.map((signedTx) => bs58.default.encode(signedTx.serialize()));
|
|
15034
15136
|
} else {
|
|
15035
15137
|
for (let i = 0; i < versionedTransactions.length; i++) {
|
|
15036
15138
|
const signedTx = await wallet.signTransaction(versionedTransactions[i]);
|
|
15037
|
-
const base58Tx = bs58.encode(signedTx.serialize());
|
|
15139
|
+
const base58Tx = bs58.default.encode(signedTx.serialize());
|
|
15038
15140
|
base58Txs.push(base58Tx);
|
|
15039
15141
|
versionedTransactions[i] = signedTx;
|
|
15040
15142
|
}
|
|
@@ -15046,7 +15148,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15046
15148
|
processOpts.callback?.(undefined, true);
|
|
15047
15149
|
}
|
|
15048
15150
|
let simulateTxs = null;
|
|
15049
|
-
if (!SKIP_SIMULATION) {
|
|
15151
|
+
if (!require_common.SKIP_SIMULATION) {
|
|
15050
15152
|
simulateTxs = async () => await simulateTransactions(processOpts, connection, versionedTransactions, mergedOpts);
|
|
15051
15153
|
}
|
|
15052
15154
|
const sendTxBundleGrpc = async (throwError) => await sendTransactionAsGrpcBundle(connection, base58Txs, throwError);
|
|
@@ -15066,7 +15168,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15066
15168
|
});
|
|
15067
15169
|
for (const [idx, method] of finalFallbackMethod.entries()) {
|
|
15068
15170
|
const isLast = idx === finalFallbackMethod.length - 1;
|
|
15069
|
-
if (idx === 0 && simulateTxs && !SKIP_SIMULATION) {
|
|
15171
|
+
if (idx === 0 && simulateTxs && !require_common.SKIP_SIMULATION) {
|
|
15070
15172
|
await simulateTxs();
|
|
15071
15173
|
}
|
|
15072
15174
|
let temporaryBundleSignature;
|
|
@@ -15118,7 +15220,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15118
15220
|
}
|
|
15119
15221
|
} catch (error) {
|
|
15120
15222
|
const failedTxs = transactions.splice(signatures.length);
|
|
15121
|
-
if (error instanceof SolanaJSONRPCError) {
|
|
15223
|
+
if (error instanceof __solana_web3_js.SolanaJSONRPCError) {
|
|
15122
15224
|
throw error;
|
|
15123
15225
|
}
|
|
15124
15226
|
if (error instanceof ProcessTransactionError) {
|
|
@@ -15128,12 +15230,12 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15128
15230
|
throw new ProcessTransactionError({
|
|
15129
15231
|
message: error.message,
|
|
15130
15232
|
type: ProcessTransactionErrorType.TransactionSendingError,
|
|
15131
|
-
programId: PROGRAM_ID.toBase58(),
|
|
15233
|
+
programId: require_common.PROGRAM_ID.toBase58(),
|
|
15132
15234
|
failedTxs,
|
|
15133
15235
|
_error: error
|
|
15134
15236
|
});
|
|
15135
15237
|
}
|
|
15136
|
-
const parsedError = parseTransactionError(error, processOpts?.programId ?? PROGRAM_ID);
|
|
15238
|
+
const parsedError = parseTransactionError(error, processOpts?.programId ?? require_common.PROGRAM_ID);
|
|
15137
15239
|
if (error?.logs?.length > 0) {
|
|
15138
15240
|
console.log("------ Logs 👇 ------");
|
|
15139
15241
|
console.log(error.logs.join("\n"));
|
|
@@ -15159,7 +15261,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15159
15261
|
}
|
|
15160
15262
|
}
|
|
15161
15263
|
const simulateTransactions = async (processOpts, connection, solanaTransactions, confirmOpts, txOpts) => {
|
|
15162
|
-
const v0Txs = solanaTransactions.map((tx) => isV0Tx(tx) ? tx : legacyTxToV0Tx(tx, txOpts));
|
|
15264
|
+
const v0Txs = solanaTransactions.map((tx) => require_common.isV0Tx(tx) ? tx : require_common.legacyTxToV0Tx(tx, txOpts));
|
|
15163
15265
|
try {
|
|
15164
15266
|
if (v0Txs.length > 1) {
|
|
15165
15267
|
const response = await simulateBundle(processOpts?.bundleSimRpcEndpoint ?? connection.rpcEndpoint, v0Txs);
|
|
@@ -15173,7 +15275,7 @@ const simulateTransactions = async (processOpts, connection, solanaTransactions,
|
|
|
15173
15275
|
});
|
|
15174
15276
|
if (response.value.err) {
|
|
15175
15277
|
const error = response.value.err;
|
|
15176
|
-
const parsedError = parseTransactionError(error, processOpts?.programId ?? PROGRAM_ID);
|
|
15278
|
+
const parsedError = parseTransactionError(error, processOpts?.programId ?? require_common.PROGRAM_ID);
|
|
15177
15279
|
throw new ProcessTransactionError({
|
|
15178
15280
|
message: parsedError.description ?? JSON.stringify(response.value.err),
|
|
15179
15281
|
type: ProcessTransactionErrorType.SimulationError,
|
|
@@ -15185,7 +15287,7 @@ const simulateTransactions = async (processOpts, connection, solanaTransactions,
|
|
|
15185
15287
|
}
|
|
15186
15288
|
} catch (error) {
|
|
15187
15289
|
if (error instanceof BundleSimulationError) {
|
|
15188
|
-
const parsedError = parseTransactionError(error, processOpts?.programId ?? PROGRAM_ID);
|
|
15290
|
+
const parsedError = parseTransactionError(error, processOpts?.programId ?? require_common.PROGRAM_ID);
|
|
15189
15291
|
throw new ProcessTransactionError({
|
|
15190
15292
|
message: parsedError.description,
|
|
15191
15293
|
type: ProcessTransactionErrorType.SimulationError,
|
|
@@ -15247,12 +15349,12 @@ async function confirmTransaction(connection, signature, commitment = "confirmed
|
|
|
15247
15349
|
}
|
|
15248
15350
|
}
|
|
15249
15351
|
console.log("🔄 Waiting for confirmation...");
|
|
15250
|
-
await sleep(2e3);
|
|
15352
|
+
await require_common.sleep(2e3);
|
|
15251
15353
|
}
|
|
15252
15354
|
console.log("❌ Transaction failed to confirm in time.");
|
|
15253
15355
|
throw new Error("Transaction failed to confirm in time.");
|
|
15254
15356
|
};
|
|
15255
|
-
const result = await Promise.race([getStatus(), setTimeoutPromise(2e4, `Transaction failed to confirm in time.`)]);
|
|
15357
|
+
const result = await Promise.race([getStatus(), require_common.setTimeoutPromise(2e4, `Transaction failed to confirm in time.`)]);
|
|
15256
15358
|
if (result instanceof Error) {
|
|
15257
15359
|
throw result;
|
|
15258
15360
|
}
|
|
@@ -15339,14 +15441,14 @@ const MAX_TX_SIZE$1 = 1232;
|
|
|
15339
15441
|
const BUNDLE_TX_SIZE$1 = 81;
|
|
15340
15442
|
const PRIORITY_TX_SIZE$1 = 44;
|
|
15341
15443
|
function isFlashloan(tx) {
|
|
15342
|
-
if (isV0Tx(tx)) {
|
|
15444
|
+
if (require_common.isV0Tx(tx)) {
|
|
15343
15445
|
const addressLookupTableAccounts = tx.addressLookupTables ?? [];
|
|
15344
|
-
const message = decompileV0Transaction(tx, addressLookupTableAccounts);
|
|
15446
|
+
const message = require_common.decompileV0Transaction(tx, addressLookupTableAccounts);
|
|
15345
15447
|
const idl = {
|
|
15346
15448
|
...LENDR_IDL,
|
|
15347
|
-
address: new PublicKey(0)
|
|
15449
|
+
address: new __solana_web3_js.PublicKey(0)
|
|
15348
15450
|
};
|
|
15349
|
-
const decoded = message.instructions.map((ix) => decodeInstruction(idl, ix.data));
|
|
15451
|
+
const decoded = message.instructions.map((ix) => require_common.decodeInstruction(idl, ix.data));
|
|
15350
15452
|
return decoded.some((ix) => ix?.name.toLowerCase().includes("flashloan"));
|
|
15351
15453
|
}
|
|
15352
15454
|
return false;
|
|
@@ -15375,25 +15477,25 @@ function formatTransactions(transactionsArg, broadcastType, blockhash, feeSettin
|
|
|
15375
15477
|
const { priorityFeeMicro, bundleTipUi, feePayer, maxCapUi } = feeSettings;
|
|
15376
15478
|
const flashloanIndex = getFlashloanIndex(transactionsArg);
|
|
15377
15479
|
transactionsArg.forEach((tx) => {
|
|
15378
|
-
if (!isV0Tx(tx)) {
|
|
15480
|
+
if (!require_common.isV0Tx(tx)) {
|
|
15379
15481
|
tx.recentBlockhash = blockhash;
|
|
15380
15482
|
tx.feePayer = feePayer;
|
|
15381
15483
|
}
|
|
15382
15484
|
});
|
|
15383
15485
|
const transactions = addTransactionTags ? addTransactionTxTags(transactionsArg) : transactionsArg;
|
|
15384
|
-
const txSizes = transactions.map((tx) => getTxSize(tx));
|
|
15486
|
+
const txSizes = transactions.map((tx) => require_common.getTxSize(tx));
|
|
15385
15487
|
const dummyPriorityFeeIx = makePriorityFeeMicroIx(1);
|
|
15386
15488
|
const priorityIxs = [];
|
|
15387
15489
|
const cuLimitIxs = [];
|
|
15388
15490
|
transactions.forEach((tx, idx) => {
|
|
15389
|
-
const cu = tx.unitsConsumed ? Math.min(tx.unitsConsumed + 5e4, 14e5) : getComputeBudgetUnits(tx);
|
|
15390
|
-
const priorityFeeUi = maxCapUi ? Math.min(microLamportsToUi(priorityFeeMicro, cu), maxCapUi) : microLamportsToUi(priorityFeeMicro, cu);
|
|
15391
|
-
let updatedFees = uiToMicroLamports(priorityFeeUi, cu);
|
|
15491
|
+
const cu = tx.unitsConsumed ? Math.min(tx.unitsConsumed + 5e4, 14e5) : require_common.getComputeBudgetUnits(tx);
|
|
15492
|
+
const priorityFeeUi = maxCapUi ? Math.min(require_common.microLamportsToUi(priorityFeeMicro, cu), maxCapUi) : require_common.microLamportsToUi(priorityFeeMicro, cu);
|
|
15493
|
+
let updatedFees = require_common.uiToMicroLamports(priorityFeeUi, cu);
|
|
15392
15494
|
if (priorityFeeUi > .1) {
|
|
15393
|
-
updatedFees = uiToMicroLamports(.1, cu);
|
|
15495
|
+
updatedFees = require_common.uiToMicroLamports(.1, cu);
|
|
15394
15496
|
}
|
|
15395
15497
|
priorityIxs.push(broadcastType === "BUNDLE" ? dummyPriorityFeeIx : makePriorityFeeMicroIx(updatedFees));
|
|
15396
|
-
cuLimitIxs.push(cu ? ComputeBudgetProgram.setComputeUnitLimit({ units: cu }) : undefined);
|
|
15498
|
+
cuLimitIxs.push(cu ? __solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: cu }) : undefined);
|
|
15397
15499
|
});
|
|
15398
15500
|
const { bundleTipIx } = makeTxPriorityIx(feePayer, maxCapUi ? Math.min(bundleTipUi, maxCapUi) : bundleTipUi, broadcastType);
|
|
15399
15501
|
let bundleTipIndex = broadcastType === "BUNDLE" ? -1 : null;
|
|
@@ -15411,12 +15513,12 @@ function formatTransactions(transactionsArg, broadcastType, blockhash, feeSettin
|
|
|
15411
15513
|
}
|
|
15412
15514
|
}
|
|
15413
15515
|
if (bundleTipIndex === -1 && bundleTipIx) {
|
|
15414
|
-
const bundleTipMessage = new TransactionMessage({
|
|
15516
|
+
const bundleTipMessage = new __solana_web3_js.TransactionMessage({
|
|
15415
15517
|
instructions: [bundleTipIx],
|
|
15416
15518
|
payerKey: feePayer,
|
|
15417
15519
|
recentBlockhash: blockhash
|
|
15418
15520
|
});
|
|
15419
|
-
formattedTransactions.push(new VersionedTransaction(bundleTipMessage.compileToV0Message()));
|
|
15521
|
+
formattedTransactions.push(new __solana_web3_js.VersionedTransaction(bundleTipMessage.compileToV0Message()));
|
|
15420
15522
|
}
|
|
15421
15523
|
for (const [index, transaction] of transactions.entries()) {
|
|
15422
15524
|
const hasFlashloan = flashloanIndex !== null;
|
|
@@ -15429,15 +15531,15 @@ function formatTransactions(transactionsArg, broadcastType, blockhash, feeSettin
|
|
|
15429
15531
|
...cuLimitIxs[index] ? [cuLimitIxs[index]] : []
|
|
15430
15532
|
];
|
|
15431
15533
|
let newTransaction;
|
|
15432
|
-
if (isV0Tx(transaction)) {
|
|
15433
|
-
newTransaction = updateV0Tx(transaction, {
|
|
15534
|
+
if (require_common.isV0Tx(transaction)) {
|
|
15535
|
+
newTransaction = require_common.updateV0Tx(transaction, {
|
|
15434
15536
|
addressLookupTables,
|
|
15435
15537
|
additionalIxs: requiredIxs,
|
|
15436
15538
|
blockhash,
|
|
15437
15539
|
replaceOnly: isTxFlashloan
|
|
15438
15540
|
});
|
|
15439
15541
|
} else {
|
|
15440
|
-
newTransaction = legacyTxToV0Tx(transaction, {
|
|
15542
|
+
newTransaction = require_common.legacyTxToV0Tx(transaction, {
|
|
15441
15543
|
addressLookupTables,
|
|
15442
15544
|
additionalIxs: requiredIxs,
|
|
15443
15545
|
blockhash,
|
|
@@ -15453,18 +15555,18 @@ function addTransactionTxTags(transactions) {
|
|
|
15453
15555
|
const txWithTags = [];
|
|
15454
15556
|
for (const [_, tx] of transactions.entries()) {
|
|
15455
15557
|
let solanaTx = tx;
|
|
15456
|
-
const arenaKey = TransactionArenaKeyMap[tx.type];
|
|
15558
|
+
const arenaKey = require_common.TransactionArenaKeyMap[tx.type];
|
|
15457
15559
|
if (arenaKey) {
|
|
15458
|
-
if (isV0Tx(solanaTx)) {
|
|
15560
|
+
if (require_common.isV0Tx(solanaTx)) {
|
|
15459
15561
|
console.log("tx", solanaTx);
|
|
15460
15562
|
const addressLookupTableAccounts = solanaTx.addressLookupTables ?? [];
|
|
15461
|
-
const message = decompileV0Transaction(solanaTx, addressLookupTableAccounts);
|
|
15563
|
+
const message = require_common.decompileV0Transaction(solanaTx, addressLookupTableAccounts);
|
|
15462
15564
|
message.instructions[0].keys.push({
|
|
15463
15565
|
pubkey: arenaKey,
|
|
15464
15566
|
isSigner: false,
|
|
15465
15567
|
isWritable: false
|
|
15466
15568
|
});
|
|
15467
|
-
solanaTx = addTransactionMetadata(new VersionedTransaction(message.compileToV0Message(tx.addressLookupTables)), {
|
|
15569
|
+
solanaTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message.compileToV0Message(tx.addressLookupTables)), {
|
|
15468
15570
|
signers: solanaTx.signers,
|
|
15469
15571
|
addressLookupTables: solanaTx.addressLookupTables,
|
|
15470
15572
|
type: solanaTx.type,
|
|
@@ -15502,7 +15604,7 @@ const SinglePoolInstruction = {
|
|
|
15502
15604
|
const mint = findPoolMintAddress(pool);
|
|
15503
15605
|
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
15504
15606
|
const mintAuthority = findPoolMintAuthorityAddress(pool);
|
|
15505
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15607
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15506
15608
|
{
|
|
15507
15609
|
pubkey: voteAccount,
|
|
15508
15610
|
isSigner: false,
|
|
@@ -15534,37 +15636,37 @@ const SinglePoolInstruction = {
|
|
|
15534
15636
|
isWritable: false
|
|
15535
15637
|
},
|
|
15536
15638
|
{
|
|
15537
|
-
pubkey: SYSVAR_RENT_ID,
|
|
15639
|
+
pubkey: require_common.SYSVAR_RENT_ID,
|
|
15538
15640
|
isSigner: false,
|
|
15539
15641
|
isWritable: false
|
|
15540
15642
|
},
|
|
15541
15643
|
{
|
|
15542
|
-
pubkey: SYSVAR_CLOCK_ID,
|
|
15644
|
+
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
15543
15645
|
isSigner: false,
|
|
15544
15646
|
isWritable: false
|
|
15545
15647
|
},
|
|
15546
15648
|
{
|
|
15547
|
-
pubkey: SYSVAR_STAKE_HISTORY_ID,
|
|
15649
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
15548
15650
|
isSigner: false,
|
|
15549
15651
|
isWritable: false
|
|
15550
15652
|
},
|
|
15551
15653
|
{
|
|
15552
|
-
pubkey: STAKE_CONFIG_ID
|
|
15654
|
+
pubkey: __solana_web3_js.STAKE_CONFIG_ID,
|
|
15553
15655
|
isSigner: false,
|
|
15554
15656
|
isWritable: false
|
|
15555
15657
|
},
|
|
15556
15658
|
{
|
|
15557
|
-
pubkey: SYSTEM_PROGRAM_ID,
|
|
15659
|
+
pubkey: require_common.SYSTEM_PROGRAM_ID,
|
|
15558
15660
|
isSigner: false,
|
|
15559
15661
|
isWritable: false
|
|
15560
15662
|
},
|
|
15561
15663
|
{
|
|
15562
|
-
pubkey: TOKEN_PROGRAM_ID,
|
|
15664
|
+
pubkey: __solana_spl_token.TOKEN_PROGRAM_ID,
|
|
15563
15665
|
isSigner: false,
|
|
15564
15666
|
isWritable: false
|
|
15565
15667
|
},
|
|
15566
15668
|
{
|
|
15567
|
-
pubkey: STAKE_PROGRAM_ID,
|
|
15669
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
15568
15670
|
isSigner: false,
|
|
15569
15671
|
isWritable: false
|
|
15570
15672
|
}
|
|
@@ -15573,7 +15675,7 @@ const SinglePoolInstruction = {
|
|
|
15573
15675
|
initializeOnRamp: (pool) => {
|
|
15574
15676
|
const onRamp = findPoolOnRampAddress(pool);
|
|
15575
15677
|
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
15576
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15678
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15577
15679
|
{
|
|
15578
15680
|
pubkey: pool,
|
|
15579
15681
|
isSigner: false,
|
|
@@ -15590,17 +15692,17 @@ const SinglePoolInstruction = {
|
|
|
15590
15692
|
isWritable: false
|
|
15591
15693
|
},
|
|
15592
15694
|
{
|
|
15593
|
-
pubkey: SYSVAR_RENT_ID,
|
|
15695
|
+
pubkey: require_common.SYSVAR_RENT_ID,
|
|
15594
15696
|
isSigner: false,
|
|
15595
15697
|
isWritable: false
|
|
15596
15698
|
},
|
|
15597
15699
|
{
|
|
15598
|
-
pubkey: SYSTEM_PROGRAM_ID,
|
|
15700
|
+
pubkey: require_common.SYSTEM_PROGRAM_ID,
|
|
15599
15701
|
isSigner: false,
|
|
15600
15702
|
isWritable: false
|
|
15601
15703
|
},
|
|
15602
15704
|
{
|
|
15603
|
-
pubkey: STAKE_PROGRAM_ID,
|
|
15705
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
15604
15706
|
isSigner: false,
|
|
15605
15707
|
isWritable: false
|
|
15606
15708
|
}
|
|
@@ -15611,7 +15713,7 @@ const SinglePoolInstruction = {
|
|
|
15611
15713
|
const mint = findPoolMintAddress(pool);
|
|
15612
15714
|
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
15613
15715
|
const mintAuthority = findPoolMintAuthorityAddress(pool);
|
|
15614
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15716
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15615
15717
|
{
|
|
15616
15718
|
pubkey: pool,
|
|
15617
15719
|
isSigner: false,
|
|
@@ -15653,22 +15755,22 @@ const SinglePoolInstruction = {
|
|
|
15653
15755
|
isWritable: true
|
|
15654
15756
|
},
|
|
15655
15757
|
{
|
|
15656
|
-
pubkey: SYSVAR_CLOCK_ID,
|
|
15758
|
+
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
15657
15759
|
isSigner: false,
|
|
15658
15760
|
isWritable: false
|
|
15659
15761
|
},
|
|
15660
15762
|
{
|
|
15661
|
-
pubkey: SYSVAR_STAKE_HISTORY_ID,
|
|
15763
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
15662
15764
|
isSigner: false,
|
|
15663
15765
|
isWritable: false
|
|
15664
15766
|
},
|
|
15665
15767
|
{
|
|
15666
|
-
pubkey: TOKEN_PROGRAM_ID,
|
|
15768
|
+
pubkey: __solana_spl_token.TOKEN_PROGRAM_ID,
|
|
15667
15769
|
isSigner: false,
|
|
15668
15770
|
isWritable: false
|
|
15669
15771
|
},
|
|
15670
15772
|
{
|
|
15671
|
-
pubkey: STAKE_PROGRAM_ID,
|
|
15773
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
15672
15774
|
isSigner: false,
|
|
15673
15775
|
isWritable: false
|
|
15674
15776
|
}
|
|
@@ -15683,9 +15785,9 @@ const SinglePoolInstruction = {
|
|
|
15683
15785
|
const data = Buffer.concat([
|
|
15684
15786
|
Buffer.from([SinglePoolInstructionType.WithdrawStake]),
|
|
15685
15787
|
userStakeAuthority.toBuffer(),
|
|
15686
|
-
Buffer.from(new BN
|
|
15788
|
+
Buffer.from(new bn_js.BN(rawAmount.toString()).toArray("le", 8))
|
|
15687
15789
|
]);
|
|
15688
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15790
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15689
15791
|
{
|
|
15690
15792
|
pubkey: pool,
|
|
15691
15793
|
isSigner: false,
|
|
@@ -15722,17 +15824,17 @@ const SinglePoolInstruction = {
|
|
|
15722
15824
|
isWritable: true
|
|
15723
15825
|
},
|
|
15724
15826
|
{
|
|
15725
|
-
pubkey: SYSVAR_CLOCK_ID,
|
|
15827
|
+
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
15726
15828
|
isSigner: false,
|
|
15727
15829
|
isWritable: false
|
|
15728
15830
|
},
|
|
15729
15831
|
{
|
|
15730
|
-
pubkey: TOKEN_PROGRAM_ID,
|
|
15832
|
+
pubkey: __solana_spl_token.TOKEN_PROGRAM_ID,
|
|
15731
15833
|
isSigner: false,
|
|
15732
15834
|
isWritable: false
|
|
15733
15835
|
},
|
|
15734
15836
|
{
|
|
15735
|
-
pubkey: STAKE_PROGRAM_ID,
|
|
15837
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
15736
15838
|
isSigner: false,
|
|
15737
15839
|
isWritable: false
|
|
15738
15840
|
}
|
|
@@ -15745,7 +15847,7 @@ const SinglePoolInstruction = {
|
|
|
15745
15847
|
findPoolMplAuthorityAddress(pool),
|
|
15746
15848
|
findMplMetadataAddress(mint)
|
|
15747
15849
|
]);
|
|
15748
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15850
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15749
15851
|
{
|
|
15750
15852
|
pubkey: pool,
|
|
15751
15853
|
isSigner: false,
|
|
@@ -15777,12 +15879,12 @@ const SinglePoolInstruction = {
|
|
|
15777
15879
|
isWritable: true
|
|
15778
15880
|
},
|
|
15779
15881
|
{
|
|
15780
|
-
pubkey: MPL_METADATA_PROGRAM_ID,
|
|
15882
|
+
pubkey: require_common.MPL_METADATA_PROGRAM_ID,
|
|
15781
15883
|
isSigner: false,
|
|
15782
15884
|
isWritable: false
|
|
15783
15885
|
},
|
|
15784
15886
|
{
|
|
15785
|
-
pubkey: SYSTEM_PROGRAM_ID,
|
|
15887
|
+
pubkey: require_common.SYSTEM_PROGRAM_ID,
|
|
15786
15888
|
isSigner: false,
|
|
15787
15889
|
isWritable: false
|
|
15788
15890
|
}
|
|
@@ -15810,7 +15912,7 @@ const SinglePoolInstruction = {
|
|
|
15810
15912
|
Buffer.from(new Uint32Array([tokenUri.length]).buffer),
|
|
15811
15913
|
Buffer.from(tokenUri)
|
|
15812
15914
|
]);
|
|
15813
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15915
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15814
15916
|
{
|
|
15815
15917
|
pubkey: voteAccount,
|
|
15816
15918
|
isSigner: false,
|
|
@@ -15837,7 +15939,7 @@ const SinglePoolInstruction = {
|
|
|
15837
15939
|
isWritable: true
|
|
15838
15940
|
},
|
|
15839
15941
|
{
|
|
15840
|
-
pubkey: MPL_METADATA_PROGRAM_ID,
|
|
15942
|
+
pubkey: require_common.MPL_METADATA_PROGRAM_ID,
|
|
15841
15943
|
isSigner: false,
|
|
15842
15944
|
isWritable: false
|
|
15843
15945
|
}
|
|
@@ -15851,8 +15953,8 @@ const createTransactionInstruction = (programId, keys, data) => {
|
|
|
15851
15953
|
data
|
|
15852
15954
|
};
|
|
15853
15955
|
};
|
|
15854
|
-
const findPda = (baseAddress, prefix, programId = SINGLE_POOL_PROGRAM_ID) => {
|
|
15855
|
-
const [pda] = PublicKey.findProgramAddressSync([Buffer.from(prefix), baseAddress.toBuffer()], programId);
|
|
15956
|
+
const findPda = (baseAddress, prefix, programId = require_common.SINGLE_POOL_PROGRAM_ID) => {
|
|
15957
|
+
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from(prefix), baseAddress.toBuffer()], programId);
|
|
15856
15958
|
return pda;
|
|
15857
15959
|
};
|
|
15858
15960
|
const findPoolMintAddressByVoteAccount = (voteAccountAddress) => findPda(findPoolAddress(voteAccountAddress), "mint");
|
|
@@ -15864,11 +15966,11 @@ const findPoolMintAuthorityAddress = (poolAddress) => findPda(poolAddress, "mint
|
|
|
15864
15966
|
const findPoolMplAuthorityAddress = (poolAddress) => findPda(poolAddress, "mpl_authority");
|
|
15865
15967
|
const findPoolOnRampAddress = (poolAddress) => findPda(poolAddress, "onramp");
|
|
15866
15968
|
const findMplMetadataAddress = async (poolMintAddress) => {
|
|
15867
|
-
const [pda] = PublicKey.findProgramAddressSync([
|
|
15969
|
+
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([
|
|
15868
15970
|
Buffer.from("metadata"),
|
|
15869
|
-
MPL_METADATA_PROGRAM_ID.toBuffer(),
|
|
15971
|
+
require_common.MPL_METADATA_PROGRAM_ID.toBuffer(),
|
|
15870
15972
|
poolMintAddress.toBuffer()
|
|
15871
|
-
], MPL_METADATA_PROGRAM_ID);
|
|
15973
|
+
], require_common.MPL_METADATA_PROGRAM_ID);
|
|
15872
15974
|
return pda;
|
|
15873
15975
|
};
|
|
15874
15976
|
const SINGLE_POOL_ACCOUNT_SIZE = BigInt(33);
|
|
@@ -15876,7 +15978,7 @@ const STAKE_ACCOUNT_SIZE = BigInt(200);
|
|
|
15876
15978
|
const MINT_SIZE = BigInt(82);
|
|
15877
15979
|
async function initializeStakedPoolTx(connection, payer, voteAccountAddress) {
|
|
15878
15980
|
const instructions$3 = await initializeStakedPoolIxs(connection, payer, voteAccountAddress);
|
|
15879
|
-
const tx = new Transaction().add(...instructions$3);
|
|
15981
|
+
const tx = new __solana_web3_js.Transaction().add(...instructions$3);
|
|
15880
15982
|
return tx;
|
|
15881
15983
|
}
|
|
15882
15984
|
async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
|
|
@@ -15892,22 +15994,22 @@ async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
|
|
|
15892
15994
|
]);
|
|
15893
15995
|
const minimumDelegation = minimumDelegationObj.value;
|
|
15894
15996
|
const instructions$3 = [];
|
|
15895
|
-
instructions$3.push(SystemProgram.transfer({
|
|
15997
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
15896
15998
|
fromPubkey: payer,
|
|
15897
15999
|
toPubkey: poolAddress,
|
|
15898
16000
|
lamports: poolRent
|
|
15899
16001
|
}));
|
|
15900
|
-
instructions$3.push(SystemProgram.transfer({
|
|
16002
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
15901
16003
|
fromPubkey: payer,
|
|
15902
16004
|
toPubkey: stakeAddress,
|
|
15903
|
-
lamports: stakeRent + minimumDelegation + LAMPORTS_PER_SOL * 1
|
|
16005
|
+
lamports: stakeRent + minimumDelegation + __solana_web3_js.LAMPORTS_PER_SOL * 1
|
|
15904
16006
|
}));
|
|
15905
|
-
instructions$3.push(SystemProgram.transfer({
|
|
16007
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
15906
16008
|
fromPubkey: payer,
|
|
15907
16009
|
toPubkey: onRampAddress,
|
|
15908
16010
|
lamports: stakeRent
|
|
15909
16011
|
}));
|
|
15910
|
-
instructions$3.push(SystemProgram.transfer({
|
|
16012
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
15911
16013
|
fromPubkey: payer,
|
|
15912
16014
|
toPubkey: mintAddress,
|
|
15913
16015
|
lamports: mintRent
|
|
@@ -15920,8 +16022,8 @@ async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
|
|
|
15920
16022
|
const createAccountIx = (from, newAccount, lamports, space, programAddress) => {
|
|
15921
16023
|
const data = Buffer.concat([
|
|
15922
16024
|
Buffer.from([0]),
|
|
15923
|
-
Buffer.from(new BN
|
|
15924
|
-
Buffer.from(new BN
|
|
16025
|
+
Buffer.from(new bn_js.BN(lamports).toArray("le", 8)),
|
|
16026
|
+
Buffer.from(new bn_js.BN(space).toArray("le", 8)),
|
|
15925
16027
|
programAddress.toBuffer()
|
|
15926
16028
|
]);
|
|
15927
16029
|
const accounts$2 = [{
|
|
@@ -15933,7 +16035,7 @@ const createAccountIx = (from, newAccount, lamports, space, programAddress) => {
|
|
|
15933
16035
|
isSigner: true,
|
|
15934
16036
|
isWritable: true
|
|
15935
16037
|
}];
|
|
15936
|
-
return createTransactionInstruction(SYSTEM_PROGRAM_ID, accounts$2, data);
|
|
16038
|
+
return createTransactionInstruction(require_common.SYSTEM_PROGRAM_ID, accounts$2, data);
|
|
15937
16039
|
};
|
|
15938
16040
|
const createPoolOnrampIx = (voteAccount) => {
|
|
15939
16041
|
const poolAccount = findPoolAddress(voteAccount);
|
|
@@ -15956,25 +16058,25 @@ const createPoolOnrampIx = (voteAccount) => {
|
|
|
15956
16058
|
isWritable: false
|
|
15957
16059
|
},
|
|
15958
16060
|
{
|
|
15959
|
-
pubkey: SYSVAR_RENT_PUBKEY,
|
|
16061
|
+
pubkey: __solana_web3_js.SYSVAR_RENT_PUBKEY,
|
|
15960
16062
|
isSigner: false,
|
|
15961
16063
|
isWritable: false
|
|
15962
16064
|
},
|
|
15963
16065
|
{
|
|
15964
|
-
pubkey: SystemProgram.programId,
|
|
16066
|
+
pubkey: __solana_web3_js.SystemProgram.programId,
|
|
15965
16067
|
isSigner: false,
|
|
15966
16068
|
isWritable: false
|
|
15967
16069
|
},
|
|
15968
16070
|
{
|
|
15969
|
-
pubkey: StakeProgram.programId,
|
|
16071
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
15970
16072
|
isSigner: false,
|
|
15971
16073
|
isWritable: false
|
|
15972
16074
|
}
|
|
15973
16075
|
];
|
|
15974
16076
|
const data = Buffer.from(Uint8Array.of(6));
|
|
15975
|
-
return new TransactionInstruction({
|
|
16077
|
+
return new __solana_web3_js.TransactionInstruction({
|
|
15976
16078
|
keys,
|
|
15977
|
-
programId: SINGLE_POOL_PROGRAM_ID,
|
|
16079
|
+
programId: require_common.SINGLE_POOL_PROGRAM_ID,
|
|
15978
16080
|
data
|
|
15979
16081
|
});
|
|
15980
16082
|
};
|
|
@@ -16010,28 +16112,28 @@ const replenishPoolIx = (voteAccount) => {
|
|
|
16010
16112
|
isWritable: false
|
|
16011
16113
|
},
|
|
16012
16114
|
{
|
|
16013
|
-
pubkey: SYSVAR_CLOCK_PUBKEY,
|
|
16115
|
+
pubkey: __solana_web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
16014
16116
|
isSigner: false,
|
|
16015
16117
|
isWritable: false
|
|
16016
16118
|
},
|
|
16017
16119
|
{
|
|
16018
|
-
pubkey: SYSVAR_STAKE_HISTORY_ID,
|
|
16120
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
16019
16121
|
isSigner: false,
|
|
16020
16122
|
isWritable: false
|
|
16021
16123
|
},
|
|
16022
16124
|
{
|
|
16023
|
-
pubkey: STAKE_CONFIG_ID
|
|
16125
|
+
pubkey: __solana_web3_js.STAKE_CONFIG_ID,
|
|
16024
16126
|
isSigner: false,
|
|
16025
16127
|
isWritable: false
|
|
16026
16128
|
},
|
|
16027
16129
|
{
|
|
16028
|
-
pubkey: StakeProgram.programId,
|
|
16130
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
16029
16131
|
isSigner: false,
|
|
16030
16132
|
isWritable: false
|
|
16031
16133
|
}
|
|
16032
16134
|
];
|
|
16033
16135
|
const data = Buffer.from(Uint8Array.of(1));
|
|
16034
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, keys, data);
|
|
16136
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, keys, data);
|
|
16035
16137
|
};
|
|
16036
16138
|
|
|
16037
16139
|
//#endregion
|
|
@@ -16044,13 +16146,13 @@ function computeFreeCollateral(lendrAccount, opts) {
|
|
|
16044
16146
|
const _clamped = opts?.clamped ?? true;
|
|
16045
16147
|
const { assets, liabilities } = computeHealthComponents(lendrAccount, LendrRequirementType.Initial);
|
|
16046
16148
|
const signedFreeCollateral = assets.minus(liabilities);
|
|
16047
|
-
return _clamped ?
|
|
16149
|
+
return _clamped ? bignumber_js.default.max(0, signedFreeCollateral) : signedFreeCollateral;
|
|
16048
16150
|
}
|
|
16049
16151
|
function computeFreeCollateralLegacy(activeBalances, banks, oraclePrices, opts) {
|
|
16050
16152
|
const _clamped = opts?.clamped ?? true;
|
|
16051
16153
|
const { assets, liabilities } = computeHealthComponentsLegacy(activeBalances, banks, oraclePrices, LendrRequirementType.Initial, []);
|
|
16052
16154
|
const signedFreeCollateral = assets.minus(liabilities);
|
|
16053
|
-
return _clamped ?
|
|
16155
|
+
return _clamped ? bignumber_js.default.max(0, signedFreeCollateral) : signedFreeCollateral;
|
|
16054
16156
|
}
|
|
16055
16157
|
function computeHealthComponents(lendrAccount, lendrReqType) {
|
|
16056
16158
|
switch (lendrReqType) {
|
|
@@ -16073,19 +16175,19 @@ function computeHealthComponentsLegacy(activeBalances, banks, oraclePrices, lend
|
|
|
16073
16175
|
const [assets, liabilities] = filteredBalances.map((accountBalance) => {
|
|
16074
16176
|
const bank = banks.get(accountBalance.bankPk.toBase58());
|
|
16075
16177
|
if (!bank) {
|
|
16076
|
-
console.warn(`Bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16077
|
-
return [new
|
|
16178
|
+
console.warn(`Bank ${require_common.shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16179
|
+
return [new bignumber_js.default(0), new bignumber_js.default(0)];
|
|
16078
16180
|
}
|
|
16079
16181
|
const priceInfo = oraclePrices.get(accountBalance.bankPk.toBase58());
|
|
16080
16182
|
if (!priceInfo) {
|
|
16081
|
-
console.warn(`Price info for bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16082
|
-
return [new
|
|
16183
|
+
console.warn(`Price info for bank ${require_common.shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16184
|
+
return [new bignumber_js.default(0), new bignumber_js.default(0)];
|
|
16083
16185
|
}
|
|
16084
16186
|
const { assets: assets$1, liabilities: liabilities$1 } = getBalanceUsdValueWithPriceBias(accountBalance, bank, priceInfo, lendrReqType);
|
|
16085
16187
|
return [assets$1, liabilities$1];
|
|
16086
16188
|
}).reduce(([asset, liability], [d, l]) => {
|
|
16087
16189
|
return [asset.plus(d), liability.plus(l)];
|
|
16088
|
-
}, [new
|
|
16190
|
+
}, [new bignumber_js.default(0), new bignumber_js.default(0)]);
|
|
16089
16191
|
return {
|
|
16090
16192
|
assets,
|
|
16091
16193
|
liabilities
|
|
@@ -16095,19 +16197,19 @@ function computeHealthComponentsWithoutBiasLegacy(activeBalances, banks, oracleP
|
|
|
16095
16197
|
const [assets, liabilities] = activeBalances.map((accountBalance) => {
|
|
16096
16198
|
const bank = banks.get(accountBalance.bankPk.toBase58());
|
|
16097
16199
|
if (!bank) {
|
|
16098
|
-
console.warn(`Bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16099
|
-
return [new
|
|
16200
|
+
console.warn(`Bank ${require_common.shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16201
|
+
return [new bignumber_js.default(0), new bignumber_js.default(0)];
|
|
16100
16202
|
}
|
|
16101
16203
|
const priceInfo = oraclePrices.get(accountBalance.bankPk.toBase58());
|
|
16102
16204
|
if (!priceInfo) {
|
|
16103
|
-
console.warn(`Price info for bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16104
|
-
return [new
|
|
16205
|
+
console.warn(`Price info for bank ${require_common.shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16206
|
+
return [new bignumber_js.default(0), new bignumber_js.default(0)];
|
|
16105
16207
|
}
|
|
16106
16208
|
const { assets: assets$1, liabilities: liabilities$1 } = computeBalanceUsdValue(accountBalance, bank, priceInfo, lendrReqType);
|
|
16107
16209
|
return [assets$1, liabilities$1];
|
|
16108
16210
|
}).reduce(([asset, liability], [d, l]) => {
|
|
16109
16211
|
return [asset.plus(d), liability.plus(l)];
|
|
16110
|
-
}, [new
|
|
16212
|
+
}, [new bignumber_js.default(0), new bignumber_js.default(0)]);
|
|
16111
16213
|
return {
|
|
16112
16214
|
assets,
|
|
16113
16215
|
liabilities
|
|
@@ -16123,17 +16225,17 @@ function computeNetApy(lendrAccount, activeBalances, banks, oraclePrices) {
|
|
|
16123
16225
|
const apr = activeBalances.reduce((weightedApr, balance) => {
|
|
16124
16226
|
const bank = banks.get(balance.bankPk.toBase58());
|
|
16125
16227
|
if (!bank) {
|
|
16126
|
-
console.warn(`Bank ${shortenAddress(balance.bankPk)} not found, excluding from APY computation`);
|
|
16228
|
+
console.warn(`Bank ${require_common.shortenAddress(balance.bankPk)} not found, excluding from APY computation`);
|
|
16127
16229
|
return weightedApr;
|
|
16128
16230
|
}
|
|
16129
16231
|
const priceInfo = oraclePrices.get(balance.bankPk.toBase58());
|
|
16130
16232
|
if (!priceInfo) {
|
|
16131
|
-
console.warn(`Price info for bank ${shortenAddress(balance.bankPk)} not found, excluding from APY computation`);
|
|
16233
|
+
console.warn(`Price info for bank ${require_common.shortenAddress(balance.bankPk)} not found, excluding from APY computation`);
|
|
16132
16234
|
return weightedApr;
|
|
16133
16235
|
}
|
|
16134
16236
|
return weightedApr.minus(computeInterestRates(bank).borrowingRate.times(computeBalanceUsdValue(balance, bank, priceInfo, LendrRequirementType.Equity).liabilities).div(totalUsdValue.isEqualTo(0) ? 1 : totalUsdValue)).plus(computeInterestRates(bank).lendingRate.times(computeBalanceUsdValue(balance, bank, priceInfo, LendrRequirementType.Equity).assets).div(totalUsdValue.isEqualTo(0) ? 1 : totalUsdValue));
|
|
16135
|
-
}, new
|
|
16136
|
-
return aprToApy(apr);
|
|
16237
|
+
}, new bignumber_js.default(0)).toNumber();
|
|
16238
|
+
return require_common.aprToApy(apr);
|
|
16137
16239
|
}
|
|
16138
16240
|
/**
|
|
16139
16241
|
* Lendr Balance Computes
|
|
@@ -16164,8 +16266,8 @@ function computeQuantity(balance, bank) {
|
|
|
16164
16266
|
};
|
|
16165
16267
|
}
|
|
16166
16268
|
function computeQuantityUi(balance, bank) {
|
|
16167
|
-
const assetsQuantity = new
|
|
16168
|
-
const liabilitiesQuantity = new
|
|
16269
|
+
const assetsQuantity = new bignumber_js.default(require_common.nativeToUi(getAssetQuantity(bank, balance.assetShares), bank.mintDecimals));
|
|
16270
|
+
const liabilitiesQuantity = new bignumber_js.default(require_common.nativeToUi(getLiabilityQuantity(bank, balance.liabilityShares), bank.mintDecimals));
|
|
16169
16271
|
return {
|
|
16170
16272
|
assets: assetsQuantity,
|
|
16171
16273
|
liabilities: liabilitiesQuantity
|
|
@@ -16183,13 +16285,13 @@ function computeClaimedEmissions(balance, bank, currentTimestamp) {
|
|
|
16183
16285
|
}
|
|
16184
16286
|
if (balanceAmount) {
|
|
16185
16287
|
const lastUpdate = balance.lastUpdate;
|
|
16186
|
-
const period = new
|
|
16187
|
-
const emissionsRate = new
|
|
16288
|
+
const period = new bignumber_js.default(currentTimestamp - lastUpdate);
|
|
16289
|
+
const emissionsRate = new bignumber_js.default(bank.emissionsRate);
|
|
16188
16290
|
const emissions = period.times(balanceAmount).times(emissionsRate).div(31536e3 * 10 ** bank.mintDecimals);
|
|
16189
|
-
const emissionsReal =
|
|
16291
|
+
const emissionsReal = bignumber_js.default.min(emissions, new bignumber_js.default(bank.emissionsRemaining));
|
|
16190
16292
|
return emissionsReal;
|
|
16191
16293
|
}
|
|
16192
|
-
return new
|
|
16294
|
+
return new bignumber_js.default(0);
|
|
16193
16295
|
}
|
|
16194
16296
|
function computeTotalOutstandingEmissions(balance, bank) {
|
|
16195
16297
|
const claimedEmissions = balance.emissionsOutstanding;
|
|
@@ -16227,7 +16329,7 @@ function computeHealthCheckAccounts(balances, banks, mandatoryBanks = [], exclud
|
|
|
16227
16329
|
return projectedActiveBanks;
|
|
16228
16330
|
}
|
|
16229
16331
|
function computeHealthAccountMetas(banksToInclude, bankMetadataMap, enableSorting = true, bankExtendedMetadata) {
|
|
16230
|
-
const wrapperFn = enableSorting ? composeRemainingAccounts : (banksAndOracles) => banksAndOracles.flat();
|
|
16332
|
+
const wrapperFn = enableSorting ? require_common.composeRemainingAccounts : (banksAndOracles) => banksAndOracles.flat();
|
|
16231
16333
|
const accounts$2 = wrapperFn(banksToInclude.map((bank) => {
|
|
16232
16334
|
const keys = [bank.address, bank.oracleKey];
|
|
16233
16335
|
if (bank.config.assetTag === 2) {
|
|
@@ -16239,7 +16341,7 @@ function computeHealthAccountMetas(banksToInclude, bankMetadataMap, enableSortin
|
|
|
16239
16341
|
if (!validatorVoteAccount) {
|
|
16240
16342
|
throw Error(`no validatorVoteAccount on Bank metadata: ${bank.address.toBase58()}`);
|
|
16241
16343
|
}
|
|
16242
|
-
const pool = findPoolAddress(new PublicKey(validatorVoteAccount));
|
|
16344
|
+
const pool = findPoolAddress(new __solana_web3_js.PublicKey(validatorVoteAccount));
|
|
16243
16345
|
const solPool = findPoolStakeAddress(pool);
|
|
16244
16346
|
const lstMint = findPoolMintAddress(pool);
|
|
16245
16347
|
keys.push(lstMint, solPool);
|
|
@@ -16268,7 +16370,7 @@ var Balance = class Balance {
|
|
|
16268
16370
|
return new Balance(balance.active, balance.bankPk, balance.assetShares, balance.liabilityShares, balance.emissionsOutstanding, balance.lastUpdate);
|
|
16269
16371
|
}
|
|
16270
16372
|
static createEmpty(bankPk) {
|
|
16271
|
-
return new Balance(false, bankPk, new
|
|
16373
|
+
return new Balance(false, bankPk, new bignumber_js.default(0), new bignumber_js.default(0), new bignumber_js.default(0), 0);
|
|
16272
16374
|
}
|
|
16273
16375
|
computeUsdValue(bank, oraclePrice, lendrRequirementType = LendrRequirementType.Equity) {
|
|
16274
16376
|
return computeBalanceUsdValue(this, bank, oraclePrice, lendrRequirementType);
|
|
@@ -16352,15 +16454,15 @@ let AccountFlags = /* @__PURE__ */ function(AccountFlags$1) {
|
|
|
16352
16454
|
//#endregion
|
|
16353
16455
|
//#region src/services/account/utils/deserialize.utils.ts
|
|
16354
16456
|
function decodeAccountRaw(encoded, idl) {
|
|
16355
|
-
const coder = new BorshCoder(idl);
|
|
16457
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
16356
16458
|
return coder.accounts.decode(AccountType.LendrAccount, encoded);
|
|
16357
16459
|
}
|
|
16358
16460
|
function parseBalanceRaw(balanceRaw) {
|
|
16359
16461
|
const active = typeof balanceRaw.active === "number" ? balanceRaw.active === 1 : balanceRaw.active;
|
|
16360
16462
|
const bankPk = balanceRaw.bankPk;
|
|
16361
|
-
const assetShares = wrappedI80F48toBigNumber(balanceRaw.assetShares);
|
|
16362
|
-
const liabilityShares = wrappedI80F48toBigNumber(balanceRaw.liabilityShares);
|
|
16363
|
-
const emissionsOutstanding = wrappedI80F48toBigNumber(balanceRaw.emissionsOutstanding);
|
|
16463
|
+
const assetShares = require_common.wrappedI80F48toBigNumber(balanceRaw.assetShares);
|
|
16464
|
+
const liabilityShares = require_common.wrappedI80F48toBigNumber(balanceRaw.liabilityShares);
|
|
16465
|
+
const emissionsOutstanding = require_common.wrappedI80F48toBigNumber(balanceRaw.emissionsOutstanding);
|
|
16364
16466
|
const lastUpdate = balanceRaw.lastUpdate.toNumber();
|
|
16365
16467
|
return {
|
|
16366
16468
|
active,
|
|
@@ -16406,7 +16508,7 @@ function getActiveAccountFlags(flags) {
|
|
|
16406
16508
|
* Check if an account flag is set
|
|
16407
16509
|
*/
|
|
16408
16510
|
function hasAccountFlag(flags, flag) {
|
|
16409
|
-
return !flags.and(new
|
|
16511
|
+
return !flags.and(new bn_js.default(flag)).isZero();
|
|
16410
16512
|
}
|
|
16411
16513
|
/**
|
|
16412
16514
|
* Convert on-chain health cache flags (BN) to an array of HealthCacheFlags enum values
|
|
@@ -16456,34 +16558,34 @@ function getHealthCacheStatusDescription(flags) {
|
|
|
16456
16558
|
}
|
|
16457
16559
|
function dtoToLendrAccount(lendrAccountDto) {
|
|
16458
16560
|
return {
|
|
16459
|
-
address: new PublicKey(lendrAccountDto.address),
|
|
16460
|
-
group: new PublicKey(lendrAccountDto.group),
|
|
16461
|
-
authority: new PublicKey(lendrAccountDto.authority),
|
|
16561
|
+
address: new __solana_web3_js.PublicKey(lendrAccountDto.address),
|
|
16562
|
+
group: new __solana_web3_js.PublicKey(lendrAccountDto.group),
|
|
16563
|
+
authority: new __solana_web3_js.PublicKey(lendrAccountDto.authority),
|
|
16462
16564
|
balances: lendrAccountDto.balances.map(dtoToBalance),
|
|
16463
16565
|
accountFlags: lendrAccountDto.accountFlags,
|
|
16464
|
-
emissionsDestinationAccount: new PublicKey(lendrAccountDto.emissionsDestinationAccount),
|
|
16566
|
+
emissionsDestinationAccount: new __solana_web3_js.PublicKey(lendrAccountDto.emissionsDestinationAccount),
|
|
16465
16567
|
healthCache: dtoToHealthCache(lendrAccountDto.healthCache)
|
|
16466
16568
|
};
|
|
16467
16569
|
}
|
|
16468
16570
|
function dtoToBalance(balanceDto) {
|
|
16469
16571
|
return {
|
|
16470
16572
|
active: balanceDto.active,
|
|
16471
|
-
bankPk: new PublicKey(balanceDto.bankPk),
|
|
16472
|
-
assetShares: new
|
|
16473
|
-
liabilityShares: new
|
|
16474
|
-
emissionsOutstanding: new
|
|
16573
|
+
bankPk: new __solana_web3_js.PublicKey(balanceDto.bankPk),
|
|
16574
|
+
assetShares: new bignumber_js.default(balanceDto.assetShares),
|
|
16575
|
+
liabilityShares: new bignumber_js.default(balanceDto.liabilityShares),
|
|
16576
|
+
emissionsOutstanding: new bignumber_js.default(balanceDto.emissionsOutstanding),
|
|
16475
16577
|
lastUpdate: balanceDto.lastUpdate
|
|
16476
16578
|
};
|
|
16477
16579
|
}
|
|
16478
16580
|
function dtoToHealthCache(healthCacheDto) {
|
|
16479
16581
|
return {
|
|
16480
|
-
assetValue: new
|
|
16481
|
-
liabilityValue: new
|
|
16482
|
-
assetValueMaint: new
|
|
16483
|
-
liabilityValueMaint: new
|
|
16484
|
-
assetValueEquity: new
|
|
16485
|
-
liabilityValueEquity: new
|
|
16486
|
-
timestamp: new
|
|
16582
|
+
assetValue: new bignumber_js.default(healthCacheDto.assetValue),
|
|
16583
|
+
liabilityValue: new bignumber_js.default(healthCacheDto.liabilityValue),
|
|
16584
|
+
assetValueMaint: new bignumber_js.default(healthCacheDto.assetValueMaint),
|
|
16585
|
+
liabilityValueMaint: new bignumber_js.default(healthCacheDto.liabilityValueMaint),
|
|
16586
|
+
assetValueEquity: new bignumber_js.default(healthCacheDto.assetValueEquity),
|
|
16587
|
+
liabilityValueEquity: new bignumber_js.default(healthCacheDto.liabilityValueEquity),
|
|
16588
|
+
timestamp: new bignumber_js.default(healthCacheDto.timestamp),
|
|
16487
16589
|
flags: healthCacheDto.flags,
|
|
16488
16590
|
prices: healthCacheDto.prices,
|
|
16489
16591
|
simulationFailed: healthCacheDto.simulationFailed
|
|
@@ -16670,7 +16772,7 @@ const fetchLendrAccountData = async (program, lendrAccountPk, bankMap, oraclePri
|
|
|
16670
16772
|
* Convert numeric flag to BN for Solana compatibility
|
|
16671
16773
|
*/
|
|
16672
16774
|
function accountFlagToBN(flag) {
|
|
16673
|
-
return new
|
|
16775
|
+
return new bn_js.default(flag);
|
|
16674
16776
|
}
|
|
16675
16777
|
function lendrAccountToDto(lendrAccount) {
|
|
16676
16778
|
return {
|
|
@@ -16739,14 +16841,14 @@ async function simulateAccountHealthCacheWithFallback(props) {
|
|
|
16739
16841
|
balances: props.balances,
|
|
16740
16842
|
bankMetadataMap: props.bankMetadataMap
|
|
16741
16843
|
});
|
|
16742
|
-
simulatedAccount.healthCache.assetValueEquity = bigNumberToWrappedI80F48(assetValueEquity);
|
|
16743
|
-
simulatedAccount.healthCache.liabilityValueEquity = bigNumberToWrappedI80F48(liabilityValueEquity);
|
|
16844
|
+
simulatedAccount.healthCache.assetValueEquity = require_common.bigNumberToWrappedI80F48(assetValueEquity);
|
|
16845
|
+
simulatedAccount.healthCache.liabilityValueEquity = require_common.bigNumberToWrappedI80F48(liabilityValueEquity);
|
|
16744
16846
|
lendrAccount = LendrAccount.fromAccountParsed(props.lendrAccount.address, simulatedAccount);
|
|
16745
16847
|
} catch (e) {
|
|
16746
16848
|
console.log("e", e);
|
|
16747
16849
|
const { assets: assetValueMaint, liabilities: liabilityValueMaint } = computeHealthComponentsLegacy(activeBalances, props.bankMap, props.oraclePrices, LendrRequirementType.Maintenance);
|
|
16748
16850
|
const { assets: assetValueInitial, liabilities: liabilityValueInitial } = computeHealthComponentsLegacy(activeBalances, props.bankMap, props.oraclePrices, LendrRequirementType.Initial);
|
|
16749
|
-
lendrAccount.setHealthCache(new HealthCache(assetValueInitial, liabilityValueInitial, assetValueMaint, liabilityValueMaint, assetValueEquity, liabilityValueEquity, new
|
|
16851
|
+
lendrAccount.setHealthCache(new HealthCache(assetValueInitial, liabilityValueInitial, assetValueMaint, liabilityValueMaint, assetValueEquity, liabilityValueEquity, new bignumber_js.default(0), [], [], true));
|
|
16750
16852
|
if (e instanceof HealthCacheSimulationError) {
|
|
16751
16853
|
return {
|
|
16752
16854
|
lendrAccount,
|
|
@@ -16760,10 +16862,10 @@ async function simulateAccountHealthCache(props) {
|
|
|
16760
16862
|
const { program, bankMap, oraclePrices, lendrAccountPk, balances, bankMetadataMap } = props;
|
|
16761
16863
|
const activeBalances = balances.filter((b) => b.active);
|
|
16762
16864
|
const { stalePythFeeds, staleSwbOracles } = getActiveStaleBanks(activeBalances, bankMap, [], oraclePrices, 30);
|
|
16763
|
-
const computeIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 });
|
|
16865
|
+
const computeIx = __solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 });
|
|
16764
16866
|
const blockhash = (await program.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
16765
|
-
const fundAccountIx = SystemProgram.transfer({
|
|
16766
|
-
fromPubkey: new PublicKey("DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD"),
|
|
16867
|
+
const fundAccountIx = __solana_web3_js.SystemProgram.transfer({
|
|
16868
|
+
fromPubkey: new __solana_web3_js.PublicKey("DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD"),
|
|
16767
16869
|
toPubkey: program.provider.publicKey,
|
|
16768
16870
|
lamports: 1e8
|
|
16769
16871
|
});
|
|
@@ -16784,7 +16886,7 @@ async function simulateAccountHealthCache(props) {
|
|
|
16784
16886
|
const pythLut = crankPythIxs.lut ? [crankPythIxs.lut] : [];
|
|
16785
16887
|
const txs = [];
|
|
16786
16888
|
if (crankPythIxs.postInstructions.length > 0) {
|
|
16787
|
-
txs.push(...splitInstructionsToFitTransactions([computeIx], [
|
|
16889
|
+
txs.push(...require_common.splitInstructionsToFitTransactions([computeIx], [
|
|
16788
16890
|
fundAccountIx,
|
|
16789
16891
|
...crankPythIxs.postInstructions.map((ix) => ix.instruction),
|
|
16790
16892
|
...crankPythIxs.closeInstructions.map((ix) => ix.instruction)
|
|
@@ -16794,19 +16896,19 @@ async function simulateAccountHealthCache(props) {
|
|
|
16794
16896
|
luts: [...crankSwbIxs.luts, ...pythLut]
|
|
16795
16897
|
}));
|
|
16796
16898
|
}
|
|
16797
|
-
const messageV0 = new TransactionMessage({
|
|
16899
|
+
const messageV0 = new __solana_web3_js.TransactionMessage({
|
|
16798
16900
|
payerKey: program.provider.publicKey,
|
|
16799
16901
|
recentBlockhash: blockhash,
|
|
16800
16902
|
instructions: [...crankSwbIxs.instructions]
|
|
16801
16903
|
}).compileToV0Message([...crankSwbIxs.luts]);
|
|
16802
|
-
const swbTx = new VersionedTransaction(messageV0);
|
|
16904
|
+
const swbTx = new __solana_web3_js.VersionedTransaction(messageV0);
|
|
16803
16905
|
txs.push(swbTx);
|
|
16804
|
-
const healthTx = new TransactionMessage({
|
|
16906
|
+
const healthTx = new __solana_web3_js.TransactionMessage({
|
|
16805
16907
|
payerKey: program.provider.publicKey,
|
|
16806
16908
|
recentBlockhash: blockhash,
|
|
16807
16909
|
instructions: [...healthPulseIxs.instructions]
|
|
16808
16910
|
}).compileToV0Message([]);
|
|
16809
|
-
const healthTxV0 = new VersionedTransaction(healthTx);
|
|
16911
|
+
const healthTxV0 = new __solana_web3_js.VersionedTransaction(healthTx);
|
|
16810
16912
|
txs.push(healthTxV0);
|
|
16811
16913
|
if (txs.length > 5) {
|
|
16812
16914
|
console.error("Too many transactions", txs.length);
|
|
@@ -16823,12 +16925,12 @@ async function simulateAccountHealthCache(props) {
|
|
|
16823
16925
|
console.log("LendrAccountPost healthCache internalErr", lendrAccountPost.healthCache.internalErr);
|
|
16824
16926
|
console.log("LendrAccountPost healthCache lndrErr", lendrAccountPost.healthCache.lendrErr);
|
|
16825
16927
|
if (lendrAccountPost.healthCache.lendrErr === 6009) {
|
|
16826
|
-
const assetValue = !wrappedI80F48toBigNumber(lendrAccountPost.healthCache.assetValue).isZero();
|
|
16827
|
-
const liabilityValue = !wrappedI80F48toBigNumber(lendrAccountPost.healthCache.liabilityValue).isZero();
|
|
16828
|
-
const assetValueEquity = !wrappedI80F48toBigNumber(lendrAccountPost.healthCache.assetValueEquity).isZero();
|
|
16829
|
-
const liabilityValueEquity = !wrappedI80F48toBigNumber(lendrAccountPost.healthCache.liabilityValueEquity).isZero();
|
|
16830
|
-
const assetValueMaint = !wrappedI80F48toBigNumber(lendrAccountPost.healthCache.assetValueMaint).isZero();
|
|
16831
|
-
const liabilityValueMaint = !wrappedI80F48toBigNumber(lendrAccountPost.healthCache.liabilityValueMaint).isZero();
|
|
16928
|
+
const assetValue = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.assetValue).isZero();
|
|
16929
|
+
const liabilityValue = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.liabilityValue).isZero();
|
|
16930
|
+
const assetValueEquity = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.assetValueEquity).isZero();
|
|
16931
|
+
const liabilityValueEquity = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.liabilityValueEquity).isZero();
|
|
16932
|
+
const assetValueMaint = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.assetValueMaint).isZero();
|
|
16933
|
+
const liabilityValueMaint = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.liabilityValueMaint).isZero();
|
|
16832
16934
|
if (assetValue && liabilityValue && assetValueEquity && liabilityValueEquity && assetValueMaint && liabilityValueMaint) {
|
|
16833
16935
|
return lendrAccountPost;
|
|
16834
16936
|
}
|
|
@@ -16864,15 +16966,15 @@ async function createUpdateFeedIx(props) {
|
|
|
16864
16966
|
*/
|
|
16865
16967
|
async function createLendrAccountTx(props) {
|
|
16866
16968
|
const authority = props.lendrAccount?.authority ?? props.lendrClient.provider.publicKey;
|
|
16867
|
-
const lendrAccountKeypair = Keypair.generate();
|
|
16868
|
-
const dummyWrappedI80F48 = bigNumberToWrappedI80F48(new
|
|
16969
|
+
const lendrAccountKeypair = __solana_web3_js.Keypair.generate();
|
|
16970
|
+
const dummyWrappedI80F48 = require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0));
|
|
16869
16971
|
const dummyBalances = Array(15).fill({
|
|
16870
16972
|
active: false,
|
|
16871
|
-
bankPk: new PublicKey("11111111111111111111111111111111"),
|
|
16973
|
+
bankPk: new __solana_web3_js.PublicKey("11111111111111111111111111111111"),
|
|
16872
16974
|
assetShares: dummyWrappedI80F48,
|
|
16873
16975
|
liabilityShares: dummyWrappedI80F48,
|
|
16874
16976
|
emissionsOutstanding: dummyWrappedI80F48,
|
|
16875
|
-
lastUpdate: new
|
|
16977
|
+
lastUpdate: new bn_js.default(0)
|
|
16876
16978
|
});
|
|
16877
16979
|
const rawAccount = {
|
|
16878
16980
|
group: props.lendrClient.group.address,
|
|
@@ -16915,21 +17017,21 @@ async function createLendrAccountTx(props) {
|
|
|
16915
17017
|
0,
|
|
16916
17018
|
0
|
|
16917
17019
|
] },
|
|
16918
|
-
timestamp: new
|
|
17020
|
+
timestamp: new bn_js.default(0),
|
|
16919
17021
|
flags: 0,
|
|
16920
17022
|
prices: [],
|
|
16921
|
-
assetValueMaint: bigNumberToWrappedI80F48(new
|
|
16922
|
-
liabilityValueMaint: bigNumberToWrappedI80F48(new
|
|
16923
|
-
assetValueEquity: bigNumberToWrappedI80F48(new
|
|
16924
|
-
liabilityValueEquity: bigNumberToWrappedI80F48(new
|
|
17023
|
+
assetValueMaint: require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0)),
|
|
17024
|
+
liabilityValueMaint: require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0)),
|
|
17025
|
+
assetValueEquity: require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0)),
|
|
17026
|
+
liabilityValueEquity: require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0)),
|
|
16925
17027
|
errIndex: 0,
|
|
16926
17028
|
internalErr: 0,
|
|
16927
17029
|
internalBankruptcyErr: 0,
|
|
16928
17030
|
internalLiqErr: 0,
|
|
16929
17031
|
lendrErr: 0
|
|
16930
17032
|
},
|
|
16931
|
-
emissionsDestinationAccount: new PublicKey("11111111111111111111111111111111"),
|
|
16932
|
-
accountFlags: new
|
|
17033
|
+
emissionsDestinationAccount: new __solana_web3_js.PublicKey("11111111111111111111111111111111"),
|
|
17034
|
+
accountFlags: new bn_js.default([
|
|
16933
17035
|
0,
|
|
16934
17036
|
0,
|
|
16935
17037
|
0
|
|
@@ -16997,28 +17099,28 @@ function getActiveStaleBanks(balances, banks, additionalBanks, oraclePrices, max
|
|
|
16997
17099
|
//#endregion
|
|
16998
17100
|
//#region src/services/group/group.service.ts
|
|
16999
17101
|
async function makeEnableFlashLoanForAccountIx(program, lendrAccountAddress) {
|
|
17000
|
-
const ix = await instructions_default.makeSetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new
|
|
17102
|
+
const ix = await instructions_default.makeSetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new bn_js.default(require_common.FLASHLOAN_ENABLED_FLAG) });
|
|
17001
17103
|
return {
|
|
17002
17104
|
instructions: [ix],
|
|
17003
17105
|
keys: []
|
|
17004
17106
|
};
|
|
17005
17107
|
}
|
|
17006
17108
|
async function makeDisableFlashLoanForAccountIx(program, lendrAccountAddress) {
|
|
17007
|
-
const ix = await instructions_default.makeUnsetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new
|
|
17109
|
+
const ix = await instructions_default.makeUnsetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new bn_js.default(require_common.FLASHLOAN_ENABLED_FLAG) });
|
|
17008
17110
|
return {
|
|
17009
17111
|
instructions: [ix],
|
|
17010
17112
|
keys: []
|
|
17011
17113
|
};
|
|
17012
17114
|
}
|
|
17013
17115
|
async function makeEnableAccountTransferForAccountIx(program, lendrAccountAddress) {
|
|
17014
|
-
const ix = await instructions_default.makeSetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new
|
|
17116
|
+
const ix = await instructions_default.makeSetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new bn_js.default(require_common.TRANSFER_ACCOUNT_AUTHORITY_FLAG) });
|
|
17015
17117
|
return {
|
|
17016
17118
|
instructions: [ix],
|
|
17017
17119
|
keys: []
|
|
17018
17120
|
};
|
|
17019
17121
|
}
|
|
17020
17122
|
async function makeDisableAccountTransferForAccountIx(program, lendrAccountAddress) {
|
|
17021
|
-
const ix = await instructions_default.makeUnsetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new
|
|
17123
|
+
const ix = await instructions_default.makeUnsetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new bn_js.default(require_common.TRANSFER_ACCOUNT_AUTHORITY_FLAG) });
|
|
17022
17124
|
return {
|
|
17023
17125
|
instructions: [ix],
|
|
17024
17126
|
keys: []
|
|
@@ -17032,7 +17134,7 @@ async function makePoolConfigureBankIx(program, bank, args) {
|
|
|
17032
17134
|
};
|
|
17033
17135
|
}
|
|
17034
17136
|
async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddress, feePayer, pythOracle) {
|
|
17035
|
-
const [settingsKey] = PublicKey.findProgramAddressSync([Buffer.from("staked_settings", "utf-8"), group.toBuffer()], program.programId);
|
|
17137
|
+
const [settingsKey] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("staked_settings", "utf-8"), group.toBuffer()], program.programId);
|
|
17036
17138
|
const poolAddress = findPoolAddress(voteAccountAddress);
|
|
17037
17139
|
const solPool = findPoolStakeAddress(poolAddress);
|
|
17038
17140
|
const lstMint = findPoolMintAddress(poolAddress);
|
|
@@ -17054,25 +17156,25 @@ async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddr
|
|
|
17054
17156
|
isWritable: false
|
|
17055
17157
|
},
|
|
17056
17158
|
{
|
|
17057
|
-
pubkey: SYSVAR_RENT_PUBKEY,
|
|
17159
|
+
pubkey: __solana_web3_js.SYSVAR_RENT_PUBKEY,
|
|
17058
17160
|
isSigner: false,
|
|
17059
17161
|
isWritable: false
|
|
17060
17162
|
},
|
|
17061
17163
|
{
|
|
17062
|
-
pubkey: SystemProgram.programId,
|
|
17164
|
+
pubkey: __solana_web3_js.SystemProgram.programId,
|
|
17063
17165
|
isSigner: false,
|
|
17064
17166
|
isWritable: false
|
|
17065
17167
|
},
|
|
17066
17168
|
{
|
|
17067
|
-
pubkey: StakeProgram.programId,
|
|
17169
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
17068
17170
|
isSigner: false,
|
|
17069
17171
|
isWritable: false
|
|
17070
17172
|
}
|
|
17071
17173
|
];
|
|
17072
17174
|
const data = Buffer.from(Uint8Array.of(6));
|
|
17073
|
-
const onrampIx = new TransactionInstruction({
|
|
17175
|
+
const onrampIx = new __solana_web3_js.TransactionInstruction({
|
|
17074
17176
|
keys,
|
|
17075
|
-
programId: SINGLE_POOL_PROGRAM_ID,
|
|
17177
|
+
programId: require_common.SINGLE_POOL_PROGRAM_ID,
|
|
17076
17178
|
data
|
|
17077
17179
|
});
|
|
17078
17180
|
const remainingKeys = [
|
|
@@ -17090,13 +17192,13 @@ async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddr
|
|
|
17090
17192
|
pubkey: key,
|
|
17091
17193
|
isSigner: false,
|
|
17092
17194
|
isWritable: false
|
|
17093
|
-
})), { seed: new
|
|
17195
|
+
})), { seed: new bn_js.default(0) });
|
|
17094
17196
|
return {
|
|
17095
17197
|
instructions: [ix],
|
|
17096
17198
|
keys: []
|
|
17097
17199
|
};
|
|
17098
17200
|
}
|
|
17099
|
-
async function makePoolAddBankIx(program, group, bank, feePayer, bankMint, bankConfig, tokenProgram = TOKEN_PROGRAM_ID, overrideOpt = {}) {
|
|
17201
|
+
async function makePoolAddBankIx(program, group, bank, feePayer, bankMint, bankConfig, tokenProgram = __solana_spl_token.TOKEN_PROGRAM_ID, overrideOpt = {}) {
|
|
17100
17202
|
const rawBankConfig = serializeBankConfigOpt(bankConfig);
|
|
17101
17203
|
const rawBankConfigCompact = {
|
|
17102
17204
|
...rawBankConfig,
|
|
@@ -17122,8 +17224,8 @@ async function makePoolAddBankIx(program, group, bank, feePayer, bankMint, bankC
|
|
|
17122
17224
|
//#region src/services/group/utils/deserialize.utils.ts
|
|
17123
17225
|
function dtoToGroup(groupDto) {
|
|
17124
17226
|
return {
|
|
17125
|
-
admin: new PublicKey(groupDto.admin),
|
|
17126
|
-
address: new PublicKey(groupDto.address)
|
|
17227
|
+
admin: new __solana_web3_js.PublicKey(groupDto.admin),
|
|
17228
|
+
address: new __solana_web3_js.PublicKey(groupDto.address)
|
|
17127
17229
|
};
|
|
17128
17230
|
}
|
|
17129
17231
|
|
|
@@ -17140,16 +17242,16 @@ function groupToDto(group) {
|
|
|
17140
17242
|
//#region src/services/native-stake/utils/deserialize.utils.ts
|
|
17141
17243
|
function dtoToValidatorStakeGroup(validatorStakeGroupDto) {
|
|
17142
17244
|
return {
|
|
17143
|
-
validator: new PublicKey(validatorStakeGroupDto.validator),
|
|
17144
|
-
poolKey: new PublicKey(validatorStakeGroupDto.poolKey),
|
|
17145
|
-
poolMintKey: new PublicKey(validatorStakeGroupDto.poolMintKey),
|
|
17245
|
+
validator: new __solana_web3_js.PublicKey(validatorStakeGroupDto.validator),
|
|
17246
|
+
poolKey: new __solana_web3_js.PublicKey(validatorStakeGroupDto.poolKey),
|
|
17247
|
+
poolMintKey: new __solana_web3_js.PublicKey(validatorStakeGroupDto.poolMintKey),
|
|
17146
17248
|
totalStake: validatorStakeGroupDto.totalStake,
|
|
17147
17249
|
selectedAccount: {
|
|
17148
|
-
pubkey: new PublicKey(validatorStakeGroupDto.selectedAccount.pubkey),
|
|
17250
|
+
pubkey: new __solana_web3_js.PublicKey(validatorStakeGroupDto.selectedAccount.pubkey),
|
|
17149
17251
|
amount: validatorStakeGroupDto.selectedAccount.amount
|
|
17150
17252
|
},
|
|
17151
17253
|
accounts: validatorStakeGroupDto.accounts.map((account) => ({
|
|
17152
|
-
pubkey: new PublicKey(account.pubkey),
|
|
17254
|
+
pubkey: new __solana_web3_js.PublicKey(account.pubkey),
|
|
17153
17255
|
amount: account.amount
|
|
17154
17256
|
}))
|
|
17155
17257
|
};
|
|
@@ -17173,7 +17275,7 @@ const fetchNativeStakeAccounts = async (connection, publicKey, opts = { filterIn
|
|
|
17173
17275
|
}
|
|
17174
17276
|
try {
|
|
17175
17277
|
const epochInfo = await connection.getEpochInfo();
|
|
17176
|
-
const accounts$2 = await connection.getParsedProgramAccounts(StakeProgram.programId, { filters: [{ memcmp: {
|
|
17278
|
+
const accounts$2 = await connection.getParsedProgramAccounts(__solana_web3_js.StakeProgram.programId, { filters: [{ memcmp: {
|
|
17177
17279
|
offset: 12,
|
|
17178
17280
|
bytes: publicKey.toBase58()
|
|
17179
17281
|
} }] });
|
|
@@ -17181,12 +17283,12 @@ const fetchNativeStakeAccounts = async (connection, publicKey, opts = { filterIn
|
|
|
17181
17283
|
await Promise.all(accounts$2.map(async (acc) => {
|
|
17182
17284
|
const parsedAccount = acc.account.data;
|
|
17183
17285
|
const stakeInfo = parsedAccount.parsed.info;
|
|
17184
|
-
if (!stakeInfo.stake?.delegation || opts.filterInactive && (Number(stakeInfo.stake.delegation.activationEpoch) >= epochInfo.epoch || stakeInfo.stake.delegation.deactivationEpoch !== MAX_U64)) {
|
|
17286
|
+
if (!stakeInfo.stake?.delegation || opts.filterInactive && (Number(stakeInfo.stake.delegation.activationEpoch) >= epochInfo.epoch || stakeInfo.stake.delegation.deactivationEpoch !== require_common.MAX_U64)) {
|
|
17185
17287
|
return;
|
|
17186
17288
|
}
|
|
17187
17289
|
const validatorAddress = stakeInfo.stake.delegation.voter;
|
|
17188
17290
|
const accountPubkey = acc.pubkey;
|
|
17189
|
-
const amount = Number(stakeInfo.stake.delegation.stake) / LAMPORTS_PER_SOL;
|
|
17291
|
+
const amount = Number(stakeInfo.stake.delegation.stake) / __solana_web3_js.LAMPORTS_PER_SOL;
|
|
17190
17292
|
const existingAccounts = validatorMap.get(validatorAddress) || [];
|
|
17191
17293
|
validatorMap.set(validatorAddress, [...existingAccounts, {
|
|
17192
17294
|
pubkey: accountPubkey,
|
|
@@ -17194,7 +17296,7 @@ const fetchNativeStakeAccounts = async (connection, publicKey, opts = { filterIn
|
|
|
17194
17296
|
}]);
|
|
17195
17297
|
}));
|
|
17196
17298
|
return Promise.all(Array.from(validatorMap.entries()).map(async ([validatorAddress, accounts$3]) => {
|
|
17197
|
-
const poolKey = findPoolAddress(new PublicKey(validatorAddress));
|
|
17299
|
+
const poolKey = findPoolAddress(new __solana_web3_js.PublicKey(validatorAddress));
|
|
17198
17300
|
const poolMintKey = findPoolMintAddress(poolKey);
|
|
17199
17301
|
const totalStake = accounts$3.reduce((acc, curr) => acc + curr.amount, 0);
|
|
17200
17302
|
const largestAccount = accounts$3.reduce((acc, curr) => acc.amount > curr.amount ? acc : curr);
|
|
@@ -17203,7 +17305,7 @@ const fetchNativeStakeAccounts = async (connection, publicKey, opts = { filterIn
|
|
|
17203
17305
|
sortedAccounts.unshift(sortedAccounts.splice(sortedAccounts.indexOf(largestAccount), 1)[0]);
|
|
17204
17306
|
}
|
|
17205
17307
|
return {
|
|
17206
|
-
validator: new PublicKey(validatorAddress),
|
|
17308
|
+
validator: new __solana_web3_js.PublicKey(validatorAddress),
|
|
17207
17309
|
poolKey,
|
|
17208
17310
|
poolMintKey,
|
|
17209
17311
|
accounts: sortedAccounts,
|
|
@@ -17236,7 +17338,7 @@ const fetchStakePoolActiveStates = async (connection, validatorVoteAccounts) =>
|
|
|
17236
17338
|
poolStakeAddressRecord[poolStakeAddress.toBase58()] = validatorVoteAccount;
|
|
17237
17339
|
});
|
|
17238
17340
|
const poolStakeAddressKeys = Object.keys(poolStakeAddressRecord);
|
|
17239
|
-
const poolStakeAccounts = Object.fromEntries((await chunkedGetRawMultipleAccountInfoOrdered(connection, poolStakeAddressKeys)).map((ai, index) => [poolStakeAddressRecord[poolStakeAddressKeys[index]], ai?.data || null]));
|
|
17341
|
+
const poolStakeAccounts = Object.fromEntries((await require_common.chunkedGetRawMultipleAccountInfoOrdered(connection, poolStakeAddressKeys)).map((ai, index) => [poolStakeAddressRecord[poolStakeAddressKeys[index]], ai?.data || null]));
|
|
17240
17342
|
validatorVoteAccounts.map((validatorVoteAccount) => {
|
|
17241
17343
|
const stakeAccount = fetchStakeAccount(poolStakeAccounts[validatorVoteAccount.toBase58()]);
|
|
17242
17344
|
const poolMintAddress = poolMintAddressRecord[validatorVoteAccount.toBase58()];
|
|
@@ -17266,17 +17368,17 @@ const fetchStakeAccount = (data) => {
|
|
|
17266
17368
|
offset += 4;
|
|
17267
17369
|
const rentExemptReserve = data.readBigUInt64LE(offset);
|
|
17268
17370
|
offset += 8;
|
|
17269
|
-
const staker = new PublicKey(data.subarray(offset, offset + 32));
|
|
17371
|
+
const staker = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17270
17372
|
offset += 32;
|
|
17271
|
-
const withdrawer = new PublicKey(data.subarray(offset, offset + 32));
|
|
17373
|
+
const withdrawer = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17272
17374
|
offset += 32;
|
|
17273
17375
|
const unixTimestamp = data.readBigUInt64LE(offset);
|
|
17274
17376
|
offset += 8;
|
|
17275
17377
|
const epoch = data.readBigUInt64LE(offset);
|
|
17276
17378
|
offset += 8;
|
|
17277
|
-
const custodian = new PublicKey(data.subarray(offset, offset + 32));
|
|
17379
|
+
const custodian = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17278
17380
|
offset += 32;
|
|
17279
|
-
const voterPubkey = new PublicKey(data.subarray(offset, offset + 32));
|
|
17381
|
+
const voterPubkey = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17280
17382
|
offset += 32;
|
|
17281
17383
|
const stake = data.readBigUInt64LE(offset);
|
|
17282
17384
|
offset += 8;
|
|
@@ -17326,7 +17428,7 @@ const fetchStakePoolMev = async (connection, validatorVoteAccounts) => {
|
|
|
17326
17428
|
const poolStakeAddresses = validatorVoteAccounts.map((validatorVoteAccount) => poolStakeAddressRecord[validatorVoteAccount.toBase58()]);
|
|
17327
17429
|
const onRampAddresses = validatorVoteAccounts.map((validatorVoteAccount) => onRampAddressRecord[validatorVoteAccount.toBase58()]);
|
|
17328
17430
|
const allAddresses = [...poolStakeAddresses, ...onRampAddresses].map((address$2) => address$2.toBase58());
|
|
17329
|
-
return chunkedGetRawMultipleAccountInfoOrdered(connection, allAddresses).then((accountInfos) => {
|
|
17431
|
+
return require_common.chunkedGetRawMultipleAccountInfoOrdered(connection, allAddresses).then((accountInfos) => {
|
|
17330
17432
|
const poolStakeInfos = accountInfos.slice(0, poolStakeAddresses.length);
|
|
17331
17433
|
const onRampInfos = accountInfos.slice(poolStakeAddresses.length);
|
|
17332
17434
|
const rent = 2282280;
|
|
@@ -17388,8 +17490,8 @@ var EmodeSettings = class EmodeSettings {
|
|
|
17388
17490
|
return {
|
|
17389
17491
|
collateralBankEmodeTag: parseEmodeTag(entry.collateralBankEmodeTag),
|
|
17390
17492
|
flags: getActiveEmodeEntryFlags(entry.flags),
|
|
17391
|
-
assetWeightInit: wrappedI80F48toBigNumber(entry.assetWeightInit),
|
|
17392
|
-
assetWeightMaint: wrappedI80F48toBigNumber(entry.assetWeightMaint)
|
|
17493
|
+
assetWeightInit: require_common.wrappedI80F48toBigNumber(entry.assetWeightInit),
|
|
17494
|
+
assetWeightMaint: require_common.wrappedI80F48toBigNumber(entry.assetWeightMaint)
|
|
17393
17495
|
};
|
|
17394
17496
|
});
|
|
17395
17497
|
return new EmodeSettings(emodeTag, timestamp, flags, emodeEntries);
|
|
@@ -17399,7 +17501,7 @@ var EmodeSettings = class EmodeSettings {
|
|
|
17399
17501
|
//#endregion
|
|
17400
17502
|
//#region src/services/bank/utils/deserialize.utils.ts
|
|
17401
17503
|
function decodeBankRaw(encoded, idl) {
|
|
17402
|
-
const coder = new BorshCoder(idl);
|
|
17504
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
17403
17505
|
return coder.accounts.decode(AccountType.Bank, encoded);
|
|
17404
17506
|
}
|
|
17405
17507
|
function parseBankRaw(address$2, accountParsed, feedIdMap, bankMetadata) {
|
|
@@ -17407,28 +17509,28 @@ function parseBankRaw(address$2, accountParsed, feedIdMap, bankMetadata) {
|
|
|
17407
17509
|
const mint = accountParsed.mint;
|
|
17408
17510
|
const mintDecimals = accountParsed.mintDecimals;
|
|
17409
17511
|
const group = accountParsed.group;
|
|
17410
|
-
const assetShareValue = wrappedI80F48toBigNumber(accountParsed.assetShareValue);
|
|
17411
|
-
const liabilityShareValue = wrappedI80F48toBigNumber(accountParsed.liabilityShareValue);
|
|
17512
|
+
const assetShareValue = require_common.wrappedI80F48toBigNumber(accountParsed.assetShareValue);
|
|
17513
|
+
const liabilityShareValue = require_common.wrappedI80F48toBigNumber(accountParsed.liabilityShareValue);
|
|
17412
17514
|
const liquidityVault = accountParsed.liquidityVault;
|
|
17413
17515
|
const liquidityVaultBump = accountParsed.liquidityVaultBump;
|
|
17414
17516
|
const liquidityVaultAuthorityBump = accountParsed.liquidityVaultAuthorityBump;
|
|
17415
17517
|
const insuranceVault = accountParsed.insuranceVault;
|
|
17416
17518
|
const insuranceVaultBump = accountParsed.insuranceVaultBump;
|
|
17417
17519
|
const insuranceVaultAuthorityBump = accountParsed.insuranceVaultAuthorityBump;
|
|
17418
|
-
const collectedInsuranceFeesOutstanding = wrappedI80F48toBigNumber(accountParsed.collectedInsuranceFeesOutstanding);
|
|
17520
|
+
const collectedInsuranceFeesOutstanding = require_common.wrappedI80F48toBigNumber(accountParsed.collectedInsuranceFeesOutstanding);
|
|
17419
17521
|
const feeVault = accountParsed.feeVault;
|
|
17420
17522
|
const feeVaultBump = accountParsed.feeVaultBump;
|
|
17421
17523
|
const feeVaultAuthorityBump = accountParsed.feeVaultAuthorityBump;
|
|
17422
|
-
const collectedGroupFeesOutstanding = wrappedI80F48toBigNumber(accountParsed.collectedGroupFeesOutstanding);
|
|
17524
|
+
const collectedGroupFeesOutstanding = require_common.wrappedI80F48toBigNumber(accountParsed.collectedGroupFeesOutstanding);
|
|
17423
17525
|
const config = parseBankConfigRaw(accountParsed.config);
|
|
17424
17526
|
const lastUpdate = accountParsed.lastUpdate.toNumber();
|
|
17425
|
-
const totalAssetShares = wrappedI80F48toBigNumber(accountParsed.totalAssetShares);
|
|
17426
|
-
const totalLiabilityShares = wrappedI80F48toBigNumber(accountParsed.totalLiabilityShares);
|
|
17527
|
+
const totalAssetShares = require_common.wrappedI80F48toBigNumber(accountParsed.totalAssetShares);
|
|
17528
|
+
const totalLiabilityShares = require_common.wrappedI80F48toBigNumber(accountParsed.totalLiabilityShares);
|
|
17427
17529
|
const emissionsActiveBorrowing = (flags & 1) > 0;
|
|
17428
17530
|
const emissionsActiveLending = (flags & 2) > 0;
|
|
17429
17531
|
const emissionsRate = accountParsed.emissionsRate.toNumber();
|
|
17430
17532
|
const emissionsMint = accountParsed.emissionsMint;
|
|
17431
|
-
const emissionsRemaining = accountParsed.emissionsRemaining ? wrappedI80F48toBigNumber(accountParsed.emissionsRemaining) : new
|
|
17533
|
+
const emissionsRemaining = accountParsed.emissionsRemaining ? require_common.wrappedI80F48toBigNumber(accountParsed.emissionsRemaining) : new bignumber_js.default(0);
|
|
17432
17534
|
const { oracleKey, shardId: pythShardId } = feedIdMap ? findOracleKey(config, feedIdMap) : { oracleKey: config.oracleKeys[0] };
|
|
17433
17535
|
const emode = EmodeSettings.from(accountParsed.emode);
|
|
17434
17536
|
const tokenSymbol = bankMetadata?.tokenSymbol;
|
|
@@ -17467,33 +17569,33 @@ function parseBankRaw(address$2, accountParsed, feedIdMap, bankMetadata) {
|
|
|
17467
17569
|
}
|
|
17468
17570
|
function dtoToBank(bankDto) {
|
|
17469
17571
|
return {
|
|
17470
|
-
address: new PublicKey(bankDto.address),
|
|
17471
|
-
group: new PublicKey(bankDto.group),
|
|
17472
|
-
mint: new PublicKey(bankDto.mint),
|
|
17572
|
+
address: new __solana_web3_js.PublicKey(bankDto.address),
|
|
17573
|
+
group: new __solana_web3_js.PublicKey(bankDto.group),
|
|
17574
|
+
mint: new __solana_web3_js.PublicKey(bankDto.mint),
|
|
17473
17575
|
mintDecimals: bankDto.mintDecimals,
|
|
17474
|
-
assetShareValue: new
|
|
17475
|
-
liabilityShareValue: new
|
|
17476
|
-
liquidityVault: new PublicKey(bankDto.liquidityVault),
|
|
17576
|
+
assetShareValue: new bignumber_js.default(bankDto.assetShareValue),
|
|
17577
|
+
liabilityShareValue: new bignumber_js.default(bankDto.liabilityShareValue),
|
|
17578
|
+
liquidityVault: new __solana_web3_js.PublicKey(bankDto.liquidityVault),
|
|
17477
17579
|
liquidityVaultBump: bankDto.liquidityVaultBump,
|
|
17478
17580
|
liquidityVaultAuthorityBump: bankDto.liquidityVaultAuthorityBump,
|
|
17479
|
-
insuranceVault: new PublicKey(bankDto.insuranceVault),
|
|
17581
|
+
insuranceVault: new __solana_web3_js.PublicKey(bankDto.insuranceVault),
|
|
17480
17582
|
insuranceVaultBump: bankDto.insuranceVaultBump,
|
|
17481
17583
|
insuranceVaultAuthorityBump: bankDto.insuranceVaultAuthorityBump,
|
|
17482
|
-
collectedInsuranceFeesOutstanding: new
|
|
17483
|
-
feeVault: new PublicKey(bankDto.feeVault),
|
|
17584
|
+
collectedInsuranceFeesOutstanding: new bignumber_js.default(bankDto.collectedInsuranceFeesOutstanding),
|
|
17585
|
+
feeVault: new __solana_web3_js.PublicKey(bankDto.feeVault),
|
|
17484
17586
|
feeVaultBump: bankDto.feeVaultBump,
|
|
17485
17587
|
feeVaultAuthorityBump: bankDto.feeVaultAuthorityBump,
|
|
17486
|
-
collectedGroupFeesOutstanding: new
|
|
17588
|
+
collectedGroupFeesOutstanding: new bignumber_js.default(bankDto.collectedGroupFeesOutstanding),
|
|
17487
17589
|
lastUpdate: bankDto.lastUpdate,
|
|
17488
17590
|
config: dtoToBankConfig(bankDto.config),
|
|
17489
|
-
totalAssetShares: new
|
|
17490
|
-
totalLiabilityShares: new
|
|
17591
|
+
totalAssetShares: new bignumber_js.default(bankDto.totalAssetShares),
|
|
17592
|
+
totalLiabilityShares: new bignumber_js.default(bankDto.totalLiabilityShares),
|
|
17491
17593
|
emissionsActiveBorrowing: bankDto.emissionsActiveBorrowing,
|
|
17492
17594
|
emissionsActiveLending: bankDto.emissionsActiveLending,
|
|
17493
17595
|
emissionsRate: bankDto.emissionsRate,
|
|
17494
|
-
emissionsMint: new PublicKey(bankDto.emissionsMint),
|
|
17495
|
-
emissionsRemaining: new
|
|
17496
|
-
oracleKey: new PublicKey(bankDto.oracleKey),
|
|
17596
|
+
emissionsMint: new __solana_web3_js.PublicKey(bankDto.emissionsMint),
|
|
17597
|
+
emissionsRemaining: new bignumber_js.default(bankDto.emissionsRemaining),
|
|
17598
|
+
oracleKey: new __solana_web3_js.PublicKey(bankDto.oracleKey),
|
|
17497
17599
|
pythShardId: bankDto.pythShardId,
|
|
17498
17600
|
emode: dtoToEmodeSettings(bankDto.emode),
|
|
17499
17601
|
tokenSymbol: bankDto.tokenSymbol
|
|
@@ -17508,76 +17610,76 @@ function dtoToEmodeSettings(emodeSettingsDto) {
|
|
|
17508
17610
|
return {
|
|
17509
17611
|
collateralBankEmodeTag: entry.collateralBankEmodeTag,
|
|
17510
17612
|
flags: entry.flags,
|
|
17511
|
-
assetWeightInit: new
|
|
17512
|
-
assetWeightMaint: new
|
|
17613
|
+
assetWeightInit: new bignumber_js.default(entry.assetWeightInit),
|
|
17614
|
+
assetWeightMaint: new bignumber_js.default(entry.assetWeightMaint)
|
|
17513
17615
|
};
|
|
17514
17616
|
})
|
|
17515
17617
|
};
|
|
17516
17618
|
}
|
|
17517
17619
|
function dtoToBankConfig(bankConfigDto) {
|
|
17518
17620
|
return {
|
|
17519
|
-
assetWeightInit: new
|
|
17520
|
-
assetWeightMaint: new
|
|
17521
|
-
liabilityWeightInit: new
|
|
17522
|
-
liabilityWeightMaint: new
|
|
17523
|
-
depositLimit: new
|
|
17524
|
-
borrowLimit: new
|
|
17621
|
+
assetWeightInit: new bignumber_js.default(bankConfigDto.assetWeightInit),
|
|
17622
|
+
assetWeightMaint: new bignumber_js.default(bankConfigDto.assetWeightMaint),
|
|
17623
|
+
liabilityWeightInit: new bignumber_js.default(bankConfigDto.liabilityWeightInit),
|
|
17624
|
+
liabilityWeightMaint: new bignumber_js.default(bankConfigDto.liabilityWeightMaint),
|
|
17625
|
+
depositLimit: new bignumber_js.default(bankConfigDto.depositLimit),
|
|
17626
|
+
borrowLimit: new bignumber_js.default(bankConfigDto.borrowLimit),
|
|
17525
17627
|
riskTier: bankConfigDto.riskTier,
|
|
17526
17628
|
operationalState: bankConfigDto.operationalState,
|
|
17527
|
-
totalAssetValueInitLimit: new
|
|
17629
|
+
totalAssetValueInitLimit: new bignumber_js.default(bankConfigDto.totalAssetValueInitLimit),
|
|
17528
17630
|
assetTag: bankConfigDto.assetTag,
|
|
17529
17631
|
oracleSetup: bankConfigDto.oracleSetup,
|
|
17530
|
-
oracleKeys: bankConfigDto.oracleKeys.map((key) => new PublicKey(key)),
|
|
17632
|
+
oracleKeys: bankConfigDto.oracleKeys.map((key) => new __solana_web3_js.PublicKey(key)),
|
|
17531
17633
|
oracleMaxAge: bankConfigDto.oracleMaxAge,
|
|
17532
17634
|
interestRateConfig: dtoToInterestRateConfig(bankConfigDto.interestRateConfig)
|
|
17533
17635
|
};
|
|
17534
17636
|
}
|
|
17535
17637
|
function dtoToInterestRateConfig(interestRateConfigDto) {
|
|
17536
17638
|
return {
|
|
17537
|
-
optimalUtilizationRate: new
|
|
17538
|
-
plateauInterestRate: new
|
|
17539
|
-
maxInterestRate: new
|
|
17540
|
-
insuranceFeeFixedApr: new
|
|
17541
|
-
insuranceIrFee: new
|
|
17542
|
-
protocolFixedFeeApr: new
|
|
17543
|
-
protocolIrFee: new
|
|
17544
|
-
protocolOriginationFee: new
|
|
17639
|
+
optimalUtilizationRate: new bignumber_js.default(interestRateConfigDto.optimalUtilizationRate),
|
|
17640
|
+
plateauInterestRate: new bignumber_js.default(interestRateConfigDto.plateauInterestRate),
|
|
17641
|
+
maxInterestRate: new bignumber_js.default(interestRateConfigDto.maxInterestRate),
|
|
17642
|
+
insuranceFeeFixedApr: new bignumber_js.default(interestRateConfigDto.insuranceFeeFixedApr),
|
|
17643
|
+
insuranceIrFee: new bignumber_js.default(interestRateConfigDto.insuranceIrFee),
|
|
17644
|
+
protocolFixedFeeApr: new bignumber_js.default(interestRateConfigDto.protocolFixedFeeApr),
|
|
17645
|
+
protocolIrFee: new bignumber_js.default(interestRateConfigDto.protocolIrFee),
|
|
17646
|
+
protocolOriginationFee: new bignumber_js.default(interestRateConfigDto.protocolOriginationFee)
|
|
17545
17647
|
};
|
|
17546
17648
|
}
|
|
17547
17649
|
function dtoToBankRaw(bankDto) {
|
|
17548
17650
|
return {
|
|
17549
|
-
group: new PublicKey(bankDto.group),
|
|
17550
|
-
mint: new PublicKey(bankDto.mint),
|
|
17651
|
+
group: new __solana_web3_js.PublicKey(bankDto.group),
|
|
17652
|
+
mint: new __solana_web3_js.PublicKey(bankDto.mint),
|
|
17551
17653
|
mintDecimals: bankDto.mintDecimals,
|
|
17552
17654
|
assetShareValue: bankDto.assetShareValue,
|
|
17553
17655
|
liabilityShareValue: bankDto.liabilityShareValue,
|
|
17554
|
-
liquidityVault: new PublicKey(bankDto.liquidityVault),
|
|
17656
|
+
liquidityVault: new __solana_web3_js.PublicKey(bankDto.liquidityVault),
|
|
17555
17657
|
liquidityVaultBump: bankDto.liquidityVaultBump,
|
|
17556
17658
|
liquidityVaultAuthorityBump: bankDto.liquidityVaultAuthorityBump,
|
|
17557
|
-
insuranceVault: new PublicKey(bankDto.insuranceVault),
|
|
17659
|
+
insuranceVault: new __solana_web3_js.PublicKey(bankDto.insuranceVault),
|
|
17558
17660
|
insuranceVaultBump: bankDto.insuranceVaultBump,
|
|
17559
17661
|
insuranceVaultAuthorityBump: bankDto.insuranceVaultAuthorityBump,
|
|
17560
17662
|
collectedInsuranceFeesOutstanding: bankDto.collectedInsuranceFeesOutstanding,
|
|
17561
|
-
feeVault: new PublicKey(bankDto.feeVault),
|
|
17663
|
+
feeVault: new __solana_web3_js.PublicKey(bankDto.feeVault),
|
|
17562
17664
|
feeVaultBump: bankDto.feeVaultBump,
|
|
17563
17665
|
feeVaultAuthorityBump: bankDto.feeVaultAuthorityBump,
|
|
17564
17666
|
collectedGroupFeesOutstanding: bankDto.collectedGroupFeesOutstanding,
|
|
17565
|
-
lastUpdate: new
|
|
17667
|
+
lastUpdate: new bn_js.default(bankDto.lastUpdate),
|
|
17566
17668
|
config: dtoToBankConfigRaw(bankDto.config),
|
|
17567
17669
|
totalAssetShares: bankDto.totalAssetShares,
|
|
17568
17670
|
totalLiabilityShares: bankDto.totalLiabilityShares,
|
|
17569
|
-
flags: new
|
|
17570
|
-
emissionsRate: new
|
|
17671
|
+
flags: new bn_js.default(bankDto.flags),
|
|
17672
|
+
emissionsRate: new bn_js.default(bankDto.emissionsRate),
|
|
17571
17673
|
emissionsRemaining: bankDto.emissionsRemaining,
|
|
17572
|
-
emissionsMint: new PublicKey(bankDto.emissionsMint),
|
|
17674
|
+
emissionsMint: new __solana_web3_js.PublicKey(bankDto.emissionsMint),
|
|
17573
17675
|
emode: dtoToEmodeSettingsRaw(bankDto.emode)
|
|
17574
17676
|
};
|
|
17575
17677
|
}
|
|
17576
17678
|
function dtoToEmodeSettingsRaw(emodeSettingsDto) {
|
|
17577
17679
|
return {
|
|
17578
17680
|
emodeTag: emodeSettingsDto.emodeTag,
|
|
17579
|
-
timestamp: new
|
|
17580
|
-
flags: new
|
|
17681
|
+
timestamp: new bn_js.default(emodeSettingsDto.timestamp),
|
|
17682
|
+
flags: new bn_js.default(emodeSettingsDto.flags),
|
|
17581
17683
|
emodeConfig: { entries: emodeSettingsDto.emodeConfig.entries.map((entry) => {
|
|
17582
17684
|
return {
|
|
17583
17685
|
collateralBankEmodeTag: entry.collateralBankEmodeTag,
|
|
@@ -17594,41 +17696,41 @@ function dtoToBankConfigRaw(bankConfigDto) {
|
|
|
17594
17696
|
assetWeightMaint: bankConfigDto.assetWeightMaint,
|
|
17595
17697
|
liabilityWeightInit: bankConfigDto.liabilityWeightInit,
|
|
17596
17698
|
liabilityWeightMaint: bankConfigDto.liabilityWeightMaint,
|
|
17597
|
-
depositLimit: new
|
|
17598
|
-
borrowLimit: new
|
|
17699
|
+
depositLimit: new bn_js.default(bankConfigDto.depositLimit),
|
|
17700
|
+
borrowLimit: new bn_js.default(bankConfigDto.borrowLimit),
|
|
17599
17701
|
riskTier: bankConfigDto.riskTier,
|
|
17600
17702
|
operationalState: bankConfigDto.operationalState,
|
|
17601
|
-
totalAssetValueInitLimit: new
|
|
17703
|
+
totalAssetValueInitLimit: new bn_js.default(bankConfigDto.totalAssetValueInitLimit),
|
|
17602
17704
|
assetTag: bankConfigDto.assetTag,
|
|
17603
17705
|
oracleSetup: bankConfigDto.oracleSetup,
|
|
17604
|
-
oracleKeys: bankConfigDto.oracleKeys.map((key) => new PublicKey(key)),
|
|
17706
|
+
oracleKeys: bankConfigDto.oracleKeys.map((key) => new __solana_web3_js.PublicKey(key)),
|
|
17605
17707
|
oracleMaxAge: bankConfigDto.oracleMaxAge,
|
|
17606
17708
|
interestRateConfig: bankConfigDto.interestRateConfig
|
|
17607
17709
|
};
|
|
17608
17710
|
}
|
|
17609
17711
|
function parseBankConfigRaw(bankConfigRaw) {
|
|
17610
|
-
const assetWeightInit = wrappedI80F48toBigNumber(bankConfigRaw.assetWeightInit);
|
|
17611
|
-
const assetWeightMaint = wrappedI80F48toBigNumber(bankConfigRaw.assetWeightMaint);
|
|
17612
|
-
const liabilityWeightInit = wrappedI80F48toBigNumber(bankConfigRaw.liabilityWeightInit);
|
|
17613
|
-
const liabilityWeightMaint = wrappedI80F48toBigNumber(bankConfigRaw.liabilityWeightMaint);
|
|
17614
|
-
const depositLimit =
|
|
17615
|
-
const borrowLimit =
|
|
17712
|
+
const assetWeightInit = require_common.wrappedI80F48toBigNumber(bankConfigRaw.assetWeightInit);
|
|
17713
|
+
const assetWeightMaint = require_common.wrappedI80F48toBigNumber(bankConfigRaw.assetWeightMaint);
|
|
17714
|
+
const liabilityWeightInit = require_common.wrappedI80F48toBigNumber(bankConfigRaw.liabilityWeightInit);
|
|
17715
|
+
const liabilityWeightMaint = require_common.wrappedI80F48toBigNumber(bankConfigRaw.liabilityWeightMaint);
|
|
17716
|
+
const depositLimit = (0, bignumber_js.default)(bankConfigRaw.depositLimit.toString());
|
|
17717
|
+
const borrowLimit = (0, bignumber_js.default)(bankConfigRaw.borrowLimit.toString());
|
|
17616
17718
|
const riskTier = parseRiskTier(bankConfigRaw.riskTier);
|
|
17617
17719
|
const operationalState = parseOperationalState(bankConfigRaw.operationalState);
|
|
17618
|
-
const totalAssetValueInitLimit =
|
|
17720
|
+
const totalAssetValueInitLimit = (0, bignumber_js.default)(bankConfigRaw.totalAssetValueInitLimit.toString());
|
|
17619
17721
|
const assetTag = bankConfigRaw.assetTag;
|
|
17620
17722
|
const oracleSetup = parseOracleSetup(bankConfigRaw.oracleSetup);
|
|
17621
17723
|
const oracleKeys = bankConfigRaw.oracleKeys;
|
|
17622
|
-
const oracleMaxAge = bankConfigRaw.oracleMaxAge === 0 ? DEFAULT_ORACLE_MAX_AGE : bankConfigRaw.oracleMaxAge;
|
|
17724
|
+
const oracleMaxAge = bankConfigRaw.oracleMaxAge === 0 ? require_common.DEFAULT_ORACLE_MAX_AGE : bankConfigRaw.oracleMaxAge;
|
|
17623
17725
|
const interestRateConfig = {
|
|
17624
|
-
insuranceFeeFixedApr: wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.insuranceFeeFixedApr),
|
|
17625
|
-
maxInterestRate: wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.maxInterestRate),
|
|
17626
|
-
insuranceIrFee: wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.insuranceIrFee),
|
|
17627
|
-
optimalUtilizationRate: wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.optimalUtilizationRate),
|
|
17628
|
-
plateauInterestRate: wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.plateauInterestRate),
|
|
17629
|
-
protocolFixedFeeApr: wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.protocolFixedFeeApr),
|
|
17630
|
-
protocolIrFee: wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.protocolIrFee),
|
|
17631
|
-
protocolOriginationFee: wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.protocolOriginationFee)
|
|
17726
|
+
insuranceFeeFixedApr: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.insuranceFeeFixedApr),
|
|
17727
|
+
maxInterestRate: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.maxInterestRate),
|
|
17728
|
+
insuranceIrFee: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.insuranceIrFee),
|
|
17729
|
+
optimalUtilizationRate: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.optimalUtilizationRate),
|
|
17730
|
+
plateauInterestRate: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.plateauInterestRate),
|
|
17731
|
+
protocolFixedFeeApr: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.protocolFixedFeeApr),
|
|
17732
|
+
protocolIrFee: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.protocolIrFee),
|
|
17733
|
+
protocolOriginationFee: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.protocolOriginationFee)
|
|
17632
17734
|
};
|
|
17633
17735
|
return {
|
|
17634
17736
|
assetWeightInit,
|
|
@@ -17691,7 +17793,7 @@ function getActiveEmodeFlags(flags) {
|
|
|
17691
17793
|
* Check if a specific EMode flag is set
|
|
17692
17794
|
*/
|
|
17693
17795
|
function hasEmodeFlag(flags, flag) {
|
|
17694
|
-
return !flags.and(new
|
|
17796
|
+
return !flags.and(new bn_js.default(flag)).isZero();
|
|
17695
17797
|
}
|
|
17696
17798
|
/**
|
|
17697
17799
|
* Get all active EMode entry flags as an array of flag names
|
|
@@ -17738,17 +17840,17 @@ const getStakeAccount = (data) => {
|
|
|
17738
17840
|
offset += 4;
|
|
17739
17841
|
const rentExemptReserve = data.readBigUInt64LE(offset);
|
|
17740
17842
|
offset += 8;
|
|
17741
|
-
const staker = new PublicKey(data.subarray(offset, offset + 32));
|
|
17843
|
+
const staker = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17742
17844
|
offset += 32;
|
|
17743
|
-
const withdrawer = new PublicKey(data.subarray(offset, offset + 32));
|
|
17845
|
+
const withdrawer = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17744
17846
|
offset += 32;
|
|
17745
17847
|
const unixTimestamp = data.readBigUInt64LE(offset);
|
|
17746
17848
|
offset += 8;
|
|
17747
17849
|
const epoch = data.readBigUInt64LE(offset);
|
|
17748
17850
|
offset += 8;
|
|
17749
|
-
const custodian = new PublicKey(data.subarray(offset, offset + 32));
|
|
17851
|
+
const custodian = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17750
17852
|
offset += 32;
|
|
17751
|
-
const voterPubkey = new PublicKey(data.subarray(offset, offset + 32));
|
|
17853
|
+
const voterPubkey = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17752
17854
|
offset += 32;
|
|
17753
17855
|
const stake = data.readBigUInt64LE(offset);
|
|
17754
17856
|
offset += 8;
|
|
@@ -17786,7 +17888,7 @@ const getStakeAccount = (data) => {
|
|
|
17786
17888
|
//#endregion
|
|
17787
17889
|
//#region src/vendor/index.ts
|
|
17788
17890
|
var vendor_exports = {};
|
|
17789
|
-
__export(vendor_exports, {
|
|
17891
|
+
require_common.__export(vendor_exports, {
|
|
17790
17892
|
AccountType: () => AccountType$1,
|
|
17791
17893
|
AggregatorAccount: () => AggregatorAccount,
|
|
17792
17894
|
AggregatorAccountData: () => AggregatorAccountData,
|
|
@@ -17822,17 +17924,17 @@ __export(vendor_exports, {
|
|
|
17822
17924
|
//#region src/utils.ts
|
|
17823
17925
|
function getBankVaultSeeds(type) {
|
|
17824
17926
|
switch (type) {
|
|
17825
|
-
case BankVaultType.LiquidityVault: return PDA_BANK_LIQUIDITY_VAULT_SEED;
|
|
17826
|
-
case BankVaultType.InsuranceVault: return PDA_BANK_INSURANCE_VAULT_SEED;
|
|
17827
|
-
case BankVaultType.FeeVault: return PDA_BANK_FEE_VAULT_SEED;
|
|
17927
|
+
case BankVaultType.LiquidityVault: return require_common.PDA_BANK_LIQUIDITY_VAULT_SEED;
|
|
17928
|
+
case BankVaultType.InsuranceVault: return require_common.PDA_BANK_INSURANCE_VAULT_SEED;
|
|
17929
|
+
case BankVaultType.FeeVault: return require_common.PDA_BANK_FEE_VAULT_SEED;
|
|
17828
17930
|
default: throw Error(`Unknown vault type ${type}`);
|
|
17829
17931
|
}
|
|
17830
17932
|
}
|
|
17831
17933
|
function getBankVaultAuthoritySeeds(type) {
|
|
17832
17934
|
switch (type) {
|
|
17833
|
-
case BankVaultType.LiquidityVault: return PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED;
|
|
17834
|
-
case BankVaultType.InsuranceVault: return PDA_BANK_INSURANCE_VAULT_AUTH_SEED;
|
|
17835
|
-
case BankVaultType.FeeVault: return PDA_BANK_FEE_VAULT_AUTH_SEED;
|
|
17935
|
+
case BankVaultType.LiquidityVault: return require_common.PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED;
|
|
17936
|
+
case BankVaultType.InsuranceVault: return require_common.PDA_BANK_INSURANCE_VAULT_AUTH_SEED;
|
|
17937
|
+
case BankVaultType.FeeVault: return require_common.PDA_BANK_FEE_VAULT_AUTH_SEED;
|
|
17836
17938
|
default: throw Error(`Unknown vault type ${type}`);
|
|
17837
17939
|
}
|
|
17838
17940
|
}
|
|
@@ -17840,33 +17942,33 @@ function getBankVaultAuthoritySeeds(type) {
|
|
|
17840
17942
|
* Compute authority PDA for a specific lendr group bank vault
|
|
17841
17943
|
*/
|
|
17842
17944
|
function getBankVaultAuthority(bankVaultType, bankPk, programId) {
|
|
17843
|
-
return PublicKey.findProgramAddressSync([getBankVaultAuthoritySeeds(bankVaultType), bankPk.toBuffer()], programId);
|
|
17945
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([getBankVaultAuthoritySeeds(bankVaultType), bankPk.toBuffer()], programId);
|
|
17844
17946
|
}
|
|
17845
17947
|
function makeWrapSolIxs(walletAddress, amount) {
|
|
17846
|
-
const address$2 = getAssociatedTokenAddressSync(NATIVE_MINT, walletAddress, true);
|
|
17847
|
-
const ixs = [createAssociatedTokenAccountIdempotentInstruction(walletAddress, address$2, walletAddress, NATIVE_MINT)];
|
|
17948
|
+
const address$2 = (0, __solana_spl_token.getAssociatedTokenAddressSync)(__solana_spl_token.NATIVE_MINT, walletAddress, true);
|
|
17949
|
+
const ixs = [(0, __solana_spl_token.createAssociatedTokenAccountIdempotentInstruction)(walletAddress, address$2, walletAddress, __solana_spl_token.NATIVE_MINT)];
|
|
17848
17950
|
if (amount.gt(0)) {
|
|
17849
|
-
const nativeAmount = uiToNative(amount, 9).toNumber() + 1e4;
|
|
17850
|
-
ixs.push(SystemProgram.transfer({
|
|
17951
|
+
const nativeAmount = require_common.uiToNative(amount, 9).toNumber() + 1e4;
|
|
17952
|
+
ixs.push(__solana_web3_js.SystemProgram.transfer({
|
|
17851
17953
|
fromPubkey: walletAddress,
|
|
17852
17954
|
toPubkey: address$2,
|
|
17853
17955
|
lamports: nativeAmount
|
|
17854
|
-
}), createSyncNativeInstruction(address$2));
|
|
17956
|
+
}), (0, __solana_spl_token.createSyncNativeInstruction)(address$2));
|
|
17855
17957
|
}
|
|
17856
17958
|
return ixs;
|
|
17857
17959
|
}
|
|
17858
17960
|
function makeUnwrapSolIx(walletAddress) {
|
|
17859
|
-
const address$2 = getAssociatedTokenAddressSync(NATIVE_MINT, walletAddress, true);
|
|
17860
|
-
return createCloseAccountInstruction(address$2, walletAddress, walletAddress);
|
|
17961
|
+
const address$2 = (0, __solana_spl_token.getAssociatedTokenAddressSync)(__solana_spl_token.NATIVE_MINT, walletAddress, true);
|
|
17962
|
+
return (0, __solana_spl_token.createCloseAccountInstruction)(address$2, walletAddress, walletAddress);
|
|
17861
17963
|
}
|
|
17862
17964
|
async function makeVersionedTransaction(blockhash, transaction, payer, addressLookupTables) {
|
|
17863
|
-
const message = new TransactionMessage({
|
|
17965
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
17864
17966
|
instructions: transaction.instructions,
|
|
17865
17967
|
payerKey: payer,
|
|
17866
17968
|
recentBlockhash: blockhash
|
|
17867
17969
|
});
|
|
17868
17970
|
const versionedMessage = addressLookupTables ? message.compileToV0Message(addressLookupTables) : message.compileToLegacyMessage();
|
|
17869
|
-
return new VersionedTransaction(versionedMessage);
|
|
17971
|
+
return new __solana_web3_js.VersionedTransaction(versionedMessage);
|
|
17870
17972
|
}
|
|
17871
17973
|
/**
|
|
17872
17974
|
* Creates a compute budget instruction to set the priority fee for a transaction.
|
|
@@ -17876,7 +17978,7 @@ async function makeVersionedTransaction(blockhash, transaction, payer, addressLo
|
|
|
17876
17978
|
* @returns A compute budget instruction with the specified priority fee
|
|
17877
17979
|
*/
|
|
17878
17980
|
function makePriorityFeeMicroIx(priorityFeeMicro) {
|
|
17879
|
-
return ComputeBudgetProgram.setComputeUnitPrice({ microLamports: Math.floor(priorityFeeMicro ?? 1) });
|
|
17981
|
+
return __solana_web3_js.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: Math.floor(priorityFeeMicro ?? 1) });
|
|
17880
17982
|
}
|
|
17881
17983
|
function makePriorityFeeIx(priorityFeeUi, computeUnitsLimit) {
|
|
17882
17984
|
const priorityFeeIx = [];
|
|
@@ -17885,11 +17987,11 @@ function makePriorityFeeIx(priorityFeeUi, computeUnitsLimit) {
|
|
|
17885
17987
|
if (priorityFeeUi) {
|
|
17886
17988
|
const isAbsurdPriorityFee = priorityFeeUi > .1;
|
|
17887
17989
|
if (!isAbsurdPriorityFee) {
|
|
17888
|
-
const priorityFeeMicroLamports = priorityFeeUi * LAMPORTS_PER_SOL * 1e6;
|
|
17990
|
+
const priorityFeeMicroLamports = priorityFeeUi * __solana_web3_js.LAMPORTS_PER_SOL * 1e6;
|
|
17889
17991
|
microLamports = Math.round(priorityFeeMicroLamports / limit);
|
|
17890
17992
|
}
|
|
17891
17993
|
}
|
|
17892
|
-
priorityFeeIx.push(ComputeBudgetProgram.setComputeUnitPrice({ microLamports }));
|
|
17994
|
+
priorityFeeIx.push(__solana_web3_js.ComputeBudgetProgram.setComputeUnitPrice({ microLamports }));
|
|
17893
17995
|
return priorityFeeIx;
|
|
17894
17996
|
}
|
|
17895
17997
|
function feedIdToString(feedId) {
|
|
@@ -17901,7 +18003,7 @@ async function buildFeedIdMap(bankConfigs, connection) {
|
|
|
17901
18003
|
const feedId = bankConfig.oracleKeys[0].toBuffer();
|
|
17902
18004
|
return {
|
|
17903
18005
|
feedId,
|
|
17904
|
-
addresses: [findPythPushOracleAddress(feedId, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID), findPythPushOracleAddress(feedId, PYTH_PUSH_ORACLE_ID, LENDR_SPONSORED_SHARD_ID)]
|
|
18006
|
+
addresses: [findPythPushOracleAddress(feedId, require_common.PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID), findPythPushOracleAddress(feedId, require_common.PYTH_PUSH_ORACLE_ID, LENDR_SPONSORED_SHARD_ID)]
|
|
17905
18007
|
};
|
|
17906
18008
|
});
|
|
17907
18009
|
const addressess = feedIdsWithAddresses.flatMap((feedIdWithAddress) => feedIdWithAddress.addresses);
|
|
@@ -17977,7 +18079,7 @@ const PYTH_SPONSORED_SHARD_ID = 0;
|
|
|
17977
18079
|
const LENDR_SPONSORED_SHARD_ID = 3301;
|
|
17978
18080
|
function findPythPushOracleAddress(feedId, programId, shardId) {
|
|
17979
18081
|
const shardBytes = u16ToArrayBufferLE(shardId);
|
|
17980
|
-
return PublicKey.findProgramAddressSync([shardBytes, feedId], programId)[0];
|
|
18082
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([shardBytes, feedId], programId)[0];
|
|
17981
18083
|
}
|
|
17982
18084
|
function u16ToArrayBufferLE(value) {
|
|
17983
18085
|
const buffer = new ArrayBuffer(2);
|
|
@@ -18044,8 +18146,8 @@ var Bank = class Bank {
|
|
|
18044
18146
|
const newBank = Object.create(Bank.prototype);
|
|
18045
18147
|
Object.assign(newBank, bank);
|
|
18046
18148
|
newBank.config = Object.assign({}, bank.config);
|
|
18047
|
-
newBank.config.assetWeightInit =
|
|
18048
|
-
newBank.config.assetWeightMaint =
|
|
18149
|
+
newBank.config.assetWeightInit = bignumber_js.default.max(bank.config.assetWeightInit, emodeWeights.assetWeightInit);
|
|
18150
|
+
newBank.config.assetWeightMaint = bignumber_js.default.max(bank.config.assetWeightMaint, emodeWeights.assetWeightMaint);
|
|
18049
18151
|
return newBank;
|
|
18050
18152
|
}
|
|
18051
18153
|
static getPrice(oraclePrice, priceBias = PriceBias.None, weightedPrice = false) {
|
|
@@ -18111,8 +18213,8 @@ var Bank = class Bank {
|
|
|
18111
18213
|
Bank address: ${this.address.toBase58()}
|
|
18112
18214
|
Mint: ${this.mint.toBase58()}, decimals: ${this.mintDecimals}
|
|
18113
18215
|
|
|
18114
|
-
Total deposits: ${nativeToUi(this.getTotalAssetQuantity(), this.mintDecimals)}
|
|
18115
|
-
Total borrows: ${nativeToUi(this.getTotalLiabilityQuantity(), this.mintDecimals)}
|
|
18216
|
+
Total deposits: ${require_common.nativeToUi(this.getTotalAssetQuantity(), this.mintDecimals)}
|
|
18217
|
+
Total borrows: ${require_common.nativeToUi(this.getTotalLiabilityQuantity(), this.mintDecimals)}
|
|
18116
18218
|
|
|
18117
18219
|
Total assets (USD value): ${this.computeAssetUsdValue(oraclePrice, this.totalAssetShares, LendrRequirementType.Equity, PriceBias.None)}
|
|
18118
18220
|
Total liabilities (USD value): ${this.computeLiabilityUsdValue(oraclePrice, this.totalLiabilityShares, LendrRequirementType.Equity, PriceBias.None)}
|
|
@@ -18130,8 +18232,8 @@ Config:
|
|
|
18130
18232
|
- Borrow limit: ${this.config.borrowLimit}
|
|
18131
18233
|
|
|
18132
18234
|
LTVs:
|
|
18133
|
-
- Initial: ${new
|
|
18134
|
-
- Maintenance: ${new
|
|
18235
|
+
- Initial: ${new bignumber_js.default(1).div(this.config.liabilityWeightInit).times(100).toFixed(2)}%
|
|
18236
|
+
- Maintenance: ${new bignumber_js.default(1).div(this.config.liabilityWeightMaint).times(100).toFixed(2)}%
|
|
18135
18237
|
`;
|
|
18136
18238
|
}
|
|
18137
18239
|
};
|
|
@@ -18297,7 +18399,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18297
18399
|
const useCache = false;
|
|
18298
18400
|
const freeCollateral = useCache ? this.computeFreeCollateral().times(_volatilityFactor) : this.computeFreeCollateralLegacy(banks, oraclePrices);
|
|
18299
18401
|
logger.debug({ freeCollateral: freeCollateral.toFixed(6) }, "[lendr:computeMaxBorrowForBank] Free collateral");
|
|
18300
|
-
const untiedCollateralForBank =
|
|
18402
|
+
const untiedCollateralForBank = bignumber_js.default.min(bank.computeAssetUsdValue(priceInfo, balance.assetShares, LendrRequirementType.Initial, PriceBias.Lowest), freeCollateral);
|
|
18301
18403
|
const priceLowestBias = getPrice(priceInfo, PriceBias.Lowest, true);
|
|
18302
18404
|
const priceHighestBias = getPrice(priceInfo, PriceBias.Highest, true);
|
|
18303
18405
|
const assetWeight = bank.getAssetWeight(LendrRequirementType.Initial, priceInfo);
|
|
@@ -18325,7 +18427,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18325
18427
|
const { liabilities: liabilitiesInit } = this.computeHealthComponents(LendrRequirementType.Initial);
|
|
18326
18428
|
if (bank.config.riskTier === RiskTier.Isolated || initAssetWeight.isZero() && maintAssetWeight.isZero()) {
|
|
18327
18429
|
if (freeCollateral.isZero() && !liabilitiesInit.isZero()) {
|
|
18328
|
-
return new
|
|
18430
|
+
return new bignumber_js.default(0);
|
|
18329
18431
|
} else {
|
|
18330
18432
|
return entireBalance;
|
|
18331
18433
|
}
|
|
@@ -18334,7 +18436,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18334
18436
|
if (liabilitiesInit.eq(0)) {
|
|
18335
18437
|
return entireBalance;
|
|
18336
18438
|
} else if (freeCollateral.isZero()) {
|
|
18337
|
-
return new
|
|
18439
|
+
return new bignumber_js.default(0);
|
|
18338
18440
|
} else {
|
|
18339
18441
|
const { liabilities: maintLiabilities, assets: maintAssets } = this.computeHealthComponents(LendrRequirementType.Maintenance);
|
|
18340
18442
|
const maintUntiedCollateral = maintAssets.minus(maintLiabilities);
|
|
@@ -18424,7 +18526,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18424
18526
|
const { assets: assetsAccount, liabilities: liabilitiesAccount } = this.computeHealthComponents(LendrRequirementType.Maintenance);
|
|
18425
18527
|
const assets = assetsAccount.minus(assetBank);
|
|
18426
18528
|
const liabilities = liabilitiesAccount.minus(liabilitiesBank);
|
|
18427
|
-
const amountBn = new
|
|
18529
|
+
const amountBn = new bignumber_js.default(amount);
|
|
18428
18530
|
let liquidationPrice;
|
|
18429
18531
|
if (isLending) {
|
|
18430
18532
|
if (liabilities.eq(0)) return null;
|
|
@@ -18453,7 +18555,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18453
18555
|
const priceAssetLower = getPrice(assetPriceInfo, PriceBias.Lowest, false);
|
|
18454
18556
|
const priceAssetMarket = getPrice(assetPriceInfo, PriceBias.None, false);
|
|
18455
18557
|
const assetMaintWeight = assetBank.config.assetWeightMaint;
|
|
18456
|
-
const liquidationDiscount = new
|
|
18558
|
+
const liquidationDiscount = new bignumber_js.default(.95);
|
|
18457
18559
|
const priceLiabHighest = getPrice(liabilityPriceInfo, PriceBias.Highest, false);
|
|
18458
18560
|
const priceLiabMarket = getPrice(liabilityPriceInfo, PriceBias.None, false);
|
|
18459
18561
|
const liabMaintWeight = liabilityBank.config.liabilityWeightMaint;
|
|
@@ -18479,7 +18581,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18479
18581
|
priceLiabMarket: priceLiabMarket.toFixed(6),
|
|
18480
18582
|
liabUsdValue: liabUsdValue.toFixed(6)
|
|
18481
18583
|
}, "[lendr:getMaxLiquidatableAssetAmount]");
|
|
18482
|
-
const maxLiquidatableUsdValue =
|
|
18584
|
+
const maxLiquidatableUsdValue = bignumber_js.default.min(assetsUsdValue, underwaterMaintUsdValue, liabUsdValue);
|
|
18483
18585
|
logger.debug({ maxLiquidatableUsdValue: maxLiquidatableUsdValue.toFixed(6) }, "[lendr:getMaxLiquidatableAssetAmount] Max liquidatable usd value");
|
|
18484
18586
|
return maxLiquidatableUsdValue.div(priceAssetLower);
|
|
18485
18587
|
}
|
|
@@ -18522,21 +18624,21 @@ var LendrAccount = class LendrAccount {
|
|
|
18522
18624
|
if (!mintData) throw Error(`Mint for bank ${bankAddress.toBase58()} not found`);
|
|
18523
18625
|
const wrapAndUnwrapSol = opts.wrapAndUnwrapSol ?? true;
|
|
18524
18626
|
const wSolBalanceUi = opts.wSolBalanceUi ?? 0;
|
|
18525
|
-
const userTokenAtaPk = getAssociatedTokenAddressSync(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18526
|
-
const remainingAccounts = mintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID) ? [{
|
|
18627
|
+
const userTokenAtaPk = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18628
|
+
const remainingAccounts = mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID) ? [{
|
|
18527
18629
|
pubkey: mintData.mint,
|
|
18528
18630
|
isSigner: false,
|
|
18529
18631
|
isWritable: false
|
|
18530
18632
|
}] : [];
|
|
18531
18633
|
const depositIxs = [];
|
|
18532
|
-
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18533
|
-
depositIxs.push(...makeWrapSolIxs(this.authority, new
|
|
18634
|
+
if (bank.mint.equals(__solana_spl_token.NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18635
|
+
depositIxs.push(...makeWrapSolIxs(this.authority, new bignumber_js.default(amount).minus(wSolBalanceUi)));
|
|
18534
18636
|
}
|
|
18535
18637
|
return {
|
|
18536
18638
|
depositIxs,
|
|
18537
18639
|
userTokenAtaPk,
|
|
18538
18640
|
mintData,
|
|
18539
|
-
ixArguments: { amount: uiToNative(amount, bank.mintDecimals) },
|
|
18641
|
+
ixArguments: { amount: require_common.uiToNative(amount, bank.mintDecimals) },
|
|
18540
18642
|
remainingAccounts
|
|
18541
18643
|
};
|
|
18542
18644
|
}
|
|
@@ -18583,23 +18685,23 @@ var LendrAccount = class LendrAccount {
|
|
|
18583
18685
|
const wrapAndUnwrapSol = opts.wrapAndUnwrapSol ?? true;
|
|
18584
18686
|
const wSolBalanceUi = opts.wSolBalanceUi ?? 0;
|
|
18585
18687
|
const repayIxs = [];
|
|
18586
|
-
if (repayAll && !bank.emissionsMint.equals(PublicKey.default)) {
|
|
18688
|
+
if (repayAll && !bank.emissionsMint.equals(__solana_web3_js.PublicKey.default)) {
|
|
18587
18689
|
repayIxs.push(...(await this.makeWithdrawEmissionsIx(program, banks, mintDatas, bankAddress)).instructions);
|
|
18588
18690
|
}
|
|
18589
|
-
const userAta = getAssociatedTokenAddressSync(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18691
|
+
const userAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18590
18692
|
const remainingAccounts = [];
|
|
18591
|
-
if (mintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
18693
|
+
if (mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID)) {
|
|
18592
18694
|
remainingAccounts.push(mintData.mint);
|
|
18593
18695
|
}
|
|
18594
|
-
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18595
|
-
repayIxs.push(...makeWrapSolIxs(this.authority, new
|
|
18696
|
+
if (bank.mint.equals(__solana_spl_token.NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18697
|
+
repayIxs.push(...makeWrapSolIxs(this.authority, new bignumber_js.default(amount).minus(wSolBalanceUi)));
|
|
18596
18698
|
}
|
|
18597
18699
|
return {
|
|
18598
18700
|
repayIxs,
|
|
18599
18701
|
mintData,
|
|
18600
18702
|
userAta,
|
|
18601
18703
|
ixArguments: {
|
|
18602
|
-
amount: uiToNative(amount, bank.mintDecimals),
|
|
18704
|
+
amount: require_common.uiToNative(amount, bank.mintDecimals),
|
|
18603
18705
|
repayAll
|
|
18604
18706
|
},
|
|
18605
18707
|
remainingAccounts
|
|
@@ -18655,17 +18757,17 @@ var LendrAccount = class LendrAccount {
|
|
|
18655
18757
|
const wrapAndUnwrapSol = withdrawOpts.wrapAndUnwrapSol ?? true;
|
|
18656
18758
|
const createAtas = withdrawOpts.createAtas ?? true;
|
|
18657
18759
|
const withdrawIxs = [];
|
|
18658
|
-
if (withdrawAll && !bank.emissionsMint.equals(PublicKey.default) && mintData.emissionTokenProgram) {
|
|
18760
|
+
if (withdrawAll && !bank.emissionsMint.equals(__solana_web3_js.PublicKey.default) && mintData.emissionTokenProgram) {
|
|
18659
18761
|
withdrawIxs.push(...(await this.makeWithdrawEmissionsIx(program, bankMap, mintDatas, bankAddress)).instructions);
|
|
18660
18762
|
}
|
|
18661
|
-
const userAta = getAssociatedTokenAddressSync(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18763
|
+
const userAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18662
18764
|
if (createAtas) {
|
|
18663
|
-
const createAtaIdempotentIx = createAssociatedTokenAccountIdempotentInstruction(withdrawOpts?.createAtaPayer ?? this.authority, userAta, this.authority, bank.mint, mintData.tokenProgram);
|
|
18765
|
+
const createAtaIdempotentIx = (0, __solana_spl_token.createAssociatedTokenAccountIdempotentInstruction)(withdrawOpts?.createAtaPayer ?? this.authority, userAta, this.authority, bank.mint, mintData.tokenProgram);
|
|
18664
18766
|
withdrawIxs.push(createAtaIdempotentIx);
|
|
18665
18767
|
}
|
|
18666
18768
|
const healthAccounts = withdrawAll ? this.getHealthCheckAccounts(bankMap, [], [bankAddress]) : this.getHealthCheckAccounts(bankMap, [bankAddress], []);
|
|
18667
18769
|
const remainingAccounts = [];
|
|
18668
|
-
if (mintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
18770
|
+
if (mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID)) {
|
|
18669
18771
|
remainingAccounts.push(mintData.mint);
|
|
18670
18772
|
}
|
|
18671
18773
|
if (withdrawOpts.observationBanksOverride) {
|
|
@@ -18697,11 +18799,11 @@ var LendrAccount = class LendrAccount {
|
|
|
18697
18799
|
authority: withdrawOpts.overrideInferAccounts?.authority,
|
|
18698
18800
|
group: withdrawOpts.overrideInferAccounts?.group
|
|
18699
18801
|
}, {
|
|
18700
|
-
amount: uiToNative(amount, bank.mintDecimals),
|
|
18802
|
+
amount: require_common.uiToNative(amount, bank.mintDecimals),
|
|
18701
18803
|
withdrawAll
|
|
18702
18804
|
}, remainingAccounts);
|
|
18703
18805
|
withdrawIxs.push(withdrawIx);
|
|
18704
|
-
if (wrapAndUnwrapSol && bank.mint.equals(NATIVE_MINT)) {
|
|
18806
|
+
if (wrapAndUnwrapSol && bank.mint.equals(__solana_spl_token.NATIVE_MINT)) {
|
|
18705
18807
|
withdrawIxs.push(makeUnwrapSolIx(this.authority));
|
|
18706
18808
|
}
|
|
18707
18809
|
return {
|
|
@@ -18722,11 +18824,11 @@ var LendrAccount = class LendrAccount {
|
|
|
18722
18824
|
tokenProgram: mintData.tokenProgram,
|
|
18723
18825
|
group: withdrawOpts.overrideInferAccounts?.group
|
|
18724
18826
|
}, {
|
|
18725
|
-
amount: uiToNative(amount, bank.mintDecimals),
|
|
18827
|
+
amount: require_common.uiToNative(amount, bank.mintDecimals),
|
|
18726
18828
|
withdrawAll
|
|
18727
18829
|
}, remainingAccounts);
|
|
18728
18830
|
withdrawIxs.push(withdrawIx);
|
|
18729
|
-
if (wrapAndUnwrapSol && bank.mint.equals(NATIVE_MINT)) {
|
|
18831
|
+
if (wrapAndUnwrapSol && bank.mint.equals(__solana_spl_token.NATIVE_MINT)) {
|
|
18730
18832
|
withdrawIxs.push(makeUnwrapSolIx(this.authority));
|
|
18731
18833
|
}
|
|
18732
18834
|
return {
|
|
@@ -18742,14 +18844,14 @@ var LendrAccount = class LendrAccount {
|
|
|
18742
18844
|
const wrapAndUnwrapSol = borrowOpts.wrapAndUnwrapSol ?? true;
|
|
18743
18845
|
const createAtas = borrowOpts.createAtas ?? true;
|
|
18744
18846
|
const borrowIxs = [];
|
|
18745
|
-
const userAta = getAssociatedTokenAddressSync(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18847
|
+
const userAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18746
18848
|
if (createAtas) {
|
|
18747
|
-
const createAtaIdempotentIx = createAssociatedTokenAccountIdempotentInstruction(borrowOpts?.createAtaPayer ?? this.authority, userAta, this.authority, bank.mint, mintData.tokenProgram);
|
|
18849
|
+
const createAtaIdempotentIx = (0, __solana_spl_token.createAssociatedTokenAccountIdempotentInstruction)(borrowOpts?.createAtaPayer ?? this.authority, userAta, this.authority, bank.mint, mintData.tokenProgram);
|
|
18748
18850
|
borrowIxs.push(createAtaIdempotentIx);
|
|
18749
18851
|
}
|
|
18750
18852
|
const healthAccounts = this.getHealthCheckAccounts(bankMap, [bankAddress], []);
|
|
18751
18853
|
const remainingAccounts = [];
|
|
18752
|
-
if (mintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
18854
|
+
if (mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID)) {
|
|
18753
18855
|
remainingAccounts.push(mintData.mint);
|
|
18754
18856
|
}
|
|
18755
18857
|
if (borrowOpts?.observationBanksOverride) {
|
|
@@ -18780,9 +18882,9 @@ var LendrAccount = class LendrAccount {
|
|
|
18780
18882
|
tokenProgram: mintData.tokenProgram,
|
|
18781
18883
|
authority: borrowOpts?.overrideInferAccounts?.authority,
|
|
18782
18884
|
group: borrowOpts?.overrideInferAccounts?.group
|
|
18783
|
-
}, { amount: uiToNative(amount, bank.mintDecimals) }, remainingAccounts);
|
|
18885
|
+
}, { amount: require_common.uiToNative(amount, bank.mintDecimals) }, remainingAccounts);
|
|
18784
18886
|
borrowIxs.push(borrowIx);
|
|
18785
|
-
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18887
|
+
if (bank.mint.equals(__solana_spl_token.NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18786
18888
|
borrowIxs.push(makeUnwrapSolIx(this.authority));
|
|
18787
18889
|
}
|
|
18788
18890
|
return {
|
|
@@ -18802,9 +18904,9 @@ var LendrAccount = class LendrAccount {
|
|
|
18802
18904
|
destinationTokenAccount: userAta,
|
|
18803
18905
|
tokenProgram: mintData.tokenProgram,
|
|
18804
18906
|
group: borrowOpts?.overrideInferAccounts?.group
|
|
18805
|
-
}, { amount: uiToNative(amount, bank.mintDecimals) }, remainingAccounts);
|
|
18907
|
+
}, { amount: require_common.uiToNative(amount, bank.mintDecimals) }, remainingAccounts);
|
|
18806
18908
|
borrowIxs.push(borrowIx);
|
|
18807
|
-
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18909
|
+
if (bank.mint.equals(__solana_spl_token.NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18808
18910
|
borrowIxs.push(makeUnwrapSolIx(this.authority));
|
|
18809
18911
|
}
|
|
18810
18912
|
return {
|
|
@@ -18821,8 +18923,8 @@ var LendrAccount = class LendrAccount {
|
|
|
18821
18923
|
throw Error(`Emission token program not found for bank ${bankAddress.toBase58()}`);
|
|
18822
18924
|
}
|
|
18823
18925
|
const ixs = [];
|
|
18824
|
-
const userAta = getAssociatedTokenAddressSync(bank.emissionsMint, this.authority, true, mintData.emissionTokenProgram);
|
|
18825
|
-
const createAtaIdempotentIx = createAssociatedTokenAccountIdempotentInstruction(this.authority, userAta, this.authority, bank.emissionsMint, mintData.emissionTokenProgram);
|
|
18926
|
+
const userAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.emissionsMint, this.authority, true, mintData.emissionTokenProgram);
|
|
18927
|
+
const createAtaIdempotentIx = (0, __solana_spl_token.createAssociatedTokenAccountIdempotentInstruction)(this.authority, userAta, this.authority, bank.emissionsMint, mintData.emissionTokenProgram);
|
|
18826
18928
|
ixs.push(createAtaIdempotentIx);
|
|
18827
18929
|
const withdrawEmissionsIx = await instructions_default.makelendingAccountWithdrawEmissionIx(program, {
|
|
18828
18930
|
lendrAccount: this.address,
|
|
@@ -18846,19 +18948,19 @@ var LendrAccount = class LendrAccount {
|
|
|
18846
18948
|
const ixs = [];
|
|
18847
18949
|
const healthAccounts = [...this.getHealthCheckAccounts(bankMap, [liabilityBankAddress, assetBankAddress], []), ...liquidateeLendrAccount.getHealthCheckAccounts(bankMap, [], [])];
|
|
18848
18950
|
const remainingAccounts = [];
|
|
18849
|
-
if (liabilityMintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
18951
|
+
if (liabilityMintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID)) {
|
|
18850
18952
|
remainingAccounts.push(liabilityMintData.mint);
|
|
18851
18953
|
}
|
|
18852
18954
|
const accountMetas = computeHealthAccountMetas(healthAccounts, bankMetadataMap);
|
|
18853
18955
|
remainingAccounts.push(...accountMetas);
|
|
18854
|
-
ixs.push(ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 }));
|
|
18956
|
+
ixs.push(__solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 }));
|
|
18855
18957
|
const liquidateIx = await instructions_default.makeLendingAccountLiquidateIx(program, {
|
|
18856
18958
|
assetBank: assetBankAddress,
|
|
18857
18959
|
liabBank: liabilityBankAddress,
|
|
18858
18960
|
liquidatorLendrAccount: this.address,
|
|
18859
18961
|
liquidateeLendrAccount: liquidateeLendrAccount.address,
|
|
18860
18962
|
tokenProgram: liabilityMintData.tokenProgram
|
|
18861
|
-
}, { assetAmount: uiToNative(assetQuantityUi, assetBank.mintDecimals) }, remainingAccounts.map((account) => ({
|
|
18963
|
+
}, { assetAmount: require_common.uiToNative(assetQuantityUi, assetBank.mintDecimals) }, remainingAccounts.map((account) => ({
|
|
18862
18964
|
pubkey: account,
|
|
18863
18965
|
isSigner: false,
|
|
18864
18966
|
isWritable: false
|
|
@@ -18870,7 +18972,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18870
18972
|
};
|
|
18871
18973
|
}
|
|
18872
18974
|
async makeBeginFlashLoanIx(program, endIndex) {
|
|
18873
|
-
const ix = await instructions_default.makeBeginFlashLoanIx(program, { lendrAccount: this.address }, { endIndex: new
|
|
18975
|
+
const ix = await instructions_default.makeBeginFlashLoanIx(program, { lendrAccount: this.address }, { endIndex: new bn_js.default(endIndex) });
|
|
18874
18976
|
return {
|
|
18875
18977
|
instructions: [ix],
|
|
18876
18978
|
keys: []
|
|
@@ -18925,12 +19027,12 @@ var LendrAccount = class LendrAccount {
|
|
|
18925
19027
|
for (let index = 0; index < instructions$3.length; index++) {
|
|
18926
19028
|
const ix = instructions$3[index];
|
|
18927
19029
|
if (!ix.programId.equals(program.programId)) continue;
|
|
18928
|
-
const borshCoder = new BorshInstructionCoder(program.idl);
|
|
19030
|
+
const borshCoder = new __coral_xyz_anchor.BorshInstructionCoder(program.idl);
|
|
18929
19031
|
const decoded = borshCoder.decode(ix.data, "base58");
|
|
18930
19032
|
if (!decoded) continue;
|
|
18931
19033
|
const ixArgs = decoded.data;
|
|
18932
19034
|
if (decoded.name === "lendingAccountBorrow" || decoded.name === "lendingAccountDeposit") {
|
|
18933
|
-
const targetBank = new PublicKey(ix.keys[3].pubkey);
|
|
19035
|
+
const targetBank = new __solana_web3_js.PublicKey(ix.keys[3].pubkey);
|
|
18934
19036
|
const targetBalance = projectedBalances.find((b) => b.bankPk.equals(targetBank));
|
|
18935
19037
|
if (!targetBalance) {
|
|
18936
19038
|
const firstInactiveBalanceIndex = projectedBalances.findIndex((b) => !b.active);
|
|
@@ -18943,22 +19045,22 @@ var LendrAccount = class LendrAccount {
|
|
|
18943
19045
|
continue;
|
|
18944
19046
|
}
|
|
18945
19047
|
if (decoded.name === "lendingAccountRepay" || decoded.name === "lendingAccountWithdraw") {
|
|
18946
|
-
const targetBank = new PublicKey(ix.keys[3].pubkey);
|
|
19048
|
+
const targetBank = new __solana_web3_js.PublicKey(ix.keys[3].pubkey);
|
|
18947
19049
|
const targetBalance = projectedBalances.find((b) => b.bankPk.equals(targetBank));
|
|
18948
19050
|
if (!targetBalance) {
|
|
18949
19051
|
throw Error(`Balance for bank ${targetBank.toBase58()} should be projected active at this point (ix ${index}: ${decoded.name}))`);
|
|
18950
19052
|
}
|
|
18951
19053
|
if (ixArgs.repayAll || ixArgs.withdrawAll) {
|
|
18952
19054
|
targetBalance.active = false;
|
|
18953
|
-
targetBalance.bankPk = PublicKey.default;
|
|
19055
|
+
targetBalance.bankPk = __solana_web3_js.PublicKey.default;
|
|
18954
19056
|
}
|
|
18955
19057
|
}
|
|
18956
19058
|
}
|
|
18957
19059
|
return projectedBalances.filter((b) => b.active).map((b) => b.bankPk);
|
|
18958
19060
|
}
|
|
18959
|
-
wrapInstructionForWSol(ix, amount = new
|
|
19061
|
+
wrapInstructionForWSol(ix, amount = new bignumber_js.default(0)) {
|
|
18960
19062
|
return [
|
|
18961
|
-
...makeWrapSolIxs(this.authority, new
|
|
19063
|
+
...makeWrapSolIxs(this.authority, new bignumber_js.default(amount)),
|
|
18962
19064
|
ix,
|
|
18963
19065
|
makeUnwrapSolIx(this.authority)
|
|
18964
19066
|
];
|
|
@@ -19009,7 +19111,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19009
19111
|
}
|
|
19010
19112
|
static async fetch(lendrAccountPk, client, commitment) {
|
|
19011
19113
|
const { config, program } = client;
|
|
19012
|
-
const _lendrAccountPk = translateAddress(lendrAccountPk);
|
|
19114
|
+
const _lendrAccountPk = (0, __coral_xyz_anchor.translateAddress)(lendrAccountPk);
|
|
19013
19115
|
const accountData = await LendrAccountWrapper._fetchAccountData(_lendrAccountPk, config, program, commitment);
|
|
19014
19116
|
const lendrAccount = LendrAccount.fromAccountParsed(_lendrAccountPk, accountData);
|
|
19015
19117
|
const lendrAccountProxy = new LendrAccountWrapper(_lendrAccountPk, client, lendrAccount);
|
|
@@ -19018,7 +19120,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19018
19120
|
}
|
|
19019
19121
|
static fromAccountParsed(lendrAccountPk, client, accountData) {
|
|
19020
19122
|
if (!accountData.group.equals(client.config.groupPk)) throw Error(`Lendr account tied to group ${accountData.group.toBase58()}. Expected: ${client.config.groupPk.toBase58()}`);
|
|
19021
|
-
const _lendrAccountPk = translateAddress(lendrAccountPk);
|
|
19123
|
+
const _lendrAccountPk = (0, __coral_xyz_anchor.translateAddress)(lendrAccountPk);
|
|
19022
19124
|
const lendrAccount = LendrAccount.fromAccountParsed(_lendrAccountPk, accountData);
|
|
19023
19125
|
return new LendrAccountWrapper(_lendrAccountPk, client, lendrAccount);
|
|
19024
19126
|
}
|
|
@@ -19099,7 +19201,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19099
19201
|
return this._lendrAccount.computeActiveEmodePairs(emodePairs);
|
|
19100
19202
|
}
|
|
19101
19203
|
computeEmodeImpacts(emodePairs) {
|
|
19102
|
-
return this._lendrAccount.computeEmodeImpacts(emodePairs, Array.from(this.client.banks.keys()).map((b) => new PublicKey(b)));
|
|
19204
|
+
return this._lendrAccount.computeEmodeImpacts(emodePairs, Array.from(this.client.banks.keys()).map((b) => new __solana_web3_js.PublicKey(b)));
|
|
19103
19205
|
}
|
|
19104
19206
|
computeMaxBorrowForBank(bankAddress, opts) {
|
|
19105
19207
|
return this._lendrAccount.computeMaxBorrowForBank(this.client.banks, this.client.oraclePrices, bankAddress, opts, this.client.logger);
|
|
@@ -19135,7 +19237,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19135
19237
|
const cuRequestIxs = [];
|
|
19136
19238
|
const activeBalances = this.balances.filter((b) => b.active);
|
|
19137
19239
|
if (activeBalances.length >= 4) {
|
|
19138
|
-
cuRequestIxs.push(ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }));
|
|
19240
|
+
cuRequestIxs.push(__solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }));
|
|
19139
19241
|
}
|
|
19140
19242
|
return cuRequestIxs;
|
|
19141
19243
|
}
|
|
@@ -19149,7 +19251,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19149
19251
|
const bank = this.client.bankMetadataMap[bankAddress.toBase58()];
|
|
19150
19252
|
const mintData = this.client.mintDatas.get(bankAddress.toBase58());
|
|
19151
19253
|
if (!mintData) throw Error(`Token data for ${bank.tokenAddress} not found`);
|
|
19152
|
-
return getAssociatedTokenAddressSync(new PublicKey(bank.tokenAddress), this.authority, true, mintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID) ? TOKEN_2022_PROGRAM_ID : undefined);
|
|
19254
|
+
return (0, __solana_spl_token.getAssociatedTokenAddressSync)(new __solana_web3_js.PublicKey(bank.tokenAddress), this.authority, true, mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID) ? __solana_spl_token.TOKEN_2022_PROGRAM_ID : undefined);
|
|
19153
19255
|
});
|
|
19154
19256
|
const ixs = [];
|
|
19155
19257
|
const userAtaAis = await this._program.provider.connection.getMultipleAccountsInfo(userAtas);
|
|
@@ -19159,7 +19261,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19159
19261
|
const bank = this.client.bankMetadataMap[bankAddress.toBase58()];
|
|
19160
19262
|
const mintData = this.client.mintDatas.get(bankAddress.toBase58());
|
|
19161
19263
|
if (!mintData) throw Error(`Token data for ${bank.tokenAddress} not found`);
|
|
19162
|
-
ixs.push(createAssociatedTokenAccountIdempotentInstruction(this.authority, userAtas[i], this.authority, new PublicKey(bank.tokenAddress), mintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID) ? TOKEN_2022_PROGRAM_ID : undefined));
|
|
19264
|
+
ixs.push((0, __solana_spl_token.createAssociatedTokenAccountIdempotentInstruction)(this.authority, userAtas[i], this.authority, new __solana_web3_js.PublicKey(bank.tokenAddress), mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID) ? __solana_spl_token.TOKEN_2022_PROGRAM_ID : undefined));
|
|
19163
19265
|
}
|
|
19164
19266
|
}
|
|
19165
19267
|
return ixs;
|
|
@@ -19199,32 +19301,32 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19199
19301
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
19200
19302
|
const feedCrankTxs = [];
|
|
19201
19303
|
if (updateFeedIxs.length > 0) {
|
|
19202
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
19304
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
19203
19305
|
instructions: [...updateFeedIxs],
|
|
19204
19306
|
payerKey: this.authority,
|
|
19205
19307
|
recentBlockhash: blockhash
|
|
19206
19308
|
}).compileToV0Message(feedLuts)), {
|
|
19207
19309
|
addressLookupTables: feedLuts,
|
|
19208
|
-
type: TransactionType.CRANK
|
|
19310
|
+
type: require_common.TransactionType.CRANK
|
|
19209
19311
|
}));
|
|
19210
19312
|
}
|
|
19211
19313
|
const lookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19212
|
-
const withdrawTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
19314
|
+
const withdrawTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
19213
19315
|
instructions: [...cuRequestIxs, ...withdrawIxs.instructions],
|
|
19214
19316
|
payerKey: this.authority,
|
|
19215
19317
|
recentBlockhash: blockhash
|
|
19216
19318
|
}).compileToV0Message(lookupTables)), {
|
|
19217
19319
|
signers: withdrawIxs.keys,
|
|
19218
19320
|
addressLookupTables: lookupTables,
|
|
19219
|
-
type: TransactionType.MOVE_POSITION_WITHDRAW
|
|
19321
|
+
type: require_common.TransactionType.MOVE_POSITION_WITHDRAW
|
|
19220
19322
|
});
|
|
19221
19323
|
const destinationAccount = await LendrAccountWrapper.fetch(destinationAccountPk, this.client);
|
|
19222
19324
|
const depositIx = await destinationAccount.makeDepositIx(amount, bankAddress);
|
|
19223
|
-
const tx = new Transaction().add(...depositIx.instructions);
|
|
19224
|
-
const depositTx = addTransactionMetadata(tx, {
|
|
19325
|
+
const tx = new __solana_web3_js.Transaction().add(...depositIx.instructions);
|
|
19326
|
+
const depositTx = require_common.addTransactionMetadata(tx, {
|
|
19225
19327
|
signers: depositIx.keys,
|
|
19226
19328
|
addressLookupTables: lookupTables,
|
|
19227
|
-
type: TransactionType.MOVE_POSITION_DEPOSIT
|
|
19329
|
+
type: require_common.TransactionType.MOVE_POSITION_DEPOSIT
|
|
19228
19330
|
});
|
|
19229
19331
|
const transactions = [
|
|
19230
19332
|
...feedCrankTxs,
|
|
@@ -19289,7 +19391,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19289
19391
|
async makeRepayWithCollatTxV2({ repayAmount, withdrawAmount, borrowBankAddress, depositBankAddress, withdrawAll = false, repayAll = false, swap, blockhash: blockhashArg }) {
|
|
19290
19392
|
const blockhash = blockhashArg ?? (await this._program.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
19291
19393
|
const setupIxs = await this.makeSetupIx([borrowBankAddress, depositBankAddress]);
|
|
19292
|
-
const cuRequestIxs = this.makeComputeBudgetIx().length > 0 ? this.makeComputeBudgetIx() : [ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 })];
|
|
19394
|
+
const cuRequestIxs = this.makeComputeBudgetIx().length > 0 ? this.makeComputeBudgetIx() : [__solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 })];
|
|
19293
19395
|
const [priorityFeeIx] = makePriorityFeeIx(1e-5);
|
|
19294
19396
|
const withdrawIxs = await this.makeWithdrawIx(withdrawAmount, depositBankAddress, withdrawAll, {
|
|
19295
19397
|
createAtas: false,
|
|
@@ -19302,22 +19404,22 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19302
19404
|
let flashloanTx;
|
|
19303
19405
|
let txOverflown = false;
|
|
19304
19406
|
if (setupIxs.length > 0) {
|
|
19305
|
-
const message = new TransactionMessage({
|
|
19407
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
19306
19408
|
payerKey: this.client.wallet.publicKey,
|
|
19307
19409
|
recentBlockhash: blockhash,
|
|
19308
19410
|
instructions: setupIxs
|
|
19309
19411
|
}).compileToLegacyMessage();
|
|
19310
|
-
additionalTxs.push(addTransactionMetadata(new VersionedTransaction(message), { type: TransactionType.CREATE_ATA }));
|
|
19412
|
+
additionalTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), { type: require_common.TransactionType.CREATE_ATA }));
|
|
19311
19413
|
}
|
|
19312
19414
|
if (updateFeedIxs.length > 0) {
|
|
19313
|
-
const message = new TransactionMessage({
|
|
19415
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
19314
19416
|
payerKey: this.client.wallet.publicKey,
|
|
19315
19417
|
recentBlockhash: blockhash,
|
|
19316
19418
|
instructions: updateFeedIxs
|
|
19317
19419
|
}).compileToV0Message(feedLuts);
|
|
19318
|
-
additionalTxs.push(addTransactionMetadata(new VersionedTransaction(message), {
|
|
19420
|
+
additionalTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), {
|
|
19319
19421
|
addressLookupTables: feedLuts,
|
|
19320
|
-
type: TransactionType.CRANK
|
|
19422
|
+
type: require_common.TransactionType.CRANK
|
|
19321
19423
|
}));
|
|
19322
19424
|
}
|
|
19323
19425
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
@@ -19333,11 +19435,11 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19333
19435
|
addressLookupTableAccounts,
|
|
19334
19436
|
blockhash
|
|
19335
19437
|
});
|
|
19336
|
-
const txSize = getTxSize(flashloanTx);
|
|
19337
|
-
const accountKeys = getAccountKeys(flashloanTx, addressLookupTableAccounts);
|
|
19338
|
-
const txToManyKeys = accountKeys > MAX_ACCOUNT_KEYS;
|
|
19339
|
-
const txToBig = txSize > MAX_TX_SIZE;
|
|
19340
|
-
const canBeDownsized = txToManyKeys && txToBig && txSize - PRIORITY_TX_SIZE <= MAX_TX_SIZE;
|
|
19438
|
+
const txSize = require_common.getTxSize(flashloanTx);
|
|
19439
|
+
const accountKeys = require_common.getAccountKeys(flashloanTx, addressLookupTableAccounts);
|
|
19440
|
+
const txToManyKeys = accountKeys > require_common.MAX_ACCOUNT_KEYS;
|
|
19441
|
+
const txToBig = txSize > require_common.MAX_TX_SIZE;
|
|
19442
|
+
const canBeDownsized = txToManyKeys && txToBig && txSize - require_common.PRIORITY_TX_SIZE <= require_common.MAX_TX_SIZE;
|
|
19341
19443
|
if (canBeDownsized) {
|
|
19342
19444
|
flashloanTx = await this.buildFlashLoanTx({
|
|
19343
19445
|
ixs: [
|
|
@@ -19349,16 +19451,16 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19349
19451
|
addressLookupTableAccounts,
|
|
19350
19452
|
blockhash
|
|
19351
19453
|
});
|
|
19352
|
-
const txSize$1 = getTxSize(flashloanTx);
|
|
19353
|
-
const txToBig$1 = txSize$1 > MAX_TX_SIZE;
|
|
19454
|
+
const txSize$1 = require_common.getTxSize(flashloanTx);
|
|
19455
|
+
const txToBig$1 = txSize$1 > require_common.MAX_TX_SIZE;
|
|
19354
19456
|
if (txToBig$1) {
|
|
19355
19457
|
txOverflown = true;
|
|
19356
19458
|
}
|
|
19357
19459
|
} else if (txToBig || txToManyKeys) {
|
|
19358
19460
|
txOverflown = true;
|
|
19359
19461
|
}
|
|
19360
|
-
flashloanTx = addTransactionMetadata(flashloanTx, {
|
|
19361
|
-
type: TransactionType.REPAY_COLLAT,
|
|
19462
|
+
flashloanTx = require_common.addTransactionMetadata(flashloanTx, {
|
|
19463
|
+
type: require_common.TransactionType.REPAY_COLLAT,
|
|
19362
19464
|
addressLookupTables: flashloanTx.addressLookupTables
|
|
19363
19465
|
});
|
|
19364
19466
|
const transactions = [...additionalTxs, flashloanTx];
|
|
@@ -19396,7 +19498,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19396
19498
|
if (!borrowBank) throw Error("Borrow bank not found");
|
|
19397
19499
|
const blockhash = blockhashArg ?? (await this._program.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
19398
19500
|
const setupIxs = await this.makeSetupIx(setupBankAddresses ?? [borrowBankAddress, depositBankAddress]);
|
|
19399
|
-
const cuRequestIxs = this.makeComputeBudgetIx().length > 0 ? this.makeComputeBudgetIx() : [ComputeBudgetProgram.setComputeUnitLimit({ units: 5e5 })];
|
|
19501
|
+
const cuRequestIxs = this.makeComputeBudgetIx().length > 0 ? this.makeComputeBudgetIx() : [__solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 5e5 })];
|
|
19400
19502
|
const [priorityFeeIx] = makePriorityFeeIx(1e-5);
|
|
19401
19503
|
const borrowIxs = await this.makeBorrowIx(borrowAmount, borrowBankAddress, {
|
|
19402
19504
|
createAtas: false,
|
|
@@ -19412,26 +19514,26 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19412
19514
|
const additionalTxs = [];
|
|
19413
19515
|
let flashloanTx;
|
|
19414
19516
|
let txOverflown = false;
|
|
19415
|
-
if (depositBank.mint.equals(NATIVE_MINT) && inputDepositAmount) {
|
|
19416
|
-
setupIxs.push(...makeWrapSolIxs(this.authority, new
|
|
19517
|
+
if (depositBank.mint.equals(__solana_spl_token.NATIVE_MINT) && inputDepositAmount) {
|
|
19518
|
+
setupIxs.push(...makeWrapSolIxs(this.authority, new bignumber_js.default(inputDepositAmount)));
|
|
19417
19519
|
}
|
|
19418
19520
|
if (setupIxs.length > 0) {
|
|
19419
|
-
const message = new TransactionMessage({
|
|
19521
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
19420
19522
|
payerKey: this.client.wallet.publicKey,
|
|
19421
19523
|
recentBlockhash: blockhash,
|
|
19422
19524
|
instructions: setupIxs
|
|
19423
19525
|
}).compileToLegacyMessage();
|
|
19424
|
-
additionalTxs.push(addTransactionMetadata(new VersionedTransaction(message), { type: TransactionType.CREATE_ATA }));
|
|
19526
|
+
additionalTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), { type: require_common.TransactionType.CREATE_ATA }));
|
|
19425
19527
|
}
|
|
19426
19528
|
if (updateFeedIxs.length > 0) {
|
|
19427
|
-
const message = new TransactionMessage({
|
|
19529
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
19428
19530
|
payerKey: this.client.wallet.publicKey,
|
|
19429
19531
|
recentBlockhash: blockhash,
|
|
19430
19532
|
instructions: updateFeedIxs
|
|
19431
19533
|
}).compileToV0Message(feedLuts);
|
|
19432
|
-
additionalTxs.push(addTransactionMetadata(new VersionedTransaction(message), {
|
|
19534
|
+
additionalTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), {
|
|
19433
19535
|
addressLookupTables: feedLuts,
|
|
19434
|
-
type: TransactionType.CRANK
|
|
19536
|
+
type: require_common.TransactionType.CRANK
|
|
19435
19537
|
}));
|
|
19436
19538
|
}
|
|
19437
19539
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
@@ -19447,11 +19549,11 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19447
19549
|
addressLookupTableAccounts,
|
|
19448
19550
|
blockhash
|
|
19449
19551
|
});
|
|
19450
|
-
const txSize = getTxSize(flashloanTx);
|
|
19451
|
-
const accountKeys = getAccountKeys(flashloanTx, addressLookupTableAccounts);
|
|
19452
|
-
const txToManyKeys = accountKeys > MAX_ACCOUNT_KEYS;
|
|
19453
|
-
const txToBig = txSize > MAX_TX_SIZE;
|
|
19454
|
-
const canBeDownsized = txToManyKeys && txToBig && txSize - PRIORITY_TX_SIZE <= MAX_TX_SIZE;
|
|
19552
|
+
const txSize = require_common.getTxSize(flashloanTx);
|
|
19553
|
+
const accountKeys = require_common.getAccountKeys(flashloanTx, addressLookupTableAccounts);
|
|
19554
|
+
const txToManyKeys = accountKeys > require_common.MAX_ACCOUNT_KEYS;
|
|
19555
|
+
const txToBig = txSize > require_common.MAX_TX_SIZE;
|
|
19556
|
+
const canBeDownsized = txToManyKeys && txToBig && txSize - require_common.PRIORITY_TX_SIZE <= require_common.MAX_TX_SIZE;
|
|
19455
19557
|
if (canBeDownsized) {
|
|
19456
19558
|
flashloanTx = await this.buildFlashLoanTx({
|
|
19457
19559
|
ixs: [
|
|
@@ -19463,16 +19565,16 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19463
19565
|
addressLookupTableAccounts,
|
|
19464
19566
|
blockhash
|
|
19465
19567
|
});
|
|
19466
|
-
const txSize$1 = getTxSize(flashloanTx);
|
|
19467
|
-
const txToBig$1 = txSize$1 > MAX_TX_SIZE;
|
|
19568
|
+
const txSize$1 = require_common.getTxSize(flashloanTx);
|
|
19569
|
+
const txToBig$1 = txSize$1 > require_common.MAX_TX_SIZE;
|
|
19468
19570
|
if (txToBig$1) {
|
|
19469
19571
|
txOverflown = true;
|
|
19470
19572
|
}
|
|
19471
19573
|
} else if (txToBig || txToManyKeys) {
|
|
19472
19574
|
txOverflown = true;
|
|
19473
19575
|
}
|
|
19474
|
-
flashloanTx = addTransactionMetadata(flashloanTx, {
|
|
19475
|
-
type: TransactionType.LOOP,
|
|
19576
|
+
flashloanTx = require_common.addTransactionMetadata(flashloanTx, {
|
|
19577
|
+
type: require_common.TransactionType.LOOP,
|
|
19476
19578
|
addressLookupTables: flashloanTx.addressLookupTables
|
|
19477
19579
|
});
|
|
19478
19580
|
const transactions = [...additionalTxs, flashloanTx];
|
|
@@ -19519,12 +19621,12 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19519
19621
|
*/
|
|
19520
19622
|
async makeCloseAccountTx() {
|
|
19521
19623
|
const ix = await this.makeCloseAccountIx();
|
|
19522
|
-
const tx = new Transaction().add(...ix.instructions);
|
|
19624
|
+
const tx = new __solana_web3_js.Transaction().add(...ix.instructions);
|
|
19523
19625
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19524
|
-
return addTransactionMetadata(tx, {
|
|
19626
|
+
return require_common.addTransactionMetadata(tx, {
|
|
19525
19627
|
signers: ix.keys,
|
|
19526
19628
|
addressLookupTables: clientLookupTables,
|
|
19527
|
-
type: TransactionType.CLOSE_ACCOUNT
|
|
19629
|
+
type: require_common.TransactionType.CLOSE_ACCOUNT
|
|
19528
19630
|
});
|
|
19529
19631
|
}
|
|
19530
19632
|
/**
|
|
@@ -19560,17 +19662,17 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19560
19662
|
const poolStakeAddress = findPoolStakeAddress(pool);
|
|
19561
19663
|
const lstMint = findPoolMintAddress(pool);
|
|
19562
19664
|
const auth = findPoolStakeAuthorityAddress(pool);
|
|
19563
|
-
const lstAta = getAssociatedTokenAddressSync(lstMint, this.authority);
|
|
19665
|
+
const lstAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(lstMint, this.authority);
|
|
19564
19666
|
const [lstAccInfo, stakeAccountInfo, stakeAccInfoParsed] = await Promise.all([
|
|
19565
19667
|
this.client.provider.connection.getAccountInfo(lstAta),
|
|
19566
19668
|
this._program.provider.connection.getAccountInfo(stakeAccountPk),
|
|
19567
19669
|
this._program.provider.connection.getParsedAccountInfo(stakeAccountPk)
|
|
19568
19670
|
]);
|
|
19569
19671
|
const stakeAccParsed = stakeAccInfoParsed?.value?.data;
|
|
19570
|
-
const [rentExemptReserve, minimumDelegation] = await Promise.all([this._program.provider.connection.getMinimumBalanceForRentExemption(StakeProgram.space), this._program.provider.connection.getStakeMinimumDelegation().then((res) => {
|
|
19571
|
-
return Math.max(res.value, LAMPORTS_PER_SOL);
|
|
19672
|
+
const [rentExemptReserve, minimumDelegation] = await Promise.all([this._program.provider.connection.getMinimumBalanceForRentExemption(__solana_web3_js.StakeProgram.space), this._program.provider.connection.getStakeMinimumDelegation().then((res) => {
|
|
19673
|
+
return Math.max(res.value, __solana_web3_js.LAMPORTS_PER_SOL);
|
|
19572
19674
|
})]);
|
|
19573
|
-
const amountLamports = Math.round(Number(amount) * LAMPORTS_PER_SOL);
|
|
19675
|
+
const amountLamports = Math.round(Number(amount) * __solana_web3_js.LAMPORTS_PER_SOL);
|
|
19574
19676
|
const stakeAccLamports = Number(stakeAccParsed.parsed.info.stake?.delegation?.stake ?? 0);
|
|
19575
19677
|
const isFullStake = amountLamports >= stakeAccLamports;
|
|
19576
19678
|
const poolStakeAccLamports = (await this._program.provider.connection.getAccountInfo(poolStakeAddress))?.lamports ?? 0;
|
|
@@ -19584,14 +19686,14 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19584
19686
|
const instructions$3 = [];
|
|
19585
19687
|
const signers = [];
|
|
19586
19688
|
if (!lstAccInfo) {
|
|
19587
|
-
instructions$3.push(createAssociatedTokenAccountInstruction(this.authority, lstAta, this.authority, lstMint));
|
|
19689
|
+
instructions$3.push((0, __solana_spl_token.createAssociatedTokenAccountInstruction)(this.authority, lstAta, this.authority, lstMint));
|
|
19588
19690
|
}
|
|
19589
19691
|
let targetStakePubkey;
|
|
19590
19692
|
if (!isFullStake) {
|
|
19591
|
-
const splitStakeAccount = Keypair.generate();
|
|
19693
|
+
const splitStakeAccount = __solana_web3_js.Keypair.generate();
|
|
19592
19694
|
signers.push(splitStakeAccount);
|
|
19593
19695
|
targetStakePubkey = splitStakeAccount.publicKey;
|
|
19594
|
-
instructions$3.push(...StakeProgram.split({
|
|
19696
|
+
instructions$3.push(...__solana_web3_js.StakeProgram.split({
|
|
19595
19697
|
stakePubkey: stakeAccountPk,
|
|
19596
19698
|
authorizedPubkey: this.authority,
|
|
19597
19699
|
splitStakePubkey: splitStakeAccount.publicKey,
|
|
@@ -19600,44 +19702,44 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19600
19702
|
} else {
|
|
19601
19703
|
targetStakePubkey = stakeAccountPk;
|
|
19602
19704
|
}
|
|
19603
|
-
const [authorizeStakerIx, authorizeWithdrawIx] = await Promise.all([StakeProgram.authorize({
|
|
19705
|
+
const [authorizeStakerIx, authorizeWithdrawIx] = await Promise.all([__solana_web3_js.StakeProgram.authorize({
|
|
19604
19706
|
stakePubkey: targetStakePubkey,
|
|
19605
19707
|
authorizedPubkey: this.authority,
|
|
19606
19708
|
newAuthorizedPubkey: auth,
|
|
19607
|
-
stakeAuthorizationType: StakeAuthorizationLayout.Staker
|
|
19608
|
-
}).instructions, StakeProgram.authorize({
|
|
19709
|
+
stakeAuthorizationType: __solana_web3_js.StakeAuthorizationLayout.Staker
|
|
19710
|
+
}).instructions, __solana_web3_js.StakeProgram.authorize({
|
|
19609
19711
|
stakePubkey: targetStakePubkey,
|
|
19610
19712
|
authorizedPubkey: this.authority,
|
|
19611
19713
|
newAuthorizedPubkey: auth,
|
|
19612
|
-
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer
|
|
19714
|
+
stakeAuthorizationType: __solana_web3_js.StakeAuthorizationLayout.Withdrawer
|
|
19613
19715
|
}).instructions]);
|
|
19614
19716
|
[authorizeStakerIx[0], authorizeWithdrawIx[0]].forEach((ix) => {
|
|
19615
19717
|
ix.keys = ix.keys.map((key) => ({
|
|
19616
19718
|
...key,
|
|
19617
|
-
isWritable: key.pubkey.equals(SYSVAR_CLOCK_ID) ? false : key.isWritable
|
|
19719
|
+
isWritable: key.pubkey.equals(require_common.SYSVAR_CLOCK_ID) ? false : key.isWritable
|
|
19618
19720
|
}));
|
|
19619
19721
|
});
|
|
19620
19722
|
instructions$3.push(...authorizeStakerIx, ...authorizeWithdrawIx);
|
|
19621
19723
|
const depositStakeIx = await SinglePoolInstruction.depositStake(pool, targetStakePubkey, lstAta, this.authority);
|
|
19622
19724
|
const lendrDepositIxs = await this.makeDepositIx(newPoolTokens / 1e9, bankAddress, depositOpts);
|
|
19623
19725
|
instructions$3.push(depositStakeIx, ...lendrDepositIxs.instructions);
|
|
19624
|
-
const transaction = new Transaction().add(...instructions$3);
|
|
19625
|
-
return addTransactionMetadata(transaction, {
|
|
19626
|
-
type: TransactionType.DEPOSIT_STAKE,
|
|
19726
|
+
const transaction = new __solana_web3_js.Transaction().add(...instructions$3);
|
|
19727
|
+
return require_common.addTransactionMetadata(transaction, {
|
|
19728
|
+
type: require_common.TransactionType.DEPOSIT_STAKE,
|
|
19627
19729
|
signers: [...signers, ...lendrDepositIxs.keys],
|
|
19628
19730
|
addressLookupTables: this.client.addressLookupTables
|
|
19629
19731
|
});
|
|
19630
19732
|
}
|
|
19631
19733
|
async makeMergeStakeAccountsTx(stakeAccountSrc, stakeAccountDest) {
|
|
19632
|
-
const mergeInstruction = StakeProgram.merge({
|
|
19734
|
+
const mergeInstruction = __solana_web3_js.StakeProgram.merge({
|
|
19633
19735
|
stakePubkey: stakeAccountDest,
|
|
19634
19736
|
sourceStakePubKey: stakeAccountSrc,
|
|
19635
19737
|
authorizedPubkey: this.authority
|
|
19636
19738
|
});
|
|
19637
|
-
const transaction = new Transaction().add(mergeInstruction);
|
|
19739
|
+
const transaction = new __solana_web3_js.Transaction().add(mergeInstruction);
|
|
19638
19740
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19639
|
-
return addTransactionMetadata(transaction, {
|
|
19640
|
-
type: TransactionType.MERGE_STAKE_ACCOUNTS,
|
|
19741
|
+
return require_common.addTransactionMetadata(transaction, {
|
|
19742
|
+
type: require_common.TransactionType.MERGE_STAKE_ACCOUNTS,
|
|
19641
19743
|
signers: [],
|
|
19642
19744
|
addressLookupTables: clientLookupTables
|
|
19643
19745
|
});
|
|
@@ -19691,10 +19793,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19691
19793
|
*/
|
|
19692
19794
|
async makeDepositTx(amount, bankAddress, depositOpts = {}) {
|
|
19693
19795
|
const ixs = await this.makeDepositIx(amount, bankAddress, depositOpts);
|
|
19694
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
19796
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
19695
19797
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19696
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
19697
|
-
type: TransactionType.DEPOSIT,
|
|
19798
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
19799
|
+
type: require_common.TransactionType.DEPOSIT,
|
|
19698
19800
|
signers: ixs.keys,
|
|
19699
19801
|
addressLookupTables: clientLookupTables
|
|
19700
19802
|
});
|
|
@@ -19702,10 +19804,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19702
19804
|
}
|
|
19703
19805
|
async makeDepositWithSessionTx(amount, bankAddress, sessionKey, depositOpts = {}) {
|
|
19704
19806
|
const ixs = await this.makeDepositWithSessionIx(amount, bankAddress, sessionKey, depositOpts);
|
|
19705
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
19807
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
19706
19808
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19707
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
19708
|
-
type: TransactionType.DEPOSIT,
|
|
19809
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
19810
|
+
type: require_common.TransactionType.DEPOSIT,
|
|
19709
19811
|
signers: ixs.keys,
|
|
19710
19812
|
addressLookupTables: clientLookupTables
|
|
19711
19813
|
});
|
|
@@ -19723,11 +19825,11 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19723
19825
|
async simulateBorrowLendTransaction(txs, banksToInspect, healthSimOptions) {
|
|
19724
19826
|
const additionalTxs = [];
|
|
19725
19827
|
if (healthSimOptions?.enabled) {
|
|
19726
|
-
const computeIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 });
|
|
19828
|
+
const computeIx = __solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 });
|
|
19727
19829
|
const updateFeedIx = await this.makeUpdateFeedIx(healthSimOptions.mandatoryBanks);
|
|
19728
19830
|
const healthPulseIx = await this.makePulseHealthIx(healthSimOptions.mandatoryBanks, healthSimOptions.excludedBanks);
|
|
19729
19831
|
const blockhash = (await this.client.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
19730
|
-
const tx = new VersionedTransaction(new TransactionMessage({
|
|
19832
|
+
const tx = new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
19731
19833
|
instructions: [
|
|
19732
19834
|
computeIx,
|
|
19733
19835
|
...updateFeedIx.instructions,
|
|
@@ -19861,10 +19963,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19861
19963
|
*/
|
|
19862
19964
|
async makeRepayTx(amount, bankAddress, repayAll = false, repayOpts = {}) {
|
|
19863
19965
|
const ixs = await this.makeRepayIx(amount, bankAddress, repayAll, repayOpts);
|
|
19864
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
19966
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
19865
19967
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19866
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
19867
|
-
type: TransactionType.REPAY,
|
|
19968
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
19969
|
+
type: require_common.TransactionType.REPAY,
|
|
19868
19970
|
signers: ixs.keys,
|
|
19869
19971
|
addressLookupTables: clientLookupTables
|
|
19870
19972
|
});
|
|
@@ -19881,10 +19983,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19881
19983
|
*/
|
|
19882
19984
|
async makeRepayWithSessionTx(amount, bankAddress, sessionKey, repayAll = false, repayOpts = {}) {
|
|
19883
19985
|
const ixs = await this.makeRepayWithSessionIx(amount, bankAddress, sessionKey, repayAll, repayOpts);
|
|
19884
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
19986
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
19885
19987
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19886
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
19887
|
-
type: TransactionType.REPAY,
|
|
19988
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
19989
|
+
type: require_common.TransactionType.REPAY,
|
|
19888
19990
|
signers: ixs.keys,
|
|
19889
19991
|
addressLookupTables: clientLookupTables
|
|
19890
19992
|
});
|
|
@@ -19935,7 +20037,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19935
20037
|
*/
|
|
19936
20038
|
async makeWithdrawStakedTx(amount, bankAddress, isWholePosition) {
|
|
19937
20039
|
const bank = this.client.getBankByPk(bankAddress);
|
|
19938
|
-
const solBank = this.client.getBankByMint(WSOL_MINT);
|
|
20040
|
+
const solBank = this.client.getBankByMint(require_common.WSOL_MINT);
|
|
19939
20041
|
const bankMetadata = this.client.bankMetadataMap[bankAddress.toBase58()];
|
|
19940
20042
|
if (!bank || !solBank) {
|
|
19941
20043
|
throw new Error("Banks not found");
|
|
@@ -19943,38 +20045,38 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19943
20045
|
if (!bankMetadata.validatorVoteAccount) {
|
|
19944
20046
|
throw new Error("Validator vote account not found");
|
|
19945
20047
|
}
|
|
19946
|
-
const pool = findPoolAddress(new PublicKey(bankMetadata.validatorVoteAccount));
|
|
20048
|
+
const pool = findPoolAddress(new __solana_web3_js.PublicKey(bankMetadata.validatorVoteAccount));
|
|
19947
20049
|
const lstMint = findPoolMintAddress(pool);
|
|
19948
20050
|
const mintAuthority = findPoolMintAuthorityAddress(pool);
|
|
19949
|
-
const lstAta = getAssociatedTokenAddressSync(lstMint, this.authority);
|
|
20051
|
+
const lstAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(lstMint, this.authority);
|
|
19950
20052
|
const rentExemption = await this._program.provider.connection.getMinimumBalanceForRentExemption(200);
|
|
19951
|
-
const stakeAmount = new
|
|
20053
|
+
const stakeAmount = new bignumber_js.default(new bignumber_js.default(amount).toString());
|
|
19952
20054
|
const withdrawIxs = await this.makeWithdrawIx(amount, bankAddress, isWholePosition, {
|
|
19953
20055
|
createAtas: true,
|
|
19954
20056
|
wrapAndUnwrapSol: true
|
|
19955
20057
|
});
|
|
19956
|
-
const stakeAccount = Keypair.generate();
|
|
19957
|
-
const createStakeAccountIx = SystemProgram.createAccount({
|
|
20058
|
+
const stakeAccount = __solana_web3_js.Keypair.generate();
|
|
20059
|
+
const createStakeAccountIx = __solana_web3_js.SystemProgram.createAccount({
|
|
19958
20060
|
fromPubkey: this.authority,
|
|
19959
20061
|
newAccountPubkey: stakeAccount.publicKey,
|
|
19960
20062
|
lamports: rentExemption,
|
|
19961
20063
|
space: 200,
|
|
19962
|
-
programId: STAKE_PROGRAM_ID
|
|
20064
|
+
programId: require_common.STAKE_PROGRAM_ID
|
|
19963
20065
|
});
|
|
19964
|
-
const approveAccountAuthorityIx = createApproveInstruction(lstAta, mintAuthority, this.authority, stakeAmount.multipliedBy(1e9).toNumber(), [], TOKEN_PROGRAM_ID);
|
|
20066
|
+
const approveAccountAuthorityIx = (0, __solana_spl_token.createApproveInstruction)(lstAta, mintAuthority, this.authority, stakeAmount.multipliedBy(1e9).toNumber(), [], __solana_spl_token.TOKEN_PROGRAM_ID);
|
|
19965
20067
|
const withdrawStakeIx = await SinglePoolInstruction.withdrawStake(pool, stakeAccount.publicKey, this.authority, lstAta, stakeAmount);
|
|
19966
20068
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
19967
|
-
const withdrawMessage = new TransactionMessage({
|
|
20069
|
+
const withdrawMessage = new __solana_web3_js.TransactionMessage({
|
|
19968
20070
|
payerKey: this.client.wallet.publicKey,
|
|
19969
20071
|
recentBlockhash: blockhash,
|
|
19970
20072
|
instructions: [...withdrawIxs.instructions]
|
|
19971
20073
|
}).compileToV0Message(this.client.addressLookupTables);
|
|
19972
|
-
const withdrawTxn = addTransactionMetadata(new VersionedTransaction(withdrawMessage), {
|
|
20074
|
+
const withdrawTxn = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(withdrawMessage), {
|
|
19973
20075
|
signers: withdrawIxs.keys,
|
|
19974
20076
|
addressLookupTables: this.client.addressLookupTables,
|
|
19975
|
-
type: TransactionType.WITHDRAW
|
|
20077
|
+
type: require_common.TransactionType.WITHDRAW
|
|
19976
20078
|
});
|
|
19977
|
-
const stakeMessage = new TransactionMessage({
|
|
20079
|
+
const stakeMessage = new __solana_web3_js.TransactionMessage({
|
|
19978
20080
|
payerKey: this.client.wallet.publicKey,
|
|
19979
20081
|
recentBlockhash: blockhash,
|
|
19980
20082
|
instructions: [
|
|
@@ -19983,10 +20085,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19983
20085
|
withdrawStakeIx
|
|
19984
20086
|
]
|
|
19985
20087
|
}).compileToV0Message(this.client.addressLookupTables);
|
|
19986
|
-
const stakeTxn = addTransactionMetadata(new VersionedTransaction(stakeMessage), {
|
|
20088
|
+
const stakeTxn = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(stakeMessage), {
|
|
19987
20089
|
signers: [stakeAccount],
|
|
19988
20090
|
addressLookupTables: this.client.addressLookupTables,
|
|
19989
|
-
type: TransactionType.WITHDRAW_STAKE
|
|
20091
|
+
type: require_common.TransactionType.WITHDRAW_STAKE
|
|
19990
20092
|
});
|
|
19991
20093
|
return {
|
|
19992
20094
|
transactions: [withdrawTxn, stakeTxn],
|
|
@@ -20022,12 +20124,12 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20022
20124
|
const cuRequestIxs = this.makeComputeBudgetIx();
|
|
20023
20125
|
const withdrawIxs = withdrawIxsWrapped.flatMap((ix) => ix.instructions);
|
|
20024
20126
|
const filteredSigners = withdrawIxsWrapped.flatMap((ix) => ix.keys).filter((key, index, self) => index === self.findIndex((k) => k.publicKey.equals(key.publicKey)));
|
|
20025
|
-
const tx = new Transaction().add(...cuRequestIxs, ...withdrawIxs);
|
|
20127
|
+
const tx = new __solana_web3_js.Transaction().add(...cuRequestIxs, ...withdrawIxs);
|
|
20026
20128
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20027
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
20129
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
20028
20130
|
signers: filteredSigners,
|
|
20029
20131
|
addressLookupTables: clientLookupTables,
|
|
20030
|
-
type: TransactionType.WITHDRAW_ALL
|
|
20132
|
+
type: require_common.TransactionType.WITHDRAW_ALL
|
|
20031
20133
|
});
|
|
20032
20134
|
return solanaTx;
|
|
20033
20135
|
}
|
|
@@ -20094,24 +20196,24 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20094
20196
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
20095
20197
|
const feedCrankTxs = [];
|
|
20096
20198
|
if (updateFeedIxs.length > 0) {
|
|
20097
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20199
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20098
20200
|
instructions: [...updateFeedIxs],
|
|
20099
20201
|
payerKey: this.authority,
|
|
20100
20202
|
recentBlockhash: blockhash
|
|
20101
20203
|
}).compileToV0Message(feedLuts)), {
|
|
20102
20204
|
addressLookupTables: feedLuts,
|
|
20103
|
-
type: TransactionType.CRANK
|
|
20205
|
+
type: require_common.TransactionType.CRANK
|
|
20104
20206
|
}));
|
|
20105
20207
|
}
|
|
20106
20208
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20107
|
-
const withdrawTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20209
|
+
const withdrawTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20108
20210
|
instructions: [...cuRequestIxs, ...withdrawIxs.instructions],
|
|
20109
20211
|
payerKey: this.authority,
|
|
20110
20212
|
recentBlockhash: blockhash
|
|
20111
20213
|
}).compileToV0Message(clientLookupTables)), {
|
|
20112
20214
|
signers: withdrawIxs.keys,
|
|
20113
20215
|
addressLookupTables: clientLookupTables,
|
|
20114
|
-
type: TransactionType.WITHDRAW
|
|
20216
|
+
type: require_common.TransactionType.WITHDRAW
|
|
20115
20217
|
});
|
|
20116
20218
|
const transactions = [...feedCrankTxs, withdrawTx];
|
|
20117
20219
|
return {
|
|
@@ -20136,24 +20238,24 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20136
20238
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
20137
20239
|
const feedCrankTxs = [];
|
|
20138
20240
|
if (updateFeedIxs.length > 0) {
|
|
20139
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20241
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20140
20242
|
instructions: [...updateFeedIxs],
|
|
20141
20243
|
payerKey: this.authority,
|
|
20142
20244
|
recentBlockhash: blockhash
|
|
20143
20245
|
}).compileToV0Message(feedLuts)), {
|
|
20144
20246
|
addressLookupTables: feedLuts,
|
|
20145
|
-
type: TransactionType.CRANK
|
|
20247
|
+
type: require_common.TransactionType.CRANK
|
|
20146
20248
|
}));
|
|
20147
20249
|
}
|
|
20148
20250
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20149
|
-
const withdrawTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20251
|
+
const withdrawTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20150
20252
|
instructions: [...cuRequestIxs, ...withdrawIxs.instructions],
|
|
20151
20253
|
payerKey: this.authority,
|
|
20152
20254
|
recentBlockhash: blockhash
|
|
20153
20255
|
}).compileToV0Message(clientLookupTables)), {
|
|
20154
20256
|
signers: withdrawIxs.keys,
|
|
20155
20257
|
addressLookupTables: clientLookupTables,
|
|
20156
|
-
type: TransactionType.WITHDRAW
|
|
20258
|
+
type: require_common.TransactionType.WITHDRAW
|
|
20157
20259
|
});
|
|
20158
20260
|
const transactions = [...feedCrankTxs, withdrawTx];
|
|
20159
20261
|
return {
|
|
@@ -20256,23 +20358,23 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20256
20358
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
20257
20359
|
const feedCrankTxs = [];
|
|
20258
20360
|
if (updateFeedIxs.length > 0) {
|
|
20259
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20361
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20260
20362
|
instructions: updateFeedIxs,
|
|
20261
20363
|
payerKey: this.authority,
|
|
20262
20364
|
recentBlockhash: blockhash
|
|
20263
20365
|
}).compileToV0Message(feedLuts)), {
|
|
20264
|
-
type: TransactionType.CRANK,
|
|
20366
|
+
type: require_common.TransactionType.CRANK,
|
|
20265
20367
|
addressLookupTables: feedLuts
|
|
20266
20368
|
}));
|
|
20267
20369
|
}
|
|
20268
20370
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20269
|
-
const borrowTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20371
|
+
const borrowTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20270
20372
|
instructions: [...cuRequestIxs, ...borrowIxs.instructions],
|
|
20271
20373
|
payerKey: this.authority,
|
|
20272
20374
|
recentBlockhash: blockhash
|
|
20273
20375
|
}).compileToV0Message(clientLookupTables)), {
|
|
20274
20376
|
signers: borrowIxs.keys,
|
|
20275
|
-
type: TransactionType.BORROW,
|
|
20377
|
+
type: require_common.TransactionType.BORROW,
|
|
20276
20378
|
addressLookupTables: clientLookupTables
|
|
20277
20379
|
});
|
|
20278
20380
|
const transactions = [...feedCrankTxs, borrowTx];
|
|
@@ -20297,23 +20399,23 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20297
20399
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
20298
20400
|
const feedCrankTxs = [];
|
|
20299
20401
|
if (updateFeedIxs.length > 0) {
|
|
20300
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20402
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20301
20403
|
instructions: updateFeedIxs,
|
|
20302
20404
|
payerKey: this.authority,
|
|
20303
20405
|
recentBlockhash: blockhash
|
|
20304
20406
|
}).compileToV0Message(feedLuts)), {
|
|
20305
|
-
type: TransactionType.CRANK,
|
|
20407
|
+
type: require_common.TransactionType.CRANK,
|
|
20306
20408
|
addressLookupTables: feedLuts
|
|
20307
20409
|
}));
|
|
20308
20410
|
}
|
|
20309
20411
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20310
|
-
const borrowTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20412
|
+
const borrowTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20311
20413
|
instructions: [...cuRequestIxs, ...borrowIxs.instructions],
|
|
20312
20414
|
payerKey: this.authority,
|
|
20313
20415
|
recentBlockhash: blockhash
|
|
20314
20416
|
}).compileToV0Message(clientLookupTables)), {
|
|
20315
20417
|
signers: borrowIxs.keys,
|
|
20316
|
-
type: TransactionType.BORROW,
|
|
20418
|
+
type: require_common.TransactionType.BORROW,
|
|
20317
20419
|
addressLookupTables: clientLookupTables
|
|
20318
20420
|
});
|
|
20319
20421
|
const transactions = [...feedCrankTxs, borrowTx];
|
|
@@ -20351,13 +20453,13 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20351
20453
|
withdrawEmissionsIxs.push(ix);
|
|
20352
20454
|
}));
|
|
20353
20455
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20354
|
-
const emissionsTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20456
|
+
const emissionsTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20355
20457
|
instructions: withdrawEmissionsIxs.flatMap((ix) => ix.instructions),
|
|
20356
20458
|
payerKey: this.authority,
|
|
20357
20459
|
recentBlockhash: blockhash
|
|
20358
20460
|
}).compileToV0Message(clientLookupTables)), {
|
|
20359
20461
|
signers: withdrawEmissionsIxs.flatMap((ix) => ix.keys),
|
|
20360
|
-
type: TransactionType.WITHDRAW_EMISSIONS,
|
|
20462
|
+
type: require_common.TransactionType.WITHDRAW_EMISSIONS,
|
|
20361
20463
|
addressLookupTables: clientLookupTables
|
|
20362
20464
|
});
|
|
20363
20465
|
return emissionsTx;
|
|
@@ -20415,12 +20517,12 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20415
20517
|
liquidateeLendrAccount: liquidateeLendrAccount.address.toBase58()
|
|
20416
20518
|
}, "[lendr:lendr-account:liquidation] Liquidating lendr account");
|
|
20417
20519
|
const liquidationIxs = await this.makeLendingAccountLiquidateIx(liquidateeLendrAccount, assetBankAddress, assetQuantityUi, liabBankAddress);
|
|
20418
|
-
const tx = new Transaction().add(...liquidationIxs.instructions);
|
|
20520
|
+
const tx = new __solana_web3_js.Transaction().add(...liquidationIxs.instructions);
|
|
20419
20521
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20420
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
20522
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
20421
20523
|
signers: liquidationIxs.keys,
|
|
20422
20524
|
addressLookupTables: clientLookupTables,
|
|
20423
|
-
type: TransactionType.LIQUIDATE_ACCOUNT
|
|
20525
|
+
type: require_common.TransactionType.LIQUIDATE_ACCOUNT
|
|
20424
20526
|
});
|
|
20425
20527
|
const sig = await this.client.processTransaction(solanaTx, processOpts, txOpts);
|
|
20426
20528
|
this.client.logger.debug({
|
|
@@ -20470,14 +20572,14 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20470
20572
|
];
|
|
20471
20573
|
const totalLookupTables = [...lookupTables ?? [], ...args.addressLookupTableAccounts ?? []];
|
|
20472
20574
|
const blockhash = args.blockhash ?? (await this._program.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
20473
|
-
const message = new TransactionMessage({
|
|
20575
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
20474
20576
|
payerKey: this.client.wallet.publicKey,
|
|
20475
20577
|
recentBlockhash: blockhash,
|
|
20476
20578
|
instructions: flashloanIxs
|
|
20477
20579
|
}).compileToV0Message(totalLookupTables);
|
|
20478
|
-
const tx = addTransactionMetadata(new VersionedTransaction(message), {
|
|
20580
|
+
const tx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), {
|
|
20479
20581
|
addressLookupTables: totalLookupTables,
|
|
20480
|
-
type: TransactionType.FLASHLOAN
|
|
20582
|
+
type: require_common.TransactionType.FLASHLOAN
|
|
20481
20583
|
});
|
|
20482
20584
|
if (args.signers) {
|
|
20483
20585
|
tx.sign(args.signers);
|
|
@@ -20493,8 +20595,8 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20493
20595
|
to: newAccountAuthority.toBase58()
|
|
20494
20596
|
}, "[lendr:lendr-account:transfer-authority] Transferring account");
|
|
20495
20597
|
const ixs = await this.makeTransferAccountAuthorityIx(newAccountAuthority);
|
|
20496
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
20497
|
-
const solanaTx = addTransactionMetadata(tx, { type: TransactionType.TRANSFER_AUTH });
|
|
20598
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
20599
|
+
const solanaTx = require_common.addTransactionMetadata(tx, { type: require_common.TransactionType.TRANSFER_AUTH });
|
|
20498
20600
|
const sig = await this.client.processTransaction(solanaTx, processOpts, txOpts);
|
|
20499
20601
|
this.client.logger.debug({ sig }, "[lendr:lendr-account:transfer-authority] Transfer successful");
|
|
20500
20602
|
return sig;
|
|
@@ -20512,13 +20614,13 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20512
20614
|
return this._lendrAccount.makePulseHealthIx(this._program, this.client.banks, mandatoryBanks, excludedBanks, this.client.bankMetadataMap || {});
|
|
20513
20615
|
}
|
|
20514
20616
|
static async _fetchAccountData(accountAddress, config, program, commitment) {
|
|
20515
|
-
const mergedCommitment = commitment ?? program.provider.connection.commitment ?? DEFAULT_COMMITMENT;
|
|
20617
|
+
const mergedCommitment = commitment ?? program.provider.connection.commitment ?? require_common.DEFAULT_COMMITMENT;
|
|
20516
20618
|
const data = await program.account.lendrAccount.fetch(accountAddress, mergedCommitment);
|
|
20517
20619
|
if (!data.group.equals(config.groupPk)) throw Error(`Lendr account tied to group ${data.group.toBase58()}. Expected: ${config.groupPk.toBase58()}`);
|
|
20518
20620
|
return data;
|
|
20519
20621
|
}
|
|
20520
20622
|
static async encode(decoded, idl) {
|
|
20521
|
-
const coder = new BorshCoder(idl);
|
|
20623
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
20522
20624
|
return await coder.accounts.encode(AccountType.LendrAccount, decoded);
|
|
20523
20625
|
}
|
|
20524
20626
|
async reload() {
|
|
@@ -20540,7 +20642,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20540
20642
|
*/
|
|
20541
20643
|
async simulateDeposit(amount, bankAddress) {
|
|
20542
20644
|
const ixs = await this.makeDepositIx(amount, bankAddress);
|
|
20543
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
20645
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
20544
20646
|
try {
|
|
20545
20647
|
return this.simulateBorrowLendTransaction([tx], [bankAddress]);
|
|
20546
20648
|
} catch (e) {
|
|
@@ -20572,7 +20674,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20572
20674
|
*/
|
|
20573
20675
|
async simulateRepay(amount, bankAddress, repayAll = false) {
|
|
20574
20676
|
const ixs = await this.makeRepayIx(amount, bankAddress, repayAll);
|
|
20575
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
20677
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
20576
20678
|
try {
|
|
20577
20679
|
return this.simulateBorrowLendTransaction([tx], [bankAddress]);
|
|
20578
20680
|
} catch (e) {
|
|
@@ -20587,7 +20689,7 @@ function makeTxPriorityIx(feePayer, feeUi = 0, broadcastType = "BUNDLE", compute
|
|
|
20587
20689
|
let bundleTipIx;
|
|
20588
20690
|
let priorityFeeIx = makePriorityFeeIx()[0];
|
|
20589
20691
|
if (broadcastType === "BUNDLE") {
|
|
20590
|
-
bundleTipIx = makeBundleTipIx(feePayer, Math.trunc(feeUi * LAMPORTS_PER_SOL));
|
|
20692
|
+
bundleTipIx = makeBundleTipIx(feePayer, Math.trunc(feeUi * __solana_web3_js.LAMPORTS_PER_SOL));
|
|
20591
20693
|
} else {
|
|
20592
20694
|
priorityFeeIx = makePriorityFeeIx(feeUi, computeUnitsLimit)[0];
|
|
20593
20695
|
}
|
|
@@ -20622,9 +20724,9 @@ function makeBundleTipIx(feePayer, bundleTip = 1e5) {
|
|
|
20622
20724
|
"3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT"
|
|
20623
20725
|
];
|
|
20624
20726
|
const randomTipAccount = tipAccounts[Math.floor(Math.random() * tipAccounts.length)];
|
|
20625
|
-
return SystemProgram.transfer({
|
|
20727
|
+
return __solana_web3_js.SystemProgram.transfer({
|
|
20626
20728
|
fromPubkey: feePayer,
|
|
20627
|
-
toPubkey: new PublicKey(randomTipAccount),
|
|
20729
|
+
toPubkey: new __solana_web3_js.PublicKey(randomTipAccount),
|
|
20628
20730
|
lamports: bundleTip
|
|
20629
20731
|
});
|
|
20630
20732
|
}
|
|
@@ -20658,11 +20760,11 @@ var LendrGroup = class LendrGroup {
|
|
|
20658
20760
|
return LendrGroup.fromAccountParsed(address$2, data);
|
|
20659
20761
|
}
|
|
20660
20762
|
static decode(encoded, idl) {
|
|
20661
|
-
const coder = new BorshCoder(idl);
|
|
20763
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
20662
20764
|
return coder.accounts.decode(AccountType.LendrGroup, encoded);
|
|
20663
20765
|
}
|
|
20664
20766
|
static async encode(decoded, idl) {
|
|
20665
|
-
const coder = new BorshCoder(idl);
|
|
20767
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
20666
20768
|
return await coder.accounts.encode(AccountType.LendrGroup, decoded);
|
|
20667
20769
|
}
|
|
20668
20770
|
async makeEnableFlashLoanForAccountIx(program, lendrAccountAddress) {
|
|
@@ -20732,7 +20834,7 @@ var LendrClient = class LendrClient {
|
|
|
20732
20834
|
this.bankMetadataMap = bankMetadataMap;
|
|
20733
20835
|
this.overrideBankAddresses = overrideBankAddresses;
|
|
20734
20836
|
this.overrideBanksMetadata = overrideBanksMetadata;
|
|
20735
|
-
this.storage = storage ?? createStorage();
|
|
20837
|
+
this.storage = storage ?? (0, unstorage.createStorage)();
|
|
20736
20838
|
this.metadataService = metadataService;
|
|
20737
20839
|
this.dataFetcher = dataFetcher ?? new DataFetcher();
|
|
20738
20840
|
}
|
|
@@ -20748,7 +20850,11 @@ var LendrClient = class LendrClient {
|
|
|
20748
20850
|
* @returns LendrClient instance
|
|
20749
20851
|
*/
|
|
20750
20852
|
static async fetch({ wallet, connection, clientOptions = {}, config = getConfig() }) {
|
|
20751
|
-
const { logger = new NoopLogger(), confirmOpts = {}, readOnly = false, storage = createStorage(), dataFetcher = new DataFetcher(), overrideBankAddresses, overrideBanksMetadata,
|
|
20853
|
+
const { logger = new NoopLogger(), confirmOpts = {}, readOnly = false, storage = (0, unstorage.createStorage)(), dataFetcher = new DataFetcher(), overrideBankAddresses, overrideBanksMetadata, metadataFetchers = [
|
|
20854
|
+
new FogoMetadataFetcher(),
|
|
20855
|
+
new MetaplexMetadataFetcher(connection.rpcEndpoint),
|
|
20856
|
+
new DummyMetadataFetcher()
|
|
20857
|
+
], addressLookupTableAddresses } = clientOptions;
|
|
20752
20858
|
logger.debug({
|
|
20753
20859
|
programId: config.programId.toBase58(),
|
|
20754
20860
|
env: config.environment,
|
|
@@ -20756,16 +20862,22 @@ var LendrClient = class LendrClient {
|
|
|
20756
20862
|
url: connection?.rpcEndpoint
|
|
20757
20863
|
}, "[lendr:client] Loading Lendr Client");
|
|
20758
20864
|
const programIdl = fetchLatestIdl();
|
|
20759
|
-
const provider = new AnchorProvider(connection, wallet, {
|
|
20760
|
-
...AnchorProvider.defaultOptions(),
|
|
20761
|
-
commitment: connection.commitment ?? AnchorProvider.defaultOptions().commitment,
|
|
20865
|
+
const provider = new __coral_xyz_anchor.AnchorProvider(connection, wallet, {
|
|
20866
|
+
...__coral_xyz_anchor.AnchorProvider.defaultOptions(),
|
|
20867
|
+
commitment: connection.commitment ?? __coral_xyz_anchor.AnchorProvider.defaultOptions().commitment,
|
|
20762
20868
|
...confirmOpts
|
|
20763
20869
|
});
|
|
20764
20870
|
const idl = {
|
|
20765
20871
|
...programIdl,
|
|
20766
20872
|
address: config.programId.toBase58()
|
|
20767
20873
|
};
|
|
20768
|
-
const program = new Program(idl, provider);
|
|
20874
|
+
const program = new __coral_xyz_anchor.Program(idl, provider);
|
|
20875
|
+
const metadataService = new MetadataService({
|
|
20876
|
+
storage,
|
|
20877
|
+
overrides: overrideBanksMetadata,
|
|
20878
|
+
fetchers: metadataFetchers,
|
|
20879
|
+
logger
|
|
20880
|
+
});
|
|
20769
20881
|
const { lendrGroup, banks, priceInfos, tokensData, feedIdMap, banksExtendedMetadata } = await LendrClient.fetchGroupData({
|
|
20770
20882
|
connection,
|
|
20771
20883
|
program,
|
|
@@ -20843,12 +20955,12 @@ var LendrClient = class LendrClient {
|
|
|
20843
20955
|
const oracleKeys = [];
|
|
20844
20956
|
for (const bank of banksRawData) {
|
|
20845
20957
|
mintKeys.push(bank.data.mint);
|
|
20846
|
-
if (!bank.data.emissionsMint.equals(PublicKey.default)) {
|
|
20958
|
+
if (!bank.data.emissionsMint.equals(__solana_web3_js.PublicKey.default)) {
|
|
20847
20959
|
emissionMintKeys.push(bank.data.emissionsMint);
|
|
20848
20960
|
}
|
|
20849
20961
|
oracleKeys.push(findOracleKey(BankConfig.fromAccountParsed(bank.data.config), feedIdMap).oracleKey);
|
|
20850
20962
|
}
|
|
20851
|
-
const allAccountInfos = await chunkedGetRawMultipleAccountInfoOrdered(program.provider.connection, [
|
|
20963
|
+
const allAccountInfos = await require_common.chunkedGetRawMultipleAccountInfoOrdered(program.provider.connection, [
|
|
20852
20964
|
groupAddress.toBase58(),
|
|
20853
20965
|
...oracleKeys.map((pk) => pk.toBase58()),
|
|
20854
20966
|
...mintKeys.map((pk) => pk.toBase58()),
|
|
@@ -20862,7 +20974,7 @@ var LendrClient = class LendrClient {
|
|
|
20862
20974
|
const mintAccountInfos = allAccountInfos.splice(0, mintKeys.length);
|
|
20863
20975
|
const emissionMintAccountInfos = allAccountInfos.splice(0);
|
|
20864
20976
|
const lendrGroup = LendrGroup.fromBuffer(groupAddress, groupAccountInfo.data, program.idl);
|
|
20865
|
-
const banksExtendedMetadata = await fetchBanksExtendedMetadata({
|
|
20977
|
+
const banksExtendedMetadata = await require_common.fetchBanksExtendedMetadata({
|
|
20866
20978
|
mintsWithOwner: mintKeys.map((mint, idx) => ({
|
|
20867
20979
|
mint,
|
|
20868
20980
|
owner: mintAccountInfos[idx].owner
|
|
@@ -20881,6 +20993,14 @@ var LendrClient = class LendrClient {
|
|
|
20881
20993
|
banksRawData.forEach(({ address: address$2, data }, index) => {
|
|
20882
20994
|
const bankAddressStr = address$2.toBase58();
|
|
20883
20995
|
const metadata$2 = banksExtendedMetadata.get(data.mint.toBase58());
|
|
20996
|
+
const oracleSetup = parseOracleSetup(data.config.oracleSetup);
|
|
20997
|
+
if (!isOracleSetupSupported(oracleSetup)) {
|
|
20998
|
+
logger.warn({
|
|
20999
|
+
oracleSetup,
|
|
21000
|
+
bank: bankAddressStr
|
|
21001
|
+
}, "unsupported oracle setup");
|
|
21002
|
+
return;
|
|
21003
|
+
}
|
|
20884
21004
|
const mintDataRaw = mintAccountInfos[index];
|
|
20885
21005
|
if (!mintDataRaw) {
|
|
20886
21006
|
throw new Error(`Failed to fetch mint account for bank ${bankAddressStr}`);
|
|
@@ -20892,7 +21012,7 @@ var LendrClient = class LendrClient {
|
|
|
20892
21012
|
const bank = Bank.fromAccountParsed(address$2, data, feedIdMap, metadata$2, mintDataRaw.owner);
|
|
20893
21013
|
banks.set(bankAddressStr, bank);
|
|
20894
21014
|
let emissionTokenProgram = null;
|
|
20895
|
-
if (!data.emissionsMint.equals(PublicKey.default)) {
|
|
21015
|
+
if (!data.emissionsMint.equals(__solana_web3_js.PublicKey.default)) {
|
|
20896
21016
|
const emissionMintDataRawIndex = emissionMintKeys.findIndex((pk) => pk.equals(data.emissionsMint));
|
|
20897
21017
|
emissionTokenProgram = emissionMintDataRawIndex >= 0 ? emissionMintAccountInfos[emissionMintDataRawIndex].owner : null;
|
|
20898
21018
|
}
|
|
@@ -20902,14 +21022,13 @@ var LendrClient = class LendrClient {
|
|
|
20902
21022
|
feeBps: 0,
|
|
20903
21023
|
emissionTokenProgram
|
|
20904
21024
|
});
|
|
20905
|
-
const oracleSetup = parseOracleSetup(data.config.oracleSetup);
|
|
20906
21025
|
priceInfos.set(bankAddressStr, parseOraclePriceData(oracleSetup, priceDataRaw.data, logger));
|
|
20907
21026
|
if (oracleSetup === OracleSetup.StakedWithPythPush && metadata$2?.validatorVoteAccount) {
|
|
20908
|
-
const [poolAddress] = PublicKey.findProgramAddressSync([Buffer.from("pool"), new PublicKey(metadata$2.validatorVoteAccount).toBuffer()], SINGLE_POOL_PROGRAM_ID);
|
|
20909
|
-
const [stakePoolAddress] = PublicKey.findProgramAddressSync([Buffer.from("stake"), poolAddress.toBuffer()], SINGLE_POOL_PROGRAM_ID);
|
|
21027
|
+
const [poolAddress] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("pool"), new __solana_web3_js.PublicKey(metadata$2.validatorVoteAccount).toBuffer()], require_common.SINGLE_POOL_PROGRAM_ID);
|
|
21028
|
+
const [stakePoolAddress] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("stake"), poolAddress.toBuffer()], require_common.SINGLE_POOL_PROGRAM_ID);
|
|
20910
21029
|
stakedCollatMap[address$2.toBase58()] = {
|
|
20911
21030
|
bankAddress: address$2,
|
|
20912
|
-
mint: new PublicKey(metadata$2.mint),
|
|
21031
|
+
mint: new __solana_web3_js.PublicKey(metadata$2.mint),
|
|
20913
21032
|
stakePoolAddress,
|
|
20914
21033
|
poolAddress
|
|
20915
21034
|
};
|
|
@@ -20917,9 +21036,9 @@ var LendrClient = class LendrClient {
|
|
|
20917
21036
|
mints.push(metadata$2.mint);
|
|
20918
21037
|
}
|
|
20919
21038
|
});
|
|
20920
|
-
const dataAis = await chunkedGetRawMultipleAccountInfoOrdered(program.provider.connection, [...mints, ...solPools]);
|
|
21039
|
+
const dataAis = await require_common.chunkedGetRawMultipleAccountInfoOrdered(program.provider.connection, [...mints, ...solPools]);
|
|
20921
21040
|
const stakePoolsAis = dataAis.slice(mints.length).map((ai) => getStakeAccount(ai.data));
|
|
20922
|
-
const lstMintsAis = dataAis.slice(0, mints.length).map((mintAi) => MintLayout.decode(mintAi.data));
|
|
21041
|
+
const lstMintsAis = dataAis.slice(0, mints.length).map((mintAi) => __solana_spl_token.MintLayout.decode(mintAi.data));
|
|
20923
21042
|
const lstMintRecord = Object.fromEntries(mints.map((mint, i) => [mint, lstMintsAis[i]]));
|
|
20924
21043
|
const solPoolsRecord = Object.fromEntries(solPools.map((poolKey, i) => [poolKey, stakePoolsAis[i]]));
|
|
20925
21044
|
for (const index in stakedCollatMap) {
|
|
@@ -20930,7 +21049,7 @@ var LendrClient = class LendrClient {
|
|
|
20930
21049
|
const oracle = priceInfos.get(bankAddress.toBase58());
|
|
20931
21050
|
if (oracle) {
|
|
20932
21051
|
const adjustPrice = (price, stakeActual$1, tokenSupply$1) => {
|
|
20933
|
-
return Number(tokenSupply$1) === 0 ? price : new
|
|
21052
|
+
return Number(tokenSupply$1) === 0 ? price : new bignumber_js.default(price.toNumber() * (stakeActual$1 - __solana_web3_js.LAMPORTS_PER_SOL) / Number(tokenSupply$1));
|
|
20934
21053
|
};
|
|
20935
21054
|
const adjustPriceComponent$1 = (priceComponent, stakeActual$1, tokenSupply$1) => ({
|
|
20936
21055
|
price: adjustPrice(priceComponent.price, stakeActual$1, tokenSupply$1),
|
|
@@ -21042,7 +21161,7 @@ var LendrClient = class LendrClient {
|
|
|
21042
21161
|
offset: 8
|
|
21043
21162
|
} }, { memcmp: {
|
|
21044
21163
|
offset: 0,
|
|
21045
|
-
bytes: bs58.encode(new BorshAccountsCoder(this.program.idl).accountDiscriminator(AccountType.LendrAccount))
|
|
21164
|
+
bytes: bs58.default.encode(new __coral_xyz_anchor.BorshAccountsCoder(this.program.idl).accountDiscriminator(AccountType.LendrAccount))
|
|
21046
21165
|
} }]
|
|
21047
21166
|
})).map((a) => a.pubkey);
|
|
21048
21167
|
}
|
|
@@ -21052,7 +21171,7 @@ var LendrClient = class LendrClient {
|
|
|
21052
21171
|
* @returns LendrAccount instances
|
|
21053
21172
|
*/
|
|
21054
21173
|
async getLendrAccountsForAuthority(authority) {
|
|
21055
|
-
const _authority = authority ? translateAddress(authority) : this.provider.wallet.publicKey;
|
|
21174
|
+
const _authority = authority ? (0, __coral_xyz_anchor.translateAddress)(authority) : this.provider.wallet.publicKey;
|
|
21056
21175
|
const lendrAccounts = (await this.program.account.lendrAccount.all([{ memcmp: {
|
|
21057
21176
|
bytes: this.groupAddress.toBase58(),
|
|
21058
21177
|
offset: 8
|
|
@@ -21082,16 +21201,16 @@ var LendrClient = class LendrClient {
|
|
|
21082
21201
|
},
|
|
21083
21202
|
filters: [{ memcmp: {
|
|
21084
21203
|
offset: 0,
|
|
21085
|
-
bytes: bs58.encode(new BorshAccountsCoder(this.program.idl).accountDiscriminator(AccountType.LendrAccount))
|
|
21204
|
+
bytes: bs58.default.encode(new __coral_xyz_anchor.BorshAccountsCoder(this.program.idl).accountDiscriminator(AccountType.LendrAccount))
|
|
21086
21205
|
} }]
|
|
21087
21206
|
})).map((a) => a.pubkey);
|
|
21088
21207
|
}
|
|
21089
21208
|
getBankByPk(bankAddress) {
|
|
21090
|
-
const _bankAddress = translateAddress(bankAddress);
|
|
21209
|
+
const _bankAddress = (0, __coral_xyz_anchor.translateAddress)(bankAddress);
|
|
21091
21210
|
return this.banks.get(_bankAddress.toString()) ?? null;
|
|
21092
21211
|
}
|
|
21093
21212
|
getBankByMint(mint) {
|
|
21094
|
-
const _mint = translateAddress(mint);
|
|
21213
|
+
const _mint = (0, __coral_xyz_anchor.translateAddress)(mint);
|
|
21095
21214
|
return [...this.banks.values()].find((bank) => bank.mint.equals(_mint)) ?? null;
|
|
21096
21215
|
}
|
|
21097
21216
|
getBankByTokenSymbol(tokenSymbol) {
|
|
@@ -21099,7 +21218,7 @@ var LendrClient = class LendrClient {
|
|
|
21099
21218
|
return [...this.banks.values()].find((bank) => bank.tokenSymbol === tokenSymbol) ?? null;
|
|
21100
21219
|
}
|
|
21101
21220
|
getOraclePriceByBank(bankAddress) {
|
|
21102
|
-
const _bankAddress = translateAddress(bankAddress);
|
|
21221
|
+
const _bankAddress = (0, __coral_xyz_anchor.translateAddress)(bankAddress);
|
|
21103
21222
|
return this.oraclePrices.get(_bankAddress.toString()) ?? null;
|
|
21104
21223
|
}
|
|
21105
21224
|
/**
|
|
@@ -21144,7 +21263,7 @@ var LendrClient = class LendrClient {
|
|
|
21144
21263
|
* @returns Object containing the transaction signature and the created LendrAccount instance
|
|
21145
21264
|
*/
|
|
21146
21265
|
async createLendrAccount(createOpts, processOpts, txOpts) {
|
|
21147
|
-
const accountKeypair = Keypair.generate();
|
|
21266
|
+
const accountKeypair = __solana_web3_js.Keypair.generate();
|
|
21148
21267
|
const newAccountKey = createOpts?.newAccountKey ?? accountKeypair.publicKey;
|
|
21149
21268
|
const solanaTx = await this.createLendrAccountTx({ accountKeypair });
|
|
21150
21269
|
const sig = await this.processTransaction(solanaTx, processOpts, txOpts);
|
|
@@ -21161,11 +21280,11 @@ var LendrClient = class LendrClient {
|
|
|
21161
21280
|
* @returns Object containing the transaction signature and the created LendrAccount instance
|
|
21162
21281
|
*/
|
|
21163
21282
|
async createLendrAccountWithSession(session, commitment, customAccountSeed) {
|
|
21164
|
-
const accountSeed = new
|
|
21165
|
-
const tx = await this.createLendrAccountWithSessionTx(session, new
|
|
21283
|
+
const accountSeed = new bn_js.default(customAccountSeed ?? 0);
|
|
21284
|
+
const tx = await this.createLendrAccountWithSessionTx(session, new bn_js.default(accountSeed ?? 0));
|
|
21166
21285
|
const txResult = await session.sendTransaction(tx);
|
|
21167
21286
|
this.logger.debug({ txResult }, "Created Lendr account (using session)");
|
|
21168
|
-
const [accountPublicKey] = PublicKey.findProgramAddressSync([
|
|
21287
|
+
const [accountPublicKey] = __solana_web3_js.PublicKey.findProgramAddressSync([
|
|
21169
21288
|
Buffer.from("pyroners"),
|
|
21170
21289
|
session.walletPublicKey.toBuffer(),
|
|
21171
21290
|
this.groupAddress.toBuffer(),
|
|
@@ -21194,15 +21313,15 @@ var LendrClient = class LendrClient {
|
|
|
21194
21313
|
* @returns Transaction that can be used to create a new lendr account
|
|
21195
21314
|
*/
|
|
21196
21315
|
async createLendrAccountTx(createOpts) {
|
|
21197
|
-
const accountKeypair = createOpts?.accountKeypair ?? Keypair.generate();
|
|
21316
|
+
const accountKeypair = createOpts?.accountKeypair ?? __solana_web3_js.Keypair.generate();
|
|
21198
21317
|
const ixs = await this.makeCreateLendrAccountIx(accountKeypair.publicKey);
|
|
21199
21318
|
const signers = [...ixs.keys];
|
|
21200
21319
|
signers.push(accountKeypair);
|
|
21201
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
21202
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
21320
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
21321
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
21203
21322
|
signers,
|
|
21204
21323
|
addressLookupTables: this.addressLookupTables,
|
|
21205
|
-
type: TransactionType.CREATE_ACCOUNT
|
|
21324
|
+
type: require_common.TransactionType.CREATE_ACCOUNT
|
|
21206
21325
|
});
|
|
21207
21326
|
return solanaTx;
|
|
21208
21327
|
}
|
|
@@ -21210,29 +21329,29 @@ var LendrClient = class LendrClient {
|
|
|
21210
21329
|
try {
|
|
21211
21330
|
return (await this.provider.connection.getLatestBlockhashAndContext("confirmed")).value.blockhash;
|
|
21212
21331
|
} catch (ex) {
|
|
21213
|
-
const connection = new Connection(this.provider.connection.rpcEndpoint, this.provider.opts);
|
|
21332
|
+
const connection = new __solana_web3_js.Connection(this.provider.connection.rpcEndpoint, this.provider.opts);
|
|
21214
21333
|
return (await connection.getLatestBlockhashAndContext("confirmed")).value.blockhash;
|
|
21215
21334
|
}
|
|
21216
21335
|
}
|
|
21217
21336
|
async createVersionTransaction(instructions$3, payerKey, signers, extraMetaData) {
|
|
21218
21337
|
const blockhash = await this.getLatestBlockHashForSure();
|
|
21219
|
-
const versionedMessage = new TransactionMessage({
|
|
21338
|
+
const versionedMessage = new __solana_web3_js.TransactionMessage({
|
|
21220
21339
|
instructions: instructions$3,
|
|
21221
21340
|
payerKey,
|
|
21222
21341
|
recentBlockhash: blockhash
|
|
21223
21342
|
});
|
|
21224
|
-
const tx = new VersionedTransaction(this.addressLookupTables ? versionedMessage.compileToV0Message(this.addressLookupTables) : versionedMessage.compileToLegacyMessage());
|
|
21343
|
+
const tx = new __solana_web3_js.VersionedTransaction(this.addressLookupTables ? versionedMessage.compileToV0Message(this.addressLookupTables) : versionedMessage.compileToLegacyMessage());
|
|
21225
21344
|
if (signers?.length) {
|
|
21226
21345
|
tx.sign(signers);
|
|
21227
21346
|
}
|
|
21228
21347
|
if (extraMetaData && Object.keys(extraMetaData)?.length) {
|
|
21229
|
-
return addTransactionMetadata(tx, extraMetaData);
|
|
21348
|
+
return require_common.addTransactionMetadata(tx, extraMetaData);
|
|
21230
21349
|
}
|
|
21231
21350
|
return tx;
|
|
21232
21351
|
}
|
|
21233
21352
|
async createLendrAccountWithSessionTx(session, accountSeed) {
|
|
21234
21353
|
const ixs = await this.makeCreateLendrAccountWithSessionIx(session, accountSeed);
|
|
21235
|
-
return this.createVersionTransaction(ixs.instructions, session.payer, [...ixs.keys], { type: TransactionType.CREATE_ACCOUNT });
|
|
21354
|
+
return this.createVersionTransaction(ixs.instructions, session.payer, [...ixs.keys], { type: require_common.TransactionType.CREATE_ACCOUNT });
|
|
21236
21355
|
}
|
|
21237
21356
|
/**
|
|
21238
21357
|
* Create transaction instruction to initialize a new group.
|
|
@@ -21265,14 +21384,14 @@ var LendrClient = class LendrClient {
|
|
|
21265
21384
|
* @returns {Promise<TransactionSignature>} A promise that resolves to the transaction signature as a string.
|
|
21266
21385
|
*/
|
|
21267
21386
|
async createPermissionlessBank({ mint, bankConfig, group, admin, seed, txOpts, processOpts }) {
|
|
21268
|
-
const keypair = seed ?? Keypair.generate();
|
|
21387
|
+
const keypair = seed ?? __solana_web3_js.Keypair.generate();
|
|
21269
21388
|
const bankIxs = await this.group.makePoolAddBankIx(this.program, keypair.publicKey, mint, bankConfig, admin);
|
|
21270
21389
|
const signers = [...bankIxs.keys, keypair];
|
|
21271
|
-
const tx = new Transaction().add(...bankIxs.instructions);
|
|
21272
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
21390
|
+
const tx = new __solana_web3_js.Transaction().add(...bankIxs.instructions);
|
|
21391
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
21273
21392
|
signers,
|
|
21274
21393
|
addressLookupTables: this.addressLookupTables,
|
|
21275
|
-
type: TransactionType.CREATE_PERM_BANK
|
|
21394
|
+
type: require_common.TransactionType.CREATE_PERM_BANK
|
|
21276
21395
|
});
|
|
21277
21396
|
const sig = await this.processTransaction(solanaTx, processOpts, txOpts);
|
|
21278
21397
|
this.logger.debug({ sig }, "Created Lendr group");
|
|
@@ -21288,14 +21407,14 @@ var LendrClient = class LendrClient {
|
|
|
21288
21407
|
* @returns The public key of the newly created lendr group.
|
|
21289
21408
|
*/
|
|
21290
21409
|
async createLendrGroup(seed, additionalIxs, processOpts, txOpts) {
|
|
21291
|
-
const accountKeypair = seed ?? Keypair.generate();
|
|
21410
|
+
const accountKeypair = seed ?? __solana_web3_js.Keypair.generate();
|
|
21292
21411
|
const ixs = await this.makeCreateLendrGroupIx(accountKeypair.publicKey);
|
|
21293
21412
|
const signers = [...ixs.keys, accountKeypair];
|
|
21294
|
-
const tx = new Transaction().add(...ixs.instructions, ...additionalIxs ?? []);
|
|
21295
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
21413
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions, ...additionalIxs ?? []);
|
|
21414
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
21296
21415
|
signers,
|
|
21297
21416
|
addressLookupTables: this.addressLookupTables,
|
|
21298
|
-
type: TransactionType.CREATE_GROUP
|
|
21417
|
+
type: require_common.TransactionType.CREATE_GROUP
|
|
21299
21418
|
});
|
|
21300
21419
|
const sig = await this.processTransaction(solanaTx, processOpts, txOpts);
|
|
21301
21420
|
this.logger.debug({ sig }, "Created Lendr group");
|
|
@@ -21312,14 +21431,14 @@ var LendrClient = class LendrClient {
|
|
|
21312
21431
|
* @returns The bank's public key and the transaction signature
|
|
21313
21432
|
*/
|
|
21314
21433
|
async createLendingPool(bankMint, bankConfig, seed, processOpts, txOpts) {
|
|
21315
|
-
const bankKeypair = seed ?? Keypair.generate();
|
|
21434
|
+
const bankKeypair = seed ?? __solana_web3_js.Keypair.generate();
|
|
21316
21435
|
const ixs = await this.group.makePoolAddBankIx(this.program, bankKeypair.publicKey, bankMint, bankConfig);
|
|
21317
21436
|
const signers = [...ixs.keys, bankKeypair];
|
|
21318
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
21319
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
21437
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
21438
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
21320
21439
|
signers,
|
|
21321
21440
|
addressLookupTables: this.addressLookupTables,
|
|
21322
|
-
type: TransactionType.CREATE_PERM_BANK
|
|
21441
|
+
type: require_common.TransactionType.CREATE_PERM_BANK
|
|
21323
21442
|
});
|
|
21324
21443
|
const sig = await this.processTransaction(solanaTx, processOpts, txOpts);
|
|
21325
21444
|
this.logger.debug({ sig }, "Created new lending pool");
|
|
@@ -21388,21 +21507,21 @@ var LendrClient = class LendrClient {
|
|
|
21388
21507
|
}
|
|
21389
21508
|
async simulateTransactions(transactions, accountsToInspect) {
|
|
21390
21509
|
const versionedTransactions = [];
|
|
21391
|
-
const connection = new Connection(this.provider.connection.rpcEndpoint, this.provider.opts);
|
|
21510
|
+
const connection = new __solana_web3_js.Connection(this.provider.connection.rpcEndpoint, this.provider.opts);
|
|
21392
21511
|
let blockhash;
|
|
21393
21512
|
try {
|
|
21394
21513
|
const getLatestBlockhashAndContext = await connection.getLatestBlockhashAndContext("confirmed");
|
|
21395
21514
|
blockhash = getLatestBlockhashAndContext.value.blockhash;
|
|
21396
21515
|
for (const transaction of transactions) {
|
|
21397
|
-
if (isV0Tx(transaction)) {
|
|
21516
|
+
if (require_common.isV0Tx(transaction)) {
|
|
21398
21517
|
versionedTransactions.push(transaction);
|
|
21399
21518
|
} else {
|
|
21400
|
-
const versionedMessage = new TransactionMessage({
|
|
21519
|
+
const versionedMessage = new __solana_web3_js.TransactionMessage({
|
|
21401
21520
|
instructions: transaction.instructions,
|
|
21402
21521
|
payerKey: this.provider.publicKey,
|
|
21403
21522
|
recentBlockhash: blockhash
|
|
21404
21523
|
});
|
|
21405
|
-
versionedTransactions.push(new VersionedTransaction(versionedMessage.compileToV0Message(this.addressLookupTables)));
|
|
21524
|
+
versionedTransactions.push(new __solana_web3_js.VersionedTransaction(versionedMessage.compileToV0Message(this.addressLookupTables)));
|
|
21406
21525
|
}
|
|
21407
21526
|
}
|
|
21408
21527
|
} catch (error) {
|
|
@@ -21478,5 +21597,230 @@ var LendrClient = class LendrClient {
|
|
|
21478
21597
|
var client_default = LendrClient;
|
|
21479
21598
|
|
|
21480
21599
|
//#endregion
|
|
21481
|
-
|
|
21482
|
-
|
|
21600
|
+
exports.AccountFlags = AccountFlags;
|
|
21601
|
+
exports.AccountType = AccountType;
|
|
21602
|
+
exports.AssetTag = AssetTag;
|
|
21603
|
+
exports.BUNDLE_TX_SIZE = require_common.BUNDLE_TX_SIZE;
|
|
21604
|
+
exports.Balance = Balance;
|
|
21605
|
+
exports.Bank = Bank;
|
|
21606
|
+
exports.BankConfig = BankConfig;
|
|
21607
|
+
exports.BankVaultType = BankVaultType;
|
|
21608
|
+
exports.DEFAULT_CLUSTER = require_common.DEFAULT_CLUSTER;
|
|
21609
|
+
exports.DEFAULT_COMMITMENT = require_common.DEFAULT_COMMITMENT;
|
|
21610
|
+
exports.DEFAULT_CONFIRM_OPTS = require_common.DEFAULT_CONFIRM_OPTS;
|
|
21611
|
+
exports.DEFAULT_ORACLE_MAX_AGE = require_common.DEFAULT_ORACLE_MAX_AGE;
|
|
21612
|
+
exports.DEFAULT_PROCESS_TX_OPTS = DEFAULT_PROCESS_TX_OPTS;
|
|
21613
|
+
exports.DEFAULT_PROCESS_TX_STRATEGY = DEFAULT_PROCESS_TX_STRATEGY;
|
|
21614
|
+
exports.DEFAULT_SEND_OPTS = require_common.DEFAULT_SEND_OPTS;
|
|
21615
|
+
exports.DISABLED_FLAG = require_common.DISABLED_FLAG;
|
|
21616
|
+
exports.DUMMY_USDC_MINT = require_common.DUMMY_USDC_MINT;
|
|
21617
|
+
exports.DataFetcher = DataFetcher;
|
|
21618
|
+
exports.DummyMetadataFetcher = DummyMetadataFetcher;
|
|
21619
|
+
exports.EmodeEntryFlags = EmodeEntryFlags;
|
|
21620
|
+
exports.EmodeFlags = EmodeFlags;
|
|
21621
|
+
exports.EmodeImpactStatus = EmodeImpactStatus;
|
|
21622
|
+
exports.EmodeSettings = EmodeSettings;
|
|
21623
|
+
exports.EmodeTag = EmodeTag;
|
|
21624
|
+
exports.FLASHLOAN_ENABLED_FLAG = require_common.FLASHLOAN_ENABLED_FLAG;
|
|
21625
|
+
exports.GROUP_PK = require_common.GROUP_PK;
|
|
21626
|
+
exports.HOURS_PER_YEAR = require_common.HOURS_PER_YEAR;
|
|
21627
|
+
exports.HealthCache = HealthCache;
|
|
21628
|
+
exports.HealthCacheFlags = HealthCacheFlags;
|
|
21629
|
+
exports.HealthCacheSimulationError = HealthCacheSimulationError;
|
|
21630
|
+
exports.JUPITER_V6_PROGRAM = require_common.JUPITER_V6_PROGRAM;
|
|
21631
|
+
exports.LENDR_IDL = LENDR_IDL;
|
|
21632
|
+
exports.LENDR_PROGRAM = require_common.LENDR_PROGRAM;
|
|
21633
|
+
exports.LENDR_SPONSORED_SHARD_ID = LENDR_SPONSORED_SHARD_ID;
|
|
21634
|
+
exports.LST_MINT = require_common.LST_MINT;
|
|
21635
|
+
exports.LUT_PROGRAM_AUTHORITY_INDEX = require_common.LUT_PROGRAM_AUTHORITY_INDEX;
|
|
21636
|
+
exports.LendrAccount = LendrAccount;
|
|
21637
|
+
exports.LendrAccountWrapper = LendrAccountWrapper;
|
|
21638
|
+
exports.LendrClient = client_default;
|
|
21639
|
+
exports.LendrGroup = LendrGroup;
|
|
21640
|
+
exports.LendrRequirementType = LendrRequirementType;
|
|
21641
|
+
exports.MAX_ACCOUNT_KEYS = require_common.MAX_ACCOUNT_KEYS;
|
|
21642
|
+
exports.MAX_CONFIDENCE_INTERVAL_RATIO = require_common.MAX_CONFIDENCE_INTERVAL_RATIO;
|
|
21643
|
+
exports.MAX_TX_SIZE = require_common.MAX_TX_SIZE;
|
|
21644
|
+
exports.MAX_U64 = require_common.MAX_U64;
|
|
21645
|
+
exports.MPL_METADATA_PROGRAM_ID = require_common.MPL_METADATA_PROGRAM_ID;
|
|
21646
|
+
exports.MetadataService = MetadataService;
|
|
21647
|
+
exports.MetaplexMetadataFetcher = MetaplexMetadataFetcher;
|
|
21648
|
+
exports.OperationalState = OperationalState;
|
|
21649
|
+
exports.OracleSetup = OracleSetup;
|
|
21650
|
+
exports.PDA_BANK_FEE_VAULT_AUTH_SEED = require_common.PDA_BANK_FEE_VAULT_AUTH_SEED;
|
|
21651
|
+
exports.PDA_BANK_FEE_VAULT_SEED = require_common.PDA_BANK_FEE_VAULT_SEED;
|
|
21652
|
+
exports.PDA_BANK_INSURANCE_VAULT_AUTH_SEED = require_common.PDA_BANK_INSURANCE_VAULT_AUTH_SEED;
|
|
21653
|
+
exports.PDA_BANK_INSURANCE_VAULT_SEED = require_common.PDA_BANK_INSURANCE_VAULT_SEED;
|
|
21654
|
+
exports.PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED = require_common.PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED;
|
|
21655
|
+
exports.PDA_BANK_LIQUIDITY_VAULT_SEED = require_common.PDA_BANK_LIQUIDITY_VAULT_SEED;
|
|
21656
|
+
exports.PRIORITY_TX_SIZE = require_common.PRIORITY_TX_SIZE;
|
|
21657
|
+
exports.PROGRAM_ID = require_common.PROGRAM_ID;
|
|
21658
|
+
exports.PYTH_PRICE_CONF_INTERVALS = require_common.PYTH_PRICE_CONF_INTERVALS;
|
|
21659
|
+
exports.PYTH_PUSH_ORACLE_ID = require_common.PYTH_PUSH_ORACLE_ID;
|
|
21660
|
+
exports.PYTH_SPONSORED_SHARD_ID = PYTH_SPONSORED_SHARD_ID;
|
|
21661
|
+
exports.PriceBias = PriceBias;
|
|
21662
|
+
exports.ProcessTransactionError = ProcessTransactionError;
|
|
21663
|
+
exports.ProcessTransactionErrorType = ProcessTransactionErrorType;
|
|
21664
|
+
exports.RiskTier = RiskTier;
|
|
21665
|
+
exports.SINGLE_POOL_PROGRAM_ID = require_common.SINGLE_POOL_PROGRAM_ID;
|
|
21666
|
+
exports.SKIP_SIMULATION = require_common.SKIP_SIMULATION;
|
|
21667
|
+
exports.STAKE_CONFIG_ID = require_common.STAKE_CONFIG_ID;
|
|
21668
|
+
exports.STAKE_PROGRAM_ID = require_common.STAKE_PROGRAM_ID;
|
|
21669
|
+
exports.SWB_PRICE_CONF_INTERVALS = require_common.SWB_PRICE_CONF_INTERVALS;
|
|
21670
|
+
exports.SYSTEM_PROGRAM_ID = require_common.SYSTEM_PROGRAM_ID;
|
|
21671
|
+
exports.SYSVAR_CLOCK_ID = require_common.SYSVAR_CLOCK_ID;
|
|
21672
|
+
exports.SYSVAR_RENT_ID = require_common.SYSVAR_RENT_ID;
|
|
21673
|
+
exports.SYSVAR_STAKE_HISTORY_ID = require_common.SYSVAR_STAKE_HISTORY_ID;
|
|
21674
|
+
exports.TRANSFER_ACCOUNT_AUTHORITY_FLAG = require_common.TRANSFER_ACCOUNT_AUTHORITY_FLAG;
|
|
21675
|
+
exports.USDC_DECIMALS = require_common.USDC_DECIMALS;
|
|
21676
|
+
exports.USDC_MINT = require_common.USDC_MINT;
|
|
21677
|
+
exports.WSOL_EXTENDED_METADATA = require_common.WSOL_EXTENDED_METADATA;
|
|
21678
|
+
exports.WSOL_MINT = require_common.WSOL_MINT;
|
|
21679
|
+
exports.accountFlagToBN = accountFlagToBN;
|
|
21680
|
+
exports.addOracleToBanksIx = addOracleToBanksIx;
|
|
21681
|
+
exports.balanceToDto = balanceToDto;
|
|
21682
|
+
exports.bankConfigRawToDto = bankConfigRawToDto;
|
|
21683
|
+
exports.bankRawToDto = bankRawToDto;
|
|
21684
|
+
exports.buildFeedIdMap = buildFeedIdMap;
|
|
21685
|
+
exports.computeAccountValue = computeAccountValue;
|
|
21686
|
+
exports.computeActiveEmodePairs = computeActiveEmodePairs;
|
|
21687
|
+
exports.computeAssetUsdValue = computeAssetUsdValue;
|
|
21688
|
+
exports.computeBalanceUsdValue = computeBalanceUsdValue;
|
|
21689
|
+
exports.computeBaseInterestRate = computeBaseInterestRate;
|
|
21690
|
+
exports.computeClaimedEmissions = computeClaimedEmissions;
|
|
21691
|
+
exports.computeEmodeImpacts = computeEmodeImpacts;
|
|
21692
|
+
exports.computeFreeCollateral = computeFreeCollateral;
|
|
21693
|
+
exports.computeFreeCollateralLegacy = computeFreeCollateralLegacy;
|
|
21694
|
+
exports.computeHealthAccountMetas = computeHealthAccountMetas;
|
|
21695
|
+
exports.computeHealthCheckAccounts = computeHealthCheckAccounts;
|
|
21696
|
+
exports.computeHealthComponents = computeHealthComponents;
|
|
21697
|
+
exports.computeHealthComponentsLegacy = computeHealthComponentsLegacy;
|
|
21698
|
+
exports.computeHealthComponentsWithoutBiasLegacy = computeHealthComponentsWithoutBiasLegacy;
|
|
21699
|
+
exports.computeInterestRates = computeInterestRates;
|
|
21700
|
+
exports.computeLiabilityUsdValue = computeLiabilityUsdValue;
|
|
21701
|
+
exports.computeLoopingParams = computeLoopingParams;
|
|
21702
|
+
exports.computeMaxLeverage = computeMaxLeverage;
|
|
21703
|
+
exports.computeNetApy = computeNetApy;
|
|
21704
|
+
exports.computeQuantity = computeQuantity;
|
|
21705
|
+
exports.computeQuantityUi = computeQuantityUi;
|
|
21706
|
+
exports.computeRemainingCapacity = computeRemainingCapacity;
|
|
21707
|
+
exports.computeTotalOutstandingEmissions = computeTotalOutstandingEmissions;
|
|
21708
|
+
exports.computeTvl = computeTvl;
|
|
21709
|
+
exports.computeUsdValue = computeUsdValue;
|
|
21710
|
+
exports.computeUtilizationRate = computeUtilizationRate;
|
|
21711
|
+
exports.confirmTransaction = confirmTransaction;
|
|
21712
|
+
exports.crankPythOracleIx = crankPythOracleIx;
|
|
21713
|
+
exports.createLendrAccountTx = createLendrAccountTx;
|
|
21714
|
+
exports.createUpdateFeedIx = createUpdateFeedIx;
|
|
21715
|
+
exports.decodeAccountRaw = decodeAccountRaw;
|
|
21716
|
+
exports.decodeBankRaw = decodeBankRaw;
|
|
21717
|
+
exports.dtoToBalance = dtoToBalance;
|
|
21718
|
+
exports.dtoToBank = dtoToBank;
|
|
21719
|
+
exports.dtoToBankConfig = dtoToBankConfig;
|
|
21720
|
+
exports.dtoToBankConfigRaw = dtoToBankConfigRaw;
|
|
21721
|
+
exports.dtoToBankRaw = dtoToBankRaw;
|
|
21722
|
+
exports.dtoToEmodeSettings = dtoToEmodeSettings;
|
|
21723
|
+
exports.dtoToEmodeSettingsRaw = dtoToEmodeSettingsRaw;
|
|
21724
|
+
exports.dtoToGroup = dtoToGroup;
|
|
21725
|
+
exports.dtoToHealthCache = dtoToHealthCache;
|
|
21726
|
+
exports.dtoToInterestRateConfig = dtoToInterestRateConfig;
|
|
21727
|
+
exports.dtoToLendrAccount = dtoToLendrAccount;
|
|
21728
|
+
exports.dtoToOraclePrice = dtoToOraclePrice;
|
|
21729
|
+
exports.dtoToValidatorStakeGroup = dtoToValidatorStakeGroup;
|
|
21730
|
+
exports.emodeSettingsRawToDto = emodeSettingsRawToDto;
|
|
21731
|
+
exports.feedIdToString = feedIdToString;
|
|
21732
|
+
exports.fetchLendrAccountAddresses = fetchLendrAccountAddresses;
|
|
21733
|
+
exports.fetchLendrAccountData = fetchLendrAccountData;
|
|
21734
|
+
exports.fetchMultipleBanks = fetchMultipleBanks;
|
|
21735
|
+
exports.fetchNativeStakeAccounts = fetchNativeStakeAccounts;
|
|
21736
|
+
exports.fetchOracleData = fetchOracleData;
|
|
21737
|
+
exports.fetchPythOracleData = fetchPythOracleData;
|
|
21738
|
+
exports.fetchStakeAccount = fetchStakeAccount;
|
|
21739
|
+
exports.fetchStakePoolActiveStates = fetchStakePoolActiveStates;
|
|
21740
|
+
exports.fetchStakePoolMev = fetchStakePoolMev;
|
|
21741
|
+
exports.fetchSwbOracleData = fetchSwbOracleData;
|
|
21742
|
+
exports.findOracleKey = findOracleKey;
|
|
21743
|
+
exports.findPythPushOracleAddress = findPythPushOracleAddress;
|
|
21744
|
+
exports.freezeBankConfigIx = freezeBankConfigIx;
|
|
21745
|
+
exports.getActiveAccountFlags = getActiveAccountFlags;
|
|
21746
|
+
exports.getActiveEmodeEntryFlags = getActiveEmodeEntryFlags;
|
|
21747
|
+
exports.getActiveEmodeFlags = getActiveEmodeFlags;
|
|
21748
|
+
exports.getActiveHealthCacheFlags = getActiveHealthCacheFlags;
|
|
21749
|
+
exports.getActiveStaleBanks = getActiveStaleBanks;
|
|
21750
|
+
exports.getAssetQuantity = getAssetQuantity;
|
|
21751
|
+
exports.getAssetShares = getAssetShares;
|
|
21752
|
+
exports.getAssetWeight = getAssetWeight;
|
|
21753
|
+
exports.getBalanceUsdValueWithPriceBias = getBalanceUsdValueWithPriceBias;
|
|
21754
|
+
exports.getBankVaultAuthority = getBankVaultAuthority;
|
|
21755
|
+
exports.getBankVaultSeeds = getBankVaultSeeds;
|
|
21756
|
+
exports.getConfig = getConfig;
|
|
21757
|
+
exports.getConfigPda = getConfigPda;
|
|
21758
|
+
exports.getHealthCacheStatusDescription = getHealthCacheStatusDescription;
|
|
21759
|
+
exports.getLiabilityQuantity = getLiabilityQuantity;
|
|
21760
|
+
exports.getLiabilityShares = getLiabilityShares;
|
|
21761
|
+
exports.getLiabilityWeight = getLiabilityWeight;
|
|
21762
|
+
exports.getPrice = getPrice;
|
|
21763
|
+
exports.getPriceFeedAccountForProgram = getPriceFeedAccountForProgram;
|
|
21764
|
+
exports.getPriceWithConfidence = getPriceWithConfidence;
|
|
21765
|
+
exports.getTotalAssetQuantity = getTotalAssetQuantity;
|
|
21766
|
+
exports.getTotalLiabilityQuantity = getTotalLiabilityQuantity;
|
|
21767
|
+
exports.getTreasuryPda = getTreasuryPda;
|
|
21768
|
+
exports.groupToDto = groupToDto;
|
|
21769
|
+
exports.hasAccountFlag = hasAccountFlag;
|
|
21770
|
+
exports.hasEmodeEntryFlag = hasEmodeEntryFlag;
|
|
21771
|
+
exports.hasEmodeFlag = hasEmodeFlag;
|
|
21772
|
+
exports.hasHealthCacheFlag = hasHealthCacheFlag;
|
|
21773
|
+
exports.healthCacheToDto = healthCacheToDto;
|
|
21774
|
+
exports.instructions = instructions_default;
|
|
21775
|
+
exports.isOracleSetupSupported = isOracleSetupSupported;
|
|
21776
|
+
exports.isWeightedPrice = isWeightedPrice;
|
|
21777
|
+
exports.lendrAccountToDto = lendrAccountToDto;
|
|
21778
|
+
exports.makeAddPermissionlessStakedBankIx = makeAddPermissionlessStakedBankIx;
|
|
21779
|
+
exports.makeBundleTipIx = makeBundleTipIx;
|
|
21780
|
+
exports.makeDisableAccountTransferForAccountIx = makeDisableAccountTransferForAccountIx;
|
|
21781
|
+
exports.makeDisableFlashLoanForAccountIx = makeDisableFlashLoanForAccountIx;
|
|
21782
|
+
exports.makeEnableAccountTransferForAccountIx = makeEnableAccountTransferForAccountIx;
|
|
21783
|
+
exports.makeEnableFlashLoanForAccountIx = makeEnableFlashLoanForAccountIx;
|
|
21784
|
+
exports.makePoolAddBankIx = makePoolAddBankIx;
|
|
21785
|
+
exports.makePoolConfigureBankIx = makePoolConfigureBankIx;
|
|
21786
|
+
exports.makePriorityFeeIx = makePriorityFeeIx;
|
|
21787
|
+
exports.makePriorityFeeMicroIx = makePriorityFeeMicroIx;
|
|
21788
|
+
exports.makePulseHealthIx = makePulseHealthIx;
|
|
21789
|
+
exports.makeTxPriorityIx = makeTxPriorityIx;
|
|
21790
|
+
exports.makeUnwrapSolIx = makeUnwrapSolIx;
|
|
21791
|
+
exports.makeVersionedTransaction = makeVersionedTransaction;
|
|
21792
|
+
exports.makeWrapSolIxs = makeWrapSolIxs;
|
|
21793
|
+
exports.metadataSchema = metadataSchema;
|
|
21794
|
+
exports.oraclePriceToDto = oraclePriceToDto;
|
|
21795
|
+
exports.parseBalanceRaw = parseBalanceRaw;
|
|
21796
|
+
exports.parseBankConfigRaw = parseBankConfigRaw;
|
|
21797
|
+
exports.parseBankRaw = parseBankRaw;
|
|
21798
|
+
exports.parseEmodeTag = parseEmodeTag;
|
|
21799
|
+
exports.parseErrorFromLogs = parseErrorFromLogs;
|
|
21800
|
+
exports.parseLendrAccountRaw = parseLendrAccountRaw;
|
|
21801
|
+
exports.parseOperationalState = parseOperationalState;
|
|
21802
|
+
exports.parseOracleSetup = parseOracleSetup;
|
|
21803
|
+
exports.parsePriceInfo = parseOraclePriceData;
|
|
21804
|
+
exports.parseRiskTier = parseRiskTier;
|
|
21805
|
+
exports.parseTransactionError = parseTransactionError;
|
|
21806
|
+
exports.processTransactions = processTransactions;
|
|
21807
|
+
exports.serializeBankConfigOpt = serializeBankConfigOpt;
|
|
21808
|
+
exports.serializeOperationalState = serializeOperationalState;
|
|
21809
|
+
exports.serializeOracleSetup = serializeOracleSetup;
|
|
21810
|
+
exports.serializeOracleSetupToIndex = serializeOracleSetupToIndex;
|
|
21811
|
+
exports.serializeRiskTier = serializeRiskTier;
|
|
21812
|
+
exports.simulateAccountHealthCache = simulateAccountHealthCache;
|
|
21813
|
+
exports.simulateAccountHealthCacheWithFallback = simulateAccountHealthCacheWithFallback;
|
|
21814
|
+
exports.simulateTransactions = simulateTransactions;
|
|
21815
|
+
exports.supportedOracleSetups = supportedOracleSetups;
|
|
21816
|
+
exports.toBankConfigDto = toBankConfigDto;
|
|
21817
|
+
exports.toBankDto = toBankDto;
|
|
21818
|
+
exports.toEmodeSettingsDto = toEmodeSettingsDto;
|
|
21819
|
+
exports.toInterestRateConfigDto = toInterestRateConfigDto;
|
|
21820
|
+
exports.validatorStakeGroupToDto = validatorStakeGroupToDto;
|
|
21821
|
+
Object.defineProperty(exports, 'vendor', {
|
|
21822
|
+
enumerable: true,
|
|
21823
|
+
get: function () {
|
|
21824
|
+
return vendor_exports;
|
|
21825
|
+
}
|
|
21826
|
+
});
|