@pyron-finance/pyron-client 1.0.6 → 1.0.8
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-70fo5HbS.cjs} +3 -2
- package/dist/{common-BtUtEjzZ.mjs → common-DSb1joUt.js} +5 -4
- package/dist/common-DSb1joUt.js.map +1 -0
- package/dist/{index-Bx-zRXFQ.d.ts → index-AiXygYKy.d.ts} +66 -68
- package/dist/index-AiXygYKy.d.ts.map +1 -0
- package/dist/{index-BAC0ffmc.d.mts → index-CMK6wLry.d.cts} +57 -55
- package/dist/index-CMK6wLry.d.cts.map +1 -0
- package/dist/{index.mjs → index.cjs} +947 -727
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +727 -946
- 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,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import * as borsh from "@coral-xyz/borsh";
|
|
14
|
-
import Big from "big.js";
|
|
1
|
+
const require_common = require('./common-70fo5HbS.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 borsh = require_common.__toESM(require("borsh"));
|
|
11
|
+
const __coral_xyz_borsh = require_common.__toESM(require("@coral-xyz/borsh"));
|
|
12
|
+
const big_js = require_common.__toESM(require("big.js"));
|
|
15
13
|
|
|
16
14
|
//#region src/logger.ts
|
|
17
15
|
var NoopLogger = class {
|
|
@@ -54,17 +52,17 @@ var DataFetcher = class {
|
|
|
54
52
|
|
|
55
53
|
//#endregion
|
|
56
54
|
//#region src/services/metadata/index.ts
|
|
57
|
-
const metadataSchema = z.object({
|
|
58
|
-
name: z.string(),
|
|
59
|
-
symbol: z.string(),
|
|
60
|
-
image: z.string()
|
|
55
|
+
const metadataSchema = zod_v4_mini.z.object({
|
|
56
|
+
name: zod_v4_mini.z.string(),
|
|
57
|
+
symbol: zod_v4_mini.z.string(),
|
|
58
|
+
image: zod_v4_mini.z.string()
|
|
61
59
|
});
|
|
62
60
|
var IMetadataService = class {
|
|
63
61
|
/** NOTE: record key is base58 of mint public key */
|
|
64
62
|
overrides;
|
|
65
63
|
_storage;
|
|
66
64
|
constructor(storage, overrides = {}) {
|
|
67
|
-
this._storage = prefixStorage(storage, "banks:metadata");
|
|
65
|
+
this._storage = (0, unstorage.prefixStorage)(storage, "banks:metadata");
|
|
68
66
|
this.overrides = overrides;
|
|
69
67
|
}
|
|
70
68
|
async forMints(mints) {
|
|
@@ -116,7 +114,7 @@ var IMetadataService = class {
|
|
|
116
114
|
|
|
117
115
|
//#endregion
|
|
118
116
|
//#region src/services/metadata/fogo.ts
|
|
119
|
-
const endpointSchema = z.record(z.string(), metadataSchema);
|
|
117
|
+
const endpointSchema = zod_v4_mini.z.record(zod_v4_mini.z.string(), metadataSchema);
|
|
120
118
|
var FogoMetadataService = class extends IMetadataService {
|
|
121
119
|
async _fetch(mints) {
|
|
122
120
|
if (mints.length === 0) {
|
|
@@ -136,9 +134,9 @@ var FogoMetadataService = class extends IMetadataService {
|
|
|
136
134
|
function getConfig({ environment = "production", overrides } = {}) {
|
|
137
135
|
return {
|
|
138
136
|
environment,
|
|
139
|
-
cluster: overrides?.cluster ?? DEFAULT_CLUSTER,
|
|
140
|
-
programId: overrides?.programId ?? PROGRAM_ID,
|
|
141
|
-
groupPk: overrides?.groupPk ?? GROUP_PK
|
|
137
|
+
cluster: overrides?.cluster ?? require_common.DEFAULT_CLUSTER,
|
|
138
|
+
programId: overrides?.programId ?? require_common.PROGRAM_ID,
|
|
139
|
+
groupPk: overrides?.groupPk ?? require_common.GROUP_PK
|
|
142
140
|
};
|
|
143
141
|
}
|
|
144
142
|
|
|
@@ -6168,7 +6166,7 @@ function parseCustomProgramError(logs, ldrProgramId) {
|
|
|
6168
6166
|
};
|
|
6169
6167
|
}
|
|
6170
6168
|
}
|
|
6171
|
-
errorMsg = LangErrorMessage.get(error.code);
|
|
6169
|
+
errorMsg = __coral_xyz_anchor.LangErrorMessage.get(error.code);
|
|
6172
6170
|
if (errorMsg !== undefined) {
|
|
6173
6171
|
return {
|
|
6174
6172
|
code: error.code,
|
|
@@ -6278,7 +6276,7 @@ const JupiterErrorCodeMap = new Map([
|
|
|
6278
6276
|
[JupiterErrorCode.ExactOutAmountNotMatched, "Exact out amount doesn't match"],
|
|
6279
6277
|
[JupiterErrorCode.SourceAndDestinationMintCannotBeTheSame, "Source mint and destination mint cannot the same"]
|
|
6280
6278
|
]);
|
|
6281
|
-
const ERROR_CODE_MAPS = new Map([[TOKEN_PROGRAM_ID.toBase58(), TokenErrorCodeMap], [JUPITER_V6_PROGRAM.toBase58(), JupiterErrorCodeMap]]);
|
|
6279
|
+
const ERROR_CODE_MAPS = new Map([[__solana_spl_token.TOKEN_PROGRAM_ID.toBase58(), TokenErrorCodeMap], [require_common.JUPITER_V6_PROGRAM.toBase58(), JupiterErrorCodeMap]]);
|
|
6282
6280
|
|
|
6283
6281
|
//#endregion
|
|
6284
6282
|
//#region src/idl/idl.utils.ts
|
|
@@ -6452,8 +6450,8 @@ async function makeLendingPoolConfigureBankOracleIx(ldProgram, accounts$2, args,
|
|
|
6452
6450
|
* @param args - Optional arguments for this instruction
|
|
6453
6451
|
*/
|
|
6454
6452
|
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
|
|
6453
|
+
const { stakedSettings, feePayer, bankMint, solPool, stakePool, tokenProgram = __solana_spl_token.TOKEN_PROGRAM_ID,...optionalAccounts } = accounts$2;
|
|
6454
|
+
return ldProgram.methods.lendingPoolAddBankPermissionless(args.seed ?? new bn_js.default(0)).accounts({
|
|
6457
6455
|
stakedSettings,
|
|
6458
6456
|
feePayer,
|
|
6459
6457
|
bankMint,
|
|
@@ -6627,13 +6625,13 @@ var HealthCache = class HealthCache {
|
|
|
6627
6625
|
this.simulationFailed = simulationFailed;
|
|
6628
6626
|
}
|
|
6629
6627
|
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);
|
|
6628
|
+
const assetValue = require_common.wrappedI80F48toBigNumber(healthCacheRaw.assetValue);
|
|
6629
|
+
const liabilityValue = require_common.wrappedI80F48toBigNumber(healthCacheRaw.liabilityValue);
|
|
6630
|
+
const assetValueMaint = require_common.wrappedI80F48toBigNumber(healthCacheRaw.assetValueMaint);
|
|
6631
|
+
const liabilityValueMaint = require_common.wrappedI80F48toBigNumber(healthCacheRaw.liabilityValueMaint);
|
|
6632
|
+
const assetValueEquity = require_common.wrappedI80F48toBigNumber(healthCacheRaw.assetValueEquity);
|
|
6633
|
+
const liabilityValueEquity = require_common.wrappedI80F48toBigNumber(healthCacheRaw.liabilityValueEquity);
|
|
6634
|
+
const timestamp = require_common.toBigNumber(healthCacheRaw.timestamp);
|
|
6637
6635
|
const flags = getActiveHealthCacheFlags(healthCacheRaw.flags);
|
|
6638
6636
|
const prices = healthCacheRaw.prices;
|
|
6639
6637
|
return new HealthCache(assetValue, liabilityValue, assetValueMaint, liabilityValueMaint, assetValueEquity, liabilityValueEquity, timestamp, flags, prices);
|
|
@@ -8961,9 +8959,9 @@ const PYTH_SOLANA_RECEIVER_PROGRAM_IDL = {
|
|
|
8961
8959
|
|
|
8962
8960
|
//#endregion
|
|
8963
8961
|
//#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");
|
|
8962
|
+
const DEFAULT_RECEIVER_PROGRAM_ID = new __solana_web3_js.PublicKey("rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ");
|
|
8963
|
+
const DEFAULT_WORMHOLE_PROGRAM_ID = new __solana_web3_js.PublicKey("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ");
|
|
8964
|
+
const DEFAULT_PUSH_ORACLE_PROGRAM_ID = new __solana_web3_js.PublicKey("pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT");
|
|
8967
8965
|
const ACCUMULATOR_MAGIC = "504e4155";
|
|
8968
8966
|
const MAJOR_VERSION = 1;
|
|
8969
8967
|
const MINOR_VERSION = 0;
|
|
@@ -9077,7 +9075,7 @@ async function buildPostEncodedVaaInstructions(wormhole, vaa) {
|
|
|
9077
9075
|
};
|
|
9078
9076
|
}
|
|
9079
9077
|
async function generateVaaInstructionGroups(wormhole, vaa) {
|
|
9080
|
-
const encodedVaaKeypair = new Keypair();
|
|
9078
|
+
const encodedVaaKeypair = new __solana_web3_js.Keypair();
|
|
9081
9079
|
const initInstructions = [await buildEncodedVaaCreateInstruction(wormhole, vaa, encodedVaaKeypair), {
|
|
9082
9080
|
instruction: await wormhole.methods.initEncodedVaa().accounts({ encodedVaa: encodedVaaKeypair.publicKey }).instruction(),
|
|
9083
9081
|
signers: [],
|
|
@@ -9137,7 +9135,7 @@ async function buildEncodedVaaCreateInstruction(wormhole, vaa, encodedVaaKeypair
|
|
|
9137
9135
|
const getGuardianSetPda = (guardianSetIndex, wormholeProgramId) => {
|
|
9138
9136
|
const guardianSetIndexBuf = Buffer.alloc(4);
|
|
9139
9137
|
guardianSetIndexBuf.writeUInt32BE(guardianSetIndex, 0);
|
|
9140
|
-
return PublicKey.findProgramAddressSync([Buffer.from("GuardianSet"), guardianSetIndexBuf], wormholeProgramId)[0];
|
|
9138
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("GuardianSet"), guardianSetIndexBuf], wormholeProgramId)[0];
|
|
9141
9139
|
};
|
|
9142
9140
|
function parsePriceFeedMessage(message) {
|
|
9143
9141
|
let cursor = 0;
|
|
@@ -9148,19 +9146,19 @@ function parsePriceFeedMessage(message) {
|
|
|
9148
9146
|
cursor += 1;
|
|
9149
9147
|
const feedId = message.subarray(cursor, cursor + 32);
|
|
9150
9148
|
cursor += 32;
|
|
9151
|
-
const price = new
|
|
9149
|
+
const price = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9152
9150
|
cursor += 8;
|
|
9153
|
-
const confidence = new
|
|
9151
|
+
const confidence = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9154
9152
|
cursor += 8;
|
|
9155
9153
|
const exponent = message.readInt32BE(cursor);
|
|
9156
9154
|
cursor += 4;
|
|
9157
|
-
const publishTime = new
|
|
9155
|
+
const publishTime = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9158
9156
|
cursor += 8;
|
|
9159
|
-
const prevPublishTime = new
|
|
9157
|
+
const prevPublishTime = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9160
9158
|
cursor += 8;
|
|
9161
|
-
const emaPrice = new
|
|
9159
|
+
const emaPrice = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9162
9160
|
cursor += 8;
|
|
9163
|
-
const emaConf = new
|
|
9161
|
+
const emaConf = new bn_js.default(message.subarray(cursor, cursor + 8), "be");
|
|
9164
9162
|
cursor += 8;
|
|
9165
9163
|
return {
|
|
9166
9164
|
feedId,
|
|
@@ -9222,7 +9220,7 @@ function readBigUInt64LE(buffer, offset = 0) {
|
|
|
9222
9220
|
/** Number of slots that can pass before a publisher's price is no longer included in the aggregate. */
|
|
9223
9221
|
const MAX_SLOT_DIFFERENCE = 25;
|
|
9224
9222
|
const empty32Buffer = Buffer.alloc(32);
|
|
9225
|
-
const PKorNull = (data) => data.equals(empty32Buffer) ? null : new PublicKey(data);
|
|
9223
|
+
const PKorNull = (data) => data.equals(empty32Buffer) ? null : new __solana_web3_js.PublicKey(data);
|
|
9226
9224
|
let PriceStatus = /* @__PURE__ */ function(PriceStatus$1) {
|
|
9227
9225
|
PriceStatus$1[PriceStatus$1["Unknown"] = 0] = "Unknown";
|
|
9228
9226
|
PriceStatus$1[PriceStatus$1["Trading"] = 1] = "Trading";
|
|
@@ -9285,7 +9283,7 @@ const parsePriceData = (data, currentSlot) => {
|
|
|
9285
9283
|
const drv2 = data.readInt8(105);
|
|
9286
9284
|
const drv3 = data.readInt16LE(106);
|
|
9287
9285
|
const drv4 = data.readInt32LE(108);
|
|
9288
|
-
const productAccountKey = new PublicKey(data.slice(112, 144));
|
|
9286
|
+
const productAccountKey = new __solana_web3_js.PublicKey(data.slice(112, 144));
|
|
9289
9287
|
const nextPriceAccountKey = PKorNull(data.slice(144, 176));
|
|
9290
9288
|
const previousSlot = readBigUInt64LE(data, 176);
|
|
9291
9289
|
const previousPriceComponent = readBigInt64LE(data, 184);
|
|
@@ -9309,7 +9307,7 @@ const parsePriceData = (data, currentSlot) => {
|
|
|
9309
9307
|
const priceComponents = [];
|
|
9310
9308
|
let offset = 240;
|
|
9311
9309
|
while (priceComponents.length < numComponentPrices) {
|
|
9312
|
-
const publisher = new PublicKey(data.slice(offset, offset + 32));
|
|
9310
|
+
const publisher = new __solana_web3_js.PublicKey(data.slice(offset, offset + 32));
|
|
9313
9311
|
offset += 32;
|
|
9314
9312
|
const componentAggregate = parsePriceInfo$1(data.slice(offset, offset + 32), exponent);
|
|
9315
9313
|
offset += 32;
|
|
@@ -9391,12 +9389,12 @@ const priceUpdateV2Schema = { struct: {
|
|
|
9391
9389
|
postedSlot: "u64"
|
|
9392
9390
|
} };
|
|
9393
9391
|
const parsePriceInfo = (data) => {
|
|
9394
|
-
const decoded = borsh
|
|
9392
|
+
const decoded = borsh.deserialize(priceUpdateV2Schema, data);
|
|
9395
9393
|
return decoded;
|
|
9396
9394
|
};
|
|
9397
9395
|
function capConfidenceInterval$1(price, confidence, maxConfidence) {
|
|
9398
9396
|
const maxConfidenceInterval = price.times(maxConfidence);
|
|
9399
|
-
return
|
|
9397
|
+
return bignumber_js.default.min(confidence, maxConfidenceInterval);
|
|
9400
9398
|
}
|
|
9401
9399
|
|
|
9402
9400
|
//#endregion
|
|
@@ -9411,7 +9409,7 @@ var Account = class {
|
|
|
9411
9409
|
*/
|
|
9412
9410
|
constructor(program, publicKey) {
|
|
9413
9411
|
this.program = program;
|
|
9414
|
-
this.publicKey = typeof publicKey === "string" ? new
|
|
9412
|
+
this.publicKey = typeof publicKey === "string" ? new __coral_xyz_anchor.web3.PublicKey(publicKey) : publicKey;
|
|
9415
9413
|
}
|
|
9416
9414
|
};
|
|
9417
9415
|
const BUFFER_DISCRIMINATOR = Buffer.from([
|
|
@@ -9486,7 +9484,7 @@ function fromJSON(obj) {
|
|
|
9486
9484
|
}
|
|
9487
9485
|
}
|
|
9488
9486
|
function layout(property) {
|
|
9489
|
-
const ret =
|
|
9487
|
+
const ret = __coral_xyz_borsh.rustEnum([__coral_xyz_borsh.struct([], "ModeRoundResolution"), __coral_xyz_borsh.struct([], "ModeSlidingResolution")]);
|
|
9490
9488
|
if (property !== undefined) {
|
|
9491
9489
|
return ret.replicate(property);
|
|
9492
9490
|
}
|
|
@@ -9508,7 +9506,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9508
9506
|
this.scale = fields.scale;
|
|
9509
9507
|
}
|
|
9510
9508
|
static layout(property) {
|
|
9511
|
-
return
|
|
9509
|
+
return __coral_xyz_borsh.struct([__coral_xyz_borsh.i128("mantissa"), __coral_xyz_borsh.u32("scale")], property);
|
|
9512
9510
|
}
|
|
9513
9511
|
static fromDecoded(obj) {
|
|
9514
9512
|
return new SwitchboardDecimal({
|
|
@@ -9530,7 +9528,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9530
9528
|
}
|
|
9531
9529
|
static fromJSON(obj) {
|
|
9532
9530
|
return new SwitchboardDecimal({
|
|
9533
|
-
mantissa: new
|
|
9531
|
+
mantissa: new bn_js.default(obj.mantissa),
|
|
9534
9532
|
scale: obj.scale
|
|
9535
9533
|
});
|
|
9536
9534
|
}
|
|
@@ -9541,7 +9539,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9541
9539
|
*/
|
|
9542
9540
|
static from(obj) {
|
|
9543
9541
|
return new SwitchboardDecimal({
|
|
9544
|
-
mantissa: new
|
|
9542
|
+
mantissa: new bn_js.default(obj.mantissa),
|
|
9545
9543
|
scale: obj.scale
|
|
9546
9544
|
});
|
|
9547
9545
|
}
|
|
@@ -9552,10 +9550,10 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9552
9550
|
*/
|
|
9553
9551
|
static fromBig(big) {
|
|
9554
9552
|
big = big.round(20);
|
|
9555
|
-
let mantissa = new
|
|
9553
|
+
let mantissa = new bn_js.default(big.c.join(""), 10);
|
|
9556
9554
|
let scale = big.c.slice(1).length - big.e;
|
|
9557
9555
|
if (scale < 0) {
|
|
9558
|
-
mantissa = mantissa.mul(new
|
|
9556
|
+
mantissa = mantissa.mul(new bn_js.default(10, 10).pow(new bn_js.default(Math.abs(scale), 10)));
|
|
9559
9557
|
scale = 0;
|
|
9560
9558
|
}
|
|
9561
9559
|
if (scale < 0) {
|
|
@@ -9564,7 +9562,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9564
9562
|
if (scale >= 28) {
|
|
9565
9563
|
throw new Error("SwitchboardDecimalExcessiveScaleError");
|
|
9566
9564
|
}
|
|
9567
|
-
mantissa = mantissa.mul(new
|
|
9565
|
+
mantissa = mantissa.mul(new bn_js.default(big.s, 10));
|
|
9568
9566
|
const result = new SwitchboardDecimal({
|
|
9569
9567
|
mantissa,
|
|
9570
9568
|
scale
|
|
@@ -9584,11 +9582,11 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9584
9582
|
* @return Big representation
|
|
9585
9583
|
*/
|
|
9586
9584
|
toBig() {
|
|
9587
|
-
let mantissa = new
|
|
9585
|
+
let mantissa = new bn_js.default(this.mantissa, 10);
|
|
9588
9586
|
let s = 1;
|
|
9589
9587
|
const c = [];
|
|
9590
|
-
const ZERO = new
|
|
9591
|
-
const TEN = new
|
|
9588
|
+
const ZERO = new bn_js.default(0, 10);
|
|
9589
|
+
const TEN = new bn_js.default(10, 10);
|
|
9592
9590
|
if (mantissa.lt(ZERO)) {
|
|
9593
9591
|
s = -1;
|
|
9594
9592
|
mantissa = mantissa.abs();
|
|
@@ -9598,7 +9596,7 @@ var SwitchboardDecimal = class SwitchboardDecimal {
|
|
|
9598
9596
|
mantissa = mantissa.div(TEN);
|
|
9599
9597
|
}
|
|
9600
9598
|
const e = c.length - this.scale - 1;
|
|
9601
|
-
const result = new
|
|
9599
|
+
const result = new big_js.default(0);
|
|
9602
9600
|
if (c.length === 0) {
|
|
9603
9601
|
return result;
|
|
9604
9602
|
}
|
|
@@ -9660,21 +9658,21 @@ var AggregatorRound = class AggregatorRound {
|
|
|
9660
9658
|
this.errorsFulfilled = fields.errorsFulfilled;
|
|
9661
9659
|
}
|
|
9662
9660
|
static layout(property) {
|
|
9663
|
-
return
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9661
|
+
return __coral_xyz_borsh.struct([
|
|
9662
|
+
__coral_xyz_borsh.u32("numSuccess"),
|
|
9663
|
+
__coral_xyz_borsh.u32("numError"),
|
|
9664
|
+
__coral_xyz_borsh.bool("isClosed"),
|
|
9665
|
+
__coral_xyz_borsh.u64("roundOpenSlot"),
|
|
9666
|
+
__coral_xyz_borsh.i64("roundOpenTimestamp"),
|
|
9669
9667
|
SwitchboardDecimal.layout("result"),
|
|
9670
9668
|
SwitchboardDecimal.layout("stdDeviation"),
|
|
9671
9669
|
SwitchboardDecimal.layout("minResponse"),
|
|
9672
9670
|
SwitchboardDecimal.layout("maxResponse"),
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9671
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.publicKey(), 16, "oraclePubkeysData"),
|
|
9672
|
+
__coral_xyz_borsh.array(SwitchboardDecimal.layout({}), 16, "mediansData"),
|
|
9673
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.i64(), 16, "currentPayout"),
|
|
9674
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.bool(), 16, "mediansFulfilled"),
|
|
9675
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.bool(), 16, "errorsFulfilled")
|
|
9678
9676
|
], property);
|
|
9679
9677
|
}
|
|
9680
9678
|
static fromDecoded(obj) {
|
|
@@ -9736,15 +9734,15 @@ var AggregatorRound = class AggregatorRound {
|
|
|
9736
9734
|
numSuccess: obj.numSuccess,
|
|
9737
9735
|
numError: obj.numError,
|
|
9738
9736
|
isClosed: obj.isClosed,
|
|
9739
|
-
roundOpenSlot: new
|
|
9740
|
-
roundOpenTimestamp: new
|
|
9737
|
+
roundOpenSlot: new bn_js.default(obj.roundOpenSlot),
|
|
9738
|
+
roundOpenTimestamp: new bn_js.default(obj.roundOpenTimestamp),
|
|
9741
9739
|
result: SwitchboardDecimal.fromJSON(obj.result),
|
|
9742
9740
|
stdDeviation: SwitchboardDecimal.fromJSON(obj.stdDeviation),
|
|
9743
9741
|
minResponse: SwitchboardDecimal.fromJSON(obj.minResponse),
|
|
9744
9742
|
maxResponse: SwitchboardDecimal.fromJSON(obj.maxResponse),
|
|
9745
|
-
oraclePubkeysData: obj.oraclePubkeysData.map((item) => new PublicKey(item)),
|
|
9743
|
+
oraclePubkeysData: obj.oraclePubkeysData.map((item) => new __solana_web3_js.PublicKey(item)),
|
|
9746
9744
|
mediansData: obj.mediansData.map((item) => SwitchboardDecimal.fromJSON(item)),
|
|
9747
|
-
currentPayout: obj.currentPayout.map((item) => new
|
|
9745
|
+
currentPayout: obj.currentPayout.map((item) => new bn_js.default(item)),
|
|
9748
9746
|
mediansFulfilled: obj.mediansFulfilled,
|
|
9749
9747
|
errorsFulfilled: obj.errorsFulfilled
|
|
9750
9748
|
});
|
|
@@ -9763,7 +9761,7 @@ var Hash = class Hash {
|
|
|
9763
9761
|
this.data = fields.data;
|
|
9764
9762
|
}
|
|
9765
9763
|
static layout(property) {
|
|
9766
|
-
return
|
|
9764
|
+
return __coral_xyz_borsh.struct([__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 32, "data")], property);
|
|
9767
9765
|
}
|
|
9768
9766
|
static fromDecoded(obj) {
|
|
9769
9767
|
return new Hash({ data: obj.data });
|
|
@@ -9867,42 +9865,42 @@ var AggregatorAccountData = class AggregatorAccountData {
|
|
|
9867
9865
|
27,
|
|
9868
9866
|
125
|
|
9869
9867
|
]);
|
|
9870
|
-
static layout =
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9868
|
+
static layout = __coral_xyz_borsh.struct([
|
|
9869
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 32, "name"),
|
|
9870
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 128, "metadata"),
|
|
9871
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 32, "reserved1"),
|
|
9872
|
+
__coral_xyz_borsh.publicKey("queuePubkey"),
|
|
9873
|
+
__coral_xyz_borsh.u32("oracleRequestBatchSize"),
|
|
9874
|
+
__coral_xyz_borsh.u32("minOracleResults"),
|
|
9875
|
+
__coral_xyz_borsh.u32("minJobResults"),
|
|
9876
|
+
__coral_xyz_borsh.u32("minUpdateDelaySeconds"),
|
|
9877
|
+
__coral_xyz_borsh.i64("startAfter"),
|
|
9880
9878
|
SwitchboardDecimal.layout("varianceThreshold"),
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9879
|
+
__coral_xyz_borsh.i64("forceReportPeriod"),
|
|
9880
|
+
__coral_xyz_borsh.i64("expiration"),
|
|
9881
|
+
__coral_xyz_borsh.u64("consecutiveFailureCount"),
|
|
9882
|
+
__coral_xyz_borsh.i64("nextAllowedUpdateTime"),
|
|
9883
|
+
__coral_xyz_borsh.bool("isLocked"),
|
|
9884
|
+
__coral_xyz_borsh.publicKey("crankPubkey"),
|
|
9887
9885
|
AggregatorRound.layout("latestConfirmedRound"),
|
|
9888
9886
|
AggregatorRound.layout("currentRound"),
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9887
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.publicKey(), 16, "jobPubkeysData"),
|
|
9888
|
+
__coral_xyz_borsh.array(Hash.layout({}), 16, "jobHashes"),
|
|
9889
|
+
__coral_xyz_borsh.u32("jobPubkeysSize"),
|
|
9890
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 32, "jobsChecksum"),
|
|
9891
|
+
__coral_xyz_borsh.publicKey("authority"),
|
|
9892
|
+
__coral_xyz_borsh.publicKey("historyBuffer"),
|
|
9895
9893
|
SwitchboardDecimal.layout("previousConfirmedRoundResult"),
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9894
|
+
__coral_xyz_borsh.u64("previousConfirmedRoundSlot"),
|
|
9895
|
+
__coral_xyz_borsh.bool("disableCrank"),
|
|
9896
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 16, "jobWeights"),
|
|
9897
|
+
__coral_xyz_borsh.i64("creationTimestamp"),
|
|
9900
9898
|
layout("resolutionMode"),
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9899
|
+
__coral_xyz_borsh.u32("basePriorityFee"),
|
|
9900
|
+
__coral_xyz_borsh.u32("priorityFeeBump"),
|
|
9901
|
+
__coral_xyz_borsh.u32("priorityFeeBumpPeriod"),
|
|
9902
|
+
__coral_xyz_borsh.u32("maxPriorityFeeMultiplier"),
|
|
9903
|
+
__coral_xyz_borsh.array(__coral_xyz_borsh.u8(), 122, "ebuf")
|
|
9906
9904
|
]);
|
|
9907
9905
|
constructor(fields) {
|
|
9908
9906
|
this.name = fields.name;
|
|
@@ -13652,9 +13650,9 @@ var idl_default = {
|
|
|
13652
13650
|
//#endregion
|
|
13653
13651
|
//#region src/vendor/switchboard_pull/index.ts
|
|
13654
13652
|
const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
|
|
13655
|
-
const switchboardAccountCoder = new BorshCoder(idl_default);
|
|
13653
|
+
const switchboardAccountCoder = new __coral_xyz_anchor.BorshCoder(idl_default);
|
|
13656
13654
|
function getSwitchboardProgram(provider) {
|
|
13657
|
-
return new Program(idl_default, provider);
|
|
13655
|
+
return new __coral_xyz_anchor.Program(idl_default, provider);
|
|
13658
13656
|
}
|
|
13659
13657
|
function decodeSwitchboardPullFeedData(data) {
|
|
13660
13658
|
const pullFeedDAta = switchboardAccountCoder.accounts.decode("PullFeedAccountData", data);
|
|
@@ -13676,7 +13674,7 @@ function getPrice(oraclePrice, priceBias = PriceBias.None, weightedPrice = false
|
|
|
13676
13674
|
}
|
|
13677
13675
|
function capConfidenceInterval(price, confidence, maxConfidence) {
|
|
13678
13676
|
const maxConfidenceInterval = price.times(maxConfidence);
|
|
13679
|
-
return
|
|
13677
|
+
return bignumber_js.default.min(confidence, maxConfidenceInterval);
|
|
13680
13678
|
}
|
|
13681
13679
|
function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), shardId) {
|
|
13682
13680
|
switch (oracleSetup) {
|
|
@@ -13690,14 +13688,14 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13690
13688
|
if (confidenceData === undefined) {
|
|
13691
13689
|
confidenceData = pythPriceData.previousConfidence;
|
|
13692
13690
|
}
|
|
13693
|
-
const pythPriceRealtime = new
|
|
13694
|
-
const pythConfidenceRealtime = new
|
|
13695
|
-
const pythConfidenceRealtimeCapped = capConfidenceInterval(pythPriceRealtime, pythConfidenceRealtime, PYTH_PRICE_CONF_INTERVALS);
|
|
13691
|
+
const pythPriceRealtime = new bignumber_js.default(priceData);
|
|
13692
|
+
const pythConfidenceRealtime = new bignumber_js.default(confidenceData).times(require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13693
|
+
const pythConfidenceRealtimeCapped = capConfidenceInterval(pythPriceRealtime, pythConfidenceRealtime, require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13696
13694
|
const pythLowestPriceRealtime = pythPriceRealtime.minus(pythConfidenceRealtimeCapped);
|
|
13697
13695
|
const pythHighestPriceRealtime = pythPriceRealtime.plus(pythConfidenceRealtimeCapped);
|
|
13698
|
-
const pythPriceWeighted = new
|
|
13699
|
-
const pythConfIntervalWeighted = new
|
|
13700
|
-
const pythConfIntervalWeightedCapped = capConfidenceInterval(pythPriceWeighted, pythConfIntervalWeighted, PYTH_PRICE_CONF_INTERVALS);
|
|
13696
|
+
const pythPriceWeighted = new bignumber_js.default(pythPriceData.emaPrice.value);
|
|
13697
|
+
const pythConfIntervalWeighted = new bignumber_js.default(pythPriceData.emaConfidence.value).times(require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13698
|
+
const pythConfIntervalWeightedCapped = capConfidenceInterval(pythPriceWeighted, pythConfIntervalWeighted, require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13701
13699
|
const pythLowestPrice = pythPriceWeighted.minus(pythConfIntervalWeightedCapped);
|
|
13702
13700
|
const pythHighestPrice = pythPriceWeighted.plus(pythConfIntervalWeightedCapped);
|
|
13703
13701
|
logger.debug({
|
|
@@ -13719,7 +13717,7 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13719
13717
|
lowestPrice: pythLowestPrice,
|
|
13720
13718
|
highestPrice: pythHighestPrice
|
|
13721
13719
|
},
|
|
13722
|
-
timestamp: new
|
|
13720
|
+
timestamp: new bignumber_js.default(Number(pythPriceData.timestamp)),
|
|
13723
13721
|
pythShardId: shardId
|
|
13724
13722
|
};
|
|
13725
13723
|
}
|
|
@@ -13727,15 +13725,15 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13727
13725
|
case OracleSetup.StakedWithPythPush: {
|
|
13728
13726
|
const bytesWithoutDiscriminator = rawData.slice(8);
|
|
13729
13727
|
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);
|
|
13728
|
+
const exponent = new bignumber_js.default(10 ** data.priceMessage.exponent);
|
|
13729
|
+
const priceRealTime = new bignumber_js.default(Number(data.priceMessage.price)).times(exponent);
|
|
13730
|
+
const confidenceRealTime = new bignumber_js.default(Number(data.priceMessage.conf)).times(exponent).times(require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13731
|
+
const cappedConfidenceRealTime = capConfidenceInterval(priceRealTime, confidenceRealTime, require_common.MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13734
13732
|
const lowestPriceRealTime = priceRealTime.minus(cappedConfidenceRealTime);
|
|
13735
13733
|
const highestPriceRealTime = priceRealTime.plus(cappedConfidenceRealTime);
|
|
13736
|
-
const priceTimeWeighted = new
|
|
13737
|
-
const confidenceTimeWeighted = new
|
|
13738
|
-
const cappedConfidenceWeighted = capConfidenceInterval(priceTimeWeighted, confidenceTimeWeighted, MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13734
|
+
const priceTimeWeighted = new bignumber_js.default(Number(data.priceMessage.emaPrice)).times(exponent);
|
|
13735
|
+
const confidenceTimeWeighted = new bignumber_js.default(Number(data.priceMessage.emaConf)).times(exponent).times(require_common.PYTH_PRICE_CONF_INTERVALS);
|
|
13736
|
+
const cappedConfidenceWeighted = capConfidenceInterval(priceTimeWeighted, confidenceTimeWeighted, require_common.MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13739
13737
|
const lowestPriceWeighted = priceTimeWeighted.minus(cappedConfidenceWeighted);
|
|
13740
13738
|
const highestPriceWeighted = priceTimeWeighted.plus(cappedConfidenceWeighted);
|
|
13741
13739
|
return {
|
|
@@ -13751,15 +13749,15 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13751
13749
|
lowestPrice: lowestPriceWeighted,
|
|
13752
13750
|
highestPrice: highestPriceWeighted
|
|
13753
13751
|
},
|
|
13754
|
-
timestamp: new
|
|
13752
|
+
timestamp: new bignumber_js.default(Number(data.priceMessage.publishTime)),
|
|
13755
13753
|
pythShardId: shardId
|
|
13756
13754
|
};
|
|
13757
13755
|
}
|
|
13758
13756
|
case OracleSetup.SwitchboardV2: {
|
|
13759
13757
|
const aggData = AggregatorAccountData.decode(rawData);
|
|
13760
|
-
const swbPrice = new
|
|
13761
|
-
const swbConfidence = new
|
|
13762
|
-
const swbConfidenceCapped = capConfidenceInterval(swbPrice, swbConfidence, MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13758
|
+
const swbPrice = new bignumber_js.default(AggregatorAccount.decodeLatestValue(aggData).toString());
|
|
13759
|
+
const swbConfidence = new bignumber_js.default(aggData.latestConfirmedRound.stdDeviation.toBig().toString()).times(require_common.SWB_PRICE_CONF_INTERVALS);
|
|
13760
|
+
const swbConfidenceCapped = capConfidenceInterval(swbPrice, swbConfidence, require_common.MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13763
13761
|
const swbLowestPrice = swbPrice.minus(swbConfidenceCapped);
|
|
13764
13762
|
const swbHighestPrice = swbPrice.plus(swbConfidenceCapped);
|
|
13765
13763
|
logger.debug({
|
|
@@ -13779,14 +13777,14 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13779
13777
|
lowestPrice: swbLowestPrice,
|
|
13780
13778
|
highestPrice: swbHighestPrice
|
|
13781
13779
|
},
|
|
13782
|
-
timestamp: new
|
|
13780
|
+
timestamp: new bignumber_js.default(aggData.latestConfirmedRound.roundOpenTimestamp)
|
|
13783
13781
|
};
|
|
13784
13782
|
}
|
|
13785
13783
|
case OracleSetup.SwitchboardPull: {
|
|
13786
13784
|
const pullFeedDAta = decodeSwitchboardPullFeedData(rawData);
|
|
13787
|
-
const swbPrice = new
|
|
13788
|
-
const swbConfidence = new
|
|
13789
|
-
const swbConfidenceCapped = capConfidenceInterval(swbPrice, swbConfidence, MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13785
|
+
const swbPrice = new bignumber_js.default(pullFeedDAta.result.value.toString()).div(10 ** SWITCHBOARD_ONDEMANDE_PRICE_PRECISION);
|
|
13786
|
+
const swbConfidence = new bignumber_js.default(pullFeedDAta.result.std_dev.toString()).times(require_common.SWB_PRICE_CONF_INTERVALS);
|
|
13787
|
+
const swbConfidenceCapped = capConfidenceInterval(swbPrice, swbConfidence, require_common.MAX_CONFIDENCE_INTERVAL_RATIO);
|
|
13790
13788
|
const swbLowestPrice = swbPrice.minus(swbConfidenceCapped);
|
|
13791
13789
|
const swbHighestPrice = swbPrice.plus(swbConfidenceCapped);
|
|
13792
13790
|
logger.debug({
|
|
@@ -13806,7 +13804,7 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13806
13804
|
lowestPrice: swbLowestPrice,
|
|
13807
13805
|
highestPrice: swbHighestPrice
|
|
13808
13806
|
},
|
|
13809
|
-
timestamp: new
|
|
13807
|
+
timestamp: new bignumber_js.default(pullFeedDAta.last_update_timestamp.toString())
|
|
13810
13808
|
};
|
|
13811
13809
|
}
|
|
13812
13810
|
default:
|
|
@@ -13820,18 +13818,18 @@ function parseOraclePriceData(oracleSetup, rawData, logger = new NoopLogger(), s
|
|
|
13820
13818
|
function dtoToOraclePrice(dto) {
|
|
13821
13819
|
return {
|
|
13822
13820
|
priceRealtime: {
|
|
13823
|
-
price: new
|
|
13824
|
-
confidence: new
|
|
13825
|
-
lowestPrice: new
|
|
13826
|
-
highestPrice: new
|
|
13821
|
+
price: new bignumber_js.default(dto.priceRealtime.price),
|
|
13822
|
+
confidence: new bignumber_js.default(dto.priceRealtime.confidence),
|
|
13823
|
+
lowestPrice: new bignumber_js.default(dto.priceRealtime.lowestPrice),
|
|
13824
|
+
highestPrice: new bignumber_js.default(dto.priceRealtime.highestPrice)
|
|
13827
13825
|
},
|
|
13828
13826
|
priceWeighted: {
|
|
13829
|
-
price: new
|
|
13830
|
-
confidence: new
|
|
13831
|
-
lowestPrice: new
|
|
13832
|
-
highestPrice: new
|
|
13827
|
+
price: new bignumber_js.default(dto.priceWeighted.price),
|
|
13828
|
+
confidence: new bignumber_js.default(dto.priceWeighted.confidence),
|
|
13829
|
+
lowestPrice: new bignumber_js.default(dto.priceWeighted.lowestPrice),
|
|
13830
|
+
highestPrice: new bignumber_js.default(dto.priceWeighted.highestPrice)
|
|
13833
13831
|
},
|
|
13834
|
-
timestamp: new
|
|
13832
|
+
timestamp: new bignumber_js.default(dto.timestamp),
|
|
13835
13833
|
pythShardId: dto.pythShardId
|
|
13836
13834
|
};
|
|
13837
13835
|
}
|
|
@@ -13870,7 +13868,7 @@ const fetchPythDataViaAPI = async (pythPushBanks, voteAccMintTuples) => {
|
|
|
13870
13868
|
const pythFeedMap = new Map();
|
|
13871
13869
|
Object.entries(pythFeedMapJson).forEach(([feedId, { feedId: feedIdStr, shardId }]) => {
|
|
13872
13870
|
pythFeedMap.set(feedId, {
|
|
13873
|
-
feedId: new PublicKey(feedIdStr),
|
|
13871
|
+
feedId: new __solana_web3_js.PublicKey(feedIdStr),
|
|
13874
13872
|
shardId
|
|
13875
13873
|
});
|
|
13876
13874
|
});
|
|
@@ -13928,18 +13926,18 @@ const fetchPythOraclePricesViaAPI = async (pythOracleKeys) => {
|
|
|
13928
13926
|
const responseBody = await response.json();
|
|
13929
13927
|
return Object.fromEntries(Object.entries(responseBody).map(([key, oraclePrice]) => [key, {
|
|
13930
13928
|
priceRealtime: {
|
|
13931
|
-
price:
|
|
13932
|
-
confidence:
|
|
13933
|
-
lowestPrice:
|
|
13934
|
-
highestPrice:
|
|
13929
|
+
price: (0, bignumber_js.default)(oraclePrice.priceRealtime.price),
|
|
13930
|
+
confidence: (0, bignumber_js.default)(oraclePrice.priceRealtime.confidence),
|
|
13931
|
+
lowestPrice: (0, bignumber_js.default)(oraclePrice.priceRealtime.lowestPrice),
|
|
13932
|
+
highestPrice: (0, bignumber_js.default)(oraclePrice.priceRealtime.highestPrice)
|
|
13935
13933
|
},
|
|
13936
13934
|
priceWeighted: {
|
|
13937
|
-
price:
|
|
13938
|
-
confidence:
|
|
13939
|
-
lowestPrice:
|
|
13940
|
-
highestPrice:
|
|
13935
|
+
price: (0, bignumber_js.default)(oraclePrice.priceWeighted.price),
|
|
13936
|
+
confidence: (0, bignumber_js.default)(oraclePrice.priceWeighted.confidence),
|
|
13937
|
+
lowestPrice: (0, bignumber_js.default)(oraclePrice.priceWeighted.lowestPrice),
|
|
13938
|
+
highestPrice: (0, bignumber_js.default)(oraclePrice.priceWeighted.highestPrice)
|
|
13941
13939
|
},
|
|
13942
|
-
timestamp: oraclePrice.timestamp ?
|
|
13940
|
+
timestamp: oraclePrice.timestamp ? (0, bignumber_js.default)(oraclePrice.timestamp) : null,
|
|
13943
13941
|
pythShardId: oraclePrice.pythShardId
|
|
13944
13942
|
}]));
|
|
13945
13943
|
};
|
|
@@ -14058,18 +14056,18 @@ const fetchSwbOraclePricesViaAPI = async (swbFeedIds) => {
|
|
|
14058
14056
|
const responseBody = await response.json();
|
|
14059
14057
|
return Object.fromEntries(Object.entries(responseBody).map(([key, oraclePrice]) => [key, {
|
|
14060
14058
|
priceRealtime: {
|
|
14061
|
-
price:
|
|
14062
|
-
confidence:
|
|
14063
|
-
lowestPrice:
|
|
14064
|
-
highestPrice:
|
|
14059
|
+
price: (0, bignumber_js.default)(oraclePrice.priceRealtime.price),
|
|
14060
|
+
confidence: (0, bignumber_js.default)(oraclePrice.priceRealtime.confidence),
|
|
14061
|
+
lowestPrice: (0, bignumber_js.default)(oraclePrice.priceRealtime.lowestPrice),
|
|
14062
|
+
highestPrice: (0, bignumber_js.default)(oraclePrice.priceRealtime.highestPrice)
|
|
14065
14063
|
},
|
|
14066
14064
|
priceWeighted: {
|
|
14067
|
-
price:
|
|
14068
|
-
confidence:
|
|
14069
|
-
lowestPrice:
|
|
14070
|
-
highestPrice:
|
|
14065
|
+
price: (0, bignumber_js.default)(oraclePrice.priceWeighted.price),
|
|
14066
|
+
confidence: (0, bignumber_js.default)(oraclePrice.priceWeighted.confidence),
|
|
14067
|
+
lowestPrice: (0, bignumber_js.default)(oraclePrice.priceWeighted.lowestPrice),
|
|
14068
|
+
highestPrice: (0, bignumber_js.default)(oraclePrice.priceWeighted.highestPrice)
|
|
14071
14069
|
},
|
|
14072
|
-
timestamp: oraclePrice.timestamp ?
|
|
14070
|
+
timestamp: oraclePrice.timestamp ? (0, bignumber_js.default)(oraclePrice.timestamp) : null
|
|
14073
14071
|
}]));
|
|
14074
14072
|
};
|
|
14075
14073
|
/**
|
|
@@ -14108,18 +14106,18 @@ const fetchOracleData = async (banks, bankMetadataMap, connection, opts) => {
|
|
|
14108
14106
|
console.error(`Bank ${bank.address.toBase58()} is missing an oracle price`);
|
|
14109
14107
|
bankOraclePriceMap.set(bank.address.toBase58(), {
|
|
14110
14108
|
priceRealtime: {
|
|
14111
|
-
price:
|
|
14112
|
-
confidence:
|
|
14113
|
-
lowestPrice:
|
|
14114
|
-
highestPrice:
|
|
14109
|
+
price: (0, bignumber_js.default)(0),
|
|
14110
|
+
confidence: (0, bignumber_js.default)(0),
|
|
14111
|
+
lowestPrice: (0, bignumber_js.default)(0),
|
|
14112
|
+
highestPrice: (0, bignumber_js.default)(0)
|
|
14115
14113
|
},
|
|
14116
14114
|
priceWeighted: {
|
|
14117
|
-
price:
|
|
14118
|
-
confidence:
|
|
14119
|
-
lowestPrice:
|
|
14120
|
-
highestPrice:
|
|
14115
|
+
price: (0, bignumber_js.default)(0),
|
|
14116
|
+
confidence: (0, bignumber_js.default)(0),
|
|
14117
|
+
lowestPrice: (0, bignumber_js.default)(0),
|
|
14118
|
+
highestPrice: (0, bignumber_js.default)(0)
|
|
14121
14119
|
},
|
|
14122
|
-
timestamp:
|
|
14120
|
+
timestamp: (0, bignumber_js.default)(0)
|
|
14123
14121
|
});
|
|
14124
14122
|
}
|
|
14125
14123
|
});
|
|
@@ -14163,7 +14161,7 @@ function computeMaxLeverage(depositBank, borrowBank, opts) {
|
|
|
14163
14161
|
};
|
|
14164
14162
|
}
|
|
14165
14163
|
function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank, depositOracleInfo, borrowOracleInfo) {
|
|
14166
|
-
const initialCollateral = toBigNumber(principal);
|
|
14164
|
+
const initialCollateral = require_common.toBigNumber(principal);
|
|
14167
14165
|
const { maxLeverage } = computeMaxLeverage(depositBank, borrowBank);
|
|
14168
14166
|
if (targetLeverage < 1) {
|
|
14169
14167
|
throw Error(`Target leverage ${targetLeverage} needs to be greater than 1`);
|
|
@@ -14171,7 +14169,7 @@ function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank
|
|
|
14171
14169
|
if (targetLeverage > maxLeverage) {
|
|
14172
14170
|
throw Error(`Target leverage ${targetLeverage} exceeds max leverage for banks ${maxLeverage}`);
|
|
14173
14171
|
}
|
|
14174
|
-
const totalDepositAmount = initialCollateral.times(new
|
|
14172
|
+
const totalDepositAmount = initialCollateral.times(new bignumber_js.default(targetLeverage));
|
|
14175
14173
|
const additionalDepositAmount = totalDepositAmount.minus(initialCollateral);
|
|
14176
14174
|
const borrowAmount = additionalDepositAmount.times(depositOracleInfo.priceWeighted.lowestPrice).div(borrowOracleInfo.priceWeighted.highestPrice);
|
|
14177
14175
|
return {
|
|
@@ -14212,7 +14210,7 @@ function getAssetWeight(bank, lendrRequirementType, oraclePrice, opts) {
|
|
|
14212
14210
|
}
|
|
14213
14211
|
}
|
|
14214
14212
|
case LendrRequirementType.Maintenance: return bank.config.assetWeightMaint;
|
|
14215
|
-
case LendrRequirementType.Equity: return new
|
|
14213
|
+
case LendrRequirementType.Equity: return new bignumber_js.default(1);
|
|
14216
14214
|
default: throw new Error("Invalid lendr requirement type");
|
|
14217
14215
|
}
|
|
14218
14216
|
}
|
|
@@ -14220,7 +14218,7 @@ function getLiabilityWeight(config, lendrRequirementType) {
|
|
|
14220
14218
|
switch (lendrRequirementType) {
|
|
14221
14219
|
case LendrRequirementType.Initial: return config.liabilityWeightInit;
|
|
14222
14220
|
case LendrRequirementType.Maintenance: return config.liabilityWeightMaint;
|
|
14223
|
-
case LendrRequirementType.Equity: return new
|
|
14221
|
+
case LendrRequirementType.Equity: return new bignumber_js.default(1);
|
|
14224
14222
|
default: throw new Error("Invalid lendr requirement type");
|
|
14225
14223
|
}
|
|
14226
14224
|
}
|
|
@@ -14251,7 +14249,7 @@ function computeInterestRates(bank) {
|
|
|
14251
14249
|
const baseInterestRate = computeBaseInterestRate(bank);
|
|
14252
14250
|
const utilizationRate = computeUtilizationRate(bank);
|
|
14253
14251
|
const lendingRate = baseInterestRate.times(utilizationRate);
|
|
14254
|
-
const borrowingRate = baseInterestRate.times(new
|
|
14252
|
+
const borrowingRate = baseInterestRate.times(new bignumber_js.default(1).plus(rateFee)).plus(fixedFee);
|
|
14255
14253
|
return {
|
|
14256
14254
|
lendingRate,
|
|
14257
14255
|
borrowingRate
|
|
@@ -14263,22 +14261,22 @@ function computeBaseInterestRate(bank) {
|
|
|
14263
14261
|
if (utilizationRate.lte(optimalUtilizationRate)) {
|
|
14264
14262
|
return utilizationRate.times(plateauInterestRate).div(optimalUtilizationRate);
|
|
14265
14263
|
} else {
|
|
14266
|
-
return utilizationRate.minus(optimalUtilizationRate).div(new
|
|
14264
|
+
return utilizationRate.minus(optimalUtilizationRate).div(new bignumber_js.default(1).minus(optimalUtilizationRate)).times(maxInterestRate.minus(plateauInterestRate)).plus(plateauInterestRate);
|
|
14267
14265
|
}
|
|
14268
14266
|
}
|
|
14269
14267
|
function computeUtilizationRate(bank) {
|
|
14270
14268
|
const assets = getTotalAssetQuantity(bank);
|
|
14271
14269
|
const liabilities = getTotalLiabilityQuantity(bank);
|
|
14272
|
-
if (assets.isZero()) return new
|
|
14270
|
+
if (assets.isZero()) return new bignumber_js.default(0);
|
|
14273
14271
|
return liabilities.div(assets);
|
|
14274
14272
|
}
|
|
14275
14273
|
const SECONDS_PER_DAY$1 = 24 * 60 * 60;
|
|
14276
14274
|
const SECONDS_PER_YEAR$1 = SECONDS_PER_DAY$1 * 365.25;
|
|
14277
14275
|
function computeRemainingCapacity(bank) {
|
|
14278
14276
|
const totalDeposits = getTotalAssetQuantity(bank);
|
|
14279
|
-
const remainingCapacity =
|
|
14277
|
+
const remainingCapacity = bignumber_js.default.max(0, bank.config.depositLimit.minus(totalDeposits));
|
|
14280
14278
|
const totalBorrows = getTotalLiabilityQuantity(bank);
|
|
14281
|
-
const remainingBorrowCapacity =
|
|
14279
|
+
const remainingBorrowCapacity = bignumber_js.default.max(0, bank.config.borrowLimit.minus(totalBorrows));
|
|
14282
14280
|
const durationSinceLastAccrual = Date.now() / 1e3 - bank.lastUpdate;
|
|
14283
14281
|
const { lendingRate, borrowingRate } = computeInterestRates(bank);
|
|
14284
14282
|
const outstandingLendingInterest = lendingRate.times(durationSinceLastAccrual).dividedBy(SECONDS_PER_YEAR$1).times(totalDeposits);
|
|
@@ -14301,7 +14299,7 @@ const fetchMultipleBanks = async (program, opts) => {
|
|
|
14301
14299
|
data.forEach((d, idx) => {
|
|
14302
14300
|
if (d) {
|
|
14303
14301
|
bankDatas.push({
|
|
14304
|
-
address: new PublicKey(addresses[idx]),
|
|
14302
|
+
address: new __solana_web3_js.PublicKey(addresses[idx]),
|
|
14305
14303
|
data: d
|
|
14306
14304
|
});
|
|
14307
14305
|
} else {
|
|
@@ -14325,8 +14323,8 @@ const fetchMultipleBanks = async (program, opts) => {
|
|
|
14325
14323
|
//#endregion
|
|
14326
14324
|
//#region src/services/bank/utils/serialize.utils.ts
|
|
14327
14325
|
function serializeBankConfigOpt(bankConfigOpt) {
|
|
14328
|
-
const toWrappedI80F48 = (value) => value && bigNumberToWrappedI80F48(value);
|
|
14329
|
-
const toBN = (value) => value && new
|
|
14326
|
+
const toWrappedI80F48 = (value) => value && require_common.bigNumberToWrappedI80F48(value);
|
|
14327
|
+
const toBN = (value) => value && new bn_js.default(value.toString());
|
|
14330
14328
|
return {
|
|
14331
14329
|
assetWeightInit: toWrappedI80F48(bankConfigOpt.assetWeightInit),
|
|
14332
14330
|
assetWeightMaint: toWrappedI80F48(bankConfigOpt.assetWeightMaint),
|
|
@@ -14596,20 +14594,20 @@ function getPriceFeedAccountForProgram(shardId, priceFeedId, pushOracleProgramId
|
|
|
14596
14594
|
}
|
|
14597
14595
|
const shardBuffer = Buffer.alloc(2);
|
|
14598
14596
|
shardBuffer.writeUint16LE(shardId, 0);
|
|
14599
|
-
return PublicKey.findProgramAddressSync([shardBuffer, priceFeedId], pushOracleProgramId ?? DEFAULT_PUSH_ORACLE_PROGRAM_ID)[0];
|
|
14597
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([shardBuffer, priceFeedId], pushOracleProgramId ?? DEFAULT_PUSH_ORACLE_PROGRAM_ID)[0];
|
|
14600
14598
|
}
|
|
14601
14599
|
const getTreasuryPda = (treasuryId, receiverProgramId) => {
|
|
14602
|
-
return PublicKey.findProgramAddressSync([Buffer.from("treasury"), Buffer.from([treasuryId])], receiverProgramId)[0];
|
|
14600
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("treasury"), Buffer.from([treasuryId])], receiverProgramId)[0];
|
|
14603
14601
|
};
|
|
14604
14602
|
const getConfigPda = (receiverProgramId) => {
|
|
14605
|
-
return PublicKey.findProgramAddressSync([Buffer.from("config")], receiverProgramId)[0];
|
|
14603
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("config")], receiverProgramId)[0];
|
|
14606
14604
|
};
|
|
14607
14605
|
async function crankPythOracleIx(oracles, provider) {
|
|
14608
14606
|
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");
|
|
14607
|
+
const wormholeProgram = new __coral_xyz_anchor.Program(PYTH_WORMHOLE_IDL, provider);
|
|
14608
|
+
const pushOracleProgram = new __coral_xyz_anchor.Program(PYTH_PUSH_ORACLE_IDL, provider);
|
|
14609
|
+
const receiverProgram = new __coral_xyz_anchor.Program(PYTH_SOLANA_RECEIVER_PROGRAM_IDL, provider);
|
|
14610
|
+
const addressLookupTableAccount = new __solana_web3_js.PublicKey("5DNCErWQFBdvCxWQXaC1mrEFsvL3ftrzZ2gVZWNybaSX");
|
|
14613
14611
|
const lookupTableAccount = (await provider.connection.getAddressLookupTable(addressLookupTableAccount)).value;
|
|
14614
14612
|
const buildURL = (endpoint) => {
|
|
14615
14613
|
return new URL(`./v2/${endpoint}`, `https://hermes.pyth.network/`);
|
|
@@ -14650,7 +14648,7 @@ async function crankPythOracleIx(oracles, provider) {
|
|
|
14650
14648
|
priceFeedAccount: getPriceFeedAccountForProgram(Number(shardId), feedId, pushOracleProgram.programId),
|
|
14651
14649
|
treasury: getTreasuryPda(treasuryId, receiverProgram.programId),
|
|
14652
14650
|
config: getConfigPda(receiverProgram.programId),
|
|
14653
|
-
systemProgram: SYSTEM_PROGRAM_ID
|
|
14651
|
+
systemProgram: require_common.SYSTEM_PROGRAM_ID
|
|
14654
14652
|
}).instruction(),
|
|
14655
14653
|
signers: [],
|
|
14656
14654
|
computeUnits: UPDATE_PRICE_FEED_COMPUTE_BUDGET
|
|
@@ -14722,7 +14720,7 @@ async function sendTransactionAsBundle(connection, base58Txs, throwError = false
|
|
|
14722
14720
|
throw new SendBundleError(`${API_ERROR_TAG} ${sendBundleResult.error.message}`);
|
|
14723
14721
|
}
|
|
14724
14722
|
const bundleId = sendBundleResult.result;
|
|
14725
|
-
await sleep(500);
|
|
14723
|
+
await require_common.sleep(500);
|
|
14726
14724
|
for (let attempt = 0; attempt < 10; attempt++) {
|
|
14727
14725
|
const getBundleStatusResponse = await fetch("https://mainnet.block-engine.jito.wtf/api/v1/bundles", {
|
|
14728
14726
|
method: "POST",
|
|
@@ -14755,7 +14753,7 @@ async function sendTransactionAsBundle(connection, base58Txs, throwError = false
|
|
|
14755
14753
|
await confirmBundle(connection, bundleId);
|
|
14756
14754
|
return bundleId;
|
|
14757
14755
|
}
|
|
14758
|
-
await sleep(1e3);
|
|
14756
|
+
await require_common.sleep(1e3);
|
|
14759
14757
|
}
|
|
14760
14758
|
} catch (error) {
|
|
14761
14759
|
if (throwError) {
|
|
@@ -14769,7 +14767,7 @@ async function confirmBundle(connection, bundleId, commitment = "confirmed") {
|
|
|
14769
14767
|
let attempts = 0;
|
|
14770
14768
|
const maxAttempts = 5;
|
|
14771
14769
|
while (attempts < maxAttempts) {
|
|
14772
|
-
await sleep(2e3);
|
|
14770
|
+
await require_common.sleep(2e3);
|
|
14773
14771
|
attempts += 1;
|
|
14774
14772
|
const getBundleStatus = await fetch("https://mainnet.block-engine.jito.wtf/api/v1/bundles", {
|
|
14775
14773
|
method: "POST",
|
|
@@ -14795,7 +14793,7 @@ async function confirmBundle(connection, bundleId, commitment = "confirmed") {
|
|
|
14795
14793
|
console.log("❌ Transaction failed to confirm in time.");
|
|
14796
14794
|
throw new Error("Transaction failed to confirm in time.");
|
|
14797
14795
|
};
|
|
14798
|
-
const result = await Promise.race([getStatus(), setTimeoutPromise(2e4, `Transaction failed to confirm in time.`)]);
|
|
14796
|
+
const result = await Promise.race([getStatus(), require_common.setTimeoutPromise(2e4, `Transaction failed to confirm in time.`)]);
|
|
14799
14797
|
if (result instanceof Error) {
|
|
14800
14798
|
throw result;
|
|
14801
14799
|
}
|
|
@@ -14831,7 +14829,7 @@ async function simulateBundle(rpcEndpoint, transactions, includeAccounts) {
|
|
|
14831
14829
|
const result = await executeBundleSimulation(rpcEndpoint, encodedTransactions, config);
|
|
14832
14830
|
return result;
|
|
14833
14831
|
} catch (error) {
|
|
14834
|
-
if (error instanceof SolanaJSONRPCError || error instanceof BundleSimulationError) {
|
|
14832
|
+
if (error instanceof __solana_web3_js.SolanaJSONRPCError || error instanceof BundleSimulationError) {
|
|
14835
14833
|
throw error;
|
|
14836
14834
|
} else {
|
|
14837
14835
|
throw new BundleSimulationError("Failed to execute bundle simulation", undefined, error);
|
|
@@ -14937,7 +14935,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
14937
14935
|
...DEFAULT_PROCESS_TX_OPTS,
|
|
14938
14936
|
...processOptsArgs
|
|
14939
14937
|
};
|
|
14940
|
-
const commitment = connection.commitment ?? DEFAULT_CONFIRM_OPTS.commitment;
|
|
14938
|
+
const commitment = connection.commitment ?? require_common.DEFAULT_CONFIRM_OPTS.commitment;
|
|
14941
14939
|
if (processOpts?.broadcastType === "BUNDLE" && processOpts?.bundleTipUi === 0) {
|
|
14942
14940
|
throw new Error("A bundle tip is required for a bundled transactions");
|
|
14943
14941
|
}
|
|
@@ -14973,7 +14971,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
14973
14971
|
lastValidBlockHeight = getLatestBlockhashAndContext.value.lastValidBlockHeight;
|
|
14974
14972
|
} catch (error) {
|
|
14975
14973
|
console.error("Failed to get latest blockhash and context", error);
|
|
14976
|
-
if (error instanceof SolanaJSONRPCError) {
|
|
14974
|
+
if (error instanceof __solana_web3_js.SolanaJSONRPCError) {
|
|
14977
14975
|
throw error;
|
|
14978
14976
|
}
|
|
14979
14977
|
throw new ProcessTransactionError({
|
|
@@ -14983,7 +14981,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
14983
14981
|
});
|
|
14984
14982
|
}
|
|
14985
14983
|
const mergedOpts = {
|
|
14986
|
-
...DEFAULT_CONFIRM_OPTS,
|
|
14984
|
+
...require_common.DEFAULT_CONFIRM_OPTS,
|
|
14987
14985
|
commitment,
|
|
14988
14986
|
preflightCommitment: commitment,
|
|
14989
14987
|
minContextSlot,
|
|
@@ -14996,7 +14994,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
14996
14994
|
blockhash
|
|
14997
14995
|
});
|
|
14998
14996
|
const unitsConsumed = isSimulatedTransactionResponse(simulationResult) ? [simulationResult.unitsConsumed] : simulationResult.map((tx) => tx.unitsConsumed ? Number(tx.unitsConsumed) : undefined);
|
|
14999
|
-
updatedTransactions = transactions.map((tx, idx) => addTransactionMetadata(tx, {
|
|
14997
|
+
updatedTransactions = transactions.map((tx, idx) => require_common.addTransactionMetadata(tx, {
|
|
15000
14998
|
...tx,
|
|
15001
14999
|
unitsConsumed: unitsConsumed[idx]
|
|
15002
15000
|
}));
|
|
@@ -15009,8 +15007,8 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15009
15007
|
console.log(`💸 Bundle tip: ${maxCapUi ? Math.min(processOpts.bundleTipUi ?? 0, maxCapUi) : processOpts.bundleTipUi} SOL`);
|
|
15010
15008
|
} else {
|
|
15011
15009
|
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;
|
|
15010
|
+
const cu = tx.unitsConsumed ? Math.min(tx.unitsConsumed + 5e4, 14e5) : require_common.getComputeBudgetUnits(tx);
|
|
15011
|
+
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
15012
|
console.log(`💸 Priority fee for tx ${idx}: ${priorityFeeUi} SOL`);
|
|
15015
15013
|
});
|
|
15016
15014
|
}
|
|
@@ -15030,11 +15028,11 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15030
15028
|
let base58Txs = [];
|
|
15031
15029
|
if (wallet.signAllTransactions) {
|
|
15032
15030
|
versionedTransactions = await wallet.signAllTransactions(versionedTransactions);
|
|
15033
|
-
base58Txs = versionedTransactions.map((signedTx) => bs58.encode(signedTx.serialize()));
|
|
15031
|
+
base58Txs = versionedTransactions.map((signedTx) => bs58.default.encode(signedTx.serialize()));
|
|
15034
15032
|
} else {
|
|
15035
15033
|
for (let i = 0; i < versionedTransactions.length; i++) {
|
|
15036
15034
|
const signedTx = await wallet.signTransaction(versionedTransactions[i]);
|
|
15037
|
-
const base58Tx = bs58.encode(signedTx.serialize());
|
|
15035
|
+
const base58Tx = bs58.default.encode(signedTx.serialize());
|
|
15038
15036
|
base58Txs.push(base58Tx);
|
|
15039
15037
|
versionedTransactions[i] = signedTx;
|
|
15040
15038
|
}
|
|
@@ -15046,7 +15044,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15046
15044
|
processOpts.callback?.(undefined, true);
|
|
15047
15045
|
}
|
|
15048
15046
|
let simulateTxs = null;
|
|
15049
|
-
if (!SKIP_SIMULATION) {
|
|
15047
|
+
if (!require_common.SKIP_SIMULATION) {
|
|
15050
15048
|
simulateTxs = async () => await simulateTransactions(processOpts, connection, versionedTransactions, mergedOpts);
|
|
15051
15049
|
}
|
|
15052
15050
|
const sendTxBundleGrpc = async (throwError) => await sendTransactionAsGrpcBundle(connection, base58Txs, throwError);
|
|
@@ -15066,7 +15064,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15066
15064
|
});
|
|
15067
15065
|
for (const [idx, method] of finalFallbackMethod.entries()) {
|
|
15068
15066
|
const isLast = idx === finalFallbackMethod.length - 1;
|
|
15069
|
-
if (idx === 0 && simulateTxs && !SKIP_SIMULATION) {
|
|
15067
|
+
if (idx === 0 && simulateTxs && !require_common.SKIP_SIMULATION) {
|
|
15070
15068
|
await simulateTxs();
|
|
15071
15069
|
}
|
|
15072
15070
|
let temporaryBundleSignature;
|
|
@@ -15118,7 +15116,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15118
15116
|
}
|
|
15119
15117
|
} catch (error) {
|
|
15120
15118
|
const failedTxs = transactions.splice(signatures.length);
|
|
15121
|
-
if (error instanceof SolanaJSONRPCError) {
|
|
15119
|
+
if (error instanceof __solana_web3_js.SolanaJSONRPCError) {
|
|
15122
15120
|
throw error;
|
|
15123
15121
|
}
|
|
15124
15122
|
if (error instanceof ProcessTransactionError) {
|
|
@@ -15128,12 +15126,12 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15128
15126
|
throw new ProcessTransactionError({
|
|
15129
15127
|
message: error.message,
|
|
15130
15128
|
type: ProcessTransactionErrorType.TransactionSendingError,
|
|
15131
|
-
programId: PROGRAM_ID.toBase58(),
|
|
15129
|
+
programId: require_common.PROGRAM_ID.toBase58(),
|
|
15132
15130
|
failedTxs,
|
|
15133
15131
|
_error: error
|
|
15134
15132
|
});
|
|
15135
15133
|
}
|
|
15136
|
-
const parsedError = parseTransactionError(error, processOpts?.programId ?? PROGRAM_ID);
|
|
15134
|
+
const parsedError = parseTransactionError(error, processOpts?.programId ?? require_common.PROGRAM_ID);
|
|
15137
15135
|
if (error?.logs?.length > 0) {
|
|
15138
15136
|
console.log("------ Logs 👇 ------");
|
|
15139
15137
|
console.log(error.logs.join("\n"));
|
|
@@ -15159,7 +15157,7 @@ async function processTransactions({ transactions, connection, wallet, processOp
|
|
|
15159
15157
|
}
|
|
15160
15158
|
}
|
|
15161
15159
|
const simulateTransactions = async (processOpts, connection, solanaTransactions, confirmOpts, txOpts) => {
|
|
15162
|
-
const v0Txs = solanaTransactions.map((tx) => isV0Tx(tx) ? tx : legacyTxToV0Tx(tx, txOpts));
|
|
15160
|
+
const v0Txs = solanaTransactions.map((tx) => require_common.isV0Tx(tx) ? tx : require_common.legacyTxToV0Tx(tx, txOpts));
|
|
15163
15161
|
try {
|
|
15164
15162
|
if (v0Txs.length > 1) {
|
|
15165
15163
|
const response = await simulateBundle(processOpts?.bundleSimRpcEndpoint ?? connection.rpcEndpoint, v0Txs);
|
|
@@ -15173,7 +15171,7 @@ const simulateTransactions = async (processOpts, connection, solanaTransactions,
|
|
|
15173
15171
|
});
|
|
15174
15172
|
if (response.value.err) {
|
|
15175
15173
|
const error = response.value.err;
|
|
15176
|
-
const parsedError = parseTransactionError(error, processOpts?.programId ?? PROGRAM_ID);
|
|
15174
|
+
const parsedError = parseTransactionError(error, processOpts?.programId ?? require_common.PROGRAM_ID);
|
|
15177
15175
|
throw new ProcessTransactionError({
|
|
15178
15176
|
message: parsedError.description ?? JSON.stringify(response.value.err),
|
|
15179
15177
|
type: ProcessTransactionErrorType.SimulationError,
|
|
@@ -15185,7 +15183,7 @@ const simulateTransactions = async (processOpts, connection, solanaTransactions,
|
|
|
15185
15183
|
}
|
|
15186
15184
|
} catch (error) {
|
|
15187
15185
|
if (error instanceof BundleSimulationError) {
|
|
15188
|
-
const parsedError = parseTransactionError(error, processOpts?.programId ?? PROGRAM_ID);
|
|
15186
|
+
const parsedError = parseTransactionError(error, processOpts?.programId ?? require_common.PROGRAM_ID);
|
|
15189
15187
|
throw new ProcessTransactionError({
|
|
15190
15188
|
message: parsedError.description,
|
|
15191
15189
|
type: ProcessTransactionErrorType.SimulationError,
|
|
@@ -15247,12 +15245,12 @@ async function confirmTransaction(connection, signature, commitment = "confirmed
|
|
|
15247
15245
|
}
|
|
15248
15246
|
}
|
|
15249
15247
|
console.log("🔄 Waiting for confirmation...");
|
|
15250
|
-
await sleep(2e3);
|
|
15248
|
+
await require_common.sleep(2e3);
|
|
15251
15249
|
}
|
|
15252
15250
|
console.log("❌ Transaction failed to confirm in time.");
|
|
15253
15251
|
throw new Error("Transaction failed to confirm in time.");
|
|
15254
15252
|
};
|
|
15255
|
-
const result = await Promise.race([getStatus(), setTimeoutPromise(2e4, `Transaction failed to confirm in time.`)]);
|
|
15253
|
+
const result = await Promise.race([getStatus(), require_common.setTimeoutPromise(2e4, `Transaction failed to confirm in time.`)]);
|
|
15256
15254
|
if (result instanceof Error) {
|
|
15257
15255
|
throw result;
|
|
15258
15256
|
}
|
|
@@ -15339,14 +15337,14 @@ const MAX_TX_SIZE$1 = 1232;
|
|
|
15339
15337
|
const BUNDLE_TX_SIZE$1 = 81;
|
|
15340
15338
|
const PRIORITY_TX_SIZE$1 = 44;
|
|
15341
15339
|
function isFlashloan(tx) {
|
|
15342
|
-
if (isV0Tx(tx)) {
|
|
15340
|
+
if (require_common.isV0Tx(tx)) {
|
|
15343
15341
|
const addressLookupTableAccounts = tx.addressLookupTables ?? [];
|
|
15344
|
-
const message = decompileV0Transaction(tx, addressLookupTableAccounts);
|
|
15342
|
+
const message = require_common.decompileV0Transaction(tx, addressLookupTableAccounts);
|
|
15345
15343
|
const idl = {
|
|
15346
15344
|
...LENDR_IDL,
|
|
15347
|
-
address: new PublicKey(0)
|
|
15345
|
+
address: new __solana_web3_js.PublicKey(0)
|
|
15348
15346
|
};
|
|
15349
|
-
const decoded = message.instructions.map((ix) => decodeInstruction(idl, ix.data));
|
|
15347
|
+
const decoded = message.instructions.map((ix) => require_common.decodeInstruction(idl, ix.data));
|
|
15350
15348
|
return decoded.some((ix) => ix?.name.toLowerCase().includes("flashloan"));
|
|
15351
15349
|
}
|
|
15352
15350
|
return false;
|
|
@@ -15375,25 +15373,25 @@ function formatTransactions(transactionsArg, broadcastType, blockhash, feeSettin
|
|
|
15375
15373
|
const { priorityFeeMicro, bundleTipUi, feePayer, maxCapUi } = feeSettings;
|
|
15376
15374
|
const flashloanIndex = getFlashloanIndex(transactionsArg);
|
|
15377
15375
|
transactionsArg.forEach((tx) => {
|
|
15378
|
-
if (!isV0Tx(tx)) {
|
|
15376
|
+
if (!require_common.isV0Tx(tx)) {
|
|
15379
15377
|
tx.recentBlockhash = blockhash;
|
|
15380
15378
|
tx.feePayer = feePayer;
|
|
15381
15379
|
}
|
|
15382
15380
|
});
|
|
15383
15381
|
const transactions = addTransactionTags ? addTransactionTxTags(transactionsArg) : transactionsArg;
|
|
15384
|
-
const txSizes = transactions.map((tx) => getTxSize(tx));
|
|
15382
|
+
const txSizes = transactions.map((tx) => require_common.getTxSize(tx));
|
|
15385
15383
|
const dummyPriorityFeeIx = makePriorityFeeMicroIx(1);
|
|
15386
15384
|
const priorityIxs = [];
|
|
15387
15385
|
const cuLimitIxs = [];
|
|
15388
15386
|
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);
|
|
15387
|
+
const cu = tx.unitsConsumed ? Math.min(tx.unitsConsumed + 5e4, 14e5) : require_common.getComputeBudgetUnits(tx);
|
|
15388
|
+
const priorityFeeUi = maxCapUi ? Math.min(require_common.microLamportsToUi(priorityFeeMicro, cu), maxCapUi) : require_common.microLamportsToUi(priorityFeeMicro, cu);
|
|
15389
|
+
let updatedFees = require_common.uiToMicroLamports(priorityFeeUi, cu);
|
|
15392
15390
|
if (priorityFeeUi > .1) {
|
|
15393
|
-
updatedFees = uiToMicroLamports(.1, cu);
|
|
15391
|
+
updatedFees = require_common.uiToMicroLamports(.1, cu);
|
|
15394
15392
|
}
|
|
15395
15393
|
priorityIxs.push(broadcastType === "BUNDLE" ? dummyPriorityFeeIx : makePriorityFeeMicroIx(updatedFees));
|
|
15396
|
-
cuLimitIxs.push(cu ? ComputeBudgetProgram.setComputeUnitLimit({ units: cu }) : undefined);
|
|
15394
|
+
cuLimitIxs.push(cu ? __solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: cu }) : undefined);
|
|
15397
15395
|
});
|
|
15398
15396
|
const { bundleTipIx } = makeTxPriorityIx(feePayer, maxCapUi ? Math.min(bundleTipUi, maxCapUi) : bundleTipUi, broadcastType);
|
|
15399
15397
|
let bundleTipIndex = broadcastType === "BUNDLE" ? -1 : null;
|
|
@@ -15411,12 +15409,12 @@ function formatTransactions(transactionsArg, broadcastType, blockhash, feeSettin
|
|
|
15411
15409
|
}
|
|
15412
15410
|
}
|
|
15413
15411
|
if (bundleTipIndex === -1 && bundleTipIx) {
|
|
15414
|
-
const bundleTipMessage = new TransactionMessage({
|
|
15412
|
+
const bundleTipMessage = new __solana_web3_js.TransactionMessage({
|
|
15415
15413
|
instructions: [bundleTipIx],
|
|
15416
15414
|
payerKey: feePayer,
|
|
15417
15415
|
recentBlockhash: blockhash
|
|
15418
15416
|
});
|
|
15419
|
-
formattedTransactions.push(new VersionedTransaction(bundleTipMessage.compileToV0Message()));
|
|
15417
|
+
formattedTransactions.push(new __solana_web3_js.VersionedTransaction(bundleTipMessage.compileToV0Message()));
|
|
15420
15418
|
}
|
|
15421
15419
|
for (const [index, transaction] of transactions.entries()) {
|
|
15422
15420
|
const hasFlashloan = flashloanIndex !== null;
|
|
@@ -15429,15 +15427,15 @@ function formatTransactions(transactionsArg, broadcastType, blockhash, feeSettin
|
|
|
15429
15427
|
...cuLimitIxs[index] ? [cuLimitIxs[index]] : []
|
|
15430
15428
|
];
|
|
15431
15429
|
let newTransaction;
|
|
15432
|
-
if (isV0Tx(transaction)) {
|
|
15433
|
-
newTransaction = updateV0Tx(transaction, {
|
|
15430
|
+
if (require_common.isV0Tx(transaction)) {
|
|
15431
|
+
newTransaction = require_common.updateV0Tx(transaction, {
|
|
15434
15432
|
addressLookupTables,
|
|
15435
15433
|
additionalIxs: requiredIxs,
|
|
15436
15434
|
blockhash,
|
|
15437
15435
|
replaceOnly: isTxFlashloan
|
|
15438
15436
|
});
|
|
15439
15437
|
} else {
|
|
15440
|
-
newTransaction = legacyTxToV0Tx(transaction, {
|
|
15438
|
+
newTransaction = require_common.legacyTxToV0Tx(transaction, {
|
|
15441
15439
|
addressLookupTables,
|
|
15442
15440
|
additionalIxs: requiredIxs,
|
|
15443
15441
|
blockhash,
|
|
@@ -15453,18 +15451,18 @@ function addTransactionTxTags(transactions) {
|
|
|
15453
15451
|
const txWithTags = [];
|
|
15454
15452
|
for (const [_, tx] of transactions.entries()) {
|
|
15455
15453
|
let solanaTx = tx;
|
|
15456
|
-
const arenaKey = TransactionArenaKeyMap[tx.type];
|
|
15454
|
+
const arenaKey = require_common.TransactionArenaKeyMap[tx.type];
|
|
15457
15455
|
if (arenaKey) {
|
|
15458
|
-
if (isV0Tx(solanaTx)) {
|
|
15456
|
+
if (require_common.isV0Tx(solanaTx)) {
|
|
15459
15457
|
console.log("tx", solanaTx);
|
|
15460
15458
|
const addressLookupTableAccounts = solanaTx.addressLookupTables ?? [];
|
|
15461
|
-
const message = decompileV0Transaction(solanaTx, addressLookupTableAccounts);
|
|
15459
|
+
const message = require_common.decompileV0Transaction(solanaTx, addressLookupTableAccounts);
|
|
15462
15460
|
message.instructions[0].keys.push({
|
|
15463
15461
|
pubkey: arenaKey,
|
|
15464
15462
|
isSigner: false,
|
|
15465
15463
|
isWritable: false
|
|
15466
15464
|
});
|
|
15467
|
-
solanaTx = addTransactionMetadata(new VersionedTransaction(message.compileToV0Message(tx.addressLookupTables)), {
|
|
15465
|
+
solanaTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message.compileToV0Message(tx.addressLookupTables)), {
|
|
15468
15466
|
signers: solanaTx.signers,
|
|
15469
15467
|
addressLookupTables: solanaTx.addressLookupTables,
|
|
15470
15468
|
type: solanaTx.type,
|
|
@@ -15502,7 +15500,7 @@ const SinglePoolInstruction = {
|
|
|
15502
15500
|
const mint = findPoolMintAddress(pool);
|
|
15503
15501
|
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
15504
15502
|
const mintAuthority = findPoolMintAuthorityAddress(pool);
|
|
15505
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15503
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15506
15504
|
{
|
|
15507
15505
|
pubkey: voteAccount,
|
|
15508
15506
|
isSigner: false,
|
|
@@ -15534,37 +15532,37 @@ const SinglePoolInstruction = {
|
|
|
15534
15532
|
isWritable: false
|
|
15535
15533
|
},
|
|
15536
15534
|
{
|
|
15537
|
-
pubkey: SYSVAR_RENT_ID,
|
|
15535
|
+
pubkey: require_common.SYSVAR_RENT_ID,
|
|
15538
15536
|
isSigner: false,
|
|
15539
15537
|
isWritable: false
|
|
15540
15538
|
},
|
|
15541
15539
|
{
|
|
15542
|
-
pubkey: SYSVAR_CLOCK_ID,
|
|
15540
|
+
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
15543
15541
|
isSigner: false,
|
|
15544
15542
|
isWritable: false
|
|
15545
15543
|
},
|
|
15546
15544
|
{
|
|
15547
|
-
pubkey: SYSVAR_STAKE_HISTORY_ID,
|
|
15545
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
15548
15546
|
isSigner: false,
|
|
15549
15547
|
isWritable: false
|
|
15550
15548
|
},
|
|
15551
15549
|
{
|
|
15552
|
-
pubkey: STAKE_CONFIG_ID
|
|
15550
|
+
pubkey: __solana_web3_js.STAKE_CONFIG_ID,
|
|
15553
15551
|
isSigner: false,
|
|
15554
15552
|
isWritable: false
|
|
15555
15553
|
},
|
|
15556
15554
|
{
|
|
15557
|
-
pubkey: SYSTEM_PROGRAM_ID,
|
|
15555
|
+
pubkey: require_common.SYSTEM_PROGRAM_ID,
|
|
15558
15556
|
isSigner: false,
|
|
15559
15557
|
isWritable: false
|
|
15560
15558
|
},
|
|
15561
15559
|
{
|
|
15562
|
-
pubkey: TOKEN_PROGRAM_ID,
|
|
15560
|
+
pubkey: __solana_spl_token.TOKEN_PROGRAM_ID,
|
|
15563
15561
|
isSigner: false,
|
|
15564
15562
|
isWritable: false
|
|
15565
15563
|
},
|
|
15566
15564
|
{
|
|
15567
|
-
pubkey: STAKE_PROGRAM_ID,
|
|
15565
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
15568
15566
|
isSigner: false,
|
|
15569
15567
|
isWritable: false
|
|
15570
15568
|
}
|
|
@@ -15573,7 +15571,7 @@ const SinglePoolInstruction = {
|
|
|
15573
15571
|
initializeOnRamp: (pool) => {
|
|
15574
15572
|
const onRamp = findPoolOnRampAddress(pool);
|
|
15575
15573
|
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
15576
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15574
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15577
15575
|
{
|
|
15578
15576
|
pubkey: pool,
|
|
15579
15577
|
isSigner: false,
|
|
@@ -15590,17 +15588,17 @@ const SinglePoolInstruction = {
|
|
|
15590
15588
|
isWritable: false
|
|
15591
15589
|
},
|
|
15592
15590
|
{
|
|
15593
|
-
pubkey: SYSVAR_RENT_ID,
|
|
15591
|
+
pubkey: require_common.SYSVAR_RENT_ID,
|
|
15594
15592
|
isSigner: false,
|
|
15595
15593
|
isWritable: false
|
|
15596
15594
|
},
|
|
15597
15595
|
{
|
|
15598
|
-
pubkey: SYSTEM_PROGRAM_ID,
|
|
15596
|
+
pubkey: require_common.SYSTEM_PROGRAM_ID,
|
|
15599
15597
|
isSigner: false,
|
|
15600
15598
|
isWritable: false
|
|
15601
15599
|
},
|
|
15602
15600
|
{
|
|
15603
|
-
pubkey: STAKE_PROGRAM_ID,
|
|
15601
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
15604
15602
|
isSigner: false,
|
|
15605
15603
|
isWritable: false
|
|
15606
15604
|
}
|
|
@@ -15611,7 +15609,7 @@ const SinglePoolInstruction = {
|
|
|
15611
15609
|
const mint = findPoolMintAddress(pool);
|
|
15612
15610
|
const stakeAuthority = findPoolStakeAuthorityAddress(pool);
|
|
15613
15611
|
const mintAuthority = findPoolMintAuthorityAddress(pool);
|
|
15614
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15612
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15615
15613
|
{
|
|
15616
15614
|
pubkey: pool,
|
|
15617
15615
|
isSigner: false,
|
|
@@ -15653,22 +15651,22 @@ const SinglePoolInstruction = {
|
|
|
15653
15651
|
isWritable: true
|
|
15654
15652
|
},
|
|
15655
15653
|
{
|
|
15656
|
-
pubkey: SYSVAR_CLOCK_ID,
|
|
15654
|
+
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
15657
15655
|
isSigner: false,
|
|
15658
15656
|
isWritable: false
|
|
15659
15657
|
},
|
|
15660
15658
|
{
|
|
15661
|
-
pubkey: SYSVAR_STAKE_HISTORY_ID,
|
|
15659
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
15662
15660
|
isSigner: false,
|
|
15663
15661
|
isWritable: false
|
|
15664
15662
|
},
|
|
15665
15663
|
{
|
|
15666
|
-
pubkey: TOKEN_PROGRAM_ID,
|
|
15664
|
+
pubkey: __solana_spl_token.TOKEN_PROGRAM_ID,
|
|
15667
15665
|
isSigner: false,
|
|
15668
15666
|
isWritable: false
|
|
15669
15667
|
},
|
|
15670
15668
|
{
|
|
15671
|
-
pubkey: STAKE_PROGRAM_ID,
|
|
15669
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
15672
15670
|
isSigner: false,
|
|
15673
15671
|
isWritable: false
|
|
15674
15672
|
}
|
|
@@ -15683,9 +15681,9 @@ const SinglePoolInstruction = {
|
|
|
15683
15681
|
const data = Buffer.concat([
|
|
15684
15682
|
Buffer.from([SinglePoolInstructionType.WithdrawStake]),
|
|
15685
15683
|
userStakeAuthority.toBuffer(),
|
|
15686
|
-
Buffer.from(new BN
|
|
15684
|
+
Buffer.from(new bn_js.BN(rawAmount.toString()).toArray("le", 8))
|
|
15687
15685
|
]);
|
|
15688
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15686
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15689
15687
|
{
|
|
15690
15688
|
pubkey: pool,
|
|
15691
15689
|
isSigner: false,
|
|
@@ -15722,17 +15720,17 @@ const SinglePoolInstruction = {
|
|
|
15722
15720
|
isWritable: true
|
|
15723
15721
|
},
|
|
15724
15722
|
{
|
|
15725
|
-
pubkey: SYSVAR_CLOCK_ID,
|
|
15723
|
+
pubkey: require_common.SYSVAR_CLOCK_ID,
|
|
15726
15724
|
isSigner: false,
|
|
15727
15725
|
isWritable: false
|
|
15728
15726
|
},
|
|
15729
15727
|
{
|
|
15730
|
-
pubkey: TOKEN_PROGRAM_ID,
|
|
15728
|
+
pubkey: __solana_spl_token.TOKEN_PROGRAM_ID,
|
|
15731
15729
|
isSigner: false,
|
|
15732
15730
|
isWritable: false
|
|
15733
15731
|
},
|
|
15734
15732
|
{
|
|
15735
|
-
pubkey: STAKE_PROGRAM_ID,
|
|
15733
|
+
pubkey: require_common.STAKE_PROGRAM_ID,
|
|
15736
15734
|
isSigner: false,
|
|
15737
15735
|
isWritable: false
|
|
15738
15736
|
}
|
|
@@ -15745,7 +15743,7 @@ const SinglePoolInstruction = {
|
|
|
15745
15743
|
findPoolMplAuthorityAddress(pool),
|
|
15746
15744
|
findMplMetadataAddress(mint)
|
|
15747
15745
|
]);
|
|
15748
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15746
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15749
15747
|
{
|
|
15750
15748
|
pubkey: pool,
|
|
15751
15749
|
isSigner: false,
|
|
@@ -15777,12 +15775,12 @@ const SinglePoolInstruction = {
|
|
|
15777
15775
|
isWritable: true
|
|
15778
15776
|
},
|
|
15779
15777
|
{
|
|
15780
|
-
pubkey: MPL_METADATA_PROGRAM_ID,
|
|
15778
|
+
pubkey: require_common.MPL_METADATA_PROGRAM_ID,
|
|
15781
15779
|
isSigner: false,
|
|
15782
15780
|
isWritable: false
|
|
15783
15781
|
},
|
|
15784
15782
|
{
|
|
15785
|
-
pubkey: SYSTEM_PROGRAM_ID,
|
|
15783
|
+
pubkey: require_common.SYSTEM_PROGRAM_ID,
|
|
15786
15784
|
isSigner: false,
|
|
15787
15785
|
isWritable: false
|
|
15788
15786
|
}
|
|
@@ -15810,7 +15808,7 @@ const SinglePoolInstruction = {
|
|
|
15810
15808
|
Buffer.from(new Uint32Array([tokenUri.length]).buffer),
|
|
15811
15809
|
Buffer.from(tokenUri)
|
|
15812
15810
|
]);
|
|
15813
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, [
|
|
15811
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, [
|
|
15814
15812
|
{
|
|
15815
15813
|
pubkey: voteAccount,
|
|
15816
15814
|
isSigner: false,
|
|
@@ -15837,7 +15835,7 @@ const SinglePoolInstruction = {
|
|
|
15837
15835
|
isWritable: true
|
|
15838
15836
|
},
|
|
15839
15837
|
{
|
|
15840
|
-
pubkey: MPL_METADATA_PROGRAM_ID,
|
|
15838
|
+
pubkey: require_common.MPL_METADATA_PROGRAM_ID,
|
|
15841
15839
|
isSigner: false,
|
|
15842
15840
|
isWritable: false
|
|
15843
15841
|
}
|
|
@@ -15851,8 +15849,8 @@ const createTransactionInstruction = (programId, keys, data) => {
|
|
|
15851
15849
|
data
|
|
15852
15850
|
};
|
|
15853
15851
|
};
|
|
15854
|
-
const findPda = (baseAddress, prefix, programId = SINGLE_POOL_PROGRAM_ID) => {
|
|
15855
|
-
const [pda] = PublicKey.findProgramAddressSync([Buffer.from(prefix), baseAddress.toBuffer()], programId);
|
|
15852
|
+
const findPda = (baseAddress, prefix, programId = require_common.SINGLE_POOL_PROGRAM_ID) => {
|
|
15853
|
+
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from(prefix), baseAddress.toBuffer()], programId);
|
|
15856
15854
|
return pda;
|
|
15857
15855
|
};
|
|
15858
15856
|
const findPoolMintAddressByVoteAccount = (voteAccountAddress) => findPda(findPoolAddress(voteAccountAddress), "mint");
|
|
@@ -15864,11 +15862,11 @@ const findPoolMintAuthorityAddress = (poolAddress) => findPda(poolAddress, "mint
|
|
|
15864
15862
|
const findPoolMplAuthorityAddress = (poolAddress) => findPda(poolAddress, "mpl_authority");
|
|
15865
15863
|
const findPoolOnRampAddress = (poolAddress) => findPda(poolAddress, "onramp");
|
|
15866
15864
|
const findMplMetadataAddress = async (poolMintAddress) => {
|
|
15867
|
-
const [pda] = PublicKey.findProgramAddressSync([
|
|
15865
|
+
const [pda] = __solana_web3_js.PublicKey.findProgramAddressSync([
|
|
15868
15866
|
Buffer.from("metadata"),
|
|
15869
|
-
MPL_METADATA_PROGRAM_ID.toBuffer(),
|
|
15867
|
+
require_common.MPL_METADATA_PROGRAM_ID.toBuffer(),
|
|
15870
15868
|
poolMintAddress.toBuffer()
|
|
15871
|
-
], MPL_METADATA_PROGRAM_ID);
|
|
15869
|
+
], require_common.MPL_METADATA_PROGRAM_ID);
|
|
15872
15870
|
return pda;
|
|
15873
15871
|
};
|
|
15874
15872
|
const SINGLE_POOL_ACCOUNT_SIZE = BigInt(33);
|
|
@@ -15876,7 +15874,7 @@ const STAKE_ACCOUNT_SIZE = BigInt(200);
|
|
|
15876
15874
|
const MINT_SIZE = BigInt(82);
|
|
15877
15875
|
async function initializeStakedPoolTx(connection, payer, voteAccountAddress) {
|
|
15878
15876
|
const instructions$3 = await initializeStakedPoolIxs(connection, payer, voteAccountAddress);
|
|
15879
|
-
const tx = new Transaction().add(...instructions$3);
|
|
15877
|
+
const tx = new __solana_web3_js.Transaction().add(...instructions$3);
|
|
15880
15878
|
return tx;
|
|
15881
15879
|
}
|
|
15882
15880
|
async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
|
|
@@ -15892,22 +15890,22 @@ async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
|
|
|
15892
15890
|
]);
|
|
15893
15891
|
const minimumDelegation = minimumDelegationObj.value;
|
|
15894
15892
|
const instructions$3 = [];
|
|
15895
|
-
instructions$3.push(SystemProgram.transfer({
|
|
15893
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
15896
15894
|
fromPubkey: payer,
|
|
15897
15895
|
toPubkey: poolAddress,
|
|
15898
15896
|
lamports: poolRent
|
|
15899
15897
|
}));
|
|
15900
|
-
instructions$3.push(SystemProgram.transfer({
|
|
15898
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
15901
15899
|
fromPubkey: payer,
|
|
15902
15900
|
toPubkey: stakeAddress,
|
|
15903
|
-
lamports: stakeRent + minimumDelegation + LAMPORTS_PER_SOL * 1
|
|
15901
|
+
lamports: stakeRent + minimumDelegation + __solana_web3_js.LAMPORTS_PER_SOL * 1
|
|
15904
15902
|
}));
|
|
15905
|
-
instructions$3.push(SystemProgram.transfer({
|
|
15903
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
15906
15904
|
fromPubkey: payer,
|
|
15907
15905
|
toPubkey: onRampAddress,
|
|
15908
15906
|
lamports: stakeRent
|
|
15909
15907
|
}));
|
|
15910
|
-
instructions$3.push(SystemProgram.transfer({
|
|
15908
|
+
instructions$3.push(__solana_web3_js.SystemProgram.transfer({
|
|
15911
15909
|
fromPubkey: payer,
|
|
15912
15910
|
toPubkey: mintAddress,
|
|
15913
15911
|
lamports: mintRent
|
|
@@ -15920,8 +15918,8 @@ async function initializeStakedPoolIxs(connection, payer, voteAccountAddress) {
|
|
|
15920
15918
|
const createAccountIx = (from, newAccount, lamports, space, programAddress) => {
|
|
15921
15919
|
const data = Buffer.concat([
|
|
15922
15920
|
Buffer.from([0]),
|
|
15923
|
-
Buffer.from(new BN
|
|
15924
|
-
Buffer.from(new BN
|
|
15921
|
+
Buffer.from(new bn_js.BN(lamports).toArray("le", 8)),
|
|
15922
|
+
Buffer.from(new bn_js.BN(space).toArray("le", 8)),
|
|
15925
15923
|
programAddress.toBuffer()
|
|
15926
15924
|
]);
|
|
15927
15925
|
const accounts$2 = [{
|
|
@@ -15933,7 +15931,7 @@ const createAccountIx = (from, newAccount, lamports, space, programAddress) => {
|
|
|
15933
15931
|
isSigner: true,
|
|
15934
15932
|
isWritable: true
|
|
15935
15933
|
}];
|
|
15936
|
-
return createTransactionInstruction(SYSTEM_PROGRAM_ID, accounts$2, data);
|
|
15934
|
+
return createTransactionInstruction(require_common.SYSTEM_PROGRAM_ID, accounts$2, data);
|
|
15937
15935
|
};
|
|
15938
15936
|
const createPoolOnrampIx = (voteAccount) => {
|
|
15939
15937
|
const poolAccount = findPoolAddress(voteAccount);
|
|
@@ -15956,25 +15954,25 @@ const createPoolOnrampIx = (voteAccount) => {
|
|
|
15956
15954
|
isWritable: false
|
|
15957
15955
|
},
|
|
15958
15956
|
{
|
|
15959
|
-
pubkey: SYSVAR_RENT_PUBKEY,
|
|
15957
|
+
pubkey: __solana_web3_js.SYSVAR_RENT_PUBKEY,
|
|
15960
15958
|
isSigner: false,
|
|
15961
15959
|
isWritable: false
|
|
15962
15960
|
},
|
|
15963
15961
|
{
|
|
15964
|
-
pubkey: SystemProgram.programId,
|
|
15962
|
+
pubkey: __solana_web3_js.SystemProgram.programId,
|
|
15965
15963
|
isSigner: false,
|
|
15966
15964
|
isWritable: false
|
|
15967
15965
|
},
|
|
15968
15966
|
{
|
|
15969
|
-
pubkey: StakeProgram.programId,
|
|
15967
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
15970
15968
|
isSigner: false,
|
|
15971
15969
|
isWritable: false
|
|
15972
15970
|
}
|
|
15973
15971
|
];
|
|
15974
15972
|
const data = Buffer.from(Uint8Array.of(6));
|
|
15975
|
-
return new TransactionInstruction({
|
|
15973
|
+
return new __solana_web3_js.TransactionInstruction({
|
|
15976
15974
|
keys,
|
|
15977
|
-
programId: SINGLE_POOL_PROGRAM_ID,
|
|
15975
|
+
programId: require_common.SINGLE_POOL_PROGRAM_ID,
|
|
15978
15976
|
data
|
|
15979
15977
|
});
|
|
15980
15978
|
};
|
|
@@ -16010,28 +16008,28 @@ const replenishPoolIx = (voteAccount) => {
|
|
|
16010
16008
|
isWritable: false
|
|
16011
16009
|
},
|
|
16012
16010
|
{
|
|
16013
|
-
pubkey: SYSVAR_CLOCK_PUBKEY,
|
|
16011
|
+
pubkey: __solana_web3_js.SYSVAR_CLOCK_PUBKEY,
|
|
16014
16012
|
isSigner: false,
|
|
16015
16013
|
isWritable: false
|
|
16016
16014
|
},
|
|
16017
16015
|
{
|
|
16018
|
-
pubkey: SYSVAR_STAKE_HISTORY_ID,
|
|
16016
|
+
pubkey: require_common.SYSVAR_STAKE_HISTORY_ID,
|
|
16019
16017
|
isSigner: false,
|
|
16020
16018
|
isWritable: false
|
|
16021
16019
|
},
|
|
16022
16020
|
{
|
|
16023
|
-
pubkey: STAKE_CONFIG_ID
|
|
16021
|
+
pubkey: __solana_web3_js.STAKE_CONFIG_ID,
|
|
16024
16022
|
isSigner: false,
|
|
16025
16023
|
isWritable: false
|
|
16026
16024
|
},
|
|
16027
16025
|
{
|
|
16028
|
-
pubkey: StakeProgram.programId,
|
|
16026
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
16029
16027
|
isSigner: false,
|
|
16030
16028
|
isWritable: false
|
|
16031
16029
|
}
|
|
16032
16030
|
];
|
|
16033
16031
|
const data = Buffer.from(Uint8Array.of(1));
|
|
16034
|
-
return createTransactionInstruction(SINGLE_POOL_PROGRAM_ID, keys, data);
|
|
16032
|
+
return createTransactionInstruction(require_common.SINGLE_POOL_PROGRAM_ID, keys, data);
|
|
16035
16033
|
};
|
|
16036
16034
|
|
|
16037
16035
|
//#endregion
|
|
@@ -16044,13 +16042,13 @@ function computeFreeCollateral(lendrAccount, opts) {
|
|
|
16044
16042
|
const _clamped = opts?.clamped ?? true;
|
|
16045
16043
|
const { assets, liabilities } = computeHealthComponents(lendrAccount, LendrRequirementType.Initial);
|
|
16046
16044
|
const signedFreeCollateral = assets.minus(liabilities);
|
|
16047
|
-
return _clamped ?
|
|
16045
|
+
return _clamped ? bignumber_js.default.max(0, signedFreeCollateral) : signedFreeCollateral;
|
|
16048
16046
|
}
|
|
16049
16047
|
function computeFreeCollateralLegacy(activeBalances, banks, oraclePrices, opts) {
|
|
16050
16048
|
const _clamped = opts?.clamped ?? true;
|
|
16051
16049
|
const { assets, liabilities } = computeHealthComponentsLegacy(activeBalances, banks, oraclePrices, LendrRequirementType.Initial, []);
|
|
16052
16050
|
const signedFreeCollateral = assets.minus(liabilities);
|
|
16053
|
-
return _clamped ?
|
|
16051
|
+
return _clamped ? bignumber_js.default.max(0, signedFreeCollateral) : signedFreeCollateral;
|
|
16054
16052
|
}
|
|
16055
16053
|
function computeHealthComponents(lendrAccount, lendrReqType) {
|
|
16056
16054
|
switch (lendrReqType) {
|
|
@@ -16073,19 +16071,19 @@ function computeHealthComponentsLegacy(activeBalances, banks, oraclePrices, lend
|
|
|
16073
16071
|
const [assets, liabilities] = filteredBalances.map((accountBalance) => {
|
|
16074
16072
|
const bank = banks.get(accountBalance.bankPk.toBase58());
|
|
16075
16073
|
if (!bank) {
|
|
16076
|
-
console.warn(`Bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16077
|
-
return [new
|
|
16074
|
+
console.warn(`Bank ${require_common.shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16075
|
+
return [new bignumber_js.default(0), new bignumber_js.default(0)];
|
|
16078
16076
|
}
|
|
16079
16077
|
const priceInfo = oraclePrices.get(accountBalance.bankPk.toBase58());
|
|
16080
16078
|
if (!priceInfo) {
|
|
16081
|
-
console.warn(`Price info for bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16082
|
-
return [new
|
|
16079
|
+
console.warn(`Price info for bank ${require_common.shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16080
|
+
return [new bignumber_js.default(0), new bignumber_js.default(0)];
|
|
16083
16081
|
}
|
|
16084
16082
|
const { assets: assets$1, liabilities: liabilities$1 } = getBalanceUsdValueWithPriceBias(accountBalance, bank, priceInfo, lendrReqType);
|
|
16085
16083
|
return [assets$1, liabilities$1];
|
|
16086
16084
|
}).reduce(([asset, liability], [d, l]) => {
|
|
16087
16085
|
return [asset.plus(d), liability.plus(l)];
|
|
16088
|
-
}, [new
|
|
16086
|
+
}, [new bignumber_js.default(0), new bignumber_js.default(0)]);
|
|
16089
16087
|
return {
|
|
16090
16088
|
assets,
|
|
16091
16089
|
liabilities
|
|
@@ -16095,19 +16093,19 @@ function computeHealthComponentsWithoutBiasLegacy(activeBalances, banks, oracleP
|
|
|
16095
16093
|
const [assets, liabilities] = activeBalances.map((accountBalance) => {
|
|
16096
16094
|
const bank = banks.get(accountBalance.bankPk.toBase58());
|
|
16097
16095
|
if (!bank) {
|
|
16098
|
-
console.warn(`Bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16099
|
-
return [new
|
|
16096
|
+
console.warn(`Bank ${require_common.shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16097
|
+
return [new bignumber_js.default(0), new bignumber_js.default(0)];
|
|
16100
16098
|
}
|
|
16101
16099
|
const priceInfo = oraclePrices.get(accountBalance.bankPk.toBase58());
|
|
16102
16100
|
if (!priceInfo) {
|
|
16103
|
-
console.warn(`Price info for bank ${shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16104
|
-
return [new
|
|
16101
|
+
console.warn(`Price info for bank ${require_common.shortenAddress(accountBalance.bankPk)} not found, excluding from health computation`);
|
|
16102
|
+
return [new bignumber_js.default(0), new bignumber_js.default(0)];
|
|
16105
16103
|
}
|
|
16106
16104
|
const { assets: assets$1, liabilities: liabilities$1 } = computeBalanceUsdValue(accountBalance, bank, priceInfo, lendrReqType);
|
|
16107
16105
|
return [assets$1, liabilities$1];
|
|
16108
16106
|
}).reduce(([asset, liability], [d, l]) => {
|
|
16109
16107
|
return [asset.plus(d), liability.plus(l)];
|
|
16110
|
-
}, [new
|
|
16108
|
+
}, [new bignumber_js.default(0), new bignumber_js.default(0)]);
|
|
16111
16109
|
return {
|
|
16112
16110
|
assets,
|
|
16113
16111
|
liabilities
|
|
@@ -16123,17 +16121,17 @@ function computeNetApy(lendrAccount, activeBalances, banks, oraclePrices) {
|
|
|
16123
16121
|
const apr = activeBalances.reduce((weightedApr, balance) => {
|
|
16124
16122
|
const bank = banks.get(balance.bankPk.toBase58());
|
|
16125
16123
|
if (!bank) {
|
|
16126
|
-
console.warn(`Bank ${shortenAddress(balance.bankPk)} not found, excluding from APY computation`);
|
|
16124
|
+
console.warn(`Bank ${require_common.shortenAddress(balance.bankPk)} not found, excluding from APY computation`);
|
|
16127
16125
|
return weightedApr;
|
|
16128
16126
|
}
|
|
16129
16127
|
const priceInfo = oraclePrices.get(balance.bankPk.toBase58());
|
|
16130
16128
|
if (!priceInfo) {
|
|
16131
|
-
console.warn(`Price info for bank ${shortenAddress(balance.bankPk)} not found, excluding from APY computation`);
|
|
16129
|
+
console.warn(`Price info for bank ${require_common.shortenAddress(balance.bankPk)} not found, excluding from APY computation`);
|
|
16132
16130
|
return weightedApr;
|
|
16133
16131
|
}
|
|
16134
16132
|
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);
|
|
16133
|
+
}, new bignumber_js.default(0)).toNumber();
|
|
16134
|
+
return require_common.aprToApy(apr);
|
|
16137
16135
|
}
|
|
16138
16136
|
/**
|
|
16139
16137
|
* Lendr Balance Computes
|
|
@@ -16164,8 +16162,8 @@ function computeQuantity(balance, bank) {
|
|
|
16164
16162
|
};
|
|
16165
16163
|
}
|
|
16166
16164
|
function computeQuantityUi(balance, bank) {
|
|
16167
|
-
const assetsQuantity = new
|
|
16168
|
-
const liabilitiesQuantity = new
|
|
16165
|
+
const assetsQuantity = new bignumber_js.default(require_common.nativeToUi(getAssetQuantity(bank, balance.assetShares), bank.mintDecimals));
|
|
16166
|
+
const liabilitiesQuantity = new bignumber_js.default(require_common.nativeToUi(getLiabilityQuantity(bank, balance.liabilityShares), bank.mintDecimals));
|
|
16169
16167
|
return {
|
|
16170
16168
|
assets: assetsQuantity,
|
|
16171
16169
|
liabilities: liabilitiesQuantity
|
|
@@ -16183,13 +16181,13 @@ function computeClaimedEmissions(balance, bank, currentTimestamp) {
|
|
|
16183
16181
|
}
|
|
16184
16182
|
if (balanceAmount) {
|
|
16185
16183
|
const lastUpdate = balance.lastUpdate;
|
|
16186
|
-
const period = new
|
|
16187
|
-
const emissionsRate = new
|
|
16184
|
+
const period = new bignumber_js.default(currentTimestamp - lastUpdate);
|
|
16185
|
+
const emissionsRate = new bignumber_js.default(bank.emissionsRate);
|
|
16188
16186
|
const emissions = period.times(balanceAmount).times(emissionsRate).div(31536e3 * 10 ** bank.mintDecimals);
|
|
16189
|
-
const emissionsReal =
|
|
16187
|
+
const emissionsReal = bignumber_js.default.min(emissions, new bignumber_js.default(bank.emissionsRemaining));
|
|
16190
16188
|
return emissionsReal;
|
|
16191
16189
|
}
|
|
16192
|
-
return new
|
|
16190
|
+
return new bignumber_js.default(0);
|
|
16193
16191
|
}
|
|
16194
16192
|
function computeTotalOutstandingEmissions(balance, bank) {
|
|
16195
16193
|
const claimedEmissions = balance.emissionsOutstanding;
|
|
@@ -16227,7 +16225,7 @@ function computeHealthCheckAccounts(balances, banks, mandatoryBanks = [], exclud
|
|
|
16227
16225
|
return projectedActiveBanks;
|
|
16228
16226
|
}
|
|
16229
16227
|
function computeHealthAccountMetas(banksToInclude, bankMetadataMap, enableSorting = true, bankExtendedMetadata) {
|
|
16230
|
-
const wrapperFn = enableSorting ? composeRemainingAccounts : (banksAndOracles) => banksAndOracles.flat();
|
|
16228
|
+
const wrapperFn = enableSorting ? require_common.composeRemainingAccounts : (banksAndOracles) => banksAndOracles.flat();
|
|
16231
16229
|
const accounts$2 = wrapperFn(banksToInclude.map((bank) => {
|
|
16232
16230
|
const keys = [bank.address, bank.oracleKey];
|
|
16233
16231
|
if (bank.config.assetTag === 2) {
|
|
@@ -16239,7 +16237,7 @@ function computeHealthAccountMetas(banksToInclude, bankMetadataMap, enableSortin
|
|
|
16239
16237
|
if (!validatorVoteAccount) {
|
|
16240
16238
|
throw Error(`no validatorVoteAccount on Bank metadata: ${bank.address.toBase58()}`);
|
|
16241
16239
|
}
|
|
16242
|
-
const pool = findPoolAddress(new PublicKey(validatorVoteAccount));
|
|
16240
|
+
const pool = findPoolAddress(new __solana_web3_js.PublicKey(validatorVoteAccount));
|
|
16243
16241
|
const solPool = findPoolStakeAddress(pool);
|
|
16244
16242
|
const lstMint = findPoolMintAddress(pool);
|
|
16245
16243
|
keys.push(lstMint, solPool);
|
|
@@ -16268,7 +16266,7 @@ var Balance = class Balance {
|
|
|
16268
16266
|
return new Balance(balance.active, balance.bankPk, balance.assetShares, balance.liabilityShares, balance.emissionsOutstanding, balance.lastUpdate);
|
|
16269
16267
|
}
|
|
16270
16268
|
static createEmpty(bankPk) {
|
|
16271
|
-
return new Balance(false, bankPk, new
|
|
16269
|
+
return new Balance(false, bankPk, new bignumber_js.default(0), new bignumber_js.default(0), new bignumber_js.default(0), 0);
|
|
16272
16270
|
}
|
|
16273
16271
|
computeUsdValue(bank, oraclePrice, lendrRequirementType = LendrRequirementType.Equity) {
|
|
16274
16272
|
return computeBalanceUsdValue(this, bank, oraclePrice, lendrRequirementType);
|
|
@@ -16352,15 +16350,15 @@ let AccountFlags = /* @__PURE__ */ function(AccountFlags$1) {
|
|
|
16352
16350
|
//#endregion
|
|
16353
16351
|
//#region src/services/account/utils/deserialize.utils.ts
|
|
16354
16352
|
function decodeAccountRaw(encoded, idl) {
|
|
16355
|
-
const coder = new BorshCoder(idl);
|
|
16353
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
16356
16354
|
return coder.accounts.decode(AccountType.LendrAccount, encoded);
|
|
16357
16355
|
}
|
|
16358
16356
|
function parseBalanceRaw(balanceRaw) {
|
|
16359
16357
|
const active = typeof balanceRaw.active === "number" ? balanceRaw.active === 1 : balanceRaw.active;
|
|
16360
16358
|
const bankPk = balanceRaw.bankPk;
|
|
16361
|
-
const assetShares = wrappedI80F48toBigNumber(balanceRaw.assetShares);
|
|
16362
|
-
const liabilityShares = wrappedI80F48toBigNumber(balanceRaw.liabilityShares);
|
|
16363
|
-
const emissionsOutstanding = wrappedI80F48toBigNumber(balanceRaw.emissionsOutstanding);
|
|
16359
|
+
const assetShares = require_common.wrappedI80F48toBigNumber(balanceRaw.assetShares);
|
|
16360
|
+
const liabilityShares = require_common.wrappedI80F48toBigNumber(balanceRaw.liabilityShares);
|
|
16361
|
+
const emissionsOutstanding = require_common.wrappedI80F48toBigNumber(balanceRaw.emissionsOutstanding);
|
|
16364
16362
|
const lastUpdate = balanceRaw.lastUpdate.toNumber();
|
|
16365
16363
|
return {
|
|
16366
16364
|
active,
|
|
@@ -16406,7 +16404,7 @@ function getActiveAccountFlags(flags) {
|
|
|
16406
16404
|
* Check if an account flag is set
|
|
16407
16405
|
*/
|
|
16408
16406
|
function hasAccountFlag(flags, flag) {
|
|
16409
|
-
return !flags.and(new
|
|
16407
|
+
return !flags.and(new bn_js.default(flag)).isZero();
|
|
16410
16408
|
}
|
|
16411
16409
|
/**
|
|
16412
16410
|
* Convert on-chain health cache flags (BN) to an array of HealthCacheFlags enum values
|
|
@@ -16456,34 +16454,34 @@ function getHealthCacheStatusDescription(flags) {
|
|
|
16456
16454
|
}
|
|
16457
16455
|
function dtoToLendrAccount(lendrAccountDto) {
|
|
16458
16456
|
return {
|
|
16459
|
-
address: new PublicKey(lendrAccountDto.address),
|
|
16460
|
-
group: new PublicKey(lendrAccountDto.group),
|
|
16461
|
-
authority: new PublicKey(lendrAccountDto.authority),
|
|
16457
|
+
address: new __solana_web3_js.PublicKey(lendrAccountDto.address),
|
|
16458
|
+
group: new __solana_web3_js.PublicKey(lendrAccountDto.group),
|
|
16459
|
+
authority: new __solana_web3_js.PublicKey(lendrAccountDto.authority),
|
|
16462
16460
|
balances: lendrAccountDto.balances.map(dtoToBalance),
|
|
16463
16461
|
accountFlags: lendrAccountDto.accountFlags,
|
|
16464
|
-
emissionsDestinationAccount: new PublicKey(lendrAccountDto.emissionsDestinationAccount),
|
|
16462
|
+
emissionsDestinationAccount: new __solana_web3_js.PublicKey(lendrAccountDto.emissionsDestinationAccount),
|
|
16465
16463
|
healthCache: dtoToHealthCache(lendrAccountDto.healthCache)
|
|
16466
16464
|
};
|
|
16467
16465
|
}
|
|
16468
16466
|
function dtoToBalance(balanceDto) {
|
|
16469
16467
|
return {
|
|
16470
16468
|
active: balanceDto.active,
|
|
16471
|
-
bankPk: new PublicKey(balanceDto.bankPk),
|
|
16472
|
-
assetShares: new
|
|
16473
|
-
liabilityShares: new
|
|
16474
|
-
emissionsOutstanding: new
|
|
16469
|
+
bankPk: new __solana_web3_js.PublicKey(balanceDto.bankPk),
|
|
16470
|
+
assetShares: new bignumber_js.default(balanceDto.assetShares),
|
|
16471
|
+
liabilityShares: new bignumber_js.default(balanceDto.liabilityShares),
|
|
16472
|
+
emissionsOutstanding: new bignumber_js.default(balanceDto.emissionsOutstanding),
|
|
16475
16473
|
lastUpdate: balanceDto.lastUpdate
|
|
16476
16474
|
};
|
|
16477
16475
|
}
|
|
16478
16476
|
function dtoToHealthCache(healthCacheDto) {
|
|
16479
16477
|
return {
|
|
16480
|
-
assetValue: new
|
|
16481
|
-
liabilityValue: new
|
|
16482
|
-
assetValueMaint: new
|
|
16483
|
-
liabilityValueMaint: new
|
|
16484
|
-
assetValueEquity: new
|
|
16485
|
-
liabilityValueEquity: new
|
|
16486
|
-
timestamp: new
|
|
16478
|
+
assetValue: new bignumber_js.default(healthCacheDto.assetValue),
|
|
16479
|
+
liabilityValue: new bignumber_js.default(healthCacheDto.liabilityValue),
|
|
16480
|
+
assetValueMaint: new bignumber_js.default(healthCacheDto.assetValueMaint),
|
|
16481
|
+
liabilityValueMaint: new bignumber_js.default(healthCacheDto.liabilityValueMaint),
|
|
16482
|
+
assetValueEquity: new bignumber_js.default(healthCacheDto.assetValueEquity),
|
|
16483
|
+
liabilityValueEquity: new bignumber_js.default(healthCacheDto.liabilityValueEquity),
|
|
16484
|
+
timestamp: new bignumber_js.default(healthCacheDto.timestamp),
|
|
16487
16485
|
flags: healthCacheDto.flags,
|
|
16488
16486
|
prices: healthCacheDto.prices,
|
|
16489
16487
|
simulationFailed: healthCacheDto.simulationFailed
|
|
@@ -16670,7 +16668,7 @@ const fetchLendrAccountData = async (program, lendrAccountPk, bankMap, oraclePri
|
|
|
16670
16668
|
* Convert numeric flag to BN for Solana compatibility
|
|
16671
16669
|
*/
|
|
16672
16670
|
function accountFlagToBN(flag) {
|
|
16673
|
-
return new
|
|
16671
|
+
return new bn_js.default(flag);
|
|
16674
16672
|
}
|
|
16675
16673
|
function lendrAccountToDto(lendrAccount) {
|
|
16676
16674
|
return {
|
|
@@ -16739,14 +16737,14 @@ async function simulateAccountHealthCacheWithFallback(props) {
|
|
|
16739
16737
|
balances: props.balances,
|
|
16740
16738
|
bankMetadataMap: props.bankMetadataMap
|
|
16741
16739
|
});
|
|
16742
|
-
simulatedAccount.healthCache.assetValueEquity = bigNumberToWrappedI80F48(assetValueEquity);
|
|
16743
|
-
simulatedAccount.healthCache.liabilityValueEquity = bigNumberToWrappedI80F48(liabilityValueEquity);
|
|
16740
|
+
simulatedAccount.healthCache.assetValueEquity = require_common.bigNumberToWrappedI80F48(assetValueEquity);
|
|
16741
|
+
simulatedAccount.healthCache.liabilityValueEquity = require_common.bigNumberToWrappedI80F48(liabilityValueEquity);
|
|
16744
16742
|
lendrAccount = LendrAccount.fromAccountParsed(props.lendrAccount.address, simulatedAccount);
|
|
16745
16743
|
} catch (e) {
|
|
16746
16744
|
console.log("e", e);
|
|
16747
16745
|
const { assets: assetValueMaint, liabilities: liabilityValueMaint } = computeHealthComponentsLegacy(activeBalances, props.bankMap, props.oraclePrices, LendrRequirementType.Maintenance);
|
|
16748
16746
|
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
|
|
16747
|
+
lendrAccount.setHealthCache(new HealthCache(assetValueInitial, liabilityValueInitial, assetValueMaint, liabilityValueMaint, assetValueEquity, liabilityValueEquity, new bignumber_js.default(0), [], [], true));
|
|
16750
16748
|
if (e instanceof HealthCacheSimulationError) {
|
|
16751
16749
|
return {
|
|
16752
16750
|
lendrAccount,
|
|
@@ -16760,10 +16758,10 @@ async function simulateAccountHealthCache(props) {
|
|
|
16760
16758
|
const { program, bankMap, oraclePrices, lendrAccountPk, balances, bankMetadataMap } = props;
|
|
16761
16759
|
const activeBalances = balances.filter((b) => b.active);
|
|
16762
16760
|
const { stalePythFeeds, staleSwbOracles } = getActiveStaleBanks(activeBalances, bankMap, [], oraclePrices, 30);
|
|
16763
|
-
const computeIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 });
|
|
16761
|
+
const computeIx = __solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 });
|
|
16764
16762
|
const blockhash = (await program.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
16765
|
-
const fundAccountIx = SystemProgram.transfer({
|
|
16766
|
-
fromPubkey: new PublicKey("DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD"),
|
|
16763
|
+
const fundAccountIx = __solana_web3_js.SystemProgram.transfer({
|
|
16764
|
+
fromPubkey: new __solana_web3_js.PublicKey("DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD"),
|
|
16767
16765
|
toPubkey: program.provider.publicKey,
|
|
16768
16766
|
lamports: 1e8
|
|
16769
16767
|
});
|
|
@@ -16784,7 +16782,7 @@ async function simulateAccountHealthCache(props) {
|
|
|
16784
16782
|
const pythLut = crankPythIxs.lut ? [crankPythIxs.lut] : [];
|
|
16785
16783
|
const txs = [];
|
|
16786
16784
|
if (crankPythIxs.postInstructions.length > 0) {
|
|
16787
|
-
txs.push(...splitInstructionsToFitTransactions([computeIx], [
|
|
16785
|
+
txs.push(...require_common.splitInstructionsToFitTransactions([computeIx], [
|
|
16788
16786
|
fundAccountIx,
|
|
16789
16787
|
...crankPythIxs.postInstructions.map((ix) => ix.instruction),
|
|
16790
16788
|
...crankPythIxs.closeInstructions.map((ix) => ix.instruction)
|
|
@@ -16794,19 +16792,19 @@ async function simulateAccountHealthCache(props) {
|
|
|
16794
16792
|
luts: [...crankSwbIxs.luts, ...pythLut]
|
|
16795
16793
|
}));
|
|
16796
16794
|
}
|
|
16797
|
-
const messageV0 = new TransactionMessage({
|
|
16795
|
+
const messageV0 = new __solana_web3_js.TransactionMessage({
|
|
16798
16796
|
payerKey: program.provider.publicKey,
|
|
16799
16797
|
recentBlockhash: blockhash,
|
|
16800
16798
|
instructions: [...crankSwbIxs.instructions]
|
|
16801
16799
|
}).compileToV0Message([...crankSwbIxs.luts]);
|
|
16802
|
-
const swbTx = new VersionedTransaction(messageV0);
|
|
16800
|
+
const swbTx = new __solana_web3_js.VersionedTransaction(messageV0);
|
|
16803
16801
|
txs.push(swbTx);
|
|
16804
|
-
const healthTx = new TransactionMessage({
|
|
16802
|
+
const healthTx = new __solana_web3_js.TransactionMessage({
|
|
16805
16803
|
payerKey: program.provider.publicKey,
|
|
16806
16804
|
recentBlockhash: blockhash,
|
|
16807
16805
|
instructions: [...healthPulseIxs.instructions]
|
|
16808
16806
|
}).compileToV0Message([]);
|
|
16809
|
-
const healthTxV0 = new VersionedTransaction(healthTx);
|
|
16807
|
+
const healthTxV0 = new __solana_web3_js.VersionedTransaction(healthTx);
|
|
16810
16808
|
txs.push(healthTxV0);
|
|
16811
16809
|
if (txs.length > 5) {
|
|
16812
16810
|
console.error("Too many transactions", txs.length);
|
|
@@ -16823,12 +16821,12 @@ async function simulateAccountHealthCache(props) {
|
|
|
16823
16821
|
console.log("LendrAccountPost healthCache internalErr", lendrAccountPost.healthCache.internalErr);
|
|
16824
16822
|
console.log("LendrAccountPost healthCache lndrErr", lendrAccountPost.healthCache.lendrErr);
|
|
16825
16823
|
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();
|
|
16824
|
+
const assetValue = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.assetValue).isZero();
|
|
16825
|
+
const liabilityValue = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.liabilityValue).isZero();
|
|
16826
|
+
const assetValueEquity = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.assetValueEquity).isZero();
|
|
16827
|
+
const liabilityValueEquity = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.liabilityValueEquity).isZero();
|
|
16828
|
+
const assetValueMaint = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.assetValueMaint).isZero();
|
|
16829
|
+
const liabilityValueMaint = !require_common.wrappedI80F48toBigNumber(lendrAccountPost.healthCache.liabilityValueMaint).isZero();
|
|
16832
16830
|
if (assetValue && liabilityValue && assetValueEquity && liabilityValueEquity && assetValueMaint && liabilityValueMaint) {
|
|
16833
16831
|
return lendrAccountPost;
|
|
16834
16832
|
}
|
|
@@ -16864,15 +16862,15 @@ async function createUpdateFeedIx(props) {
|
|
|
16864
16862
|
*/
|
|
16865
16863
|
async function createLendrAccountTx(props) {
|
|
16866
16864
|
const authority = props.lendrAccount?.authority ?? props.lendrClient.provider.publicKey;
|
|
16867
|
-
const lendrAccountKeypair = Keypair.generate();
|
|
16868
|
-
const dummyWrappedI80F48 = bigNumberToWrappedI80F48(new
|
|
16865
|
+
const lendrAccountKeypair = __solana_web3_js.Keypair.generate();
|
|
16866
|
+
const dummyWrappedI80F48 = require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0));
|
|
16869
16867
|
const dummyBalances = Array(15).fill({
|
|
16870
16868
|
active: false,
|
|
16871
|
-
bankPk: new PublicKey("11111111111111111111111111111111"),
|
|
16869
|
+
bankPk: new __solana_web3_js.PublicKey("11111111111111111111111111111111"),
|
|
16872
16870
|
assetShares: dummyWrappedI80F48,
|
|
16873
16871
|
liabilityShares: dummyWrappedI80F48,
|
|
16874
16872
|
emissionsOutstanding: dummyWrappedI80F48,
|
|
16875
|
-
lastUpdate: new
|
|
16873
|
+
lastUpdate: new bn_js.default(0)
|
|
16876
16874
|
});
|
|
16877
16875
|
const rawAccount = {
|
|
16878
16876
|
group: props.lendrClient.group.address,
|
|
@@ -16915,21 +16913,21 @@ async function createLendrAccountTx(props) {
|
|
|
16915
16913
|
0,
|
|
16916
16914
|
0
|
|
16917
16915
|
] },
|
|
16918
|
-
timestamp: new
|
|
16916
|
+
timestamp: new bn_js.default(0),
|
|
16919
16917
|
flags: 0,
|
|
16920
16918
|
prices: [],
|
|
16921
|
-
assetValueMaint: bigNumberToWrappedI80F48(new
|
|
16922
|
-
liabilityValueMaint: bigNumberToWrappedI80F48(new
|
|
16923
|
-
assetValueEquity: bigNumberToWrappedI80F48(new
|
|
16924
|
-
liabilityValueEquity: bigNumberToWrappedI80F48(new
|
|
16919
|
+
assetValueMaint: require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0)),
|
|
16920
|
+
liabilityValueMaint: require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0)),
|
|
16921
|
+
assetValueEquity: require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0)),
|
|
16922
|
+
liabilityValueEquity: require_common.bigNumberToWrappedI80F48(new bignumber_js.default(0)),
|
|
16925
16923
|
errIndex: 0,
|
|
16926
16924
|
internalErr: 0,
|
|
16927
16925
|
internalBankruptcyErr: 0,
|
|
16928
16926
|
internalLiqErr: 0,
|
|
16929
16927
|
lendrErr: 0
|
|
16930
16928
|
},
|
|
16931
|
-
emissionsDestinationAccount: new PublicKey("11111111111111111111111111111111"),
|
|
16932
|
-
accountFlags: new
|
|
16929
|
+
emissionsDestinationAccount: new __solana_web3_js.PublicKey("11111111111111111111111111111111"),
|
|
16930
|
+
accountFlags: new bn_js.default([
|
|
16933
16931
|
0,
|
|
16934
16932
|
0,
|
|
16935
16933
|
0
|
|
@@ -16997,28 +16995,28 @@ function getActiveStaleBanks(balances, banks, additionalBanks, oraclePrices, max
|
|
|
16997
16995
|
//#endregion
|
|
16998
16996
|
//#region src/services/group/group.service.ts
|
|
16999
16997
|
async function makeEnableFlashLoanForAccountIx(program, lendrAccountAddress) {
|
|
17000
|
-
const ix = await instructions_default.makeSetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new
|
|
16998
|
+
const ix = await instructions_default.makeSetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new bn_js.default(require_common.FLASHLOAN_ENABLED_FLAG) });
|
|
17001
16999
|
return {
|
|
17002
17000
|
instructions: [ix],
|
|
17003
17001
|
keys: []
|
|
17004
17002
|
};
|
|
17005
17003
|
}
|
|
17006
17004
|
async function makeDisableFlashLoanForAccountIx(program, lendrAccountAddress) {
|
|
17007
|
-
const ix = await instructions_default.makeUnsetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new
|
|
17005
|
+
const ix = await instructions_default.makeUnsetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new bn_js.default(require_common.FLASHLOAN_ENABLED_FLAG) });
|
|
17008
17006
|
return {
|
|
17009
17007
|
instructions: [ix],
|
|
17010
17008
|
keys: []
|
|
17011
17009
|
};
|
|
17012
17010
|
}
|
|
17013
17011
|
async function makeEnableAccountTransferForAccountIx(program, lendrAccountAddress) {
|
|
17014
|
-
const ix = await instructions_default.makeSetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new
|
|
17012
|
+
const ix = await instructions_default.makeSetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new bn_js.default(require_common.TRANSFER_ACCOUNT_AUTHORITY_FLAG) });
|
|
17015
17013
|
return {
|
|
17016
17014
|
instructions: [ix],
|
|
17017
17015
|
keys: []
|
|
17018
17016
|
};
|
|
17019
17017
|
}
|
|
17020
17018
|
async function makeDisableAccountTransferForAccountIx(program, lendrAccountAddress) {
|
|
17021
|
-
const ix = await instructions_default.makeUnsetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new
|
|
17019
|
+
const ix = await instructions_default.makeUnsetAccountFlagIx(program, { lendrAccount: lendrAccountAddress }, { flag: new bn_js.default(require_common.TRANSFER_ACCOUNT_AUTHORITY_FLAG) });
|
|
17022
17020
|
return {
|
|
17023
17021
|
instructions: [ix],
|
|
17024
17022
|
keys: []
|
|
@@ -17032,7 +17030,7 @@ async function makePoolConfigureBankIx(program, bank, args) {
|
|
|
17032
17030
|
};
|
|
17033
17031
|
}
|
|
17034
17032
|
async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddress, feePayer, pythOracle) {
|
|
17035
|
-
const [settingsKey] = PublicKey.findProgramAddressSync([Buffer.from("staked_settings", "utf-8"), group.toBuffer()], program.programId);
|
|
17033
|
+
const [settingsKey] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("staked_settings", "utf-8"), group.toBuffer()], program.programId);
|
|
17036
17034
|
const poolAddress = findPoolAddress(voteAccountAddress);
|
|
17037
17035
|
const solPool = findPoolStakeAddress(poolAddress);
|
|
17038
17036
|
const lstMint = findPoolMintAddress(poolAddress);
|
|
@@ -17054,25 +17052,25 @@ async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddr
|
|
|
17054
17052
|
isWritable: false
|
|
17055
17053
|
},
|
|
17056
17054
|
{
|
|
17057
|
-
pubkey: SYSVAR_RENT_PUBKEY,
|
|
17055
|
+
pubkey: __solana_web3_js.SYSVAR_RENT_PUBKEY,
|
|
17058
17056
|
isSigner: false,
|
|
17059
17057
|
isWritable: false
|
|
17060
17058
|
},
|
|
17061
17059
|
{
|
|
17062
|
-
pubkey: SystemProgram.programId,
|
|
17060
|
+
pubkey: __solana_web3_js.SystemProgram.programId,
|
|
17063
17061
|
isSigner: false,
|
|
17064
17062
|
isWritable: false
|
|
17065
17063
|
},
|
|
17066
17064
|
{
|
|
17067
|
-
pubkey: StakeProgram.programId,
|
|
17065
|
+
pubkey: __solana_web3_js.StakeProgram.programId,
|
|
17068
17066
|
isSigner: false,
|
|
17069
17067
|
isWritable: false
|
|
17070
17068
|
}
|
|
17071
17069
|
];
|
|
17072
17070
|
const data = Buffer.from(Uint8Array.of(6));
|
|
17073
|
-
const onrampIx = new TransactionInstruction({
|
|
17071
|
+
const onrampIx = new __solana_web3_js.TransactionInstruction({
|
|
17074
17072
|
keys,
|
|
17075
|
-
programId: SINGLE_POOL_PROGRAM_ID,
|
|
17073
|
+
programId: require_common.SINGLE_POOL_PROGRAM_ID,
|
|
17076
17074
|
data
|
|
17077
17075
|
});
|
|
17078
17076
|
const remainingKeys = [
|
|
@@ -17090,13 +17088,13 @@ async function makeAddPermissionlessStakedBankIx(program, group, voteAccountAddr
|
|
|
17090
17088
|
pubkey: key,
|
|
17091
17089
|
isSigner: false,
|
|
17092
17090
|
isWritable: false
|
|
17093
|
-
})), { seed: new
|
|
17091
|
+
})), { seed: new bn_js.default(0) });
|
|
17094
17092
|
return {
|
|
17095
17093
|
instructions: [ix],
|
|
17096
17094
|
keys: []
|
|
17097
17095
|
};
|
|
17098
17096
|
}
|
|
17099
|
-
async function makePoolAddBankIx(program, group, bank, feePayer, bankMint, bankConfig, tokenProgram = TOKEN_PROGRAM_ID, overrideOpt = {}) {
|
|
17097
|
+
async function makePoolAddBankIx(program, group, bank, feePayer, bankMint, bankConfig, tokenProgram = __solana_spl_token.TOKEN_PROGRAM_ID, overrideOpt = {}) {
|
|
17100
17098
|
const rawBankConfig = serializeBankConfigOpt(bankConfig);
|
|
17101
17099
|
const rawBankConfigCompact = {
|
|
17102
17100
|
...rawBankConfig,
|
|
@@ -17122,8 +17120,8 @@ async function makePoolAddBankIx(program, group, bank, feePayer, bankMint, bankC
|
|
|
17122
17120
|
//#region src/services/group/utils/deserialize.utils.ts
|
|
17123
17121
|
function dtoToGroup(groupDto) {
|
|
17124
17122
|
return {
|
|
17125
|
-
admin: new PublicKey(groupDto.admin),
|
|
17126
|
-
address: new PublicKey(groupDto.address)
|
|
17123
|
+
admin: new __solana_web3_js.PublicKey(groupDto.admin),
|
|
17124
|
+
address: new __solana_web3_js.PublicKey(groupDto.address)
|
|
17127
17125
|
};
|
|
17128
17126
|
}
|
|
17129
17127
|
|
|
@@ -17140,16 +17138,16 @@ function groupToDto(group) {
|
|
|
17140
17138
|
//#region src/services/native-stake/utils/deserialize.utils.ts
|
|
17141
17139
|
function dtoToValidatorStakeGroup(validatorStakeGroupDto) {
|
|
17142
17140
|
return {
|
|
17143
|
-
validator: new PublicKey(validatorStakeGroupDto.validator),
|
|
17144
|
-
poolKey: new PublicKey(validatorStakeGroupDto.poolKey),
|
|
17145
|
-
poolMintKey: new PublicKey(validatorStakeGroupDto.poolMintKey),
|
|
17141
|
+
validator: new __solana_web3_js.PublicKey(validatorStakeGroupDto.validator),
|
|
17142
|
+
poolKey: new __solana_web3_js.PublicKey(validatorStakeGroupDto.poolKey),
|
|
17143
|
+
poolMintKey: new __solana_web3_js.PublicKey(validatorStakeGroupDto.poolMintKey),
|
|
17146
17144
|
totalStake: validatorStakeGroupDto.totalStake,
|
|
17147
17145
|
selectedAccount: {
|
|
17148
|
-
pubkey: new PublicKey(validatorStakeGroupDto.selectedAccount.pubkey),
|
|
17146
|
+
pubkey: new __solana_web3_js.PublicKey(validatorStakeGroupDto.selectedAccount.pubkey),
|
|
17149
17147
|
amount: validatorStakeGroupDto.selectedAccount.amount
|
|
17150
17148
|
},
|
|
17151
17149
|
accounts: validatorStakeGroupDto.accounts.map((account) => ({
|
|
17152
|
-
pubkey: new PublicKey(account.pubkey),
|
|
17150
|
+
pubkey: new __solana_web3_js.PublicKey(account.pubkey),
|
|
17153
17151
|
amount: account.amount
|
|
17154
17152
|
}))
|
|
17155
17153
|
};
|
|
@@ -17173,7 +17171,7 @@ const fetchNativeStakeAccounts = async (connection, publicKey, opts = { filterIn
|
|
|
17173
17171
|
}
|
|
17174
17172
|
try {
|
|
17175
17173
|
const epochInfo = await connection.getEpochInfo();
|
|
17176
|
-
const accounts$2 = await connection.getParsedProgramAccounts(StakeProgram.programId, { filters: [{ memcmp: {
|
|
17174
|
+
const accounts$2 = await connection.getParsedProgramAccounts(__solana_web3_js.StakeProgram.programId, { filters: [{ memcmp: {
|
|
17177
17175
|
offset: 12,
|
|
17178
17176
|
bytes: publicKey.toBase58()
|
|
17179
17177
|
} }] });
|
|
@@ -17181,12 +17179,12 @@ const fetchNativeStakeAccounts = async (connection, publicKey, opts = { filterIn
|
|
|
17181
17179
|
await Promise.all(accounts$2.map(async (acc) => {
|
|
17182
17180
|
const parsedAccount = acc.account.data;
|
|
17183
17181
|
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)) {
|
|
17182
|
+
if (!stakeInfo.stake?.delegation || opts.filterInactive && (Number(stakeInfo.stake.delegation.activationEpoch) >= epochInfo.epoch || stakeInfo.stake.delegation.deactivationEpoch !== require_common.MAX_U64)) {
|
|
17185
17183
|
return;
|
|
17186
17184
|
}
|
|
17187
17185
|
const validatorAddress = stakeInfo.stake.delegation.voter;
|
|
17188
17186
|
const accountPubkey = acc.pubkey;
|
|
17189
|
-
const amount = Number(stakeInfo.stake.delegation.stake) / LAMPORTS_PER_SOL;
|
|
17187
|
+
const amount = Number(stakeInfo.stake.delegation.stake) / __solana_web3_js.LAMPORTS_PER_SOL;
|
|
17190
17188
|
const existingAccounts = validatorMap.get(validatorAddress) || [];
|
|
17191
17189
|
validatorMap.set(validatorAddress, [...existingAccounts, {
|
|
17192
17190
|
pubkey: accountPubkey,
|
|
@@ -17194,7 +17192,7 @@ const fetchNativeStakeAccounts = async (connection, publicKey, opts = { filterIn
|
|
|
17194
17192
|
}]);
|
|
17195
17193
|
}));
|
|
17196
17194
|
return Promise.all(Array.from(validatorMap.entries()).map(async ([validatorAddress, accounts$3]) => {
|
|
17197
|
-
const poolKey = findPoolAddress(new PublicKey(validatorAddress));
|
|
17195
|
+
const poolKey = findPoolAddress(new __solana_web3_js.PublicKey(validatorAddress));
|
|
17198
17196
|
const poolMintKey = findPoolMintAddress(poolKey);
|
|
17199
17197
|
const totalStake = accounts$3.reduce((acc, curr) => acc + curr.amount, 0);
|
|
17200
17198
|
const largestAccount = accounts$3.reduce((acc, curr) => acc.amount > curr.amount ? acc : curr);
|
|
@@ -17203,7 +17201,7 @@ const fetchNativeStakeAccounts = async (connection, publicKey, opts = { filterIn
|
|
|
17203
17201
|
sortedAccounts.unshift(sortedAccounts.splice(sortedAccounts.indexOf(largestAccount), 1)[0]);
|
|
17204
17202
|
}
|
|
17205
17203
|
return {
|
|
17206
|
-
validator: new PublicKey(validatorAddress),
|
|
17204
|
+
validator: new __solana_web3_js.PublicKey(validatorAddress),
|
|
17207
17205
|
poolKey,
|
|
17208
17206
|
poolMintKey,
|
|
17209
17207
|
accounts: sortedAccounts,
|
|
@@ -17236,7 +17234,7 @@ const fetchStakePoolActiveStates = async (connection, validatorVoteAccounts) =>
|
|
|
17236
17234
|
poolStakeAddressRecord[poolStakeAddress.toBase58()] = validatorVoteAccount;
|
|
17237
17235
|
});
|
|
17238
17236
|
const poolStakeAddressKeys = Object.keys(poolStakeAddressRecord);
|
|
17239
|
-
const poolStakeAccounts = Object.fromEntries((await chunkedGetRawMultipleAccountInfoOrdered(connection, poolStakeAddressKeys)).map((ai, index) => [poolStakeAddressRecord[poolStakeAddressKeys[index]], ai?.data || null]));
|
|
17237
|
+
const poolStakeAccounts = Object.fromEntries((await require_common.chunkedGetRawMultipleAccountInfoOrdered(connection, poolStakeAddressKeys)).map((ai, index) => [poolStakeAddressRecord[poolStakeAddressKeys[index]], ai?.data || null]));
|
|
17240
17238
|
validatorVoteAccounts.map((validatorVoteAccount) => {
|
|
17241
17239
|
const stakeAccount = fetchStakeAccount(poolStakeAccounts[validatorVoteAccount.toBase58()]);
|
|
17242
17240
|
const poolMintAddress = poolMintAddressRecord[validatorVoteAccount.toBase58()];
|
|
@@ -17266,17 +17264,17 @@ const fetchStakeAccount = (data) => {
|
|
|
17266
17264
|
offset += 4;
|
|
17267
17265
|
const rentExemptReserve = data.readBigUInt64LE(offset);
|
|
17268
17266
|
offset += 8;
|
|
17269
|
-
const staker = new PublicKey(data.subarray(offset, offset + 32));
|
|
17267
|
+
const staker = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17270
17268
|
offset += 32;
|
|
17271
|
-
const withdrawer = new PublicKey(data.subarray(offset, offset + 32));
|
|
17269
|
+
const withdrawer = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17272
17270
|
offset += 32;
|
|
17273
17271
|
const unixTimestamp = data.readBigUInt64LE(offset);
|
|
17274
17272
|
offset += 8;
|
|
17275
17273
|
const epoch = data.readBigUInt64LE(offset);
|
|
17276
17274
|
offset += 8;
|
|
17277
|
-
const custodian = new PublicKey(data.subarray(offset, offset + 32));
|
|
17275
|
+
const custodian = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17278
17276
|
offset += 32;
|
|
17279
|
-
const voterPubkey = new PublicKey(data.subarray(offset, offset + 32));
|
|
17277
|
+
const voterPubkey = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17280
17278
|
offset += 32;
|
|
17281
17279
|
const stake = data.readBigUInt64LE(offset);
|
|
17282
17280
|
offset += 8;
|
|
@@ -17326,7 +17324,7 @@ const fetchStakePoolMev = async (connection, validatorVoteAccounts) => {
|
|
|
17326
17324
|
const poolStakeAddresses = validatorVoteAccounts.map((validatorVoteAccount) => poolStakeAddressRecord[validatorVoteAccount.toBase58()]);
|
|
17327
17325
|
const onRampAddresses = validatorVoteAccounts.map((validatorVoteAccount) => onRampAddressRecord[validatorVoteAccount.toBase58()]);
|
|
17328
17326
|
const allAddresses = [...poolStakeAddresses, ...onRampAddresses].map((address$2) => address$2.toBase58());
|
|
17329
|
-
return chunkedGetRawMultipleAccountInfoOrdered(connection, allAddresses).then((accountInfos) => {
|
|
17327
|
+
return require_common.chunkedGetRawMultipleAccountInfoOrdered(connection, allAddresses).then((accountInfos) => {
|
|
17330
17328
|
const poolStakeInfos = accountInfos.slice(0, poolStakeAddresses.length);
|
|
17331
17329
|
const onRampInfos = accountInfos.slice(poolStakeAddresses.length);
|
|
17332
17330
|
const rent = 2282280;
|
|
@@ -17388,8 +17386,8 @@ var EmodeSettings = class EmodeSettings {
|
|
|
17388
17386
|
return {
|
|
17389
17387
|
collateralBankEmodeTag: parseEmodeTag(entry.collateralBankEmodeTag),
|
|
17390
17388
|
flags: getActiveEmodeEntryFlags(entry.flags),
|
|
17391
|
-
assetWeightInit: wrappedI80F48toBigNumber(entry.assetWeightInit),
|
|
17392
|
-
assetWeightMaint: wrappedI80F48toBigNumber(entry.assetWeightMaint)
|
|
17389
|
+
assetWeightInit: require_common.wrappedI80F48toBigNumber(entry.assetWeightInit),
|
|
17390
|
+
assetWeightMaint: require_common.wrappedI80F48toBigNumber(entry.assetWeightMaint)
|
|
17393
17391
|
};
|
|
17394
17392
|
});
|
|
17395
17393
|
return new EmodeSettings(emodeTag, timestamp, flags, emodeEntries);
|
|
@@ -17399,7 +17397,7 @@ var EmodeSettings = class EmodeSettings {
|
|
|
17399
17397
|
//#endregion
|
|
17400
17398
|
//#region src/services/bank/utils/deserialize.utils.ts
|
|
17401
17399
|
function decodeBankRaw(encoded, idl) {
|
|
17402
|
-
const coder = new BorshCoder(idl);
|
|
17400
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
17403
17401
|
return coder.accounts.decode(AccountType.Bank, encoded);
|
|
17404
17402
|
}
|
|
17405
17403
|
function parseBankRaw(address$2, accountParsed, feedIdMap, bankMetadata) {
|
|
@@ -17407,28 +17405,28 @@ function parseBankRaw(address$2, accountParsed, feedIdMap, bankMetadata) {
|
|
|
17407
17405
|
const mint = accountParsed.mint;
|
|
17408
17406
|
const mintDecimals = accountParsed.mintDecimals;
|
|
17409
17407
|
const group = accountParsed.group;
|
|
17410
|
-
const assetShareValue = wrappedI80F48toBigNumber(accountParsed.assetShareValue);
|
|
17411
|
-
const liabilityShareValue = wrappedI80F48toBigNumber(accountParsed.liabilityShareValue);
|
|
17408
|
+
const assetShareValue = require_common.wrappedI80F48toBigNumber(accountParsed.assetShareValue);
|
|
17409
|
+
const liabilityShareValue = require_common.wrappedI80F48toBigNumber(accountParsed.liabilityShareValue);
|
|
17412
17410
|
const liquidityVault = accountParsed.liquidityVault;
|
|
17413
17411
|
const liquidityVaultBump = accountParsed.liquidityVaultBump;
|
|
17414
17412
|
const liquidityVaultAuthorityBump = accountParsed.liquidityVaultAuthorityBump;
|
|
17415
17413
|
const insuranceVault = accountParsed.insuranceVault;
|
|
17416
17414
|
const insuranceVaultBump = accountParsed.insuranceVaultBump;
|
|
17417
17415
|
const insuranceVaultAuthorityBump = accountParsed.insuranceVaultAuthorityBump;
|
|
17418
|
-
const collectedInsuranceFeesOutstanding = wrappedI80F48toBigNumber(accountParsed.collectedInsuranceFeesOutstanding);
|
|
17416
|
+
const collectedInsuranceFeesOutstanding = require_common.wrappedI80F48toBigNumber(accountParsed.collectedInsuranceFeesOutstanding);
|
|
17419
17417
|
const feeVault = accountParsed.feeVault;
|
|
17420
17418
|
const feeVaultBump = accountParsed.feeVaultBump;
|
|
17421
17419
|
const feeVaultAuthorityBump = accountParsed.feeVaultAuthorityBump;
|
|
17422
|
-
const collectedGroupFeesOutstanding = wrappedI80F48toBigNumber(accountParsed.collectedGroupFeesOutstanding);
|
|
17420
|
+
const collectedGroupFeesOutstanding = require_common.wrappedI80F48toBigNumber(accountParsed.collectedGroupFeesOutstanding);
|
|
17423
17421
|
const config = parseBankConfigRaw(accountParsed.config);
|
|
17424
17422
|
const lastUpdate = accountParsed.lastUpdate.toNumber();
|
|
17425
|
-
const totalAssetShares = wrappedI80F48toBigNumber(accountParsed.totalAssetShares);
|
|
17426
|
-
const totalLiabilityShares = wrappedI80F48toBigNumber(accountParsed.totalLiabilityShares);
|
|
17423
|
+
const totalAssetShares = require_common.wrappedI80F48toBigNumber(accountParsed.totalAssetShares);
|
|
17424
|
+
const totalLiabilityShares = require_common.wrappedI80F48toBigNumber(accountParsed.totalLiabilityShares);
|
|
17427
17425
|
const emissionsActiveBorrowing = (flags & 1) > 0;
|
|
17428
17426
|
const emissionsActiveLending = (flags & 2) > 0;
|
|
17429
17427
|
const emissionsRate = accountParsed.emissionsRate.toNumber();
|
|
17430
17428
|
const emissionsMint = accountParsed.emissionsMint;
|
|
17431
|
-
const emissionsRemaining = accountParsed.emissionsRemaining ? wrappedI80F48toBigNumber(accountParsed.emissionsRemaining) : new
|
|
17429
|
+
const emissionsRemaining = accountParsed.emissionsRemaining ? require_common.wrappedI80F48toBigNumber(accountParsed.emissionsRemaining) : new bignumber_js.default(0);
|
|
17432
17430
|
const { oracleKey, shardId: pythShardId } = feedIdMap ? findOracleKey(config, feedIdMap) : { oracleKey: config.oracleKeys[0] };
|
|
17433
17431
|
const emode = EmodeSettings.from(accountParsed.emode);
|
|
17434
17432
|
const tokenSymbol = bankMetadata?.tokenSymbol;
|
|
@@ -17467,33 +17465,33 @@ function parseBankRaw(address$2, accountParsed, feedIdMap, bankMetadata) {
|
|
|
17467
17465
|
}
|
|
17468
17466
|
function dtoToBank(bankDto) {
|
|
17469
17467
|
return {
|
|
17470
|
-
address: new PublicKey(bankDto.address),
|
|
17471
|
-
group: new PublicKey(bankDto.group),
|
|
17472
|
-
mint: new PublicKey(bankDto.mint),
|
|
17468
|
+
address: new __solana_web3_js.PublicKey(bankDto.address),
|
|
17469
|
+
group: new __solana_web3_js.PublicKey(bankDto.group),
|
|
17470
|
+
mint: new __solana_web3_js.PublicKey(bankDto.mint),
|
|
17473
17471
|
mintDecimals: bankDto.mintDecimals,
|
|
17474
|
-
assetShareValue: new
|
|
17475
|
-
liabilityShareValue: new
|
|
17476
|
-
liquidityVault: new PublicKey(bankDto.liquidityVault),
|
|
17472
|
+
assetShareValue: new bignumber_js.default(bankDto.assetShareValue),
|
|
17473
|
+
liabilityShareValue: new bignumber_js.default(bankDto.liabilityShareValue),
|
|
17474
|
+
liquidityVault: new __solana_web3_js.PublicKey(bankDto.liquidityVault),
|
|
17477
17475
|
liquidityVaultBump: bankDto.liquidityVaultBump,
|
|
17478
17476
|
liquidityVaultAuthorityBump: bankDto.liquidityVaultAuthorityBump,
|
|
17479
|
-
insuranceVault: new PublicKey(bankDto.insuranceVault),
|
|
17477
|
+
insuranceVault: new __solana_web3_js.PublicKey(bankDto.insuranceVault),
|
|
17480
17478
|
insuranceVaultBump: bankDto.insuranceVaultBump,
|
|
17481
17479
|
insuranceVaultAuthorityBump: bankDto.insuranceVaultAuthorityBump,
|
|
17482
|
-
collectedInsuranceFeesOutstanding: new
|
|
17483
|
-
feeVault: new PublicKey(bankDto.feeVault),
|
|
17480
|
+
collectedInsuranceFeesOutstanding: new bignumber_js.default(bankDto.collectedInsuranceFeesOutstanding),
|
|
17481
|
+
feeVault: new __solana_web3_js.PublicKey(bankDto.feeVault),
|
|
17484
17482
|
feeVaultBump: bankDto.feeVaultBump,
|
|
17485
17483
|
feeVaultAuthorityBump: bankDto.feeVaultAuthorityBump,
|
|
17486
|
-
collectedGroupFeesOutstanding: new
|
|
17484
|
+
collectedGroupFeesOutstanding: new bignumber_js.default(bankDto.collectedGroupFeesOutstanding),
|
|
17487
17485
|
lastUpdate: bankDto.lastUpdate,
|
|
17488
17486
|
config: dtoToBankConfig(bankDto.config),
|
|
17489
|
-
totalAssetShares: new
|
|
17490
|
-
totalLiabilityShares: new
|
|
17487
|
+
totalAssetShares: new bignumber_js.default(bankDto.totalAssetShares),
|
|
17488
|
+
totalLiabilityShares: new bignumber_js.default(bankDto.totalLiabilityShares),
|
|
17491
17489
|
emissionsActiveBorrowing: bankDto.emissionsActiveBorrowing,
|
|
17492
17490
|
emissionsActiveLending: bankDto.emissionsActiveLending,
|
|
17493
17491
|
emissionsRate: bankDto.emissionsRate,
|
|
17494
|
-
emissionsMint: new PublicKey(bankDto.emissionsMint),
|
|
17495
|
-
emissionsRemaining: new
|
|
17496
|
-
oracleKey: new PublicKey(bankDto.oracleKey),
|
|
17492
|
+
emissionsMint: new __solana_web3_js.PublicKey(bankDto.emissionsMint),
|
|
17493
|
+
emissionsRemaining: new bignumber_js.default(bankDto.emissionsRemaining),
|
|
17494
|
+
oracleKey: new __solana_web3_js.PublicKey(bankDto.oracleKey),
|
|
17497
17495
|
pythShardId: bankDto.pythShardId,
|
|
17498
17496
|
emode: dtoToEmodeSettings(bankDto.emode),
|
|
17499
17497
|
tokenSymbol: bankDto.tokenSymbol
|
|
@@ -17508,76 +17506,76 @@ function dtoToEmodeSettings(emodeSettingsDto) {
|
|
|
17508
17506
|
return {
|
|
17509
17507
|
collateralBankEmodeTag: entry.collateralBankEmodeTag,
|
|
17510
17508
|
flags: entry.flags,
|
|
17511
|
-
assetWeightInit: new
|
|
17512
|
-
assetWeightMaint: new
|
|
17509
|
+
assetWeightInit: new bignumber_js.default(entry.assetWeightInit),
|
|
17510
|
+
assetWeightMaint: new bignumber_js.default(entry.assetWeightMaint)
|
|
17513
17511
|
};
|
|
17514
17512
|
})
|
|
17515
17513
|
};
|
|
17516
17514
|
}
|
|
17517
17515
|
function dtoToBankConfig(bankConfigDto) {
|
|
17518
17516
|
return {
|
|
17519
|
-
assetWeightInit: new
|
|
17520
|
-
assetWeightMaint: new
|
|
17521
|
-
liabilityWeightInit: new
|
|
17522
|
-
liabilityWeightMaint: new
|
|
17523
|
-
depositLimit: new
|
|
17524
|
-
borrowLimit: new
|
|
17517
|
+
assetWeightInit: new bignumber_js.default(bankConfigDto.assetWeightInit),
|
|
17518
|
+
assetWeightMaint: new bignumber_js.default(bankConfigDto.assetWeightMaint),
|
|
17519
|
+
liabilityWeightInit: new bignumber_js.default(bankConfigDto.liabilityWeightInit),
|
|
17520
|
+
liabilityWeightMaint: new bignumber_js.default(bankConfigDto.liabilityWeightMaint),
|
|
17521
|
+
depositLimit: new bignumber_js.default(bankConfigDto.depositLimit),
|
|
17522
|
+
borrowLimit: new bignumber_js.default(bankConfigDto.borrowLimit),
|
|
17525
17523
|
riskTier: bankConfigDto.riskTier,
|
|
17526
17524
|
operationalState: bankConfigDto.operationalState,
|
|
17527
|
-
totalAssetValueInitLimit: new
|
|
17525
|
+
totalAssetValueInitLimit: new bignumber_js.default(bankConfigDto.totalAssetValueInitLimit),
|
|
17528
17526
|
assetTag: bankConfigDto.assetTag,
|
|
17529
17527
|
oracleSetup: bankConfigDto.oracleSetup,
|
|
17530
|
-
oracleKeys: bankConfigDto.oracleKeys.map((key) => new PublicKey(key)),
|
|
17528
|
+
oracleKeys: bankConfigDto.oracleKeys.map((key) => new __solana_web3_js.PublicKey(key)),
|
|
17531
17529
|
oracleMaxAge: bankConfigDto.oracleMaxAge,
|
|
17532
17530
|
interestRateConfig: dtoToInterestRateConfig(bankConfigDto.interestRateConfig)
|
|
17533
17531
|
};
|
|
17534
17532
|
}
|
|
17535
17533
|
function dtoToInterestRateConfig(interestRateConfigDto) {
|
|
17536
17534
|
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
|
|
17535
|
+
optimalUtilizationRate: new bignumber_js.default(interestRateConfigDto.optimalUtilizationRate),
|
|
17536
|
+
plateauInterestRate: new bignumber_js.default(interestRateConfigDto.plateauInterestRate),
|
|
17537
|
+
maxInterestRate: new bignumber_js.default(interestRateConfigDto.maxInterestRate),
|
|
17538
|
+
insuranceFeeFixedApr: new bignumber_js.default(interestRateConfigDto.insuranceFeeFixedApr),
|
|
17539
|
+
insuranceIrFee: new bignumber_js.default(interestRateConfigDto.insuranceIrFee),
|
|
17540
|
+
protocolFixedFeeApr: new bignumber_js.default(interestRateConfigDto.protocolFixedFeeApr),
|
|
17541
|
+
protocolIrFee: new bignumber_js.default(interestRateConfigDto.protocolIrFee),
|
|
17542
|
+
protocolOriginationFee: new bignumber_js.default(interestRateConfigDto.protocolOriginationFee)
|
|
17545
17543
|
};
|
|
17546
17544
|
}
|
|
17547
17545
|
function dtoToBankRaw(bankDto) {
|
|
17548
17546
|
return {
|
|
17549
|
-
group: new PublicKey(bankDto.group),
|
|
17550
|
-
mint: new PublicKey(bankDto.mint),
|
|
17547
|
+
group: new __solana_web3_js.PublicKey(bankDto.group),
|
|
17548
|
+
mint: new __solana_web3_js.PublicKey(bankDto.mint),
|
|
17551
17549
|
mintDecimals: bankDto.mintDecimals,
|
|
17552
17550
|
assetShareValue: bankDto.assetShareValue,
|
|
17553
17551
|
liabilityShareValue: bankDto.liabilityShareValue,
|
|
17554
|
-
liquidityVault: new PublicKey(bankDto.liquidityVault),
|
|
17552
|
+
liquidityVault: new __solana_web3_js.PublicKey(bankDto.liquidityVault),
|
|
17555
17553
|
liquidityVaultBump: bankDto.liquidityVaultBump,
|
|
17556
17554
|
liquidityVaultAuthorityBump: bankDto.liquidityVaultAuthorityBump,
|
|
17557
|
-
insuranceVault: new PublicKey(bankDto.insuranceVault),
|
|
17555
|
+
insuranceVault: new __solana_web3_js.PublicKey(bankDto.insuranceVault),
|
|
17558
17556
|
insuranceVaultBump: bankDto.insuranceVaultBump,
|
|
17559
17557
|
insuranceVaultAuthorityBump: bankDto.insuranceVaultAuthorityBump,
|
|
17560
17558
|
collectedInsuranceFeesOutstanding: bankDto.collectedInsuranceFeesOutstanding,
|
|
17561
|
-
feeVault: new PublicKey(bankDto.feeVault),
|
|
17559
|
+
feeVault: new __solana_web3_js.PublicKey(bankDto.feeVault),
|
|
17562
17560
|
feeVaultBump: bankDto.feeVaultBump,
|
|
17563
17561
|
feeVaultAuthorityBump: bankDto.feeVaultAuthorityBump,
|
|
17564
17562
|
collectedGroupFeesOutstanding: bankDto.collectedGroupFeesOutstanding,
|
|
17565
|
-
lastUpdate: new
|
|
17563
|
+
lastUpdate: new bn_js.default(bankDto.lastUpdate),
|
|
17566
17564
|
config: dtoToBankConfigRaw(bankDto.config),
|
|
17567
17565
|
totalAssetShares: bankDto.totalAssetShares,
|
|
17568
17566
|
totalLiabilityShares: bankDto.totalLiabilityShares,
|
|
17569
|
-
flags: new
|
|
17570
|
-
emissionsRate: new
|
|
17567
|
+
flags: new bn_js.default(bankDto.flags),
|
|
17568
|
+
emissionsRate: new bn_js.default(bankDto.emissionsRate),
|
|
17571
17569
|
emissionsRemaining: bankDto.emissionsRemaining,
|
|
17572
|
-
emissionsMint: new PublicKey(bankDto.emissionsMint),
|
|
17570
|
+
emissionsMint: new __solana_web3_js.PublicKey(bankDto.emissionsMint),
|
|
17573
17571
|
emode: dtoToEmodeSettingsRaw(bankDto.emode)
|
|
17574
17572
|
};
|
|
17575
17573
|
}
|
|
17576
17574
|
function dtoToEmodeSettingsRaw(emodeSettingsDto) {
|
|
17577
17575
|
return {
|
|
17578
17576
|
emodeTag: emodeSettingsDto.emodeTag,
|
|
17579
|
-
timestamp: new
|
|
17580
|
-
flags: new
|
|
17577
|
+
timestamp: new bn_js.default(emodeSettingsDto.timestamp),
|
|
17578
|
+
flags: new bn_js.default(emodeSettingsDto.flags),
|
|
17581
17579
|
emodeConfig: { entries: emodeSettingsDto.emodeConfig.entries.map((entry) => {
|
|
17582
17580
|
return {
|
|
17583
17581
|
collateralBankEmodeTag: entry.collateralBankEmodeTag,
|
|
@@ -17594,41 +17592,41 @@ function dtoToBankConfigRaw(bankConfigDto) {
|
|
|
17594
17592
|
assetWeightMaint: bankConfigDto.assetWeightMaint,
|
|
17595
17593
|
liabilityWeightInit: bankConfigDto.liabilityWeightInit,
|
|
17596
17594
|
liabilityWeightMaint: bankConfigDto.liabilityWeightMaint,
|
|
17597
|
-
depositLimit: new
|
|
17598
|
-
borrowLimit: new
|
|
17595
|
+
depositLimit: new bn_js.default(bankConfigDto.depositLimit),
|
|
17596
|
+
borrowLimit: new bn_js.default(bankConfigDto.borrowLimit),
|
|
17599
17597
|
riskTier: bankConfigDto.riskTier,
|
|
17600
17598
|
operationalState: bankConfigDto.operationalState,
|
|
17601
|
-
totalAssetValueInitLimit: new
|
|
17599
|
+
totalAssetValueInitLimit: new bn_js.default(bankConfigDto.totalAssetValueInitLimit),
|
|
17602
17600
|
assetTag: bankConfigDto.assetTag,
|
|
17603
17601
|
oracleSetup: bankConfigDto.oracleSetup,
|
|
17604
|
-
oracleKeys: bankConfigDto.oracleKeys.map((key) => new PublicKey(key)),
|
|
17602
|
+
oracleKeys: bankConfigDto.oracleKeys.map((key) => new __solana_web3_js.PublicKey(key)),
|
|
17605
17603
|
oracleMaxAge: bankConfigDto.oracleMaxAge,
|
|
17606
17604
|
interestRateConfig: bankConfigDto.interestRateConfig
|
|
17607
17605
|
};
|
|
17608
17606
|
}
|
|
17609
17607
|
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 =
|
|
17608
|
+
const assetWeightInit = require_common.wrappedI80F48toBigNumber(bankConfigRaw.assetWeightInit);
|
|
17609
|
+
const assetWeightMaint = require_common.wrappedI80F48toBigNumber(bankConfigRaw.assetWeightMaint);
|
|
17610
|
+
const liabilityWeightInit = require_common.wrappedI80F48toBigNumber(bankConfigRaw.liabilityWeightInit);
|
|
17611
|
+
const liabilityWeightMaint = require_common.wrappedI80F48toBigNumber(bankConfigRaw.liabilityWeightMaint);
|
|
17612
|
+
const depositLimit = (0, bignumber_js.default)(bankConfigRaw.depositLimit.toString());
|
|
17613
|
+
const borrowLimit = (0, bignumber_js.default)(bankConfigRaw.borrowLimit.toString());
|
|
17616
17614
|
const riskTier = parseRiskTier(bankConfigRaw.riskTier);
|
|
17617
17615
|
const operationalState = parseOperationalState(bankConfigRaw.operationalState);
|
|
17618
|
-
const totalAssetValueInitLimit =
|
|
17616
|
+
const totalAssetValueInitLimit = (0, bignumber_js.default)(bankConfigRaw.totalAssetValueInitLimit.toString());
|
|
17619
17617
|
const assetTag = bankConfigRaw.assetTag;
|
|
17620
17618
|
const oracleSetup = parseOracleSetup(bankConfigRaw.oracleSetup);
|
|
17621
17619
|
const oracleKeys = bankConfigRaw.oracleKeys;
|
|
17622
|
-
const oracleMaxAge = bankConfigRaw.oracleMaxAge === 0 ? DEFAULT_ORACLE_MAX_AGE : bankConfigRaw.oracleMaxAge;
|
|
17620
|
+
const oracleMaxAge = bankConfigRaw.oracleMaxAge === 0 ? require_common.DEFAULT_ORACLE_MAX_AGE : bankConfigRaw.oracleMaxAge;
|
|
17623
17621
|
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)
|
|
17622
|
+
insuranceFeeFixedApr: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.insuranceFeeFixedApr),
|
|
17623
|
+
maxInterestRate: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.maxInterestRate),
|
|
17624
|
+
insuranceIrFee: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.insuranceIrFee),
|
|
17625
|
+
optimalUtilizationRate: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.optimalUtilizationRate),
|
|
17626
|
+
plateauInterestRate: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.plateauInterestRate),
|
|
17627
|
+
protocolFixedFeeApr: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.protocolFixedFeeApr),
|
|
17628
|
+
protocolIrFee: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.protocolIrFee),
|
|
17629
|
+
protocolOriginationFee: require_common.wrappedI80F48toBigNumber(bankConfigRaw.interestRateConfig.protocolOriginationFee)
|
|
17632
17630
|
};
|
|
17633
17631
|
return {
|
|
17634
17632
|
assetWeightInit,
|
|
@@ -17691,7 +17689,7 @@ function getActiveEmodeFlags(flags) {
|
|
|
17691
17689
|
* Check if a specific EMode flag is set
|
|
17692
17690
|
*/
|
|
17693
17691
|
function hasEmodeFlag(flags, flag) {
|
|
17694
|
-
return !flags.and(new
|
|
17692
|
+
return !flags.and(new bn_js.default(flag)).isZero();
|
|
17695
17693
|
}
|
|
17696
17694
|
/**
|
|
17697
17695
|
* Get all active EMode entry flags as an array of flag names
|
|
@@ -17738,17 +17736,17 @@ const getStakeAccount = (data) => {
|
|
|
17738
17736
|
offset += 4;
|
|
17739
17737
|
const rentExemptReserve = data.readBigUInt64LE(offset);
|
|
17740
17738
|
offset += 8;
|
|
17741
|
-
const staker = new PublicKey(data.subarray(offset, offset + 32));
|
|
17739
|
+
const staker = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17742
17740
|
offset += 32;
|
|
17743
|
-
const withdrawer = new PublicKey(data.subarray(offset, offset + 32));
|
|
17741
|
+
const withdrawer = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17744
17742
|
offset += 32;
|
|
17745
17743
|
const unixTimestamp = data.readBigUInt64LE(offset);
|
|
17746
17744
|
offset += 8;
|
|
17747
17745
|
const epoch = data.readBigUInt64LE(offset);
|
|
17748
17746
|
offset += 8;
|
|
17749
|
-
const custodian = new PublicKey(data.subarray(offset, offset + 32));
|
|
17747
|
+
const custodian = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17750
17748
|
offset += 32;
|
|
17751
|
-
const voterPubkey = new PublicKey(data.subarray(offset, offset + 32));
|
|
17749
|
+
const voterPubkey = new __solana_web3_js.PublicKey(data.subarray(offset, offset + 32));
|
|
17752
17750
|
offset += 32;
|
|
17753
17751
|
const stake = data.readBigUInt64LE(offset);
|
|
17754
17752
|
offset += 8;
|
|
@@ -17786,7 +17784,7 @@ const getStakeAccount = (data) => {
|
|
|
17786
17784
|
//#endregion
|
|
17787
17785
|
//#region src/vendor/index.ts
|
|
17788
17786
|
var vendor_exports = {};
|
|
17789
|
-
__export(vendor_exports, {
|
|
17787
|
+
require_common.__export(vendor_exports, {
|
|
17790
17788
|
AccountType: () => AccountType$1,
|
|
17791
17789
|
AggregatorAccount: () => AggregatorAccount,
|
|
17792
17790
|
AggregatorAccountData: () => AggregatorAccountData,
|
|
@@ -17822,17 +17820,17 @@ __export(vendor_exports, {
|
|
|
17822
17820
|
//#region src/utils.ts
|
|
17823
17821
|
function getBankVaultSeeds(type) {
|
|
17824
17822
|
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;
|
|
17823
|
+
case BankVaultType.LiquidityVault: return require_common.PDA_BANK_LIQUIDITY_VAULT_SEED;
|
|
17824
|
+
case BankVaultType.InsuranceVault: return require_common.PDA_BANK_INSURANCE_VAULT_SEED;
|
|
17825
|
+
case BankVaultType.FeeVault: return require_common.PDA_BANK_FEE_VAULT_SEED;
|
|
17828
17826
|
default: throw Error(`Unknown vault type ${type}`);
|
|
17829
17827
|
}
|
|
17830
17828
|
}
|
|
17831
17829
|
function getBankVaultAuthoritySeeds(type) {
|
|
17832
17830
|
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;
|
|
17831
|
+
case BankVaultType.LiquidityVault: return require_common.PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED;
|
|
17832
|
+
case BankVaultType.InsuranceVault: return require_common.PDA_BANK_INSURANCE_VAULT_AUTH_SEED;
|
|
17833
|
+
case BankVaultType.FeeVault: return require_common.PDA_BANK_FEE_VAULT_AUTH_SEED;
|
|
17836
17834
|
default: throw Error(`Unknown vault type ${type}`);
|
|
17837
17835
|
}
|
|
17838
17836
|
}
|
|
@@ -17840,33 +17838,33 @@ function getBankVaultAuthoritySeeds(type) {
|
|
|
17840
17838
|
* Compute authority PDA for a specific lendr group bank vault
|
|
17841
17839
|
*/
|
|
17842
17840
|
function getBankVaultAuthority(bankVaultType, bankPk, programId) {
|
|
17843
|
-
return PublicKey.findProgramAddressSync([getBankVaultAuthoritySeeds(bankVaultType), bankPk.toBuffer()], programId);
|
|
17841
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([getBankVaultAuthoritySeeds(bankVaultType), bankPk.toBuffer()], programId);
|
|
17844
17842
|
}
|
|
17845
17843
|
function makeWrapSolIxs(walletAddress, amount) {
|
|
17846
|
-
const address$2 = getAssociatedTokenAddressSync(NATIVE_MINT, walletAddress, true);
|
|
17847
|
-
const ixs = [createAssociatedTokenAccountIdempotentInstruction(walletAddress, address$2, walletAddress, NATIVE_MINT)];
|
|
17844
|
+
const address$2 = (0, __solana_spl_token.getAssociatedTokenAddressSync)(__solana_spl_token.NATIVE_MINT, walletAddress, true);
|
|
17845
|
+
const ixs = [(0, __solana_spl_token.createAssociatedTokenAccountIdempotentInstruction)(walletAddress, address$2, walletAddress, __solana_spl_token.NATIVE_MINT)];
|
|
17848
17846
|
if (amount.gt(0)) {
|
|
17849
|
-
const nativeAmount = uiToNative(amount, 9).toNumber() + 1e4;
|
|
17850
|
-
ixs.push(SystemProgram.transfer({
|
|
17847
|
+
const nativeAmount = require_common.uiToNative(amount, 9).toNumber() + 1e4;
|
|
17848
|
+
ixs.push(__solana_web3_js.SystemProgram.transfer({
|
|
17851
17849
|
fromPubkey: walletAddress,
|
|
17852
17850
|
toPubkey: address$2,
|
|
17853
17851
|
lamports: nativeAmount
|
|
17854
|
-
}), createSyncNativeInstruction(address$2));
|
|
17852
|
+
}), (0, __solana_spl_token.createSyncNativeInstruction)(address$2));
|
|
17855
17853
|
}
|
|
17856
17854
|
return ixs;
|
|
17857
17855
|
}
|
|
17858
17856
|
function makeUnwrapSolIx(walletAddress) {
|
|
17859
|
-
const address$2 = getAssociatedTokenAddressSync(NATIVE_MINT, walletAddress, true);
|
|
17860
|
-
return createCloseAccountInstruction(address$2, walletAddress, walletAddress);
|
|
17857
|
+
const address$2 = (0, __solana_spl_token.getAssociatedTokenAddressSync)(__solana_spl_token.NATIVE_MINT, walletAddress, true);
|
|
17858
|
+
return (0, __solana_spl_token.createCloseAccountInstruction)(address$2, walletAddress, walletAddress);
|
|
17861
17859
|
}
|
|
17862
17860
|
async function makeVersionedTransaction(blockhash, transaction, payer, addressLookupTables) {
|
|
17863
|
-
const message = new TransactionMessage({
|
|
17861
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
17864
17862
|
instructions: transaction.instructions,
|
|
17865
17863
|
payerKey: payer,
|
|
17866
17864
|
recentBlockhash: blockhash
|
|
17867
17865
|
});
|
|
17868
17866
|
const versionedMessage = addressLookupTables ? message.compileToV0Message(addressLookupTables) : message.compileToLegacyMessage();
|
|
17869
|
-
return new VersionedTransaction(versionedMessage);
|
|
17867
|
+
return new __solana_web3_js.VersionedTransaction(versionedMessage);
|
|
17870
17868
|
}
|
|
17871
17869
|
/**
|
|
17872
17870
|
* Creates a compute budget instruction to set the priority fee for a transaction.
|
|
@@ -17876,7 +17874,7 @@ async function makeVersionedTransaction(blockhash, transaction, payer, addressLo
|
|
|
17876
17874
|
* @returns A compute budget instruction with the specified priority fee
|
|
17877
17875
|
*/
|
|
17878
17876
|
function makePriorityFeeMicroIx(priorityFeeMicro) {
|
|
17879
|
-
return ComputeBudgetProgram.setComputeUnitPrice({ microLamports: Math.floor(priorityFeeMicro ?? 1) });
|
|
17877
|
+
return __solana_web3_js.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: Math.floor(priorityFeeMicro ?? 1) });
|
|
17880
17878
|
}
|
|
17881
17879
|
function makePriorityFeeIx(priorityFeeUi, computeUnitsLimit) {
|
|
17882
17880
|
const priorityFeeIx = [];
|
|
@@ -17885,11 +17883,11 @@ function makePriorityFeeIx(priorityFeeUi, computeUnitsLimit) {
|
|
|
17885
17883
|
if (priorityFeeUi) {
|
|
17886
17884
|
const isAbsurdPriorityFee = priorityFeeUi > .1;
|
|
17887
17885
|
if (!isAbsurdPriorityFee) {
|
|
17888
|
-
const priorityFeeMicroLamports = priorityFeeUi * LAMPORTS_PER_SOL * 1e6;
|
|
17886
|
+
const priorityFeeMicroLamports = priorityFeeUi * __solana_web3_js.LAMPORTS_PER_SOL * 1e6;
|
|
17889
17887
|
microLamports = Math.round(priorityFeeMicroLamports / limit);
|
|
17890
17888
|
}
|
|
17891
17889
|
}
|
|
17892
|
-
priorityFeeIx.push(ComputeBudgetProgram.setComputeUnitPrice({ microLamports }));
|
|
17890
|
+
priorityFeeIx.push(__solana_web3_js.ComputeBudgetProgram.setComputeUnitPrice({ microLamports }));
|
|
17893
17891
|
return priorityFeeIx;
|
|
17894
17892
|
}
|
|
17895
17893
|
function feedIdToString(feedId) {
|
|
@@ -17901,7 +17899,7 @@ async function buildFeedIdMap(bankConfigs, connection) {
|
|
|
17901
17899
|
const feedId = bankConfig.oracleKeys[0].toBuffer();
|
|
17902
17900
|
return {
|
|
17903
17901
|
feedId,
|
|
17904
|
-
addresses: [findPythPushOracleAddress(feedId, PYTH_PUSH_ORACLE_ID, PYTH_SPONSORED_SHARD_ID), findPythPushOracleAddress(feedId, PYTH_PUSH_ORACLE_ID, LENDR_SPONSORED_SHARD_ID)]
|
|
17902
|
+
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
17903
|
};
|
|
17906
17904
|
});
|
|
17907
17905
|
const addressess = feedIdsWithAddresses.flatMap((feedIdWithAddress) => feedIdWithAddress.addresses);
|
|
@@ -17977,7 +17975,7 @@ const PYTH_SPONSORED_SHARD_ID = 0;
|
|
|
17977
17975
|
const LENDR_SPONSORED_SHARD_ID = 3301;
|
|
17978
17976
|
function findPythPushOracleAddress(feedId, programId, shardId) {
|
|
17979
17977
|
const shardBytes = u16ToArrayBufferLE(shardId);
|
|
17980
|
-
return PublicKey.findProgramAddressSync([shardBytes, feedId], programId)[0];
|
|
17978
|
+
return __solana_web3_js.PublicKey.findProgramAddressSync([shardBytes, feedId], programId)[0];
|
|
17981
17979
|
}
|
|
17982
17980
|
function u16ToArrayBufferLE(value) {
|
|
17983
17981
|
const buffer = new ArrayBuffer(2);
|
|
@@ -18044,8 +18042,8 @@ var Bank = class Bank {
|
|
|
18044
18042
|
const newBank = Object.create(Bank.prototype);
|
|
18045
18043
|
Object.assign(newBank, bank);
|
|
18046
18044
|
newBank.config = Object.assign({}, bank.config);
|
|
18047
|
-
newBank.config.assetWeightInit =
|
|
18048
|
-
newBank.config.assetWeightMaint =
|
|
18045
|
+
newBank.config.assetWeightInit = bignumber_js.default.max(bank.config.assetWeightInit, emodeWeights.assetWeightInit);
|
|
18046
|
+
newBank.config.assetWeightMaint = bignumber_js.default.max(bank.config.assetWeightMaint, emodeWeights.assetWeightMaint);
|
|
18049
18047
|
return newBank;
|
|
18050
18048
|
}
|
|
18051
18049
|
static getPrice(oraclePrice, priceBias = PriceBias.None, weightedPrice = false) {
|
|
@@ -18111,8 +18109,8 @@ var Bank = class Bank {
|
|
|
18111
18109
|
Bank address: ${this.address.toBase58()}
|
|
18112
18110
|
Mint: ${this.mint.toBase58()}, decimals: ${this.mintDecimals}
|
|
18113
18111
|
|
|
18114
|
-
Total deposits: ${nativeToUi(this.getTotalAssetQuantity(), this.mintDecimals)}
|
|
18115
|
-
Total borrows: ${nativeToUi(this.getTotalLiabilityQuantity(), this.mintDecimals)}
|
|
18112
|
+
Total deposits: ${require_common.nativeToUi(this.getTotalAssetQuantity(), this.mintDecimals)}
|
|
18113
|
+
Total borrows: ${require_common.nativeToUi(this.getTotalLiabilityQuantity(), this.mintDecimals)}
|
|
18116
18114
|
|
|
18117
18115
|
Total assets (USD value): ${this.computeAssetUsdValue(oraclePrice, this.totalAssetShares, LendrRequirementType.Equity, PriceBias.None)}
|
|
18118
18116
|
Total liabilities (USD value): ${this.computeLiabilityUsdValue(oraclePrice, this.totalLiabilityShares, LendrRequirementType.Equity, PriceBias.None)}
|
|
@@ -18130,8 +18128,8 @@ Config:
|
|
|
18130
18128
|
- Borrow limit: ${this.config.borrowLimit}
|
|
18131
18129
|
|
|
18132
18130
|
LTVs:
|
|
18133
|
-
- Initial: ${new
|
|
18134
|
-
- Maintenance: ${new
|
|
18131
|
+
- Initial: ${new bignumber_js.default(1).div(this.config.liabilityWeightInit).times(100).toFixed(2)}%
|
|
18132
|
+
- Maintenance: ${new bignumber_js.default(1).div(this.config.liabilityWeightMaint).times(100).toFixed(2)}%
|
|
18135
18133
|
`;
|
|
18136
18134
|
}
|
|
18137
18135
|
};
|
|
@@ -18297,7 +18295,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18297
18295
|
const useCache = false;
|
|
18298
18296
|
const freeCollateral = useCache ? this.computeFreeCollateral().times(_volatilityFactor) : this.computeFreeCollateralLegacy(banks, oraclePrices);
|
|
18299
18297
|
logger.debug({ freeCollateral: freeCollateral.toFixed(6) }, "[lendr:computeMaxBorrowForBank] Free collateral");
|
|
18300
|
-
const untiedCollateralForBank =
|
|
18298
|
+
const untiedCollateralForBank = bignumber_js.default.min(bank.computeAssetUsdValue(priceInfo, balance.assetShares, LendrRequirementType.Initial, PriceBias.Lowest), freeCollateral);
|
|
18301
18299
|
const priceLowestBias = getPrice(priceInfo, PriceBias.Lowest, true);
|
|
18302
18300
|
const priceHighestBias = getPrice(priceInfo, PriceBias.Highest, true);
|
|
18303
18301
|
const assetWeight = bank.getAssetWeight(LendrRequirementType.Initial, priceInfo);
|
|
@@ -18325,7 +18323,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18325
18323
|
const { liabilities: liabilitiesInit } = this.computeHealthComponents(LendrRequirementType.Initial);
|
|
18326
18324
|
if (bank.config.riskTier === RiskTier.Isolated || initAssetWeight.isZero() && maintAssetWeight.isZero()) {
|
|
18327
18325
|
if (freeCollateral.isZero() && !liabilitiesInit.isZero()) {
|
|
18328
|
-
return new
|
|
18326
|
+
return new bignumber_js.default(0);
|
|
18329
18327
|
} else {
|
|
18330
18328
|
return entireBalance;
|
|
18331
18329
|
}
|
|
@@ -18334,7 +18332,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18334
18332
|
if (liabilitiesInit.eq(0)) {
|
|
18335
18333
|
return entireBalance;
|
|
18336
18334
|
} else if (freeCollateral.isZero()) {
|
|
18337
|
-
return new
|
|
18335
|
+
return new bignumber_js.default(0);
|
|
18338
18336
|
} else {
|
|
18339
18337
|
const { liabilities: maintLiabilities, assets: maintAssets } = this.computeHealthComponents(LendrRequirementType.Maintenance);
|
|
18340
18338
|
const maintUntiedCollateral = maintAssets.minus(maintLiabilities);
|
|
@@ -18424,7 +18422,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18424
18422
|
const { assets: assetsAccount, liabilities: liabilitiesAccount } = this.computeHealthComponents(LendrRequirementType.Maintenance);
|
|
18425
18423
|
const assets = assetsAccount.minus(assetBank);
|
|
18426
18424
|
const liabilities = liabilitiesAccount.minus(liabilitiesBank);
|
|
18427
|
-
const amountBn = new
|
|
18425
|
+
const amountBn = new bignumber_js.default(amount);
|
|
18428
18426
|
let liquidationPrice;
|
|
18429
18427
|
if (isLending) {
|
|
18430
18428
|
if (liabilities.eq(0)) return null;
|
|
@@ -18453,7 +18451,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18453
18451
|
const priceAssetLower = getPrice(assetPriceInfo, PriceBias.Lowest, false);
|
|
18454
18452
|
const priceAssetMarket = getPrice(assetPriceInfo, PriceBias.None, false);
|
|
18455
18453
|
const assetMaintWeight = assetBank.config.assetWeightMaint;
|
|
18456
|
-
const liquidationDiscount = new
|
|
18454
|
+
const liquidationDiscount = new bignumber_js.default(.95);
|
|
18457
18455
|
const priceLiabHighest = getPrice(liabilityPriceInfo, PriceBias.Highest, false);
|
|
18458
18456
|
const priceLiabMarket = getPrice(liabilityPriceInfo, PriceBias.None, false);
|
|
18459
18457
|
const liabMaintWeight = liabilityBank.config.liabilityWeightMaint;
|
|
@@ -18479,7 +18477,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18479
18477
|
priceLiabMarket: priceLiabMarket.toFixed(6),
|
|
18480
18478
|
liabUsdValue: liabUsdValue.toFixed(6)
|
|
18481
18479
|
}, "[lendr:getMaxLiquidatableAssetAmount]");
|
|
18482
|
-
const maxLiquidatableUsdValue =
|
|
18480
|
+
const maxLiquidatableUsdValue = bignumber_js.default.min(assetsUsdValue, underwaterMaintUsdValue, liabUsdValue);
|
|
18483
18481
|
logger.debug({ maxLiquidatableUsdValue: maxLiquidatableUsdValue.toFixed(6) }, "[lendr:getMaxLiquidatableAssetAmount] Max liquidatable usd value");
|
|
18484
18482
|
return maxLiquidatableUsdValue.div(priceAssetLower);
|
|
18485
18483
|
}
|
|
@@ -18522,21 +18520,21 @@ var LendrAccount = class LendrAccount {
|
|
|
18522
18520
|
if (!mintData) throw Error(`Mint for bank ${bankAddress.toBase58()} not found`);
|
|
18523
18521
|
const wrapAndUnwrapSol = opts.wrapAndUnwrapSol ?? true;
|
|
18524
18522
|
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) ? [{
|
|
18523
|
+
const userTokenAtaPk = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18524
|
+
const remainingAccounts = mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID) ? [{
|
|
18527
18525
|
pubkey: mintData.mint,
|
|
18528
18526
|
isSigner: false,
|
|
18529
18527
|
isWritable: false
|
|
18530
18528
|
}] : [];
|
|
18531
18529
|
const depositIxs = [];
|
|
18532
|
-
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18533
|
-
depositIxs.push(...makeWrapSolIxs(this.authority, new
|
|
18530
|
+
if (bank.mint.equals(__solana_spl_token.NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18531
|
+
depositIxs.push(...makeWrapSolIxs(this.authority, new bignumber_js.default(amount).minus(wSolBalanceUi)));
|
|
18534
18532
|
}
|
|
18535
18533
|
return {
|
|
18536
18534
|
depositIxs,
|
|
18537
18535
|
userTokenAtaPk,
|
|
18538
18536
|
mintData,
|
|
18539
|
-
ixArguments: { amount: uiToNative(amount, bank.mintDecimals) },
|
|
18537
|
+
ixArguments: { amount: require_common.uiToNative(amount, bank.mintDecimals) },
|
|
18540
18538
|
remainingAccounts
|
|
18541
18539
|
};
|
|
18542
18540
|
}
|
|
@@ -18583,23 +18581,23 @@ var LendrAccount = class LendrAccount {
|
|
|
18583
18581
|
const wrapAndUnwrapSol = opts.wrapAndUnwrapSol ?? true;
|
|
18584
18582
|
const wSolBalanceUi = opts.wSolBalanceUi ?? 0;
|
|
18585
18583
|
const repayIxs = [];
|
|
18586
|
-
if (repayAll && !bank.emissionsMint.equals(PublicKey.default)) {
|
|
18584
|
+
if (repayAll && !bank.emissionsMint.equals(__solana_web3_js.PublicKey.default)) {
|
|
18587
18585
|
repayIxs.push(...(await this.makeWithdrawEmissionsIx(program, banks, mintDatas, bankAddress)).instructions);
|
|
18588
18586
|
}
|
|
18589
|
-
const userAta = getAssociatedTokenAddressSync(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18587
|
+
const userAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18590
18588
|
const remainingAccounts = [];
|
|
18591
|
-
if (mintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
18589
|
+
if (mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID)) {
|
|
18592
18590
|
remainingAccounts.push(mintData.mint);
|
|
18593
18591
|
}
|
|
18594
|
-
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18595
|
-
repayIxs.push(...makeWrapSolIxs(this.authority, new
|
|
18592
|
+
if (bank.mint.equals(__solana_spl_token.NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18593
|
+
repayIxs.push(...makeWrapSolIxs(this.authority, new bignumber_js.default(amount).minus(wSolBalanceUi)));
|
|
18596
18594
|
}
|
|
18597
18595
|
return {
|
|
18598
18596
|
repayIxs,
|
|
18599
18597
|
mintData,
|
|
18600
18598
|
userAta,
|
|
18601
18599
|
ixArguments: {
|
|
18602
|
-
amount: uiToNative(amount, bank.mintDecimals),
|
|
18600
|
+
amount: require_common.uiToNative(amount, bank.mintDecimals),
|
|
18603
18601
|
repayAll
|
|
18604
18602
|
},
|
|
18605
18603
|
remainingAccounts
|
|
@@ -18655,17 +18653,17 @@ var LendrAccount = class LendrAccount {
|
|
|
18655
18653
|
const wrapAndUnwrapSol = withdrawOpts.wrapAndUnwrapSol ?? true;
|
|
18656
18654
|
const createAtas = withdrawOpts.createAtas ?? true;
|
|
18657
18655
|
const withdrawIxs = [];
|
|
18658
|
-
if (withdrawAll && !bank.emissionsMint.equals(PublicKey.default) && mintData.emissionTokenProgram) {
|
|
18656
|
+
if (withdrawAll && !bank.emissionsMint.equals(__solana_web3_js.PublicKey.default) && mintData.emissionTokenProgram) {
|
|
18659
18657
|
withdrawIxs.push(...(await this.makeWithdrawEmissionsIx(program, bankMap, mintDatas, bankAddress)).instructions);
|
|
18660
18658
|
}
|
|
18661
|
-
const userAta = getAssociatedTokenAddressSync(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18659
|
+
const userAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18662
18660
|
if (createAtas) {
|
|
18663
|
-
const createAtaIdempotentIx = createAssociatedTokenAccountIdempotentInstruction(withdrawOpts?.createAtaPayer ?? this.authority, userAta, this.authority, bank.mint, mintData.tokenProgram);
|
|
18661
|
+
const createAtaIdempotentIx = (0, __solana_spl_token.createAssociatedTokenAccountIdempotentInstruction)(withdrawOpts?.createAtaPayer ?? this.authority, userAta, this.authority, bank.mint, mintData.tokenProgram);
|
|
18664
18662
|
withdrawIxs.push(createAtaIdempotentIx);
|
|
18665
18663
|
}
|
|
18666
18664
|
const healthAccounts = withdrawAll ? this.getHealthCheckAccounts(bankMap, [], [bankAddress]) : this.getHealthCheckAccounts(bankMap, [bankAddress], []);
|
|
18667
18665
|
const remainingAccounts = [];
|
|
18668
|
-
if (mintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
18666
|
+
if (mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID)) {
|
|
18669
18667
|
remainingAccounts.push(mintData.mint);
|
|
18670
18668
|
}
|
|
18671
18669
|
if (withdrawOpts.observationBanksOverride) {
|
|
@@ -18697,11 +18695,11 @@ var LendrAccount = class LendrAccount {
|
|
|
18697
18695
|
authority: withdrawOpts.overrideInferAccounts?.authority,
|
|
18698
18696
|
group: withdrawOpts.overrideInferAccounts?.group
|
|
18699
18697
|
}, {
|
|
18700
|
-
amount: uiToNative(amount, bank.mintDecimals),
|
|
18698
|
+
amount: require_common.uiToNative(amount, bank.mintDecimals),
|
|
18701
18699
|
withdrawAll
|
|
18702
18700
|
}, remainingAccounts);
|
|
18703
18701
|
withdrawIxs.push(withdrawIx);
|
|
18704
|
-
if (wrapAndUnwrapSol && bank.mint.equals(NATIVE_MINT)) {
|
|
18702
|
+
if (wrapAndUnwrapSol && bank.mint.equals(__solana_spl_token.NATIVE_MINT)) {
|
|
18705
18703
|
withdrawIxs.push(makeUnwrapSolIx(this.authority));
|
|
18706
18704
|
}
|
|
18707
18705
|
return {
|
|
@@ -18722,11 +18720,11 @@ var LendrAccount = class LendrAccount {
|
|
|
18722
18720
|
tokenProgram: mintData.tokenProgram,
|
|
18723
18721
|
group: withdrawOpts.overrideInferAccounts?.group
|
|
18724
18722
|
}, {
|
|
18725
|
-
amount: uiToNative(amount, bank.mintDecimals),
|
|
18723
|
+
amount: require_common.uiToNative(amount, bank.mintDecimals),
|
|
18726
18724
|
withdrawAll
|
|
18727
18725
|
}, remainingAccounts);
|
|
18728
18726
|
withdrawIxs.push(withdrawIx);
|
|
18729
|
-
if (wrapAndUnwrapSol && bank.mint.equals(NATIVE_MINT)) {
|
|
18727
|
+
if (wrapAndUnwrapSol && bank.mint.equals(__solana_spl_token.NATIVE_MINT)) {
|
|
18730
18728
|
withdrawIxs.push(makeUnwrapSolIx(this.authority));
|
|
18731
18729
|
}
|
|
18732
18730
|
return {
|
|
@@ -18742,14 +18740,14 @@ var LendrAccount = class LendrAccount {
|
|
|
18742
18740
|
const wrapAndUnwrapSol = borrowOpts.wrapAndUnwrapSol ?? true;
|
|
18743
18741
|
const createAtas = borrowOpts.createAtas ?? true;
|
|
18744
18742
|
const borrowIxs = [];
|
|
18745
|
-
const userAta = getAssociatedTokenAddressSync(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18743
|
+
const userAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.mint, this.authority, true, mintData.tokenProgram);
|
|
18746
18744
|
if (createAtas) {
|
|
18747
|
-
const createAtaIdempotentIx = createAssociatedTokenAccountIdempotentInstruction(borrowOpts?.createAtaPayer ?? this.authority, userAta, this.authority, bank.mint, mintData.tokenProgram);
|
|
18745
|
+
const createAtaIdempotentIx = (0, __solana_spl_token.createAssociatedTokenAccountIdempotentInstruction)(borrowOpts?.createAtaPayer ?? this.authority, userAta, this.authority, bank.mint, mintData.tokenProgram);
|
|
18748
18746
|
borrowIxs.push(createAtaIdempotentIx);
|
|
18749
18747
|
}
|
|
18750
18748
|
const healthAccounts = this.getHealthCheckAccounts(bankMap, [bankAddress], []);
|
|
18751
18749
|
const remainingAccounts = [];
|
|
18752
|
-
if (mintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
18750
|
+
if (mintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID)) {
|
|
18753
18751
|
remainingAccounts.push(mintData.mint);
|
|
18754
18752
|
}
|
|
18755
18753
|
if (borrowOpts?.observationBanksOverride) {
|
|
@@ -18780,9 +18778,9 @@ var LendrAccount = class LendrAccount {
|
|
|
18780
18778
|
tokenProgram: mintData.tokenProgram,
|
|
18781
18779
|
authority: borrowOpts?.overrideInferAccounts?.authority,
|
|
18782
18780
|
group: borrowOpts?.overrideInferAccounts?.group
|
|
18783
|
-
}, { amount: uiToNative(amount, bank.mintDecimals) }, remainingAccounts);
|
|
18781
|
+
}, { amount: require_common.uiToNative(amount, bank.mintDecimals) }, remainingAccounts);
|
|
18784
18782
|
borrowIxs.push(borrowIx);
|
|
18785
|
-
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18783
|
+
if (bank.mint.equals(__solana_spl_token.NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18786
18784
|
borrowIxs.push(makeUnwrapSolIx(this.authority));
|
|
18787
18785
|
}
|
|
18788
18786
|
return {
|
|
@@ -18802,9 +18800,9 @@ var LendrAccount = class LendrAccount {
|
|
|
18802
18800
|
destinationTokenAccount: userAta,
|
|
18803
18801
|
tokenProgram: mintData.tokenProgram,
|
|
18804
18802
|
group: borrowOpts?.overrideInferAccounts?.group
|
|
18805
|
-
}, { amount: uiToNative(amount, bank.mintDecimals) }, remainingAccounts);
|
|
18803
|
+
}, { amount: require_common.uiToNative(amount, bank.mintDecimals) }, remainingAccounts);
|
|
18806
18804
|
borrowIxs.push(borrowIx);
|
|
18807
|
-
if (bank.mint.equals(NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18805
|
+
if (bank.mint.equals(__solana_spl_token.NATIVE_MINT) && wrapAndUnwrapSol) {
|
|
18808
18806
|
borrowIxs.push(makeUnwrapSolIx(this.authority));
|
|
18809
18807
|
}
|
|
18810
18808
|
return {
|
|
@@ -18821,8 +18819,8 @@ var LendrAccount = class LendrAccount {
|
|
|
18821
18819
|
throw Error(`Emission token program not found for bank ${bankAddress.toBase58()}`);
|
|
18822
18820
|
}
|
|
18823
18821
|
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);
|
|
18822
|
+
const userAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(bank.emissionsMint, this.authority, true, mintData.emissionTokenProgram);
|
|
18823
|
+
const createAtaIdempotentIx = (0, __solana_spl_token.createAssociatedTokenAccountIdempotentInstruction)(this.authority, userAta, this.authority, bank.emissionsMint, mintData.emissionTokenProgram);
|
|
18826
18824
|
ixs.push(createAtaIdempotentIx);
|
|
18827
18825
|
const withdrawEmissionsIx = await instructions_default.makelendingAccountWithdrawEmissionIx(program, {
|
|
18828
18826
|
lendrAccount: this.address,
|
|
@@ -18846,19 +18844,19 @@ var LendrAccount = class LendrAccount {
|
|
|
18846
18844
|
const ixs = [];
|
|
18847
18845
|
const healthAccounts = [...this.getHealthCheckAccounts(bankMap, [liabilityBankAddress, assetBankAddress], []), ...liquidateeLendrAccount.getHealthCheckAccounts(bankMap, [], [])];
|
|
18848
18846
|
const remainingAccounts = [];
|
|
18849
|
-
if (liabilityMintData.tokenProgram.equals(TOKEN_2022_PROGRAM_ID)) {
|
|
18847
|
+
if (liabilityMintData.tokenProgram.equals(__solana_spl_token.TOKEN_2022_PROGRAM_ID)) {
|
|
18850
18848
|
remainingAccounts.push(liabilityMintData.mint);
|
|
18851
18849
|
}
|
|
18852
18850
|
const accountMetas = computeHealthAccountMetas(healthAccounts, bankMetadataMap);
|
|
18853
18851
|
remainingAccounts.push(...accountMetas);
|
|
18854
|
-
ixs.push(ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 }));
|
|
18852
|
+
ixs.push(__solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 }));
|
|
18855
18853
|
const liquidateIx = await instructions_default.makeLendingAccountLiquidateIx(program, {
|
|
18856
18854
|
assetBank: assetBankAddress,
|
|
18857
18855
|
liabBank: liabilityBankAddress,
|
|
18858
18856
|
liquidatorLendrAccount: this.address,
|
|
18859
18857
|
liquidateeLendrAccount: liquidateeLendrAccount.address,
|
|
18860
18858
|
tokenProgram: liabilityMintData.tokenProgram
|
|
18861
|
-
}, { assetAmount: uiToNative(assetQuantityUi, assetBank.mintDecimals) }, remainingAccounts.map((account) => ({
|
|
18859
|
+
}, { assetAmount: require_common.uiToNative(assetQuantityUi, assetBank.mintDecimals) }, remainingAccounts.map((account) => ({
|
|
18862
18860
|
pubkey: account,
|
|
18863
18861
|
isSigner: false,
|
|
18864
18862
|
isWritable: false
|
|
@@ -18870,7 +18868,7 @@ var LendrAccount = class LendrAccount {
|
|
|
18870
18868
|
};
|
|
18871
18869
|
}
|
|
18872
18870
|
async makeBeginFlashLoanIx(program, endIndex) {
|
|
18873
|
-
const ix = await instructions_default.makeBeginFlashLoanIx(program, { lendrAccount: this.address }, { endIndex: new
|
|
18871
|
+
const ix = await instructions_default.makeBeginFlashLoanIx(program, { lendrAccount: this.address }, { endIndex: new bn_js.default(endIndex) });
|
|
18874
18872
|
return {
|
|
18875
18873
|
instructions: [ix],
|
|
18876
18874
|
keys: []
|
|
@@ -18925,12 +18923,12 @@ var LendrAccount = class LendrAccount {
|
|
|
18925
18923
|
for (let index = 0; index < instructions$3.length; index++) {
|
|
18926
18924
|
const ix = instructions$3[index];
|
|
18927
18925
|
if (!ix.programId.equals(program.programId)) continue;
|
|
18928
|
-
const borshCoder = new BorshInstructionCoder(program.idl);
|
|
18926
|
+
const borshCoder = new __coral_xyz_anchor.BorshInstructionCoder(program.idl);
|
|
18929
18927
|
const decoded = borshCoder.decode(ix.data, "base58");
|
|
18930
18928
|
if (!decoded) continue;
|
|
18931
18929
|
const ixArgs = decoded.data;
|
|
18932
18930
|
if (decoded.name === "lendingAccountBorrow" || decoded.name === "lendingAccountDeposit") {
|
|
18933
|
-
const targetBank = new PublicKey(ix.keys[3].pubkey);
|
|
18931
|
+
const targetBank = new __solana_web3_js.PublicKey(ix.keys[3].pubkey);
|
|
18934
18932
|
const targetBalance = projectedBalances.find((b) => b.bankPk.equals(targetBank));
|
|
18935
18933
|
if (!targetBalance) {
|
|
18936
18934
|
const firstInactiveBalanceIndex = projectedBalances.findIndex((b) => !b.active);
|
|
@@ -18943,22 +18941,22 @@ var LendrAccount = class LendrAccount {
|
|
|
18943
18941
|
continue;
|
|
18944
18942
|
}
|
|
18945
18943
|
if (decoded.name === "lendingAccountRepay" || decoded.name === "lendingAccountWithdraw") {
|
|
18946
|
-
const targetBank = new PublicKey(ix.keys[3].pubkey);
|
|
18944
|
+
const targetBank = new __solana_web3_js.PublicKey(ix.keys[3].pubkey);
|
|
18947
18945
|
const targetBalance = projectedBalances.find((b) => b.bankPk.equals(targetBank));
|
|
18948
18946
|
if (!targetBalance) {
|
|
18949
18947
|
throw Error(`Balance for bank ${targetBank.toBase58()} should be projected active at this point (ix ${index}: ${decoded.name}))`);
|
|
18950
18948
|
}
|
|
18951
18949
|
if (ixArgs.repayAll || ixArgs.withdrawAll) {
|
|
18952
18950
|
targetBalance.active = false;
|
|
18953
|
-
targetBalance.bankPk = PublicKey.default;
|
|
18951
|
+
targetBalance.bankPk = __solana_web3_js.PublicKey.default;
|
|
18954
18952
|
}
|
|
18955
18953
|
}
|
|
18956
18954
|
}
|
|
18957
18955
|
return projectedBalances.filter((b) => b.active).map((b) => b.bankPk);
|
|
18958
18956
|
}
|
|
18959
|
-
wrapInstructionForWSol(ix, amount = new
|
|
18957
|
+
wrapInstructionForWSol(ix, amount = new bignumber_js.default(0)) {
|
|
18960
18958
|
return [
|
|
18961
|
-
...makeWrapSolIxs(this.authority, new
|
|
18959
|
+
...makeWrapSolIxs(this.authority, new bignumber_js.default(amount)),
|
|
18962
18960
|
ix,
|
|
18963
18961
|
makeUnwrapSolIx(this.authority)
|
|
18964
18962
|
];
|
|
@@ -19009,7 +19007,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19009
19007
|
}
|
|
19010
19008
|
static async fetch(lendrAccountPk, client, commitment) {
|
|
19011
19009
|
const { config, program } = client;
|
|
19012
|
-
const _lendrAccountPk = translateAddress(lendrAccountPk);
|
|
19010
|
+
const _lendrAccountPk = (0, __coral_xyz_anchor.translateAddress)(lendrAccountPk);
|
|
19013
19011
|
const accountData = await LendrAccountWrapper._fetchAccountData(_lendrAccountPk, config, program, commitment);
|
|
19014
19012
|
const lendrAccount = LendrAccount.fromAccountParsed(_lendrAccountPk, accountData);
|
|
19015
19013
|
const lendrAccountProxy = new LendrAccountWrapper(_lendrAccountPk, client, lendrAccount);
|
|
@@ -19018,7 +19016,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19018
19016
|
}
|
|
19019
19017
|
static fromAccountParsed(lendrAccountPk, client, accountData) {
|
|
19020
19018
|
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);
|
|
19019
|
+
const _lendrAccountPk = (0, __coral_xyz_anchor.translateAddress)(lendrAccountPk);
|
|
19022
19020
|
const lendrAccount = LendrAccount.fromAccountParsed(_lendrAccountPk, accountData);
|
|
19023
19021
|
return new LendrAccountWrapper(_lendrAccountPk, client, lendrAccount);
|
|
19024
19022
|
}
|
|
@@ -19099,7 +19097,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19099
19097
|
return this._lendrAccount.computeActiveEmodePairs(emodePairs);
|
|
19100
19098
|
}
|
|
19101
19099
|
computeEmodeImpacts(emodePairs) {
|
|
19102
|
-
return this._lendrAccount.computeEmodeImpacts(emodePairs, Array.from(this.client.banks.keys()).map((b) => new PublicKey(b)));
|
|
19100
|
+
return this._lendrAccount.computeEmodeImpacts(emodePairs, Array.from(this.client.banks.keys()).map((b) => new __solana_web3_js.PublicKey(b)));
|
|
19103
19101
|
}
|
|
19104
19102
|
computeMaxBorrowForBank(bankAddress, opts) {
|
|
19105
19103
|
return this._lendrAccount.computeMaxBorrowForBank(this.client.banks, this.client.oraclePrices, bankAddress, opts, this.client.logger);
|
|
@@ -19135,7 +19133,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19135
19133
|
const cuRequestIxs = [];
|
|
19136
19134
|
const activeBalances = this.balances.filter((b) => b.active);
|
|
19137
19135
|
if (activeBalances.length >= 4) {
|
|
19138
|
-
cuRequestIxs.push(ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }));
|
|
19136
|
+
cuRequestIxs.push(__solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 }));
|
|
19139
19137
|
}
|
|
19140
19138
|
return cuRequestIxs;
|
|
19141
19139
|
}
|
|
@@ -19149,7 +19147,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19149
19147
|
const bank = this.client.bankMetadataMap[bankAddress.toBase58()];
|
|
19150
19148
|
const mintData = this.client.mintDatas.get(bankAddress.toBase58());
|
|
19151
19149
|
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);
|
|
19150
|
+
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
19151
|
});
|
|
19154
19152
|
const ixs = [];
|
|
19155
19153
|
const userAtaAis = await this._program.provider.connection.getMultipleAccountsInfo(userAtas);
|
|
@@ -19159,7 +19157,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19159
19157
|
const bank = this.client.bankMetadataMap[bankAddress.toBase58()];
|
|
19160
19158
|
const mintData = this.client.mintDatas.get(bankAddress.toBase58());
|
|
19161
19159
|
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));
|
|
19160
|
+
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
19161
|
}
|
|
19164
19162
|
}
|
|
19165
19163
|
return ixs;
|
|
@@ -19199,32 +19197,32 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19199
19197
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
19200
19198
|
const feedCrankTxs = [];
|
|
19201
19199
|
if (updateFeedIxs.length > 0) {
|
|
19202
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
19200
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
19203
19201
|
instructions: [...updateFeedIxs],
|
|
19204
19202
|
payerKey: this.authority,
|
|
19205
19203
|
recentBlockhash: blockhash
|
|
19206
19204
|
}).compileToV0Message(feedLuts)), {
|
|
19207
19205
|
addressLookupTables: feedLuts,
|
|
19208
|
-
type: TransactionType.CRANK
|
|
19206
|
+
type: require_common.TransactionType.CRANK
|
|
19209
19207
|
}));
|
|
19210
19208
|
}
|
|
19211
19209
|
const lookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19212
|
-
const withdrawTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
19210
|
+
const withdrawTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
19213
19211
|
instructions: [...cuRequestIxs, ...withdrawIxs.instructions],
|
|
19214
19212
|
payerKey: this.authority,
|
|
19215
19213
|
recentBlockhash: blockhash
|
|
19216
19214
|
}).compileToV0Message(lookupTables)), {
|
|
19217
19215
|
signers: withdrawIxs.keys,
|
|
19218
19216
|
addressLookupTables: lookupTables,
|
|
19219
|
-
type: TransactionType.MOVE_POSITION_WITHDRAW
|
|
19217
|
+
type: require_common.TransactionType.MOVE_POSITION_WITHDRAW
|
|
19220
19218
|
});
|
|
19221
19219
|
const destinationAccount = await LendrAccountWrapper.fetch(destinationAccountPk, this.client);
|
|
19222
19220
|
const depositIx = await destinationAccount.makeDepositIx(amount, bankAddress);
|
|
19223
|
-
const tx = new Transaction().add(...depositIx.instructions);
|
|
19224
|
-
const depositTx = addTransactionMetadata(tx, {
|
|
19221
|
+
const tx = new __solana_web3_js.Transaction().add(...depositIx.instructions);
|
|
19222
|
+
const depositTx = require_common.addTransactionMetadata(tx, {
|
|
19225
19223
|
signers: depositIx.keys,
|
|
19226
19224
|
addressLookupTables: lookupTables,
|
|
19227
|
-
type: TransactionType.MOVE_POSITION_DEPOSIT
|
|
19225
|
+
type: require_common.TransactionType.MOVE_POSITION_DEPOSIT
|
|
19228
19226
|
});
|
|
19229
19227
|
const transactions = [
|
|
19230
19228
|
...feedCrankTxs,
|
|
@@ -19289,7 +19287,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19289
19287
|
async makeRepayWithCollatTxV2({ repayAmount, withdrawAmount, borrowBankAddress, depositBankAddress, withdrawAll = false, repayAll = false, swap, blockhash: blockhashArg }) {
|
|
19290
19288
|
const blockhash = blockhashArg ?? (await this._program.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
19291
19289
|
const setupIxs = await this.makeSetupIx([borrowBankAddress, depositBankAddress]);
|
|
19292
|
-
const cuRequestIxs = this.makeComputeBudgetIx().length > 0 ? this.makeComputeBudgetIx() : [ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 })];
|
|
19290
|
+
const cuRequestIxs = this.makeComputeBudgetIx().length > 0 ? this.makeComputeBudgetIx() : [__solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1e6 })];
|
|
19293
19291
|
const [priorityFeeIx] = makePriorityFeeIx(1e-5);
|
|
19294
19292
|
const withdrawIxs = await this.makeWithdrawIx(withdrawAmount, depositBankAddress, withdrawAll, {
|
|
19295
19293
|
createAtas: false,
|
|
@@ -19302,22 +19300,22 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19302
19300
|
let flashloanTx;
|
|
19303
19301
|
let txOverflown = false;
|
|
19304
19302
|
if (setupIxs.length > 0) {
|
|
19305
|
-
const message = new TransactionMessage({
|
|
19303
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
19306
19304
|
payerKey: this.client.wallet.publicKey,
|
|
19307
19305
|
recentBlockhash: blockhash,
|
|
19308
19306
|
instructions: setupIxs
|
|
19309
19307
|
}).compileToLegacyMessage();
|
|
19310
|
-
additionalTxs.push(addTransactionMetadata(new VersionedTransaction(message), { type: TransactionType.CREATE_ATA }));
|
|
19308
|
+
additionalTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), { type: require_common.TransactionType.CREATE_ATA }));
|
|
19311
19309
|
}
|
|
19312
19310
|
if (updateFeedIxs.length > 0) {
|
|
19313
|
-
const message = new TransactionMessage({
|
|
19311
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
19314
19312
|
payerKey: this.client.wallet.publicKey,
|
|
19315
19313
|
recentBlockhash: blockhash,
|
|
19316
19314
|
instructions: updateFeedIxs
|
|
19317
19315
|
}).compileToV0Message(feedLuts);
|
|
19318
|
-
additionalTxs.push(addTransactionMetadata(new VersionedTransaction(message), {
|
|
19316
|
+
additionalTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), {
|
|
19319
19317
|
addressLookupTables: feedLuts,
|
|
19320
|
-
type: TransactionType.CRANK
|
|
19318
|
+
type: require_common.TransactionType.CRANK
|
|
19321
19319
|
}));
|
|
19322
19320
|
}
|
|
19323
19321
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
@@ -19333,11 +19331,11 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19333
19331
|
addressLookupTableAccounts,
|
|
19334
19332
|
blockhash
|
|
19335
19333
|
});
|
|
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;
|
|
19334
|
+
const txSize = require_common.getTxSize(flashloanTx);
|
|
19335
|
+
const accountKeys = require_common.getAccountKeys(flashloanTx, addressLookupTableAccounts);
|
|
19336
|
+
const txToManyKeys = accountKeys > require_common.MAX_ACCOUNT_KEYS;
|
|
19337
|
+
const txToBig = txSize > require_common.MAX_TX_SIZE;
|
|
19338
|
+
const canBeDownsized = txToManyKeys && txToBig && txSize - require_common.PRIORITY_TX_SIZE <= require_common.MAX_TX_SIZE;
|
|
19341
19339
|
if (canBeDownsized) {
|
|
19342
19340
|
flashloanTx = await this.buildFlashLoanTx({
|
|
19343
19341
|
ixs: [
|
|
@@ -19349,16 +19347,16 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19349
19347
|
addressLookupTableAccounts,
|
|
19350
19348
|
blockhash
|
|
19351
19349
|
});
|
|
19352
|
-
const txSize$1 = getTxSize(flashloanTx);
|
|
19353
|
-
const txToBig$1 = txSize$1 > MAX_TX_SIZE;
|
|
19350
|
+
const txSize$1 = require_common.getTxSize(flashloanTx);
|
|
19351
|
+
const txToBig$1 = txSize$1 > require_common.MAX_TX_SIZE;
|
|
19354
19352
|
if (txToBig$1) {
|
|
19355
19353
|
txOverflown = true;
|
|
19356
19354
|
}
|
|
19357
19355
|
} else if (txToBig || txToManyKeys) {
|
|
19358
19356
|
txOverflown = true;
|
|
19359
19357
|
}
|
|
19360
|
-
flashloanTx = addTransactionMetadata(flashloanTx, {
|
|
19361
|
-
type: TransactionType.REPAY_COLLAT,
|
|
19358
|
+
flashloanTx = require_common.addTransactionMetadata(flashloanTx, {
|
|
19359
|
+
type: require_common.TransactionType.REPAY_COLLAT,
|
|
19362
19360
|
addressLookupTables: flashloanTx.addressLookupTables
|
|
19363
19361
|
});
|
|
19364
19362
|
const transactions = [...additionalTxs, flashloanTx];
|
|
@@ -19396,7 +19394,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19396
19394
|
if (!borrowBank) throw Error("Borrow bank not found");
|
|
19397
19395
|
const blockhash = blockhashArg ?? (await this._program.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
19398
19396
|
const setupIxs = await this.makeSetupIx(setupBankAddresses ?? [borrowBankAddress, depositBankAddress]);
|
|
19399
|
-
const cuRequestIxs = this.makeComputeBudgetIx().length > 0 ? this.makeComputeBudgetIx() : [ComputeBudgetProgram.setComputeUnitLimit({ units: 5e5 })];
|
|
19397
|
+
const cuRequestIxs = this.makeComputeBudgetIx().length > 0 ? this.makeComputeBudgetIx() : [__solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 5e5 })];
|
|
19400
19398
|
const [priorityFeeIx] = makePriorityFeeIx(1e-5);
|
|
19401
19399
|
const borrowIxs = await this.makeBorrowIx(borrowAmount, borrowBankAddress, {
|
|
19402
19400
|
createAtas: false,
|
|
@@ -19412,26 +19410,26 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19412
19410
|
const additionalTxs = [];
|
|
19413
19411
|
let flashloanTx;
|
|
19414
19412
|
let txOverflown = false;
|
|
19415
|
-
if (depositBank.mint.equals(NATIVE_MINT) && inputDepositAmount) {
|
|
19416
|
-
setupIxs.push(...makeWrapSolIxs(this.authority, new
|
|
19413
|
+
if (depositBank.mint.equals(__solana_spl_token.NATIVE_MINT) && inputDepositAmount) {
|
|
19414
|
+
setupIxs.push(...makeWrapSolIxs(this.authority, new bignumber_js.default(inputDepositAmount)));
|
|
19417
19415
|
}
|
|
19418
19416
|
if (setupIxs.length > 0) {
|
|
19419
|
-
const message = new TransactionMessage({
|
|
19417
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
19420
19418
|
payerKey: this.client.wallet.publicKey,
|
|
19421
19419
|
recentBlockhash: blockhash,
|
|
19422
19420
|
instructions: setupIxs
|
|
19423
19421
|
}).compileToLegacyMessage();
|
|
19424
|
-
additionalTxs.push(addTransactionMetadata(new VersionedTransaction(message), { type: TransactionType.CREATE_ATA }));
|
|
19422
|
+
additionalTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), { type: require_common.TransactionType.CREATE_ATA }));
|
|
19425
19423
|
}
|
|
19426
19424
|
if (updateFeedIxs.length > 0) {
|
|
19427
|
-
const message = new TransactionMessage({
|
|
19425
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
19428
19426
|
payerKey: this.client.wallet.publicKey,
|
|
19429
19427
|
recentBlockhash: blockhash,
|
|
19430
19428
|
instructions: updateFeedIxs
|
|
19431
19429
|
}).compileToV0Message(feedLuts);
|
|
19432
|
-
additionalTxs.push(addTransactionMetadata(new VersionedTransaction(message), {
|
|
19430
|
+
additionalTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), {
|
|
19433
19431
|
addressLookupTables: feedLuts,
|
|
19434
|
-
type: TransactionType.CRANK
|
|
19432
|
+
type: require_common.TransactionType.CRANK
|
|
19435
19433
|
}));
|
|
19436
19434
|
}
|
|
19437
19435
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
@@ -19447,11 +19445,11 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19447
19445
|
addressLookupTableAccounts,
|
|
19448
19446
|
blockhash
|
|
19449
19447
|
});
|
|
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;
|
|
19448
|
+
const txSize = require_common.getTxSize(flashloanTx);
|
|
19449
|
+
const accountKeys = require_common.getAccountKeys(flashloanTx, addressLookupTableAccounts);
|
|
19450
|
+
const txToManyKeys = accountKeys > require_common.MAX_ACCOUNT_KEYS;
|
|
19451
|
+
const txToBig = txSize > require_common.MAX_TX_SIZE;
|
|
19452
|
+
const canBeDownsized = txToManyKeys && txToBig && txSize - require_common.PRIORITY_TX_SIZE <= require_common.MAX_TX_SIZE;
|
|
19455
19453
|
if (canBeDownsized) {
|
|
19456
19454
|
flashloanTx = await this.buildFlashLoanTx({
|
|
19457
19455
|
ixs: [
|
|
@@ -19463,16 +19461,16 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19463
19461
|
addressLookupTableAccounts,
|
|
19464
19462
|
blockhash
|
|
19465
19463
|
});
|
|
19466
|
-
const txSize$1 = getTxSize(flashloanTx);
|
|
19467
|
-
const txToBig$1 = txSize$1 > MAX_TX_SIZE;
|
|
19464
|
+
const txSize$1 = require_common.getTxSize(flashloanTx);
|
|
19465
|
+
const txToBig$1 = txSize$1 > require_common.MAX_TX_SIZE;
|
|
19468
19466
|
if (txToBig$1) {
|
|
19469
19467
|
txOverflown = true;
|
|
19470
19468
|
}
|
|
19471
19469
|
} else if (txToBig || txToManyKeys) {
|
|
19472
19470
|
txOverflown = true;
|
|
19473
19471
|
}
|
|
19474
|
-
flashloanTx = addTransactionMetadata(flashloanTx, {
|
|
19475
|
-
type: TransactionType.LOOP,
|
|
19472
|
+
flashloanTx = require_common.addTransactionMetadata(flashloanTx, {
|
|
19473
|
+
type: require_common.TransactionType.LOOP,
|
|
19476
19474
|
addressLookupTables: flashloanTx.addressLookupTables
|
|
19477
19475
|
});
|
|
19478
19476
|
const transactions = [...additionalTxs, flashloanTx];
|
|
@@ -19519,12 +19517,12 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19519
19517
|
*/
|
|
19520
19518
|
async makeCloseAccountTx() {
|
|
19521
19519
|
const ix = await this.makeCloseAccountIx();
|
|
19522
|
-
const tx = new Transaction().add(...ix.instructions);
|
|
19520
|
+
const tx = new __solana_web3_js.Transaction().add(...ix.instructions);
|
|
19523
19521
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19524
|
-
return addTransactionMetadata(tx, {
|
|
19522
|
+
return require_common.addTransactionMetadata(tx, {
|
|
19525
19523
|
signers: ix.keys,
|
|
19526
19524
|
addressLookupTables: clientLookupTables,
|
|
19527
|
-
type: TransactionType.CLOSE_ACCOUNT
|
|
19525
|
+
type: require_common.TransactionType.CLOSE_ACCOUNT
|
|
19528
19526
|
});
|
|
19529
19527
|
}
|
|
19530
19528
|
/**
|
|
@@ -19560,17 +19558,17 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19560
19558
|
const poolStakeAddress = findPoolStakeAddress(pool);
|
|
19561
19559
|
const lstMint = findPoolMintAddress(pool);
|
|
19562
19560
|
const auth = findPoolStakeAuthorityAddress(pool);
|
|
19563
|
-
const lstAta = getAssociatedTokenAddressSync(lstMint, this.authority);
|
|
19561
|
+
const lstAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(lstMint, this.authority);
|
|
19564
19562
|
const [lstAccInfo, stakeAccountInfo, stakeAccInfoParsed] = await Promise.all([
|
|
19565
19563
|
this.client.provider.connection.getAccountInfo(lstAta),
|
|
19566
19564
|
this._program.provider.connection.getAccountInfo(stakeAccountPk),
|
|
19567
19565
|
this._program.provider.connection.getParsedAccountInfo(stakeAccountPk)
|
|
19568
19566
|
]);
|
|
19569
19567
|
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);
|
|
19568
|
+
const [rentExemptReserve, minimumDelegation] = await Promise.all([this._program.provider.connection.getMinimumBalanceForRentExemption(__solana_web3_js.StakeProgram.space), this._program.provider.connection.getStakeMinimumDelegation().then((res) => {
|
|
19569
|
+
return Math.max(res.value, __solana_web3_js.LAMPORTS_PER_SOL);
|
|
19572
19570
|
})]);
|
|
19573
|
-
const amountLamports = Math.round(Number(amount) * LAMPORTS_PER_SOL);
|
|
19571
|
+
const amountLamports = Math.round(Number(amount) * __solana_web3_js.LAMPORTS_PER_SOL);
|
|
19574
19572
|
const stakeAccLamports = Number(stakeAccParsed.parsed.info.stake?.delegation?.stake ?? 0);
|
|
19575
19573
|
const isFullStake = amountLamports >= stakeAccLamports;
|
|
19576
19574
|
const poolStakeAccLamports = (await this._program.provider.connection.getAccountInfo(poolStakeAddress))?.lamports ?? 0;
|
|
@@ -19584,14 +19582,14 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19584
19582
|
const instructions$3 = [];
|
|
19585
19583
|
const signers = [];
|
|
19586
19584
|
if (!lstAccInfo) {
|
|
19587
|
-
instructions$3.push(createAssociatedTokenAccountInstruction(this.authority, lstAta, this.authority, lstMint));
|
|
19585
|
+
instructions$3.push((0, __solana_spl_token.createAssociatedTokenAccountInstruction)(this.authority, lstAta, this.authority, lstMint));
|
|
19588
19586
|
}
|
|
19589
19587
|
let targetStakePubkey;
|
|
19590
19588
|
if (!isFullStake) {
|
|
19591
|
-
const splitStakeAccount = Keypair.generate();
|
|
19589
|
+
const splitStakeAccount = __solana_web3_js.Keypair.generate();
|
|
19592
19590
|
signers.push(splitStakeAccount);
|
|
19593
19591
|
targetStakePubkey = splitStakeAccount.publicKey;
|
|
19594
|
-
instructions$3.push(...StakeProgram.split({
|
|
19592
|
+
instructions$3.push(...__solana_web3_js.StakeProgram.split({
|
|
19595
19593
|
stakePubkey: stakeAccountPk,
|
|
19596
19594
|
authorizedPubkey: this.authority,
|
|
19597
19595
|
splitStakePubkey: splitStakeAccount.publicKey,
|
|
@@ -19600,44 +19598,44 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19600
19598
|
} else {
|
|
19601
19599
|
targetStakePubkey = stakeAccountPk;
|
|
19602
19600
|
}
|
|
19603
|
-
const [authorizeStakerIx, authorizeWithdrawIx] = await Promise.all([StakeProgram.authorize({
|
|
19601
|
+
const [authorizeStakerIx, authorizeWithdrawIx] = await Promise.all([__solana_web3_js.StakeProgram.authorize({
|
|
19604
19602
|
stakePubkey: targetStakePubkey,
|
|
19605
19603
|
authorizedPubkey: this.authority,
|
|
19606
19604
|
newAuthorizedPubkey: auth,
|
|
19607
|
-
stakeAuthorizationType: StakeAuthorizationLayout.Staker
|
|
19608
|
-
}).instructions, StakeProgram.authorize({
|
|
19605
|
+
stakeAuthorizationType: __solana_web3_js.StakeAuthorizationLayout.Staker
|
|
19606
|
+
}).instructions, __solana_web3_js.StakeProgram.authorize({
|
|
19609
19607
|
stakePubkey: targetStakePubkey,
|
|
19610
19608
|
authorizedPubkey: this.authority,
|
|
19611
19609
|
newAuthorizedPubkey: auth,
|
|
19612
|
-
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer
|
|
19610
|
+
stakeAuthorizationType: __solana_web3_js.StakeAuthorizationLayout.Withdrawer
|
|
19613
19611
|
}).instructions]);
|
|
19614
19612
|
[authorizeStakerIx[0], authorizeWithdrawIx[0]].forEach((ix) => {
|
|
19615
19613
|
ix.keys = ix.keys.map((key) => ({
|
|
19616
19614
|
...key,
|
|
19617
|
-
isWritable: key.pubkey.equals(SYSVAR_CLOCK_ID) ? false : key.isWritable
|
|
19615
|
+
isWritable: key.pubkey.equals(require_common.SYSVAR_CLOCK_ID) ? false : key.isWritable
|
|
19618
19616
|
}));
|
|
19619
19617
|
});
|
|
19620
19618
|
instructions$3.push(...authorizeStakerIx, ...authorizeWithdrawIx);
|
|
19621
19619
|
const depositStakeIx = await SinglePoolInstruction.depositStake(pool, targetStakePubkey, lstAta, this.authority);
|
|
19622
19620
|
const lendrDepositIxs = await this.makeDepositIx(newPoolTokens / 1e9, bankAddress, depositOpts);
|
|
19623
19621
|
instructions$3.push(depositStakeIx, ...lendrDepositIxs.instructions);
|
|
19624
|
-
const transaction = new Transaction().add(...instructions$3);
|
|
19625
|
-
return addTransactionMetadata(transaction, {
|
|
19626
|
-
type: TransactionType.DEPOSIT_STAKE,
|
|
19622
|
+
const transaction = new __solana_web3_js.Transaction().add(...instructions$3);
|
|
19623
|
+
return require_common.addTransactionMetadata(transaction, {
|
|
19624
|
+
type: require_common.TransactionType.DEPOSIT_STAKE,
|
|
19627
19625
|
signers: [...signers, ...lendrDepositIxs.keys],
|
|
19628
19626
|
addressLookupTables: this.client.addressLookupTables
|
|
19629
19627
|
});
|
|
19630
19628
|
}
|
|
19631
19629
|
async makeMergeStakeAccountsTx(stakeAccountSrc, stakeAccountDest) {
|
|
19632
|
-
const mergeInstruction = StakeProgram.merge({
|
|
19630
|
+
const mergeInstruction = __solana_web3_js.StakeProgram.merge({
|
|
19633
19631
|
stakePubkey: stakeAccountDest,
|
|
19634
19632
|
sourceStakePubKey: stakeAccountSrc,
|
|
19635
19633
|
authorizedPubkey: this.authority
|
|
19636
19634
|
});
|
|
19637
|
-
const transaction = new Transaction().add(mergeInstruction);
|
|
19635
|
+
const transaction = new __solana_web3_js.Transaction().add(mergeInstruction);
|
|
19638
19636
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19639
|
-
return addTransactionMetadata(transaction, {
|
|
19640
|
-
type: TransactionType.MERGE_STAKE_ACCOUNTS,
|
|
19637
|
+
return require_common.addTransactionMetadata(transaction, {
|
|
19638
|
+
type: require_common.TransactionType.MERGE_STAKE_ACCOUNTS,
|
|
19641
19639
|
signers: [],
|
|
19642
19640
|
addressLookupTables: clientLookupTables
|
|
19643
19641
|
});
|
|
@@ -19691,10 +19689,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19691
19689
|
*/
|
|
19692
19690
|
async makeDepositTx(amount, bankAddress, depositOpts = {}) {
|
|
19693
19691
|
const ixs = await this.makeDepositIx(amount, bankAddress, depositOpts);
|
|
19694
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
19692
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
19695
19693
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19696
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
19697
|
-
type: TransactionType.DEPOSIT,
|
|
19694
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
19695
|
+
type: require_common.TransactionType.DEPOSIT,
|
|
19698
19696
|
signers: ixs.keys,
|
|
19699
19697
|
addressLookupTables: clientLookupTables
|
|
19700
19698
|
});
|
|
@@ -19702,10 +19700,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19702
19700
|
}
|
|
19703
19701
|
async makeDepositWithSessionTx(amount, bankAddress, sessionKey, depositOpts = {}) {
|
|
19704
19702
|
const ixs = await this.makeDepositWithSessionIx(amount, bankAddress, sessionKey, depositOpts);
|
|
19705
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
19703
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
19706
19704
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19707
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
19708
|
-
type: TransactionType.DEPOSIT,
|
|
19705
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
19706
|
+
type: require_common.TransactionType.DEPOSIT,
|
|
19709
19707
|
signers: ixs.keys,
|
|
19710
19708
|
addressLookupTables: clientLookupTables
|
|
19711
19709
|
});
|
|
@@ -19723,11 +19721,11 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19723
19721
|
async simulateBorrowLendTransaction(txs, banksToInspect, healthSimOptions) {
|
|
19724
19722
|
const additionalTxs = [];
|
|
19725
19723
|
if (healthSimOptions?.enabled) {
|
|
19726
|
-
const computeIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 });
|
|
19724
|
+
const computeIx = __solana_web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 });
|
|
19727
19725
|
const updateFeedIx = await this.makeUpdateFeedIx(healthSimOptions.mandatoryBanks);
|
|
19728
19726
|
const healthPulseIx = await this.makePulseHealthIx(healthSimOptions.mandatoryBanks, healthSimOptions.excludedBanks);
|
|
19729
19727
|
const blockhash = (await this.client.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
19730
|
-
const tx = new VersionedTransaction(new TransactionMessage({
|
|
19728
|
+
const tx = new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
19731
19729
|
instructions: [
|
|
19732
19730
|
computeIx,
|
|
19733
19731
|
...updateFeedIx.instructions,
|
|
@@ -19861,10 +19859,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19861
19859
|
*/
|
|
19862
19860
|
async makeRepayTx(amount, bankAddress, repayAll = false, repayOpts = {}) {
|
|
19863
19861
|
const ixs = await this.makeRepayIx(amount, bankAddress, repayAll, repayOpts);
|
|
19864
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
19862
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
19865
19863
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19866
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
19867
|
-
type: TransactionType.REPAY,
|
|
19864
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
19865
|
+
type: require_common.TransactionType.REPAY,
|
|
19868
19866
|
signers: ixs.keys,
|
|
19869
19867
|
addressLookupTables: clientLookupTables
|
|
19870
19868
|
});
|
|
@@ -19881,10 +19879,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19881
19879
|
*/
|
|
19882
19880
|
async makeRepayWithSessionTx(amount, bankAddress, sessionKey, repayAll = false, repayOpts = {}) {
|
|
19883
19881
|
const ixs = await this.makeRepayWithSessionIx(amount, bankAddress, sessionKey, repayAll, repayOpts);
|
|
19884
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
19882
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
19885
19883
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
19886
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
19887
|
-
type: TransactionType.REPAY,
|
|
19884
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
19885
|
+
type: require_common.TransactionType.REPAY,
|
|
19888
19886
|
signers: ixs.keys,
|
|
19889
19887
|
addressLookupTables: clientLookupTables
|
|
19890
19888
|
});
|
|
@@ -19935,7 +19933,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19935
19933
|
*/
|
|
19936
19934
|
async makeWithdrawStakedTx(amount, bankAddress, isWholePosition) {
|
|
19937
19935
|
const bank = this.client.getBankByPk(bankAddress);
|
|
19938
|
-
const solBank = this.client.getBankByMint(WSOL_MINT);
|
|
19936
|
+
const solBank = this.client.getBankByMint(require_common.WSOL_MINT);
|
|
19939
19937
|
const bankMetadata = this.client.bankMetadataMap[bankAddress.toBase58()];
|
|
19940
19938
|
if (!bank || !solBank) {
|
|
19941
19939
|
throw new Error("Banks not found");
|
|
@@ -19943,38 +19941,38 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19943
19941
|
if (!bankMetadata.validatorVoteAccount) {
|
|
19944
19942
|
throw new Error("Validator vote account not found");
|
|
19945
19943
|
}
|
|
19946
|
-
const pool = findPoolAddress(new PublicKey(bankMetadata.validatorVoteAccount));
|
|
19944
|
+
const pool = findPoolAddress(new __solana_web3_js.PublicKey(bankMetadata.validatorVoteAccount));
|
|
19947
19945
|
const lstMint = findPoolMintAddress(pool);
|
|
19948
19946
|
const mintAuthority = findPoolMintAuthorityAddress(pool);
|
|
19949
|
-
const lstAta = getAssociatedTokenAddressSync(lstMint, this.authority);
|
|
19947
|
+
const lstAta = (0, __solana_spl_token.getAssociatedTokenAddressSync)(lstMint, this.authority);
|
|
19950
19948
|
const rentExemption = await this._program.provider.connection.getMinimumBalanceForRentExemption(200);
|
|
19951
|
-
const stakeAmount = new
|
|
19949
|
+
const stakeAmount = new bignumber_js.default(new bignumber_js.default(amount).toString());
|
|
19952
19950
|
const withdrawIxs = await this.makeWithdrawIx(amount, bankAddress, isWholePosition, {
|
|
19953
19951
|
createAtas: true,
|
|
19954
19952
|
wrapAndUnwrapSol: true
|
|
19955
19953
|
});
|
|
19956
|
-
const stakeAccount = Keypair.generate();
|
|
19957
|
-
const createStakeAccountIx = SystemProgram.createAccount({
|
|
19954
|
+
const stakeAccount = __solana_web3_js.Keypair.generate();
|
|
19955
|
+
const createStakeAccountIx = __solana_web3_js.SystemProgram.createAccount({
|
|
19958
19956
|
fromPubkey: this.authority,
|
|
19959
19957
|
newAccountPubkey: stakeAccount.publicKey,
|
|
19960
19958
|
lamports: rentExemption,
|
|
19961
19959
|
space: 200,
|
|
19962
|
-
programId: STAKE_PROGRAM_ID
|
|
19960
|
+
programId: require_common.STAKE_PROGRAM_ID
|
|
19963
19961
|
});
|
|
19964
|
-
const approveAccountAuthorityIx = createApproveInstruction(lstAta, mintAuthority, this.authority, stakeAmount.multipliedBy(1e9).toNumber(), [], TOKEN_PROGRAM_ID);
|
|
19962
|
+
const approveAccountAuthorityIx = (0, __solana_spl_token.createApproveInstruction)(lstAta, mintAuthority, this.authority, stakeAmount.multipliedBy(1e9).toNumber(), [], __solana_spl_token.TOKEN_PROGRAM_ID);
|
|
19965
19963
|
const withdrawStakeIx = await SinglePoolInstruction.withdrawStake(pool, stakeAccount.publicKey, this.authority, lstAta, stakeAmount);
|
|
19966
19964
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
19967
|
-
const withdrawMessage = new TransactionMessage({
|
|
19965
|
+
const withdrawMessage = new __solana_web3_js.TransactionMessage({
|
|
19968
19966
|
payerKey: this.client.wallet.publicKey,
|
|
19969
19967
|
recentBlockhash: blockhash,
|
|
19970
19968
|
instructions: [...withdrawIxs.instructions]
|
|
19971
19969
|
}).compileToV0Message(this.client.addressLookupTables);
|
|
19972
|
-
const withdrawTxn = addTransactionMetadata(new VersionedTransaction(withdrawMessage), {
|
|
19970
|
+
const withdrawTxn = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(withdrawMessage), {
|
|
19973
19971
|
signers: withdrawIxs.keys,
|
|
19974
19972
|
addressLookupTables: this.client.addressLookupTables,
|
|
19975
|
-
type: TransactionType.WITHDRAW
|
|
19973
|
+
type: require_common.TransactionType.WITHDRAW
|
|
19976
19974
|
});
|
|
19977
|
-
const stakeMessage = new TransactionMessage({
|
|
19975
|
+
const stakeMessage = new __solana_web3_js.TransactionMessage({
|
|
19978
19976
|
payerKey: this.client.wallet.publicKey,
|
|
19979
19977
|
recentBlockhash: blockhash,
|
|
19980
19978
|
instructions: [
|
|
@@ -19983,10 +19981,10 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
19983
19981
|
withdrawStakeIx
|
|
19984
19982
|
]
|
|
19985
19983
|
}).compileToV0Message(this.client.addressLookupTables);
|
|
19986
|
-
const stakeTxn = addTransactionMetadata(new VersionedTransaction(stakeMessage), {
|
|
19984
|
+
const stakeTxn = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(stakeMessage), {
|
|
19987
19985
|
signers: [stakeAccount],
|
|
19988
19986
|
addressLookupTables: this.client.addressLookupTables,
|
|
19989
|
-
type: TransactionType.WITHDRAW_STAKE
|
|
19987
|
+
type: require_common.TransactionType.WITHDRAW_STAKE
|
|
19990
19988
|
});
|
|
19991
19989
|
return {
|
|
19992
19990
|
transactions: [withdrawTxn, stakeTxn],
|
|
@@ -20022,12 +20020,12 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20022
20020
|
const cuRequestIxs = this.makeComputeBudgetIx();
|
|
20023
20021
|
const withdrawIxs = withdrawIxsWrapped.flatMap((ix) => ix.instructions);
|
|
20024
20022
|
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);
|
|
20023
|
+
const tx = new __solana_web3_js.Transaction().add(...cuRequestIxs, ...withdrawIxs);
|
|
20026
20024
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20027
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
20025
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
20028
20026
|
signers: filteredSigners,
|
|
20029
20027
|
addressLookupTables: clientLookupTables,
|
|
20030
|
-
type: TransactionType.WITHDRAW_ALL
|
|
20028
|
+
type: require_common.TransactionType.WITHDRAW_ALL
|
|
20031
20029
|
});
|
|
20032
20030
|
return solanaTx;
|
|
20033
20031
|
}
|
|
@@ -20094,24 +20092,24 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20094
20092
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
20095
20093
|
const feedCrankTxs = [];
|
|
20096
20094
|
if (updateFeedIxs.length > 0) {
|
|
20097
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20095
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20098
20096
|
instructions: [...updateFeedIxs],
|
|
20099
20097
|
payerKey: this.authority,
|
|
20100
20098
|
recentBlockhash: blockhash
|
|
20101
20099
|
}).compileToV0Message(feedLuts)), {
|
|
20102
20100
|
addressLookupTables: feedLuts,
|
|
20103
|
-
type: TransactionType.CRANK
|
|
20101
|
+
type: require_common.TransactionType.CRANK
|
|
20104
20102
|
}));
|
|
20105
20103
|
}
|
|
20106
20104
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20107
|
-
const withdrawTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20105
|
+
const withdrawTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20108
20106
|
instructions: [...cuRequestIxs, ...withdrawIxs.instructions],
|
|
20109
20107
|
payerKey: this.authority,
|
|
20110
20108
|
recentBlockhash: blockhash
|
|
20111
20109
|
}).compileToV0Message(clientLookupTables)), {
|
|
20112
20110
|
signers: withdrawIxs.keys,
|
|
20113
20111
|
addressLookupTables: clientLookupTables,
|
|
20114
|
-
type: TransactionType.WITHDRAW
|
|
20112
|
+
type: require_common.TransactionType.WITHDRAW
|
|
20115
20113
|
});
|
|
20116
20114
|
const transactions = [...feedCrankTxs, withdrawTx];
|
|
20117
20115
|
return {
|
|
@@ -20136,24 +20134,24 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20136
20134
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
20137
20135
|
const feedCrankTxs = [];
|
|
20138
20136
|
if (updateFeedIxs.length > 0) {
|
|
20139
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20137
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20140
20138
|
instructions: [...updateFeedIxs],
|
|
20141
20139
|
payerKey: this.authority,
|
|
20142
20140
|
recentBlockhash: blockhash
|
|
20143
20141
|
}).compileToV0Message(feedLuts)), {
|
|
20144
20142
|
addressLookupTables: feedLuts,
|
|
20145
|
-
type: TransactionType.CRANK
|
|
20143
|
+
type: require_common.TransactionType.CRANK
|
|
20146
20144
|
}));
|
|
20147
20145
|
}
|
|
20148
20146
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20149
|
-
const withdrawTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20147
|
+
const withdrawTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20150
20148
|
instructions: [...cuRequestIxs, ...withdrawIxs.instructions],
|
|
20151
20149
|
payerKey: this.authority,
|
|
20152
20150
|
recentBlockhash: blockhash
|
|
20153
20151
|
}).compileToV0Message(clientLookupTables)), {
|
|
20154
20152
|
signers: withdrawIxs.keys,
|
|
20155
20153
|
addressLookupTables: clientLookupTables,
|
|
20156
|
-
type: TransactionType.WITHDRAW
|
|
20154
|
+
type: require_common.TransactionType.WITHDRAW
|
|
20157
20155
|
});
|
|
20158
20156
|
const transactions = [...feedCrankTxs, withdrawTx];
|
|
20159
20157
|
return {
|
|
@@ -20256,23 +20254,23 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20256
20254
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
20257
20255
|
const feedCrankTxs = [];
|
|
20258
20256
|
if (updateFeedIxs.length > 0) {
|
|
20259
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20257
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20260
20258
|
instructions: updateFeedIxs,
|
|
20261
20259
|
payerKey: this.authority,
|
|
20262
20260
|
recentBlockhash: blockhash
|
|
20263
20261
|
}).compileToV0Message(feedLuts)), {
|
|
20264
|
-
type: TransactionType.CRANK,
|
|
20262
|
+
type: require_common.TransactionType.CRANK,
|
|
20265
20263
|
addressLookupTables: feedLuts
|
|
20266
20264
|
}));
|
|
20267
20265
|
}
|
|
20268
20266
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20269
|
-
const borrowTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20267
|
+
const borrowTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20270
20268
|
instructions: [...cuRequestIxs, ...borrowIxs.instructions],
|
|
20271
20269
|
payerKey: this.authority,
|
|
20272
20270
|
recentBlockhash: blockhash
|
|
20273
20271
|
}).compileToV0Message(clientLookupTables)), {
|
|
20274
20272
|
signers: borrowIxs.keys,
|
|
20275
|
-
type: TransactionType.BORROW,
|
|
20273
|
+
type: require_common.TransactionType.BORROW,
|
|
20276
20274
|
addressLookupTables: clientLookupTables
|
|
20277
20275
|
});
|
|
20278
20276
|
const transactions = [...feedCrankTxs, borrowTx];
|
|
@@ -20297,23 +20295,23 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20297
20295
|
const { value: { blockhash } } = await this._program.provider.connection.getLatestBlockhashAndContext("confirmed");
|
|
20298
20296
|
const feedCrankTxs = [];
|
|
20299
20297
|
if (updateFeedIxs.length > 0) {
|
|
20300
|
-
feedCrankTxs.push(addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20298
|
+
feedCrankTxs.push(require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20301
20299
|
instructions: updateFeedIxs,
|
|
20302
20300
|
payerKey: this.authority,
|
|
20303
20301
|
recentBlockhash: blockhash
|
|
20304
20302
|
}).compileToV0Message(feedLuts)), {
|
|
20305
|
-
type: TransactionType.CRANK,
|
|
20303
|
+
type: require_common.TransactionType.CRANK,
|
|
20306
20304
|
addressLookupTables: feedLuts
|
|
20307
20305
|
}));
|
|
20308
20306
|
}
|
|
20309
20307
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20310
|
-
const borrowTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20308
|
+
const borrowTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20311
20309
|
instructions: [...cuRequestIxs, ...borrowIxs.instructions],
|
|
20312
20310
|
payerKey: this.authority,
|
|
20313
20311
|
recentBlockhash: blockhash
|
|
20314
20312
|
}).compileToV0Message(clientLookupTables)), {
|
|
20315
20313
|
signers: borrowIxs.keys,
|
|
20316
|
-
type: TransactionType.BORROW,
|
|
20314
|
+
type: require_common.TransactionType.BORROW,
|
|
20317
20315
|
addressLookupTables: clientLookupTables
|
|
20318
20316
|
});
|
|
20319
20317
|
const transactions = [...feedCrankTxs, borrowTx];
|
|
@@ -20351,13 +20349,13 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20351
20349
|
withdrawEmissionsIxs.push(ix);
|
|
20352
20350
|
}));
|
|
20353
20351
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20354
|
-
const emissionsTx = addTransactionMetadata(new VersionedTransaction(new TransactionMessage({
|
|
20352
|
+
const emissionsTx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(new __solana_web3_js.TransactionMessage({
|
|
20355
20353
|
instructions: withdrawEmissionsIxs.flatMap((ix) => ix.instructions),
|
|
20356
20354
|
payerKey: this.authority,
|
|
20357
20355
|
recentBlockhash: blockhash
|
|
20358
20356
|
}).compileToV0Message(clientLookupTables)), {
|
|
20359
20357
|
signers: withdrawEmissionsIxs.flatMap((ix) => ix.keys),
|
|
20360
|
-
type: TransactionType.WITHDRAW_EMISSIONS,
|
|
20358
|
+
type: require_common.TransactionType.WITHDRAW_EMISSIONS,
|
|
20361
20359
|
addressLookupTables: clientLookupTables
|
|
20362
20360
|
});
|
|
20363
20361
|
return emissionsTx;
|
|
@@ -20415,12 +20413,12 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20415
20413
|
liquidateeLendrAccount: liquidateeLendrAccount.address.toBase58()
|
|
20416
20414
|
}, "[lendr:lendr-account:liquidation] Liquidating lendr account");
|
|
20417
20415
|
const liquidationIxs = await this.makeLendingAccountLiquidateIx(liquidateeLendrAccount, assetBankAddress, assetQuantityUi, liabBankAddress);
|
|
20418
|
-
const tx = new Transaction().add(...liquidationIxs.instructions);
|
|
20416
|
+
const tx = new __solana_web3_js.Transaction().add(...liquidationIxs.instructions);
|
|
20419
20417
|
const clientLookupTables = await getClientAddressLookupTableAccounts(this.client);
|
|
20420
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
20418
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
20421
20419
|
signers: liquidationIxs.keys,
|
|
20422
20420
|
addressLookupTables: clientLookupTables,
|
|
20423
|
-
type: TransactionType.LIQUIDATE_ACCOUNT
|
|
20421
|
+
type: require_common.TransactionType.LIQUIDATE_ACCOUNT
|
|
20424
20422
|
});
|
|
20425
20423
|
const sig = await this.client.processTransaction(solanaTx, processOpts, txOpts);
|
|
20426
20424
|
this.client.logger.debug({
|
|
@@ -20470,14 +20468,14 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20470
20468
|
];
|
|
20471
20469
|
const totalLookupTables = [...lookupTables ?? [], ...args.addressLookupTableAccounts ?? []];
|
|
20472
20470
|
const blockhash = args.blockhash ?? (await this._program.provider.connection.getLatestBlockhash("confirmed")).blockhash;
|
|
20473
|
-
const message = new TransactionMessage({
|
|
20471
|
+
const message = new __solana_web3_js.TransactionMessage({
|
|
20474
20472
|
payerKey: this.client.wallet.publicKey,
|
|
20475
20473
|
recentBlockhash: blockhash,
|
|
20476
20474
|
instructions: flashloanIxs
|
|
20477
20475
|
}).compileToV0Message(totalLookupTables);
|
|
20478
|
-
const tx = addTransactionMetadata(new VersionedTransaction(message), {
|
|
20476
|
+
const tx = require_common.addTransactionMetadata(new __solana_web3_js.VersionedTransaction(message), {
|
|
20479
20477
|
addressLookupTables: totalLookupTables,
|
|
20480
|
-
type: TransactionType.FLASHLOAN
|
|
20478
|
+
type: require_common.TransactionType.FLASHLOAN
|
|
20481
20479
|
});
|
|
20482
20480
|
if (args.signers) {
|
|
20483
20481
|
tx.sign(args.signers);
|
|
@@ -20493,8 +20491,8 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20493
20491
|
to: newAccountAuthority.toBase58()
|
|
20494
20492
|
}, "[lendr:lendr-account:transfer-authority] Transferring account");
|
|
20495
20493
|
const ixs = await this.makeTransferAccountAuthorityIx(newAccountAuthority);
|
|
20496
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
20497
|
-
const solanaTx = addTransactionMetadata(tx, { type: TransactionType.TRANSFER_AUTH });
|
|
20494
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
20495
|
+
const solanaTx = require_common.addTransactionMetadata(tx, { type: require_common.TransactionType.TRANSFER_AUTH });
|
|
20498
20496
|
const sig = await this.client.processTransaction(solanaTx, processOpts, txOpts);
|
|
20499
20497
|
this.client.logger.debug({ sig }, "[lendr:lendr-account:transfer-authority] Transfer successful");
|
|
20500
20498
|
return sig;
|
|
@@ -20512,13 +20510,13 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20512
20510
|
return this._lendrAccount.makePulseHealthIx(this._program, this.client.banks, mandatoryBanks, excludedBanks, this.client.bankMetadataMap || {});
|
|
20513
20511
|
}
|
|
20514
20512
|
static async _fetchAccountData(accountAddress, config, program, commitment) {
|
|
20515
|
-
const mergedCommitment = commitment ?? program.provider.connection.commitment ?? DEFAULT_COMMITMENT;
|
|
20513
|
+
const mergedCommitment = commitment ?? program.provider.connection.commitment ?? require_common.DEFAULT_COMMITMENT;
|
|
20516
20514
|
const data = await program.account.lendrAccount.fetch(accountAddress, mergedCommitment);
|
|
20517
20515
|
if (!data.group.equals(config.groupPk)) throw Error(`Lendr account tied to group ${data.group.toBase58()}. Expected: ${config.groupPk.toBase58()}`);
|
|
20518
20516
|
return data;
|
|
20519
20517
|
}
|
|
20520
20518
|
static async encode(decoded, idl) {
|
|
20521
|
-
const coder = new BorshCoder(idl);
|
|
20519
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
20522
20520
|
return await coder.accounts.encode(AccountType.LendrAccount, decoded);
|
|
20523
20521
|
}
|
|
20524
20522
|
async reload() {
|
|
@@ -20540,7 +20538,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20540
20538
|
*/
|
|
20541
20539
|
async simulateDeposit(amount, bankAddress) {
|
|
20542
20540
|
const ixs = await this.makeDepositIx(amount, bankAddress);
|
|
20543
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
20541
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
20544
20542
|
try {
|
|
20545
20543
|
return this.simulateBorrowLendTransaction([tx], [bankAddress]);
|
|
20546
20544
|
} catch (e) {
|
|
@@ -20572,7 +20570,7 @@ var LendrAccountWrapper = class LendrAccountWrapper {
|
|
|
20572
20570
|
*/
|
|
20573
20571
|
async simulateRepay(amount, bankAddress, repayAll = false) {
|
|
20574
20572
|
const ixs = await this.makeRepayIx(amount, bankAddress, repayAll);
|
|
20575
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
20573
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
20576
20574
|
try {
|
|
20577
20575
|
return this.simulateBorrowLendTransaction([tx], [bankAddress]);
|
|
20578
20576
|
} catch (e) {
|
|
@@ -20587,7 +20585,7 @@ function makeTxPriorityIx(feePayer, feeUi = 0, broadcastType = "BUNDLE", compute
|
|
|
20587
20585
|
let bundleTipIx;
|
|
20588
20586
|
let priorityFeeIx = makePriorityFeeIx()[0];
|
|
20589
20587
|
if (broadcastType === "BUNDLE") {
|
|
20590
|
-
bundleTipIx = makeBundleTipIx(feePayer, Math.trunc(feeUi * LAMPORTS_PER_SOL));
|
|
20588
|
+
bundleTipIx = makeBundleTipIx(feePayer, Math.trunc(feeUi * __solana_web3_js.LAMPORTS_PER_SOL));
|
|
20591
20589
|
} else {
|
|
20592
20590
|
priorityFeeIx = makePriorityFeeIx(feeUi, computeUnitsLimit)[0];
|
|
20593
20591
|
}
|
|
@@ -20622,9 +20620,9 @@ function makeBundleTipIx(feePayer, bundleTip = 1e5) {
|
|
|
20622
20620
|
"3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT"
|
|
20623
20621
|
];
|
|
20624
20622
|
const randomTipAccount = tipAccounts[Math.floor(Math.random() * tipAccounts.length)];
|
|
20625
|
-
return SystemProgram.transfer({
|
|
20623
|
+
return __solana_web3_js.SystemProgram.transfer({
|
|
20626
20624
|
fromPubkey: feePayer,
|
|
20627
|
-
toPubkey: new PublicKey(randomTipAccount),
|
|
20625
|
+
toPubkey: new __solana_web3_js.PublicKey(randomTipAccount),
|
|
20628
20626
|
lamports: bundleTip
|
|
20629
20627
|
});
|
|
20630
20628
|
}
|
|
@@ -20658,11 +20656,11 @@ var LendrGroup = class LendrGroup {
|
|
|
20658
20656
|
return LendrGroup.fromAccountParsed(address$2, data);
|
|
20659
20657
|
}
|
|
20660
20658
|
static decode(encoded, idl) {
|
|
20661
|
-
const coder = new BorshCoder(idl);
|
|
20659
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
20662
20660
|
return coder.accounts.decode(AccountType.LendrGroup, encoded);
|
|
20663
20661
|
}
|
|
20664
20662
|
static async encode(decoded, idl) {
|
|
20665
|
-
const coder = new BorshCoder(idl);
|
|
20663
|
+
const coder = new __coral_xyz_anchor.BorshCoder(idl);
|
|
20666
20664
|
return await coder.accounts.encode(AccountType.LendrGroup, decoded);
|
|
20667
20665
|
}
|
|
20668
20666
|
async makeEnableFlashLoanForAccountIx(program, lendrAccountAddress) {
|
|
@@ -20732,7 +20730,7 @@ var LendrClient = class LendrClient {
|
|
|
20732
20730
|
this.bankMetadataMap = bankMetadataMap;
|
|
20733
20731
|
this.overrideBankAddresses = overrideBankAddresses;
|
|
20734
20732
|
this.overrideBanksMetadata = overrideBanksMetadata;
|
|
20735
|
-
this.storage = storage ?? createStorage();
|
|
20733
|
+
this.storage = storage ?? (0, unstorage.createStorage)();
|
|
20736
20734
|
this.metadataService = metadataService;
|
|
20737
20735
|
this.dataFetcher = dataFetcher ?? new DataFetcher();
|
|
20738
20736
|
}
|
|
@@ -20748,7 +20746,7 @@ var LendrClient = class LendrClient {
|
|
|
20748
20746
|
* @returns LendrClient instance
|
|
20749
20747
|
*/
|
|
20750
20748
|
static async fetch({ wallet, connection, clientOptions = {}, config = getConfig() }) {
|
|
20751
|
-
const { logger = new NoopLogger(), confirmOpts = {}, readOnly = false, storage = createStorage(), dataFetcher = new DataFetcher(), overrideBankAddresses, overrideBanksMetadata, metadataService = new FogoMetadataService(storage, overrideBanksMetadata), addressLookupTableAddresses } = clientOptions;
|
|
20749
|
+
const { logger = new NoopLogger(), confirmOpts = {}, readOnly = false, storage = (0, unstorage.createStorage)(), dataFetcher = new DataFetcher(), overrideBankAddresses, overrideBanksMetadata, metadataService = new FogoMetadataService(storage, overrideBanksMetadata), addressLookupTableAddresses } = clientOptions;
|
|
20752
20750
|
logger.debug({
|
|
20753
20751
|
programId: config.programId.toBase58(),
|
|
20754
20752
|
env: config.environment,
|
|
@@ -20756,16 +20754,16 @@ var LendrClient = class LendrClient {
|
|
|
20756
20754
|
url: connection?.rpcEndpoint
|
|
20757
20755
|
}, "[lendr:client] Loading Lendr Client");
|
|
20758
20756
|
const programIdl = fetchLatestIdl();
|
|
20759
|
-
const provider = new AnchorProvider(connection, wallet, {
|
|
20760
|
-
...AnchorProvider.defaultOptions(),
|
|
20761
|
-
commitment: connection.commitment ?? AnchorProvider.defaultOptions().commitment,
|
|
20757
|
+
const provider = new __coral_xyz_anchor.AnchorProvider(connection, wallet, {
|
|
20758
|
+
...__coral_xyz_anchor.AnchorProvider.defaultOptions(),
|
|
20759
|
+
commitment: connection.commitment ?? __coral_xyz_anchor.AnchorProvider.defaultOptions().commitment,
|
|
20762
20760
|
...confirmOpts
|
|
20763
20761
|
});
|
|
20764
20762
|
const idl = {
|
|
20765
20763
|
...programIdl,
|
|
20766
20764
|
address: config.programId.toBase58()
|
|
20767
20765
|
};
|
|
20768
|
-
const program = new Program(idl, provider);
|
|
20766
|
+
const program = new __coral_xyz_anchor.Program(idl, provider);
|
|
20769
20767
|
const { lendrGroup, banks, priceInfos, tokensData, feedIdMap, banksExtendedMetadata } = await LendrClient.fetchGroupData({
|
|
20770
20768
|
connection,
|
|
20771
20769
|
program,
|
|
@@ -20843,12 +20841,12 @@ var LendrClient = class LendrClient {
|
|
|
20843
20841
|
const oracleKeys = [];
|
|
20844
20842
|
for (const bank of banksRawData) {
|
|
20845
20843
|
mintKeys.push(bank.data.mint);
|
|
20846
|
-
if (!bank.data.emissionsMint.equals(PublicKey.default)) {
|
|
20844
|
+
if (!bank.data.emissionsMint.equals(__solana_web3_js.PublicKey.default)) {
|
|
20847
20845
|
emissionMintKeys.push(bank.data.emissionsMint);
|
|
20848
20846
|
}
|
|
20849
20847
|
oracleKeys.push(findOracleKey(BankConfig.fromAccountParsed(bank.data.config), feedIdMap).oracleKey);
|
|
20850
20848
|
}
|
|
20851
|
-
const allAccountInfos = await chunkedGetRawMultipleAccountInfoOrdered(program.provider.connection, [
|
|
20849
|
+
const allAccountInfos = await require_common.chunkedGetRawMultipleAccountInfoOrdered(program.provider.connection, [
|
|
20852
20850
|
groupAddress.toBase58(),
|
|
20853
20851
|
...oracleKeys.map((pk) => pk.toBase58()),
|
|
20854
20852
|
...mintKeys.map((pk) => pk.toBase58()),
|
|
@@ -20862,7 +20860,7 @@ var LendrClient = class LendrClient {
|
|
|
20862
20860
|
const mintAccountInfos = allAccountInfos.splice(0, mintKeys.length);
|
|
20863
20861
|
const emissionMintAccountInfos = allAccountInfos.splice(0);
|
|
20864
20862
|
const lendrGroup = LendrGroup.fromBuffer(groupAddress, groupAccountInfo.data, program.idl);
|
|
20865
|
-
const banksExtendedMetadata = await fetchBanksExtendedMetadata({
|
|
20863
|
+
const banksExtendedMetadata = await require_common.fetchBanksExtendedMetadata({
|
|
20866
20864
|
mintsWithOwner: mintKeys.map((mint, idx) => ({
|
|
20867
20865
|
mint,
|
|
20868
20866
|
owner: mintAccountInfos[idx].owner
|
|
@@ -20892,7 +20890,7 @@ var LendrClient = class LendrClient {
|
|
|
20892
20890
|
const bank = Bank.fromAccountParsed(address$2, data, feedIdMap, metadata$2, mintDataRaw.owner);
|
|
20893
20891
|
banks.set(bankAddressStr, bank);
|
|
20894
20892
|
let emissionTokenProgram = null;
|
|
20895
|
-
if (!data.emissionsMint.equals(PublicKey.default)) {
|
|
20893
|
+
if (!data.emissionsMint.equals(__solana_web3_js.PublicKey.default)) {
|
|
20896
20894
|
const emissionMintDataRawIndex = emissionMintKeys.findIndex((pk) => pk.equals(data.emissionsMint));
|
|
20897
20895
|
emissionTokenProgram = emissionMintDataRawIndex >= 0 ? emissionMintAccountInfos[emissionMintDataRawIndex].owner : null;
|
|
20898
20896
|
}
|
|
@@ -20905,11 +20903,11 @@ var LendrClient = class LendrClient {
|
|
|
20905
20903
|
const oracleSetup = parseOracleSetup(data.config.oracleSetup);
|
|
20906
20904
|
priceInfos.set(bankAddressStr, parseOraclePriceData(oracleSetup, priceDataRaw.data, logger));
|
|
20907
20905
|
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);
|
|
20906
|
+
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);
|
|
20907
|
+
const [stakePoolAddress] = __solana_web3_js.PublicKey.findProgramAddressSync([Buffer.from("stake"), poolAddress.toBuffer()], require_common.SINGLE_POOL_PROGRAM_ID);
|
|
20910
20908
|
stakedCollatMap[address$2.toBase58()] = {
|
|
20911
20909
|
bankAddress: address$2,
|
|
20912
|
-
mint: new PublicKey(metadata$2.mint),
|
|
20910
|
+
mint: new __solana_web3_js.PublicKey(metadata$2.mint),
|
|
20913
20911
|
stakePoolAddress,
|
|
20914
20912
|
poolAddress
|
|
20915
20913
|
};
|
|
@@ -20917,9 +20915,9 @@ var LendrClient = class LendrClient {
|
|
|
20917
20915
|
mints.push(metadata$2.mint);
|
|
20918
20916
|
}
|
|
20919
20917
|
});
|
|
20920
|
-
const dataAis = await chunkedGetRawMultipleAccountInfoOrdered(program.provider.connection, [...mints, ...solPools]);
|
|
20918
|
+
const dataAis = await require_common.chunkedGetRawMultipleAccountInfoOrdered(program.provider.connection, [...mints, ...solPools]);
|
|
20921
20919
|
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));
|
|
20920
|
+
const lstMintsAis = dataAis.slice(0, mints.length).map((mintAi) => __solana_spl_token.MintLayout.decode(mintAi.data));
|
|
20923
20921
|
const lstMintRecord = Object.fromEntries(mints.map((mint, i) => [mint, lstMintsAis[i]]));
|
|
20924
20922
|
const solPoolsRecord = Object.fromEntries(solPools.map((poolKey, i) => [poolKey, stakePoolsAis[i]]));
|
|
20925
20923
|
for (const index in stakedCollatMap) {
|
|
@@ -20930,7 +20928,7 @@ var LendrClient = class LendrClient {
|
|
|
20930
20928
|
const oracle = priceInfos.get(bankAddress.toBase58());
|
|
20931
20929
|
if (oracle) {
|
|
20932
20930
|
const adjustPrice = (price, stakeActual$1, tokenSupply$1) => {
|
|
20933
|
-
return Number(tokenSupply$1) === 0 ? price : new
|
|
20931
|
+
return Number(tokenSupply$1) === 0 ? price : new bignumber_js.default(price.toNumber() * (stakeActual$1 - __solana_web3_js.LAMPORTS_PER_SOL) / Number(tokenSupply$1));
|
|
20934
20932
|
};
|
|
20935
20933
|
const adjustPriceComponent$1 = (priceComponent, stakeActual$1, tokenSupply$1) => ({
|
|
20936
20934
|
price: adjustPrice(priceComponent.price, stakeActual$1, tokenSupply$1),
|
|
@@ -21042,7 +21040,7 @@ var LendrClient = class LendrClient {
|
|
|
21042
21040
|
offset: 8
|
|
21043
21041
|
} }, { memcmp: {
|
|
21044
21042
|
offset: 0,
|
|
21045
|
-
bytes: bs58.encode(new BorshAccountsCoder(this.program.idl).accountDiscriminator(AccountType.LendrAccount))
|
|
21043
|
+
bytes: bs58.default.encode(new __coral_xyz_anchor.BorshAccountsCoder(this.program.idl).accountDiscriminator(AccountType.LendrAccount))
|
|
21046
21044
|
} }]
|
|
21047
21045
|
})).map((a) => a.pubkey);
|
|
21048
21046
|
}
|
|
@@ -21052,7 +21050,7 @@ var LendrClient = class LendrClient {
|
|
|
21052
21050
|
* @returns LendrAccount instances
|
|
21053
21051
|
*/
|
|
21054
21052
|
async getLendrAccountsForAuthority(authority) {
|
|
21055
|
-
const _authority = authority ? translateAddress(authority) : this.provider.wallet.publicKey;
|
|
21053
|
+
const _authority = authority ? (0, __coral_xyz_anchor.translateAddress)(authority) : this.provider.wallet.publicKey;
|
|
21056
21054
|
const lendrAccounts = (await this.program.account.lendrAccount.all([{ memcmp: {
|
|
21057
21055
|
bytes: this.groupAddress.toBase58(),
|
|
21058
21056
|
offset: 8
|
|
@@ -21082,16 +21080,16 @@ var LendrClient = class LendrClient {
|
|
|
21082
21080
|
},
|
|
21083
21081
|
filters: [{ memcmp: {
|
|
21084
21082
|
offset: 0,
|
|
21085
|
-
bytes: bs58.encode(new BorshAccountsCoder(this.program.idl).accountDiscriminator(AccountType.LendrAccount))
|
|
21083
|
+
bytes: bs58.default.encode(new __coral_xyz_anchor.BorshAccountsCoder(this.program.idl).accountDiscriminator(AccountType.LendrAccount))
|
|
21086
21084
|
} }]
|
|
21087
21085
|
})).map((a) => a.pubkey);
|
|
21088
21086
|
}
|
|
21089
21087
|
getBankByPk(bankAddress) {
|
|
21090
|
-
const _bankAddress = translateAddress(bankAddress);
|
|
21088
|
+
const _bankAddress = (0, __coral_xyz_anchor.translateAddress)(bankAddress);
|
|
21091
21089
|
return this.banks.get(_bankAddress.toString()) ?? null;
|
|
21092
21090
|
}
|
|
21093
21091
|
getBankByMint(mint) {
|
|
21094
|
-
const _mint = translateAddress(mint);
|
|
21092
|
+
const _mint = (0, __coral_xyz_anchor.translateAddress)(mint);
|
|
21095
21093
|
return [...this.banks.values()].find((bank) => bank.mint.equals(_mint)) ?? null;
|
|
21096
21094
|
}
|
|
21097
21095
|
getBankByTokenSymbol(tokenSymbol) {
|
|
@@ -21099,7 +21097,7 @@ var LendrClient = class LendrClient {
|
|
|
21099
21097
|
return [...this.banks.values()].find((bank) => bank.tokenSymbol === tokenSymbol) ?? null;
|
|
21100
21098
|
}
|
|
21101
21099
|
getOraclePriceByBank(bankAddress) {
|
|
21102
|
-
const _bankAddress = translateAddress(bankAddress);
|
|
21100
|
+
const _bankAddress = (0, __coral_xyz_anchor.translateAddress)(bankAddress);
|
|
21103
21101
|
return this.oraclePrices.get(_bankAddress.toString()) ?? null;
|
|
21104
21102
|
}
|
|
21105
21103
|
/**
|
|
@@ -21144,7 +21142,7 @@ var LendrClient = class LendrClient {
|
|
|
21144
21142
|
* @returns Object containing the transaction signature and the created LendrAccount instance
|
|
21145
21143
|
*/
|
|
21146
21144
|
async createLendrAccount(createOpts, processOpts, txOpts) {
|
|
21147
|
-
const accountKeypair = Keypair.generate();
|
|
21145
|
+
const accountKeypair = __solana_web3_js.Keypair.generate();
|
|
21148
21146
|
const newAccountKey = createOpts?.newAccountKey ?? accountKeypair.publicKey;
|
|
21149
21147
|
const solanaTx = await this.createLendrAccountTx({ accountKeypair });
|
|
21150
21148
|
const sig = await this.processTransaction(solanaTx, processOpts, txOpts);
|
|
@@ -21161,11 +21159,11 @@ var LendrClient = class LendrClient {
|
|
|
21161
21159
|
* @returns Object containing the transaction signature and the created LendrAccount instance
|
|
21162
21160
|
*/
|
|
21163
21161
|
async createLendrAccountWithSession(session, commitment, customAccountSeed) {
|
|
21164
|
-
const accountSeed = new
|
|
21165
|
-
const tx = await this.createLendrAccountWithSessionTx(session, new
|
|
21162
|
+
const accountSeed = new bn_js.default(customAccountSeed ?? 0);
|
|
21163
|
+
const tx = await this.createLendrAccountWithSessionTx(session, new bn_js.default(accountSeed ?? 0));
|
|
21166
21164
|
const txResult = await session.sendTransaction(tx);
|
|
21167
21165
|
this.logger.debug({ txResult }, "Created Lendr account (using session)");
|
|
21168
|
-
const [accountPublicKey] = PublicKey.findProgramAddressSync([
|
|
21166
|
+
const [accountPublicKey] = __solana_web3_js.PublicKey.findProgramAddressSync([
|
|
21169
21167
|
Buffer.from("pyroners"),
|
|
21170
21168
|
session.walletPublicKey.toBuffer(),
|
|
21171
21169
|
this.groupAddress.toBuffer(),
|
|
@@ -21194,15 +21192,15 @@ var LendrClient = class LendrClient {
|
|
|
21194
21192
|
* @returns Transaction that can be used to create a new lendr account
|
|
21195
21193
|
*/
|
|
21196
21194
|
async createLendrAccountTx(createOpts) {
|
|
21197
|
-
const accountKeypair = createOpts?.accountKeypair ?? Keypair.generate();
|
|
21195
|
+
const accountKeypair = createOpts?.accountKeypair ?? __solana_web3_js.Keypair.generate();
|
|
21198
21196
|
const ixs = await this.makeCreateLendrAccountIx(accountKeypair.publicKey);
|
|
21199
21197
|
const signers = [...ixs.keys];
|
|
21200
21198
|
signers.push(accountKeypair);
|
|
21201
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
21202
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
21199
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
21200
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
21203
21201
|
signers,
|
|
21204
21202
|
addressLookupTables: this.addressLookupTables,
|
|
21205
|
-
type: TransactionType.CREATE_ACCOUNT
|
|
21203
|
+
type: require_common.TransactionType.CREATE_ACCOUNT
|
|
21206
21204
|
});
|
|
21207
21205
|
return solanaTx;
|
|
21208
21206
|
}
|
|
@@ -21210,29 +21208,29 @@ var LendrClient = class LendrClient {
|
|
|
21210
21208
|
try {
|
|
21211
21209
|
return (await this.provider.connection.getLatestBlockhashAndContext("confirmed")).value.blockhash;
|
|
21212
21210
|
} catch (ex) {
|
|
21213
|
-
const connection = new Connection(this.provider.connection.rpcEndpoint, this.provider.opts);
|
|
21211
|
+
const connection = new __solana_web3_js.Connection(this.provider.connection.rpcEndpoint, this.provider.opts);
|
|
21214
21212
|
return (await connection.getLatestBlockhashAndContext("confirmed")).value.blockhash;
|
|
21215
21213
|
}
|
|
21216
21214
|
}
|
|
21217
21215
|
async createVersionTransaction(instructions$3, payerKey, signers, extraMetaData) {
|
|
21218
21216
|
const blockhash = await this.getLatestBlockHashForSure();
|
|
21219
|
-
const versionedMessage = new TransactionMessage({
|
|
21217
|
+
const versionedMessage = new __solana_web3_js.TransactionMessage({
|
|
21220
21218
|
instructions: instructions$3,
|
|
21221
21219
|
payerKey,
|
|
21222
21220
|
recentBlockhash: blockhash
|
|
21223
21221
|
});
|
|
21224
|
-
const tx = new VersionedTransaction(this.addressLookupTables ? versionedMessage.compileToV0Message(this.addressLookupTables) : versionedMessage.compileToLegacyMessage());
|
|
21222
|
+
const tx = new __solana_web3_js.VersionedTransaction(this.addressLookupTables ? versionedMessage.compileToV0Message(this.addressLookupTables) : versionedMessage.compileToLegacyMessage());
|
|
21225
21223
|
if (signers?.length) {
|
|
21226
21224
|
tx.sign(signers);
|
|
21227
21225
|
}
|
|
21228
21226
|
if (extraMetaData && Object.keys(extraMetaData)?.length) {
|
|
21229
|
-
return addTransactionMetadata(tx, extraMetaData);
|
|
21227
|
+
return require_common.addTransactionMetadata(tx, extraMetaData);
|
|
21230
21228
|
}
|
|
21231
21229
|
return tx;
|
|
21232
21230
|
}
|
|
21233
21231
|
async createLendrAccountWithSessionTx(session, accountSeed) {
|
|
21234
21232
|
const ixs = await this.makeCreateLendrAccountWithSessionIx(session, accountSeed);
|
|
21235
|
-
return this.createVersionTransaction(ixs.instructions, session.payer, [...ixs.keys], { type: TransactionType.CREATE_ACCOUNT });
|
|
21233
|
+
return this.createVersionTransaction(ixs.instructions, session.payer, [...ixs.keys], { type: require_common.TransactionType.CREATE_ACCOUNT });
|
|
21236
21234
|
}
|
|
21237
21235
|
/**
|
|
21238
21236
|
* Create transaction instruction to initialize a new group.
|
|
@@ -21265,14 +21263,14 @@ var LendrClient = class LendrClient {
|
|
|
21265
21263
|
* @returns {Promise<TransactionSignature>} A promise that resolves to the transaction signature as a string.
|
|
21266
21264
|
*/
|
|
21267
21265
|
async createPermissionlessBank({ mint, bankConfig, group, admin, seed, txOpts, processOpts }) {
|
|
21268
|
-
const keypair = seed ?? Keypair.generate();
|
|
21266
|
+
const keypair = seed ?? __solana_web3_js.Keypair.generate();
|
|
21269
21267
|
const bankIxs = await this.group.makePoolAddBankIx(this.program, keypair.publicKey, mint, bankConfig, admin);
|
|
21270
21268
|
const signers = [...bankIxs.keys, keypair];
|
|
21271
|
-
const tx = new Transaction().add(...bankIxs.instructions);
|
|
21272
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
21269
|
+
const tx = new __solana_web3_js.Transaction().add(...bankIxs.instructions);
|
|
21270
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
21273
21271
|
signers,
|
|
21274
21272
|
addressLookupTables: this.addressLookupTables,
|
|
21275
|
-
type: TransactionType.CREATE_PERM_BANK
|
|
21273
|
+
type: require_common.TransactionType.CREATE_PERM_BANK
|
|
21276
21274
|
});
|
|
21277
21275
|
const sig = await this.processTransaction(solanaTx, processOpts, txOpts);
|
|
21278
21276
|
this.logger.debug({ sig }, "Created Lendr group");
|
|
@@ -21288,14 +21286,14 @@ var LendrClient = class LendrClient {
|
|
|
21288
21286
|
* @returns The public key of the newly created lendr group.
|
|
21289
21287
|
*/
|
|
21290
21288
|
async createLendrGroup(seed, additionalIxs, processOpts, txOpts) {
|
|
21291
|
-
const accountKeypair = seed ?? Keypair.generate();
|
|
21289
|
+
const accountKeypair = seed ?? __solana_web3_js.Keypair.generate();
|
|
21292
21290
|
const ixs = await this.makeCreateLendrGroupIx(accountKeypair.publicKey);
|
|
21293
21291
|
const signers = [...ixs.keys, accountKeypair];
|
|
21294
|
-
const tx = new Transaction().add(...ixs.instructions, ...additionalIxs ?? []);
|
|
21295
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
21292
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions, ...additionalIxs ?? []);
|
|
21293
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
21296
21294
|
signers,
|
|
21297
21295
|
addressLookupTables: this.addressLookupTables,
|
|
21298
|
-
type: TransactionType.CREATE_GROUP
|
|
21296
|
+
type: require_common.TransactionType.CREATE_GROUP
|
|
21299
21297
|
});
|
|
21300
21298
|
const sig = await this.processTransaction(solanaTx, processOpts, txOpts);
|
|
21301
21299
|
this.logger.debug({ sig }, "Created Lendr group");
|
|
@@ -21312,14 +21310,14 @@ var LendrClient = class LendrClient {
|
|
|
21312
21310
|
* @returns The bank's public key and the transaction signature
|
|
21313
21311
|
*/
|
|
21314
21312
|
async createLendingPool(bankMint, bankConfig, seed, processOpts, txOpts) {
|
|
21315
|
-
const bankKeypair = seed ?? Keypair.generate();
|
|
21313
|
+
const bankKeypair = seed ?? __solana_web3_js.Keypair.generate();
|
|
21316
21314
|
const ixs = await this.group.makePoolAddBankIx(this.program, bankKeypair.publicKey, bankMint, bankConfig);
|
|
21317
21315
|
const signers = [...ixs.keys, bankKeypair];
|
|
21318
|
-
const tx = new Transaction().add(...ixs.instructions);
|
|
21319
|
-
const solanaTx = addTransactionMetadata(tx, {
|
|
21316
|
+
const tx = new __solana_web3_js.Transaction().add(...ixs.instructions);
|
|
21317
|
+
const solanaTx = require_common.addTransactionMetadata(tx, {
|
|
21320
21318
|
signers,
|
|
21321
21319
|
addressLookupTables: this.addressLookupTables,
|
|
21322
|
-
type: TransactionType.CREATE_PERM_BANK
|
|
21320
|
+
type: require_common.TransactionType.CREATE_PERM_BANK
|
|
21323
21321
|
});
|
|
21324
21322
|
const sig = await this.processTransaction(solanaTx, processOpts, txOpts);
|
|
21325
21323
|
this.logger.debug({ sig }, "Created new lending pool");
|
|
@@ -21388,21 +21386,21 @@ var LendrClient = class LendrClient {
|
|
|
21388
21386
|
}
|
|
21389
21387
|
async simulateTransactions(transactions, accountsToInspect) {
|
|
21390
21388
|
const versionedTransactions = [];
|
|
21391
|
-
const connection = new Connection(this.provider.connection.rpcEndpoint, this.provider.opts);
|
|
21389
|
+
const connection = new __solana_web3_js.Connection(this.provider.connection.rpcEndpoint, this.provider.opts);
|
|
21392
21390
|
let blockhash;
|
|
21393
21391
|
try {
|
|
21394
21392
|
const getLatestBlockhashAndContext = await connection.getLatestBlockhashAndContext("confirmed");
|
|
21395
21393
|
blockhash = getLatestBlockhashAndContext.value.blockhash;
|
|
21396
21394
|
for (const transaction of transactions) {
|
|
21397
|
-
if (isV0Tx(transaction)) {
|
|
21395
|
+
if (require_common.isV0Tx(transaction)) {
|
|
21398
21396
|
versionedTransactions.push(transaction);
|
|
21399
21397
|
} else {
|
|
21400
|
-
const versionedMessage = new TransactionMessage({
|
|
21398
|
+
const versionedMessage = new __solana_web3_js.TransactionMessage({
|
|
21401
21399
|
instructions: transaction.instructions,
|
|
21402
21400
|
payerKey: this.provider.publicKey,
|
|
21403
21401
|
recentBlockhash: blockhash
|
|
21404
21402
|
});
|
|
21405
|
-
versionedTransactions.push(new VersionedTransaction(versionedMessage.compileToV0Message(this.addressLookupTables)));
|
|
21403
|
+
versionedTransactions.push(new __solana_web3_js.VersionedTransaction(versionedMessage.compileToV0Message(this.addressLookupTables)));
|
|
21406
21404
|
}
|
|
21407
21405
|
}
|
|
21408
21406
|
} catch (error) {
|
|
@@ -21478,5 +21476,227 @@ var LendrClient = class LendrClient {
|
|
|
21478
21476
|
var client_default = LendrClient;
|
|
21479
21477
|
|
|
21480
21478
|
//#endregion
|
|
21481
|
-
|
|
21482
|
-
|
|
21479
|
+
exports.AccountFlags = AccountFlags;
|
|
21480
|
+
exports.AccountType = AccountType;
|
|
21481
|
+
exports.AssetTag = AssetTag;
|
|
21482
|
+
exports.BUNDLE_TX_SIZE = require_common.BUNDLE_TX_SIZE;
|
|
21483
|
+
exports.Balance = Balance;
|
|
21484
|
+
exports.Bank = Bank;
|
|
21485
|
+
exports.BankConfig = BankConfig;
|
|
21486
|
+
exports.BankVaultType = BankVaultType;
|
|
21487
|
+
exports.DEFAULT_CLUSTER = require_common.DEFAULT_CLUSTER;
|
|
21488
|
+
exports.DEFAULT_COMMITMENT = require_common.DEFAULT_COMMITMENT;
|
|
21489
|
+
exports.DEFAULT_CONFIRM_OPTS = require_common.DEFAULT_CONFIRM_OPTS;
|
|
21490
|
+
exports.DEFAULT_ORACLE_MAX_AGE = require_common.DEFAULT_ORACLE_MAX_AGE;
|
|
21491
|
+
exports.DEFAULT_PROCESS_TX_OPTS = DEFAULT_PROCESS_TX_OPTS;
|
|
21492
|
+
exports.DEFAULT_PROCESS_TX_STRATEGY = DEFAULT_PROCESS_TX_STRATEGY;
|
|
21493
|
+
exports.DEFAULT_SEND_OPTS = require_common.DEFAULT_SEND_OPTS;
|
|
21494
|
+
exports.DISABLED_FLAG = require_common.DISABLED_FLAG;
|
|
21495
|
+
exports.DUMMY_USDC_MINT = require_common.DUMMY_USDC_MINT;
|
|
21496
|
+
exports.DataFetcher = DataFetcher;
|
|
21497
|
+
exports.EmodeEntryFlags = EmodeEntryFlags;
|
|
21498
|
+
exports.EmodeFlags = EmodeFlags;
|
|
21499
|
+
exports.EmodeImpactStatus = EmodeImpactStatus;
|
|
21500
|
+
exports.EmodeSettings = EmodeSettings;
|
|
21501
|
+
exports.EmodeTag = EmodeTag;
|
|
21502
|
+
exports.FLASHLOAN_ENABLED_FLAG = require_common.FLASHLOAN_ENABLED_FLAG;
|
|
21503
|
+
exports.FogoMetadataService = FogoMetadataService;
|
|
21504
|
+
exports.GROUP_PK = require_common.GROUP_PK;
|
|
21505
|
+
exports.HOURS_PER_YEAR = require_common.HOURS_PER_YEAR;
|
|
21506
|
+
exports.HealthCache = HealthCache;
|
|
21507
|
+
exports.HealthCacheFlags = HealthCacheFlags;
|
|
21508
|
+
exports.HealthCacheSimulationError = HealthCacheSimulationError;
|
|
21509
|
+
exports.IMetadataService = IMetadataService;
|
|
21510
|
+
exports.JUPITER_V6_PROGRAM = require_common.JUPITER_V6_PROGRAM;
|
|
21511
|
+
exports.LENDR_IDL = LENDR_IDL;
|
|
21512
|
+
exports.LENDR_PROGRAM = require_common.LENDR_PROGRAM;
|
|
21513
|
+
exports.LENDR_SPONSORED_SHARD_ID = LENDR_SPONSORED_SHARD_ID;
|
|
21514
|
+
exports.LST_MINT = require_common.LST_MINT;
|
|
21515
|
+
exports.LUT_PROGRAM_AUTHORITY_INDEX = require_common.LUT_PROGRAM_AUTHORITY_INDEX;
|
|
21516
|
+
exports.LendrAccount = LendrAccount;
|
|
21517
|
+
exports.LendrAccountWrapper = LendrAccountWrapper;
|
|
21518
|
+
exports.LendrClient = client_default;
|
|
21519
|
+
exports.LendrGroup = LendrGroup;
|
|
21520
|
+
exports.LendrRequirementType = LendrRequirementType;
|
|
21521
|
+
exports.MAX_ACCOUNT_KEYS = require_common.MAX_ACCOUNT_KEYS;
|
|
21522
|
+
exports.MAX_CONFIDENCE_INTERVAL_RATIO = require_common.MAX_CONFIDENCE_INTERVAL_RATIO;
|
|
21523
|
+
exports.MAX_TX_SIZE = require_common.MAX_TX_SIZE;
|
|
21524
|
+
exports.MAX_U64 = require_common.MAX_U64;
|
|
21525
|
+
exports.MPL_METADATA_PROGRAM_ID = require_common.MPL_METADATA_PROGRAM_ID;
|
|
21526
|
+
exports.OperationalState = OperationalState;
|
|
21527
|
+
exports.OracleSetup = OracleSetup;
|
|
21528
|
+
exports.PDA_BANK_FEE_VAULT_AUTH_SEED = require_common.PDA_BANK_FEE_VAULT_AUTH_SEED;
|
|
21529
|
+
exports.PDA_BANK_FEE_VAULT_SEED = require_common.PDA_BANK_FEE_VAULT_SEED;
|
|
21530
|
+
exports.PDA_BANK_INSURANCE_VAULT_AUTH_SEED = require_common.PDA_BANK_INSURANCE_VAULT_AUTH_SEED;
|
|
21531
|
+
exports.PDA_BANK_INSURANCE_VAULT_SEED = require_common.PDA_BANK_INSURANCE_VAULT_SEED;
|
|
21532
|
+
exports.PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED = require_common.PDA_BANK_LIQUIDITY_VAULT_AUTH_SEED;
|
|
21533
|
+
exports.PDA_BANK_LIQUIDITY_VAULT_SEED = require_common.PDA_BANK_LIQUIDITY_VAULT_SEED;
|
|
21534
|
+
exports.PRIORITY_TX_SIZE = require_common.PRIORITY_TX_SIZE;
|
|
21535
|
+
exports.PROGRAM_ID = require_common.PROGRAM_ID;
|
|
21536
|
+
exports.PYTH_PRICE_CONF_INTERVALS = require_common.PYTH_PRICE_CONF_INTERVALS;
|
|
21537
|
+
exports.PYTH_PUSH_ORACLE_ID = require_common.PYTH_PUSH_ORACLE_ID;
|
|
21538
|
+
exports.PYTH_SPONSORED_SHARD_ID = PYTH_SPONSORED_SHARD_ID;
|
|
21539
|
+
exports.PriceBias = PriceBias;
|
|
21540
|
+
exports.ProcessTransactionError = ProcessTransactionError;
|
|
21541
|
+
exports.ProcessTransactionErrorType = ProcessTransactionErrorType;
|
|
21542
|
+
exports.RiskTier = RiskTier;
|
|
21543
|
+
exports.SINGLE_POOL_PROGRAM_ID = require_common.SINGLE_POOL_PROGRAM_ID;
|
|
21544
|
+
exports.SKIP_SIMULATION = require_common.SKIP_SIMULATION;
|
|
21545
|
+
exports.STAKE_CONFIG_ID = require_common.STAKE_CONFIG_ID;
|
|
21546
|
+
exports.STAKE_PROGRAM_ID = require_common.STAKE_PROGRAM_ID;
|
|
21547
|
+
exports.SWB_PRICE_CONF_INTERVALS = require_common.SWB_PRICE_CONF_INTERVALS;
|
|
21548
|
+
exports.SYSTEM_PROGRAM_ID = require_common.SYSTEM_PROGRAM_ID;
|
|
21549
|
+
exports.SYSVAR_CLOCK_ID = require_common.SYSVAR_CLOCK_ID;
|
|
21550
|
+
exports.SYSVAR_RENT_ID = require_common.SYSVAR_RENT_ID;
|
|
21551
|
+
exports.SYSVAR_STAKE_HISTORY_ID = require_common.SYSVAR_STAKE_HISTORY_ID;
|
|
21552
|
+
exports.TRANSFER_ACCOUNT_AUTHORITY_FLAG = require_common.TRANSFER_ACCOUNT_AUTHORITY_FLAG;
|
|
21553
|
+
exports.USDC_DECIMALS = require_common.USDC_DECIMALS;
|
|
21554
|
+
exports.USDC_MINT = require_common.USDC_MINT;
|
|
21555
|
+
exports.WSOL_EXTENDED_METADATA = require_common.WSOL_EXTENDED_METADATA;
|
|
21556
|
+
exports.WSOL_MINT = require_common.WSOL_MINT;
|
|
21557
|
+
exports.accountFlagToBN = accountFlagToBN;
|
|
21558
|
+
exports.addOracleToBanksIx = addOracleToBanksIx;
|
|
21559
|
+
exports.balanceToDto = balanceToDto;
|
|
21560
|
+
exports.bankConfigRawToDto = bankConfigRawToDto;
|
|
21561
|
+
exports.bankRawToDto = bankRawToDto;
|
|
21562
|
+
exports.buildFeedIdMap = buildFeedIdMap;
|
|
21563
|
+
exports.computeAccountValue = computeAccountValue;
|
|
21564
|
+
exports.computeActiveEmodePairs = computeActiveEmodePairs;
|
|
21565
|
+
exports.computeAssetUsdValue = computeAssetUsdValue;
|
|
21566
|
+
exports.computeBalanceUsdValue = computeBalanceUsdValue;
|
|
21567
|
+
exports.computeBaseInterestRate = computeBaseInterestRate;
|
|
21568
|
+
exports.computeClaimedEmissions = computeClaimedEmissions;
|
|
21569
|
+
exports.computeEmodeImpacts = computeEmodeImpacts;
|
|
21570
|
+
exports.computeFreeCollateral = computeFreeCollateral;
|
|
21571
|
+
exports.computeFreeCollateralLegacy = computeFreeCollateralLegacy;
|
|
21572
|
+
exports.computeHealthAccountMetas = computeHealthAccountMetas;
|
|
21573
|
+
exports.computeHealthCheckAccounts = computeHealthCheckAccounts;
|
|
21574
|
+
exports.computeHealthComponents = computeHealthComponents;
|
|
21575
|
+
exports.computeHealthComponentsLegacy = computeHealthComponentsLegacy;
|
|
21576
|
+
exports.computeHealthComponentsWithoutBiasLegacy = computeHealthComponentsWithoutBiasLegacy;
|
|
21577
|
+
exports.computeInterestRates = computeInterestRates;
|
|
21578
|
+
exports.computeLiabilityUsdValue = computeLiabilityUsdValue;
|
|
21579
|
+
exports.computeLoopingParams = computeLoopingParams;
|
|
21580
|
+
exports.computeMaxLeverage = computeMaxLeverage;
|
|
21581
|
+
exports.computeNetApy = computeNetApy;
|
|
21582
|
+
exports.computeQuantity = computeQuantity;
|
|
21583
|
+
exports.computeQuantityUi = computeQuantityUi;
|
|
21584
|
+
exports.computeRemainingCapacity = computeRemainingCapacity;
|
|
21585
|
+
exports.computeTotalOutstandingEmissions = computeTotalOutstandingEmissions;
|
|
21586
|
+
exports.computeTvl = computeTvl;
|
|
21587
|
+
exports.computeUsdValue = computeUsdValue;
|
|
21588
|
+
exports.computeUtilizationRate = computeUtilizationRate;
|
|
21589
|
+
exports.confirmTransaction = confirmTransaction;
|
|
21590
|
+
exports.crankPythOracleIx = crankPythOracleIx;
|
|
21591
|
+
exports.createLendrAccountTx = createLendrAccountTx;
|
|
21592
|
+
exports.createUpdateFeedIx = createUpdateFeedIx;
|
|
21593
|
+
exports.decodeAccountRaw = decodeAccountRaw;
|
|
21594
|
+
exports.decodeBankRaw = decodeBankRaw;
|
|
21595
|
+
exports.dtoToBalance = dtoToBalance;
|
|
21596
|
+
exports.dtoToBank = dtoToBank;
|
|
21597
|
+
exports.dtoToBankConfig = dtoToBankConfig;
|
|
21598
|
+
exports.dtoToBankConfigRaw = dtoToBankConfigRaw;
|
|
21599
|
+
exports.dtoToBankRaw = dtoToBankRaw;
|
|
21600
|
+
exports.dtoToEmodeSettings = dtoToEmodeSettings;
|
|
21601
|
+
exports.dtoToEmodeSettingsRaw = dtoToEmodeSettingsRaw;
|
|
21602
|
+
exports.dtoToGroup = dtoToGroup;
|
|
21603
|
+
exports.dtoToHealthCache = dtoToHealthCache;
|
|
21604
|
+
exports.dtoToInterestRateConfig = dtoToInterestRateConfig;
|
|
21605
|
+
exports.dtoToLendrAccount = dtoToLendrAccount;
|
|
21606
|
+
exports.dtoToOraclePrice = dtoToOraclePrice;
|
|
21607
|
+
exports.dtoToValidatorStakeGroup = dtoToValidatorStakeGroup;
|
|
21608
|
+
exports.emodeSettingsRawToDto = emodeSettingsRawToDto;
|
|
21609
|
+
exports.feedIdToString = feedIdToString;
|
|
21610
|
+
exports.fetchLendrAccountAddresses = fetchLendrAccountAddresses;
|
|
21611
|
+
exports.fetchLendrAccountData = fetchLendrAccountData;
|
|
21612
|
+
exports.fetchMultipleBanks = fetchMultipleBanks;
|
|
21613
|
+
exports.fetchNativeStakeAccounts = fetchNativeStakeAccounts;
|
|
21614
|
+
exports.fetchOracleData = fetchOracleData;
|
|
21615
|
+
exports.fetchPythOracleData = fetchPythOracleData;
|
|
21616
|
+
exports.fetchStakeAccount = fetchStakeAccount;
|
|
21617
|
+
exports.fetchStakePoolActiveStates = fetchStakePoolActiveStates;
|
|
21618
|
+
exports.fetchStakePoolMev = fetchStakePoolMev;
|
|
21619
|
+
exports.fetchSwbOracleData = fetchSwbOracleData;
|
|
21620
|
+
exports.findOracleKey = findOracleKey;
|
|
21621
|
+
exports.findPythPushOracleAddress = findPythPushOracleAddress;
|
|
21622
|
+
exports.freezeBankConfigIx = freezeBankConfigIx;
|
|
21623
|
+
exports.getActiveAccountFlags = getActiveAccountFlags;
|
|
21624
|
+
exports.getActiveEmodeEntryFlags = getActiveEmodeEntryFlags;
|
|
21625
|
+
exports.getActiveEmodeFlags = getActiveEmodeFlags;
|
|
21626
|
+
exports.getActiveHealthCacheFlags = getActiveHealthCacheFlags;
|
|
21627
|
+
exports.getActiveStaleBanks = getActiveStaleBanks;
|
|
21628
|
+
exports.getAssetQuantity = getAssetQuantity;
|
|
21629
|
+
exports.getAssetShares = getAssetShares;
|
|
21630
|
+
exports.getAssetWeight = getAssetWeight;
|
|
21631
|
+
exports.getBalanceUsdValueWithPriceBias = getBalanceUsdValueWithPriceBias;
|
|
21632
|
+
exports.getBankVaultAuthority = getBankVaultAuthority;
|
|
21633
|
+
exports.getBankVaultSeeds = getBankVaultSeeds;
|
|
21634
|
+
exports.getConfig = getConfig;
|
|
21635
|
+
exports.getConfigPda = getConfigPda;
|
|
21636
|
+
exports.getHealthCacheStatusDescription = getHealthCacheStatusDescription;
|
|
21637
|
+
exports.getLiabilityQuantity = getLiabilityQuantity;
|
|
21638
|
+
exports.getLiabilityShares = getLiabilityShares;
|
|
21639
|
+
exports.getLiabilityWeight = getLiabilityWeight;
|
|
21640
|
+
exports.getPrice = getPrice;
|
|
21641
|
+
exports.getPriceFeedAccountForProgram = getPriceFeedAccountForProgram;
|
|
21642
|
+
exports.getPriceWithConfidence = getPriceWithConfidence;
|
|
21643
|
+
exports.getTotalAssetQuantity = getTotalAssetQuantity;
|
|
21644
|
+
exports.getTotalLiabilityQuantity = getTotalLiabilityQuantity;
|
|
21645
|
+
exports.getTreasuryPda = getTreasuryPda;
|
|
21646
|
+
exports.groupToDto = groupToDto;
|
|
21647
|
+
exports.hasAccountFlag = hasAccountFlag;
|
|
21648
|
+
exports.hasEmodeEntryFlag = hasEmodeEntryFlag;
|
|
21649
|
+
exports.hasEmodeFlag = hasEmodeFlag;
|
|
21650
|
+
exports.hasHealthCacheFlag = hasHealthCacheFlag;
|
|
21651
|
+
exports.healthCacheToDto = healthCacheToDto;
|
|
21652
|
+
exports.instructions = instructions_default;
|
|
21653
|
+
exports.isWeightedPrice = isWeightedPrice;
|
|
21654
|
+
exports.lendrAccountToDto = lendrAccountToDto;
|
|
21655
|
+
exports.makeAddPermissionlessStakedBankIx = makeAddPermissionlessStakedBankIx;
|
|
21656
|
+
exports.makeBundleTipIx = makeBundleTipIx;
|
|
21657
|
+
exports.makeDisableAccountTransferForAccountIx = makeDisableAccountTransferForAccountIx;
|
|
21658
|
+
exports.makeDisableFlashLoanForAccountIx = makeDisableFlashLoanForAccountIx;
|
|
21659
|
+
exports.makeEnableAccountTransferForAccountIx = makeEnableAccountTransferForAccountIx;
|
|
21660
|
+
exports.makeEnableFlashLoanForAccountIx = makeEnableFlashLoanForAccountIx;
|
|
21661
|
+
exports.makePoolAddBankIx = makePoolAddBankIx;
|
|
21662
|
+
exports.makePoolConfigureBankIx = makePoolConfigureBankIx;
|
|
21663
|
+
exports.makePriorityFeeIx = makePriorityFeeIx;
|
|
21664
|
+
exports.makePriorityFeeMicroIx = makePriorityFeeMicroIx;
|
|
21665
|
+
exports.makePulseHealthIx = makePulseHealthIx;
|
|
21666
|
+
exports.makeTxPriorityIx = makeTxPriorityIx;
|
|
21667
|
+
exports.makeUnwrapSolIx = makeUnwrapSolIx;
|
|
21668
|
+
exports.makeVersionedTransaction = makeVersionedTransaction;
|
|
21669
|
+
exports.makeWrapSolIxs = makeWrapSolIxs;
|
|
21670
|
+
exports.metadataSchema = metadataSchema;
|
|
21671
|
+
exports.oraclePriceToDto = oraclePriceToDto;
|
|
21672
|
+
exports.parseBalanceRaw = parseBalanceRaw;
|
|
21673
|
+
exports.parseBankConfigRaw = parseBankConfigRaw;
|
|
21674
|
+
exports.parseBankRaw = parseBankRaw;
|
|
21675
|
+
exports.parseEmodeTag = parseEmodeTag;
|
|
21676
|
+
exports.parseErrorFromLogs = parseErrorFromLogs;
|
|
21677
|
+
exports.parseLendrAccountRaw = parseLendrAccountRaw;
|
|
21678
|
+
exports.parseOperationalState = parseOperationalState;
|
|
21679
|
+
exports.parseOracleSetup = parseOracleSetup;
|
|
21680
|
+
exports.parsePriceInfo = parseOraclePriceData;
|
|
21681
|
+
exports.parseRiskTier = parseRiskTier;
|
|
21682
|
+
exports.parseTransactionError = parseTransactionError;
|
|
21683
|
+
exports.processTransactions = processTransactions;
|
|
21684
|
+
exports.serializeBankConfigOpt = serializeBankConfigOpt;
|
|
21685
|
+
exports.serializeOperationalState = serializeOperationalState;
|
|
21686
|
+
exports.serializeOracleSetup = serializeOracleSetup;
|
|
21687
|
+
exports.serializeOracleSetupToIndex = serializeOracleSetupToIndex;
|
|
21688
|
+
exports.serializeRiskTier = serializeRiskTier;
|
|
21689
|
+
exports.simulateAccountHealthCache = simulateAccountHealthCache;
|
|
21690
|
+
exports.simulateAccountHealthCacheWithFallback = simulateAccountHealthCacheWithFallback;
|
|
21691
|
+
exports.simulateTransactions = simulateTransactions;
|
|
21692
|
+
exports.toBankConfigDto = toBankConfigDto;
|
|
21693
|
+
exports.toBankDto = toBankDto;
|
|
21694
|
+
exports.toEmodeSettingsDto = toEmodeSettingsDto;
|
|
21695
|
+
exports.toInterestRateConfigDto = toInterestRateConfigDto;
|
|
21696
|
+
exports.validatorStakeGroupToDto = validatorStakeGroupToDto;
|
|
21697
|
+
Object.defineProperty(exports, 'vendor', {
|
|
21698
|
+
enumerable: true,
|
|
21699
|
+
get: function () {
|
|
21700
|
+
return vendor_exports;
|
|
21701
|
+
}
|
|
21702
|
+
});
|