@haven-fi/solauto-sdk 1.0.156 → 1.0.158

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,6 +27,8 @@ export declare abstract class SolautoClient extends TxHandler {
27
27
  solautoPosition: PublicKey;
28
28
  solautoPositionData: SolautoPosition | null;
29
29
  solautoPositionState: PositionState | undefined;
30
+ maxLtvBps?: number;
31
+ liqThresholdBps?: number;
30
32
  supplyMint: PublicKey;
31
33
  positionSupplyTa: PublicKey;
32
34
  signerSupplyTa: PublicKey;
@@ -54,6 +56,7 @@ export declare abstract class SolautoClient extends TxHandler {
54
56
  } | undefined>;
55
57
  solautoPositionSettings(): SolautoSettingsParameters | undefined;
56
58
  solautoPositionActiveDca(): DCASettings | undefined;
59
+ maxLtvAndLiqThreshold(): Promise<[number, number] | undefined>;
57
60
  openPosition(settingParams?: SolautoSettingsParametersInpArgs, dca?: DCASettingsInpArgs): TransactionBuilder;
58
61
  updatePositionIx(args: UpdatePositionDataArgs): TransactionBuilder;
59
62
  closePositionIx(): TransactionBuilder;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAOnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAMvB,MAAM,cAAc,CAAC;AAOtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAA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OhE,wBAAwB,IAAI,WAAW,GAAG,SAAS;IAO7C,qBAAqB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAOpE,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IA0BrB,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB;IAwDlE,eAAe,IAAI,kBAAkB;IAYrC,WAAW,IAAI,kBAAkB;IAgCjC,QAAQ,CAAC,OAAO,IAAI,kBAAkB;IAEtC,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAuFhE,QAAQ,CAAC,WAAW,CAClB,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IAErB,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAE3E,QAAQ,CAAC,SAAS,CAChB,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
@@ -189,6 +189,12 @@ class SolautoClient extends txHandler_1.TxHandler {
189
189
  return (this.livePositionUpdates.activeDca ??
190
190
  this.solautoPositionData?.position.dca);
191
191
  }
192
+ async maxLtvAndLiqThreshold() {
193
+ if (this.maxLtvBps !== undefined && this.liqThresholdBps !== undefined) {
194
+ return [0, 0];
195
+ }
196
+ return undefined;
197
+ }
192
198
  openPosition(settingParams, dca) {
193
199
  if (dca && dca.dcaInBaseUnit > 0) {
194
200
  this.livePositionUpdates.new({
@@ -30,6 +30,7 @@ export declare class SolautoMarginfiClient extends SolautoClient {
30
30
  protocolAccount(): PublicKey;
31
31
  defaultLookupTables(): string[];
32
32
  lutAccountsToAdd(): PublicKey[];
33
+ maxLtvAndLiqThreshold(): Promise<[number, number] | undefined>;
33
34
  marginfiAccountInitialize(): TransactionBuilder;
34
35
  openPosition(settingParams?: SolautoSettingsParametersInpArgs, dca?: DCASettingsInpArgs): TransactionBuilder;
35
36
  private marginfiOpenPositionIx;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EAEb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAUnE,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,OAAO,CAAC,WAAW,CAAkB;IAE9B,eAAe,EAAG,SAAS,CAAC;IAE5B,sBAAsB,EAAE,MAAM,CAAa;IAC3C,eAAe,EAAG,SAAS,GAAG,MAAM,CAAC;IACrC,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e,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB;IA+D1C,8BAA8B;IA0CpC,eAAe,IAAI,SAAS;IAI5B,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAUzB,qBAAqB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IA2BpE,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA+C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAoErB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAwClE"}
@@ -53,7 +53,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
53
53
  this.supplyPriceOracle = new web3_js_1.PublicKey(this.marginfiSupplyAccounts.priceOracle);
54
54
  this.debtPriceOracle = new web3_js_1.PublicKey(this.marginfiDebtAccounts.priceOracle);
55
55
  if (!this.solautoPositionState) {
56
- const [maxLtv, liqThreshold] = await (0, marginfiUtils_1.getMaxLtvAndLiqThreshold)(this.umi, { mint: this.supplyMint }, { mint: this.debtMint });
56
+ const [maxLtv, liqThreshold] = (await this.maxLtvAndLiqThreshold());
57
57
  this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, (0, numberUtils_1.toBps)(maxLtv), (0, numberUtils_1.toBps)(liqThreshold));
58
58
  }
59
59
  if (!this.initialized) {
@@ -96,6 +96,28 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
96
96
  : []),
97
97
  ];
98
98
  }
99
+ async maxLtvAndLiqThreshold() {
100
+ const result = super.maxLtvAndLiqThreshold();
101
+ if (result) {
102
+ return result;
103
+ }
104
+ else {
105
+ if (this.supplyMint.equals(web3_js_1.PublicKey.default) ||
106
+ this.debtMint.equals(web3_js_1.PublicKey.default)) {
107
+ return [0, 0];
108
+ }
109
+ else {
110
+ const [maxLtv, liqThreshold] = await (0, marginfiUtils_1.getMaxLtvAndLiqThreshold)(this.umi, {
111
+ mint: this.supplyMint,
112
+ }, {
113
+ mint: this.debtMint,
114
+ });
115
+ this.maxLtvBps = maxLtv;
116
+ this.liqThresholdBps = liqThreshold;
117
+ return [this.maxLtvBps, this.liqThresholdBps];
118
+ }
119
+ }
120
+ }
99
121
  marginfiAccountInitialize() {
100
122
  return (0, marginfi_sdk_1.marginfiAccountInitialize)(this.umi, {
101
123
  marginfiAccount: this.marginfiAccount,
@@ -314,9 +336,11 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
314
336
  : undefined,
315
337
  rebalanceType,
316
338
  targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
317
- targetInAmountBaseUnit: targetLiqUtilizationRateBps ? swapDetails.amount : null,
339
+ targetInAmountBaseUnit: targetLiqUtilizationRateBps
340
+ ? swapDetails.amount
341
+ : null,
318
342
  limitGapBps: limitGapBps ?? null,
319
- slippageBps: slippageBps ?? 0
343
+ slippageBps: slippageBps ?? 0,
320
344
  });
321
345
  }
322
346
  flashBorrow(flashLoanDetails, destinationTokenAccount) {
@@ -217,7 +217,7 @@ class TransactionsManager {
217
217
  if (updateLookupTable &&
218
218
  updateLookupTable.updateLutTx.getInstructions().length > 0 &&
219
219
  updateLookupTable?.needsToBeIsolated) {
220
- await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => this.sendTransaction(updateLookupTable.updateLutTx, updateLutTxName, attemptNum, prioritySetting), 3, 150, this.errorsToThrow);
220
+ await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await this.sendTransaction(updateLookupTable.updateLutTx, updateLutTxName, attemptNum, prioritySetting), 3, 150, this.errorsToThrow);
221
221
  }
222
222
  this.lookupTables.defaultLuts = client.defaultLookupTables();
223
223
  for (const item of items) {
@@ -317,7 +317,7 @@ class TransactionsManager {
317
317
  if (this.txHandler.localTest) {
318
318
  await this.debugAccounts(itemSet, tx);
319
319
  }
320
- this.sendTransaction(tx, itemSet.name(), attemptNum, prioritySetting);
320
+ await this.sendTransaction(tx, itemSet.name(), attemptNum, prioritySetting);
321
321
  }
322
322
  }, this.retries, this.retryDelay, this.errorsToThrow);
323
323
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.156",
3
+ "version": "1.0.158",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -78,6 +78,9 @@ export abstract class SolautoClient extends TxHandler {
78
78
  public solautoPositionData!: SolautoPosition | null;
79
79
  public solautoPositionState!: PositionState | undefined;
80
80
 
81
+ public maxLtvBps?: number;
82
+ public liqThresholdBps?: number;
83
+
81
84
  public supplyMint!: PublicKey;
82
85
  public positionSupplyTa!: PublicKey;
83
86
  public signerSupplyTa!: PublicKey;
@@ -358,6 +361,13 @@ export abstract class SolautoClient extends TxHandler {
358
361
  );
359
362
  }
360
363
 
364
+ async maxLtvAndLiqThreshold(): Promise<[number, number] | undefined> {
365
+ if (this.maxLtvBps !== undefined && this.liqThresholdBps !== undefined) {
366
+ return [0, 0];
367
+ }
368
+ return undefined;
369
+ }
370
+
361
371
  openPosition(
362
372
  settingParams?: SolautoSettingsParametersInpArgs,
363
373
  dca?: DCASettingsInpArgs
@@ -133,11 +133,7 @@ export class SolautoMarginfiClient extends SolautoClient {
133
133
  this.debtPriceOracle = new PublicKey(this.marginfiDebtAccounts.priceOracle);
134
134
 
135
135
  if (!this.solautoPositionState) {
136
- const [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(
137
- this.umi,
138
- { mint: this.supplyMint },
139
- { mint: this.debtMint }
140
- );
136
+ const [maxLtv, liqThreshold] = (await this.maxLtvAndLiqThreshold())!;
141
137
  this.solautoPositionState = createFakePositionState(
142
138
  { mint: this.supplyMint },
143
139
  { mint: this.debtMint },
@@ -212,6 +208,33 @@ export class SolautoMarginfiClient extends SolautoClient {
212
208
  ];
213
209
  }
214
210
 
211
+ async maxLtvAndLiqThreshold(): Promise<[number, number] | undefined> {
212
+ const result = super.maxLtvAndLiqThreshold();
213
+ if (result) {
214
+ return result;
215
+ } else {
216
+ if (
217
+ this.supplyMint.equals(PublicKey.default) ||
218
+ this.debtMint.equals(PublicKey.default)
219
+ ) {
220
+ return [0, 0];
221
+ } else {
222
+ const [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(
223
+ this.umi,
224
+ {
225
+ mint: this.supplyMint,
226
+ },
227
+ {
228
+ mint: this.debtMint,
229
+ }
230
+ );
231
+ this.maxLtvBps = maxLtv;
232
+ this.liqThresholdBps = liqThreshold;
233
+ return [this.maxLtvBps, this.liqThresholdBps];
234
+ }
235
+ }
236
+ }
237
+
215
238
  marginfiAccountInitialize(): TransactionBuilder {
216
239
  return marginfiAccountInitialize(this.umi, {
217
240
  marginfiAccount: this.marginfiAccount as Signer,
@@ -433,7 +456,7 @@ export class SolautoMarginfiClient extends SolautoClient {
433
456
  slippageBps: number,
434
457
  flashLoan?: FlashLoanDetails,
435
458
  targetLiqUtilizationRateBps?: number,
436
- limitGapBps?: number,
459
+ limitGapBps?: number
437
460
  ): TransactionBuilder {
438
461
  const inputIsSupply = swapDetails.inputMint.equals(this.supplyMint);
439
462
  const outputIsSupply = swapDetails.outputMint.equals(this.supplyMint);
@@ -452,7 +475,9 @@ export class SolautoMarginfiClient extends SolautoClient {
452
475
  ixsSysvar: publicKey(SYSVAR_INSTRUCTIONS_PUBKEY),
453
476
  solautoFeesSupplyTa:
454
477
  rebalanceStep === "B" ? publicKey(this.solautoFeesSupplyTa) : undefined,
455
- authorityReferralState: publicKey(this.referralStateManager.referralState),
478
+ authorityReferralState: publicKey(
479
+ this.referralStateManager.referralState
480
+ ),
456
481
  referredBySupplyTa: this.referredBySupplyTa
457
482
  ? publicKey(this.referredBySupplyTa)
458
483
  : undefined,
@@ -469,7 +494,9 @@ export class SolautoMarginfiClient extends SolautoClient {
469
494
  supplyBank: publicKey(this.marginfiSupplyAccounts.bank),
470
495
  supplyPriceOracle: publicKey(this.supplyPriceOracle),
471
496
  positionSupplyTa: publicKey(this.positionSupplyTa),
472
- authoritySupplyTa: publicKey(getTokenAccount(this.authority, this.supplyMint)),
497
+ authoritySupplyTa: publicKey(
498
+ getTokenAccount(this.authority, this.supplyMint)
499
+ ),
473
500
  vaultSupplyTa: needSupplyAccounts
474
501
  ? publicKey(this.marginfiSupplyAccounts.liquidityVault)
475
502
  : undefined,
@@ -479,7 +506,9 @@ export class SolautoMarginfiClient extends SolautoClient {
479
506
  debtBank: publicKey(this.marginfiDebtAccounts.bank),
480
507
  debtPriceOracle: publicKey(this.debtPriceOracle),
481
508
  positionDebtTa: publicKey(this.positionDebtTa),
482
- authorityDebtTa: publicKey(getTokenAccount(this.authority, this.debtMint)),
509
+ authorityDebtTa: publicKey(
510
+ getTokenAccount(this.authority, this.debtMint)
511
+ ),
483
512
  vaultDebtTa: needDebtAccounts
484
513
  ? publicKey(this.marginfiDebtAccounts.liquidityVault)
485
514
  : undefined,
@@ -488,9 +517,11 @@ export class SolautoMarginfiClient extends SolautoClient {
488
517
  : undefined,
489
518
  rebalanceType,
490
519
  targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
491
- targetInAmountBaseUnit: targetLiqUtilizationRateBps ? swapDetails.amount : null,
520
+ targetInAmountBaseUnit: targetLiqUtilizationRateBps
521
+ ? swapDetails.amount
522
+ : null,
492
523
  limitGapBps: limitGapBps ?? null,
493
- slippageBps: slippageBps ?? 0
524
+ slippageBps: slippageBps ?? 0,
494
525
  });
495
526
  }
496
527
 
@@ -639,8 +670,20 @@ export class SolautoMarginfiClient extends SolautoClient {
639
670
  this.log("Debt price: ", debtPrice);
640
671
  this.log("Liq threshold bps:", freshState.liqThresholdBps);
641
672
  this.log("Liq utilization rate bps:", freshState.liqUtilizationRateBps);
642
- this.log("Supply USD:", fromBaseUnit(freshState.supply.amountUsed.baseUnit, freshState.supply.decimals) * supplyPrice);
643
- this.log("Debt USD:", fromBaseUnit(freshState.debt.amountUsed.baseUnit, freshState.debt.decimals) * debtPrice);
673
+ this.log(
674
+ "Supply USD:",
675
+ fromBaseUnit(
676
+ freshState.supply.amountUsed.baseUnit,
677
+ freshState.supply.decimals
678
+ ) * supplyPrice
679
+ );
680
+ this.log(
681
+ "Debt USD:",
682
+ fromBaseUnit(
683
+ freshState.debt.amountUsed.baseUnit,
684
+ freshState.debt.decimals
685
+ ) * debtPrice
686
+ );
644
687
  }
645
688
 
646
689
  return freshState;
@@ -320,7 +320,7 @@ export class TransactionsManager {
320
320
  ) {
321
321
  await retryWithExponentialBackoff(
322
322
  async (attemptNum) =>
323
- this.sendTransaction(
323
+ await this.sendTransaction(
324
324
  updateLookupTable.updateLutTx,
325
325
  updateLutTxName,
326
326
  attemptNum,
@@ -472,7 +472,7 @@ export class TransactionsManager {
472
472
  if (this.txHandler.localTest) {
473
473
  await this.debugAccounts(itemSet, tx);
474
474
  }
475
- this.sendTransaction(
475
+ await this.sendTransaction(
476
476
  tx,
477
477
  itemSet.name(),
478
478
  attemptNum,