@suilend/sdk 6.0.1 → 6.0.3
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/client.js +19 -2
- package/lib/pythAdapter.d.ts +67 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -12,7 +12,6 @@ import { Obligation } from "./_generated/suilend/obligation/structs.js";
|
|
|
12
12
|
import { newConfig as createRateLimiterConfig, } from "./_generated/suilend/rate-limiter/functions.js";
|
|
13
13
|
import { createReserveConfig, } from "./_generated/suilend/reserve-config/functions.js";
|
|
14
14
|
import { PRIMARY_PYTH_ENDPOINT } from "./lib/pyth.js";
|
|
15
|
-
import { createJsonRpcAdapter } from "./lib/pythAdapter.js";
|
|
16
15
|
import { Side } from "./lib/types.js";
|
|
17
16
|
import { chunkedMultiGet } from "./utils/obligation.js";
|
|
18
17
|
const SUI_COINTYPE = "0x2::sui::SUI";
|
|
@@ -136,7 +135,25 @@ export class SuilendClient {
|
|
|
136
135
|
constructor(lendingMarket, suiGrpcClient) {
|
|
137
136
|
this.lendingMarket = lendingMarket;
|
|
138
137
|
this.suiGrpcClient = suiGrpcClient;
|
|
139
|
-
|
|
138
|
+
// The grpc client goes in DIRECTLY, not through createJsonRpcAdapter.
|
|
139
|
+
//
|
|
140
|
+
// pyth v4's SuiPythClient reads through `provider.core.getObject` and
|
|
141
|
+
// `provider.core.getDynamicField`; v2 read the legacy top-level
|
|
142
|
+
// `provider.getObject` / `getDynamicFieldObject`. The class name survived the
|
|
143
|
+
// major bump, its provider contract did not — so the adapter, which produces
|
|
144
|
+
// exactly that legacy shape and has no `.core`, made every call through
|
|
145
|
+
// pythClient throw "Cannot read properties of undefined (reading
|
|
146
|
+
// 'getDynamicField')". That is the on-chain price-update path, i.e. every
|
|
147
|
+
// deposit/withdraw/borrow/repay, and nothing read-only touches it.
|
|
148
|
+
//
|
|
149
|
+
// `SuiGrpcClient` satisfies v4's `ClientWithCoreApi` natively, so no adapter
|
|
150
|
+
// is needed here at all. The adapter's hardcoded price-table fallback is also
|
|
151
|
+
// obsolete: `core.getDynamicField` resolves the pyth `price_info` wrapper over
|
|
152
|
+
// grpc and returns the same table id the adapter had pinned.
|
|
153
|
+
//
|
|
154
|
+
// createJsonRpcAdapter is still exported — the indexer's bluefin swapper
|
|
155
|
+
// needs the legacy shape — it just must not be used for pyth v4.
|
|
156
|
+
this.pythClient = new SuiPythClient(suiGrpcClient, PYTH_STATE_ID, WORMHOLE_STATE_ID);
|
|
140
157
|
const pythEndpoint = PRIMARY_PYTH_ENDPOINT; // TODO: Use getWorkingPythEndpoint
|
|
141
158
|
this.pythConnection = new SuiPriceServiceConnection(pythEndpoint, {
|
|
142
159
|
timeout: 30 * 1000,
|
package/lib/pythAdapter.d.ts
CHANGED
|
@@ -1,8 +1,74 @@
|
|
|
1
1
|
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
2
|
+
/**
|
|
3
|
+
* A Move object as the legacy JSON-RPC shape reported it.
|
|
4
|
+
*
|
|
5
|
+
* `fields` stays `unknown` on purpose: it is a decoded Move struct whose shape
|
|
6
|
+
* depends entirely on the object being read, and the callers that consume this
|
|
7
|
+
* adapter narrow it themselves. That is a genuine unknown, not the blanket `any`
|
|
8
|
+
* this module used to return.
|
|
9
|
+
*/
|
|
10
|
+
export interface LegacyObjectResponse {
|
|
11
|
+
data: {
|
|
12
|
+
objectId: string;
|
|
13
|
+
type: string;
|
|
14
|
+
content: {
|
|
15
|
+
dataType: "moveObject";
|
|
16
|
+
fields: unknown;
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
} | null;
|
|
20
|
+
}
|
|
21
|
+
/** A coin as the legacy JSON-RPC `getCoins` reported it. */
|
|
22
|
+
export interface LegacyCoin {
|
|
23
|
+
coinObjectId: string;
|
|
24
|
+
version: string | bigint | number;
|
|
25
|
+
digest: string;
|
|
26
|
+
balance: string | bigint | number;
|
|
27
|
+
coinType: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The legacy JSON-RPC surface this adapter provides.
|
|
31
|
+
*
|
|
32
|
+
* Explicit rather than inferred, and that is the whole point: this type has NO
|
|
33
|
+
* `core` property, so handing the adapter to something expecting `@mysten/sui`'s
|
|
34
|
+
* `ClientWithCoreApi` — which is what pyth v4's `SuiPythClient` wants — is now a
|
|
35
|
+
* COMPILE error.
|
|
36
|
+
*
|
|
37
|
+
* It used to be inferred as `any` (measurably: `IsAny<ReturnType<...>>` resolved
|
|
38
|
+
* to true), which made exactly that mismatch invisible to tsc. It shipped twice:
|
|
39
|
+
* @suilend/sdk 6.0.0/6.0.1 broke every deposit/withdraw/borrow/repay, and
|
|
40
|
+
* steamm-sdk 3.5.0 broke the admin oracle flow, both with
|
|
41
|
+
* "Cannot read properties of undefined (reading 'getDynamicField')". Neither was
|
|
42
|
+
* caught by a typecheck; both were found in production.
|
|
43
|
+
*
|
|
44
|
+
* Keep this typed. A third instance should fail to compile, not to run.
|
|
45
|
+
*/
|
|
46
|
+
export interface LegacyJsonRpcAdapter {
|
|
47
|
+
getObject(args: {
|
|
48
|
+
id: string;
|
|
49
|
+
options?: unknown;
|
|
50
|
+
}): Promise<LegacyObjectResponse>;
|
|
51
|
+
getCoins(args: {
|
|
52
|
+
owner: string;
|
|
53
|
+
coinType?: string;
|
|
54
|
+
cursor?: string | null;
|
|
55
|
+
}): Promise<{
|
|
56
|
+
data: LegacyCoin[];
|
|
57
|
+
nextCursor: string | null | undefined;
|
|
58
|
+
hasNextPage: boolean;
|
|
59
|
+
}>;
|
|
60
|
+
getDynamicFieldObject(args: {
|
|
61
|
+
parentId: string;
|
|
62
|
+
name: {
|
|
63
|
+
type: string;
|
|
64
|
+
value: unknown;
|
|
65
|
+
};
|
|
66
|
+
}): Promise<LegacyObjectResponse>;
|
|
67
|
+
}
|
|
2
68
|
/**
|
|
3
69
|
* Adapter that wraps SuiGrpcClient to provide the legacy SuiClient (JSON-RPC)
|
|
4
70
|
* interface expected by third-party SDKs like @pythnetwork/pyth-sui-js.
|
|
5
71
|
*
|
|
6
72
|
* Maps old JSON-RPC method signatures to the new gRPC equivalents.
|
|
7
73
|
*/
|
|
8
|
-
export declare function createJsonRpcAdapter(suiGrpcClient: SuiGrpcClient):
|
|
74
|
+
export declare function createJsonRpcAdapter(suiGrpcClient: SuiGrpcClient): LegacyJsonRpcAdapter;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"6.0.
|
|
1
|
+
{"name":"@suilend/sdk","version":"6.0.3","private":false,"description":"A TypeScript SDK for interacting with the Suilend program","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./client":"./client.js","./mmt":"./mmt.js","./strategies":"./strategies.js","./api/events":"./api/events.js","./api":"./api/index.js","./lib/constants":"./lib/constants.js","./lib":"./lib/index.js","./lib/initialize":"./lib/initialize.js","./lib/liquidityMining":"./lib/liquidityMining.js","./lib/pyth":"./lib/pyth.js","./lib/pythAdapter":"./lib/pythAdapter.js","./lib/strategyOwnerCap":"./lib/strategyOwnerCap.js","./lib/transactions":"./lib/transactions.js","./lib/types":"./lib/types.js","./margin":"./margin/index.js","./parsers/apiReserveAssetDataEvent":"./parsers/apiReserveAssetDataEvent.js","./parsers":"./parsers/index.js","./parsers/lendingMarket":"./parsers/lendingMarket.js","./parsers/obligation":"./parsers/obligation.js","./parsers/rateLimiter":"./parsers/rateLimiter.js","./parsers/reserve":"./parsers/reserve.js","./swap":"./swap/index.js","./swap/quote":"./swap/quote.js","./swap/transaction":"./swap/transaction.js","./utils/events":"./utils/events.js","./utils/feedId":"./utils/feedId.js","./utils":"./utils/index.js","./utils/obligation":"./utils/obligation.js","./utils/simulate":"./utils/simulate.js","./_generated/_framework/reified":"./_generated/_framework/reified.js","./_generated/_framework/util":"./_generated/_framework/util.js","./_generated/_framework/vector":"./_generated/_framework/vector.js","./_generated/suilend":"./_generated/suilend/index.js","./margin/margin/admin_cap":"./margin/margin/admin_cap.js","./margin/margin/market":"./margin/margin/market.js","./margin/margin/permissions":"./margin/margin/permissions.js","./margin/margin/position":"./margin/margin/position.js","./margin/margin/router":"./margin/margin/router.js","./margin/margin/version":"./margin/margin/version.js","./margin/utils":"./margin/utils/index.js","./_generated/suilend/cell/structs":"./_generated/suilend/cell/structs.js","./_generated/suilend/decimal/structs":"./_generated/suilend/decimal/structs.js","./_generated/suilend/lending-market/functions":"./_generated/suilend/lending-market/functions.js","./_generated/suilend/lending-market/structs":"./_generated/suilend/lending-market/structs.js","./_generated/suilend/lending-market-registry/functions":"./_generated/suilend/lending-market-registry/functions.js","./_generated/suilend/liquidity-mining/structs":"./_generated/suilend/liquidity-mining/structs.js","./_generated/suilend/obligation/structs":"./_generated/suilend/obligation/structs.js","./_generated/suilend/rate-limiter/functions":"./_generated/suilend/rate-limiter/functions.js","./_generated/suilend/rate-limiter/structs":"./_generated/suilend/rate-limiter/structs.js","./_generated/suilend/reserve/structs":"./_generated/suilend/reserve/structs.js","./_generated/suilend/reserve-config/functions":"./_generated/suilend/reserve-config/functions.js","./_generated/suilend/reserve-config/structs":"./_generated/suilend/reserve-config/structs.js","./_generated/_dependencies/source/0x1":"./_generated/_dependencies/source/0x1/index.js","./_generated/_dependencies/source/0x2":"./_generated/_dependencies/source/0x2/index.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js","./margin/margin/deps/std/type_name":"./margin/margin/deps/std/type_name.js","./margin/margin/deps/sui/vec_set":"./margin/margin/deps/sui/vec_set.js","./margin/margin/deps/suilend/lending_market":"./margin/margin/deps/suilend/lending_market.js","./_generated/_dependencies/source/0x1/ascii/structs":"./_generated/_dependencies/source/0x1/ascii/structs.js","./_generated/_dependencies/source/0x1/option/structs":"./_generated/_dependencies/source/0x1/option/structs.js","./_generated/_dependencies/source/0x1/type-name/structs":"./_generated/_dependencies/source/0x1/type-name/structs.js","./_generated/_dependencies/source/0x2/bag/structs":"./_generated/_dependencies/source/0x2/bag/structs.js","./_generated/_dependencies/source/0x2/balance/structs":"./_generated/_dependencies/source/0x2/balance/structs.js","./_generated/_dependencies/source/0x2/object/structs":"./_generated/_dependencies/source/0x2/object/structs.js","./_generated/_dependencies/source/0x2/object-table/structs":"./_generated/_dependencies/source/0x2/object-table/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js"},"types":"./index.d.ts","scripts":{"build":"rm -rf ./dist && tsc && node ./fix-esm-imports.js","typecheck":"tsc --noEmit && tsc --noEmit -p tsconfig.test.json","test":"vitest run","lint:ci":"yarn run typecheck","prettier":"prettier --write src/ tests/","release":"yarn run build && node ./release.js && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/fireflyprotocol/lending-mono.git","directory":"ts/sdks/sdk"},"dependencies":{"@bluefin-exchange/bluefin7k-aggregator-sdk":"^7.3.0","@cetusprotocol/aggregator-sdk":"^1.5.7","@flowx-finance/sdk":"^2.1.0","@pythnetwork/hermes-client":"3.1.0","@pythnetwork/pyth-sui-js":"4.0.0","@suilend/springsui-sdk":"^4.0.0","bignumber.js":"^9.1.2","bn.js":"^5.2.2","crypto-js":"^4.2.0","lodash":"^4.17.21","p-limit":"3.1.0","uuid":"^11.0.3"},"devDependencies":{"@mysten/bcs":"^2.0.5","@mysten/sui":"2.17.0","@suilend/sui-core":"^1.0.0","@tsconfig/recommended":"^1.0.8","@types/bn.js":"^5.2.0","@types/lodash":"^4.17.20","@types/node":"^22.9.0","prettier":"^3.3.3","ts-node":"^10.9.2","typescript":"^6.0.3","vitest":"4.1.0"},"peerDependencies":{"@mysten/bcs":"^2.0.5","@mysten/sui":"2.17.0","@suilend/sui-core":"^1.0.0"},"type":"module"}
|