@haven-fi/solauto-sdk 1.0.788 → 1.0.791

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,27 +1,6 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  export declare const PYTH_PUSH_PROGRAM: PublicKey;
3
- export declare const PYTH_SPONSORED_SHARD_ID = 0;
4
- export declare const MARGINFI_SPONSORED_SHARD_ID = 3301;
5
- export declare const PYTH_PRICE_FEED_IDS: {
6
- [x: string]: string;
7
- bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1: string;
8
- mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So: string;
9
- J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn: string;
10
- LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp: string;
11
- "5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm": string;
12
- JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN: string;
13
- jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL: string;
14
- "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4": string;
15
- "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh": string;
16
- "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs": string;
17
- hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux: string;
18
- HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3: string;
19
- EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: string;
20
- Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB: string;
21
- DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263: string;
22
- EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm: string;
23
- pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn: string;
24
- };
3
+ export declare const PYTH_PRICE_FEED_IDS: Record<string, string>;
25
4
  export declare const PYTH_ORACLE_ACCOUNTS: {
26
5
  pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn: string;
27
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pythConstants.d.ts","sourceRoot":"","sources":["../../src/constants/pythConstants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,iBAAiB,WAE7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAGhD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;CAqC/B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;CAEhC,CAAC"}
1
+ {"version":3,"file":"pythConstants.d.ts","sourceRoot":"","sources":["../../src/constants/pythConstants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,iBAAiB,WAE7B,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA6BtD,CAAC;AAEF,eAAO,MAAM,oBAAoB;;CAEhC,CAAC"}
@@ -33,23 +33,16 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.PYTH_ORACLE_ACCOUNTS = exports.PYTH_PRICE_FEED_IDS = exports.MARGINFI_SPONSORED_SHARD_ID = exports.PYTH_SPONSORED_SHARD_ID = exports.PYTH_PUSH_PROGRAM = void 0;
37
- const spl_token_1 = require("@solana/spl-token");
36
+ exports.PYTH_ORACLE_ACCOUNTS = exports.PYTH_PRICE_FEED_IDS = exports.PYTH_PUSH_PROGRAM = void 0;
38
37
  const tokens = __importStar(require("./tokenConstants"));
39
38
  const web3_js_1 = require("@solana/web3.js");
40
39
  exports.PYTH_PUSH_PROGRAM = new web3_js_1.PublicKey("pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT");
41
- exports.PYTH_SPONSORED_SHARD_ID = 0;
42
- exports.MARGINFI_SPONSORED_SHARD_ID = 3301;
43
40
  // https://pyth.network/developers/price-feed-ids#solana-stable
44
41
  exports.PYTH_PRICE_FEED_IDS = {
45
- [spl_token_1.NATIVE_MINT.toString()]: "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
46
42
  [tokens.B_SOL]: "0x89875379e70f8fbadc17aef315adf3a8d5d160b811435537e03c97e8aac97d9c",
47
43
  [tokens.M_SOL]: "0xc2289a6a43d2ce91c6f55caec370f4acc38a2ed477f58813334c6d03749ff2a4",
48
- [tokens.JITO_SOL]: "0x67be9f519b95cf24338801051f9a808eff0a578ccb388db73b7f6fe1de019ffb",
49
- [tokens.LST]: "0x12fb674ee496045b1d9cf7d5e65379acb026133c2ad69f3ed996fb9fe68e3a37",
50
44
  [tokens.INF]: "0xf51570985c642c49c2d6e50156390fdba80bb6d5f7fa389d2f012ced4f7d208f",
51
45
  [tokens.JUP]: "0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996",
52
- [tokens.JTO]: "0xb43660a5f790c69354b0729a5ef9d50d68f1df92107540210b9cccba1f947cc2",
53
46
  [tokens.JLP]: "0xc811abc82b4bad1f9bd711a2773ccaa935b03ecef974236942cec5e0eb845a3a",
54
47
  [tokens.WBTC]: "0xc9d8b075a5c69303365ae23633d4e085199bf5c520a3b90fed1322a0342ffc33",
55
48
  [tokens.WETH]: "0x9d4294bbcd1174d6f2003ec365831e64cc31d9f6f15a2b85399db8d5000960f6",
@@ -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;CA+BxE,CAAC"}
1
+ {"version":3,"file":"switchboardConstants.d.ts","sourceRoot":"","sources":["../../src/constants/switchboardConstants.ts"],"names":[],"mappings":"AAGA,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+CxE,CAAC"}
@@ -34,13 +34,30 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.SWITCHBOARD_PRICE_FEED_IDS = void 0;
37
+ const spl_token_1 = require("@solana/spl-token");
37
38
  const tokens = __importStar(require("./tokenConstants"));
38
39
  // https://beta.ondemand.switchboard.xyz/solana/mainnet
39
40
  exports.SWITCHBOARD_PRICE_FEED_IDS = {
41
+ [spl_token_1.NATIVE_MINT.toString()]: {
42
+ feedId: "4Hmd6PdjVA9auCoScE12iaBogfwS4ZXQ6VZoBeqanwWW",
43
+ feedHash: "0x1f42dfb21efb24828b99fbe70e6d139cd665aafcbb1706bccd8f2a9b12562db6",
44
+ },
40
45
  [tokens.JUP_SOL]: {
41
46
  feedId: "HX5WM3qzogAfRCjBUWwnniLByMfFrjm1b5yo4KoWGR27",
42
47
  feedHash: "0xc02f22d47b20b43bafde474328ac027283dbd7bb443660f5ec414c93faec56dc",
43
48
  },
49
+ [tokens.JITO_SOL]: {
50
+ feedId: "5htZ4vPKPjAEg8EJv6JHcaCetMM4XehZo8znQvrp6Ur3",
51
+ feedHash: "0x44f5a7676baf4c6e5eb26fdde2695e7e3e0971071b76ddc622fa71528092ca25"
52
+ },
53
+ [tokens.LST]: {
54
+ feedId: "BWK8Wnybb7rPteNMqJs9uWoqdfYApNym6WgE59BwLe1v",
55
+ feedHash: "0x74e140c452fe29cced80898a51961ed1410c1fe0efbdc970fe5aac986427419e"
56
+ },
57
+ [tokens.JTO]: {
58
+ feedId: "A9RnpLxxtAS2TR3HtSMNJfsKpRPvkLbBkGZ6gKziSPLr",
59
+ feedHash: "0xa5bc3b659791facc5edfd8e74942c79d7e8d59f0f913dcdd9bcfb33a2fceb575"
60
+ },
44
61
  [tokens.H_SOL]: {
45
62
  feedId: "1snBjCaHejZqQsAqkELAKNaqUrDNNCr7zmNX6qaQCzg",
46
63
  feedHash: "0x59206aa3da593cd2312bde1930cf3368f6119a650229e147060be4fc2fcd1367",
@@ -1 +1 @@
1
- {"version":3,"file":"clientTransactionsManager.d.ts","sourceRoot":"","sources":["../../../../src/services/transactions/manager/clientTransactionsManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM5D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3C,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,aAAa,CAAC;YACjE,SAAS;YAmBT,mBAAmB;YA4BnB,WAAW;IA4CZ,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE;CAkClD"}
1
+ {"version":3,"file":"clientTransactionsManager.d.ts","sourceRoot":"","sources":["../../../../src/services/transactions/manager/clientTransactionsManager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAO5D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3C,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,aAAa,CAAC;YACjE,SAAS;YAmBT,mBAAmB;YAuCnB,WAAW;IA4CZ,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE;CAmClD"}
@@ -24,9 +24,13 @@ class ClientTransactionsManager extends transactionsManager_1.TransactionsManage
24
24
  : []),
25
25
  ];
26
26
  if (txs.find((x) => x.oracleInteractor) && switchboardMints.length) {
27
- this.txHandler.log("Requires oracle update(s)...");
28
- const oracleTxs = switchboardMints.map((x) => new types_1.TransactionItem(async () => await (0, utils_1.buildSwbSubmitResponseTx)(this.txHandler.connection, this.txHandler.signer, x), this.updateOracleTxName));
29
- txs.unshift(...oracleTxs);
27
+ this.txHandler.log("Checking if oracle update(s) needed...");
28
+ const staleOracles = (await (0, utils_1.getSwitchboardFeedData)(this.txHandler.connection, switchboardMints)).filter((x) => x.stale).length > 0;
29
+ if (staleOracles) {
30
+ this.txHandler.log("Requires oracle update(s)...");
31
+ const oracleTxs = switchboardMints.map((x) => new types_1.TransactionItem(async () => await (0, utils_1.buildSwbSubmitResponseTx)(this.txHandler.connection, this.txHandler.signer, x), this.updateOracleTxName));
32
+ txs.unshift(...oracleTxs);
33
+ }
30
34
  }
31
35
  }
32
36
  async addChoreTxs(txs, updateLutTx) {
@@ -1 +1 @@
1
- {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/utils/marginfi/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAKhF,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAGL,uBAAuB,EAExB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,OAAO,EACP,IAAI,EAIJ,eAAe,EAGhB,MAAM,6BAA6B,CAAC;AASrC,wBAAgB,4BAA4B,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CActE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,UAAU,OASxE;AAED,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,GAAG,EACR,eAAe,EAAE,uBAAuB,GACvC,OAAO,CAAC,SAAS,EAAE,CAAC,CA0BtB;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS;;;;;GAanE;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE;IAAE,EAAE,CAAC,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,IAAI,CAAA;CAAE,sBAetC;AAED,UAAU,wBAAyB,SAAQ,qBAAqB;IAC9D,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,SAAS,GACd,wBAAwB,CAyB1B;AAED,wBAAsB,0CAA0C,CAC9D,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,WAAW,EAAE,CAAC,CAWxB;AAED,wBAAgB,oCAAoC,CAClD,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,WAAW,EAAE,MAAM,GAClB,CAAC,MAAM,EAAE,MAAM,CAAC,CA6BlB;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,WASpE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAW3E"}
1
+ {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/utils/marginfi/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAKhF,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAEL,uBAAuB,EACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,OAAO,EACP,IAAI,EAIJ,eAAe,EAGhB,MAAM,6BAA6B,CAAC;AASrC,wBAAgB,4BAA4B,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CActE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,UAAU,OASxE;AAED,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,GAAG,EACR,eAAe,EAAE,uBAAuB,GACvC,OAAO,CAAC,SAAS,EAAE,CAAC,CA8BtB;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS;;;;;GAanE;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE;IAAE,EAAE,CAAC,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,IAAI,CAAA;CAAE,sBAiBtC;AAED,UAAU,wBAAyB,SAAQ,qBAAqB;IAC9D,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,SAAS,GACd,wBAAwB,CAyB1B;AAED,wBAAsB,0CAA0C,CAC9D,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,WAAW,EAAE,CAAC,CAWxB;AAED,wBAAgB,oCAAoC,CAClD,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,WAAW,EAAE,MAAM,GAClB,CAAC,MAAM,EAAE,MAAM,CAAC,CA6BlB;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,WASpE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAW3E"}
@@ -19,6 +19,7 @@ const numberUtils_1 = require("../numberUtils");
19
19
  const accountUtils_1 = require("../accountUtils");
20
20
  const pythUtils_1 = require("../pythUtils");
21
21
  const solanaUtils_1 = require("../solanaUtils");
22
+ const generalUtils_1 = require("../generalUtils");
22
23
  function createDynamicMarginfiProgram(env) {
23
24
  return {
24
25
  name: "marginfi",
@@ -45,7 +46,9 @@ async function getAllBankRelatedAccounts(umi, bankAccountsMap) {
45
46
  const banks = Object.values(bankAccountsMap).flatMap((group) => Object.values(group).map((accounts) => accounts.bank));
46
47
  const banksData = await (0, marginfi_1.safeFetchAllBank)(umi, banks.map((x) => (0, umi_1.publicKey)(x)));
47
48
  const oracles = banksData
48
- .map((bank) => bank.config.oracleKeys.map((x) => (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x)))
49
+ .map((bank) => bank.config.oracleKeys
50
+ .map((x) => (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x))
51
+ .filter((x) => (0, generalUtils_1.validPubkey)(x)))
49
52
  .flat()
50
53
  .map((x) => x.toString());
51
54
  const otherAccounts = Object.entries(bankAccountsMap).flatMap(([groupName, tokenMap]) => Object.values(tokenMap).flatMap((accounts) => [
@@ -75,7 +78,9 @@ async function getMarginfiPriceOracle(umi, bank) {
75
78
  bank.data = await (0, marginfi_1.fetchBank)(umi, (0, umi_web3js_adapters_1.fromWeb3JsPublicKey)(bank.pk));
76
79
  }
77
80
  const priceOracle = bank.data.config.oracleSetup === marginfi_1.OracleSetup.PythPushOracle
78
- ? await (0, pythUtils_1.getMostUpToDatePythOracle)(umi, bank.data.config.oracleKeys.map((x) => (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x)))
81
+ ? await (0, pythUtils_1.getMostUpToDatePythOracle)(umi, bank.data.config.oracleKeys
82
+ .map((x) => (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x))
83
+ .filter((x) => (0, generalUtils_1.validPubkey)(x)))
79
84
  : (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(bank.data.config.oracleKeys[0]);
80
85
  return priceOracle;
81
86
  }
@@ -1,5 +1,4 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { Umi } from "@metaplex-foundation/umi";
3
3
  export declare function getMostUpToDatePythOracle(umi: Umi, oracleKeys: PublicKey[]): Promise<PublicKey>;
4
- export declare function getPythPushOracleAddress(feedId: PublicKey, shardId: number, programId?: PublicKey): PublicKey;
5
4
  //# sourceMappingURL=pythUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pythUtils.d.ts","sourceRoot":"","sources":["../../src/utils/pythUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAK1D,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,SAAS,EAAE,sBAgBxB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,SAA6B,GACvC,SAAS,CAMX"}
1
+ {"version":3,"file":"pythUtils.d.ts","sourceRoot":"","sources":["../../src/utils/pythUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAK1D,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,SAAS,EAAE,sBAgBxB"}
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMostUpToDatePythOracle = getMostUpToDatePythOracle;
4
- exports.getPythPushOracleAddress = getPythPushOracleAddress;
5
- const web3_js_1 = require("@solana/web3.js");
6
4
  const umi_1 = require("@metaplex-foundation/umi");
7
- const constants_1 = require("../constants");
8
5
  const generalUtils_1 = require("./generalUtils");
9
6
  const pyth_1 = require("../externalSdks/pyth");
10
7
  async function getMostUpToDatePythOracle(umi, oracleKeys) {
@@ -12,7 +9,3 @@ async function getMostUpToDatePythOracle(umi, oracleKeys) {
12
9
  Number(a[1]?.priceMessage.publishTime ?? 0));
13
10
  return oracles[0][0];
14
11
  }
15
- function getPythPushOracleAddress(feedId, shardId, programId = constants_1.PYTH_PUSH_PROGRAM) {
16
- const shardBytes = (0, generalUtils_1.u16ToArrayBufferLE)(shardId);
17
- return web3_js_1.PublicKey.findProgramAddressSync([shardBytes, feedId.toBuffer()], programId)[0];
18
- }
@@ -48,7 +48,7 @@ export async function main() {
48
48
 
49
49
  await client.initializeExistingSolautoPosition({
50
50
  positionId: 1,
51
- authority: new PublicKey("7rujyCAvZYsd3kmfhEN6YmsRLpobtzsqrsZAKv5Mgkob"),
51
+ authority: new PublicKey("6K8FQ4W8SV2DGs73aQ5zybgfgSCGswybWbGXnw9JjoJR"),
52
52
  // lpUserAccount: new PublicKey(
53
53
  // "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
54
54
  // ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.788",
3
+ "version": "1.0.791",
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",
@@ -6,27 +6,16 @@ export const PYTH_PUSH_PROGRAM = new PublicKey(
6
6
  "pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT"
7
7
  );
8
8
 
9
- export const PYTH_SPONSORED_SHARD_ID = 0;
10
- export const MARGINFI_SPONSORED_SHARD_ID = 3301;
11
-
12
9
  // https://pyth.network/developers/price-feed-ids#solana-stable
13
- export const PYTH_PRICE_FEED_IDS = {
14
- [NATIVE_MINT.toString()]:
15
- "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
10
+ export const PYTH_PRICE_FEED_IDS: Record<string, string> = {
16
11
  [tokens.B_SOL]:
17
12
  "0x89875379e70f8fbadc17aef315adf3a8d5d160b811435537e03c97e8aac97d9c",
18
13
  [tokens.M_SOL]:
19
14
  "0xc2289a6a43d2ce91c6f55caec370f4acc38a2ed477f58813334c6d03749ff2a4",
20
- [tokens.JITO_SOL]:
21
- "0x67be9f519b95cf24338801051f9a808eff0a578ccb388db73b7f6fe1de019ffb",
22
- [tokens.LST]:
23
- "0x12fb674ee496045b1d9cf7d5e65379acb026133c2ad69f3ed996fb9fe68e3a37",
24
15
  [tokens.INF]:
25
16
  "0xf51570985c642c49c2d6e50156390fdba80bb6d5f7fa389d2f012ced4f7d208f",
26
17
  [tokens.JUP]:
27
18
  "0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996",
28
- [tokens.JTO]:
29
- "0xb43660a5f790c69354b0729a5ef9d50d68f1df92107540210b9cccba1f947cc2",
30
19
  [tokens.JLP]:
31
20
  "0xc811abc82b4bad1f9bd711a2773ccaa935b03ecef974236942cec5e0eb845a3a",
32
21
  [tokens.WBTC]:
@@ -1,3 +1,4 @@
1
+ import { NATIVE_MINT } from "@solana/spl-token";
1
2
  import * as tokens from "./tokenConstants";
2
3
 
3
4
  interface SwitchboardFeed {
@@ -7,11 +8,27 @@ interface SwitchboardFeed {
7
8
 
8
9
  // https://beta.ondemand.switchboard.xyz/solana/mainnet
9
10
  export const SWITCHBOARD_PRICE_FEED_IDS: { [key: string]: SwitchboardFeed } = {
11
+ [NATIVE_MINT.toString()]: {
12
+ feedId: "4Hmd6PdjVA9auCoScE12iaBogfwS4ZXQ6VZoBeqanwWW",
13
+ feedHash: "0x1f42dfb21efb24828b99fbe70e6d139cd665aafcbb1706bccd8f2a9b12562db6",
14
+ },
10
15
  [tokens.JUP_SOL]: {
11
16
  feedId: "HX5WM3qzogAfRCjBUWwnniLByMfFrjm1b5yo4KoWGR27",
12
17
  feedHash:
13
18
  "0xc02f22d47b20b43bafde474328ac027283dbd7bb443660f5ec414c93faec56dc",
14
19
  },
20
+ [tokens.JITO_SOL]: {
21
+ feedId: "5htZ4vPKPjAEg8EJv6JHcaCetMM4XehZo8znQvrp6Ur3",
22
+ feedHash: "0x44f5a7676baf4c6e5eb26fdde2695e7e3e0971071b76ddc622fa71528092ca25"
23
+ },
24
+ [tokens.LST]: {
25
+ feedId: "BWK8Wnybb7rPteNMqJs9uWoqdfYApNym6WgE59BwLe1v",
26
+ feedHash: "0x74e140c452fe29cced80898a51961ed1410c1fe0efbdc970fe5aac986427419e"
27
+ },
28
+ [tokens.JTO]: {
29
+ feedId: "A9RnpLxxtAS2TR3HtSMNJfsKpRPvkLbBkGZ6gKziSPLr",
30
+ feedHash: "0xa5bc3b659791facc5edfd8e74942c79d7e8d59f0f913dcdd9bcfb33a2fceb575"
31
+ },
15
32
  [tokens.H_SOL]: {
16
33
  feedId: "1snBjCaHejZqQsAqkELAKNaqUrDNNCr7zmNX6qaQCzg",
17
34
  feedHash:
@@ -6,6 +6,7 @@ import { SolautoClient } from "../../solauto";
6
6
  import { TransactionsManager } from "./transactionsManager";
7
7
  import {
8
8
  buildSwbSubmitResponseTx,
9
+ getSwitchboardFeedData,
9
10
  isSwitchboardMint,
10
11
  retryWithExponentialBackoff,
11
12
  } from "../../../utils";
@@ -44,20 +45,31 @@ export class ClientTransactionsManager extends TransactionsManager<SolautoClient
44
45
  ];
45
46
 
46
47
  if (txs.find((x) => x.oracleInteractor) && switchboardMints.length) {
47
- this.txHandler.log("Requires oracle update(s)...");
48
- const oracleTxs = switchboardMints.map(
49
- (x) =>
50
- new TransactionItem(
51
- async () =>
52
- await buildSwbSubmitResponseTx(
53
- this.txHandler.connection,
54
- this.txHandler.signer,
55
- x
56
- ),
57
- this.updateOracleTxName
48
+ this.txHandler.log("Checking if oracle update(s) needed...");
49
+ const staleOracles =
50
+ (
51
+ await getSwitchboardFeedData(
52
+ this.txHandler.connection,
53
+ switchboardMints
58
54
  )
59
- );
60
- txs.unshift(...oracleTxs);
55
+ ).filter((x) => x.stale).length > 0;
56
+
57
+ if (staleOracles) {
58
+ this.txHandler.log("Requires oracle update(s)...");
59
+ const oracleTxs = switchboardMints.map(
60
+ (x) =>
61
+ new TransactionItem(
62
+ async () =>
63
+ await buildSwbSubmitResponseTx(
64
+ this.txHandler.connection,
65
+ this.txHandler.signer,
66
+ x
67
+ ),
68
+ this.updateOracleTxName
69
+ )
70
+ );
71
+ txs.unshift(...oracleTxs);
72
+ }
61
73
  }
62
74
  }
63
75
 
@@ -111,7 +123,8 @@ export class ClientTransactionsManager extends TransactionsManager<SolautoClient
111
123
 
112
124
  const updateLut = await client.updateLookupTable();
113
125
 
114
- const updateLutInSepTx = updateLut?.new || (updateLut?.accountsToAdd ?? []).length > 4;
126
+ const updateLutInSepTx =
127
+ updateLut?.new || (updateLut?.accountsToAdd ?? []).length > 4;
115
128
  if (updateLut && updateLutInSepTx) {
116
129
  await this.updateLut(updateLut.tx, updateLut.new);
117
130
  }
@@ -7,9 +7,7 @@ import {
7
7
  import { ProgramEnv, MarginfiAssetAccounts } from "../../types";
8
8
  import {
9
9
  getMarginfiAccounts,
10
- MARGINFI_SPONSORED_SHARD_ID,
11
10
  MarginfiBankAccountsMap,
12
- PYTH_SPONSORED_SHARD_ID,
13
11
  } from "../../constants";
14
12
  import {
15
13
  Balance,
@@ -25,9 +23,9 @@ import { bytesToI80F48, fromBaseUnit, toBps } from "../numberUtils";
25
23
  import { getTokenAccountData } from "../accountUtils";
26
24
  import {
27
25
  getMostUpToDatePythOracle,
28
- getPythPushOracleAddress,
29
26
  } from "../pythUtils";
30
27
  import { getAccountMeta } from "../solanaUtils";
28
+ import { validPubkey } from "../generalUtils";
31
29
 
32
30
  export function createDynamicMarginfiProgram(env?: ProgramEnv): Program {
33
31
  return {
@@ -69,7 +67,11 @@ export async function getAllBankRelatedAccounts(
69
67
  );
70
68
 
71
69
  const oracles = banksData
72
- .map((bank) => bank.config.oracleKeys.map((x) => toWeb3JsPublicKey(x)))
70
+ .map((bank) =>
71
+ bank.config.oracleKeys
72
+ .map((x) => toWeb3JsPublicKey(x))
73
+ .filter((x) => validPubkey(x))
74
+ )
73
75
  .flat()
74
76
  .map((x) => x.toString());
75
77
 
@@ -114,7 +116,9 @@ export async function getMarginfiPriceOracle(
114
116
  bank.data.config.oracleSetup === OracleSetup.PythPushOracle
115
117
  ? await getMostUpToDatePythOracle(
116
118
  umi,
117
- bank.data.config.oracleKeys.map((x) => toWeb3JsPublicKey(x))
119
+ bank.data.config.oracleKeys
120
+ .map((x) => toWeb3JsPublicKey(x))
121
+ .filter((x) => validPubkey(x))
118
122
  )
119
123
  : toWeb3JsPublicKey(bank.data.config.oracleKeys[0]);
120
124
 
@@ -23,15 +23,3 @@ export async function getMostUpToDatePythOracle(
23
23
 
24
24
  return oracles[0][0];
25
25
  }
26
-
27
- export function getPythPushOracleAddress(
28
- feedId: PublicKey,
29
- shardId: number,
30
- programId: PublicKey = PYTH_PUSH_PROGRAM
31
- ): PublicKey {
32
- const shardBytes = u16ToArrayBufferLE(shardId);
33
- return PublicKey.findProgramAddressSync(
34
- [shardBytes, feedId.toBuffer()],
35
- programId
36
- )[0];
37
- }