@haven-fi/solauto-sdk 1.0.813 → 1.0.814

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.
@@ -20,5 +20,6 @@ export declare const CHORES_TX_NAME = "account chores";
20
20
  export declare const JITO_TIP_ACCOUNTS: string[];
21
21
  export declare const SOLAUTO_LUT = "8b7KefQDroVLGao71J5H3hFwABeyMCgCrLpXWssNFhk9";
22
22
  export declare const STANDARD_LUT_ACCOUNTS: string[];
23
+ export declare const UPDATE_ORACLE_TX_NAME = "update oracle";
23
24
  export {};
24
25
  //# sourceMappingURL=solautoConstants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAQzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,UAAU,UAAU;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AACD,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAO,CAAC;AAExD,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,eAAO,MAAM,iBAAiB,UAS7B,CAAC;AAEF,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,qBAAqB,UAYR,CAAC"}
1
+ {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAQzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,UAAU,UAAU;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AACD,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAO,CAAC;AAExD,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,eAAO,MAAM,iBAAiB,UAS7B,CAAC;AAEF,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,qBAAqB,UAYR,CAAC;AAE3B,eAAO,MAAM,qBAAqB,kBAAkB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.JITO_TIP_ACCOUNTS = exports.CHORES_TX_NAME = exports.PRICES = exports.REFERRER_PERCENTAGE = exports.OFFSET_FROM_MAX_LTV = exports.MIN_USD_SUPPORTED_POSITION = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.SOLAUTO_TEST_PROGRAM = exports.SOLAUTO_PROD_PROGRAM = void 0;
3
+ exports.UPDATE_ORACLE_TX_NAME = exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.JITO_TIP_ACCOUNTS = exports.CHORES_TX_NAME = exports.PRICES = exports.REFERRER_PERCENTAGE = exports.OFFSET_FROM_MAX_LTV = exports.MIN_USD_SUPPORTED_POSITION = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.SOLAUTO_TEST_PROGRAM = exports.SOLAUTO_PROD_PROGRAM = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  const generalConstants_1 = require("./generalConstants");
@@ -39,3 +39,4 @@ exports.STANDARD_LUT_ACCOUNTS = [
39
39
  web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
40
40
  jupiter_1.JUPITER_PROGRAM_ID,
41
41
  ].map((x) => x.toString());
42
+ exports.UPDATE_ORACLE_TX_NAME = "update oracle";
@@ -3,7 +3,6 @@ import { TransactionsManager } from "./transactionsManager";
3
3
  import { TransactionItem } from "../types";
4
4
  export declare class ClientTransactionsManager extends TransactionsManager<SolautoClient> {
5
5
  private updateLut;
6
- private addSwbOraclePullTxs;
7
6
  private addChoreTxs;
8
7
  send(transactions: TransactionItem[]): Promise<import("./transactionsManager").TransactionManagerStatuses>;
9
8
  }
@@ -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;AAO5D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3C,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,aAAa,CAAC;YACjE,SAAS;YAmBT,mBAAmB;YAwCnB,WAAW;IA4CZ,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE;CAmClD"}
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;AAQ5D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3C,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,aAAa,CAAC;YACjE,SAAS;YAmBT,WAAW;IA4CZ,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE;CAmClD"}
@@ -14,26 +14,6 @@ class ClientTransactionsManager extends transactionsManager_1.TransactionsManage
14
14
  await (0, utils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => await this.sendTransaction(tx.setAddressLookupTables(lutInputs), updateLutTxName, attemptNum, this.getUpdatedPriorityFeeSetting(prevError, attemptNum), "skip-simulation"), this.signableRetries, 150, this.errorsToThrow);
15
15
  await this.txHandler.refetchReferralState();
16
16
  }
17
- async addSwbOraclePullTxs(txs) {
18
- const switchboardMints = [
19
- ...((0, utils_1.isSwitchboardMint)(this.txHandler.pos.supplyMint)
20
- ? [this.txHandler.pos.supplyMint]
21
- : []),
22
- ...((0, utils_1.isSwitchboardMint)(this.txHandler.pos.debtMint)
23
- ? [this.txHandler.pos.debtMint]
24
- : []),
25
- ];
26
- if (txs.find((x) => x.oracleInteractor) && switchboardMints.length) {
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
- this.txHandler.log("Set crank IXs in TX");
33
- txs.unshift(...oracleTxs);
34
- }
35
- }
36
- }
37
17
  async addChoreTxs(txs, updateLutTx) {
38
18
  let [choresBefore, choresAfter] = await (0, transactionUtils_1.getTransactionChores)(this.txHandler, (0, umi_1.transactionBuilder)().add(txs
39
19
  .filter((x) => x.tx && x.tx.getInstructions().length > 0)
@@ -63,7 +43,7 @@ class ClientTransactionsManager extends transactionsManager_1.TransactionsManage
63
43
  await this.updateLut(updateLut.tx, updateLut.new);
64
44
  }
65
45
  this.lookupTables.defaultLuts = client.defaultLookupTables();
66
- await this.addSwbOraclePullTxs(items);
46
+ // await addSwbOraclePullTxs(this.txHandler, items);
67
47
  for (const item of items) {
68
48
  await item.initialize();
69
49
  }
@@ -50,7 +50,6 @@ export declare class TransactionsManager<T extends TxHandler> {
50
50
  protected totalRetries: number;
51
51
  protected retryDelay: number;
52
52
  protected abortController?: AbortController;
53
- updateOracleTxName: string;
54
53
  constructor(args: TransactionsManagerArgs<T>);
55
54
  private assembleTransactionSets;
56
55
  private updateStatus;
@@ -1 +1 @@
1
- {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../../../src/services/transactions/manager/transactionsManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAElB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,aAAa,EAId,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAkB,MAAM,UAAU,CAAC;AAEzE,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAED,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,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CAAC,eAAe,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;IAE5C,kBAAkB,SAAmB;gBAEzB,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC;YAoB9B,uBAAuB;IA2CrC,OAAO,CAAC,YAAY;YA+BN,aAAa;IAoB3B,SAAS,CAAC,4BAA4B,CACpC,SAAS,EAAE,KAAK,GAAG,SAAS,EAC5B,UAAU,EAAE,MAAM;IAcpB,OAAO,CAAC,mBAAmB;IAkBd,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;IAoCtC,OAAO,CAAC,mBAAmB;YA0Bb,eAAe;YAkDf,6BAA6B;YAyC7B,cAAc;YA0Ed,qBAAqB;cAuDnB,eAAe,CAC7B,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,kBAAkB,CAAC,EAAE,kBAAkB,EACvC,SAAS,CAAC,EAAE,kBAAkB;IAqChC,OAAO,CAAC,gBAAgB;CAqCzB"}
1
+ {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../../../src/services/transactions/manager/transactionsManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAElB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,aAAa,EAId,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAkB,MAAM,UAAU,CAAC;AAGzE,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAED,oBAAY,iBAAiB;I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Aa,CAAC,EAAE,aAAa,CAAC;IACxC,SAAS,CAAC,QAAQ,EAAE,0BAA0B,CAAM;IACpD,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IACrC,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;gBAEhC,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC;YAoB9B,uBAAuB;IA6CrC,OAAO,CAAC,YAAY;YAiCN,aAAa;IAwB3B,SAAS,CAAC,4BAA4B,CACpC,SAAS,EAAE,KAAK,GAAG,SAAS,EAC5B,UAAU,EAAE,MAAM;IAcpB,OAAO,CAAC,mBAAmB;IAkBd,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;IAoCtC,OAAO,CAAC,mBAAmB;YA0Bb,eAAe;YAkDf,6BAA6B;YAyC7B,cAAc;YA0Ed,qBAAqB;cAuDnB,eAAe,CAC7B,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,kBAAkB,CAAC,EAAE,kBAAkB,EACvC,SAAS,CAAC,EAAE,kBAAkB;IAqChC,OAAO,CAAC,gBAAgB;CAuCzB"}
@@ -10,6 +10,7 @@ const types_1 = require("../../../types");
10
10
  const utils_1 = require("../../../utils");
11
11
  const transactionUtils_1 = require("../transactionUtils");
12
12
  const types_2 = require("../types");
13
+ const constants_1 = require("../../../constants");
13
14
  class TransactionTooLargeError extends Error {
14
15
  constructor(message) {
15
16
  super(message);
@@ -29,7 +30,6 @@ var TransactionStatus;
29
30
  class TransactionsManager {
30
31
  constructor(args) {
31
32
  this.statuses = [];
32
- this.updateOracleTxName = "update oracle";
33
33
  this.txHandler = args.txHandler;
34
34
  this.statusCallback = args.statusCallback;
35
35
  this.txRunType = args.txRunType;
@@ -102,7 +102,9 @@ class TransactionsManager {
102
102
  this.statuses.push(args);
103
103
  }
104
104
  }
105
- (0, utils_1.consoleLog)(`${args.name} ${args.attemptNum} is ${args.status.toString().toLowerCase()}`);
105
+ (0, utils_1.consoleLog)(`${args.name} ${args.attemptNum} is ${args.status
106
+ .toString()
107
+ .toLowerCase()}`);
106
108
  this.statusCallback?.([...this.statuses]);
107
109
  }
108
110
  async debugAccounts(itemSet, tx) {
@@ -171,7 +173,7 @@ class TransactionsManager {
171
173
  }
172
174
  const newItemSetNames = itemSets.flatMap((x) => x.items.map((y) => y.name ?? ""));
173
175
  if (newItemSetNames.length === 1 &&
174
- newItemSetNames[0] === this.updateOracleTxName) {
176
+ newItemSetNames[0] === constants_1.UPDATE_ORACLE_TX_NAME) {
175
177
  (0, utils_1.consoleLog)("Skipping unnecessary oracle update");
176
178
  this.updateStatusForSets(itemSets.map((x) => x.name()), {
177
179
  status: TransactionStatus.Skipped,
@@ -2,6 +2,7 @@ import { Connection, PublicKey } from "@solana/web3.js";
2
2
  import { Signer } from "@metaplex-foundation/umi";
3
3
  import * as OnDemand from "@switchboard-xyz/on-demand";
4
4
  import { TransactionItemInputs } from "../types";
5
+ import { SolautoClient, TransactionItem } from "../services";
5
6
  export declare function getPullFeed(conn: Connection, mint: PublicKey, wallet?: PublicKey): Promise<{
6
7
  gateway: OnDemand.Gateway;
7
8
  feed: OnDemand.PullFeed;
@@ -13,4 +14,5 @@ export declare function getSwitchboardFeedData(conn: Connection, mints: PublicKe
13
14
  stale: boolean;
14
15
  }[]>;
15
16
  export declare function isSwitchboardMint(mint: PublicKey | string): boolean;
17
+ export declare function addSwbOraclePullTxs(client: SolautoClient, txs: TransactionItem[]): Promise<void>;
16
18
  //# sourceMappingURL=switchboardUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"switchboardUtils.d.ts","sourceRoot":"","sources":["../../src/utils/switchboardUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAC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EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAiD5C;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;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,WAEzD;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,eAAe,EAAE,iBAkCvB"}
@@ -37,6 +37,7 @@ exports.getPullFeed = getPullFeed;
37
37
  exports.buildSwbSubmitResponseTx = buildSwbSubmitResponseTx;
38
38
  exports.getSwitchboardFeedData = getSwitchboardFeedData;
39
39
  exports.isSwitchboardMint = isSwitchboardMint;
40
+ exports.addSwbOraclePullTxs = addSwbOraclePullTxs;
40
41
  const web3_js_1 = require("@solana/web3.js");
41
42
  const umi_1 = require("@metaplex-foundation/umi");
42
43
  const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
@@ -46,6 +47,7 @@ const constants_1 = require("../constants");
46
47
  const generalUtils_1 = require("./generalUtils");
47
48
  const solanaUtils_1 = require("./solanaUtils");
48
49
  const common_1 = require("@switchboard-xyz/common");
50
+ const services_1 = require("../services");
49
51
  async function getPullFeed(conn, mint, wallet) {
50
52
  const dummyWallet = {
51
53
  publicKey: wallet ?? new web3_js_1.PublicKey("11111111111111111111111111111111"),
@@ -68,7 +70,6 @@ async function getPullFeed(conn, mint, wallet) {
68
70
  }
69
71
  async function buildSwbSubmitResponseTx(conn, signer, mint) {
70
72
  const { feed, gateway } = await getPullFeed(conn, mint, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(signer.publicKey));
71
- // Try to replicate locally in the lambda docker container
72
73
  (0, generalUtils_1.consoleLog)("Fetching crank IX...");
73
74
  const [pullIxs, responses] = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
74
75
  const res = await feed.fetchUpdateIx({
@@ -120,3 +121,21 @@ async function getSwitchboardFeedData(conn, mints) {
120
121
  function isSwitchboardMint(mint) {
121
122
  return Object.keys(constants_1.SWITCHBOARD_PRICE_FEED_IDS).includes(mint.toString());
122
123
  }
124
+ async function addSwbOraclePullTxs(client, txs) {
125
+ const switchboardMints = [
126
+ ...(isSwitchboardMint(client.pos.supplyMint)
127
+ ? [client.pos.supplyMint]
128
+ : []),
129
+ ...(isSwitchboardMint(client.pos.debtMint) ? [client.pos.debtMint] : []),
130
+ ];
131
+ if (txs.find((x) => x.oracleInteractor) && switchboardMints.length) {
132
+ (0, generalUtils_1.consoleLog)("Checking if oracle update(s) needed...");
133
+ const staleOracles = (await getSwitchboardFeedData(client.connection, switchboardMints)).filter((x) => x.stale).length > 0;
134
+ if (staleOracles) {
135
+ (0, generalUtils_1.consoleLog)("Requires oracle update(s)...");
136
+ const oracleTxs = switchboardMints.map((x) => new services_1.TransactionItem(async () => await buildSwbSubmitResponseTx(client.connection, client.signer, x), constants_1.UPDATE_ORACLE_TX_NAME));
137
+ (0, generalUtils_1.consoleLog)("Set crank IXs in TX");
138
+ txs.unshift(...oracleTxs);
139
+ }
140
+ }
141
+ }
@@ -4,6 +4,7 @@ import { fromWeb3JsKeypair } from "@metaplex-foundation/umi-web3js-adapters";
4
4
  import {
5
5
  ClientTransactionsManager,
6
6
  consoleLog,
7
+ fetchBank,
7
8
  getBatches,
8
9
  getClient,
9
10
  getPositionExBulk,
@@ -15,6 +16,8 @@ import {
15
16
  PriorityFeeSetting,
16
17
  ProgramEnv,
17
18
  rebalance,
19
+ safeFetchBank,
20
+ safeFetchMarginfiAccount,
18
21
  SOLAUTO_PROD_PROGRAM,
19
22
  SOLAUTO_TEST_PROGRAM,
20
23
  SolautoClient,
@@ -46,24 +49,30 @@ export async function main() {
46
49
  lpEnv,
47
50
  });
48
51
 
49
- await client.initializeExistingSolautoPosition({
50
- positionId: 1,
51
- authority: new PublicKey("61rtn5tzVkesapo6Cz83SPoShUfAePSxJsqniuF2wRKC"),
52
- // lpUserAccount: new PublicKey(
53
- // "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
54
- // ),
55
- });
52
+ // await client.initializeExistingSolautoPosition({
53
+ // positionId: 1,
54
+ // authority: new PublicKey("61rtn5tzVkesapo6Cz83SPoShUfAePSxJsqniuF2wRKC"),
55
+ // // lpUserAccount: new PublicKey(
56
+ // // "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
57
+ // // ),
58
+ // });
56
59
 
57
- const transactionItems = [rebalance(client)];
60
+ // const transactionItems = [rebalance(client)];
58
61
 
59
- const txManager = new ClientTransactionsManager({
60
- txHandler: client,
61
- txRunType: payForTransaction ? "normal" : "only-simulate",
62
- priorityFeeSetting: PriorityFeeSetting.Default,
63
- retryConfig: { totalRetries: 2 },
64
- });
65
- const statuses = await txManager.send(transactionItems);
66
- consoleLog(statuses);
62
+ const account = await fetchBank(umi, publicKey("Ac4KV5K5isDqtABtg6h5DiwzZMe3Sp9bc3pBiCUvUpaQ"));
63
+ console.log(account.config.oracleKeys[0]);
64
+ console.log(account.config.oracleKeys[1]);
65
+ console.log(account.config.oracleKeys[2]);
66
+ console.log(account.config.oracleKeys[3]);
67
+
68
+ // const txManager = new ClientTransactionsManager({
69
+ // txHandler: client,
70
+ // txRunType: payForTransaction ? "normal" : "only-simulate",
71
+ // priorityFeeSetting: PriorityFeeSetting.Default,
72
+ // retryConfig: { totalRetries: 2 },
73
+ // });
74
+ // const statuses = await txManager.send(transactionItems);
75
+ // consoleLog(statuses);
67
76
  }
68
77
 
69
78
  async function refreshAll() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.813",
3
+ "version": "1.0.814",
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",
@@ -65,3 +65,5 @@ export const STANDARD_LUT_ACCOUNTS = [
65
65
  SYSVAR_INSTRUCTIONS_PUBKEY,
66
66
  JUPITER_PROGRAM_ID,
67
67
  ].map((x) => x.toString());
68
+
69
+ export const UPDATE_ORACLE_TX_NAME = "update oracle";
@@ -5,6 +5,7 @@ import {
5
5
  import { SolautoClient } from "../../solauto";
6
6
  import { TransactionsManager } from "./transactionsManager";
7
7
  import {
8
+ addSwbOraclePullTxs,
8
9
  buildSwbSubmitResponseTx,
9
10
  getSwitchboardFeedData,
10
11
  isSwitchboardMint,
@@ -34,46 +35,6 @@ export class ClientTransactionsManager extends TransactionsManager<SolautoClient
34
35
  await this.txHandler.refetchReferralState();
35
36
  }
36
37
 
37
- private async addSwbOraclePullTxs(txs: TransactionItem[]) {
38
- const switchboardMints = [
39
- ...(isSwitchboardMint(this.txHandler.pos.supplyMint)
40
- ? [this.txHandler.pos.supplyMint]
41
- : []),
42
- ...(isSwitchboardMint(this.txHandler.pos.debtMint)
43
- ? [this.txHandler.pos.debtMint]
44
- : []),
45
- ];
46
-
47
- if (txs.find((x) => x.oracleInteractor) && switchboardMints.length) {
48
- this.txHandler.log("Checking if oracle update(s) needed...");
49
- const staleOracles =
50
- (
51
- await getSwitchboardFeedData(
52
- this.txHandler.connection,
53
- switchboardMints
54
- )
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
- this.txHandler.log("Set crank IXs in TX");
72
- txs.unshift(...oracleTxs);
73
- }
74
- }
75
- }
76
-
77
38
  private async addChoreTxs(
78
39
  txs: TransactionItem[],
79
40
  updateLutTx?: TransactionBuilder
@@ -131,7 +92,7 @@ export class ClientTransactionsManager extends TransactionsManager<SolautoClient
131
92
  }
132
93
  this.lookupTables.defaultLuts = client.defaultLookupTables();
133
94
 
134
- await this.addSwbOraclePullTxs(items);
95
+ // await addSwbOraclePullTxs(this.txHandler, items);
135
96
 
136
97
  for (const item of items) {
137
98
  await item.initialize();
@@ -16,6 +16,7 @@ import {
16
16
  import { TxHandler } from "../../solauto";
17
17
  import { getErrorInfo } from "../transactionUtils";
18
18
  import { LookupTables, TransactionItem, TransactionSet } from "../types";
19
+ import { UPDATE_ORACLE_TX_NAME } from "../../../constants";
19
20
 
20
21
  export class TransactionTooLargeError extends Error {
21
22
  constructor(message: string) {
@@ -75,8 +76,6 @@ export class TransactionsManager<T extends TxHandler> {
75
76
  protected retryDelay: number;
76
77
  protected abortController?: AbortController;
77
78
 
78
- updateOracleTxName = "update oracle";
79
-
80
79
  constructor(args: TransactionsManagerArgs<T>) {
81
80
  this.txHandler = args.txHandler;
82
81
  this.statusCallback = args.statusCallback;
@@ -118,7 +117,9 @@ export class TransactionsManager<T extends TxHandler> {
118
117
  );
119
118
  if (!transaction.fitsInOneTransaction(this.txHandler.umi)) {
120
119
  throw new TransactionTooLargeError(
121
- `Exceeds max transaction size (${transaction.getTransactionSize(this.txHandler.umi)})`
120
+ `Exceeds max transaction size (${transaction.getTransactionSize(
121
+ this.txHandler.umi
122
+ )})`
122
123
  );
123
124
  } else {
124
125
  let newSet = new TransactionSet(this.txHandler, this.lookupTables, [
@@ -166,7 +167,9 @@ export class TransactionsManager<T extends TxHandler> {
166
167
  }
167
168
  }
168
169
  consoleLog(
169
- `${args.name} ${args.attemptNum} is ${args.status.toString().toLowerCase()}`
170
+ `${args.name} ${args.attemptNum} is ${args.status
171
+ .toString()
172
+ .toLowerCase()}`
170
173
  );
171
174
  this.statusCallback?.([...this.statuses]);
172
175
  }
@@ -180,7 +183,11 @@ export class TransactionsManager<T extends TxHandler> {
180
183
  (x) => !lutAccounts.includes(x)
181
184
  );
182
185
  consoleLog(
183
- `Program ${ix.programId}, data len: ${ix.data.length}, LUT accounts data: ${ix.keys.filter((x) => lutAccounts.includes(x.pubkey)).length * 3}`
186
+ `Program ${ix.programId}, data len: ${
187
+ ix.data.length
188
+ }, LUT accounts data: ${
189
+ ix.keys.filter((x) => lutAccounts.includes(x.pubkey)).length * 3
190
+ }`
184
191
  );
185
192
  if (accountsNotInLut.length > 0) {
186
193
  consoleLog(`${accountsNotInLut.length} accounts not in LUT:`);
@@ -273,7 +280,7 @@ export class TransactionsManager<T extends TxHandler> {
273
280
  );
274
281
  if (
275
282
  newItemSetNames.length === 1 &&
276
- newItemSetNames[0] === this.updateOracleTxName
283
+ newItemSetNames[0] === UPDATE_ORACLE_TX_NAME
277
284
  ) {
278
285
  consoleLog("Skipping unnecessary oracle update");
279
286
  this.updateStatusForSets(
@@ -570,7 +577,9 @@ export class TransactionsManager<T extends TxHandler> {
570
577
  this.priorityFeeSetting
571
578
  );
572
579
 
573
- const errorString = `${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo?.split("\n")[0] ?? "unknown"}`;
580
+ const errorString = `${errorDetails.errorName ?? "Unknown error"}: ${
581
+ errorDetails.errorInfo?.split("\n")[0] ?? "unknown"
582
+ }`;
574
583
  const errorInfo =
575
584
  errorDetails.errorName || errorDetails.errorInfo
576
585
  ? errorString
@@ -9,7 +9,11 @@ import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
9
9
  import { AnchorProvider, Idl, Program } from "@coral-xyz/anchor";
10
10
  import * as OnDemand from "@switchboard-xyz/on-demand";
11
11
  import Big from "big.js";
12
- import { PRICES, SWITCHBOARD_PRICE_FEED_IDS } from "../constants";
12
+ import {
13
+ PRICES,
14
+ SWITCHBOARD_PRICE_FEED_IDS,
15
+ UPDATE_ORACLE_TX_NAME,
16
+ } from "../constants";
13
17
  import { TransactionItemInputs } from "../types";
14
18
  import {
15
19
  consoleLog,
@@ -18,6 +22,7 @@ import {
18
22
  } from "./generalUtils";
19
23
  import { getWrappedInstruction } from "./solanaUtils";
20
24
  import { CrossbarClient } from "@switchboard-xyz/common";
25
+ import { SolautoClient, TransactionItem } from "../services";
21
26
 
22
27
  export async function getPullFeed(
23
28
  conn: Connection,
@@ -69,8 +74,6 @@ export async function buildSwbSubmitResponseTx(
69
74
  toWeb3JsPublicKey(signer.publicKey)
70
75
  );
71
76
 
72
- // Try to replicate locally in the lambda docker container
73
-
74
77
  consoleLog("Fetching crank IX...");
75
78
  const [pullIxs, responses] = await retryWithExponentialBackoff(
76
79
  async () => {
@@ -146,3 +149,41 @@ export async function getSwitchboardFeedData(
146
149
  export function isSwitchboardMint(mint: PublicKey | string) {
147
150
  return Object.keys(SWITCHBOARD_PRICE_FEED_IDS).includes(mint.toString());
148
151
  }
152
+
153
+ export async function addSwbOraclePullTxs(
154
+ client: SolautoClient,
155
+ txs: TransactionItem[]
156
+ ) {
157
+ const switchboardMints = [
158
+ ...(isSwitchboardMint(client.pos.supplyMint)
159
+ ? [client.pos.supplyMint]
160
+ : []),
161
+ ...(isSwitchboardMint(client.pos.debtMint) ? [client.pos.debtMint] : []),
162
+ ];
163
+
164
+ if (txs.find((x) => x.oracleInteractor) && switchboardMints.length) {
165
+ consoleLog("Checking if oracle update(s) needed...");
166
+ const staleOracles =
167
+ (
168
+ await getSwitchboardFeedData(client.connection, switchboardMints)
169
+ ).filter((x) => x.stale).length > 0;
170
+
171
+ if (staleOracles) {
172
+ consoleLog("Requires oracle update(s)...");
173
+ const oracleTxs = switchboardMints.map(
174
+ (x) =>
175
+ new TransactionItem(
176
+ async () =>
177
+ await buildSwbSubmitResponseTx(
178
+ client.connection,
179
+ client.signer,
180
+ x
181
+ ),
182
+ UPDATE_ORACLE_TX_NAME
183
+ )
184
+ );
185
+ consoleLog("Set crank IXs in TX");
186
+ txs.unshift(...oracleTxs);
187
+ }
188
+ }
189
+ }