@haven-fi/solauto-sdk 1.0.70 → 1.0.71

Sign up to get free protection for your applications and to get access to all the features.
@@ -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;AAK1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EACb,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;AASnE,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,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAE1B,sBAAsB,EAAG,qBAAqB,CAAC;IAC/C,oBAAoB,EAAG,qBAAqB,CAAC;IAG7C,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,6BAA6B,EAAG,SAAS,CAAC;IAC1C,2BAA2B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mErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IA2DrB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IA6ElE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAiBlE"}
@@ -40,12 +40,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
40
40
  this.marginfiGroup = marginfiAccountData
41
41
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(marginfiAccountData.group)
42
42
  : args.marginfiGroup ?? new web3_js_1.PublicKey(marginfiAccounts_1.DEFAULT_MARGINFI_GROUP);
43
- this.marginfiSupplyAccounts = (0, marginfiUtils_1.findMarginfiAccounts)({
44
- mint: this.supplyMint.toString(),
45
- });
46
- this.marginfiDebtAccounts = (0, marginfiUtils_1.findMarginfiAccounts)({
47
- mint: this.debtMint.toString(),
48
- });
43
+ this.marginfiSupplyAccounts =
44
+ marginfiAccounts_1.MARGINFI_ACCOUNTS[this.supplyMint.toString()];
45
+ this.marginfiDebtAccounts = marginfiAccounts_1.MARGINFI_ACCOUNTS[this.debtMint.toString()];
49
46
  if (!this.initialized) {
50
47
  await this.setIntermediaryMarginfiDetails();
51
48
  }
@@ -78,7 +75,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
78
75
  return [
79
76
  ...super.lutAccountsToAdd(),
80
77
  this.marginfiAccountPk,
81
- ...(this.signer.publicKey.toString() === this.authority.toString() ? [this.intermediaryMarginfiAccountPk] : []),
78
+ ...(this.signer.publicKey.toString() === this.authority.toString()
79
+ ? [this.intermediaryMarginfiAccountPk]
80
+ : []),
82
81
  ];
83
82
  }
84
83
  marginfiAccountInitialize() {
@@ -344,8 +343,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
344
343
  isWritable: false,
345
344
  },
346
345
  {
347
- pubkey: (0, umi_1.publicKey)((0, marginfiUtils_1.findMarginfiAccounts)({ bank: x.bankPk.toString() })
348
- .priceOracle),
346
+ pubkey: (0, umi_1.publicKey)((0, marginfiUtils_1.findMarginfiAccounts)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.bankPk)).priceOracle),
349
347
  isSigner: false,
350
348
  isWritable: false,
351
349
  },
@@ -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;CAerE,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;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"}
@@ -5,19 +5,29 @@ const spl_token_1 = require("@solana/spl-token");
5
5
  const tokenConstants_1 = require("./tokenConstants");
6
6
  exports.DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
7
7
  exports.MARGINFI_ACCOUNTS = {
8
- SOL: {
9
- mint: spl_token_1.NATIVE_MINT.toString(),
8
+ [spl_token_1.NATIVE_MINT.toString()]: {
10
9
  bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
11
10
  liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
12
11
  vaultAuthority: "DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD",
13
12
  priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE"
14
13
  },
15
- USDC: {
16
- mint: tokenConstants_1.USDC_MINT,
14
+ [tokenConstants_1.USDC_MINT]: {
17
15
  bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
18
16
  liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
19
17
  vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
20
18
  priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX"
19
+ },
20
+ [tokenConstants_1.B_SOL]: {
21
+ bank: "6hS9i46WyTq1KXcoa2Chas2Txh9TJAVr6n1t3tnrE23K",
22
+ liquidityVault: "2WMipeKDB2CENxbzdmnVrRbsxCA2LY6kCtBe6AAqDP9p",
23
+ vaultAuthority: "8RcZHucpVHkHWRRdMhJZsxBK9mqKSYnMKGqtF84U8YEo",
24
+ priceOracle: "5cN76Xm2Dtx9MnrQqBDeZZRsWruTTcw37UruznAdSvvE",
25
+ },
26
+ [tokenConstants_1.JUP]: {
27
+ bank: "Guu5uBc8k1WK1U2ihGosNaCy57LSgCkpWAabtzQqrQf8",
28
+ liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
29
+ vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
30
+ priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
21
31
  }
22
32
  };
23
33
  exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
@@ -1,5 +1,7 @@
1
1
  export declare const PYTH_PRICE_FEED_IDS: {
2
2
  [x: string]: string;
3
3
  EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: string;
4
+ bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1: string;
5
+ JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN: string;
4
6
  };
5
7
  //# sourceMappingURL=pythConstants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pythConstants.d.ts","sourceRoot":"","sources":["../../src/constants/pythConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;CAK/B,CAAC"}
1
+ {"version":3,"file":"pythConstants.d.ts","sourceRoot":"","sources":["../../src/constants/pythConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;;;CAO/B,CAAC"}
@@ -7,4 +7,6 @@ const tokenConstants_1 = require("./tokenConstants");
7
7
  exports.PYTH_PRICE_FEED_IDS = {
8
8
  [spl_token_1.NATIVE_MINT.toString()]: "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
9
9
  [tokenConstants_1.USDC_MINT]: "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
10
+ [tokenConstants_1.B_SOL]: "0x89875379e70f8fbadc17aef315adf3a8d5d160b811435537e03c97e8aac97d9c",
11
+ [tokenConstants_1.JUP]: "0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996",
10
12
  };
@@ -1,8 +1,14 @@
1
1
  export declare const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
2
+ export declare const B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
3
+ export declare const JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
2
4
  export declare const ALL_SUPPORTED_TOKENS: string[];
3
- export declare const TOKEN_DECIMALS: {
4
- [x: string]: number;
5
- EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: number;
5
+ interface TokenInfo {
6
+ decimals: number;
7
+ isStableCoin?: boolean;
8
+ isLST?: boolean;
9
+ }
10
+ export declare const TOKEN_INFO: {
11
+ [key: string]: TokenInfo;
6
12
  };
7
- export declare const STABLECOINS: string[];
13
+ export {};
8
14
  //# sourceMappingURL=tokenConstants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,iDAAiD,CAAC;AAGxE,eAAO,MAAM,oBAAoB,UAGhC,CAAC;AAEF,eAAO,MAAM,cAAc;;;CAG1B,CAAC;AAEF,eAAO,MAAM,WAAW,UAEvB,CAAC"}
1
+ {"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,iDAAiD,CAAC;AACxE,eAAO,MAAM,KAAK,gDAAgD,CAAC;AACnE,eAAO,MAAM,GAAG,gDAAgD,CAAC;AAGjE,eAAO,MAAM,oBAAoB,UAKhC,CAAC;AAEF,UAAU,SAAS;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAelD,CAAC"}
@@ -1,17 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STABLECOINS = exports.TOKEN_DECIMALS = exports.ALL_SUPPORTED_TOKENS = exports.USDC_MINT = void 0;
3
+ exports.TOKEN_INFO = exports.ALL_SUPPORTED_TOKENS = exports.JUP = exports.B_SOL = exports.USDC_MINT = void 0;
4
4
  const spl_token_1 = require("@solana/spl-token");
5
- // When adding token ensure a price feed is provided in pythConstants.ts & the token is added to the necessary lists below
5
+ // When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
6
6
  exports.USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
7
+ exports.B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
8
+ exports.JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
7
9
  exports.ALL_SUPPORTED_TOKENS = [
8
10
  spl_token_1.NATIVE_MINT.toString(),
9
11
  exports.USDC_MINT,
12
+ exports.B_SOL,
13
+ exports.JUP,
10
14
  ];
11
- exports.TOKEN_DECIMALS = {
12
- [spl_token_1.NATIVE_MINT.toString()]: 9,
13
- [exports.USDC_MINT]: 6
15
+ exports.TOKEN_INFO = {
16
+ [spl_token_1.NATIVE_MINT.toString()]: {
17
+ decimals: 9,
18
+ },
19
+ [exports.USDC_MINT]: {
20
+ decimals: 6,
21
+ isStableCoin: true
22
+ },
23
+ [exports.B_SOL]: {
24
+ decimals: 9,
25
+ isLST: true
26
+ },
27
+ [exports.JUP]: {
28
+ decimals: 6
29
+ }
14
30
  };
15
- exports.STABLECOINS = [
16
- exports.USDC_MINT
17
- ];
@@ -1,5 +1,4 @@
1
1
  export interface MarginfiAssetAccounts {
2
- mint: string;
3
2
  bank: string;
4
3
  liquidityVault: string;
5
4
  vaultAuthority: string;
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/types/accounts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB"}
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/types/accounts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -4,10 +4,7 @@ import { Bank } from "../marginfi-sdk";
4
4
  import { MarginfiAssetAccounts } from "../types/accounts";
5
5
  import { PositionState } from "../generated";
6
6
  import { LivePositionUpdates } from "./solauto/generalUtils";
7
- export declare function findMarginfiAccounts({ mint, bank, }: {
8
- mint?: string;
9
- bank?: string;
10
- }): MarginfiAssetAccounts;
7
+ export declare function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts;
11
8
  export declare function getMaxLtvAndLiqThreshold(umi: Umi, supply: {
12
9
  mint: PublicKey;
13
10
  bank?: Bank | null;
@@ -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;AAUzB,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,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,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
@@ -15,28 +15,22 @@ 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
- function findMarginfiAccounts({ mint, bank, }) {
18
+ function findMarginfiAccounts(bank) {
19
19
  for (const key in marginfiAccounts_1.MARGINFI_ACCOUNTS) {
20
20
  const account = marginfiAccounts_1.MARGINFI_ACCOUNTS[key];
21
- if (mint && account.mint.toString().toLowerCase() === mint.toLowerCase()) {
22
- return account;
23
- }
24
- if (bank && account.bank.toString().toLowerCase() === bank.toLowerCase()) {
21
+ if (account.bank.toString().toLowerCase() === bank.toString().toLowerCase()) {
25
22
  return account;
26
23
  }
27
24
  }
28
- throw new Error(`Marginfi accounts not found by the mint: ${mint}`);
25
+ throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
29
26
  }
30
27
  async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
31
28
  if (!supply.bank || supply.bank === null) {
32
- supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({
33
- mint: supply.mint.toString(),
34
- }).bank));
29
+ supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supply.mint.toString()].bank));
35
30
  }
36
- if ((!debt.bank || debt.bank === null) && !debt.mint.equals(web3_js_1.PublicKey.default)) {
37
- debt.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({
38
- mint: debt.mint.toString(),
39
- }).bank));
31
+ if ((!debt.bank || debt.bank === null) &&
32
+ !debt.mint.equals(web3_js_1.PublicKey.default)) {
33
+ debt.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[debt.mint.toString()].bank));
40
34
  }
41
35
  if (!supplyPrice) {
42
36
  const [price] = await (0, generalUtils_1.getTokenPrices)([
@@ -141,10 +135,10 @@ async function getTokenUsage(umi, bank, isAsset, shares, amountUsedAdjustment) {
141
135
  async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMint, debtMint, livePositionUpdates) {
142
136
  let marginfiAccount = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(umi, (0, umi_1.publicKey)(marginfiAccountPk));
143
137
  let supplyBank = supplyMint && supplyMint !== web3_js_1.PublicKey.default
144
- ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({ mint: supplyMint.toString() }).bank))
138
+ ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supplyMint.toString()].bank))
145
139
  : null;
146
140
  let debtBank = debtMint && debtMint !== web3_js_1.PublicKey.default
147
- ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({ mint: debtMint.toString() }).bank))
141
+ ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[debtMint.toString()].bank))
148
142
  : null;
149
143
  let supplyUsage = undefined;
150
144
  let debtUsage = undefined;
@@ -235,8 +235,8 @@ async function positionStateWithLatestPrices(state, supplyPrice, debtPrice) {
235
235
  };
236
236
  }
237
237
  function createFakePositionState(supply, debt, maxLtvBps, liqThresholdBps) {
238
- const supplyDecimals = constants_1.TOKEN_DECIMALS[supply.mint.toString()];
239
- const debtDecimals = constants_1.TOKEN_DECIMALS[debt.mint.toString()];
238
+ const supplyDecimals = constants_1.TOKEN_INFO[supply.mint.toString()].decimals;
239
+ const debtDecimals = constants_1.TOKEN_INFO[debt.mint.toString()].decimals;
240
240
  const supplyUsd = supply.amountUsed * supply.price;
241
241
  const debtUsd = debt.amountUsed * debt.price;
242
242
  return {
@@ -14,7 +14,7 @@ async function addBanks() {
14
14
  const accounts = MARGINFI_ACCOUNTS[key];
15
15
  await updateLookupTable(
16
16
  [
17
- accounts.mint,
17
+ key,
18
18
  accounts.bank,
19
19
  accounts.liquidityVault,
20
20
  accounts.vaultAuthority,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.70",
3
+ "version": "1.0.71",
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",
@@ -16,6 +16,7 @@ import { SolautoClient, SolautoClientArgs } from "./solautoClient";
16
16
  import { MarginfiAssetAccounts } from "../types/accounts";
17
17
  import {
18
18
  DEFAULT_MARGINFI_GROUP,
19
+ MARGINFI_ACCOUNTS,
19
20
  MARGINFI_ACCOUNTS_LOOKUP_TABLE,
20
21
  } from "../constants/marginfiAccounts";
21
22
  import {
@@ -108,12 +109,9 @@ export class SolautoMarginfiClient extends SolautoClient {
108
109
  ? toWeb3JsPublicKey(marginfiAccountData.group)
109
110
  : args.marginfiGroup ?? new PublicKey(DEFAULT_MARGINFI_GROUP);
110
111
 
111
- this.marginfiSupplyAccounts = findMarginfiAccounts({
112
- mint: this.supplyMint.toString(),
113
- })!;
114
- this.marginfiDebtAccounts = findMarginfiAccounts({
115
- mint: this.debtMint.toString(),
116
- })!;
112
+ this.marginfiSupplyAccounts =
113
+ MARGINFI_ACCOUNTS[this.supplyMint.toString()]!;
114
+ this.marginfiDebtAccounts = MARGINFI_ACCOUNTS[this.debtMint.toString()]!;
117
115
 
118
116
  if (!this.initialized) {
119
117
  await this.setIntermediaryMarginfiDetails();
@@ -171,7 +169,9 @@ export class SolautoMarginfiClient extends SolautoClient {
171
169
  return [
172
170
  ...super.lutAccountsToAdd(),
173
171
  this.marginfiAccountPk,
174
- ...(this.signer.publicKey.toString() === this.authority.toString() ? [this.intermediaryMarginfiAccountPk] : []),
172
+ ...(this.signer.publicKey.toString() === this.authority.toString()
173
+ ? [this.intermediaryMarginfiAccountPk]
174
+ : []),
175
175
  ];
176
176
  }
177
177
 
@@ -358,17 +358,13 @@ export class SolautoMarginfiClient extends SolautoClient {
358
358
  : this.positionDebtTa
359
359
  );
360
360
  vaultDebtTa = publicKey(this.marginfiDebtAccounts.liquidityVault);
361
- debtVaultAuthority = publicKey(
362
- this.marginfiDebtAccounts.vaultAuthority
363
- );
361
+ debtVaultAuthority = publicKey(this.marginfiDebtAccounts.vaultAuthority);
364
362
  }
365
363
 
366
364
  let supplyPriceOracle: UmiPublicKey | undefined = undefined;
367
365
  let debtPriceOracle: UmiPublicKey | undefined = undefined;
368
366
  if (args.__kind === "Withdraw" || args.__kind === "Borrow") {
369
- supplyPriceOracle = publicKey(
370
- this.marginfiSupplyAccounts.priceOracle
371
- );
367
+ supplyPriceOracle = publicKey(this.marginfiSupplyAccounts.priceOracle);
372
368
  debtPriceOracle = publicKey(this.marginfiDebtAccounts.priceOracle);
373
369
  }
374
370
 
@@ -512,8 +508,7 @@ export class SolautoMarginfiClient extends SolautoClient {
512
508
  },
513
509
  {
514
510
  pubkey: publicKey(
515
- findMarginfiAccounts({ bank: x.bankPk.toString() })
516
- .priceOracle
511
+ findMarginfiAccounts(toWeb3JsPublicKey(x.bankPk)).priceOracle
517
512
  ),
518
513
  isSigner: false,
519
514
  isWritable: false,
@@ -1,23 +1,33 @@
1
1
  import { NATIVE_MINT } from "@solana/spl-token";
2
- import { USDC_MINT } from "./tokenConstants";
2
+ import { B_SOL, JUP, USDC_MINT } from "./tokenConstants";
3
3
  import { MarginfiAssetAccounts } from "../types/accounts";
4
4
 
5
5
  export const DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
6
6
 
7
7
  export const MARGINFI_ACCOUNTS: { [key: string]: MarginfiAssetAccounts } = {
8
- SOL: {
9
- mint: NATIVE_MINT.toString(),
8
+ [NATIVE_MINT.toString()]: {
10
9
  bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
11
10
  liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
12
11
  vaultAuthority: "DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD",
13
12
  priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE"
14
13
  },
15
- USDC: {
16
- mint: USDC_MINT,
14
+ [USDC_MINT]: {
17
15
  bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
18
16
  liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
19
17
  vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
20
18
  priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX"
19
+ },
20
+ [B_SOL]: {
21
+ bank: "6hS9i46WyTq1KXcoa2Chas2Txh9TJAVr6n1t3tnrE23K",
22
+ liquidityVault: "2WMipeKDB2CENxbzdmnVrRbsxCA2LY6kCtBe6AAqDP9p",
23
+ vaultAuthority: "8RcZHucpVHkHWRRdMhJZsxBK9mqKSYnMKGqtF84U8YEo",
24
+ priceOracle: "5cN76Xm2Dtx9MnrQqBDeZZRsWruTTcw37UruznAdSvvE",
25
+ },
26
+ [JUP]: {
27
+ bank: "Guu5uBc8k1WK1U2ihGosNaCy57LSgCkpWAabtzQqrQf8",
28
+ liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
29
+ vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
30
+ priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
21
31
  }
22
32
  };
23
33
 
@@ -1,5 +1,5 @@
1
1
  import { NATIVE_MINT } from "@solana/spl-token";
2
- import { USDC_MINT } from "./tokenConstants";
2
+ import { B_SOL, JUP, USDC_MINT } from "./tokenConstants";
3
3
 
4
4
  // https://pyth.network/developers/price-feed-ids#solana-stable
5
5
  export const PYTH_PRICE_FEED_IDS = {
@@ -7,4 +7,6 @@ export const PYTH_PRICE_FEED_IDS = {
7
7
  "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
8
8
  [USDC_MINT]:
9
9
  "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
10
- };
10
+ [B_SOL]: "0x89875379e70f8fbadc17aef315adf3a8d5d160b811435537e03c97e8aac97d9c",
11
+ [JUP]: "0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996",
12
+ };
@@ -1,19 +1,37 @@
1
1
  import { NATIVE_MINT } from "@solana/spl-token";
2
2
 
3
- // When adding token ensure a price feed is provided in pythConstants.ts & the token is added to the necessary lists below
3
+ // When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
4
4
  export const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
5
+ export const B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
6
+ export const JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
5
7
 
6
8
 
7
9
  export const ALL_SUPPORTED_TOKENS = [
8
10
  NATIVE_MINT.toString(),
9
11
  USDC_MINT,
12
+ B_SOL,
13
+ JUP,
10
14
  ];
11
15
 
12
- export const TOKEN_DECIMALS = {
13
- [NATIVE_MINT.toString()]: 9,
14
- [USDC_MINT]: 6
15
- };
16
+ interface TokenInfo {
17
+ decimals: number;
18
+ isStableCoin?: boolean;
19
+ isLST?: boolean;
20
+ }
16
21
 
17
- export const STABLECOINS = [
18
- USDC_MINT
19
- ];
22
+ export const TOKEN_INFO: { [key: string]: TokenInfo } = {
23
+ [NATIVE_MINT.toString()]: {
24
+ decimals: 9,
25
+ },
26
+ [USDC_MINT]: {
27
+ decimals: 6,
28
+ isStableCoin: true
29
+ },
30
+ [B_SOL]: {
31
+ decimals: 9,
32
+ isLST: true
33
+ },
34
+ [JUP]: {
35
+ decimals: 6
36
+ }
37
+ };
@@ -1,5 +1,4 @@
1
1
  export interface MarginfiAssetAccounts {
2
- mint: string;
3
2
  bank: string;
4
3
  liquidityVault: string;
5
4
  vaultAuthority: string;
@@ -23,23 +23,16 @@ import { USD_DECIMALS } from "../constants/generalAccounts";
23
23
  import { LivePositionUpdates } from "./solauto/generalUtils";
24
24
  import { currentUnixSecondsSolana } from "./solanaUtils";
25
25
 
26
- export function findMarginfiAccounts({
27
- mint,
28
- bank,
29
- }: {
30
- mint?: string;
31
- bank?: string;
32
- }): MarginfiAssetAccounts {
26
+ export function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts {
33
27
  for (const key in MARGINFI_ACCOUNTS) {
34
28
  const account = MARGINFI_ACCOUNTS[key];
35
- if (mint && account.mint.toString().toLowerCase() === mint.toLowerCase()) {
36
- return account;
37
- }
38
- if (bank && account.bank.toString().toLowerCase() === bank.toLowerCase()) {
29
+ if (
30
+ account.bank.toString().toLowerCase() === bank.toString().toLowerCase()
31
+ ) {
39
32
  return account;
40
33
  }
41
34
  }
42
- throw new Error(`Marginfi accounts not found by the mint: ${mint}`);
35
+ throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
43
36
  }
44
37
 
45
38
  export async function getMaxLtvAndLiqThreshold(
@@ -57,21 +50,18 @@ export async function getMaxLtvAndLiqThreshold(
57
50
  if (!supply.bank || supply.bank === null) {
58
51
  supply.bank = await safeFetchBank(
59
52
  umi,
60
- publicKey(
61
- findMarginfiAccounts({
62
- mint: supply.mint.toString(),
63
- }).bank
64
- )
53
+ publicKey(MARGINFI_ACCOUNTS[supply.mint.toString()].bank)
65
54
  );
66
55
  }
67
56
 
68
- if ((!debt.bank || debt.bank === null) && !debt.mint.equals(PublicKey.default)) {
57
+ if (
58
+ (!debt.bank || debt.bank === null) &&
59
+ !debt.mint.equals(PublicKey.default)
60
+ ) {
69
61
  debt.bank = await safeFetchBank(
70
62
  umi,
71
63
  publicKey(
72
- findMarginfiAccounts({
73
- mint: debt.mint.toString(),
74
- }).bank
64
+ MARGINFI_ACCOUNTS[debt.mint.toString()].bank
75
65
  )
76
66
  );
77
67
  }
@@ -248,14 +238,14 @@ export async function getMarginfiAccountPositionState(
248
238
  supplyMint && supplyMint !== PublicKey.default
249
239
  ? await safeFetchBank(
250
240
  umi,
251
- publicKey(findMarginfiAccounts({ mint: supplyMint.toString() }).bank)
241
+ publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank)
252
242
  )
253
243
  : null;
254
244
  let debtBank: Bank | null =
255
245
  debtMint && debtMint !== PublicKey.default
256
246
  ? await safeFetchBank(
257
247
  umi,
258
- publicKey(findMarginfiAccounts({ mint: debtMint.toString() }).bank)
248
+ publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank)
259
249
  )
260
250
  : null;
261
251
 
@@ -23,7 +23,7 @@ import { getReferralState } from "../accountUtils";
23
23
  import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
24
24
  import {
25
25
  ALL_SUPPORTED_TOKENS,
26
- TOKEN_DECIMALS,
26
+ TOKEN_INFO,
27
27
  USD_DECIMALS,
28
28
  } from "../../constants";
29
29
  import {
@@ -368,8 +368,8 @@ export function createFakePositionState(
368
368
  maxLtvBps: number,
369
369
  liqThresholdBps: number
370
370
  ): PositionState {
371
- const supplyDecimals = TOKEN_DECIMALS[supply.mint.toString()];
372
- const debtDecimals = TOKEN_DECIMALS[debt.mint.toString()];
371
+ const supplyDecimals = TOKEN_INFO[supply.mint.toString()].decimals;
372
+ const debtDecimals = TOKEN_INFO[debt.mint.toString()].decimals;
373
373
 
374
374
  const supplyUsd = supply.amountUsed * supply.price;
375
375
  const debtUsd = debt.amountUsed * debt.price;