@gearbox-protocol/sdk 17.10.1 → 17.11.0

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.
Files changed (112) hide show
  1. package/dist/cjs/offchain/AbstractOffchainNamespace.js +31 -8
  2. package/dist/cjs/permissionless/api/GearboxPermissionless.js +79 -0
  3. package/dist/cjs/permissionless/api/chains/ChainsNamespace.js +180 -0
  4. package/dist/cjs/permissionless/api/chains/index.js +4 -0
  5. package/dist/cjs/permissionless/api/chains/schemas.js +34 -0
  6. package/dist/cjs/permissionless/api/chains/types.js +1 -0
  7. package/dist/cjs/permissionless/api/deploy/PermissionlessDeploy.js +152 -0
  8. package/dist/cjs/permissionless/api/deploy/effective-staleness.js +46 -0
  9. package/dist/cjs/permissionless/api/deploy/index.js +8 -0
  10. package/dist/cjs/permissionless/api/deploy/types.js +1 -0
  11. package/dist/cjs/permissionless/api/errors.js +82 -0
  12. package/dist/cjs/permissionless/api/index.js +28 -0
  13. package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +84 -0
  14. package/dist/cjs/permissionless/api/oracles/index.js +6 -0
  15. package/dist/cjs/permissionless/api/oracles/schemas.js +64 -0
  16. package/dist/cjs/permissionless/api/oracles/types.js +1 -0
  17. package/dist/cjs/permissionless/api/schemas.js +28 -0
  18. package/dist/cjs/permissionless/api/transactions/InstanceOwnerTransactions.js +230 -0
  19. package/dist/cjs/permissionless/api/transactions/index.js +4 -0
  20. package/dist/cjs/permissionless/api/transactions/lp-price-feeds.js +86 -0
  21. package/dist/cjs/permissionless/api/transactions/types.js +1 -0
  22. package/dist/cjs/permissionless/api/types.js +1 -0
  23. package/dist/cjs/permissionless/bindings/cross-chain-multisig.js +1 -1
  24. package/dist/cjs/permissionless/bindings/index.js +3 -3
  25. package/dist/cjs/permissionless/bindings/instance-manager.js +3 -3
  26. package/dist/cjs/permissionless/index.js +31 -8
  27. package/dist/cjs/permissionless/utils/governance/timelock-txs.js +1 -1
  28. package/dist/cjs/permissionless/utils/index.js +4 -4
  29. package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +1 -1
  30. package/dist/cjs/permissionless/utils/price-update/index.js +1 -1
  31. package/dist/esm/dev/AccountOpener.js +1 -1
  32. package/dist/esm/dev/withdrawalUtils.js +1 -1
  33. package/dist/esm/history/trace/extractTransfers.js +1 -1
  34. package/dist/esm/offchain/AbstractOffchainNamespace.js +31 -8
  35. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  36. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  37. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  38. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  39. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  40. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  41. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  42. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  43. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  44. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  45. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  46. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  47. package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
  48. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  49. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  50. package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
  51. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  52. package/dist/esm/permissionless/api/GearboxPermissionless.js +78 -0
  53. package/dist/esm/permissionless/api/chains/ChainsNamespace.js +179 -0
  54. package/dist/esm/permissionless/api/chains/index.js +3 -0
  55. package/dist/esm/permissionless/api/chains/schemas.js +30 -0
  56. package/dist/esm/permissionless/api/chains/types.js +1 -0
  57. package/dist/esm/permissionless/api/deploy/PermissionlessDeploy.js +149 -0
  58. package/dist/esm/permissionless/api/deploy/effective-staleness.js +46 -0
  59. package/dist/esm/permissionless/api/deploy/index.js +4 -0
  60. package/dist/esm/permissionless/api/deploy/types.js +1 -0
  61. package/dist/esm/permissionless/api/errors.js +77 -0
  62. package/dist/esm/permissionless/api/index.js +13 -0
  63. package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +81 -0
  64. package/dist/esm/permissionless/api/oracles/index.js +3 -0
  65. package/dist/esm/permissionless/api/oracles/schemas.js +59 -0
  66. package/dist/esm/permissionless/api/oracles/types.js +1 -0
  67. package/dist/esm/permissionless/api/schemas.js +25 -0
  68. package/dist/esm/permissionless/api/transactions/InstanceOwnerTransactions.js +229 -0
  69. package/dist/esm/permissionless/api/transactions/index.js +3 -0
  70. package/dist/esm/permissionless/api/transactions/lp-price-feeds.js +84 -0
  71. package/dist/esm/permissionless/api/transactions/types.js +1 -0
  72. package/dist/esm/permissionless/api/types.js +1 -0
  73. package/dist/esm/permissionless/bindings/cross-chain-multisig.js +1 -1
  74. package/dist/esm/permissionless/bindings/index.js +3 -3
  75. package/dist/esm/permissionless/bindings/instance-manager.js +3 -3
  76. package/dist/esm/permissionless/index.js +17 -9
  77. package/dist/esm/permissionless/utils/governance/timelock-txs.js +1 -1
  78. package/dist/esm/permissionless/utils/index.js +4 -4
  79. package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +1 -1
  80. package/dist/esm/permissionless/utils/price-update/index.js +1 -1
  81. package/dist/types/offchain/AbstractOffchainNamespace.d.ts +12 -0
  82. package/dist/types/permissionless/api/GearboxPermissionless.d.ts +71 -0
  83. package/dist/types/permissionless/api/chains/ChainsNamespace.d.ts +99 -0
  84. package/dist/types/permissionless/api/chains/index.d.ts +3 -0
  85. package/dist/types/permissionless/api/chains/schemas.d.ts +49 -0
  86. package/dist/types/permissionless/api/chains/types.d.ts +58 -0
  87. package/dist/types/permissionless/api/deploy/PermissionlessDeploy.d.ts +69 -0
  88. package/dist/types/permissionless/api/deploy/effective-staleness.d.ts +19 -0
  89. package/dist/types/permissionless/api/deploy/index.d.ts +4 -0
  90. package/dist/types/permissionless/api/deploy/types.d.ts +87 -0
  91. package/dist/types/permissionless/api/errors.d.ts +63 -0
  92. package/dist/types/permissionless/api/index.d.ts +17 -0
  93. package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +64 -0
  94. package/dist/types/permissionless/api/oracles/index.d.ts +3 -0
  95. package/dist/types/permissionless/api/oracles/schemas.d.ts +103 -0
  96. package/dist/types/permissionless/api/oracles/types.d.ts +63 -0
  97. package/dist/types/permissionless/api/schemas.d.ts +22 -0
  98. package/dist/types/permissionless/api/transactions/InstanceOwnerTransactions.d.ts +60 -0
  99. package/dist/types/permissionless/api/transactions/index.d.ts +3 -0
  100. package/dist/types/permissionless/api/transactions/lp-price-feeds.d.ts +17 -0
  101. package/dist/types/permissionless/api/transactions/types.d.ts +36 -0
  102. package/dist/types/permissionless/api/types.d.ts +12 -0
  103. package/dist/types/permissionless/bindings/factory/credit-factory.d.ts +1 -1
  104. package/dist/types/permissionless/bindings/factory/loss-policy-factory.d.ts +1 -1
  105. package/dist/types/permissionless/bindings/factory/pool-factory.d.ts +1 -1
  106. package/dist/types/permissionless/bindings/factory/price-oracle-factory.d.ts +1 -1
  107. package/dist/types/permissionless/bindings/index.d.ts +1 -1
  108. package/dist/types/permissionless/core/index.d.ts +1 -1
  109. package/dist/types/permissionless/index.d.ts +23 -10
  110. package/dist/types/permissionless/utils/governance/index.d.ts +1 -1
  111. package/dist/types/permissionless/utils/index.d.ts +1 -1
  112. package/package.json +1 -1
@@ -0,0 +1,99 @@
1
+ import { AbstractOffchainNamespace } from "../../../offchain/AbstractOffchainNamespace.js";
2
+ import { GearboxPermissionlessOptions } from "../types.js";
3
+ import { AttachChainsArgs, ChainSummaryArgs, PermissionlessChain, PermissionlessChainSummary } from "./types.js";
4
+ import { Chain, PublicClient, Transport } from "viem";
5
+ //#region src/permissionless/api/chains/ChainsNamespace.d.ts
6
+ /**
7
+ * The chains the permissionless stack runs on, and the viem clients that
8
+ * reach them.
9
+ *
10
+ * Both halves live here because they answer the same question. Which chains
11
+ * exist is the backend's to decide — it holds rows for chains it does not
12
+ * serve, and those must not be reachable — so the list is also the only
13
+ * honest basis for deciding which clients to build. Nothing is passed in: a
14
+ * caller that had to name the chains could name one the backend does not
15
+ * serve, or miss one it does.
16
+ *
17
+ * The list is fetched once, by {@link attach}, and kept for the client's
18
+ * lifetime:
19
+ *
20
+ * ```ts
21
+ * await permissionless.attach();
22
+ * const chains = permissionless.chains.list();
23
+ * ```
24
+ *
25
+ * Every read before that throws {@link PermissionlessNotAttachedError} rather
26
+ * than answering with an empty list, which would be indistinguishable from a
27
+ * backend that serves nothing.
28
+ *
29
+ * What {@link attach} reads is only what identifies a chain. The counters a
30
+ * list renders next to one are {@link summary}, a second read, because they
31
+ * aggregate over every market the backend knows and nothing should wait on
32
+ * that to start.
33
+ **/
34
+ declare class ChainsNamespace extends AbstractOffchainNamespace {
35
+ #private;
36
+ constructor(options: GearboxPermissionlessOptions);
37
+ /**
38
+ * Reads the chain list off the backend and builds a client for each chain
39
+ * it names.
40
+ *
41
+ * Idempotent, and joins a call already in flight, so a double invocation —
42
+ * React's StrictMode, two components mounting at once — costs one request.
43
+ * A second call with a different `scope` is a no-op: the list is decided
44
+ * once.
45
+ **/
46
+ attach({ scope }?: AttachChainsArgs): Promise<void>;
47
+ /**
48
+ * Whether {@link attach} has completed.
49
+ **/
50
+ get isAttached(): boolean;
51
+ /**
52
+ * Every chain the backend serves, in the order it listed them.
53
+ **/
54
+ list(): PermissionlessChain[];
55
+ /**
56
+ * One chain by id, or nothing when the backend does not serve it.
57
+ *
58
+ * Reads the attached list rather than a route of its own, which is also
59
+ * what makes "not served" and "not activated" distinguishable: the first is
60
+ * absence here, the second is {@link PermissionlessChain.isActivated}.
61
+ **/
62
+ find(chainId: number): PermissionlessChain | undefined;
63
+ /**
64
+ * The same chains, with the counters a list renders next to them.
65
+ *
66
+ * A read of its own, and not part of {@link attach}: the counters aggregate
67
+ * over every market configurator and market the backend knows, which is
68
+ * slow enough that waiting on it would hold up the whole client. A list
69
+ * renders off {@link list} and fills the numbers in when this resolves.
70
+ *
71
+ * Nothing is cached — each call is a request — so a caller that renders
72
+ * this should hold it in whatever already owns its async state.
73
+ *
74
+ * Covers the scope {@link attach} settled on unless one is named here, so
75
+ * the counters describe the list that is already on screen rather than a
76
+ * different set of chains.
77
+ *
78
+ * ```ts
79
+ * await permissionless.attach();
80
+ * const chains = permissionless.chains.list();
81
+ * const withCounters = await permissionless.chains.summary();
82
+ * ```
83
+ **/
84
+ summary({ scope }?: ChainSummaryArgs): Promise<PermissionlessChainSummary[]>;
85
+ /**
86
+ * Chains a client could be built for. A subset of {@link list} — see
87
+ * {@link client}.
88
+ **/
89
+ get chainIds(): number[];
90
+ /**
91
+ * The client for one chain.
92
+ *
93
+ * @throws {@link PermissionlessChainUnreachableError} when the backend does
94
+ * not serve the chain, or serves one this SDK carries no definition for.
95
+ **/
96
+ client(chainId: number): PublicClient<Transport, Chain>;
97
+ }
98
+ //#endregion
99
+ export { ChainsNamespace };
@@ -0,0 +1,3 @@
1
+ import { AttachChainsArgs, ChainScope, ChainSummaryArgs, PermissionlessChain, PermissionlessChainSummary } from "./types.js";
2
+ import { ChainsNamespace } from "./ChainsNamespace.js";
3
+ export { AttachChainsArgs, ChainScope, ChainSummaryArgs, ChainsNamespace, PermissionlessChain, PermissionlessChainSummary };
@@ -0,0 +1,49 @@
1
+ import { z } from "zod/v4";
2
+ //#region src/permissionless/api/chains/schemas.d.ts
3
+ /**
4
+ * Runtime schema for {@link PermissionlessChain}.
5
+ **/
6
+ declare const chainSchema: z.ZodObject<{
7
+ chainId: z.ZodNumber;
8
+ name: z.ZodString;
9
+ isPublic: z.ZodBoolean;
10
+ isActivated: z.ZodBoolean;
11
+ explorerUrl: z.ZodString;
12
+ }, z.core.$loose>;
13
+ /** What `GET /chain/list` answers with. */
14
+ declare const chainListSchema: z.ZodArray<z.ZodObject<{
15
+ chainId: z.ZodNumber;
16
+ name: z.ZodString;
17
+ isPublic: z.ZodBoolean;
18
+ isActivated: z.ZodBoolean;
19
+ explorerUrl: z.ZodString;
20
+ }, z.core.$loose>>;
21
+ /**
22
+ * Runtime schema for {@link PermissionlessChainSummary}.
23
+ *
24
+ * Strict about the two counters on purpose: they are the only reason this
25
+ * read exists, and a backend that answered without them would render as
26
+ * dashes where the numbers belong — a skew worth failing on rather than
27
+ * displaying.
28
+ **/
29
+ declare const chainSummarySchema: z.ZodObject<{
30
+ chainId: z.ZodNumber;
31
+ name: z.ZodString;
32
+ isPublic: z.ZodBoolean;
33
+ isActivated: z.ZodBoolean;
34
+ explorerUrl: z.ZodString;
35
+ riskCuratorsQty: z.ZodNumber;
36
+ marketsQty: z.ZodNumber;
37
+ }, z.core.$loose>;
38
+ /** What `GET /chain/summary` answers with. */
39
+ declare const chainSummaryListSchema: z.ZodArray<z.ZodObject<{
40
+ chainId: z.ZodNumber;
41
+ name: z.ZodString;
42
+ isPublic: z.ZodBoolean;
43
+ isActivated: z.ZodBoolean;
44
+ explorerUrl: z.ZodString;
45
+ riskCuratorsQty: z.ZodNumber;
46
+ marketsQty: z.ZodNumber;
47
+ }, z.core.$loose>>;
48
+ //#endregion
49
+ export { chainListSchema, chainSchema, chainSummaryListSchema, chainSummarySchema };
@@ -0,0 +1,58 @@
1
+ //#region src/permissionless/api/chains/types.d.ts
2
+ /**
3
+ * Which chains a read covers:
4
+ *
5
+ * - `public` — the ones open to everyone, the backend's default;
6
+ * - `all` — those plus the private ones the caller may see.
7
+ **/
8
+ type ChainScope = "public" | "all";
9
+ /**
10
+ * One chain the permissionless stack is deployed on.
11
+ *
12
+ * This list is what exists: the backend holds rows for chains it does not
13
+ * serve, and those are not reachable through it.
14
+ *
15
+ * Deliberately bare. It is read during {@link ChainsNamespace.attach}, which
16
+ * every other call waits on, so it carries only what identifies a chain and
17
+ * decides whether to show it. The counters are a second read, see
18
+ * {@link PermissionlessChainSummary}.
19
+ **/
20
+ interface PermissionlessChain {
21
+ chainId: number;
22
+ name: string;
23
+ /** Whether the instance is open to everyone, or only to its own curators. */
24
+ isPublic: boolean;
25
+ /**
26
+ * Whether the instance is live. A pending one has nothing to show, and the
27
+ * default `public` scope leaves it out.
28
+ **/
29
+ isActivated: boolean;
30
+ explorerUrl: string;
31
+ }
32
+ /**
33
+ * A chain with the counters a list renders next to it, see
34
+ * {@link ChainsNamespace.summary}.
35
+ **/
36
+ interface PermissionlessChainSummary extends PermissionlessChain {
37
+ riskCuratorsQty: number;
38
+ marketsQty: number;
39
+ }
40
+ /** Args of {@link ChainsNamespace.attach}. */
41
+ interface AttachChainsArgs {
42
+ /**
43
+ * @defaultValue `"public"`
44
+ **/
45
+ scope?: ChainScope;
46
+ }
47
+ /** Args of {@link ChainsNamespace.summary}. */
48
+ interface ChainSummaryArgs {
49
+ /**
50
+ * Which chains to count.
51
+ *
52
+ * @defaultValue the scope {@link ChainsNamespace.attach} settled on, so
53
+ * the counters describe the list already on screen.
54
+ **/
55
+ scope?: ChainScope;
56
+ }
57
+ //#endregion
58
+ export { AttachChainsArgs, ChainScope, ChainSummaryArgs, PermissionlessChain, PermissionlessChainSummary };
@@ -0,0 +1,69 @@
1
+ import { ChainsNamespace } from "../chains/ChainsNamespace.js";
2
+ import { DeployContractArgs, DeployPriceFeedArgs, PreparedDeployment, PreparedPriceFeedDeployment } from "./types.js";
3
+ import { Hex } from "viem";
4
+ //#region src/permissionless/api/deploy/PermissionlessDeploy.d.ts
5
+ /**
6
+ * Salt a generic contract deploy gets when the caller does not name one. Two
7
+ * deploys of the same type and arguments by the same owner collide under it,
8
+ * which for a singleton like a pause committee is the point.
9
+ **/
10
+ declare const DEFAULT_DEPLOY_SALT: Hex;
11
+ /**
12
+ * The salt a price feed is deployed under, derived from its name so that two
13
+ * feeds of the same type and arguments get different addresses.
14
+ **/
15
+ declare function priceFeedSalt(name: string): Hex;
16
+ /**
17
+ * Deploys through the BytecodeRepository: the constructor arguments it wants,
18
+ * the CREATE2 address those produce, and the transaction that gets there.
19
+ *
20
+ * Entirely on-chain — no backend is involved, every answer is derived from the
21
+ * target chain. Nothing is sent either: a browser holds the only wallet, so a
22
+ * call prepares the deploy and the caller sends
23
+ * {@link PreparedDeployment.tx} with whatever signs for them.
24
+ *
25
+ * ```ts
26
+ * const feed = await permissionless.deploy.priceFeed({
27
+ * chainId: 1,
28
+ * owner: account,
29
+ * contractType: "PRICE_FEED::CHAINLINK",
30
+ * version: 310,
31
+ * name: "WETH / USD",
32
+ * values,
33
+ * });
34
+ * if (!feed.isAlreadyDeployed) {
35
+ * await sendRawTx(wallet, { tx: feed.tx });
36
+ * }
37
+ * ```
38
+ **/
39
+ declare class PermissionlessDeploy {
40
+ #private;
41
+ constructor(chains: ChainsNamespace);
42
+ /**
43
+ * Prepares a price feed deploy from the values a form collected: encodes
44
+ * them the way the PriceFeedStore reads them back, and reports where the
45
+ * feed will land.
46
+ *
47
+ * A COMPOSITE's first leg is the one case where the values are not taken as
48
+ * given. It arrives with `stalenessPeriod` 0 whenever it is a derived feed,
49
+ * because the store registers those with 0 and rejects anything else — which
50
+ * says nothing about what the leg itself enforces. A composite built on that
51
+ * 0 can never pass its own staleness check, so the real bound is read off
52
+ * the leg, see {@link deriveEffectiveStalenessPeriod}.
53
+ *
54
+ * The deployed feed reaches {@link PermissionlessOracles.store} only once
55
+ * it is in the PriceFeedStore, which is a batch the instance owner
56
+ * executes, see {@link InstanceOwnerTransactions.addFeeds}.
57
+ **/
58
+ priceFeed(args: DeployPriceFeedArgs): Promise<PreparedPriceFeedDeployment>;
59
+ /**
60
+ * Prepares a generic contract deploy from ABI type/value pairs.
61
+ *
62
+ * Unlike a price feed, the arguments here are already typed by the caller,
63
+ * so nothing is looked up: they are encoded as given and the address they
64
+ * produce is reported.
65
+ **/
66
+ contract(args: DeployContractArgs): Promise<PreparedDeployment>;
67
+ }
68
+ //#endregion
69
+ export { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt };
@@ -0,0 +1,19 @@
1
+ import { Address, PublicClient } from "viem";
2
+ //#region src/permissionless/api/deploy/effective-staleness.d.ts
3
+ /**
4
+ * The staleness a deployed price feed enforces on the price it reports.
5
+ *
6
+ * This is deliberately not the value the feed is registered with in the
7
+ * PriceFeedStore — derived feeds must be registered with 0 there, and the store
8
+ * rejects anything else for them with `IncorrectParameterException()`. It is
9
+ * the value a parent feed needs when it re-checks the leg's `updatedAt`
10
+ * itself.
11
+ *
12
+ * Returns `null` when it cannot be determined. Callers must surface that
13
+ * rather than substitute a bound: a leg constructed with a staleness its
14
+ * underlying oracle can never satisfy produces a feed that reverts on every
15
+ * read and can never be added to the store.
16
+ **/
17
+ declare function deriveEffectiveStalenessPeriod(client: PublicClient, address: Address): Promise<number | null>;
18
+ //#endregion
19
+ export { deriveEffectiveStalenessPeriod };
@@ -0,0 +1,4 @@
1
+ import { DeployArgs, DeployContractArgs, DeployPriceFeedArgs, PreparedDeployment, PreparedPriceFeedDeployment } from "./types.js";
2
+ import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./PermissionlessDeploy.js";
3
+ import { deriveEffectiveStalenessPeriod } from "./effective-staleness.js";
4
+ export { DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployPriceFeedArgs, PermissionlessDeploy, PreparedDeployment, PreparedPriceFeedDeployment, deriveEffectiveStalenessPeriod, priceFeedSalt };
@@ -0,0 +1,87 @@
1
+ import { RawTx } from "../../../onchain/types/transactions.js";
2
+ import "../../../onchain/index.js";
3
+ import { InputValueParams } from "../../core/pricefeed-builder.js";
4
+ import "../../core/index.js";
5
+ import { FunctionParams } from "../../utils/abi-encoder.js";
6
+ import { Address, Hex } from "viem";
7
+ //#region src/permissionless/api/deploy/types.d.ts
8
+ /**
9
+ * What both deploy flows name: which chain to read, and who the deployer is.
10
+ * `owner` goes into the CREATE2 derivation, so it has to be the address that
11
+ * will send {@link PreparedDeployment.tx} — anyone else's send lands on a
12
+ * different address.
13
+ *
14
+ * The chain must be among the ones the client was constructed with, see
15
+ * {@link GearboxPermissionlessOptions.chains}.
16
+ **/
17
+ interface DeployArgs {
18
+ chainId: number;
19
+ owner: Address;
20
+ contractType: string;
21
+ version: number;
22
+ }
23
+ /** Args of {@link PermissionlessDeploy.priceFeed}. */
24
+ interface DeployPriceFeedArgs extends DeployArgs {
25
+ /**
26
+ * Constructor values keyed by the labels of the feed's
27
+ * {@link PriceFeedSetupParams}, i.e. what a form collects.
28
+ **/
29
+ values: Record<string, InputValueParams>;
30
+ /**
31
+ * Name the feed is deployed under. Used as the CREATE2 salt unless
32
+ * {@link salt} is given, which is what makes two feeds of the same type and
33
+ * args land on different addresses.
34
+ **/
35
+ name?: string;
36
+ /** @see {@link priceFeedSalt} for the default derived from {@link name}. */
37
+ salt?: Hex;
38
+ }
39
+ /** Args of {@link PermissionlessDeploy.contract}. */
40
+ interface DeployContractArgs extends DeployArgs {
41
+ /** Constructor values as ABI type/value pairs. */
42
+ values: FunctionParams[];
43
+ /**
44
+ * @defaultValue {@link DEFAULT_DEPLOY_SALT}
45
+ **/
46
+ salt?: Hex;
47
+ }
48
+ /**
49
+ * A deploy that has been resolved against the chain but not sent.
50
+ *
51
+ * Nothing here touches a wallet: sending is left to the caller, who in a
52
+ * browser holds the only one. A caller that signs with viem sends
53
+ * {@link tx} through `sendRawTx`; one on wagmi can either do the same or call
54
+ * `BytecodeRepository.deploy` itself with the fields below.
55
+ **/
56
+ interface PreparedDeployment {
57
+ contractType: string;
58
+ version: number;
59
+ owner: Address;
60
+ salt: Hex;
61
+ /** ABI-encoded constructor arguments, as the repository expects them. */
62
+ encodedParams: Hex;
63
+ /** Where CREATE2 puts the contract for this `owner`, type, args and salt. */
64
+ address: Address;
65
+ /**
66
+ * Whether that address already holds code. When it does, {@link tx} would
67
+ * revert, and the deploy the caller wanted has already happened.
68
+ **/
69
+ isAlreadyDeployed: boolean;
70
+ /** `BytecodeRepository.deploy(contractType, version, encodedParams, salt)`. */
71
+ tx: RawTx;
72
+ }
73
+ /**
74
+ * A prepared price feed deploy, plus the constructor values that were actually
75
+ * encoded.
76
+ **/
77
+ interface PreparedPriceFeedDeployment extends PreparedDeployment {
78
+ /**
79
+ * {@link DeployPriceFeedArgs.values} after the bounds that had to be read
80
+ * off the chain were filled in, see
81
+ * {@link deriveEffectiveStalenessPeriod}. Encoding these again reproduces
82
+ * {@link PreparedDeployment.encodedParams} byte for byte.
83
+ **/
84
+ values: Record<string, InputValueParams>;
85
+ }
86
+ //#endregion
87
+ export { DeployArgs, DeployContractArgs, DeployPriceFeedArgs, PreparedDeployment, PreparedPriceFeedDeployment };
@@ -0,0 +1,63 @@
1
+ import { Address, BaseError } from "viem";
2
+ //#region src/permissionless/api/errors.d.ts
3
+ /**
4
+ * Thrown when anything is read off {@link ChainsNamespace} before
5
+ * {@link GearboxPermissionless.attach} has completed.
6
+ *
7
+ * The chain list is the backend's answer, so there is nothing to report until
8
+ * it arrives. Answering with an empty list instead would be indistinguishable
9
+ * from a backend that serves no chains at all.
10
+ **/
11
+ declare class PermissionlessNotAttachedError extends BaseError {
12
+ name: string;
13
+ constructor();
14
+ }
15
+ /**
16
+ * Thrown when a call has to read a chain the client holds no viem client for.
17
+ *
18
+ * Either the backend does not serve the chain, or it serves one this SDK
19
+ * carries no definition for: endpoints come from the chain definition, since
20
+ * the backend's own urls carry provider keys and are never handed out.
21
+ **/
22
+ declare class PermissionlessChainUnreachableError extends BaseError {
23
+ name: string;
24
+ /** Chain that was asked for. */
25
+ readonly chainId: number;
26
+ constructor(chainId: number);
27
+ }
28
+ /**
29
+ * Thrown when a rename names a feed the PriceFeedStore does not carry. A name
30
+ * is part of what the store holds, so there is nothing to change on a feed
31
+ * that never reached it.
32
+ **/
33
+ declare class PriceFeedNotInStoreError extends BaseError {
34
+ name: string;
35
+ /** Feed that was named. */
36
+ readonly priceFeed: Address;
37
+ readonly chainId: number;
38
+ constructor(priceFeed: Address, chainId: number);
39
+ }
40
+ /**
41
+ * Thrown when a composite feed names a leg whose own staleness bound cannot be
42
+ * read off the chain.
43
+ *
44
+ * Deploying with a placeholder is not an option: a composite whose check can
45
+ * never pass reverts on every read, and the store will not take it. The bound
46
+ * has to be set on the leg first.
47
+ **/
48
+ declare class PriceFeedStalenessUnknownError extends BaseError {
49
+ name: string;
50
+ /** Leg whose bound could not be determined. */
51
+ readonly priceFeed: Address;
52
+ constructor(priceFeed: Address);
53
+ }
54
+ /**
55
+ * Thrown when a price feed deploy names neither a salt nor the name one would
56
+ * be derived from, leaving CREATE2 nothing to distinguish it by.
57
+ **/
58
+ declare class PriceFeedSaltMissingError extends BaseError {
59
+ name: string;
60
+ constructor();
61
+ }
62
+ //#endregion
63
+ export { PermissionlessChainUnreachableError, PermissionlessNotAttachedError, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError };
@@ -0,0 +1,17 @@
1
+ import { GearboxPermissionlessOptions } from "./types.js";
2
+ import { AttachChainsArgs, ChainScope, ChainSummaryArgs, PermissionlessChain, PermissionlessChainSummary } from "./chains/types.js";
3
+ import { ChainsNamespace } from "./chains/ChainsNamespace.js";
4
+ import { DeployArgs, DeployContractArgs, DeployPriceFeedArgs, PreparedDeployment, PreparedPriceFeedDeployment } from "./deploy/types.js";
5
+ import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./deploy/PermissionlessDeploy.js";
6
+ import { GetPricesArgs, PermissionlessAsset, PermissionlessPriceFeedStatus, PermissionlessPriceFeedStore, PermissionlessPrices } from "./oracles/types.js";
7
+ import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./oracles/PermissionlessOracles.js";
8
+ import { ChangeNamesArgs, ChangeStalenessPeriodsArgs, ForbidFeedsArgs, InstanceTxsArgs } from "./transactions/types.js";
9
+ import { InstanceOwnerTransactions } from "./transactions/InstanceOwnerTransactions.js";
10
+ import { GearboxPermissionless } from "./GearboxPermissionless.js";
11
+ import "./chains/index.js";
12
+ import { deriveEffectiveStalenessPeriod } from "./deploy/effective-staleness.js";
13
+ import "./deploy/index.js";
14
+ import { PermissionlessChainUnreachableError, PermissionlessNotAttachedError, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError } from "./errors.js";
15
+ import "./oracles/index.js";
16
+ import "./transactions/index.js";
17
+ export { AttachChainsArgs, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployPriceFeedArgs, ForbidFeedsArgs, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions, GetPricesArgs, InstanceOwnerTransactions, InstanceTxsArgs, PermissionlessAsset, PermissionlessChain, PermissionlessChainSummary, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PermissionlessPriceFeedStatus, PermissionlessPriceFeedStore, PermissionlessPrices, PreparedDeployment, PreparedPriceFeedDeployment, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, deriveEffectiveStalenessPeriod, priceFeedSalt };
@@ -0,0 +1,64 @@
1
+ import { AbstractOffchainNamespace } from "../../../offchain/AbstractOffchainNamespace.js";
2
+ import { GearboxPermissionlessOptions } from "../types.js";
3
+ import { ChainsNamespace } from "../chains/ChainsNamespace.js";
4
+ import { GetPricesArgs, PermissionlessPriceFeedStore, PermissionlessPrices } from "./types.js";
5
+ import { Address } from "viem";
6
+ //#region src/permissionless/api/oracles/PermissionlessOracles.d.ts
7
+ declare const GET_PRICES_GAS_LIMIT_BY_CHAIN_ID: Record<number, bigint>;
8
+ declare const GET_PRICES_CHUNK_SIZE = 200;
9
+ /**
10
+ * The price feeds of one chain: the PriceFeedStore as the backend has indexed
11
+ * it, and the prices behind it.
12
+ *
13
+ * ```ts
14
+ * const store = await permissionless.oracles.store({ chainId: 1 });
15
+ * const { prices } = await permissionless.oracles.prices({ chainId: 1 });
16
+ * ```
17
+ *
18
+ * Read-only. What the store carries is decided on chain, so putting a feed
19
+ * there is a batch the instance owner executes — see
20
+ * {@link InstanceOwnerTransactions} — not a row a client writes here.
21
+ **/
22
+ declare class PermissionlessOracles extends AbstractOffchainNamespace {
23
+ #private;
24
+ constructor(options: GearboxPermissionlessOptions, chains: ChainsNamespace);
25
+ /**
26
+ * The store with the assets and feeds of one chain.
27
+ **/
28
+ store({ chainId }: {
29
+ chainId: number;
30
+ }): Promise<PermissionlessPriceFeedStore>;
31
+ /**
32
+ * A price per feed, and a market cap per feed and asset. The feeds the
33
+ * indexer has not seen are read off the chain by the backend, so the store
34
+ * is priced whole.
35
+ **/
36
+ prices({ chainId }: {
37
+ chainId: number;
38
+ }): Promise<PermissionlessPrices>;
39
+ /**
40
+ * The price each of the named feeds reports, read off the chain.
41
+ *
42
+ * Where {@link prices} answers for the store as a whole and at whatever
43
+ * moment the backend priced it, this prices exactly the feeds asked for, at
44
+ * the current block. A feed the store does not carry prices the same way,
45
+ * which is what makes this the call to reach for after a deploy, or while a
46
+ * form is still choosing between candidates.
47
+ *
48
+ * Feeds needing a fresh answer before they can be read are updated inside
49
+ * the same simulation, so a push-based feed prices as readily as a
50
+ * pull-based one. `null` is a feed whose read reverted, not a zero.
51
+ *
52
+ * ```ts
53
+ * const prices = await permissionless.oracles.getPrices({
54
+ * chainId: 1,
55
+ * priceFeeds: [feed],
56
+ * });
57
+ * ```
58
+ *
59
+ * @returns A price per feed, in the 8 decimals every Gearbox feed reports.
60
+ **/
61
+ getPrices({ chainId, priceFeeds }: GetPricesArgs): Promise<Record<Address, bigint | null>>;
62
+ }
63
+ //#endregion
64
+ export { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles };
@@ -0,0 +1,3 @@
1
+ import { GetPricesArgs, PermissionlessAsset, PermissionlessPriceFeedStatus, PermissionlessPriceFeedStore, PermissionlessPrices } from "./types.js";
2
+ import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./PermissionlessOracles.js";
3
+ export { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GetPricesArgs, PermissionlessAsset, PermissionlessOracles, PermissionlessPriceFeedStatus, PermissionlessPriceFeedStore, PermissionlessPrices };
@@ -0,0 +1,103 @@
1
+ import { z } from "zod/v4";
2
+ //#region src/permissionless/api/oracles/schemas.d.ts
3
+ /**
4
+ * Runtime schemas for {@link ./types.js}.
5
+ *
6
+ * The objects are loose: the backend reads most of these rows straight off the
7
+ * chain through the SDK's own bindings, which attach fields the hand-written
8
+ * types do not declare, and dropping them would make this client lossier than
9
+ * the payload it decodes.
10
+ **/
11
+ /** {@link PriceFeed}, as the backend serves it. */
12
+ declare const priceFeedSchema: z.ZodObject<{
13
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
14
+ contractType: z.ZodString;
15
+ version: z.ZodNumber;
16
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
17
+ isInStore: z.ZodBoolean;
18
+ stalenessPeriod: z.ZodNumber;
19
+ name: z.ZodString;
20
+ }, z.core.$loose>;
21
+ /** {@link PermissionlessPriceFeedStatus} */
22
+ declare const priceFeedStatusSchema: z.ZodEnum<{
23
+ forbidden: "forbidden";
24
+ inStore: "inStore";
25
+ pendingForbidden: "pendingForbidden";
26
+ private: "private";
27
+ }>;
28
+ /** {@link PermissionlessAsset} */
29
+ declare const assetSchema: z.ZodObject<{
30
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
31
+ symbol: z.ZodString;
32
+ name: z.ZodString;
33
+ decimals: z.ZodNumber;
34
+ isInStore: z.ZodBoolean;
35
+ owner: z.ZodCustom<`0x${string}`, `0x${string}`>;
36
+ priceFeeds: z.ZodArray<z.ZodObject<{
37
+ pricefeed: z.ZodObject<{
38
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
39
+ contractType: z.ZodString;
40
+ version: z.ZodNumber;
41
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
42
+ isInStore: z.ZodBoolean;
43
+ stalenessPeriod: z.ZodNumber;
44
+ name: z.ZodString;
45
+ }, z.core.$loose>;
46
+ status: z.ZodEnum<{
47
+ forbidden: "forbidden";
48
+ inStore: "inStore";
49
+ pendingForbidden: "pendingForbidden";
50
+ private: "private";
51
+ }>;
52
+ }, z.core.$loose>>;
53
+ }, z.core.$loose>;
54
+ /** {@link PermissionlessPriceFeedStore} */
55
+ declare const priceFeedStoreSchema: z.ZodObject<{
56
+ chainId: z.ZodNumber;
57
+ name: z.ZodString;
58
+ isPublic: z.ZodBoolean;
59
+ isActivated: z.ZodBoolean;
60
+ explorerUrl: z.ZodString;
61
+ assets: z.ZodArray<z.ZodObject<{
62
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
63
+ symbol: z.ZodString;
64
+ name: z.ZodString;
65
+ decimals: z.ZodNumber;
66
+ isInStore: z.ZodBoolean;
67
+ owner: z.ZodCustom<`0x${string}`, `0x${string}`>;
68
+ priceFeeds: z.ZodArray<z.ZodObject<{
69
+ pricefeed: z.ZodObject<{
70
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
71
+ contractType: z.ZodString;
72
+ version: z.ZodNumber;
73
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
74
+ isInStore: z.ZodBoolean;
75
+ stalenessPeriod: z.ZodNumber;
76
+ name: z.ZodString;
77
+ }, z.core.$loose>;
78
+ status: z.ZodEnum<{
79
+ forbidden: "forbidden";
80
+ inStore: "inStore";
81
+ pendingForbidden: "pendingForbidden";
82
+ private: "private";
83
+ }>;
84
+ }, z.core.$loose>>;
85
+ }, z.core.$loose>>;
86
+ priceFeeds: z.ZodArray<z.ZodObject<{
87
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
88
+ contractType: z.ZodString;
89
+ version: z.ZodNumber;
90
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
91
+ isInStore: z.ZodBoolean;
92
+ stalenessPeriod: z.ZodNumber;
93
+ name: z.ZodString;
94
+ }, z.core.$loose>>;
95
+ }, z.core.$loose>;
96
+ /** {@link PermissionlessPrices} */
97
+ declare const pricesSchema: z.ZodObject<{
98
+ prices: z.ZodType<Record<`0x${string}`, string | null>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, string | null>, unknown>>;
99
+ marketCaps: z.ZodType<Record<`0x${string}`, Record<`0x${string}`, string | null>>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, Record<`0x${string}`, string | null>>, unknown>>;
100
+ time: z.ZodNumber;
101
+ }, z.core.$loose>;
102
+ //#endregion
103
+ export { assetSchema, priceFeedSchema, priceFeedStatusSchema, priceFeedStoreSchema, pricesSchema };