@steerprotocol/sdk 4.0.0-next.3 → 4.0.0-next.4
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 +17 -0
- package/dist/index.cjs +27 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -13
- package/dist/index.d.mts +18 -13
- package/dist/index.mjs +27 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,6 +134,23 @@ entry points honor client `indexers`/`http` configuration and accept per-request
|
|
|
134
134
|
timeout, and cancellation overrides as the second argument. The existing `getVault()` API and
|
|
135
135
|
its onchain identity checks remain the loading path.
|
|
136
136
|
|
|
137
|
+
When catalog records are already available, supply them through the optional `VaultLoadOptions.metadata` field:
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
const vaults = await steer.getVaults(ChainId.Base, records.map((record) => record.id), {
|
|
141
|
+
blockNumber: 100000n,
|
|
142
|
+
metadata: records,
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
This skips metadata subgraph requests while retaining all onchain registration, implementation,
|
|
147
|
+
protocol and pool checks. Records are matched by address case-insensitively and copied before IO.
|
|
148
|
+
Supply one complete record per unique requested address. Missing, duplicate, unrequested or malformed
|
|
149
|
+
records fail without a metadata fetch. Results preserve requested order and duplicate addresses.
|
|
150
|
+
Omit `metadata` to retain the existing subgraph lookup. The same options work on `getVault`, typed
|
|
151
|
+
vault getters and the connected-network loading methods. Metadata remains descriptive and is never
|
|
152
|
+
forwarded to viem/RPC or used to establish verified identity. Snapshot/accounting options are unchanged.
|
|
153
|
+
|
|
137
154
|
`getVaults(chainId, addresses, options)` returns the same resolved vault objects as `getVault()`
|
|
138
155
|
in input order, including duplicate inputs. Base V3/Integral resolution uses a bulk Solidity reader:
|
|
139
156
|
**two RPC requests per page of at most 64 vaults** at a pinned block. Latest reads add one shared
|
package/dist/index.cjs
CHANGED
|
@@ -11433,6 +11433,20 @@ function vaultMetadata(value) {
|
|
|
11433
11433
|
strategyToken: strategy === null ? null : Object.freeze({ id: String(strategy.id) })
|
|
11434
11434
|
});
|
|
11435
11435
|
}
|
|
11436
|
+
/** Validate and detach caller-owned metadata before any asynchronous resolution. */
|
|
11437
|
+
function captureVaultMetadata(addresses, values) {
|
|
11438
|
+
if (!Array.isArray(values)) throw new Error("Supplied vault metadata must be an array");
|
|
11439
|
+
const requested = new Set(addresses.map((address) => address.toLowerCase()));
|
|
11440
|
+
const records = /* @__PURE__ */ new Map();
|
|
11441
|
+
for (const value of values) {
|
|
11442
|
+
const metadata = vaultMetadata(value);
|
|
11443
|
+
if (!requested.has(metadata.id)) throw new Error(`Supplied vault metadata contains an unrequested address: ${metadata.id}`);
|
|
11444
|
+
if (records.has(metadata.id)) throw new Error(`Supplied vault metadata contains a duplicate address: ${metadata.id}`);
|
|
11445
|
+
records.set(metadata.id, metadata);
|
|
11446
|
+
}
|
|
11447
|
+
for (const address of requested) if (!records.has(address)) throw new Error(`Supplied vault metadata is missing address: ${address}`);
|
|
11448
|
+
return records;
|
|
11449
|
+
}
|
|
11436
11450
|
//#endregion
|
|
11437
11451
|
//#region src/vault/resolver-types.ts
|
|
11438
11452
|
let ProtocolContractRole = /* @__PURE__ */ function(ProtocolContractRole) {
|
|
@@ -20954,9 +20968,14 @@ var VaultResolver = class {
|
|
|
20954
20968
|
if (snapshot.blockNumber !== blockNumber || !vault.underlying.some((position) => position.kind === "liquidity" && sameLiquidityPool(position.pool, snapshot.pool))) throw new Error("Vault returned another accounting snapshot");
|
|
20955
20969
|
return readValidatedVaultSnapshot(vault, snapshot, vault.steer.context);
|
|
20956
20970
|
}
|
|
20957
|
-
#metadata(steer, addresses) {
|
|
20971
|
+
#metadata(steer, addresses, supplied) {
|
|
20958
20972
|
let pending;
|
|
20959
20973
|
return async (address) => {
|
|
20974
|
+
if (supplied) {
|
|
20975
|
+
const metadata = supplied.get(address.toLowerCase());
|
|
20976
|
+
if (!metadata) throw new Error(`Supplied vault metadata is missing address: ${address}`);
|
|
20977
|
+
return metadata;
|
|
20978
|
+
}
|
|
20960
20979
|
pending ??= steer.dataAdapter.getVaultMetadata(addresses);
|
|
20961
20980
|
const metadata = (await pending).find((record) => record.id.toLowerCase() === address.toLowerCase());
|
|
20962
20981
|
if (!metadata) throw new Error("Vault metadata is not indexed");
|
|
@@ -20967,13 +20986,15 @@ var VaultResolver = class {
|
|
|
20967
20986
|
async resolveMany(steer, addresses, options) {
|
|
20968
20987
|
const inputs = [...addresses];
|
|
20969
20988
|
for (const address of inputs) addressKey(address);
|
|
20989
|
+
const supplied = options?.metadata;
|
|
20990
|
+
const metadata = supplied === void 0 ? void 0 : captureVaultMetadata(inputs, supplied);
|
|
20970
20991
|
if (!inputs.length) return Object.freeze([]);
|
|
20971
20992
|
const blockNumber = await this.#blockNumber(steer, options);
|
|
20972
20993
|
const result = [];
|
|
20973
20994
|
let bulkSupported = !!this.#reader.readMany;
|
|
20974
20995
|
for (let start = 0; start < inputs.length; start += 64) {
|
|
20975
20996
|
const batch = inputs.slice(start, start + 64);
|
|
20976
|
-
const loadMetadata = this.#metadata(steer, batch);
|
|
20997
|
+
const loadMetadata = this.#metadata(steer, batch, metadata);
|
|
20977
20998
|
const contexts = batch.map((address) => Object.freeze({
|
|
20978
20999
|
steer,
|
|
20979
21000
|
address,
|
|
@@ -21130,7 +21151,10 @@ var SteerNetwork = class {
|
|
|
21130
21151
|
return this.#vaultResolver().resolve(this, address, options);
|
|
21131
21152
|
}
|
|
21132
21153
|
async getVaults(addresses, options) {
|
|
21133
|
-
if (!addresses.length)
|
|
21154
|
+
if (!addresses.length) {
|
|
21155
|
+
if (options?.metadata !== void 0) captureVaultMetadata(addresses, options.metadata);
|
|
21156
|
+
return Object.freeze([]);
|
|
21157
|
+
}
|
|
21134
21158
|
return this.#vaultResolver().resolveMany(this, addresses, options);
|
|
21135
21159
|
}
|
|
21136
21160
|
getVaultSnapshots(addresses, options) {
|