@haven-fi/solauto-sdk 1.0.608 → 1.0.610
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/services/solauto/solautoClient.d.ts.map +1 -1
- package/dist/services/solauto/solautoClient.js +2 -0
- package/dist/solautoPosition/solautoPositionEx.d.ts +5 -4
- package/dist/solautoPosition/solautoPositionEx.d.ts.map +1 -1
- package/dist/solautoPosition/solautoPositionEx.js +30 -15
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jitoUtils.js +7 -1
- package/package.json +1 -1
- package/src/services/solauto/solautoClient.ts +2 -0
- package/src/solautoPosition/solautoPositionEx.ts +45 -25
- package/src/utils/jitoUtils.ts +10 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../../src/services/solauto/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAEL,SAAS,EAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,gCAAgC,EAEhC,sBAAsB,EAGvB,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,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AAS,GAAG,SAAS;IAOnC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO;IAkB1C,mBAAmB,IAAI,MAAM,EAAE;IAS/B,gBAAgB,IAAI,SAAS,EAAE;IAoBzB,iCAAiC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAUzD,iBAAiB,IAAI,OAAO,CAC9B;QACE,EAAE,EAAE,kBAAkB,CAAC;QACvB,GAAG,EAAE,OAAO,CAAC;QACb,aAAa,EAAE,SAAS,EAAE,CAAC;KAC5B,GACD,SAAS,CACZ;IA4DK,cAAc,IAAI,OAAO,CAAC;QAC9B,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IA8CF,cAAc,CACZ,QAAQ,CAAC,EAAE,gCAAgC,EAC3C,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IA0BrB,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB;IAsDlE,QAAQ,CAAC,eAAe,IAAI,kBAAkB;IAE9C,WAAW,IAAI,kBAAkB;IAgCjC,QAAQ,CAAC,SAAS,IAAI,kBAAkB;IAExC,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAsFlE,QAAQ,CAAC,WAAW,CAClB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,gBAAgB,GACrB,kBAAkB;CACtB"}
|
@@ -94,6 +94,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
|
|
94
94
|
lutAccountsToAdd() {
|
95
95
|
return [
|
96
96
|
this.authority,
|
97
|
+
...(this.authorityLutAddress ? [this.authorityLutAddress] : []),
|
97
98
|
...((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey).equals(this.authority)
|
98
99
|
? [this.signerSupplyTa]
|
99
100
|
: []),
|
@@ -152,6 +153,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
|
|
152
153
|
})))
|
153
154
|
.add(await this.flProvider.flAccountPrereqIxs());
|
154
155
|
this.log("Requires authority LUT update...");
|
156
|
+
this.log("Addresses to add:", accountsToAdd.join(", "));
|
155
157
|
return {
|
156
158
|
tx,
|
157
159
|
new: existingLutAccounts.length === 0,
|
@@ -65,12 +65,13 @@ export declare abstract class SolautoPositionEx {
|
|
65
65
|
protected canRefreshPositionState(): boolean;
|
66
66
|
abstract refreshPositionState(): Promise<void>;
|
67
67
|
utilizationRateBpsDrift(): Promise<number>;
|
68
|
+
updateSupply(newSupplyUsd: number, supplyPrice?: number): void;
|
69
|
+
updateDebt(newDebtUsd: number, debtPrice?: number): void;
|
70
|
+
updateNetWorth(supplyPrice?: number): void;
|
71
|
+
updateLiqUtilizationRate(): void;
|
68
72
|
updateWithLatestPrices(supplyPrice?: number, debtPrice?: number): Promise<void>;
|
69
|
-
refetchPositionData(): Promise<void>;
|
70
|
-
updateNetWorth(supplyPrice: number, debtPrice: number): void;
|
71
|
-
updateSupply(newSupplyUsd: number, supplyPrice: number): void;
|
72
|
-
updateDebt(newDebtUsd: number, debtPrice: number): void;
|
73
73
|
simulateRebalance(unixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number): void;
|
74
|
+
refetchPositionData(): Promise<void>;
|
74
75
|
}
|
75
76
|
export {};
|
76
77
|
//# sourceMappingURL=solautoPositionEx.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoPositionEx.d.ts","sourceRoot":"","sources":["../../src/solautoPosition/solautoPositionEx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,WAAW,EAEX,eAAe,EACf,aAAa,EACb,eAAe,EACf,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAQL,cAAc,
|
1
|
+
{"version":3,"file":"solautoPositionEx.d.ts","sourceRoot":"","sources":["../../src/solautoP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,EACjB,2BAA2B,CAAC,EAAE,MAAM;IAkBhC,mBAAmB;CAM1B"}
|
@@ -147,34 +147,49 @@ class SolautoPositionEx {
|
|
147
147
|
const newState = await (0, utils_1.positionStateWithLatestPrices)(this.state(), supplyPrice, debtPrice);
|
148
148
|
return newState.liqUtilizationRateBps - oldState.liqUtilizationRateBps;
|
149
149
|
}
|
150
|
-
async updateWithLatestPrices(supplyPrice, debtPrice) {
|
151
|
-
this._data.state = await (0, utils_1.positionStateWithLatestPrices)(this.state(), supplyPrice, debtPrice);
|
152
|
-
}
|
153
|
-
async refetchPositionData() {
|
154
|
-
this._data = await (0, generated_1.fetchSolautoPosition)(this.umi, (0, umi_web3js_adapters_1.fromWeb3JsPublicKey)(this.publicKey));
|
155
|
-
}
|
156
|
-
updateNetWorth(supplyPrice, debtPrice) {
|
157
|
-
const netWorthUsd = this.supplyUsd() - this.debtUsd();
|
158
|
-
this._data.state.netWorth.baseAmountUsdValue =
|
159
|
-
(0, utils_1.toRoundedUsdValue)(netWorthUsd);
|
160
|
-
this._data.state.netWorth.baseUnit = (0, utils_1.toBaseUnit)(netWorthUsd / supplyPrice, this.supplyMintInfo().decimals);
|
161
|
-
}
|
162
150
|
updateSupply(newSupplyUsd, supplyPrice) {
|
163
151
|
this._data.state.supply.amountUsed.baseAmountUsdValue =
|
164
152
|
(0, utils_1.toRoundedUsdValue)(newSupplyUsd);
|
165
|
-
this._data.state.supply.amountUsed.baseUnit = (0, utils_1.toBaseUnit)(newSupplyUsd / supplyPrice, this.supplyMintInfo().decimals);
|
153
|
+
this._data.state.supply.amountUsed.baseUnit = (0, utils_1.toBaseUnit)(newSupplyUsd / (supplyPrice ?? (0, utils_1.safeGetPrice)(this.supplyMint()) ?? 0), this.supplyMintInfo().decimals);
|
166
154
|
}
|
167
155
|
updateDebt(newDebtUsd, debtPrice) {
|
168
156
|
this._data.state.debt.amountUsed.baseAmountUsdValue =
|
169
157
|
(0, utils_1.toRoundedUsdValue)(newDebtUsd);
|
170
|
-
this._data.state.debt.amountUsed.baseUnit = (0, utils_1.toBaseUnit)(newDebtUsd / debtPrice, this.debtMintInfo().decimals);
|
158
|
+
this._data.state.debt.amountUsed.baseUnit = (0, utils_1.toBaseUnit)(newDebtUsd / (debtPrice ?? (0, utils_1.safeGetPrice)(this.debtMint()) ?? 0), this.debtMintInfo().decimals);
|
159
|
+
}
|
160
|
+
updateNetWorth(supplyPrice) {
|
161
|
+
const netWorthUsd = this.supplyUsd() - this.debtUsd();
|
162
|
+
this._data.state.netWorth.baseAmountUsdValue =
|
163
|
+
(0, utils_1.toRoundedUsdValue)(netWorthUsd);
|
164
|
+
this._data.state.netWorth.baseUnit = (0, utils_1.toBaseUnit)(netWorthUsd / (supplyPrice ?? (0, utils_1.safeGetPrice)(this.supplyMint()) ?? 0), this.supplyMintInfo().decimals);
|
165
|
+
}
|
166
|
+
updateLiqUtilizationRate() {
|
167
|
+
this._data.state.liqUtilizationRateBps = (0, utils_1.getLiqUtilzationRateBps)(this.supplyUsd(), this.debtUsd(), this.state().liqThresholdBps);
|
168
|
+
}
|
169
|
+
async updateWithLatestPrices(supplyPrice, debtPrice) {
|
170
|
+
if (!supplyPrice || !debtPrice) {
|
171
|
+
[supplyPrice, debtPrice] = await (0, utils_1.fetchTokenPrices)([
|
172
|
+
this.supplyMint(),
|
173
|
+
this.debtMint(),
|
174
|
+
]);
|
175
|
+
}
|
176
|
+
const supplyUsd = this.totalSupply() * supplyPrice;
|
177
|
+
const debtUsd = this.totalDebt() * debtPrice;
|
178
|
+
this.updateSupply(supplyUsd, supplyPrice);
|
179
|
+
this.updateDebt(debtUsd, debtPrice);
|
180
|
+
this.updateNetWorth(supplyPrice);
|
181
|
+
this.updateLiqUtilizationRate();
|
171
182
|
}
|
172
183
|
simulateRebalance(unixTime, supplyPrice, debtPrice, targetLiqUtilizationRateBps) {
|
173
184
|
this._data.state.lastRefreshed = BigInt(unixTime);
|
174
185
|
const rebalance = (0, rebalance_1.getRebalanceValues)(this, targetLiqUtilizationRateBps, rebalance_1.SolautoFeesBps.create(true, targetLiqUtilizationRateBps, this.netWorthUsd()));
|
175
186
|
this.updateSupply(rebalance.endResult.supplyUsd, supplyPrice);
|
176
187
|
this.updateDebt(rebalance.endResult.debtUsd, debtPrice);
|
177
|
-
this.updateNetWorth(supplyPrice
|
188
|
+
this.updateNetWorth(supplyPrice);
|
189
|
+
this.updateLiqUtilizationRate();
|
190
|
+
}
|
191
|
+
async refetchPositionData() {
|
192
|
+
this._data = await (0, generated_1.fetchSolautoPosition)(this.umi, (0, umi_web3js_adapters_1.fromWeb3JsPublicKey)(this.publicKey));
|
178
193
|
}
|
179
194
|
}
|
180
195
|
exports.SolautoPositionEx = SolautoPositionEx;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAIV,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEH,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAYlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAgB,mBAAmB,IAAI,SAAS,CAG/C;AAkND,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB;;;;IAkB7D;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EAAE,EACtB,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CA+F/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -119,7 +119,13 @@ async function pollBundleStatus(umi, bundleId, interval = 1000, timeout = 40000)
|
|
119
119
|
const endTime = Date.now() + timeout;
|
120
120
|
while (Date.now() < endTime) {
|
121
121
|
await new Promise((resolve) => setTimeout(resolve, interval));
|
122
|
-
const statuses = await
|
122
|
+
const statuses = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
|
123
|
+
const resp = await getBundleStatus(umi, bundleId);
|
124
|
+
if (resp?.value?.length > 0 && resp.value[0] === null) {
|
125
|
+
throw new Error("No confirmation status");
|
126
|
+
}
|
127
|
+
return resp;
|
128
|
+
}, 3, 250);
|
123
129
|
if (statuses?.value?.length > 0) {
|
124
130
|
(0, generalUtils_1.consoleLog)("Statuses:", statuses);
|
125
131
|
const status = statuses.value[0].confirmation_status;
|
package/package.json
CHANGED
@@ -206,6 +206,7 @@ export abstract class SolautoClient extends ReferralStateManager {
|
|
206
206
|
lutAccountsToAdd(): PublicKey[] {
|
207
207
|
return [
|
208
208
|
this.authority,
|
209
|
+
...(this.authorityLutAddress ? [this.authorityLutAddress] : []),
|
209
210
|
...(toWeb3JsPublicKey(this.signer.publicKey).equals(this.authority)
|
210
211
|
? [this.signerSupplyTa]
|
211
212
|
: []),
|
@@ -291,6 +292,7 @@ export abstract class SolautoClient extends ReferralStateManager {
|
|
291
292
|
.add(await this.flProvider.flAccountPrereqIxs());
|
292
293
|
|
293
294
|
this.log("Requires authority LUT update...");
|
295
|
+
this.log("Addresses to add:", accountsToAdd.join(", "));
|
294
296
|
return {
|
295
297
|
tx,
|
296
298
|
new: existingLutAccounts.length === 0,
|
@@ -19,6 +19,8 @@ import {
|
|
19
19
|
ContextUpdates,
|
20
20
|
currentUnixSeconds,
|
21
21
|
debtLiquidityUsdAvailable,
|
22
|
+
fetchTokenPrices,
|
23
|
+
getLiqUtilzationRateBps,
|
22
24
|
maxBoostToBps,
|
23
25
|
maxRepayToBps,
|
24
26
|
positionStateWithLatestPrices,
|
@@ -289,47 +291,57 @@ export abstract class SolautoPositionEx {
|
|
289
291
|
return newState.liqUtilizationRateBps - oldState.liqUtilizationRateBps;
|
290
292
|
}
|
291
293
|
|
292
|
-
|
293
|
-
this._data.state =
|
294
|
-
|
295
|
-
|
296
|
-
|
294
|
+
updateSupply(newSupplyUsd: number, supplyPrice?: number) {
|
295
|
+
this._data.state.supply.amountUsed.baseAmountUsdValue =
|
296
|
+
toRoundedUsdValue(newSupplyUsd);
|
297
|
+
this._data.state.supply.amountUsed.baseUnit = toBaseUnit(
|
298
|
+
newSupplyUsd / (supplyPrice ?? safeGetPrice(this.supplyMint()) ?? 0),
|
299
|
+
this.supplyMintInfo().decimals
|
297
300
|
);
|
298
301
|
}
|
299
302
|
|
300
|
-
|
301
|
-
this._data =
|
302
|
-
|
303
|
-
|
303
|
+
updateDebt(newDebtUsd: number, debtPrice?: number) {
|
304
|
+
this._data.state.debt.amountUsed.baseAmountUsdValue =
|
305
|
+
toRoundedUsdValue(newDebtUsd);
|
306
|
+
this._data.state.debt.amountUsed.baseUnit = toBaseUnit(
|
307
|
+
newDebtUsd / (debtPrice ?? safeGetPrice(this.debtMint()) ?? 0),
|
308
|
+
this.debtMintInfo().decimals
|
304
309
|
);
|
305
310
|
}
|
306
311
|
|
307
|
-
updateNetWorth(supplyPrice
|
312
|
+
updateNetWorth(supplyPrice?: number) {
|
308
313
|
const netWorthUsd = this.supplyUsd() - this.debtUsd();
|
309
314
|
this._data.state.netWorth.baseAmountUsdValue =
|
310
315
|
toRoundedUsdValue(netWorthUsd);
|
311
316
|
this._data.state.netWorth.baseUnit = toBaseUnit(
|
312
|
-
netWorthUsd / supplyPrice,
|
317
|
+
netWorthUsd / (supplyPrice ?? safeGetPrice(this.supplyMint()) ?? 0),
|
313
318
|
this.supplyMintInfo().decimals
|
314
319
|
);
|
315
320
|
}
|
316
321
|
|
317
|
-
|
318
|
-
this._data.state.
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
this.supplyMintInfo().decimals
|
322
|
+
updateLiqUtilizationRate() {
|
323
|
+
this._data.state.liqUtilizationRateBps = getLiqUtilzationRateBps(
|
324
|
+
this.supplyUsd(),
|
325
|
+
this.debtUsd(),
|
326
|
+
this.state().liqThresholdBps
|
323
327
|
);
|
324
328
|
}
|
325
329
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
330
|
+
async updateWithLatestPrices(supplyPrice?: number, debtPrice?: number) {
|
331
|
+
if (!supplyPrice || !debtPrice) {
|
332
|
+
[supplyPrice, debtPrice] = await fetchTokenPrices([
|
333
|
+
this.supplyMint(),
|
334
|
+
this.debtMint(),
|
335
|
+
]);
|
336
|
+
}
|
337
|
+
|
338
|
+
const supplyUsd = this.totalSupply() * supplyPrice;
|
339
|
+
const debtUsd = this.totalDebt() * debtPrice;
|
340
|
+
|
341
|
+
this.updateSupply(supplyUsd, supplyPrice);
|
342
|
+
this.updateDebt(debtUsd, debtPrice);
|
343
|
+
this.updateNetWorth(supplyPrice);
|
344
|
+
this.updateLiqUtilizationRate();
|
333
345
|
}
|
334
346
|
|
335
347
|
simulateRebalance(
|
@@ -350,6 +362,14 @@ export abstract class SolautoPositionEx {
|
|
350
362
|
);
|
351
363
|
this.updateSupply(rebalance.endResult.supplyUsd, supplyPrice);
|
352
364
|
this.updateDebt(rebalance.endResult.debtUsd, debtPrice);
|
353
|
-
this.updateNetWorth(supplyPrice
|
365
|
+
this.updateNetWorth(supplyPrice);
|
366
|
+
this.updateLiqUtilizationRate();
|
367
|
+
}
|
368
|
+
|
369
|
+
async refetchPositionData() {
|
370
|
+
this._data = await fetchSolautoPosition(
|
371
|
+
this.umi,
|
372
|
+
fromWeb3JsPublicKey(this.publicKey)
|
373
|
+
);
|
354
374
|
}
|
355
375
|
}
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -6,9 +6,7 @@ import {
|
|
6
6
|
VersionedTransaction,
|
7
7
|
} from "@solana/web3.js";
|
8
8
|
import { toWeb3JsTransaction } from "@metaplex-foundation/umi-web3js-adapters";
|
9
|
-
import {
|
10
|
-
JITO_TIP_ACCOUNTS,
|
11
|
-
} from "../constants/solautoConstants";
|
9
|
+
import { JITO_TIP_ACCOUNTS } from "../constants/solautoConstants";
|
12
10
|
import {
|
13
11
|
Signer,
|
14
12
|
TransactionBuilder,
|
@@ -191,7 +189,15 @@ async function pollBundleStatus(
|
|
191
189
|
const endTime = Date.now() + timeout;
|
192
190
|
while (Date.now() < endTime) {
|
193
191
|
await new Promise((resolve) => setTimeout(resolve, interval));
|
194
|
-
|
192
|
+
|
193
|
+
const statuses = await retryWithExponentialBackoff(async () => {
|
194
|
+
const resp = await getBundleStatus(umi, bundleId);
|
195
|
+
if (resp?.value?.length > 0 && resp.value[0] === null) {
|
196
|
+
throw new Error("No confirmation status");
|
197
|
+
}
|
198
|
+
return resp;
|
199
|
+
}, 3, 250);
|
200
|
+
|
195
201
|
if (statuses?.value?.length > 0) {
|
196
202
|
consoleLog("Statuses:", statuses);
|
197
203
|
const status = statuses.value[0].confirmation_status;
|