@varla/sdk 1.11.2 → 1.11.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/AGENTS.md CHANGED
@@ -93,3 +93,97 @@ The SDK can provide raw primitives; **ranking is app-side**:
93
93
  - **Cooldown period**
94
94
  - As of `contracts/VarlaPool.sol` in this repo, there is **no cooldown / withdraw delay** view.
95
95
  - If a cooldown is introduced later, we can add `views.readPoolConfig({ pool })`.
96
+
97
+ ---
98
+
99
+ ## All view helpers (generated)
100
+
101
+ <!-- BEGIN GENERATED:VIEW_HELPERS -->
102
+ <!--
103
+ This section is auto-generated by scripts/sdk-generate-docs.ts.
104
+ Do not edit manually.
105
+ -->
106
+
107
+ - `getInterestRateStrategyFromPool`
108
+ - `hydrateOraclePositionIds`
109
+ - `previewBorrow`
110
+ - `previewRepay`
111
+ - `readAccessManagerBasics`
112
+ - `readAccountPositions`
113
+ - `readAccountPositionsFull`
114
+ - `readAccountSnapshot`
115
+ - `readAdapterInfo`
116
+ - `readBadDebtStatus`
117
+ - `readBorrowLimits`
118
+ - `readBorrowerState`
119
+ - `readBorrowers`
120
+ - `readBorrowersPage`
121
+ - `readCalculateLiquidationBonus`
122
+ - `readCanLiquidate`
123
+ - `readConfiguredPositionIds`
124
+ - `readConvertLiquidatorBasics`
125
+ - `readCoreAddresses`
126
+ - `readCoreGlobalDebt`
127
+ - `readDefaultLtvConfig`
128
+ - `readHasRole`
129
+ - `readHealthFactor`
130
+ - `readInterestRateStrategyBasics`
131
+ - `readLenderSnapshot`
132
+ - `readLiquidationBonusBps`
133
+ - `readLiquidationConfig`
134
+ - `readLiquidationParamsForPosition`
135
+ - `readLiquidatorBasics`
136
+ - `readLiquidity`
137
+ - `readLtvForPosition`
138
+ - `readManyAccountSnapshots`
139
+ - `readManyBorrowLimits`
140
+ - `readManyHasRole`
141
+ - `readManyLiquidationBonusBps`
142
+ - `readManyOraclePositionMeta`
143
+ - `readManyPositionSnapshots`
144
+ - `readManyTargetConfigs`
145
+ - `readManyTargetFunctionRoles`
146
+ - `readMaxPositionsConfig`
147
+ - `readMaxRedeem`
148
+ - `readMaxWithdraw`
149
+ - `readMergeLiquidatorBasics`
150
+ - `readNegRiskMarketPositionIds`
151
+ - `readOracleBasics`
152
+ - `readOracleCollateralStatus`
153
+ - `readOracleConfig`
154
+ - `readOracleFinalizationStatus`
155
+ - `readOracleGuardsStatus`
156
+ - `readOraclePositionMeta`
157
+ - `readOraclePriceData`
158
+ - `readOracleRegistry`
159
+ - `readOracleRegistryPage`
160
+ - `readOracleTiming`
161
+ - `readPoolAccounting`
162
+ - `readPoolCaps`
163
+ - `readPoolCoreAddress`
164
+ - `readPoolDebtState`
165
+ - `readPoolHealthScore`
166
+ - `readPoolRates`
167
+ - `readPoolSharePrice`
168
+ - `readPoolSnapshot`
169
+ - `readPortfolioValue`
170
+ - `readPositionBalance`
171
+ - `readPositionBalances`
172
+ - `readPositionCount`
173
+ - `readPositionLiquidationConfigOverride`
174
+ - `readPositionLtvOverride`
175
+ - `readPositionSnapshot`
176
+ - `readPreviewLiquidation`
177
+ - `readPrice`
178
+ - `readProxyAdminPaused`
179
+ - `readRepayTiming`
180
+ - `readRiskTier`
181
+ - `readRoleSummary`
182
+ - `readSpotPrice`
183
+ - `readSystemSnapshot`
184
+ - `readTargetConfig`
185
+ - `readTierLiquidationConfig`
186
+ - `readTieredLtvConfig`
187
+ - `readTryGetPrice`
188
+ - `readTwap`
189
+ <!-- END GENERATED:VIEW_HELPERS -->
package/BACKEND.md CHANGED
@@ -308,3 +308,97 @@ Useful health signals to emit from a backend:
308
308
  - Treat RPC errors as expected: implement retry/backoff and fallbacks.
309
309
  - Keep multicalls bounded (chunking) to avoid RPC provider limits.
310
310
 
311
+ ---
312
+
313
+ ## All view helpers (generated)
314
+
315
+ <!-- BEGIN GENERATED:VIEW_HELPERS -->
316
+ <!--
317
+ This section is auto-generated by scripts/sdk-generate-docs.ts.
318
+ Do not edit manually.
319
+ -->
320
+
321
+ - `getInterestRateStrategyFromPool`
322
+ - `hydrateOraclePositionIds`
323
+ - `previewBorrow`
324
+ - `previewRepay`
325
+ - `readAccessManagerBasics`
326
+ - `readAccountPositions`
327
+ - `readAccountPositionsFull`
328
+ - `readAccountSnapshot`
329
+ - `readAdapterInfo`
330
+ - `readBadDebtStatus`
331
+ - `readBorrowLimits`
332
+ - `readBorrowerState`
333
+ - `readBorrowers`
334
+ - `readBorrowersPage`
335
+ - `readCalculateLiquidationBonus`
336
+ - `readCanLiquidate`
337
+ - `readConfiguredPositionIds`
338
+ - `readConvertLiquidatorBasics`
339
+ - `readCoreAddresses`
340
+ - `readCoreGlobalDebt`
341
+ - `readDefaultLtvConfig`
342
+ - `readHasRole`
343
+ - `readHealthFactor`
344
+ - `readInterestRateStrategyBasics`
345
+ - `readLenderSnapshot`
346
+ - `readLiquidationBonusBps`
347
+ - `readLiquidationConfig`
348
+ - `readLiquidationParamsForPosition`
349
+ - `readLiquidatorBasics`
350
+ - `readLiquidity`
351
+ - `readLtvForPosition`
352
+ - `readManyAccountSnapshots`
353
+ - `readManyBorrowLimits`
354
+ - `readManyHasRole`
355
+ - `readManyLiquidationBonusBps`
356
+ - `readManyOraclePositionMeta`
357
+ - `readManyPositionSnapshots`
358
+ - `readManyTargetConfigs`
359
+ - `readManyTargetFunctionRoles`
360
+ - `readMaxPositionsConfig`
361
+ - `readMaxRedeem`
362
+ - `readMaxWithdraw`
363
+ - `readMergeLiquidatorBasics`
364
+ - `readNegRiskMarketPositionIds`
365
+ - `readOracleBasics`
366
+ - `readOracleCollateralStatus`
367
+ - `readOracleConfig`
368
+ - `readOracleFinalizationStatus`
369
+ - `readOracleGuardsStatus`
370
+ - `readOraclePositionMeta`
371
+ - `readOraclePriceData`
372
+ - `readOracleRegistry`
373
+ - `readOracleRegistryPage`
374
+ - `readOracleTiming`
375
+ - `readPoolAccounting`
376
+ - `readPoolCaps`
377
+ - `readPoolCoreAddress`
378
+ - `readPoolDebtState`
379
+ - `readPoolHealthScore`
380
+ - `readPoolRates`
381
+ - `readPoolSharePrice`
382
+ - `readPoolSnapshot`
383
+ - `readPortfolioValue`
384
+ - `readPositionBalance`
385
+ - `readPositionBalances`
386
+ - `readPositionCount`
387
+ - `readPositionLiquidationConfigOverride`
388
+ - `readPositionLtvOverride`
389
+ - `readPositionSnapshot`
390
+ - `readPreviewLiquidation`
391
+ - `readPrice`
392
+ - `readProxyAdminPaused`
393
+ - `readRepayTiming`
394
+ - `readRiskTier`
395
+ - `readRoleSummary`
396
+ - `readSpotPrice`
397
+ - `readSystemSnapshot`
398
+ - `readTargetConfig`
399
+ - `readTierLiquidationConfig`
400
+ - `readTieredLtvConfig`
401
+ - `readTryGetPrice`
402
+ - `readTwap`
403
+ <!-- END GENERATED:VIEW_HELPERS -->
404
+
package/FRONTEND.md CHANGED
@@ -388,3 +388,97 @@ This keeps UI components clean, and gives you one place to wire:
388
388
  - analytics
389
389
  - receipt confirmations
390
390
  - error mapping
391
+
392
+ ---
393
+
394
+ ## All view helpers (generated)
395
+
396
+ <!-- BEGIN GENERATED:VIEW_HELPERS -->
397
+ <!--
398
+ This section is auto-generated by scripts/sdk-generate-docs.ts.
399
+ Do not edit manually.
400
+ -->
401
+
402
+ - `getInterestRateStrategyFromPool`
403
+ - `hydrateOraclePositionIds`
404
+ - `previewBorrow`
405
+ - `previewRepay`
406
+ - `readAccessManagerBasics`
407
+ - `readAccountPositions`
408
+ - `readAccountPositionsFull`
409
+ - `readAccountSnapshot`
410
+ - `readAdapterInfo`
411
+ - `readBadDebtStatus`
412
+ - `readBorrowLimits`
413
+ - `readBorrowerState`
414
+ - `readBorrowers`
415
+ - `readBorrowersPage`
416
+ - `readCalculateLiquidationBonus`
417
+ - `readCanLiquidate`
418
+ - `readConfiguredPositionIds`
419
+ - `readConvertLiquidatorBasics`
420
+ - `readCoreAddresses`
421
+ - `readCoreGlobalDebt`
422
+ - `readDefaultLtvConfig`
423
+ - `readHasRole`
424
+ - `readHealthFactor`
425
+ - `readInterestRateStrategyBasics`
426
+ - `readLenderSnapshot`
427
+ - `readLiquidationBonusBps`
428
+ - `readLiquidationConfig`
429
+ - `readLiquidationParamsForPosition`
430
+ - `readLiquidatorBasics`
431
+ - `readLiquidity`
432
+ - `readLtvForPosition`
433
+ - `readManyAccountSnapshots`
434
+ - `readManyBorrowLimits`
435
+ - `readManyHasRole`
436
+ - `readManyLiquidationBonusBps`
437
+ - `readManyOraclePositionMeta`
438
+ - `readManyPositionSnapshots`
439
+ - `readManyTargetConfigs`
440
+ - `readManyTargetFunctionRoles`
441
+ - `readMaxPositionsConfig`
442
+ - `readMaxRedeem`
443
+ - `readMaxWithdraw`
444
+ - `readMergeLiquidatorBasics`
445
+ - `readNegRiskMarketPositionIds`
446
+ - `readOracleBasics`
447
+ - `readOracleCollateralStatus`
448
+ - `readOracleConfig`
449
+ - `readOracleFinalizationStatus`
450
+ - `readOracleGuardsStatus`
451
+ - `readOraclePositionMeta`
452
+ - `readOraclePriceData`
453
+ - `readOracleRegistry`
454
+ - `readOracleRegistryPage`
455
+ - `readOracleTiming`
456
+ - `readPoolAccounting`
457
+ - `readPoolCaps`
458
+ - `readPoolCoreAddress`
459
+ - `readPoolDebtState`
460
+ - `readPoolHealthScore`
461
+ - `readPoolRates`
462
+ - `readPoolSharePrice`
463
+ - `readPoolSnapshot`
464
+ - `readPortfolioValue`
465
+ - `readPositionBalance`
466
+ - `readPositionBalances`
467
+ - `readPositionCount`
468
+ - `readPositionLiquidationConfigOverride`
469
+ - `readPositionLtvOverride`
470
+ - `readPositionSnapshot`
471
+ - `readPreviewLiquidation`
472
+ - `readPrice`
473
+ - `readProxyAdminPaused`
474
+ - `readRepayTiming`
475
+ - `readRiskTier`
476
+ - `readRoleSummary`
477
+ - `readSpotPrice`
478
+ - `readSystemSnapshot`
479
+ - `readTargetConfig`
480
+ - `readTierLiquidationConfig`
481
+ - `readTieredLtvConfig`
482
+ - `readTryGetPrice`
483
+ - `readTwap`
484
+ <!-- END GENERATED:VIEW_HELPERS -->
@@ -1,4 +1,4 @@
1
- import type { Address, Hash } from "viem";
1
+ import type { Address, Hash, Hex } from "viem";
2
2
  /**
3
3
  * EIP-712 payload builder for OracleUpdaterRouter.
4
4
  *
@@ -51,6 +51,16 @@ export declare const ORACLE_UPDATER_ROUTER_TYPES: {
51
51
  readonly type: "bytes32";
52
52
  }];
53
53
  };
54
+ /**
55
+ * Hardcoded UPDATE_TYPEHASH from the deployed OracleUpdaterRouter contract.
56
+ *
57
+ * Computed from:
58
+ * keccak256("Update(address oracle,uint256 chainId,address publisher,uint256 nonce,uint256 deadline,bytes32 positionIdsHash,bytes32 priceListHash,bytes32 twapListHash,bytes32 liquidityListHash)")
59
+ *
60
+ * IMPORTANT: This must match the contract's hardcoded UPDATE_TYPEHASH exactly.
61
+ * If the contract is redeployed with a different type hash, this must be updated.
62
+ */
63
+ export declare const UPDATE_TYPEHASH: Hash;
54
64
  /**
55
65
  * Convert an update with dynamic arrays into the typed-data "message" shape expected by the router.
56
66
  */
@@ -65,9 +75,21 @@ export declare function toOracleUpdaterRouterTypedMessage(u: OracleUpdaterRouter
65
75
  readonly twapListHash: `0x${string}`;
66
76
  readonly liquidityListHash: `0x${string}`;
67
77
  };
78
+ /**
79
+ * Compute the EIP-712 digest that should be signed.
80
+ * This manually computes the digest to ensure exact match with the contract's hashUpdate().
81
+ */
82
+ export declare function computeOracleUpdaterDigest(params: {
83
+ routerAddress: Address;
84
+ update: OracleUpdaterRouterUpdate;
85
+ }): Hash;
68
86
  export declare function signOracleUpdaterRouterUpdate(params: {
69
87
  walletClient: {
70
- signTypedData: (args: any) => Promise<Hash>;
88
+ signMessage: (args: {
89
+ message: {
90
+ raw: Hex;
91
+ };
92
+ }) => Promise<Hash>;
71
93
  };
72
94
  routerAddress: Address;
73
95
  update: OracleUpdaterRouterUpdate;
@@ -1 +1 @@
1
- {"version":3,"file":"oracleUpdaterRouter.d.ts","sourceRoot":"","sources":["../../src/actions/oracleUpdaterRouter.ts"],"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;CACnC,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhB;AAED,wBAAsB,6CAA6C,CAAC,MAAM,EAAE;IAC1E,YAAY,EAAE;QAAE,gBAAgB,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;KAAE,CAAC;IAChE,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,yBAAyB,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC;CACjB,GAAG,OAAO,CAAC,GAAG,CAAC,CAqBf"}
@@ -1,5 +1,5 @@
1
1
  // Note: explicit .js extension is required for Node ESM resolution.
2
- import { encodeAbiParameters, keccak256 } from "viem";
2
+ import { concat, encodeAbiParameters, encodePacked, keccak256, toHex } from "viem";
3
3
  import { abis } from "../generated.js";
4
4
  /**
5
5
  * EIP-712 payload builder for OracleUpdaterRouter.
@@ -25,13 +25,31 @@ export const ORACLE_UPDATER_ROUTER_TYPES = {
25
25
  { name: "liquidityListHash", type: "bytes32" },
26
26
  ],
27
27
  };
28
+ /**
29
+ * Hardcoded UPDATE_TYPEHASH from the deployed OracleUpdaterRouter contract.
30
+ *
31
+ * Computed from:
32
+ * keccak256("Update(address oracle,uint256 chainId,address publisher,uint256 nonce,uint256 deadline,bytes32 positionIdsHash,bytes32 priceListHash,bytes32 twapListHash,bytes32 liquidityListHash)")
33
+ *
34
+ * IMPORTANT: This must match the contract's hardcoded UPDATE_TYPEHASH exactly.
35
+ * If the contract is redeployed with a different type hash, this must be updated.
36
+ */
37
+ export const UPDATE_TYPEHASH = "0xfb5c9ee2f30c92eeb6fe0049d8ba63d98fcbb57cccd2761e2fd7275ac1bd9bd0";
38
+ /**
39
+ * Hardcoded EIP712Domain type hash.
40
+ * keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
41
+ */
42
+ const EIP712_DOMAIN_TYPEHASH = "0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f";
43
+ /**
44
+ * Hash a uint256[] array using Solidity's abi.encodePacked semantics.
45
+ * Matches: keccak256(abi.encodePacked(uint256[]))
46
+ */
28
47
  function hashU256Array(xs) {
29
- // Solidity uses keccak256(abi.encodePacked(uint256[])) for the struct hash.
30
- // abi.encodePacked(uint256[]) is just tight packing of each uint256 as 32 bytes.
31
48
  if (xs.length === 0)
32
49
  return keccak256(new Uint8Array([]));
33
- const bytes = encodeAbiParameters(Array(xs.length).fill({ type: "uint256" }), xs);
34
- return keccak256(bytes);
50
+ // abi.encodePacked(uint256[]) is just tight packing of each uint256 as 32 bytes
51
+ const packed = encodePacked(xs.map(() => "uint256"), xs);
52
+ return keccak256(packed);
35
53
  }
36
54
  /**
37
55
  * Convert an update with dynamic arrays into the typed-data "message" shape expected by the router.
@@ -49,18 +67,74 @@ export function toOracleUpdaterRouterTypedMessage(u) {
49
67
  liquidityListHash: hashU256Array(u.liquidityList),
50
68
  };
51
69
  }
70
+ /**
71
+ * Compute the EIP-712 domain separator for the OracleUpdaterRouter.
72
+ */
73
+ function computeDomainSeparator(chainId, routerAddress) {
74
+ return keccak256(encodeAbiParameters([
75
+ { type: "bytes32" },
76
+ { type: "bytes32" },
77
+ { type: "bytes32" },
78
+ { type: "uint256" },
79
+ { type: "address" },
80
+ ], [
81
+ EIP712_DOMAIN_TYPEHASH,
82
+ keccak256(toHex(ORACLE_UPDATER_ROUTER_EIP712.name)),
83
+ keccak256(toHex(ORACLE_UPDATER_ROUTER_EIP712.version)),
84
+ chainId,
85
+ routerAddress,
86
+ ]));
87
+ }
88
+ /**
89
+ * Compute the struct hash for an Update using the contract's exact UPDATE_TYPEHASH.
90
+ * This bypasses viem's automatic type hash computation to ensure exact match with the contract.
91
+ */
92
+ function computeStructHash(update) {
93
+ const msg = toOracleUpdaterRouterTypedMessage(update);
94
+ return keccak256(encodeAbiParameters([
95
+ { type: "bytes32" }, // UPDATE_TYPEHASH
96
+ { type: "address" }, // oracle
97
+ { type: "uint256" }, // chainId
98
+ { type: "address" }, // publisher
99
+ { type: "uint256" }, // nonce
100
+ { type: "uint256" }, // deadline
101
+ { type: "bytes32" }, // positionIdsHash
102
+ { type: "bytes32" }, // priceListHash
103
+ { type: "bytes32" }, // twapListHash
104
+ { type: "bytes32" }, // liquidityListHash
105
+ ], [
106
+ UPDATE_TYPEHASH,
107
+ msg.oracle,
108
+ msg.chainId,
109
+ msg.publisher,
110
+ msg.nonce,
111
+ msg.deadline,
112
+ msg.positionIdsHash,
113
+ msg.priceListHash,
114
+ msg.twapListHash,
115
+ msg.liquidityListHash,
116
+ ]));
117
+ }
118
+ /**
119
+ * Compute the EIP-712 digest that should be signed.
120
+ * This manually computes the digest to ensure exact match with the contract's hashUpdate().
121
+ */
122
+ export function computeOracleUpdaterDigest(params) {
123
+ const domainSeparator = computeDomainSeparator(params.update.chainId, params.routerAddress);
124
+ const structHash = computeStructHash(params.update);
125
+ // EIP-712: "\x19\x01" ++ domainSeparator ++ structHash
126
+ return keccak256(concat(["0x1901", domainSeparator, structHash]));
127
+ }
52
128
  export async function signOracleUpdaterRouterUpdate(params) {
53
- return (await params.walletClient.signTypedData({
54
- domain: {
55
- name: ORACLE_UPDATER_ROUTER_EIP712.name,
56
- version: ORACLE_UPDATER_ROUTER_EIP712.version,
57
- chainId: params.update.chainId,
58
- verifyingContract: params.routerAddress,
59
- },
60
- primaryType: "Update",
61
- types: ORACLE_UPDATER_ROUTER_TYPES,
62
- message: toOracleUpdaterRouterTypedMessage(params.update),
63
- }));
129
+ // Manually compute the EIP-712 digest to ensure exact match with contract
130
+ const digest = computeOracleUpdaterDigest({
131
+ routerAddress: params.routerAddress,
132
+ update: params.update,
133
+ });
134
+ // Sign the raw digest (not a personal_sign, just the raw hash)
135
+ return params.walletClient.signMessage({
136
+ message: { raw: digest },
137
+ });
64
138
  }
65
139
  export async function prepareOracleUpdaterRouterUpdatePricesWithSig(params) {
66
140
  return await params.publicClient.simulateContract({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varla/sdk",
3
- "version": "1.11.2",
3
+ "version": "1.11.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,