@haven-fi/solauto-sdk 1.0.795 → 1.0.796
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":"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;
|
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
|
-
|
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(),
|
package/local/txSandbox.ts
CHANGED
@@ -5,13 +5,16 @@ 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,
|
13
15
|
LendingPlatform,
|
14
16
|
LOCAL_IRONFORGE_API_URL,
|
17
|
+
openSolautoPosition,
|
15
18
|
PriceType,
|
16
19
|
PriorityFeeSetting,
|
17
20
|
ProgramEnv,
|
@@ -19,7 +22,9 @@ import {
|
|
19
22
|
SOLAUTO_PROD_PROGRAM,
|
20
23
|
SOLAUTO_TEST_PROGRAM,
|
21
24
|
SolautoClient,
|
25
|
+
toBaseUnit,
|
22
26
|
TransactionItem,
|
27
|
+
USDC,
|
23
28
|
} from "../src";
|
24
29
|
import { getSecretKey } from "./shared";
|
25
30
|
import { NATIVE_MINT } from "@solana/spl-token";
|
@@ -36,7 +41,7 @@ let [conn, umi] = getSolanaRpcConnection(
|
|
36
41
|
|
37
42
|
const signer = createSignerFromKeypair(
|
38
43
|
umi,
|
39
|
-
fromWeb3JsKeypair(Keypair.fromSecretKey(getSecretKey("
|
44
|
+
fromWeb3JsKeypair(Keypair.fromSecretKey(getSecretKey("id")))
|
40
45
|
);
|
41
46
|
|
42
47
|
export async function main() {
|
@@ -48,20 +53,28 @@ export async function main() {
|
|
48
53
|
lpEnv,
|
49
54
|
});
|
50
55
|
|
51
|
-
await client.
|
56
|
+
await client.initializeNewSolautoPosition({
|
52
57
|
positionId: 1,
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
// ),
|
58
|
+
supplyMint: NATIVE_MINT,
|
59
|
+
debtMint: new PublicKey(USDC),
|
60
|
+
lpPoolAccount: getMarginfiAccounts("Prod").defaultGroup,
|
57
61
|
});
|
58
62
|
|
59
|
-
// const transactionItems = [rebalance(client)];
|
60
63
|
const transactionItems = [
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
openSolautoPosition(client, {
|
65
|
+
boostToBps: 2000,
|
66
|
+
boostGap: 50,
|
67
|
+
repayToBps: 5000,
|
68
|
+
repayGap: 50,
|
69
|
+
}),
|
70
|
+
deposit(client, toBaseUnit(0.5, 9)),
|
71
|
+
rebalance(client),
|
64
72
|
];
|
73
|
+
// const transactionItems = [
|
74
|
+
// new TransactionItem(
|
75
|
+
// async () => await buildSwbSubmitResponseTx(conn, signer, NATIVE_MINT)
|
76
|
+
// ),
|
77
|
+
// ];
|
65
78
|
|
66
79
|
const txManager = new ClientTransactionsManager({
|
67
80
|
txHandler: client,
|
package/package.json
CHANGED
@@ -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({
|