@haven-fi/solauto-sdk 1.0.204 → 1.0.206

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,7 +45,7 @@ export declare abstract class SolautoClient extends TxHandler {
45
45
  livePositionUpdates: LivePositionUpdates;
46
46
  constructor(rpcUrl: string, localTest?: boolean);
47
47
  initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform): Promise<void>;
48
- setReferredBy(referredBy: PublicKey): void;
48
+ setReferredBy(referredBy?: PublicKey): void;
49
49
  resetLiveTxUpdates(success?: boolean): Promise<void>;
50
50
  abstract protocolAccount(): PublicKey;
51
51
  defaultLookupTables(): string[];
@@ -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;AAWtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,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C,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAOvE,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,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
@@ -62,9 +62,7 @@ class SolautoClient extends txHandler_1.TxHandler {
62
62
  signer: args.signer,
63
63
  wallet: args.wallet,
64
64
  });
65
- if (args.referredByAuthority) {
66
- this.setReferredBy(args.referredByAuthority);
67
- }
65
+ this.setReferredBy(args.referredByAuthority);
68
66
  this.solautoFeesWallet = generalAccounts_1.SOLAUTO_FEES_WALLET;
69
67
  this.solautoFeesSupplyTa = (0, accountUtils_1.getTokenAccount)(this.solautoFeesWallet, this.supplyMint);
70
68
  const authorityReferralStateData = this.referralStateManager.referralStateData;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,E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AAO,CAAC,sBAAsB;IA6C9B,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,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAqErB,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;CA6ClE"}
@@ -430,9 +430,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
430
430
  return state;
431
431
  }
432
432
  const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, this.marginfiGroup, !this.selfManaged && this.solautoPositionData === null
433
- ? this.supplyMint
433
+ ? { mint: this.supplyMint }
434
434
  : undefined, !this.selfManaged && this.solautoPositionData === null
435
- ? this.debtMint
435
+ ? { mint: this.debtMint }
436
436
  : undefined, this.livePositionUpdates);
437
437
  if (freshState) {
438
438
  this.log("Fresh state", freshState);
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAGL,aAAa,EAYd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,M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tB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBAwCzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CAkHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,SAAS,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAmCrD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAwC9D"}
@@ -340,8 +340,7 @@ async function requiresRefreshBeforeRebalance(client) {
340
340
  oldStateWithLatestPrices.liqUtilizationRateBps);
341
341
  if (client.livePositionUpdates.supplyAdjustment === BigInt(0) &&
342
342
  client.livePositionUpdates.debtAdjustment === BigInt(0) &&
343
- utilizationRateDiff / oldStateWithLatestPrices.liqUtilizationRateBps >=
344
- 0.005) {
343
+ utilizationRateDiff >= 20) {
345
344
  return true;
346
345
  }
347
346
  }
@@ -18,7 +18,17 @@ export declare function getAllMarginfiAccountsByAuthority(umi: Umi, authority: P
18
18
  supplyMint?: PublicKey;
19
19
  debtMint?: PublicKey;
20
20
  }[]>;
21
- export declare function getMarginfiAccountPositionState(umi: Umi, marginfiAccountPk: PublicKey, marginfiGroup?: PublicKey, supplyMint?: PublicKey, debtMint?: PublicKey, livePositionUpdates?: LivePositionUpdates): Promise<PositionState | undefined>;
21
+ interface BankSelection {
22
+ mint?: PublicKey;
23
+ banksCache?: BanksCache;
24
+ }
25
+ type BanksCache = {
26
+ [group: string]: {
27
+ [mint: string]: Bank;
28
+ };
29
+ };
30
+ export declare function getMarginfiAccountPositionState(umi: Umi, marginfiAccountPk: PublicKey, marginfiGroup?: PublicKey, supply?: BankSelection, debt?: BankSelection, livePositionUpdates?: LivePositionUpdates): Promise<PositionState | undefined>;
22
31
  export declare function calculateAnnualAPYs(bank: Bank): [number, number];
23
32
  export declare function getUpToDateShareValues(bank: Bank): Promise<[number, number]>;
33
+ export {};
24
34
  //# sourceMappingURL=marginfiUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAKL,MAAM,iBAAiB,CAAC;AAiBzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAY3E;AAED,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,WAAW,EAAE,MAAM,GAClB,CAAC,MAAM,EAAE,MAAM,CAAC,CA6BlB;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,SAAS,EACxB,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GA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EACtB,IAAI,CAAC,EAAE,aAAa,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA0LpC;AA+DD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,oBAU7C;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgB3B"}
@@ -143,17 +143,27 @@ async function getTokenUsage(bank, isAsset, shares, amountUsedAdjustment) {
143
143
  padding: new Uint8Array([]),
144
144
  };
145
145
  }
146
- async function getMarginfiAccountPositionState(umi, marginfiAccountPk, marginfiGroup, supplyMint, debtMint, livePositionUpdates) {
146
+ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, marginfiGroup, supply, debt, livePositionUpdates) {
147
147
  let marginfiAccount = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(umi, (0, umi_1.publicKey)(marginfiAccountPk), { commitment: "confirmed" });
148
+ if (!supply) {
149
+ supply = {};
150
+ }
151
+ if (!debt) {
152
+ debt = {};
153
+ }
148
154
  if (!marginfiGroup && marginfiAccount) {
149
155
  marginfiGroup = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(marginfiAccount.group);
150
156
  }
151
- let supplyBank = supplyMint && supplyMint !== web3_js_1.PublicKey.default
152
- ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][supplyMint.toString()].bank), { commitment: "confirmed" })
153
- : null;
154
- let debtBank = debtMint && debtMint !== web3_js_1.PublicKey.default
155
- ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][debtMint.toString()].bank), { commitment: "confirmed" })
156
- : null;
157
+ let supplyBank = supply?.banksCache && supply.mint && marginfiGroup
158
+ ? supply.banksCache[marginfiGroup.toString()][supply?.mint?.toString()]
159
+ : supply?.mint && supply?.mint !== web3_js_1.PublicKey.default
160
+ ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][supply?.mint.toString()].bank), { commitment: "confirmed" })
161
+ : null;
162
+ let debtBank = debt?.banksCache && debt.mint && marginfiGroup
163
+ ? debt.banksCache[marginfiGroup.toString()][debt?.mint?.toString()]
164
+ : debt?.mint && debt?.mint !== web3_js_1.PublicKey.default
165
+ ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][debt?.mint.toString()].bank), { commitment: "confirmed" })
166
+ : null;
157
167
  let supplyUsage = undefined;
158
168
  let debtUsage = undefined;
159
169
  if (marginfiAccount !== null &&
@@ -170,8 +180,8 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, marginfiG
170
180
  commitment: "confirmed",
171
181
  });
172
182
  }
173
- if (!supplyMint) {
174
- supplyMint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(supplyBank.mint);
183
+ if (!supply.mint) {
184
+ supply.mint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(supplyBank.mint);
175
185
  }
176
186
  supplyUsage = await getTokenUsage(supplyBank, true, (0, numberUtils_1.bytesToI80F48)(supplyBalances[0].assetShares.value), livePositionUpdates?.supplyAdjustment);
177
187
  }
@@ -181,8 +191,8 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, marginfiG
181
191
  commitment: "confirmed",
182
192
  });
183
193
  }
184
- if (!debtMint) {
185
- debtMint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(debtBank.mint);
194
+ if (!debt.mint) {
195
+ debt.mint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(debtBank.mint);
186
196
  }
187
197
  debtUsage = await getTokenUsage(debtBank, false, (0, numberUtils_1.bytesToI80F48)(debtBalances[0].liabilityShares.value), livePositionUpdates?.debtAdjustment);
188
198
  }
@@ -204,7 +214,7 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, marginfiG
204
214
  if (!debtUsage) {
205
215
  debtUsage = await getTokenUsage(debtBank, false, 0, livePositionUpdates?.debtAdjustment);
206
216
  }
207
- const supplyPrice = (0, generalUtils_1.safeGetPrice)(supplyMint);
217
+ const supplyPrice = (0, generalUtils_1.safeGetPrice)(supply.mint);
208
218
  let [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(umi, marginfiGroup ?? new web3_js_1.PublicKey(marginfiAccounts_1.DEFAULT_MARGINFI_GROUP), {
209
219
  mint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(supplyBank.mint),
210
220
  bank: supplyBank,
@@ -238,7 +248,7 @@ function marginfiInterestRateCurve(bank, utilizationRatio) {
238
248
  return (utilizationRatio * plateauIr) / optimalUr;
239
249
  }
240
250
  else {
241
- return ((((utilizationRatio - optimalUr) / (1 - optimalUr)) * (maxIr - plateauIr)) +
251
+ return (((utilizationRatio - optimalUr) / (1 - optimalUr)) * (maxIr - plateauIr) +
242
252
  plateauIr);
243
253
  }
244
254
  }
@@ -251,7 +261,7 @@ function calcInterestRate(bank, utilizationRatio) {
251
261
  const insuranceFixedFeeApr = (0, numberUtils_1.bytesToI80F48)(bank.config.interestRateConfig.insuranceFeeFixedApr.value);
252
262
  const rateFee = protocolIrFee + insuranceIrFee;
253
263
  const totalFixedFeeApr = protocolFixedFeeApr + insuranceFixedFeeApr;
254
- const borrowingRate = (baseRate * (1 + rateFee)) + totalFixedFeeApr;
264
+ const borrowingRate = baseRate * (1 + rateFee) + totalFixedFeeApr;
255
265
  return [lendingRate, borrowingRate];
256
266
  }
257
267
  function calcAccruedInterestPaymentPerPeriod(apr, timeDelta, shareValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.204",
3
+ "version": "1.0.206",
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",
@@ -175,9 +175,7 @@ export abstract class SolautoClient extends TxHandler {
175
175
  wallet: args.wallet,
176
176
  });
177
177
 
178
- if (args.referredByAuthority) {
179
- this.setReferredBy(args.referredByAuthority);
180
- }
178
+ this.setReferredBy(args.referredByAuthority);
181
179
 
182
180
  this.solautoFeesWallet = SOLAUTO_FEES_WALLET;
183
181
  this.solautoFeesSupplyTa = getTokenAccount(
@@ -209,7 +207,7 @@ export abstract class SolautoClient extends TxHandler {
209
207
  );
210
208
  }
211
209
 
212
- public setReferredBy(referredBy: PublicKey) {
210
+ public setReferredBy(referredBy?: PublicKey) {
213
211
  const authorityReferralStateData =
214
212
  this.referralStateManager.referralStateData;
215
213
  const hasReferredBy =
@@ -55,7 +55,6 @@ import {
55
55
  getMaxLtvAndLiqThreshold,
56
56
  } from "../utils/marginfiUtils";
57
57
  import { bytesToI80F48, fromBaseUnit, toBps } from "../utils/numberUtils";
58
- import { createFakePositionState } from "../utils";
59
58
  import { QuoteResponse } from "@jup-ag/api";
60
59
 
61
60
  export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
@@ -653,10 +652,10 @@ export class SolautoMarginfiClient extends SolautoClient {
653
652
  this.marginfiAccountPk,
654
653
  this.marginfiGroup,
655
654
  !this.selfManaged && this.solautoPositionData === null
656
- ? this.supplyMint
655
+ ? { mint: this.supplyMint }
657
656
  : undefined,
658
657
  !this.selfManaged && this.solautoPositionData === null
659
- ? this.debtMint
658
+ ? { mint: this.debtMint }
660
659
  : undefined,
661
660
  this.livePositionUpdates
662
661
  );
@@ -612,8 +612,7 @@ export async function requiresRefreshBeforeRebalance(client: SolautoClient) {
612
612
  if (
613
613
  client.livePositionUpdates.supplyAdjustment === BigInt(0) &&
614
614
  client.livePositionUpdates.debtAdjustment === BigInt(0) &&
615
- utilizationRateDiff / oldStateWithLatestPrices.liqUtilizationRateBps >=
616
- 0.005
615
+ utilizationRateDiff >= 20
617
616
  ) {
618
617
  return true;
619
618
  }
@@ -256,12 +256,19 @@ async function getTokenUsage(
256
256
  };
257
257
  }
258
258
 
259
+ interface BankSelection {
260
+ mint?: PublicKey;
261
+ banksCache?: BanksCache;
262
+ }
263
+
264
+ type BanksCache = { [group: string]: { [mint: string]: Bank } };
265
+
259
266
  export async function getMarginfiAccountPositionState(
260
267
  umi: Umi,
261
268
  marginfiAccountPk: PublicKey,
262
269
  marginfiGroup?: PublicKey,
263
- supplyMint?: PublicKey,
264
- debtMint?: PublicKey,
270
+ supply?: BankSelection,
271
+ debt?: BankSelection,
265
272
  livePositionUpdates?: LivePositionUpdates
266
273
  ): Promise<PositionState | undefined> {
267
274
  let marginfiAccount = await safeFetchMarginfiAccount(
@@ -270,34 +277,45 @@ export async function getMarginfiAccountPositionState(
270
277
  { commitment: "confirmed" }
271
278
  );
272
279
 
280
+ if (!supply) {
281
+ supply = {};
282
+ }
283
+ if (!debt) {
284
+ debt = {};
285
+ }
286
+
273
287
  if (!marginfiGroup && marginfiAccount) {
274
288
  marginfiGroup = toWeb3JsPublicKey(marginfiAccount.group);
275
289
  }
276
290
 
277
291
  let supplyBank: Bank | null =
278
- supplyMint && supplyMint !== PublicKey.default
279
- ? await safeFetchBank(
280
- umi,
281
- publicKey(
282
- MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][
283
- supplyMint.toString()
284
- ].bank
285
- ),
286
- { commitment: "confirmed" }
287
- )
288
- : null;
292
+ supply?.banksCache && supply.mint && marginfiGroup
293
+ ? supply.banksCache[marginfiGroup!.toString()][supply?.mint?.toString()]
294
+ : supply?.mint && supply?.mint !== PublicKey.default
295
+ ? await safeFetchBank(
296
+ umi,
297
+ publicKey(
298
+ MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][
299
+ supply?.mint.toString()
300
+ ].bank
301
+ ),
302
+ { commitment: "confirmed" }
303
+ )
304
+ : null;
289
305
  let debtBank: Bank | null =
290
- debtMint && debtMint !== PublicKey.default
291
- ? await safeFetchBank(
292
- umi,
293
- publicKey(
294
- MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][
295
- debtMint.toString()
296
- ].bank
297
- ),
298
- { commitment: "confirmed" }
299
- )
300
- : null;
306
+ debt?.banksCache && debt.mint && marginfiGroup
307
+ ? debt.banksCache[marginfiGroup!.toString()][debt?.mint?.toString()]
308
+ : debt?.mint && debt?.mint !== PublicKey.default
309
+ ? await safeFetchBank(
310
+ umi,
311
+ publicKey(
312
+ MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][
313
+ debt?.mint.toString()
314
+ ].bank
315
+ ),
316
+ { commitment: "confirmed" }
317
+ )
318
+ : null;
301
319
 
302
320
  let supplyUsage: PositionTokenUsage | undefined = undefined;
303
321
  let debtUsage: PositionTokenUsage | undefined = undefined;
@@ -326,8 +344,8 @@ export async function getMarginfiAccountPositionState(
326
344
  commitment: "confirmed",
327
345
  });
328
346
  }
329
- if (!supplyMint) {
330
- supplyMint = toWeb3JsPublicKey(supplyBank!.mint);
347
+ if (!supply.mint) {
348
+ supply.mint = toWeb3JsPublicKey(supplyBank!.mint);
331
349
  }
332
350
  supplyUsage = await getTokenUsage(
333
351
  supplyBank!,
@@ -343,8 +361,8 @@ export async function getMarginfiAccountPositionState(
343
361
  commitment: "confirmed",
344
362
  });
345
363
  }
346
- if (!debtMint) {
347
- debtMint = toWeb3JsPublicKey(debtBank!.mint);
364
+ if (!debt.mint) {
365
+ debt.mint = toWeb3JsPublicKey(debtBank!.mint);
348
366
  }
349
367
  debtUsage = await getTokenUsage(
350
368
  debtBank!,
@@ -393,7 +411,7 @@ export async function getMarginfiAccountPositionState(
393
411
  );
394
412
  }
395
413
 
396
- const supplyPrice = safeGetPrice(supplyMint!)!;
414
+ const supplyPrice = safeGetPrice(supply.mint!)!;
397
415
  let [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(
398
416
  umi,
399
417
  marginfiGroup ?? new PublicKey(DEFAULT_MARGINFI_GROUP),
@@ -458,7 +476,7 @@ function marginfiInterestRateCurve(
458
476
  return (utilizationRatio * plateauIr) / optimalUr;
459
477
  } else {
460
478
  return (
461
- (((utilizationRatio - optimalUr) / (1 - optimalUr)) * (maxIr - plateauIr)) +
479
+ ((utilizationRatio - optimalUr) / (1 - optimalUr)) * (maxIr - plateauIr) +
462
480
  plateauIr
463
481
  );
464
482
  }
@@ -486,7 +504,7 @@ function calcInterestRate(
486
504
  );
487
505
  const rateFee = protocolIrFee + insuranceIrFee;
488
506
  const totalFixedFeeApr = protocolFixedFeeApr + insuranceFixedFeeApr;
489
- const borrowingRate = (baseRate * (1 + rateFee)) + totalFixedFeeApr;
507
+ const borrowingRate = baseRate * (1 + rateFee) + totalFixedFeeApr;
490
508
 
491
509
  return [lendingRate, borrowingRate];
492
510
  }
@@ -1,16 +1,21 @@
1
1
  import { describe, it } from "mocha";
2
2
  import { none, publicKey, some } from "@metaplex-foundation/umi";
3
3
  import { setupTest } from "../shared";
4
+ import { SolautoMarginfiClient } from "../../src/clients/solautoMarginfiClient";
4
5
  import {
5
- SolautoMarginfiClient,
6
- } from "../../src/clients/solautoMarginfiClient";
7
- import {
6
+ PositionType,
7
+ safeFetchAllSolautoPosition,
8
8
  solautoAction,
9
9
  SolautoSettingsParametersInpArgs,
10
10
  } from "../../src/generated";
11
11
  import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
12
- import { maxBoostToBps, maxRepayFromBps, maxRepayToBps, toBaseUnit } from "../../src/utils/numberUtils";
13
- import { NATIVE_MINT } from "@solana/spl-token";
12
+ import {
13
+ maxBoostToBps,
14
+ maxRepayFromBps,
15
+ maxRepayToBps,
16
+ toBaseUnit,
17
+ } from "../../src/utils/numberUtils";
18
+ import { getAssociatedTokenAddress, NATIVE_MINT } from "@solana/spl-token";
14
19
  import { fetchTokenPrices } from "../../src/utils/generalUtils";
15
20
  import {
16
21
  TransactionItem,
@@ -18,18 +23,23 @@ import {
18
23
  } from "../../src/transactions/transactionsManager";
19
24
  import { PublicKey } from "@solana/web3.js";
20
25
  import { USDC } from "../../src/constants";
21
- import { buildHeliusApiUrl, getMarginfiAccountPositionState } from "../../src/utils";
26
+ import {
27
+ buildHeliusApiUrl,
28
+ getAllPositionsByAuthority,
29
+ getMarginfiAccountPositionState,
30
+ getSolautoManagedPositions,
31
+ } from "../../src/utils";
32
+ import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
22
33
 
23
34
  describe("Solauto Marginfi tests", async () => {
24
35
  // const signer = setupTest();
25
36
  const signer = setupTest("solauto-manager");
26
37
 
27
- const payForTransactions = true;
38
+ const payForTransactions = false;
28
39
  const useJitoBundle = false;
29
40
  const positionId = 1;
30
41
 
31
42
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
32
-
33
43
  const client = new SolautoMarginfiClient(
34
44
  buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
35
45
  true
@@ -39,18 +49,16 @@ describe("Solauto Marginfi tests", async () => {
39
49
  const supplyDecimals = 9;
40
50
  const debtDecimals = 6;
41
51
 
42
- await client.initialize(
43
- {
44
- signer,
45
- positionId,
46
- authority: new PublicKey("AprYCPiVeKMCgjQ2ZufwChMzvQ5kFjJo2ekTLSkXsQDm")
47
- // marginfiAccount: new PublicKey(
48
- // "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
49
- // ),
50
- // supplyMint: NATIVE_MINT,
51
- // debtMint: new PublicKey(USDC),
52
- }
53
- );
52
+ await client.initialize({
53
+ signer,
54
+ positionId,
55
+ authority: new PublicKey("AprYCPiVeKMCgjQ2ZufwChMzvQ5kFjJo2ekTLSkXsQDm"),
56
+ // marginfiAccount: new PublicKey(
57
+ // "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
58
+ // ),
59
+ // supplyMint: NATIVE_MINT,
60
+ // debtMint: new PublicKey(USDC),
61
+ });
54
62
 
55
63
  const transactionItems: TransactionItem[] = [];
56
64
  // const settingParams: SolautoSettingsParametersInpArgs = {