@haven-fi/solauto-sdk 1.0.544 → 1.0.546
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/jupiterUtils.js +1 -1
- package/dist/utils/priceUtils.d.ts +1 -6
- package/dist/utils/priceUtils.d.ts.map +1 -1
- package/dist/utils/priceUtils.js +0 -14
- package/package.json +1 -1
- package/src/utils/jupiterUtils.ts +1 -1
- package/src/utils/priceUtils.ts +2 -22
- package/tests/transactions/solautoMarginfi.ts +39 -13
@@ -101,7 +101,7 @@ async function getJupPriceData(mints, mayIncludeSpamTokens) {
|
|
101
101
|
if (invalidValues && !mayIncludeSpamTokens) {
|
102
102
|
throw new Error("Invalid price values");
|
103
103
|
}
|
104
|
-
const trueData = Object.entries(result).reduce((acc, [key, val]) => val
|
104
|
+
const trueData = Object.entries(result).reduce((acc, [key, val]) => !val?.extraInfo?.quotedPrice?.sellAt
|
105
105
|
? { ...acc, [key]: { ...val, price: "0" } }
|
106
106
|
: { ...acc, [key]: val }, {});
|
107
107
|
return trueData;
|
@@ -1,13 +1,8 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
2
|
import { PublicKey as UmiPublicKey } from "@metaplex-foundation/umi";
|
3
|
-
import { QuoteGetSwapModeEnum } from "@jup-ag/api";
|
4
3
|
export declare function fetchTokenPrices(mints: PublicKey[]): Promise<number[]>;
|
5
4
|
export declare function getPythPrices(mints: PublicKey[]): Promise<number[]>;
|
6
5
|
export declare function getSwitchboardPrices(mints: PublicKey[]): Promise<number[]>;
|
7
6
|
export declare function getJupTokenPrices(mints: PublicKey[], mayIncludeSpamTokens?: boolean): Promise<number[]>;
|
8
|
-
export declare function safeGetPrice(mint: PublicKey | UmiPublicKey | undefined): number | undefined;
|
9
|
-
export declare function getPriceImpact(inputMint: PublicKey, outputMint: PublicKey, amount: bigint, swapMode: QuoteGetSwapModeEnum): Promise<{
|
10
|
-
priceImpact: number;
|
11
|
-
quote: import("@jup-ag/api").QuoteResponse;
|
12
|
-
}>;
|
7
|
+
export declare function safeGetPrice(mint: PublicKey | UmiPublicKey | string | undefined): number | undefined;
|
13
8
|
//# sourceMappingURL=priceUtils.d.ts.map
|
@@ -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;
|
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;AAerE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAyC5E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,qBAwCrD;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAoDnB;AAED,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,SAAS,EAAE,EAClB,oBAAoB,CAAC,EAAE,OAAO,qBAqB/B;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,GAClD,MAAM,GAAG,SAAS,CAKpB"}
|
package/dist/utils/priceUtils.js
CHANGED
@@ -28,7 +28,6 @@ exports.getPythPrices = getPythPrices;
|
|
28
28
|
exports.getSwitchboardPrices = getSwitchboardPrices;
|
29
29
|
exports.getJupTokenPrices = getJupTokenPrices;
|
30
30
|
exports.safeGetPrice = safeGetPrice;
|
31
|
-
exports.getPriceImpact = getPriceImpact;
|
32
31
|
const pythConstants_1 = require("../constants/pythConstants");
|
33
32
|
const numberUtils_1 = require("./numberUtils");
|
34
33
|
const solautoConstants_1 = require("../constants/solautoConstants");
|
@@ -140,16 +139,3 @@ function safeGetPrice(mint) {
|
|
140
139
|
}
|
141
140
|
return undefined;
|
142
141
|
}
|
143
|
-
async function getPriceImpact(inputMint, outputMint, amount, swapMode) {
|
144
|
-
const quoteResponse = await (0, jupiterUtils_1.getJupQuote)({
|
145
|
-
inputMint,
|
146
|
-
outputMint,
|
147
|
-
amount,
|
148
|
-
exactIn: swapMode === "ExactIn",
|
149
|
-
exactOut: swapMode === "ExactOut",
|
150
|
-
});
|
151
|
-
return {
|
152
|
-
priceImpact: parseFloat(quoteResponse.priceImpactPct),
|
153
|
-
quote: quoteResponse,
|
154
|
-
};
|
155
|
-
}
|
package/package.json
CHANGED
@@ -204,7 +204,7 @@ export async function getJupPriceData(
|
|
204
204
|
result as { [key: string]: any }
|
205
205
|
).reduce(
|
206
206
|
(acc, [key, val]) =>
|
207
|
-
val
|
207
|
+
!val?.extraInfo?.quotedPrice?.sellAt
|
208
208
|
? { ...acc, [key]: { ...val, price: "0" } }
|
209
209
|
: { ...acc, [key]: val },
|
210
210
|
{}
|
package/src/utils/priceUtils.ts
CHANGED
@@ -181,30 +181,10 @@ export async function getJupTokenPrices(
|
|
181
181
|
}
|
182
182
|
|
183
183
|
export function safeGetPrice(
|
184
|
-
mint: PublicKey | UmiPublicKey | undefined
|
184
|
+
mint: PublicKey | UmiPublicKey | string | undefined
|
185
185
|
): number | undefined {
|
186
186
|
if (mint && mint?.toString() in PRICES) {
|
187
187
|
return PRICES[mint!.toString()].price;
|
188
188
|
}
|
189
189
|
return undefined;
|
190
|
-
}
|
191
|
-
|
192
|
-
export async function getPriceImpact(
|
193
|
-
inputMint: PublicKey,
|
194
|
-
outputMint: PublicKey,
|
195
|
-
amount: bigint,
|
196
|
-
swapMode: QuoteGetSwapModeEnum
|
197
|
-
) {
|
198
|
-
const quoteResponse = await getJupQuote({
|
199
|
-
inputMint,
|
200
|
-
outputMint,
|
201
|
-
amount,
|
202
|
-
exactIn: swapMode === "ExactIn",
|
203
|
-
exactOut: swapMode === "ExactOut",
|
204
|
-
});
|
205
|
-
|
206
|
-
return {
|
207
|
-
priceImpact: parseFloat(quoteResponse.priceImpactPct),
|
208
|
-
quote: quoteResponse,
|
209
|
-
};
|
210
|
-
}
|
190
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { describe, it } from "mocha";
|
2
|
-
import { none, publicKey, some } from "@metaplex-foundation/umi";
|
2
|
+
import { none, publicKey, some, Umi } from "@metaplex-foundation/umi";
|
3
3
|
import { setupTest } from "../shared";
|
4
4
|
import { SolautoMarginfiClient } from "../../src/clients/solautoMarginfiClient";
|
5
5
|
import {
|
@@ -43,6 +43,29 @@ import {
|
|
43
43
|
import { PriorityFeeSetting } from "../../src/types";
|
44
44
|
import { buildIronforgeApiUrl, fromBaseUnit, tokenInfo, USD_DECIMALS } from "../../dist";
|
45
45
|
|
46
|
+
async function getAssets(
|
47
|
+
umi: Umi,
|
48
|
+
mints: PublicKey[]
|
49
|
+
) {
|
50
|
+
const response = await fetch(umi.rpc.getEndpoint(), {
|
51
|
+
method: 'POST',
|
52
|
+
headers: {
|
53
|
+
'Content-Type': 'application/json',
|
54
|
+
},
|
55
|
+
body: JSON.stringify({
|
56
|
+
jsonrpc: '2.0',
|
57
|
+
id: 'get-assets',
|
58
|
+
method: 'getAssetBatch',
|
59
|
+
params: {
|
60
|
+
ids: mints.map((x) => x.toString()),
|
61
|
+
},
|
62
|
+
}),
|
63
|
+
});
|
64
|
+
const res = await response.json();
|
65
|
+
return res;
|
66
|
+
}
|
67
|
+
|
68
|
+
|
46
69
|
describe("Solauto Marginfi tests", async () => {
|
47
70
|
// const signer = setupTest();
|
48
71
|
const signer = setupTest("solauto-manager");
|
@@ -62,18 +85,21 @@ describe("Solauto Marginfi tests", async () => {
|
|
62
85
|
const supplyDecimals = 6;
|
63
86
|
const debtDecimals = 6;
|
64
87
|
|
65
|
-
await client.initialize({
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
});
|
88
|
+
// await client.initialize({
|
89
|
+
// signer,
|
90
|
+
// positionId,
|
91
|
+
// authority: new PublicKey("FKYQs7KgRvaKQHxXwb8HKfoBcFdSxLL3JvHWpPdVQ16v"),
|
92
|
+
// // new: true,
|
93
|
+
// // marginfiAccount: new PublicKey(
|
94
|
+
// // ""
|
95
|
+
// // ),
|
96
|
+
// // marginfiGroup: new PublicKey(""),
|
97
|
+
// // supplyMint: new PublicKey(""),
|
98
|
+
// // debtMint: new PublicKey(USDC),
|
99
|
+
// });
|
100
|
+
|
101
|
+
console.log(await getAssets(client.umi, [NATIVE_MINT, new PublicKey(USDC)]));
|
102
|
+
return;
|
77
103
|
|
78
104
|
const transactionItems: TransactionItem[] = [];
|
79
105
|
// const settingParams: SolautoSettingsParametersInpArgs = {
|