@haven-fi/solauto-sdk 1.0.391 → 1.0.392
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.
- package/dist/utils/priceUtils.d.ts.map +1 -1
- package/dist/utils/priceUtils.js +6 -2
- package/dist/utils/switchboardUtils.d.ts +2 -2
- package/dist/utils/switchboardUtils.d.ts.map +1 -1
- package/dist/utils/switchboardUtils.js +5 -3
- package/package.json +1 -1
- package/src/utils/priceUtils.ts +2 -1
- package/src/utils/switchboardUtils.ts +4 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/priceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAcrE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqC5E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,qBAwCrD;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,
|
1
|
+
{"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/priceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAcrE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqC5E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,qBAwCrD;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CA8CnB;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,qBAYzD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAKpB"}
|
package/dist/utils/priceUtils.js
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.fetchTokenPrices = fetchTokenPrices;
|
4
7
|
exports.getPythPrices = getPythPrices;
|
@@ -10,7 +13,7 @@ const numberUtils_1 = require("./numberUtils");
|
|
10
13
|
const solautoConstants_1 = require("../constants/solautoConstants");
|
11
14
|
const switchboardConstants_1 = require("../constants/switchboardConstants");
|
12
15
|
const generalUtils_1 = require("./generalUtils");
|
13
|
-
const on_demand_1 = require("@switchboard-xyz/on-demand");
|
16
|
+
const on_demand_1 = __importDefault(require("@switchboard-xyz/on-demand"));
|
14
17
|
const jupiterUtils_1 = require("./jupiterUtils");
|
15
18
|
async function fetchTokenPrices(mints) {
|
16
19
|
const currentTime = (0, generalUtils_1.currentUnixSeconds)();
|
@@ -68,7 +71,8 @@ async function getSwitchboardPrices(mints) {
|
|
68
71
|
if (mints.length === 0) {
|
69
72
|
return [];
|
70
73
|
}
|
71
|
-
const
|
74
|
+
const { CrossbarClient } = on_demand_1.default;
|
75
|
+
const crossbar = CrossbarClient.default();
|
72
76
|
let prices = [];
|
73
77
|
try {
|
74
78
|
prices = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Connection, PublicKey } from "@solana/web3.js";
|
2
|
-
import
|
2
|
+
import OnDemand from "@switchboard-xyz/on-demand";
|
3
3
|
import { TransactionItemInputs } from "../types";
|
4
4
|
import { Signer } from "@metaplex-foundation/umi";
|
5
|
-
export declare function getPullFeed(conn: Connection, mint: PublicKey, wallet?: PublicKey): PullFeed;
|
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<{
|
8
8
|
mint: PublicKey;
|
@@ -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,
|
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,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,CAwB5C;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"}
|
@@ -9,7 +9,7 @@ exports.getSwitchboardFeedData = getSwitchboardFeedData;
|
|
9
9
|
const anchor_1 = require("@coral-xyz/anchor");
|
10
10
|
const switchboard_json_1 = __importDefault(require("../idls/switchboard.json"));
|
11
11
|
const web3_js_1 = require("@solana/web3.js");
|
12
|
-
const on_demand_1 = require("@switchboard-xyz/on-demand");
|
12
|
+
const on_demand_1 = __importDefault(require("@switchboard-xyz/on-demand"));
|
13
13
|
const switchboardConstants_1 = require("../constants/switchboardConstants");
|
14
14
|
const umi_1 = require("@metaplex-foundation/umi");
|
15
15
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
@@ -22,10 +22,12 @@ function getPullFeed(conn, mint, wallet) {
|
|
22
22
|
};
|
23
23
|
const provider = new anchor_1.AnchorProvider(conn, dummyWallet, anchor_1.AnchorProvider.defaultOptions());
|
24
24
|
const program = new anchor_1.Program(switchboard_json_1.default, provider);
|
25
|
-
|
25
|
+
const { PullFeed } = on_demand_1.default;
|
26
|
+
return new PullFeed(program, new web3_js_1.PublicKey(switchboardConstants_1.SWITCHBOARD_PRICE_FEED_IDS[mint.toString()]));
|
26
27
|
}
|
27
28
|
async function buildSwbSubmitResponseTx(conn, signer, mint) {
|
28
|
-
const
|
29
|
+
const { CrossbarClient } = on_demand_1.default;
|
30
|
+
const crossbar = CrossbarClient.default();
|
29
31
|
const feed = getPullFeed(conn, mint, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(signer.publicKey));
|
30
32
|
const [pullIx, responses] = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await feed.fetchUpdateIx({
|
31
33
|
crossbarClient: crossbar,
|
package/package.json
CHANGED
package/src/utils/priceUtils.ts
CHANGED
@@ -10,7 +10,7 @@ import {
|
|
10
10
|
retryWithExponentialBackoff,
|
11
11
|
zip,
|
12
12
|
} from "./generalUtils";
|
13
|
-
import
|
13
|
+
import OnDemand from "@switchboard-xyz/on-demand";
|
14
14
|
import { getJupPriceData } from "./jupiterUtils";
|
15
15
|
|
16
16
|
export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
|
@@ -101,6 +101,7 @@ export async function getSwitchboardPrices(
|
|
101
101
|
return [];
|
102
102
|
}
|
103
103
|
|
104
|
+
const { CrossbarClient } = OnDemand;
|
104
105
|
const crossbar = CrossbarClient.default();
|
105
106
|
|
106
107
|
let prices: number[] = [];
|
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
Transaction,
|
7
7
|
VersionedTransaction,
|
8
8
|
} from "@solana/web3.js";
|
9
|
-
import
|
9
|
+
import 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";
|
@@ -37,6 +37,7 @@ export function getPullFeed(
|
|
37
37
|
);
|
38
38
|
const program = new Program(switchboardIdl as Idl, provider);
|
39
39
|
|
40
|
+
const { PullFeed } = OnDemand;
|
40
41
|
return new PullFeed(
|
41
42
|
program,
|
42
43
|
new PublicKey(SWITCHBOARD_PRICE_FEED_IDS[mint.toString()])
|
@@ -48,6 +49,8 @@ export async function buildSwbSubmitResponseTx(
|
|
48
49
|
signer: Signer,
|
49
50
|
mint: PublicKey
|
50
51
|
): Promise<TransactionItemInputs | undefined> {
|
52
|
+
const { CrossbarClient } = OnDemand;
|
53
|
+
|
51
54
|
const crossbar = CrossbarClient.default();
|
52
55
|
const feed = getPullFeed(conn, mint, toWeb3JsPublicKey(signer.publicKey));
|
53
56
|
const [pullIx, responses] = await retryWithExponentialBackoff(
|