@haven-fi/solauto-sdk 1.0.795 → 1.0.797

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":"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"}
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"}
@@ -29,6 +29,7 @@ class ClientTransactionsManager extends transactionsManager_1.TransactionsManage
29
29
  if (staleOracles) {
30
30
  this.txHandler.log("Requires oracle update(s)...");
31
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");
32
33
  txs.unshift(...oracleTxs);
33
34
  }
34
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"switchboardUtils.d.ts","sourceRoot":"","sources":["../../src/utils/switchboardUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAsB,MAAM,0BAA0B,CAAC;AAGtE,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAC;AAIvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAOjD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,SAAS,EACf,MAAM,CAAC,EAAE,SAAS,8BAyBnB;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAwC5C;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"}
1
+ {"version":3,"file":"switchboardUtils.d.ts","sourceRoot":"","sources":["../../src/utils/switchboardUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAsB,MAAM,0BAA0B,CAAC;AAGtE,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAC;AAIvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAQjD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,SAAS,EACf,MAAM,CAAC,EAAE,SAAS,8BA0BnB;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CA0C5C;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"}
@@ -32,9 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
36
  exports.getPullFeed = getPullFeed;
40
37
  exports.buildSwbSubmitResponseTx = buildSwbSubmitResponseTx;
@@ -45,7 +42,6 @@ const umi_1 = require("@metaplex-foundation/umi");
45
42
  const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
46
43
  const anchor_1 = require("@coral-xyz/anchor");
47
44
  const OnDemand = __importStar(require("@switchboard-xyz/on-demand"));
48
- const switchboard_json_1 = __importDefault(require("../idls/switchboard.json"));
49
45
  const constants_1 = require("../constants");
50
46
  const generalUtils_1 = require("./generalUtils");
51
47
  const solanaUtils_1 = require("./solanaUtils");
@@ -56,13 +52,15 @@ async function getPullFeed(conn, mint, wallet) {
56
52
  signAllTransactions: async (txs) => txs,
57
53
  };
58
54
  const provider = new anchor_1.AnchorProvider(conn, dummyWallet, anchor_1.AnchorProvider.defaultOptions());
59
- const program = new anchor_1.Program(switchboard_json_1.default, provider);
55
+ (0, generalUtils_1.consoleLog)("Pulling SWB program...");
60
56
  const { PullFeed, ON_DEMAND_MAINNET_PID } = OnDemand;
61
57
  const sbProgram = await anchor_1.Program.at(ON_DEMAND_MAINNET_PID, provider);
58
+ (0, generalUtils_1.consoleLog)("Pulled SWB program!");
62
59
  return new PullFeed(sbProgram, new web3_js_1.PublicKey(constants_1.SWITCHBOARD_PRICE_FEED_IDS[mint.toString()].feedId));
63
60
  }
64
61
  async function buildSwbSubmitResponseTx(conn, signer, mint) {
65
62
  const feed = await getPullFeed(conn, mint, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(signer.publicKey));
63
+ (0, generalUtils_1.consoleLog)("Fetching crank IX...");
66
64
  const [pullIxs, responses] = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
67
65
  const res = await feed.fetchUpdateIx({
68
66
  gateway: await feed.fetchGatewayUrl(),
@@ -5,13 +5,17 @@ import {
5
5
  buildSwbSubmitResponseTx,
6
6
  ClientTransactionsManager,
7
7
  consoleLog,
8
+ deposit,
8
9
  getBatches,
9
10
  getClient,
11
+ getMarginfiAccounts,
10
12
  getPositionExBulk,
11
13
  getSolanaRpcConnection,
12
14
  getSolautoManagedPositions,
15
+ JITO_SOL,
13
16
  LendingPlatform,
14
17
  LOCAL_IRONFORGE_API_URL,
18
+ openSolautoPosition,
15
19
  PriceType,
16
20
  PriorityFeeSetting,
17
21
  ProgramEnv,
@@ -19,7 +23,9 @@ import {
19
23
  SOLAUTO_PROD_PROGRAM,
20
24
  SOLAUTO_TEST_PROGRAM,
21
25
  SolautoClient,
26
+ toBaseUnit,
22
27
  TransactionItem,
28
+ USDC,
23
29
  } from "../src";
24
30
  import { getSecretKey } from "./shared";
25
31
  import { NATIVE_MINT } from "@solana/spl-token";
@@ -36,7 +42,7 @@ let [conn, umi] = getSolanaRpcConnection(
36
42
 
37
43
  const signer = createSignerFromKeypair(
38
44
  umi,
39
- fromWeb3JsKeypair(Keypair.fromSecretKey(getSecretKey("solauto-manager")))
45
+ fromWeb3JsKeypair(Keypair.fromSecretKey(getSecretKey("id")))
40
46
  );
41
47
 
42
48
  export async function main() {
@@ -50,16 +56,25 @@ export async function main() {
50
56
 
51
57
  await client.initializeExistingSolautoPosition({
52
58
  positionId: 1,
53
- authority: new PublicKey("R8Nnj1UqK1BRPnfJYj7MvfPUK3GmEzmgh1CwFFtUNsF"),
54
- // lpUserAccount: new PublicKey(
55
- // "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
56
- // ),
59
+ authority: new PublicKey("EvAzkzFa7bu4vWpgu8Wyng8LLeCNmteP8jDme5gWSQWL")
60
+ // supplyMint: NATIVE_MINT,
61
+ // debtMint: new PublicKey(USDC),
62
+ // lpPoolAccount: getMarginfiAccounts("Prod").defaultGroup,
57
63
  });
58
64
 
59
- // const transactionItems = [rebalance(client)];
65
+ // const transactionItems = [
66
+ // openSolautoPosition(client, {
67
+ // boostToBps: 2000,
68
+ // boostGap: 50,
69
+ // repayToBps: 5000,
70
+ // repayGap: 50,
71
+ // }),
72
+ // deposit(client, toBaseUnit(0.5, 9)),
73
+ // rebalance(client),
74
+ // ];
60
75
  const transactionItems = [
61
76
  new TransactionItem(
62
- async () => await buildSwbSubmitResponseTx(conn, signer, NATIVE_MINT)
77
+ async () => await buildSwbSubmitResponseTx(conn, signer, new PublicKey(JITO_SOL))
63
78
  ),
64
79
  ];
65
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.795",
3
+ "version": "1.0.797",
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",
@@ -68,6 +68,7 @@ export class ClientTransactionsManager extends TransactionsManager<SolautoClient
68
68
  this.updateOracleTxName
69
69
  )
70
70
  );
71
+ this.txHandler.log("Set crank IXs in TX");
71
72
  txs.unshift(...oracleTxs);
72
73
  }
73
74
  }
@@ -13,6 +13,7 @@ import switchboardIdl from "../idls/switchboard.json";
13
13
  import { PRICES, SWITCHBOARD_PRICE_FEED_IDS } from "../constants";
14
14
  import { TransactionItemInputs } from "../types";
15
15
  import {
16
+ consoleLog,
16
17
  currentUnixSeconds,
17
18
  retryWithExponentialBackoff,
18
19
  } from "./generalUtils";
@@ -37,11 +38,12 @@ export async function getPullFeed(
37
38
  dummyWallet,
38
39
  AnchorProvider.defaultOptions()
39
40
  );
40
- const program = new Program(switchboardIdl as Idl, provider);
41
41
 
42
+ consoleLog("Pulling SWB program...");
42
43
  const { PullFeed, ON_DEMAND_MAINNET_PID } = OnDemand;
43
44
  const sbProgram = await Program.at(ON_DEMAND_MAINNET_PID, provider);
44
45
 
46
+ consoleLog("Pulled SWB program!");
45
47
  return new PullFeed(
46
48
  sbProgram,
47
49
  new PublicKey(SWITCHBOARD_PRICE_FEED_IDS[mint.toString()].feedId)
@@ -54,6 +56,8 @@ export async function buildSwbSubmitResponseTx(
54
56
  mint: PublicKey
55
57
  ): Promise<TransactionItemInputs | undefined> {
56
58
  const feed = await getPullFeed(conn, mint, toWeb3JsPublicKey(signer.publicKey));
59
+
60
+ consoleLog("Fetching crank IX...");
57
61
  const [pullIxs, responses] = await retryWithExponentialBackoff(
58
62
  async () => {
59
63
  const res = await feed.fetchUpdateIx({