@haven-fi/solauto-sdk 1.0.581 → 1.0.582

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":"switchboardConstants.d.ts","sourceRoot":"","sources":["../../src/constants/switchboardConstants.ts"],"names":[],"mappings":"AAEA,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAGD,eAAO,MAAM,0BAA0B,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;CA0BxE,CAAC"}
1
+ {"version":3,"file":"switchboardConstants.d.ts","sourceRoot":"","sources":["../../src/constants/switchboardConstants.ts"],"names":[],"mappings":"AAEA,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAGD,eAAO,MAAM,0BAA0B,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;CA+BxE,CAAC"}
@@ -33,22 +33,22 @@ exports.SWITCHBOARD_PRICE_FEED_IDS = {
33
33
  },
34
34
  [tokens.H_SOL]: {
35
35
  feedId: "1snBjCaHejZqQsAqkELAKNaqUrDNNCr7zmNX6qaQCzg",
36
- feedHash: "0x59206aa3da593cd2312bde1930cf3368f6119a650229e147060be4fc2fcd1367"
36
+ feedHash: "0x59206aa3da593cd2312bde1930cf3368f6119a650229e147060be4fc2fcd1367",
37
37
  },
38
38
  [tokens.POPCAT]: {
39
39
  feedId: "FTcFqwCjAgv2VMaowQ9XSBcesVzFzZkaju25nKio6bki",
40
- feedHash: "0xeb4f9a43024f8f33786b7291404510af8e94a66e1acb44953a3137878ee7033f"
40
+ feedHash: "0xeb4f9a43024f8f33786b7291404510af8e94a66e1acb44953a3137878ee7033f",
41
41
  },
42
42
  [tokens.RETARDIO]: {
43
43
  feedId: "EvPXnpMoyrj4B6P55LDP2VpSLkTBWom2SqL4486ToNhM",
44
- feedHash: "0x982d968a0608046986aec84d95ae884c4dc2140f0b3e14ed7b8161ada573d18b"
44
+ feedHash: "0x982d968a0608046986aec84d95ae884c4dc2140f0b3e14ed7b8161ada573d18b",
45
45
  },
46
46
  [tokens.BILLY]: {
47
47
  feedId: "uBe4er4VSMgYvBNwSbFctSShRXNPkCfaPh7zHMBFeBi",
48
- feedHash: "0xbbd0d393111ff1ad7cc1a2f15ce24b61d4d6b3e99e440aa77572bd7f1da9afbe"
48
+ feedHash: "0xbbd0d393111ff1ad7cc1a2f15ce24b61d4d6b3e99e440aa77572bd7f1da9afbe",
49
49
  },
50
50
  [tokens.HMTR]: {
51
51
  feedId: "F2hKL67W4ZDe9k7ZrJKnp2LhWrgqg2JQTkJf2dgBggRD",
52
- feedHash: "0x61999c4f8a03208b5b5b50663323b1ef8d0acbb3642ec79053b33b5768605fb5"
52
+ feedHash: "0x61999c4f8a03208b5b5b50663323b1ef8d0acbb3642ec79053b33b5768605fb5",
53
53
  },
54
54
  };
@@ -43,7 +43,7 @@ async function fetchTokenPrices(mints) {
43
43
  return mints.map((mint) => solautoConstants_1.PRICES[mint.toString()].price);
44
44
  }
45
45
  const pythMints = mints.filter((x) => x.toString() in pythConstants_1.PYTH_PRICE_FEED_IDS);
46
- const switchboardMints = mints.filter((x) => x.toString() in switchboardConstants_1.SWITCHBOARD_PRICE_FEED_IDS);
46
+ const switchboardMints = mints.filter((x) => x.toString() in Object.keys(switchboardConstants_1.SWITCHBOARD_PRICE_FEED_IDS));
47
47
  const otherMints = mints.filter((x) => !pythMints.includes(x) && !switchboardMints.includes(x));
48
48
  const [pythData, switchboardData, jupData] = await Promise.all([
49
49
  (0, generalUtils_1.zip)(pythMints, await getPythPrices(pythMints)),
@@ -1,7 +1,7 @@
1
1
  import { Connection, PublicKey } from "@solana/web3.js";
2
- import * as OnDemand from "@switchboard-xyz/on-demand";
3
2
  import { TransactionItemInputs } from "../types";
4
3
  import { Signer } from "@metaplex-foundation/umi";
4
+ import * as OnDemand from "@switchboard-xyz/on-demand";
5
5
  export declare function getPullFeed(conn: Connection, mint: PublicKey, wallet?: PublicKey): OnDemand.PullFeed;
6
6
  export declare function buildSwbSubmitResponseTx(conn: Connection, signer: Signer, mint: PublicKey): Promise<TransactionItemInputs | undefined>;
7
7
  export declare function getSwitchboardFeedData(conn: Connection, mints: PublicKey[]): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"switchboardUtils.d.ts","sourceRoot":"","sources":["../../src/utils/switchboardUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,SAAS,EAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,EAAsB,MAAM,0BAA0B,CAAC;AAOtE,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,SAAS,EACf,MAAM,CAAC,EAAE,SAAS,qBAuBnB;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsB5C;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,CAAC,CAuB/D"}
1
+ {"version":3,"file":"switchboardUtils.d.ts","sourceRoot":"","sources":["../../src/utils/switchboardUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,SAAS,EAGV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,EAAsB,MAAM,0BAA0B,CAAC;AAEtE,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAC;AAIvD,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,SAAS,EACf,MAAM,CAAC,EAAE,SAAS,qBAuBnB;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsB5C;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,CAAC,CAuB/D"}
@@ -32,11 +32,12 @@ exports.getSwitchboardFeedData = getSwitchboardFeedData;
32
32
  const anchor_1 = require("@coral-xyz/anchor");
33
33
  const switchboard_json_1 = __importDefault(require("../idls/switchboard.json"));
34
34
  const web3_js_1 = require("@solana/web3.js");
35
- const OnDemand = __importStar(require("@switchboard-xyz/on-demand"));
36
35
  const switchboardConstants_1 = require("../constants/switchboardConstants");
37
36
  const umi_1 = require("@metaplex-foundation/umi");
38
37
  const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
38
+ const OnDemand = __importStar(require("@switchboard-xyz/on-demand"));
39
39
  const generalUtils_1 = require("./generalUtils");
40
+ const solanaUtils_1 = require("./solanaUtils");
40
41
  function getPullFeed(conn, mint, wallet) {
41
42
  const dummyWallet = {
42
43
  publicKey: wallet ?? new web3_js_1.PublicKey("11111111111111111111111111111111"),
@@ -50,15 +51,15 @@ function getPullFeed(conn, mint, wallet) {
50
51
  }
51
52
  async function buildSwbSubmitResponseTx(conn, signer, mint) {
52
53
  const feed = getPullFeed(conn, mint, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(signer.publicKey));
53
- const [pullIxs, responses] = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await feed.fetchUpdateIx({}), 2, 200);
54
+ const [pullIx, responses] = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await feed.fetchUpdateIx({
55
+ chain: "solana",
56
+ network: "mainnet-beta",
57
+ }), 2, 200);
58
+ if (!pullIx) {
59
+ throw new Error("Unable to fetch SWB crank IX");
60
+ }
54
61
  return {
55
- tx: (0, umi_1.transactionBuilder)(pullIxs.map((x) => {
56
- return {
57
- bytesCreatedOnChain: 0,
58
- instruction: (0, umi_web3js_adapters_1.fromWeb3JsInstruction)(x),
59
- signers: [signer],
60
- };
61
- })),
62
+ tx: (0, umi_1.transactionBuilder)([(0, solanaUtils_1.getWrappedInstruction)(signer, pullIx)]),
62
63
  lookupTableAddresses: responses
63
64
  .filter((x) => Boolean(x.oracle.lut?.key))
64
65
  .map((x) => x.oracle.lut.key.toString()),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.581",
3
+ "version": "1.0.582",
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",
@@ -24,7 +24,7 @@
24
24
  "@solana/spl-token": "^0.4.0",
25
25
  "@solana/web3.js": "=1.95.8",
26
26
  "@switchboard-xyz/common": "=3.0.12",
27
- "@switchboard-xyz/on-demand": "=2.4.0",
27
+ "@switchboard-xyz/on-demand": "=1.2.51",
28
28
  "axios": "^1.7.8",
29
29
  "bs58": "^5.0.0",
30
30
  "cross-fetch": "^4.0.0",
@@ -14,22 +14,27 @@ export const SWITCHBOARD_PRICE_FEED_IDS: { [key: string]: SwitchboardFeed } = {
14
14
  },
15
15
  [tokens.H_SOL]: {
16
16
  feedId: "1snBjCaHejZqQsAqkELAKNaqUrDNNCr7zmNX6qaQCzg",
17
- feedHash: "0x59206aa3da593cd2312bde1930cf3368f6119a650229e147060be4fc2fcd1367"
17
+ feedHash:
18
+ "0x59206aa3da593cd2312bde1930cf3368f6119a650229e147060be4fc2fcd1367",
18
19
  },
19
20
  [tokens.POPCAT]: {
20
21
  feedId: "FTcFqwCjAgv2VMaowQ9XSBcesVzFzZkaju25nKio6bki",
21
- feedHash: "0xeb4f9a43024f8f33786b7291404510af8e94a66e1acb44953a3137878ee7033f"
22
+ feedHash:
23
+ "0xeb4f9a43024f8f33786b7291404510af8e94a66e1acb44953a3137878ee7033f",
22
24
  },
23
25
  [tokens.RETARDIO]: {
24
26
  feedId: "EvPXnpMoyrj4B6P55LDP2VpSLkTBWom2SqL4486ToNhM",
25
- feedHash: "0x982d968a0608046986aec84d95ae884c4dc2140f0b3e14ed7b8161ada573d18b"
27
+ feedHash:
28
+ "0x982d968a0608046986aec84d95ae884c4dc2140f0b3e14ed7b8161ada573d18b",
26
29
  },
27
30
  [tokens.BILLY]: {
28
31
  feedId: "uBe4er4VSMgYvBNwSbFctSShRXNPkCfaPh7zHMBFeBi",
29
- feedHash: "0xbbd0d393111ff1ad7cc1a2f15ce24b61d4d6b3e99e440aa77572bd7f1da9afbe"
32
+ feedHash:
33
+ "0xbbd0d393111ff1ad7cc1a2f15ce24b61d4d6b3e99e440aa77572bd7f1da9afbe",
30
34
  },
31
35
  [tokens.HMTR]: {
32
36
  feedId: "F2hKL67W4ZDe9k7ZrJKnp2LhWrgqg2JQTkJf2dgBggRD",
33
- feedHash: "0x61999c4f8a03208b5b5b50663323b1ef8d0acbb3642ec79053b33b5768605fb5"
37
+ feedHash:
38
+ "0x61999c4f8a03208b5b5b50663323b1ef8d0acbb3642ec79053b33b5768605fb5",
34
39
  },
35
40
  };
@@ -6,15 +6,13 @@ import {
6
6
  Transaction,
7
7
  VersionedTransaction,
8
8
  } from "@solana/web3.js";
9
- import * as OnDemand from "@switchboard-xyz/on-demand";
10
9
  import { SWITCHBOARD_PRICE_FEED_IDS } from "../constants/switchboardConstants";
11
10
  import { TransactionItemInputs } from "../types";
12
11
  import { Signer, transactionBuilder } from "@metaplex-foundation/umi";
13
- import {
14
- fromWeb3JsInstruction,
15
- toWeb3JsPublicKey,
16
- } from "@metaplex-foundation/umi-web3js-adapters";
17
- import { retryWithExponentialBackoff, zip } from "./generalUtils";
12
+ import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
13
+ import * as OnDemand from "@switchboard-xyz/on-demand";
14
+ import { retryWithExponentialBackoff } from "./generalUtils";
15
+ import { getWrappedInstruction } from "./solanaUtils";
18
16
 
19
17
  export function getPullFeed(
20
18
  conn: Connection,
@@ -50,22 +48,22 @@ export async function buildSwbSubmitResponseTx(
50
48
  mint: PublicKey
51
49
  ): Promise<TransactionItemInputs | undefined> {
52
50
  const feed = getPullFeed(conn, mint, toWeb3JsPublicKey(signer.publicKey));
53
- const [pullIxs, responses] = await retryWithExponentialBackoff(
54
- async () => await feed.fetchUpdateIx({}),
51
+ const [pullIx, responses] = await retryWithExponentialBackoff(
52
+ async () =>
53
+ await feed.fetchUpdateIx({
54
+ chain: "solana",
55
+ network: "mainnet-beta",
56
+ }),
55
57
  2,
56
58
  200
57
59
  );
58
60
 
61
+ if (!pullIx) {
62
+ throw new Error("Unable to fetch SWB crank IX");
63
+ }
64
+
59
65
  return {
60
- tx: transactionBuilder(
61
- pullIxs!.map((x) => {
62
- return {
63
- bytesCreatedOnChain: 0,
64
- instruction: fromWeb3JsInstruction(x),
65
- signers: [signer],
66
- };
67
- })
68
- ),
66
+ tx: transactionBuilder([getWrappedInstruction(signer, pullIx!)]),
69
67
  lookupTableAddresses: responses
70
68
  .filter((x) => Boolean(x.oracle.lut?.key))
71
69
  .map((x) => x.oracle.lut!.key.toString()),
@@ -72,7 +72,7 @@ describe("Solauto Marginfi tests", async () => {
72
72
  await client.initialize({
73
73
  signer,
74
74
  positionId,
75
- authority: new PublicKey("5bFfSCsGUgEzYH8kwwRtFnWkKZ1by8uD8RHvKQPnQReB"),
75
+ authority: new PublicKey("EBhRj7jbF2EVE21i19JSuCX1BAbnZFYhoKW64HnaZ3kf"),
76
76
  // new: true,
77
77
  // marginfiAccount: new PublicKey(
78
78
  // ""