@pyron-finance/pyron-client 2.8.0 → 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -11392,13 +11392,13 @@ async function makePulseHealthIx(ldProgram, accounts, remainingAccounts = []) {
11392
11392
  lendrAccount: accounts.lendrAccount
11393
11393
  }).remainingAccounts(remainingAccounts).instruction();
11394
11394
  }
11395
- async function makeHandleBankruptcyIx(ldProgram, accounts) {
11395
+ async function makeHandleBankruptcyIx(ldProgram, accounts, remainingAccounts = []) {
11396
11396
  const { bank, lendrAccount, tokenProgram, ...optionalAccounts } = accounts;
11397
11397
  return ldProgram.methods.lendingPoolHandleBankruptcy().accounts({
11398
11398
  bank,
11399
11399
  lendrAccount,
11400
11400
  tokenProgram
11401
- }).accountsPartial(optionalAccounts).instruction();
11401
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
11402
11402
  }
11403
11403
  var instructions = {
11404
11404
  makeDepositIx,
@@ -23312,14 +23312,19 @@ var BankConfig = class _BankConfig {
23312
23312
  };
23313
23313
 
23314
23314
  // src/models/account/pure.ts
23315
- function makeSessionWrapSolIxs(walletAddress, sessionKey, payer, amount, existingBalance) {
23316
- const nativeAmount = uiToNative(amount, 9).toNumber();
23317
- const TOKEN_ACCOUNT_RENT_EXEMPT = 2039280;
23318
- const existingBalanceNative = existingBalance ? uiToNative(existingBalance, 9).toNumber() : 0;
23319
- let totalAmount = nativeAmount;
23320
- if (existingBalanceNative < TOKEN_ACCOUNT_RENT_EXEMPT) {
23321
- const rentNeeded = Math.max(0, TOKEN_ACCOUNT_RENT_EXEMPT - existingBalanceNative);
23322
- totalAmount = nativeAmount + rentNeeded;
23315
+ var TOKEN_ACCOUNT_RENT_EXEMPT = 2039280;
23316
+ function makeSessionWrapSolIxs(walletAddress, sessionKey, amount, options) {
23317
+ let totalAmount;
23318
+ if (options?.wrapAmountUi !== void 0) {
23319
+ totalAmount = uiToNative(options.wrapAmountUi, 9).toNumber();
23320
+ } else {
23321
+ const nativeAmount = uiToNative(amount, 9).toNumber();
23322
+ const existingBalanceNative = options?.existingBalance ? uiToNative(options.existingBalance, 9).toNumber() : 0;
23323
+ totalAmount = nativeAmount;
23324
+ if (existingBalanceNative < TOKEN_ACCOUNT_RENT_EXEMPT) {
23325
+ const rentNeeded = Math.max(0, TOKEN_ACCOUNT_RENT_EXEMPT - existingBalanceNative);
23326
+ totalAmount = nativeAmount + rentNeeded;
23327
+ }
23323
23328
  }
23324
23329
  return (0, import_sessions_sdk.createSessionWrapInstructions)(sessionKey, walletAddress, BigInt(totalAmount));
23325
23330
  }
@@ -23859,10 +23864,8 @@ var LendrAccount = class _LendrAccount {
23859
23864
  const wrapIxs = makeSessionWrapSolIxs(
23860
23865
  session.walletPublicKey,
23861
23866
  session.sessionPublicKey,
23862
- session.payer,
23863
23867
  wrapAmount,
23864
- wSolBalanceUi
23865
- // Pass existing balance to calculate rent correctly
23868
+ { existingBalance: wSolBalanceUi }
23866
23869
  );
23867
23870
  depositIxs.push(...wrapIxs);
23868
23871
  }
@@ -23977,17 +23980,15 @@ var LendrAccount = class _LendrAccount {
23977
23980
  );
23978
23981
  if (bank.mint.equals(import_spl_token6.NATIVE_MINT)) {
23979
23982
  const wSolBalanceUi = opts.wSolBalanceUi ?? 0;
23980
- let wrapAmount = new import_bignumber14.default(amount).minus(wSolBalanceUi);
23981
- if (repayAll) {
23982
- wrapAmount = wrapAmount.plus(96071e-8);
23983
- }
23983
+ const neededAmount = new import_bignumber14.default(amount).minus(wSolBalanceUi);
23984
23984
  const wrapIxs = makeSessionWrapSolIxs(
23985
23985
  session.walletPublicKey,
23986
23986
  session.sessionPublicKey,
23987
- session.payer,
23988
- wrapAmount,
23989
- wSolBalanceUi
23990
- // Pass existing balance to calculate rent correctly
23987
+ neededAmount,
23988
+ {
23989
+ existingBalance: wSolBalanceUi,
23990
+ wrapAmountUi: opts.wrapAmountUi
23991
+ }
23991
23992
  );
23992
23993
  repayIxs.push(...wrapIxs);
23993
23994
  }
@@ -26513,12 +26514,25 @@ var LendrAccountWrapper = class _LendrAccountWrapper {
26513
26514
  if (!bank) throw Error(`Bank ${bankAddress.toBase58()} not found`);
26514
26515
  const mintData = this.client.mintDatas.get(bankAddress.toBase58());
26515
26516
  if (!mintData) throw Error(`Mint data for bank ${bankAddress.toBase58()} not found`);
26516
- const ix = await instructions_default.makeHandleBankruptcyIx(this._program, {
26517
- bank: bankAddress,
26518
- lendrAccount: this.address,
26519
- tokenProgram: mintData.tokenProgram,
26520
- group: this.client.group.address
26521
- });
26517
+ const remainingAccounts = [];
26518
+ for (const balance of this.activeBalances) {
26519
+ const balBank = this.client.getBankByPk(balance.bankPk);
26520
+ if (!balBank) continue;
26521
+ remainingAccounts.push(
26522
+ { pubkey: balBank.address, isSigner: false, isWritable: false },
26523
+ { pubkey: balBank.config.oracleKeys[0], isSigner: false, isWritable: false }
26524
+ );
26525
+ }
26526
+ const ix = await instructions_default.makeHandleBankruptcyIx(
26527
+ this._program,
26528
+ {
26529
+ bank: bankAddress,
26530
+ lendrAccount: this.address,
26531
+ tokenProgram: mintData.tokenProgram,
26532
+ group: this.client.group.address
26533
+ },
26534
+ remainingAccounts
26535
+ );
26522
26536
  return {
26523
26537
  instructions: [ix],
26524
26538
  keys: []
package/dist/index.d.cts CHANGED
@@ -448,6 +448,7 @@ interface MakeDepositWithSessionIxOpts extends MakeDepositIxOpts {
448
448
  interface MakeRepayIxOpts {
449
449
  wrapAndUnwrapSol?: boolean;
450
450
  wSolBalanceUi?: number;
451
+ wrapAmountUi?: number;
451
452
  overrideInferAccounts?: {
452
453
  group?: PublicKey;
453
454
  authority?: PublicKey;
@@ -3041,7 +3042,7 @@ declare function makeHandleBankruptcyIx(ldProgram: LendrProgram, accounts: {
3041
3042
  liquidityVault?: PublicKey;
3042
3043
  insuranceVault?: PublicKey;
3043
3044
  insuranceVaultAuthority?: PublicKey;
3044
- }): Promise<_solana_web3_js.TransactionInstruction>;
3045
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
3045
3046
  declare const instructions: {
3046
3047
  makeDepositIx: typeof makeDepositIx;
3047
3048
  makeDepositWithSessionIx: typeof makeDepositWithSessionIx;
package/dist/index.d.ts CHANGED
@@ -448,6 +448,7 @@ interface MakeDepositWithSessionIxOpts extends MakeDepositIxOpts {
448
448
  interface MakeRepayIxOpts {
449
449
  wrapAndUnwrapSol?: boolean;
450
450
  wSolBalanceUi?: number;
451
+ wrapAmountUi?: number;
451
452
  overrideInferAccounts?: {
452
453
  group?: PublicKey;
453
454
  authority?: PublicKey;
@@ -3041,7 +3042,7 @@ declare function makeHandleBankruptcyIx(ldProgram: LendrProgram, accounts: {
3041
3042
  liquidityVault?: PublicKey;
3042
3043
  insuranceVault?: PublicKey;
3043
3044
  insuranceVaultAuthority?: PublicKey;
3044
- }): Promise<_solana_web3_js.TransactionInstruction>;
3045
+ }, remainingAccounts?: AccountMeta[]): Promise<_solana_web3_js.TransactionInstruction>;
3045
3046
  declare const instructions: {
3046
3047
  makeDepositIx: typeof makeDepositIx;
3047
3048
  makeDepositWithSessionIx: typeof makeDepositWithSessionIx;
package/dist/index.js CHANGED
@@ -11181,13 +11181,13 @@ async function makePulseHealthIx(ldProgram, accounts, remainingAccounts = []) {
11181
11181
  lendrAccount: accounts.lendrAccount
11182
11182
  }).remainingAccounts(remainingAccounts).instruction();
11183
11183
  }
11184
- async function makeHandleBankruptcyIx(ldProgram, accounts) {
11184
+ async function makeHandleBankruptcyIx(ldProgram, accounts, remainingAccounts = []) {
11185
11185
  const { bank, lendrAccount, tokenProgram, ...optionalAccounts } = accounts;
11186
11186
  return ldProgram.methods.lendingPoolHandleBankruptcy().accounts({
11187
11187
  bank,
11188
11188
  lendrAccount,
11189
11189
  tokenProgram
11190
- }).accountsPartial(optionalAccounts).instruction();
11190
+ }).accountsPartial(optionalAccounts).remainingAccounts(remainingAccounts).instruction();
11191
11191
  }
11192
11192
  var instructions = {
11193
11193
  makeDepositIx,
@@ -23135,14 +23135,19 @@ var BankConfig = class _BankConfig {
23135
23135
  };
23136
23136
 
23137
23137
  // src/models/account/pure.ts
23138
- function makeSessionWrapSolIxs(walletAddress, sessionKey, payer, amount, existingBalance) {
23139
- const nativeAmount = uiToNative(amount, 9).toNumber();
23140
- const TOKEN_ACCOUNT_RENT_EXEMPT = 2039280;
23141
- const existingBalanceNative = existingBalance ? uiToNative(existingBalance, 9).toNumber() : 0;
23142
- let totalAmount = nativeAmount;
23143
- if (existingBalanceNative < TOKEN_ACCOUNT_RENT_EXEMPT) {
23144
- const rentNeeded = Math.max(0, TOKEN_ACCOUNT_RENT_EXEMPT - existingBalanceNative);
23145
- totalAmount = nativeAmount + rentNeeded;
23138
+ var TOKEN_ACCOUNT_RENT_EXEMPT = 2039280;
23139
+ function makeSessionWrapSolIxs(walletAddress, sessionKey, amount, options) {
23140
+ let totalAmount;
23141
+ if (options?.wrapAmountUi !== void 0) {
23142
+ totalAmount = uiToNative(options.wrapAmountUi, 9).toNumber();
23143
+ } else {
23144
+ const nativeAmount = uiToNative(amount, 9).toNumber();
23145
+ const existingBalanceNative = options?.existingBalance ? uiToNative(options.existingBalance, 9).toNumber() : 0;
23146
+ totalAmount = nativeAmount;
23147
+ if (existingBalanceNative < TOKEN_ACCOUNT_RENT_EXEMPT) {
23148
+ const rentNeeded = Math.max(0, TOKEN_ACCOUNT_RENT_EXEMPT - existingBalanceNative);
23149
+ totalAmount = nativeAmount + rentNeeded;
23150
+ }
23146
23151
  }
23147
23152
  return createSessionWrapInstructions(sessionKey, walletAddress, BigInt(totalAmount));
23148
23153
  }
@@ -23682,10 +23687,8 @@ var LendrAccount = class _LendrAccount {
23682
23687
  const wrapIxs = makeSessionWrapSolIxs(
23683
23688
  session.walletPublicKey,
23684
23689
  session.sessionPublicKey,
23685
- session.payer,
23686
23690
  wrapAmount,
23687
- wSolBalanceUi
23688
- // Pass existing balance to calculate rent correctly
23691
+ { existingBalance: wSolBalanceUi }
23689
23692
  );
23690
23693
  depositIxs.push(...wrapIxs);
23691
23694
  }
@@ -23800,17 +23803,15 @@ var LendrAccount = class _LendrAccount {
23800
23803
  );
23801
23804
  if (bank.mint.equals(NATIVE_MINT2)) {
23802
23805
  const wSolBalanceUi = opts.wSolBalanceUi ?? 0;
23803
- let wrapAmount = new BigNumber14(amount).minus(wSolBalanceUi);
23804
- if (repayAll) {
23805
- wrapAmount = wrapAmount.plus(96071e-8);
23806
- }
23806
+ const neededAmount = new BigNumber14(amount).minus(wSolBalanceUi);
23807
23807
  const wrapIxs = makeSessionWrapSolIxs(
23808
23808
  session.walletPublicKey,
23809
23809
  session.sessionPublicKey,
23810
- session.payer,
23811
- wrapAmount,
23812
- wSolBalanceUi
23813
- // Pass existing balance to calculate rent correctly
23810
+ neededAmount,
23811
+ {
23812
+ existingBalance: wSolBalanceUi,
23813
+ wrapAmountUi: opts.wrapAmountUi
23814
+ }
23814
23815
  );
23815
23816
  repayIxs.push(...wrapIxs);
23816
23817
  }
@@ -26355,12 +26356,25 @@ var LendrAccountWrapper = class _LendrAccountWrapper {
26355
26356
  if (!bank) throw Error(`Bank ${bankAddress.toBase58()} not found`);
26356
26357
  const mintData = this.client.mintDatas.get(bankAddress.toBase58());
26357
26358
  if (!mintData) throw Error(`Mint data for bank ${bankAddress.toBase58()} not found`);
26358
- const ix = await instructions_default.makeHandleBankruptcyIx(this._program, {
26359
- bank: bankAddress,
26360
- lendrAccount: this.address,
26361
- tokenProgram: mintData.tokenProgram,
26362
- group: this.client.group.address
26363
- });
26359
+ const remainingAccounts = [];
26360
+ for (const balance of this.activeBalances) {
26361
+ const balBank = this.client.getBankByPk(balance.bankPk);
26362
+ if (!balBank) continue;
26363
+ remainingAccounts.push(
26364
+ { pubkey: balBank.address, isSigner: false, isWritable: false },
26365
+ { pubkey: balBank.config.oracleKeys[0], isSigner: false, isWritable: false }
26366
+ );
26367
+ }
26368
+ const ix = await instructions_default.makeHandleBankruptcyIx(
26369
+ this._program,
26370
+ {
26371
+ bank: bankAddress,
26372
+ lendrAccount: this.address,
26373
+ tokenProgram: mintData.tokenProgram,
26374
+ group: this.client.group.address
26375
+ },
26376
+ remainingAccounts
26377
+ );
26364
26378
  return {
26365
26379
  instructions: [ix],
26366
26380
  keys: []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyron-finance/pyron-client",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "keywords": [],
5
5
  "license": "MIT",
6
6
  "type": "module",