@haven-fi/solauto-sdk 1.0.76 → 1.0.78

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"marginfiAccounts.d.ts","sourceRoot":"","sources":["../../src/constants/marginfiAccounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AAErF,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAA;CAyBrE,CAAC;AAEF,eAAO,MAAM,8BAA8B,iDAAiD,CAAC"}
1
+ {"version":3,"file":"marginfiAccounts.d.ts","sourceRoot":"","sources":["../../src/constants/marginfiAccounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AAGrF,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAA;CA+BrE,CAAC;AAEF,eAAO,MAAM,8BAA8B,iDAAiD,CAAC"}
@@ -3,8 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = exports.MARGINFI_ACCOUNTS = exports.DEFAULT_MARGINFI_GROUP = void 0;
4
4
  const spl_token_1 = require("@solana/spl-token");
5
5
  const tokenConstants_1 = require("./tokenConstants");
6
+ const web3_js_1 = require("@solana/web3.js");
6
7
  exports.DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
8
+ const DEFAULT_PUBKEY = web3_js_1.PublicKey.default.toString();
7
9
  exports.MARGINFI_ACCOUNTS = {
10
+ [DEFAULT_PUBKEY]: {
11
+ bank: DEFAULT_PUBKEY,
12
+ liquidityVault: DEFAULT_PUBKEY,
13
+ vaultAuthority: DEFAULT_PUBKEY,
14
+ priceOracle: DEFAULT_PUBKEY,
15
+ },
8
16
  [spl_token_1.NATIVE_MINT.toString()]: {
9
17
  bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
10
18
  liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
@@ -28,6 +36,6 @@ exports.MARGINFI_ACCOUNTS = {
28
36
  liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
29
37
  vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
30
38
  priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
31
- }
39
+ },
32
40
  };
33
41
  exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
@@ -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;AAWzB,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,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,IA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AU3E;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,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"}
@@ -25,6 +25,9 @@ function findMarginfiAccounts(bank) {
25
25
  throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
26
26
  }
27
27
  async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
28
+ if (!supply.bank && supply.mint.equals(web3_js_1.PublicKey.default)) {
29
+ return [0, 0];
30
+ }
28
31
  if (!supply.bank || supply.bank === null) {
29
32
  supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supply.mint.toString()].bank));
30
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.76",
3
+ "version": "1.0.78",
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",
@@ -1,10 +1,18 @@
1
1
  import { NATIVE_MINT } from "@solana/spl-token";
2
2
  import { B_SOL, JUP, USDC_MINT } from "./tokenConstants";
3
3
  import { MarginfiAssetAccounts } from "../types/accounts";
4
+ import { PublicKey } from "@solana/web3.js";
4
5
 
5
6
  export const DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
6
7
 
8
+ const DEFAULT_PUBKEY = PublicKey.default.toString();
7
9
  export const MARGINFI_ACCOUNTS: { [key: string]: MarginfiAssetAccounts } = {
10
+ [DEFAULT_PUBKEY]: {
11
+ bank: DEFAULT_PUBKEY,
12
+ liquidityVault: DEFAULT_PUBKEY,
13
+ vaultAuthority: DEFAULT_PUBKEY,
14
+ priceOracle: DEFAULT_PUBKEY,
15
+ },
8
16
  [NATIVE_MINT.toString()]: {
9
17
  bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
10
18
  liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
@@ -28,7 +36,7 @@ export const MARGINFI_ACCOUNTS: { [key: string]: MarginfiAssetAccounts } = {
28
36
  liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
29
37
  vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
30
38
  priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
31
- }
39
+ },
32
40
  };
33
41
 
34
42
  export const MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
@@ -48,6 +48,10 @@ export async function getMaxLtvAndLiqThreshold(
48
48
  },
49
49
  supplyPrice?: number
50
50
  ): Promise<[number, number]> {
51
+ if (!supply.bank && supply.mint.equals(PublicKey.default)) {
52
+ return [0, 0];
53
+ }
54
+
51
55
  if (!supply.bank || supply.bank === null) {
52
56
  supply.bank = await safeFetchBank(
53
57
  umi,