@gearbox-protocol/sdk 18.1.0 → 18.2.0-next.10

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 (98) hide show
  1. package/dist/cjs/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +179 -0
  2. package/dist/cjs/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +534 -0
  3. package/dist/cjs/abi/router/treehouseWorker.js +885 -0
  4. package/dist/cjs/onchain/market/adapters/abi/actionAbi.js +1 -0
  5. package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +3 -0
  6. package/dist/cjs/onchain/market/adapters/types.js +3 -0
  7. package/dist/cjs/permissionless/api/GearboxPermissionless.js +12 -5
  8. package/dist/cjs/permissionless/api/analytics/PermissionlessAnalytics.js +50 -0
  9. package/dist/cjs/permissionless/api/analytics/index.js +4 -0
  10. package/dist/cjs/permissionless/api/analytics/schemas.js +27 -0
  11. package/dist/cjs/permissionless/api/analytics/types.js +1 -0
  12. package/dist/cjs/permissionless/api/index.js +3 -0
  13. package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +444 -28
  14. package/dist/cjs/permissionless/api/oracles/enrich.js +99 -0
  15. package/dist/cjs/permissionless/api/oracles/schemas.js +102 -16
  16. package/dist/cjs/permissionless/api/schemas.js +0 -3
  17. package/dist/cjs/permissionless/bindings/index.js +1 -1
  18. package/dist/cjs/permissionless/index.js +4 -1
  19. package/dist/cjs/permissionless/utils/index.js +1 -0
  20. package/dist/cjs/permissionless/utils/price-update/get-prices.js +25 -0
  21. package/dist/cjs/permissionless/utils/price-update/index.js +1 -0
  22. package/dist/cjs/testnets/TestnetsAPI.js +179 -0
  23. package/dist/cjs/testnets/errors/TestnetNotFoundError.js +15 -0
  24. package/dist/cjs/testnets/errors/TestnetRequestFailedError.js +24 -0
  25. package/dist/cjs/testnets/errors/TestnetStatusError.js +19 -0
  26. package/dist/cjs/testnets/errors/TestnetValidationError.js +24 -0
  27. package/dist/cjs/testnets/errors/TestnetWaitTimeoutError.js +30 -0
  28. package/dist/cjs/testnets/errors/TestnetsError.js +34 -0
  29. package/dist/cjs/testnets/errors/index.js +13 -0
  30. package/dist/cjs/testnets/index.js +32 -0
  31. package/dist/cjs/testnets/package.json +1 -0
  32. package/dist/cjs/testnets/schemas.js +242 -0
  33. package/dist/cjs/testnets/types.js +1 -0
  34. package/dist/esm/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +178 -0
  35. package/dist/esm/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +533 -0
  36. package/dist/esm/abi/router/treehouseWorker.js +884 -0
  37. package/dist/esm/onchain/market/adapters/abi/actionAbi.js +1 -0
  38. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +3 -0
  39. package/dist/esm/onchain/market/adapters/types.js +3 -0
  40. package/dist/esm/permissionless/api/GearboxPermissionless.js +12 -5
  41. package/dist/esm/permissionless/api/analytics/PermissionlessAnalytics.js +49 -0
  42. package/dist/esm/permissionless/api/analytics/index.js +2 -0
  43. package/dist/esm/permissionless/api/analytics/schemas.js +25 -0
  44. package/dist/esm/permissionless/api/analytics/types.js +1 -0
  45. package/dist/esm/permissionless/api/index.js +3 -1
  46. package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +446 -30
  47. package/dist/esm/permissionless/api/oracles/enrich.js +94 -0
  48. package/dist/esm/permissionless/api/oracles/schemas.js +94 -17
  49. package/dist/esm/permissionless/api/schemas.js +2 -4
  50. package/dist/esm/permissionless/bindings/index.js +1 -1
  51. package/dist/esm/permissionless/index.js +4 -3
  52. package/dist/esm/permissionless/utils/index.js +2 -2
  53. package/dist/esm/permissionless/utils/price-update/get-prices.js +25 -1
  54. package/dist/esm/permissionless/utils/price-update/index.js +2 -2
  55. package/dist/esm/testnets/TestnetsAPI.js +178 -0
  56. package/dist/esm/testnets/errors/TestnetNotFoundError.js +14 -0
  57. package/dist/esm/testnets/errors/TestnetRequestFailedError.js +23 -0
  58. package/dist/esm/testnets/errors/TestnetStatusError.js +18 -0
  59. package/dist/esm/testnets/errors/TestnetValidationError.js +23 -0
  60. package/dist/esm/testnets/errors/TestnetWaitTimeoutError.js +29 -0
  61. package/dist/esm/testnets/errors/TestnetsError.js +33 -0
  62. package/dist/esm/testnets/errors/index.js +7 -0
  63. package/dist/esm/testnets/index.js +11 -0
  64. package/dist/esm/testnets/package.json +1 -0
  65. package/dist/esm/testnets/schemas.js +228 -0
  66. package/dist/esm/testnets/types.js +1 -0
  67. package/dist/types/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.d.ts +148 -0
  68. package/dist/types/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.d.ts +440 -0
  69. package/dist/types/abi/router/treehouseWorker.d.ts +728 -0
  70. package/dist/types/onchain/market/adapters/types.d.ts +4 -1
  71. package/dist/types/permissionless/api/GearboxPermissionless.d.ts +11 -5
  72. package/dist/types/permissionless/api/analytics/PermissionlessAnalytics.d.ts +38 -0
  73. package/dist/types/permissionless/api/analytics/index.d.ts +3 -0
  74. package/dist/types/permissionless/api/analytics/schemas.d.ts +32 -0
  75. package/dist/types/permissionless/api/analytics/types.d.ts +38 -0
  76. package/dist/types/permissionless/api/index.d.ts +5 -2
  77. package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +159 -22
  78. package/dist/types/permissionless/api/oracles/enrich.d.ts +59 -0
  79. package/dist/types/permissionless/api/oracles/index.d.ts +2 -2
  80. package/dist/types/permissionless/api/oracles/schemas.d.ts +202 -7
  81. package/dist/types/permissionless/api/oracles/types.d.ts +401 -22
  82. package/dist/types/permissionless/api/schemas.d.ts +0 -2
  83. package/dist/types/permissionless/index.d.ts +5 -3
  84. package/dist/types/permissionless/utils/index.d.ts +2 -2
  85. package/dist/types/permissionless/utils/price-update/get-prices.d.ts +17 -0
  86. package/dist/types/permissionless/utils/price-update/index.d.ts +2 -2
  87. package/dist/types/testnets/TestnetsAPI.d.ts +108 -0
  88. package/dist/types/testnets/errors/TestnetNotFoundError.d.ts +12 -0
  89. package/dist/types/testnets/errors/TestnetRequestFailedError.d.ts +11 -0
  90. package/dist/types/testnets/errors/TestnetStatusError.d.ts +15 -0
  91. package/dist/types/testnets/errors/TestnetValidationError.d.ts +16 -0
  92. package/dist/types/testnets/errors/TestnetWaitTimeoutError.d.ts +21 -0
  93. package/dist/types/testnets/errors/TestnetsError.d.ts +47 -0
  94. package/dist/types/testnets/errors/index.d.ts +7 -0
  95. package/dist/types/testnets/index.d.ts +11 -0
  96. package/dist/types/testnets/schemas.d.ts +554 -0
  97. package/dist/types/testnets/types.d.ts +717 -0
  98. package/package.json +9 -3
@@ -32,6 +32,7 @@ const adapterActionSignatures = {
32
32
  311: "function setPairStatusBatch((address,address,address,uint8,uint8)[])"
33
33
  },
34
34
  ["TRADERJOE_ROUTER"]: { 310: "function setPoolStatusBatch((address,address,uint256,uint8,bool)[])" },
35
+ ["TREEHOUSE_ROUTER"]: { 310: "function setAssetStatusBatch(address[],bool[])" },
35
36
  ["UNISWAP_V2_ROUTER"]: { 310: "function setPairStatusBatch((address,address,bool)[])" },
36
37
  ["UNISWAP_V3_ROUTER"]: { 310: "function setPoolStatusBatch((address,address,uint24,bool)[])" },
37
38
  ["UNISWAP_V4_GATEWAY"]: { 310: "function setPoolKeyStatusBatch(((address,address,uint24,int24,address),bool)[])" },
@@ -35,6 +35,9 @@ const adapterConstructorAbi = {
35
35
  ["UNISWAP_V4_GATEWAY"]: { 310: BASIC_ADAPTER_ABI },
36
36
  ["VELODROME_V2_ROUTER"]: { 310: BASIC_ADAPTER_ABI },
37
37
  ["SECURITIZE_ONRAMP"]: { 310: BASIC_ADAPTER_ABI },
38
+ ["TREEHOUSE_FASTLANE"]: { 310: BASIC_ADAPTER_ABI },
39
+ ["TREEHOUSE_GATEWAY"]: { 310: BASIC_ADAPTER_ABI },
40
+ ["TREEHOUSE_ROUTER"]: { 310: BASIC_ADAPTER_ABI },
38
41
  ["CURVE_V1_2ASSETS"]: { 311: CURVE_V1_ADAPTER_311_ABI },
39
42
  ["CURVE_V1_3ASSETS"]: { 311: CURVE_V1_ADAPTER_311_ABI },
40
43
  ["CURVE_V1_4ASSETS"]: { 311: CURVE_V1_ADAPTER_311_ABI },
@@ -33,6 +33,9 @@ let AdapterType = /* @__PURE__ */ function(AdapterType) {
33
33
  AdapterType["SECURITIZE_REDEMPTION"] = "SECURITIZE_REDEMPTION";
34
34
  AdapterType["STAKING_REWARDS"] = "STAKING_REWARDS";
35
35
  AdapterType["TRADERJOE_ROUTER"] = "TRADERJOE_ROUTER";
36
+ AdapterType["TREEHOUSE_FASTLANE"] = "TREEHOUSE_FASTLANE";
37
+ AdapterType["TREEHOUSE_GATEWAY"] = "TREEHOUSE_GATEWAY";
38
+ AdapterType["TREEHOUSE_ROUTER"] = "TREEHOUSE_ROUTER";
36
39
  AdapterType["UNISWAP_V2_ROUTER"] = "UNISWAP_V2_ROUTER";
37
40
  AdapterType["UNISWAP_V3_ROUTER"] = "UNISWAP_V3_ROUTER";
38
41
  AdapterType["UNISWAP_V4_GATEWAY"] = "UNISWAP_V4_GATEWAY";
@@ -1,3 +1,4 @@
1
+ import { PermissionlessAnalytics } from "./analytics/PermissionlessAnalytics.js";
1
2
  import { ChainsNamespace } from "./chains/ChainsNamespace.js";
2
3
  import { PermissionlessDeploy } from "./deploy/PermissionlessDeploy.js";
3
4
  import { PermissionlessOracles } from "./oracles/PermissionlessOracles.js";
@@ -24,11 +25,11 @@ import { InstanceOwnerTransactions } from "./transactions/InstanceOwnerTransacti
24
25
  * const store = await permissionless.oracles.store({ chainId: chain.chainId });
25
26
  * ```
26
27
  *
27
- * Only what needs a server goes to one. {@link chains} and {@link oracles}
28
- * are the backend's reads; {@link deploy} and {@link transactions} read the
29
- * target chain directly, because everything they answer is derived from there
30
- * and a round trip would only move the derivation further from the wallet
31
- * that has to sign for it.
28
+ * Only what needs a server goes to one. {@link chains}, {@link oracles} and
29
+ * {@link analytics} are the backend's reads; {@link deploy} and
30
+ * {@link transactions} read the target chain directly, because everything
31
+ * they answer is derived from there and a round trip would only move the
32
+ * derivation further from the wallet that has to sign for it.
32
33
  **/
33
34
  var GearboxPermissionless = class {
34
35
  /**
@@ -41,6 +42,11 @@ var GearboxPermissionless = class {
41
42
  **/
42
43
  oracles;
43
44
  /**
45
+ * Namespace for history: what a feed's price did over a window, see
46
+ * {@link PermissionlessAnalytics}.
47
+ **/
48
+ analytics;
49
+ /**
44
50
  * Namespace for the Safe batches an instance owner executes. Backend-free,
45
51
  * see {@link InstanceOwnerTransactions}.
46
52
  **/
@@ -53,6 +59,7 @@ var GearboxPermissionless = class {
53
59
  constructor(options = {}) {
54
60
  this.chains = new ChainsNamespace(options);
55
61
  this.oracles = new PermissionlessOracles(options, this.chains);
62
+ this.analytics = new PermissionlessAnalytics(options);
56
63
  this.transactions = new InstanceOwnerTransactions(this.chains, this.oracles);
57
64
  this.deploy = new PermissionlessDeploy(this.chains);
58
65
  }
@@ -0,0 +1,49 @@
1
+ import { AbstractOffchainNamespace } from "../../../offchain/AbstractOffchainNamespace.js";
2
+ import { priceFeedChartSchema } from "./schemas.js";
3
+ //#region src/permissionless/api/analytics/PermissionlessAnalytics.ts
4
+ /**
5
+ * History of the permissionless stack: what a thing did, rather than what it
6
+ * is.
7
+ *
8
+ * Separate from {@link PermissionlessOracles} because the two are read on
9
+ * different clocks. A feed's identity settles when a curator uploads it and
10
+ * is read once per page; its price moves every block and is re-read whenever
11
+ * a window changes. Folding the series into the feed would make every range
12
+ * switch re-fetch the identity, and every identity read carry a series the
13
+ * caller may never draw.
14
+ *
15
+ * ```ts
16
+ * const chart = await permissionless.analytics.priceChart({
17
+ * chainId: 1,
18
+ * address: feed,
19
+ * range: "1w",
20
+ * });
21
+ * ```
22
+ **/
23
+ var PermissionlessAnalytics = class extends AbstractOffchainNamespace {
24
+ constructor(options) {
25
+ super("PermissionlessAnalytics", {
26
+ ...options,
27
+ chainIds: []
28
+ });
29
+ }
30
+ /**
31
+ * The price one feed reported over a window.
32
+ *
33
+ * Backend-only by construction: the chain serves the present, and
34
+ * reconstructing a series from it would mean an archive read per point.
35
+ *
36
+ * @throws When the PriceFeedStore does not carry the feed. An address the
37
+ * store never held has no indexed history, and answering an empty series
38
+ * would read as "no price yet" rather than as the mistake it is.
39
+ **/
40
+ async priceChart({ chainId, address, range }) {
41
+ return this.getData({
42
+ path: `/pfs/${chainId}/price-feed/${address}/chart`,
43
+ query: { range },
44
+ schema: priceFeedChartSchema
45
+ });
46
+ }
47
+ };
48
+ //#endregion
49
+ export { PermissionlessAnalytics };
@@ -0,0 +1,2 @@
1
+ export { PermissionlessAnalytics } from "./PermissionlessAnalytics.js";
2
+ import "./types.js";
@@ -0,0 +1,25 @@
1
+ import { CHART_RANGES } from "../../../model/charts.js";
2
+ import { z } from "zod/v4";
3
+ //#region src/permissionless/api/analytics/schemas.ts
4
+ /**
5
+ * Runtime schemas for {@link ./types.js}.
6
+ *
7
+ * Loose for the same reason the oracles schemas are: the backend assembles
8
+ * these rows from its own indexes and may report more about a window than the
9
+ * hand-written types declare.
10
+ **/
11
+ /** {@link PriceFeedChartPoint} */
12
+ const priceFeedChartPointSchema = z.looseObject({
13
+ timestamp: z.number(),
14
+ value: z.number()
15
+ });
16
+ /** {@link PriceFeedPriceChart} */
17
+ const priceFeedChartSchema = z.looseObject({
18
+ range: z.enum(CHART_RANGES),
19
+ from: z.number(),
20
+ to: z.number(),
21
+ intervalSeconds: z.number(),
22
+ points: z.array(priceFeedChartPointSchema)
23
+ });
24
+ //#endregion
25
+ export { priceFeedChartPointSchema, priceFeedChartSchema };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,5 @@
1
+ import { PermissionlessAnalytics } from "./analytics/PermissionlessAnalytics.js";
2
+ import "./analytics/index.js";
1
3
  import { PermissionlessChainUnreachableError, PermissionlessNotAttachedError, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError } from "./errors.js";
2
4
  import { ChainsNamespace } from "./chains/ChainsNamespace.js";
3
5
  import "./chains/index.js";
@@ -10,4 +12,4 @@ import { GearboxPermissionless } from "./GearboxPermissionless.js";
10
12
  import "./oracles/index.js";
11
13
  import "./transactions/index.js";
12
14
  import "./types.js";
13
- export { ChainsNamespace, DEFAULT_DEPLOY_SALT, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, InstanceOwnerTransactions, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, deriveEffectiveStalenessPeriod, priceFeedSalt };
15
+ export { ChainsNamespace, DEFAULT_DEPLOY_SALT, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, InstanceOwnerTransactions, PermissionlessAnalytics, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, deriveEffectiveStalenessPeriod, priceFeedSalt };