haedal-lending-vault 1.0.0 → 1.0.2
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/README.md +4 -4
- package/dist/config.js +1 -1
- package/dist/index.js +137 -104
- package/package.json +6 -6
- package/types/src/client/LLVClient.d.ts +0 -1
- package/types/src/config/mainnetWalletDeployment.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# Haedal Lending Vault SDK
|
|
2
2
|
|
|
3
|
-
Use `haedal-lending-vault@1.0.
|
|
3
|
+
Use `haedal-lending-vault@1.0.2` with Node 24 and `@mysten/sui@2.31.3`. The SDK reads pool and position data and builds Sui transactions. Your connected wallet supplies the account address, signs transactions and submits them.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
Install the delivered archive in your application:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npm install --save-exact ./haedal-lending-vault-1.0.
|
|
10
|
+
npm install --save-exact ./haedal-lending-vault-1.0.2.tgz @mysten/sui@2.31.3
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
If this version is available on the public npm registry:
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
|
-
npm install --save-exact haedal-lending-vault@1.0.
|
|
16
|
+
npm install --save-exact haedal-lending-vault@1.0.2 @mysten/sui@2.31.3
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Use package exports for imports. TypeScript consumers should use `moduleResolution: "NodeNext"` or `"Bundler"` and an ES2022 target for `bigint`.
|
|
@@ -225,7 +225,7 @@ Object.assign(globalThis, { Buffer });
|
|
|
225
225
|
// await import("./vault-integration.js");
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
Your existing wallet adapter can implement `SubmitTransaction`. If choosing `@mysten/dapp-kit-core@1.6.0` with Sui 2.31.
|
|
228
|
+
Your existing wallet adapter can implement `SubmitTransaction`. If choosing `@mysten/dapp-kit-core@1.6.0` with Sui 2.31.3, pin `@mysten/slush-wallet` to 1.2.4 and `@mysten/wallet-standard` to 0.21.26 in your application's npm `overrides` to keep that dependency combination compatible.
|
|
229
229
|
|
|
230
230
|
## Public API
|
|
231
231
|
|
package/dist/config.js
CHANGED
|
@@ -23,7 +23,7 @@ var mainnetWalletDeployment = {
|
|
|
23
23
|
"liquidityLayerPackageId": "0x3777fbddf314316bb4b3618538255b09eff5460de094f5084f21edbeacbec9a8",
|
|
24
24
|
"liquidityLayerOriginalPackageId": "0x3777fbddf314316bb4b3618538255b09eff5460de094f5084f21edbeacbec9a8",
|
|
25
25
|
"llvGlobalId": "0x00b91a04f89f4bbdb98d52fb08b6652f3277ed6bd821817f8b0aa54a6fa9f233",
|
|
26
|
-
"suilendPackageId": "
|
|
26
|
+
"suilendPackageId": "0xd63e95654c6f6148db349782c5f1d324bca055a7bdbd36830e92edcfca958037",
|
|
27
27
|
"scallopPackageId": "0x8c2fcc3af98331ee0f293bca262e26b6e2c8eeabc2042032d739cc83bd19697e",
|
|
28
28
|
"naviPackageId": "0x9d413ab9ae6cb58ba1189de65ac39b201a5ada39018840ee88ecfe25a856923e",
|
|
29
29
|
"cetusPackageId": "0x2987edc5c5f9eee33df9504e5ed5c35cafd469e8ef1cf8602aed4ae6464f1118",
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,84 @@ import {
|
|
|
60
60
|
parseProtocolError
|
|
61
61
|
} from "./chunk-CLSDR2XU.js";
|
|
62
62
|
|
|
63
|
+
// src/suilend-price-updater.ts
|
|
64
|
+
import { SuilendClient } from "@suilend/sdk/client";
|
|
65
|
+
import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
|
|
66
|
+
|
|
67
|
+
// src/refresh-dedup.ts
|
|
68
|
+
var txState = /* @__PURE__ */ new WeakMap();
|
|
69
|
+
function getOrInitRefreshState(tx) {
|
|
70
|
+
let s = txState.get(tx);
|
|
71
|
+
if (!s) {
|
|
72
|
+
s = {
|
|
73
|
+
naviPythAppended: false,
|
|
74
|
+
marketRefreshed: /* @__PURE__ */ new Set(),
|
|
75
|
+
naviOraclePreupdated: false,
|
|
76
|
+
suilendPricePreupdated: false,
|
|
77
|
+
currentOraclePreupdated: false,
|
|
78
|
+
alphalendLazerAppended: false,
|
|
79
|
+
alphalendTokenPriceRefreshed: /* @__PURE__ */ new Set()
|
|
80
|
+
};
|
|
81
|
+
txState.set(tx, s);
|
|
82
|
+
}
|
|
83
|
+
return s;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/suilend-price-updater.ts
|
|
87
|
+
var HAEDAL_SUILEND_HERMES_URL = "https://www.haedal.xyz";
|
|
88
|
+
function looksLikeNativeSuiGrpcClient(client) {
|
|
89
|
+
const candidate = client;
|
|
90
|
+
return Boolean(candidate?.core) && typeof candidate?.getObject === "function" && typeof candidate?.simulateTransaction === "function" && typeof candidate?.listOwnedObjects === "function";
|
|
91
|
+
}
|
|
92
|
+
function tryUnwrapSuiGrpcClient(client) {
|
|
93
|
+
const nested = client?.__rawGrpcClient;
|
|
94
|
+
const candidate = nested ?? client;
|
|
95
|
+
return looksLikeNativeSuiGrpcClient(candidate) ? candidate : void 0;
|
|
96
|
+
}
|
|
97
|
+
function unwrapSuiGrpcClient(client) {
|
|
98
|
+
const unwrapped = tryUnwrapSuiGrpcClient(client);
|
|
99
|
+
if (!unwrapped) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
"[suilend] Pro price refresh requires an unwrapped SuiGrpcClient; JSON-RPC adapters are not supported"
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return unwrapped;
|
|
105
|
+
}
|
|
106
|
+
function normalizeObjectId(objectId) {
|
|
107
|
+
return `0x${objectId.replace(/^0x/, "").replace(/^0+/, "") || "0"}`.toLowerCase();
|
|
108
|
+
}
|
|
109
|
+
function feedIdFromBytes(bytes) {
|
|
110
|
+
return `0x${Array.from(bytes).map((byte) => Number(byte).toString(16).padStart(2, "0")).join("")}`;
|
|
111
|
+
}
|
|
112
|
+
async function appendSuilendRefreshCalls(tx, context) {
|
|
113
|
+
const suiGrpcClient = unwrapSuiGrpcClient(context.suiGrpcClient);
|
|
114
|
+
const client = await SuilendClient.initialize(
|
|
115
|
+
context.lendingMarketId,
|
|
116
|
+
context.lendingMarketType,
|
|
117
|
+
suiGrpcClient
|
|
118
|
+
);
|
|
119
|
+
client.pythConnection = new SuiPriceServiceConnection(
|
|
120
|
+
HAEDAL_SUILEND_HERMES_URL
|
|
121
|
+
);
|
|
122
|
+
const reserveArrayIndex = client.findReserveArrayIndex(context.assetType);
|
|
123
|
+
if (reserveArrayIndex < 0) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`[suilend] asset ${context.assetType} is not a reserve in ${context.lendingMarketId}`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
const reserve = client.lendingMarket.reserves[Number(reserveArrayIndex)];
|
|
129
|
+
const resolvedPriceInfoObjectId = await client.pythClient.getPriceFeedObjectId(
|
|
130
|
+
feedIdFromBytes(reserve.priceIdentifier.bytes)
|
|
131
|
+
);
|
|
132
|
+
if (!resolvedPriceInfoObjectId || normalizeObjectId(resolvedPriceInfoObjectId) !== normalizeObjectId(context.expectedPriceInfoObjectId)) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`[suilend] pool PriceInfoObject ${context.expectedPriceInfoObjectId} does not match the official Pro registry result ${resolvedPriceInfoObjectId ?? "<missing>"}`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
await client.refreshAll(tx, void 0, [context.assetType]);
|
|
138
|
+
getOrInitRefreshState(tx).suilendPricePreupdated = true;
|
|
139
|
+
}
|
|
140
|
+
|
|
63
141
|
// src/client/LLVClient.ts
|
|
64
142
|
import { Transaction as Transaction8 } from "@mysten/sui/transactions";
|
|
65
143
|
|
|
@@ -4437,6 +4515,11 @@ async function readPoolRouteState(ctx, poolId) {
|
|
|
4437
4515
|
};
|
|
4438
4516
|
}
|
|
4439
4517
|
|
|
4518
|
+
// src/readers/protocolAvailabilityReaders.ts
|
|
4519
|
+
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
4520
|
+
import { phantom } from "@suilend/sdk/_generated/_framework/reified";
|
|
4521
|
+
import { LendingMarket } from "@suilend/sdk/_generated/suilend/lending-market/structs";
|
|
4522
|
+
|
|
4440
4523
|
// src/protocol-limits.ts
|
|
4441
4524
|
function asRecord2(value) {
|
|
4442
4525
|
return typeof value === "object" && value !== null ? value : null;
|
|
@@ -4867,12 +4950,43 @@ async function readCurrentBuiltInAvailability(ctx, poolId) {
|
|
|
4867
4950
|
}
|
|
4868
4951
|
};
|
|
4869
4952
|
}
|
|
4870
|
-
async function
|
|
4871
|
-
|
|
4953
|
+
async function readSuilendLimits(ctx, config) {
|
|
4954
|
+
if (ctx.suilendGrpcClient) {
|
|
4955
|
+
const market = await LendingMarket.fetch(
|
|
4956
|
+
ctx.suilendGrpcClient,
|
|
4957
|
+
phantom(config.suilendPType),
|
|
4958
|
+
config.suilendMarketId
|
|
4959
|
+
);
|
|
4960
|
+
const reserve = market.reserves[config.suilendReserveIdx];
|
|
4961
|
+
if (!reserve || normalizeStructTag(reserve.coinType) !== normalizeStructTag(config.assetType)) {
|
|
4962
|
+
throw new Error("Suilend reserve index does not match the configured pool asset");
|
|
4963
|
+
}
|
|
4964
|
+
const fields2 = reserve.config.element;
|
|
4965
|
+
return {
|
|
4966
|
+
depositLimit: fields2?.depositLimit ?? null,
|
|
4967
|
+
depositLimitUsd: fields2?.depositLimitUsd ?? null,
|
|
4968
|
+
reportedSupply: null
|
|
4969
|
+
};
|
|
4970
|
+
}
|
|
4872
4971
|
const reserveFields = selectVecLikeEntry(
|
|
4873
4972
|
(await readObjectFields(ctx.provider, config.suilendMarketId)).reserves,
|
|
4874
4973
|
config.suilendReserveIdx
|
|
4875
4974
|
);
|
|
4975
|
+
const cell = getMoveStructFields(reserveFields?.config);
|
|
4976
|
+
const element = getMoveStructFields(cell?.element);
|
|
4977
|
+
const option = element?.vec ?? cell?.element;
|
|
4978
|
+
const fields = Array.isArray(option) ? getMoveStructFields(option[0]) : element ?? (cell && !("element" in cell) ? cell : null);
|
|
4979
|
+
const depositLimit = normalizeBigIntValue(fields?.deposit_limit ?? fields?.depositLimit);
|
|
4980
|
+
const depositLimitUsd = normalizeBigIntValue(fields?.deposit_limit_usd ?? fields?.depositLimitUsd);
|
|
4981
|
+
return {
|
|
4982
|
+
depositLimit,
|
|
4983
|
+
depositLimitUsd,
|
|
4984
|
+
reportedSupply: normalizeBigIntValue(reserveFields?.total_supply ?? reserveFields?.totalSupply)
|
|
4985
|
+
};
|
|
4986
|
+
}
|
|
4987
|
+
async function readSuilendBuiltInAvailability(ctx, poolId) {
|
|
4988
|
+
const config = await getSuilendConfigFromPool(ctx.provider, poolId);
|
|
4989
|
+
const { depositLimit, depositLimitUsd, reportedSupply } = await readSuilendLimits(ctx, config);
|
|
4876
4990
|
const ctokenRatio = await devInspectMoveCallU128Pair(ctx.provider, {
|
|
4877
4991
|
sender: AVAILABILITY_INSPECT_SENDER2,
|
|
4878
4992
|
target: `${ctx.extPackageForProtocol(PROTOCOL_SUILEND)}::suilend_adapter::get_ctoken_ratio`,
|
|
@@ -4885,16 +4999,8 @@ async function readSuilendBuiltInAvailability(ctx, poolId) {
|
|
|
4885
4999
|
typeArguments: [config.suilendPType, config.assetType],
|
|
4886
5000
|
buildArguments: (tx) => [tx.object(config.suilendMarketId)]
|
|
4887
5001
|
});
|
|
4888
|
-
const
|
|
4889
|
-
|
|
4890
|
-
"depositLimit"
|
|
4891
|
-
]);
|
|
4892
|
-
const depositLimitUsd = findFirstBigIntDeep(reserveFields, [
|
|
4893
|
-
"deposit_limit_usd",
|
|
4894
|
-
"depositLimitUsd"
|
|
4895
|
-
]);
|
|
4896
|
-
const currentSupply = ctokenRatio?.[0] ?? findFirstBigIntDeep(reserveFields, ["total_supply", "totalSupply"]);
|
|
4897
|
-
const depositRemaining = maxRemaining(depositLimit, currentSupply);
|
|
5002
|
+
const currentSupply = ctokenRatio?.[0] ?? reportedSupply;
|
|
5003
|
+
const depositRemaining = depositLimit === 0n || depositLimitUsd === 0n ? 0n : maxRemaining(depositLimit, currentSupply);
|
|
4898
5004
|
const limits = [
|
|
4899
5005
|
protocolAvailabilityLimit(
|
|
4900
5006
|
"available_liquidity",
|
|
@@ -4919,7 +5025,8 @@ async function readSuilendBuiltInAvailability(ctx, poolId) {
|
|
|
4919
5025
|
depositLimitUsd,
|
|
4920
5026
|
"estimated",
|
|
4921
5027
|
"onchain",
|
|
4922
|
-
"SuiLend reserve config deposit_limit_usd; price freshness affects exact cap"
|
|
5028
|
+
"SuiLend reserve config deposit_limit_usd in whole USD; price freshness affects exact cap",
|
|
5029
|
+
"raw"
|
|
4923
5030
|
));
|
|
4924
5031
|
}
|
|
4925
5032
|
if (ctokenRatio) {
|
|
@@ -4944,7 +5051,7 @@ async function readSuilendBuiltInAvailability(ctx, poolId) {
|
|
|
4944
5051
|
maxDepositByProtocol: protocolAvailabilityAmount(
|
|
4945
5052
|
depositRemaining,
|
|
4946
5053
|
depositRemaining === null ? "unavailable" : "estimated",
|
|
4947
|
-
|
|
5054
|
+
"onchain",
|
|
4948
5055
|
depositRemaining === null ? "SuiLend reserve deposit cap fields could not be decoded" : "SuiLend deposit_limit minus current reserve supply"
|
|
4949
5056
|
),
|
|
4950
5057
|
maxWithdrawByProtocol: protocolAvailabilityAmount(
|
|
@@ -5663,6 +5770,7 @@ var LLVClientContexts = class {
|
|
|
5663
5770
|
protocolAvailabilityReaderContext(provider = this.rpc) {
|
|
5664
5771
|
return {
|
|
5665
5772
|
provider,
|
|
5773
|
+
suilendGrpcClient: this.context.suilendGrpcClient,
|
|
5666
5774
|
packageId: this.packageId,
|
|
5667
5775
|
clockId: this.config.clockId,
|
|
5668
5776
|
shareTokenType: this.config.shareTokenType,
|
|
@@ -5674,25 +5782,6 @@ var LLVClientContexts = class {
|
|
|
5674
5782
|
}
|
|
5675
5783
|
};
|
|
5676
5784
|
|
|
5677
|
-
// src/refresh-dedup.ts
|
|
5678
|
-
var txState = /* @__PURE__ */ new WeakMap();
|
|
5679
|
-
function getOrInitRefreshState(tx) {
|
|
5680
|
-
let s = txState.get(tx);
|
|
5681
|
-
if (!s) {
|
|
5682
|
-
s = {
|
|
5683
|
-
naviPythAppended: false,
|
|
5684
|
-
marketRefreshed: /* @__PURE__ */ new Set(),
|
|
5685
|
-
naviOraclePreupdated: false,
|
|
5686
|
-
suilendPricePreupdated: false,
|
|
5687
|
-
currentOraclePreupdated: false,
|
|
5688
|
-
alphalendLazerAppended: false,
|
|
5689
|
-
alphalendTokenPriceRefreshed: /* @__PURE__ */ new Set()
|
|
5690
|
-
};
|
|
5691
|
-
txState.set(tx, s);
|
|
5692
|
-
}
|
|
5693
|
-
return s;
|
|
5694
|
-
}
|
|
5695
|
-
|
|
5696
5785
|
// src/navi-sdk-oracle.ts
|
|
5697
5786
|
import * as NaviLending from "@naviprotocol/lending";
|
|
5698
5787
|
var NAVI_ORACLE_UPDATE_FUNCTION = "update_single_price_v3";
|
|
@@ -5780,63 +5869,6 @@ async function appendNaviSdkOracleUpdate(tx, params, deps = {}) {
|
|
|
5780
5869
|
return resolved;
|
|
5781
5870
|
}
|
|
5782
5871
|
|
|
5783
|
-
// src/suilend-price-updater.ts
|
|
5784
|
-
import { SuilendClient } from "@suilend/sdk/client";
|
|
5785
|
-
import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
|
|
5786
|
-
var HAEDAL_SUILEND_HERMES_URL = "https://lv-user.haedal.xyz";
|
|
5787
|
-
function looksLikeNativeSuiGrpcClient(client) {
|
|
5788
|
-
const candidate = client;
|
|
5789
|
-
return Boolean(candidate?.core) && typeof candidate?.getObject === "function" && typeof candidate?.simulateTransaction === "function" && typeof candidate?.listOwnedObjects === "function";
|
|
5790
|
-
}
|
|
5791
|
-
function tryUnwrapSuiGrpcClient(client) {
|
|
5792
|
-
const nested = client?.__rawGrpcClient;
|
|
5793
|
-
const candidate = nested ?? client;
|
|
5794
|
-
return looksLikeNativeSuiGrpcClient(candidate) ? candidate : void 0;
|
|
5795
|
-
}
|
|
5796
|
-
function unwrapSuiGrpcClient(client) {
|
|
5797
|
-
const unwrapped = tryUnwrapSuiGrpcClient(client);
|
|
5798
|
-
if (!unwrapped) {
|
|
5799
|
-
throw new Error(
|
|
5800
|
-
"[suilend] Pro price refresh requires an unwrapped SuiGrpcClient; JSON-RPC adapters are not supported"
|
|
5801
|
-
);
|
|
5802
|
-
}
|
|
5803
|
-
return unwrapped;
|
|
5804
|
-
}
|
|
5805
|
-
function normalizeObjectId(objectId) {
|
|
5806
|
-
return `0x${objectId.replace(/^0x/, "").replace(/^0+/, "") || "0"}`.toLowerCase();
|
|
5807
|
-
}
|
|
5808
|
-
function feedIdFromBytes(bytes) {
|
|
5809
|
-
return `0x${Array.from(bytes).map((byte) => Number(byte).toString(16).padStart(2, "0")).join("")}`;
|
|
5810
|
-
}
|
|
5811
|
-
async function appendSuilendRefreshCalls(tx, context) {
|
|
5812
|
-
const suiGrpcClient = unwrapSuiGrpcClient(context.suiGrpcClient);
|
|
5813
|
-
const client = await SuilendClient.initialize(
|
|
5814
|
-
context.lendingMarketId,
|
|
5815
|
-
context.lendingMarketType,
|
|
5816
|
-
suiGrpcClient
|
|
5817
|
-
);
|
|
5818
|
-
client.pythConnection = new SuiPriceServiceConnection(
|
|
5819
|
-
HAEDAL_SUILEND_HERMES_URL
|
|
5820
|
-
);
|
|
5821
|
-
const reserveArrayIndex = client.findReserveArrayIndex(context.assetType);
|
|
5822
|
-
if (reserveArrayIndex < 0) {
|
|
5823
|
-
throw new Error(
|
|
5824
|
-
`[suilend] asset ${context.assetType} is not a reserve in ${context.lendingMarketId}`
|
|
5825
|
-
);
|
|
5826
|
-
}
|
|
5827
|
-
const reserve = client.lendingMarket.reserves[Number(reserveArrayIndex)];
|
|
5828
|
-
const resolvedPriceInfoObjectId = await client.pythClient.getPriceFeedObjectId(
|
|
5829
|
-
feedIdFromBytes(reserve.priceIdentifier.bytes)
|
|
5830
|
-
);
|
|
5831
|
-
if (!resolvedPriceInfoObjectId || normalizeObjectId(resolvedPriceInfoObjectId) !== normalizeObjectId(context.expectedPriceInfoObjectId)) {
|
|
5832
|
-
throw new Error(
|
|
5833
|
-
`[suilend] pool PriceInfoObject ${context.expectedPriceInfoObjectId} does not match the official Pro registry result ${resolvedPriceInfoObjectId ?? "<missing>"}`
|
|
5834
|
-
);
|
|
5835
|
-
}
|
|
5836
|
-
await client.refreshAll(tx, void 0, [context.assetType]);
|
|
5837
|
-
getOrInitRefreshState(tx).suilendPricePreupdated = true;
|
|
5838
|
-
}
|
|
5839
|
-
|
|
5840
5872
|
// src/lazer-price-updater.ts
|
|
5841
5873
|
import { Inputs } from "@mysten/sui/transactions";
|
|
5842
5874
|
var LAZER_FETCH_TIMEOUT_MS = 4e3;
|
|
@@ -5922,7 +5954,7 @@ async function appendAlphaLendLazerUpdate(tx, config, options = {}) {
|
|
|
5922
5954
|
}
|
|
5923
5955
|
|
|
5924
5956
|
// src/current-price-updater.ts
|
|
5925
|
-
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
5957
|
+
import { normalizeStructTag as normalizeStructTag2 } from "@mysten/sui/utils";
|
|
5926
5958
|
var CurrentOracleProfileUnsupportedError = class extends Error {
|
|
5927
5959
|
constructor(assetType, reason) {
|
|
5928
5960
|
super(`[current-oracle] ${assetType}: ${reason}`);
|
|
@@ -5930,11 +5962,11 @@ var CurrentOracleProfileUnsupportedError = class extends Error {
|
|
|
5930
5962
|
this.reason = reason;
|
|
5931
5963
|
}
|
|
5932
5964
|
};
|
|
5933
|
-
var SUI_ASSET =
|
|
5934
|
-
var USDC_ASSET =
|
|
5965
|
+
var SUI_ASSET = normalizeStructTag2("0x2::sui::SUI");
|
|
5966
|
+
var USDC_ASSET = normalizeStructTag2(
|
|
5935
5967
|
"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"
|
|
5936
5968
|
);
|
|
5937
|
-
var HASUI_ASSET =
|
|
5969
|
+
var HASUI_ASSET = normalizeStructTag2(
|
|
5938
5970
|
"0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
|
|
5939
5971
|
);
|
|
5940
5972
|
var CURRENT_PYTH_FEED_IDS = /* @__PURE__ */ new Map([
|
|
@@ -5942,19 +5974,19 @@ var CURRENT_PYTH_FEED_IDS = /* @__PURE__ */ new Map([
|
|
|
5942
5974
|
[USDC_ASSET, 7],
|
|
5943
5975
|
[HASUI_ASSET, 3244],
|
|
5944
5976
|
[
|
|
5945
|
-
|
|
5977
|
+
normalizeStructTag2(
|
|
5946
5978
|
"0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT"
|
|
5947
5979
|
),
|
|
5948
5980
|
8
|
|
5949
5981
|
],
|
|
5950
5982
|
[
|
|
5951
|
-
|
|
5983
|
+
normalizeStructTag2(
|
|
5952
5984
|
"0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH"
|
|
5953
5985
|
),
|
|
5954
5986
|
2
|
|
5955
5987
|
],
|
|
5956
5988
|
[
|
|
5957
|
-
|
|
5989
|
+
normalizeStructTag2(
|
|
5958
5990
|
"0x3e8e9423d80e1774a7ca128fccd8bf5f1f7753be658c5e645929037f7c819040::lbtc::LBTC"
|
|
5959
5991
|
),
|
|
5960
5992
|
468
|
|
@@ -5964,21 +5996,21 @@ var PYTH_STORK_ASSETS = new Set([
|
|
|
5964
5996
|
SUI_ASSET,
|
|
5965
5997
|
"0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH",
|
|
5966
5998
|
"0x3e8e9423d80e1774a7ca128fccd8bf5f1f7753be658c5e645929037f7c819040::lbtc::LBTC"
|
|
5967
|
-
].map(
|
|
5999
|
+
].map(normalizeStructTag2));
|
|
5968
6000
|
var PYTH_ADMIN_REF_ASSETS = new Set([
|
|
5969
6001
|
USDC_ASSET,
|
|
5970
6002
|
"0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
|
|
5971
6003
|
HASUI_ASSET
|
|
5972
|
-
].map(
|
|
6004
|
+
].map(normalizeStructTag2));
|
|
5973
6005
|
var UNSUPPORTED_ASSET_REASONS = /* @__PURE__ */ new Map([
|
|
5974
6006
|
[
|
|
5975
|
-
|
|
6007
|
+
normalizeStructTag2(
|
|
5976
6008
|
"0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI"
|
|
5977
6009
|
),
|
|
5978
6010
|
"Current official API's Pyth update currently fails xOracle freshness validation"
|
|
5979
6011
|
],
|
|
5980
6012
|
[
|
|
5981
|
-
|
|
6013
|
+
normalizeStructTag2(
|
|
5982
6014
|
"0x876a4b7bce8aeaef60464c11f4026903e9afacab79b9b142686158aa86560b50::xbtc::XBTC"
|
|
5983
6015
|
),
|
|
5984
6016
|
"requires a verified Stork update and Current API Pyth data currently fails confidence validation"
|
|
@@ -5987,7 +6019,7 @@ var UNSUPPORTED_ASSET_REASONS = /* @__PURE__ */ new Map([
|
|
|
5987
6019
|
var CURRENT_ORACLE_FETCH_TIMEOUT_MS = 4e3;
|
|
5988
6020
|
var CURRENT_ORACLE_POST_FETCH_DELAY_MS = 1e3;
|
|
5989
6021
|
function profileFor(assetType) {
|
|
5990
|
-
const normalized =
|
|
6022
|
+
const normalized = normalizeStructTag2(assetType);
|
|
5991
6023
|
if (PYTH_STORK_ASSETS.has(normalized)) return "pyth-stork";
|
|
5992
6024
|
if (PYTH_ADMIN_REF_ASSETS.has(normalized)) return "pyth-admin-ref";
|
|
5993
6025
|
throw new CurrentOracleProfileUnsupportedError(
|
|
@@ -5996,7 +6028,7 @@ function profileFor(assetType) {
|
|
|
5996
6028
|
);
|
|
5997
6029
|
}
|
|
5998
6030
|
function canonicalOracleApiType(assetType) {
|
|
5999
|
-
const [address, ...rest] =
|
|
6031
|
+
const [address, ...rest] = normalizeStructTag2(assetType).split("::");
|
|
6000
6032
|
if (!address || rest.length < 2) {
|
|
6001
6033
|
throw new Error(`[current-oracle] invalid asset type ${assetType}`);
|
|
6002
6034
|
}
|
|
@@ -6164,7 +6196,7 @@ async function appendCurrentOracleUpdateInner(tx, params) {
|
|
|
6164
6196
|
if (!Number.isFinite(postFetchDelayMs) || postFetchDelayMs < 0) {
|
|
6165
6197
|
throw new Error("[current-oracle] postFetchDelayMs must be a non-negative finite number");
|
|
6166
6198
|
}
|
|
6167
|
-
const assetType =
|
|
6199
|
+
const assetType = normalizeStructTag2(params.assetType);
|
|
6168
6200
|
const assets = assetType === HASUI_ASSET ? [assetType, SUI_ASSET] : [assetType];
|
|
6169
6201
|
const profiles = assets.map(profileFor);
|
|
6170
6202
|
const feedIds = assets.map((currentAssetType) => {
|
|
@@ -6512,6 +6544,7 @@ var LLVClient = class {
|
|
|
6512
6544
|
this.contexts = new LLVClientContexts({
|
|
6513
6545
|
getConfig: () => this.config,
|
|
6514
6546
|
getRpc: () => this.rpc,
|
|
6547
|
+
suilendGrpcClient: tryUnwrapSuiGrpcClient(provider),
|
|
6515
6548
|
extPackageForProtocol: (protocolId) => this.extPkg(protocolId),
|
|
6516
6549
|
isReceiptDrivenProtocol: (protocolId) => this.isReceiptDrivenProtocol(protocolId),
|
|
6517
6550
|
clampU64: (value) => this.clampU64(value),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "haedal-lending-vault",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Haedal Lending Vault user SDK",
|
|
6
6
|
"publishConfig": {
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"README.md"
|
|
61
61
|
],
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@
|
|
63
|
+
"@suilend/sdk": "14.2.1",
|
|
64
|
+
"@pythnetwork/pyth-sui-js": "^2.4.0",
|
|
65
|
+
"@mysten/sui": "2.31.3",
|
|
64
66
|
"bn.js": "^5.2.1",
|
|
65
67
|
"decimal.js": "^10.4.3",
|
|
66
|
-
"@mysten/bcs": "2.
|
|
68
|
+
"@mysten/bcs": "2.1.1",
|
|
67
69
|
"bignumber.js": "^9.1.1",
|
|
68
|
-
"@naviprotocol/lending": "2.0.7"
|
|
69
|
-
"@suilend/sdk": "8.0.0",
|
|
70
|
-
"@pythnetwork/pyth-sui-js": "^2.4.0"
|
|
70
|
+
"@naviprotocol/lending": "2.0.7"
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** User deposits enter Idle; withdrawals use Idle or the configured fallback queue. */
|
|
2
1
|
import { Transaction } from "@mysten/sui/transactions";
|
|
3
2
|
import { type UserWithdrawAvailability } from "../withdraw-availability.js";
|
|
4
3
|
import type { LLVProvider } from "../provider/types.js";
|
|
@@ -4,7 +4,7 @@ export declare const mainnetWalletDeployment: {
|
|
|
4
4
|
readonly liquidityLayerPackageId: "0x3777fbddf314316bb4b3618538255b09eff5460de094f5084f21edbeacbec9a8";
|
|
5
5
|
readonly liquidityLayerOriginalPackageId: "0x3777fbddf314316bb4b3618538255b09eff5460de094f5084f21edbeacbec9a8";
|
|
6
6
|
readonly llvGlobalId: "0x00b91a04f89f4bbdb98d52fb08b6652f3277ed6bd821817f8b0aa54a6fa9f233";
|
|
7
|
-
readonly suilendPackageId: "
|
|
7
|
+
readonly suilendPackageId: "0xd63e95654c6f6148db349782c5f1d324bca055a7bdbd36830e92edcfca958037";
|
|
8
8
|
readonly scallopPackageId: "0x8c2fcc3af98331ee0f293bca262e26b6e2c8eeabc2042032d739cc83bd19697e";
|
|
9
9
|
readonly naviPackageId: "0x9d413ab9ae6cb58ba1189de65ac39b201a5ada39018840ee88ecfe25a856923e";
|
|
10
10
|
readonly cetusPackageId: "0x2987edc5c5f9eee33df9504e5ed5c35cafd469e8ef1cf8602aed4ae6464f1118";
|