@gearbox-protocol/sdk 17.10.1 → 17.12.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.
- package/dist/cjs/offchain/AbstractOffchainNamespace.js +31 -8
- package/dist/cjs/permissionless/api/GearboxPermissionless.js +79 -0
- package/dist/cjs/permissionless/api/chains/ChainsNamespace.js +180 -0
- package/dist/cjs/permissionless/api/chains/index.js +4 -0
- package/dist/cjs/permissionless/api/chains/schemas.js +34 -0
- package/dist/cjs/permissionless/api/chains/types.js +1 -0
- package/dist/cjs/permissionless/api/deploy/PermissionlessDeploy.js +152 -0
- package/dist/cjs/permissionless/api/deploy/effective-staleness.js +46 -0
- package/dist/cjs/permissionless/api/deploy/index.js +8 -0
- package/dist/cjs/permissionless/api/deploy/types.js +1 -0
- package/dist/cjs/permissionless/api/errors.js +82 -0
- package/dist/cjs/permissionless/api/index.js +28 -0
- package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +84 -0
- package/dist/cjs/permissionless/api/oracles/index.js +6 -0
- package/dist/cjs/permissionless/api/oracles/schemas.js +51 -0
- package/dist/cjs/permissionless/api/oracles/types.js +1 -0
- package/dist/cjs/permissionless/api/schemas.js +28 -0
- package/dist/cjs/permissionless/api/transactions/InstanceOwnerTransactions.js +234 -0
- package/dist/cjs/permissionless/api/transactions/index.js +4 -0
- package/dist/cjs/permissionless/api/transactions/lp-price-feeds.js +86 -0
- package/dist/cjs/permissionless/api/transactions/types.js +1 -0
- package/dist/cjs/permissionless/api/types.js +1 -0
- package/dist/cjs/permissionless/bindings/cross-chain-multisig.js +1 -1
- package/dist/cjs/permissionless/bindings/index.js +3 -3
- package/dist/cjs/permissionless/bindings/instance-manager.js +3 -3
- package/dist/cjs/permissionless/bindings/price-feed-store.js +0 -2
- package/dist/cjs/permissionless/index.js +31 -8
- package/dist/cjs/permissionless/utils/governance/timelock-txs.js +1 -1
- package/dist/cjs/permissionless/utils/index.js +4 -4
- package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +1 -1
- package/dist/cjs/permissionless/utils/price-update/index.js +1 -1
- package/dist/esm/offchain/AbstractOffchainNamespace.js +31 -8
- package/dist/esm/permissionless/api/GearboxPermissionless.js +78 -0
- package/dist/esm/permissionless/api/chains/ChainsNamespace.js +179 -0
- package/dist/esm/permissionless/api/chains/index.js +3 -0
- package/dist/esm/permissionless/api/chains/schemas.js +30 -0
- package/dist/esm/permissionless/api/chains/types.js +1 -0
- package/dist/esm/permissionless/api/deploy/PermissionlessDeploy.js +149 -0
- package/dist/esm/permissionless/api/deploy/effective-staleness.js +46 -0
- package/dist/esm/permissionless/api/deploy/index.js +4 -0
- package/dist/esm/permissionless/api/deploy/types.js +1 -0
- package/dist/esm/permissionless/api/errors.js +77 -0
- package/dist/esm/permissionless/api/index.js +13 -0
- package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +81 -0
- package/dist/esm/permissionless/api/oracles/index.js +3 -0
- package/dist/esm/permissionless/api/oracles/schemas.js +47 -0
- package/dist/esm/permissionless/api/oracles/types.js +1 -0
- package/dist/esm/permissionless/api/schemas.js +25 -0
- package/dist/esm/permissionless/api/transactions/InstanceOwnerTransactions.js +233 -0
- package/dist/esm/permissionless/api/transactions/index.js +3 -0
- package/dist/esm/permissionless/api/transactions/lp-price-feeds.js +84 -0
- package/dist/esm/permissionless/api/transactions/types.js +1 -0
- package/dist/esm/permissionless/api/types.js +1 -0
- package/dist/esm/permissionless/bindings/cross-chain-multisig.js +1 -1
- package/dist/esm/permissionless/bindings/index.js +3 -3
- package/dist/esm/permissionless/bindings/instance-manager.js +3 -3
- package/dist/esm/permissionless/bindings/price-feed-store.js +0 -2
- package/dist/esm/permissionless/index.js +17 -9
- package/dist/esm/permissionless/utils/governance/timelock-txs.js +1 -1
- package/dist/esm/permissionless/utils/index.js +4 -4
- package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +1 -1
- package/dist/esm/permissionless/utils/price-update/index.js +1 -1
- package/dist/types/offchain/AbstractOffchainNamespace.d.ts +12 -0
- package/dist/types/permissionless/api/GearboxPermissionless.d.ts +71 -0
- package/dist/types/permissionless/api/chains/ChainsNamespace.d.ts +99 -0
- package/dist/types/permissionless/api/chains/index.d.ts +3 -0
- package/dist/types/permissionless/api/chains/schemas.d.ts +49 -0
- package/dist/types/permissionless/api/chains/types.d.ts +58 -0
- package/dist/types/permissionless/api/deploy/PermissionlessDeploy.d.ts +69 -0
- package/dist/types/permissionless/api/deploy/effective-staleness.d.ts +19 -0
- package/dist/types/permissionless/api/deploy/index.d.ts +4 -0
- package/dist/types/permissionless/api/deploy/types.d.ts +87 -0
- package/dist/types/permissionless/api/errors.d.ts +63 -0
- package/dist/types/permissionless/api/index.d.ts +17 -0
- package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +64 -0
- package/dist/types/permissionless/api/oracles/index.d.ts +3 -0
- package/dist/types/permissionless/api/oracles/schemas.d.ts +74 -0
- package/dist/types/permissionless/api/oracles/types.d.ts +51 -0
- package/dist/types/permissionless/api/schemas.d.ts +22 -0
- package/dist/types/permissionless/api/transactions/InstanceOwnerTransactions.d.ts +68 -0
- package/dist/types/permissionless/api/transactions/index.d.ts +3 -0
- package/dist/types/permissionless/api/transactions/lp-price-feeds.d.ts +17 -0
- package/dist/types/permissionless/api/transactions/types.d.ts +58 -0
- package/dist/types/permissionless/api/types.d.ts +12 -0
- package/dist/types/permissionless/bindings/factory/credit-factory.d.ts +1 -1
- package/dist/types/permissionless/bindings/factory/loss-policy-factory.d.ts +1 -1
- package/dist/types/permissionless/bindings/factory/pool-factory.d.ts +1 -1
- package/dist/types/permissionless/bindings/factory/price-oracle-factory.d.ts +1 -1
- package/dist/types/permissionless/bindings/index.d.ts +1 -1
- package/dist/types/permissionless/core/index.d.ts +1 -1
- package/dist/types/permissionless/core/pricefeed.d.ts +0 -1
- package/dist/types/permissionless/index.d.ts +23 -10
- package/dist/types/permissionless/utils/governance/index.d.ts +1 -1
- package/dist/types/permissionless/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,7 @@ import { BaseContract } from "../../onchain/base/BaseContract.js";
|
|
|
3
3
|
import { gearboxRouterAbi } from "../../abi/router/gearboxRouter.js";
|
|
4
4
|
import "../../onchain/index.js";
|
|
5
5
|
import { BytecodeRepositoryContract } from "./bytecode-repository.js";
|
|
6
|
-
import {
|
|
7
|
-
import "./compressors/index.js";
|
|
6
|
+
import { PriceFeedStoreContract } from "./price-feed-store.js";
|
|
8
7
|
import "../deployment/addresses.js";
|
|
9
8
|
import { instanceManagerAbi } from "../../abi/310/instanceManager.js";
|
|
10
9
|
import { camelotV3WorkerAbi } from "../../abi/router/camelotV3Worker.js";
|
|
@@ -13,7 +12,8 @@ import { mellow4626WorkerAbi } from "../../abi/router/mellow4626Worker.js";
|
|
|
13
12
|
import { pendleRouterWorkerAbi } from "../../abi/router/pendleRouterWorker.js";
|
|
14
13
|
import { uniswapV3WorkerAbi } from "../../abi/router/uniswapV3Worker.js";
|
|
15
14
|
import { uniswapV4WorkerAbi } from "../../abi/router/uniswapV4Worker.js";
|
|
16
|
-
import {
|
|
15
|
+
import { WithdrawalCompressorContract } from "./compressors/withdrawal-compressor.js";
|
|
16
|
+
import "./compressors/index.js";
|
|
17
17
|
import { RoutingManagerContract } from "./router/routing-manager.js";
|
|
18
18
|
import "./router/index.js";
|
|
19
19
|
import { TreasurySplitterContract } from "./treasury-splitter.js";
|
|
@@ -45,7 +45,6 @@ var PriceFeedStoreContract = class extends BaseContract {
|
|
|
45
45
|
deployedBy: this.address,
|
|
46
46
|
stalenessPeriod: info.stalenessPeriod,
|
|
47
47
|
name: info.name,
|
|
48
|
-
isInStore: true,
|
|
49
48
|
parameters: {}
|
|
50
49
|
}));
|
|
51
50
|
}
|
|
@@ -276,7 +275,6 @@ var PriceFeedStoreContract = class extends BaseContract {
|
|
|
276
275
|
deployedBy: this.address,
|
|
277
276
|
stalenessPeriod: Number(info.stalenessPeriod),
|
|
278
277
|
name: info.name,
|
|
279
|
-
isInStore: true,
|
|
280
278
|
parameters: {}
|
|
281
279
|
};
|
|
282
280
|
});
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PermissionlessChainUnreachableError, PermissionlessNotAttachedError, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError } from "./api/errors.js";
|
|
2
|
+
import { ChainsNamespace } from "./api/chains/ChainsNamespace.js";
|
|
3
|
+
import { deriveEffectiveStalenessPeriod } from "./api/deploy/effective-staleness.js";
|
|
2
4
|
import { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR } from "./utils/literals.js";
|
|
3
5
|
import { normalizeSignature } from "./utils/signature.js";
|
|
4
6
|
import { BytecodeRepositoryContract } from "./bindings/bytecode-repository.js";
|
|
5
|
-
import { TokenCompressorContract } from "./bindings/compressors/token-compressor.js";
|
|
6
|
-
import { WithdrawalCompressorContract } from "./bindings/compressors/withdrawal-compressor.js";
|
|
7
|
-
import { Addresses } from "./deployment/addresses.js";
|
|
8
7
|
import { priceFeedSetupParams } from "./bindings/pricefeeds/index.js";
|
|
9
8
|
import { PriceFeedStoreContract } from "./bindings/price-feed-store.js";
|
|
9
|
+
import { Addresses } from "./deployment/addresses.js";
|
|
10
|
+
import { encodeFunctionParams } from "./utils/abi-encoder.js";
|
|
11
|
+
import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./api/deploy/PermissionlessDeploy.js";
|
|
12
|
+
import { getPrices } from "./utils/price-update/get-prices.js";
|
|
13
|
+
import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./api/oracles/PermissionlessOracles.js";
|
|
14
|
+
import { AddressProviderContract } from "./bindings/address-provider.js";
|
|
15
|
+
import { TokenCompressorContract } from "./bindings/compressors/token-compressor.js";
|
|
16
|
+
import { WithdrawalCompressorContract } from "./bindings/compressors/withdrawal-compressor.js";
|
|
10
17
|
import { RoutingManagerContract } from "./bindings/router/routing-manager.js";
|
|
11
18
|
import { TreasurySplitterContract } from "./bindings/treasury-splitter.js";
|
|
12
19
|
import { InstanceManagerContract } from "./bindings/instance-manager.js";
|
|
20
|
+
import { calculateChecksum, convertRawTxToSafeMultisigTx, getSafeBatch, getSafeBatches } from "./utils/governance/batch.js";
|
|
21
|
+
import { getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds.js";
|
|
22
|
+
import { InstanceOwnerTransactions } from "./api/transactions/InstanceOwnerTransactions.js";
|
|
23
|
+
import { GearboxPermissionless } from "./api/GearboxPermissionless.js";
|
|
24
|
+
import "./api/index.js";
|
|
13
25
|
import { MarketConfiguratorFactoryContract } from "./bindings/market-configurator-factory.js";
|
|
14
26
|
import { CrossChainMultisigContract } from "./bindings/cross-chain-multisig.js";
|
|
15
27
|
import { PUBLIC_CREATE2_FACTORY, checkCreate2Deployment, checkCreate2DeploymentAddress, createCreate2DeployRawTx, deployUsingPublicCreate2, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, handleSalt } from "./utils/create2.js";
|
|
@@ -24,12 +36,8 @@ import { ArchiveTransport } from "./chains/archive-transport.js";
|
|
|
24
36
|
import { chunkedLogsTransport } from "./chains/chunked-log-transport.js";
|
|
25
37
|
import "./core/index.js";
|
|
26
38
|
import { MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT } from "./deployment/mainnet.js";
|
|
27
|
-
import { encodeFunctionParams } from "./utils/abi-encoder.js";
|
|
28
39
|
import { getBlockNumberByTimestamp } from "./utils/block-utils.js";
|
|
29
|
-
import { calculateChecksum, convertRawTxToSafeMultisigTx, getSafeBatch, getSafeBatches } from "./utils/governance/batch.js";
|
|
30
40
|
import { convertQueueBatchToExecuteTx } from "./utils/governance/timelock-txs.js";
|
|
31
41
|
import { getPriceUpdateTx } from "./utils/price-update/get-price-update-tx.js";
|
|
32
|
-
import { getPrices } from "./utils/price-update/get-prices.js";
|
|
33
|
-
import { getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds.js";
|
|
34
42
|
import "./utils/index.js";
|
|
35
|
-
export { AccessMode, AddressProviderContract, Addresses, ArchiveTransport, BYTECODE_REPOSITORY, BytecodeRepositoryContract, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, CrossChainMultisigContract, GovernorContract, INSTANCE_MANAGER, InstanceManagerContract, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PriceFeedStoreContract, RoutingManagerContract, TOKEN_COMPRESSOR, TimeLockContract, TokenCompressorContract, TreasurySplitterContract, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, priceFeedSetupParams, shortenHash, significantTrunc };
|
|
43
|
+
export { AccessMode, AddressProviderContract, Addresses, ArchiveTransport, BYTECODE_REPOSITORY, BytecodeRepositoryContract, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainsNamespace, CrossChainMultisigContract, DEFAULT_DEPLOY_SALT, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GovernorContract, INSTANCE_MANAGER, InstanceManagerContract, InstanceOwnerTransactions, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, PriceFeedStoreContract, RoutingManagerContract, TOKEN_COMPRESSOR, TimeLockContract, TokenCompressorContract, TreasurySplitterContract, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, deriveEffectiveStalenessPeriod, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, priceFeedSalt, priceFeedSetupParams, shortenHash, significantTrunc };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRawTx } from "../../../onchain/utils/createRawTx.js";
|
|
2
2
|
import "../../../onchain/index.js";
|
|
3
|
-
import { governorAbi } from "../../../abi/governance/governor.js";
|
|
4
3
|
import { convertRawTxToSafeMultisigTx } from "./batch.js";
|
|
4
|
+
import { governorAbi } from "../../../abi/governance/governor.js";
|
|
5
5
|
//#region src/permissionless/utils/governance/timelock-txs.ts
|
|
6
6
|
function convertQueueBatchToExecuteTx(queueBatch) {
|
|
7
7
|
const executionBatch = queueBatch.filter((tx) => tx.contractMethod.name === "queueTransaction").map((tx) => ({
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, TOKEN_COMPRESSOR } from "./literals.js";
|
|
2
2
|
import { normalizeSignature } from "./signature.js";
|
|
3
|
+
import { encodeFunctionParams } from "./abi-encoder.js";
|
|
4
|
+
import { getPrices } from "./price-update/get-prices.js";
|
|
5
|
+
import { calculateChecksum, convertRawTxToSafeMultisigTx, getSafeBatch, getSafeBatches } from "./governance/batch.js";
|
|
6
|
+
import { getUpdatablePriceFeeds } from "./price-update/get-updatable-feeds.js";
|
|
3
7
|
import { PUBLIC_CREATE2_FACTORY, checkCreate2Deployment, checkCreate2DeploymentAddress, createCreate2DeployRawTx, deployUsingPublicCreate2, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, handleSalt } from "./create2.js";
|
|
4
8
|
import { convertPercent, deepJsonParse, formatBytecodeSize, formatBytecodeVersion, shortenHash, significantTrunc } from "./format.js";
|
|
5
|
-
import { encodeFunctionParams } from "./abi-encoder.js";
|
|
6
9
|
import { getBlockNumberByTimestamp } from "./block-utils.js";
|
|
7
|
-
import { calculateChecksum, convertRawTxToSafeMultisigTx, getSafeBatch, getSafeBatches } from "./governance/batch.js";
|
|
8
10
|
import { convertQueueBatchToExecuteTx } from "./governance/timelock-txs.js";
|
|
9
11
|
import "./governance/index.js";
|
|
10
12
|
import { getPriceUpdateTx } from "./price-update/get-price-update-tx.js";
|
|
11
|
-
import { getPrices } from "./price-update/get-prices.js";
|
|
12
|
-
import { getUpdatablePriceFeeds } from "./price-update/get-updatable-feeds.js";
|
|
13
13
|
import "./price-update/index.js";
|
|
14
14
|
export { BYTECODE_REPOSITORY, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, INSTANCE_MANAGER, MARKET_CONFIGURATOR_FACTORY, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, TOKEN_COMPRESSOR, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, shortenHash, significantTrunc };
|
|
@@ -2,8 +2,8 @@ import { createRawTx } from "../../../onchain/utils/createRawTx.js";
|
|
|
2
2
|
import { getRawPriceUpdates } from "../../../onchain/market/pricefeeds/updates/getRawPriceUpdates.js";
|
|
3
3
|
import { OnchainSDK } from "../../../onchain/OnchainSDK.js";
|
|
4
4
|
import "../../../onchain/index.js";
|
|
5
|
-
import "../../deployment/addresses.js";
|
|
6
5
|
import { PriceFeedStoreContract } from "../../bindings/price-feed-store.js";
|
|
6
|
+
import "../../deployment/addresses.js";
|
|
7
7
|
import "../../bindings/index.js";
|
|
8
8
|
import { multicall3Abi } from "viem";
|
|
9
9
|
//#region src/permissionless/utils/price-update/get-price-update-tx.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPriceUpdateTx } from "./get-price-update-tx.js";
|
|
2
1
|
import { getPrices } from "./get-prices.js";
|
|
3
2
|
import { getUpdatablePriceFeeds } from "./get-updatable-feeds.js";
|
|
3
|
+
import { getPriceUpdateTx } from "./get-price-update-tx.js";
|
|
4
4
|
export { getPriceUpdateTx, getPrices, getUpdatablePriceFeeds };
|
|
@@ -54,6 +54,18 @@ declare abstract class AbstractOffchainNamespace {
|
|
|
54
54
|
* schema skew throw, since none of them is a {@link DataResponse}.
|
|
55
55
|
**/
|
|
56
56
|
protected get<S extends z.ZodType>(request: OffchainGetRequest<S>): Promise<DataResponse<z.output<S>>>;
|
|
57
|
+
/**
|
|
58
|
+
* Reads one endpoint that answers with the payload alone, and returns it
|
|
59
|
+
* unwrapped.
|
|
60
|
+
*
|
|
61
|
+
* A read served at no particular block has no envelope to report: the
|
|
62
|
+
* permissionless routes either span every chain at once, or fall through to
|
|
63
|
+
* a multicall on the chain itself, so the backend answers `{ data }` and
|
|
64
|
+
* there is no {@link ResponseMetadata} for {@link get} to decode. The
|
|
65
|
+
* envelope is still there, which is what keeps a payload that happens to be
|
|
66
|
+
* an array from being mistaken for an error body.
|
|
67
|
+
**/
|
|
68
|
+
protected getData<S extends z.ZodType>(request: OffchainGetRequest<S>): Promise<z.output<S>>;
|
|
57
69
|
/**
|
|
58
70
|
* Reads the charts of one subject: one series per metric named, onto the one
|
|
59
71
|
* grid that lets them be compared at an index.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { GearboxPermissionlessOptions } from "./types.js";
|
|
2
|
+
import { AttachChainsArgs } from "./chains/types.js";
|
|
3
|
+
import { ChainsNamespace } from "./chains/ChainsNamespace.js";
|
|
4
|
+
import { PermissionlessDeploy } from "./deploy/PermissionlessDeploy.js";
|
|
5
|
+
import { PermissionlessOracles } from "./oracles/PermissionlessOracles.js";
|
|
6
|
+
import { InstanceOwnerTransactions } from "./transactions/InstanceOwnerTransactions.js";
|
|
7
|
+
//#region src/permissionless/api/GearboxPermissionless.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Client for the permissionless stack: the oracle rows of a chain, the
|
|
10
|
+
* batches an instance owner executes, and the deploys that produce what goes
|
|
11
|
+
* into both.
|
|
12
|
+
*
|
|
13
|
+
* It reads the same backend {@link GearboxAPI} does, and reads the same way —
|
|
14
|
+
* one namespace per subject, every call scoped by the chain it names. Which
|
|
15
|
+
* chains those are is not passed in: {@link attach} reads the list off the
|
|
16
|
+
* backend and builds a client for each, so this client covers exactly what
|
|
17
|
+
* the backend serves.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const permissionless = new GearboxPermissionless({
|
|
21
|
+
* baseUrl: "https://api.gearbox.fi",
|
|
22
|
+
* });
|
|
23
|
+
* await permissionless.attach();
|
|
24
|
+
*
|
|
25
|
+
* const [chain] = permissionless.chains.list();
|
|
26
|
+
* const store = await permissionless.oracles.store({ chainId: chain.chainId });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Only what needs a server goes to one. {@link chains} and {@link oracles}
|
|
30
|
+
* are the backend's reads; {@link deploy} and {@link transactions} read the
|
|
31
|
+
* target chain directly, because everything they answer is derived from there
|
|
32
|
+
* and a round trip would only move the derivation further from the wallet
|
|
33
|
+
* that has to sign for it.
|
|
34
|
+
**/
|
|
35
|
+
declare class GearboxPermissionless {
|
|
36
|
+
/**
|
|
37
|
+
* Namespace for the chains the stack runs on, and the viem clients that
|
|
38
|
+
* reach them.
|
|
39
|
+
**/
|
|
40
|
+
readonly chains: ChainsNamespace;
|
|
41
|
+
/**
|
|
42
|
+
* Namespace for price feeds: the store and its prices.
|
|
43
|
+
**/
|
|
44
|
+
readonly oracles: PermissionlessOracles;
|
|
45
|
+
/**
|
|
46
|
+
* Namespace for the Safe batches an instance owner executes. Backend-free,
|
|
47
|
+
* see {@link InstanceOwnerTransactions}.
|
|
48
|
+
**/
|
|
49
|
+
readonly transactions: InstanceOwnerTransactions;
|
|
50
|
+
/**
|
|
51
|
+
* Namespace for deploys through the BytecodeRepository. Backend-free, see
|
|
52
|
+
* {@link PermissionlessDeploy}.
|
|
53
|
+
**/
|
|
54
|
+
readonly deploy: PermissionlessDeploy;
|
|
55
|
+
constructor(options?: GearboxPermissionlessOptions);
|
|
56
|
+
/**
|
|
57
|
+
* Loads the chain list and builds the clients, see
|
|
58
|
+
* {@link ChainsNamespace.attach}. Idempotent, and joins a call already in
|
|
59
|
+
* flight.
|
|
60
|
+
*
|
|
61
|
+
* Everything that reads a chain goes through it, so this has to finish
|
|
62
|
+
* before the first such call.
|
|
63
|
+
**/
|
|
64
|
+
attach(args?: AttachChainsArgs): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Whether {@link attach} has completed.
|
|
67
|
+
**/
|
|
68
|
+
get isAttached(): boolean;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { GearboxPermissionless };
|
|
@@ -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 };
|