@haven-fi/solauto-sdk 1.0.86 → 1.0.88

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.
@@ -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,EAAyB,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EACL,IAAI,EAKL,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAI7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAU3E;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,IAAI,EAAE;IACJ,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA+D3B;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,qBAAqB,CAAC,EAAE,OAAO,GAC9B,OAAO,CACR;IAAE,eAAe,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,EAAE,CAC/E,CAqDA;AAgED,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG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ACR;IAAE,eAAe,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,EAAE,CAC/E,CA6CA;AAgED,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,iBAAiB,EAAE,SAAS,EAC5B,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA+IpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
@@ -15,7 +15,6 @@ const solautoConstants_1 = require("../constants/solautoConstants");
15
15
  const marginfiAccounts_1 = require("../constants/marginfiAccounts");
16
16
  const generalAccounts_1 = require("../constants/generalAccounts");
17
17
  const solanaUtils_1 = require("./solanaUtils");
18
- const accountUtils_1 = require("./accountUtils");
19
18
  function findMarginfiAccounts(bank) {
20
19
  for (const key in marginfiAccounts_1.MARGINFI_ACCOUNTS) {
21
20
  const account = marginfiAccounts_1.MARGINFI_ACCOUNTS[key];
@@ -60,7 +59,7 @@ async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
60
59
  return [maxLtv, liqThreshold];
61
60
  }
62
61
  async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithSolauto) {
63
- const getAccounts = async (authorityPk) => await umi.rpc.getProgramAccounts(marginfi_sdk_1.MARGINFI_PROGRAM_ID, {
62
+ const marginfiAccounts = await umi.rpc.getProgramAccounts(marginfi_sdk_1.MARGINFI_PROGRAM_ID, {
64
63
  commitment: "finalized",
65
64
  dataSlice: {
66
65
  offset: 0,
@@ -72,22 +71,14 @@ async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithS
72
71
  },
73
72
  {
74
73
  memcmp: {
75
- bytes: new Uint8Array(authorityPk.toBuffer()),
74
+ bytes: new Uint8Array(authority.toBuffer()),
76
75
  offset: 40, // Anchor account discriminator + group pubkey
77
76
  },
78
77
  },
79
78
  ],
80
79
  });
81
- let marginfiAccounts = [];
82
- let selfManagedSolautoPositions = [];
83
80
  if (compatibleWithSolauto) {
84
- [marginfiAccounts, selfManagedSolautoPositions] = await Promise.all([getAccounts(authority), getAccounts((0, accountUtils_1.getSolautoPositionAccount)(authority, 0))]);
85
- }
86
- else {
87
- marginfiAccounts = await getAccounts(authority);
88
- }
89
- if (compatibleWithSolauto) {
90
- const positionStates = await Promise.all([...selfManagedSolautoPositions, ...marginfiAccounts].map(async (x) => ({
81
+ const positionStates = await Promise.all(marginfiAccounts.map(async (x) => ({
91
82
  publicKey: x.publicKey,
92
83
  state: await getMarginfiAccountPositionState(umi, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey)),
93
84
  })));
@@ -70,8 +70,8 @@ function getDebtAdjustmentUsd(liqThresholdBps, supplyUsd, debtUsd, targetLiqUtil
70
70
  function getSolautoFeesBps(isReferred, feeType, positionNetWorthUsd) {
71
71
  const minSize = 10000; // Minimum position size
72
72
  const maxSize = 1000000; // Maximum position size
73
- const maxFeeBps = 500; // Fee in basis points for minSize (5%)
74
- const minFeeBps = 100; // Fee in basis points for maxSize (1%)
73
+ const maxFeeBps = 300; // Fee in basis points for minSize (5%)
74
+ const minFeeBps = 50; // Fee in basis points for maxSize (1%)
75
75
  let feeBps = 0;
76
76
  if (feeType === generated_1.FeeType.Small) {
77
77
  feeBps = 100;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.86",
3
+ "version": "1.0.88",
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",
@@ -120,7 +120,7 @@ export async function getAllMarginfiAccountsByAuthority(
120
120
  ): Promise<
121
121
  { marginfiAccount: PublicKey; supplyMint?: PublicKey; debtMint?: PublicKey }[]
122
122
  > {
123
- const getAccounts = async (authorityPk: PublicKey) => await umi.rpc.getProgramAccounts(
123
+ const marginfiAccounts = await umi.rpc.getProgramAccounts(
124
124
  MARGINFI_PROGRAM_ID,
125
125
  {
126
126
  commitment: "finalized",
@@ -134,25 +134,17 @@ export async function getAllMarginfiAccountsByAuthority(
134
134
  },
135
135
  {
136
136
  memcmp: {
137
- bytes: new Uint8Array(authorityPk.toBuffer()),
137
+ bytes: new Uint8Array(authority.toBuffer()),
138
138
  offset: 40, // Anchor account discriminator + group pubkey
139
139
  },
140
140
  },
141
141
  ],
142
142
  }
143
- )
144
-
145
- let marginfiAccounts: RpcAccount[] = [];
146
- let selfManagedSolautoPositions: RpcAccount[] = [];
147
- if (compatibleWithSolauto) {
148
- [marginfiAccounts, selfManagedSolautoPositions] = await Promise.all([getAccounts(authority), getAccounts(getSolautoPositionAccount(authority, 0))]);
149
- } else {
150
- marginfiAccounts = await getAccounts(authority);
151
- }
143
+ );
152
144
 
153
145
  if (compatibleWithSolauto) {
154
146
  const positionStates = await Promise.all(
155
- [...selfManagedSolautoPositions, ...marginfiAccounts].map(async (x) => ({
147
+ marginfiAccounts.map(async (x) => ({
156
148
  publicKey: x.publicKey,
157
149
  state: await getMarginfiAccountPositionState(
158
150
  umi,
@@ -98,8 +98,8 @@ export function getSolautoFeesBps(
98
98
  } {
99
99
  const minSize = 10000; // Minimum position size
100
100
  const maxSize = 1000000; // Maximum position size
101
- const maxFeeBps = 500; // Fee in basis points for minSize (5%)
102
- const minFeeBps = 100; // Fee in basis points for maxSize (1%)
101
+ const maxFeeBps = 300; // Fee in basis points for minSize (5%)
102
+ const minFeeBps = 50; // Fee in basis points for maxSize (1%)
103
103
 
104
104
  let feeBps: number = 0;
105
105
  if (feeType === FeeType.Small) {