@haven-fi/solauto-sdk 1.0.392 → 1.0.394

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.
@@ -7,6 +7,7 @@ export interface ReferralStateManagerArgs {
7
7
  signer?: Signer;
8
8
  wallet?: WalletAdapter;
9
9
  authority?: PublicKey;
10
+ referralState?: PublicKey;
10
11
  referredByAuthority?: PublicKey;
11
12
  }
12
13
  export declare class ReferralStateManager extends TxHandler {
@@ -1 +1 @@
1
- {"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAEL,MAAM,EAEN,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAEL,aAAa,EAGd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,mBAAmB,CAAC,EAAE,SAAS,CAAC;CACjC;AAED,qBAAa,oBAAqB,SAAQ,SAAS;IAC1C,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,EAAG,MAAM,CAAC;IAEhB,aAAa,EAAG,SAAS,CAAC;IAC1B,iBAAiB,EAAG,aAAa,GAAG,IAAI,CAAC;IACzC,SAAS,EAAG,SAAS,CAAC;IAEtB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,eAAe,CAAC,EAAE,SAAS,CAAC;IAE7B,UAAU,CAAC,IAAI,EAAE,wBAAwB;IA2B/C,mBAAmB,IAAI,MAAM,EAAE;IAS/B,aAAa,CAAC,UAAU,CAAC,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,EACxB,WAAW,CAAC,EAAE,SAAS,GACtB,kBAAkB;IAerB,mBAAmB,IAAI,kBAAkB;IA0BnC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC3D"}
@@ -20,7 +20,7 @@ class ReferralStateManager extends txHandler_1.TxHandler {
20
20
  : (0, umi_signer_wallet_adapters_1.walletAdapterIdentity)(args.wallet, true));
21
21
  this.signer = this.umi.identity;
22
22
  this.authority = args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey);
23
- this.referralState = (0, utils_1.getReferralState)(this.authority, this.programId);
23
+ this.referralState = args.referralState ?? (0, utils_1.getReferralState)(this.authority, this.programId);
24
24
  this.referralStateData = await (0, generated_1.safeFetchReferralState)(this.umi, (0, umi_1.publicKey)(this.referralState), { commitment: "confirmed" });
25
25
  this.setReferredBy(args.referredByAuthority);
26
26
  this.log("Authority:", this.authority.toString());
@@ -1,6 +1,26 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.fetchTokenPrices = fetchTokenPrices;
@@ -13,7 +33,7 @@ const numberUtils_1 = require("./numberUtils");
13
33
  const solautoConstants_1 = require("../constants/solautoConstants");
14
34
  const switchboardConstants_1 = require("../constants/switchboardConstants");
15
35
  const generalUtils_1 = require("./generalUtils");
16
- const on_demand_1 = __importDefault(require("@switchboard-xyz/on-demand"));
36
+ const OnDemand = __importStar(require("@switchboard-xyz/on-demand"));
17
37
  const jupiterUtils_1 = require("./jupiterUtils");
18
38
  async function fetchTokenPrices(mints) {
19
39
  const currentTime = (0, generalUtils_1.currentUnixSeconds)();
@@ -71,7 +91,7 @@ async function getSwitchboardPrices(mints) {
71
91
  if (mints.length === 0) {
72
92
  return [];
73
93
  }
74
- const { CrossbarClient } = on_demand_1.default;
94
+ const { CrossbarClient } = OnDemand;
75
95
  const crossbar = CrossbarClient.default();
76
96
  let prices = [];
77
97
  try {
@@ -1,5 +1,5 @@
1
1
  import { Connection, PublicKey } from "@solana/web3.js";
2
- import OnDemand from "@switchboard-xyz/on-demand";
2
+ import * as OnDemand from "@switchboard-xyz/on-demand";
3
3
  import { TransactionItemInputs } from "../types";
4
4
  import { Signer } from "@metaplex-foundation/umi";
5
5
  export declare function getPullFeed(conn: Connection, mint: PublicKey, wallet?: PublicKey): OnDemand.PullFeed;
@@ -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,QAAQ,MAAM,4BAA4B,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,EAAsB,MAAM,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,CAuB/D"}
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -9,7 +32,7 @@ exports.getSwitchboardFeedData = getSwitchboardFeedData;
9
32
  const anchor_1 = require("@coral-xyz/anchor");
10
33
  const switchboard_json_1 = __importDefault(require("../idls/switchboard.json"));
11
34
  const web3_js_1 = require("@solana/web3.js");
12
- const on_demand_1 = __importDefault(require("@switchboard-xyz/on-demand"));
35
+ const OnDemand = __importStar(require("@switchboard-xyz/on-demand"));
13
36
  const switchboardConstants_1 = require("../constants/switchboardConstants");
14
37
  const umi_1 = require("@metaplex-foundation/umi");
15
38
  const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
@@ -22,11 +45,11 @@ function getPullFeed(conn, mint, wallet) {
22
45
  };
23
46
  const provider = new anchor_1.AnchorProvider(conn, dummyWallet, anchor_1.AnchorProvider.defaultOptions());
24
47
  const program = new anchor_1.Program(switchboard_json_1.default, provider);
25
- const { PullFeed } = on_demand_1.default;
48
+ const { PullFeed } = OnDemand;
26
49
  return new PullFeed(program, new web3_js_1.PublicKey(switchboardConstants_1.SWITCHBOARD_PRICE_FEED_IDS[mint.toString()]));
27
50
  }
28
51
  async function buildSwbSubmitResponseTx(conn, signer, mint) {
29
- const { CrossbarClient } = on_demand_1.default;
52
+ const { CrossbarClient } = OnDemand;
30
53
  const crossbar = CrossbarClient.default();
31
54
  const feed = getPullFeed(conn, mint, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(signer.publicKey));
32
55
  const [pullIx, responses] = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await feed.fetchUpdateIx({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.392",
3
+ "version": "1.0.394",
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",
@@ -26,6 +26,7 @@ export interface ReferralStateManagerArgs {
26
26
  signer?: Signer;
27
27
  wallet?: WalletAdapter;
28
28
  authority?: PublicKey;
29
+ referralState?: PublicKey;
29
30
  referredByAuthority?: PublicKey;
30
31
  }
31
32
 
@@ -52,7 +53,7 @@ export class ReferralStateManager extends TxHandler {
52
53
  this.signer = this.umi.identity;
53
54
  this.authority = args.authority ?? toWeb3JsPublicKey(this.signer.publicKey);
54
55
 
55
- this.referralState = getReferralState(this.authority, this.programId);
56
+ this.referralState = args.referralState ?? getReferralState(this.authority, this.programId);
56
57
 
57
58
  this.referralStateData = await safeFetchReferralState(
58
59
  this.umi,
@@ -10,7 +10,7 @@ import {
10
10
  retryWithExponentialBackoff,
11
11
  zip,
12
12
  } from "./generalUtils";
13
- import OnDemand from "@switchboard-xyz/on-demand";
13
+ import * as OnDemand from "@switchboard-xyz/on-demand";
14
14
  import { getJupPriceData } from "./jupiterUtils";
15
15
 
16
16
  export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
@@ -6,7 +6,7 @@ import {
6
6
  Transaction,
7
7
  VersionedTransaction,
8
8
  } from "@solana/web3.js";
9
- import OnDemand from "@switchboard-xyz/on-demand";
9
+ import * as OnDemand from "@switchboard-xyz/on-demand";
10
10
  import { SWITCHBOARD_PRICE_FEED_IDS } from "../constants/switchboardConstants";
11
11
  import { TransactionItemInputs } from "../types";
12
12
  import { Signer, transactionBuilder } from "@metaplex-foundation/umi";