@oydual31/more-vaults-sdk 1.1.24 → 1.1.26
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/ethers/index.cjs +177 -6
- package/dist/ethers/index.cjs.map +1 -1
- package/dist/ethers/index.d.cts +75 -2
- package/dist/ethers/index.d.ts +75 -2
- package/dist/ethers/index.js +165 -7
- package/dist/ethers/index.js.map +1 -1
- package/dist/gasBuffer-BMHxT7CX.d.cts +35 -0
- package/dist/gasBuffer-BMHxT7CX.d.ts +35 -0
- package/dist/react/index.cjs +40 -4
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +40 -4
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +224 -28
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +88 -3
- package/dist/viem/index.d.ts +88 -3
- package/dist/viem/index.js +212 -30
- package/dist/viem/index.js.map +1 -1
- package/package.json +3 -2
- package/src/common/gasBuffer.test.ts +70 -0
- package/src/common/gasBuffer.ts +51 -0
- package/src/ethers/chains.ts +15 -0
- package/src/ethers/crossChainFlows.test.ts +77 -0
- package/src/ethers/crossChainFlows.ts +241 -9
- package/src/ethers/index.ts +16 -1
- package/src/ethers/redeemFlows.ts +2 -1
- package/src/viem/chains.ts +20 -0
- package/src/viem/crossChainFlows.test.ts +96 -0
- package/src/viem/crossChainFlows.ts +258 -20
- package/src/viem/curatorMulticall.ts +28 -0
- package/src/viem/curatorSwaps.ts +1 -1
- package/src/viem/depositFlows.ts +3 -2
- package/src/viem/index.ts +17 -1
- package/src/viem/redeemFlows.ts +12 -8
package/dist/ethers/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContractTransactionReceipt, Signer, Provider } from 'ethers';
|
|
2
2
|
export { ContractTransactionReceipt, Provider, Signer } from 'ethers';
|
|
3
|
+
export { D as DEFAULT_GAS_BUFFER_BPS, a as applyGasBuffer, g as getDefaultGasBufferBps, s as setDefaultGasBufferBps } from '../gasBuffer-BMHxT7CX.cjs';
|
|
3
4
|
|
|
4
5
|
/** EVM Chain IDs for chains supported by MoreVaults */
|
|
5
6
|
declare const CHAIN_IDS: {
|
|
@@ -340,6 +341,15 @@ declare const OFT_ROUTES: {
|
|
|
340
341
|
* - FlowSwap V3 (Flow EVM, 0xeEDC...): derived from original UniV3, includes `deadline`
|
|
341
342
|
*/
|
|
342
343
|
declare const UNISWAP_V3_ROUTERS: Record<number, string>;
|
|
344
|
+
/**
|
|
345
|
+
* LayerZero V2 EndpointV2 address per chain.
|
|
346
|
+
* Flow EVM uses a chain-specific address; all other supported chains use the canonical address.
|
|
347
|
+
* Verified: Flow EVM endpoint 0xcb566e3b... confirmed from ComposeSent event emitter on-chain.
|
|
348
|
+
*/
|
|
349
|
+
declare const DEFAULT_LZ_ENDPOINT = "0x1a44076050125825900e736c501f859c50fe728c";
|
|
350
|
+
declare const LZ_ENDPOINT_BY_CHAIN: Partial<Record<number, string>>;
|
|
351
|
+
/** Returns the LZ EndpointV2 address for a given EVM chain ID. */
|
|
352
|
+
declare function getLzEndpoint(chainId: number): string;
|
|
343
353
|
/**
|
|
344
354
|
* Recommended timeouts for cross-chain operations (milliseconds).
|
|
345
355
|
* UIs should show a progress indicator and NOT timeout before these values.
|
|
@@ -1013,6 +1023,12 @@ declare function mintAsync(signer: Signer, addresses: VaultAddresses, shares: bi
|
|
|
1013
1023
|
*/
|
|
1014
1024
|
declare function smartDeposit(signer: Signer, provider: Provider, addresses: VaultAddresses, assets: bigint, receiver: string, extraOptions?: string): Promise<DepositResult | AsyncRequestResult>;
|
|
1015
1025
|
|
|
1026
|
+
/** Default block-range window scanned backwards when no `fromBlock` is given. */
|
|
1027
|
+
declare const COMPOSE_SCAN_WINDOW_BLOCKS = 200000n;
|
|
1028
|
+
/** Block chunk size per `getLogs` call when scanning `ComposeSent` events. */
|
|
1029
|
+
declare const COMPOSE_SCAN_CHUNK_SIZE = 2000n;
|
|
1030
|
+
/** Gas limit forwarded to `endpoint.lzCompose` when executing a pending compose. */
|
|
1031
|
+
declare const EXECUTE_COMPOSE_GAS_LIMIT = 5000000n;
|
|
1016
1032
|
/**
|
|
1017
1033
|
* D6 / D7 — Deposit from a spoke chain to the hub vault via OFT Compose.
|
|
1018
1034
|
*
|
|
@@ -1091,7 +1107,7 @@ declare function quoteComposeFee(provider: Provider, vault: string, spokeEid?: n
|
|
|
1091
1107
|
* @param index Compose index (default 0)
|
|
1092
1108
|
* @returns Transaction receipt
|
|
1093
1109
|
*/
|
|
1094
|
-
declare function executeCompose(signer: Signer, from: string, to: string, guid: string, message: string, fee: bigint, index?: number): Promise<{
|
|
1110
|
+
declare function executeCompose(signer: Signer, from: string, to: string, guid: string, message: string, fee: bigint, index?: number, hubChainId?: number): Promise<{
|
|
1095
1111
|
receipt: ContractTransactionReceipt;
|
|
1096
1112
|
}>;
|
|
1097
1113
|
/**
|
|
@@ -1138,6 +1154,63 @@ interface ComposeData {
|
|
|
1138
1154
|
* @returns Complete ComposeData ready for executeCompose
|
|
1139
1155
|
*/
|
|
1140
1156
|
declare function waitForCompose(hubProvider: Provider, composeData: ComposeData, receiver: string, pollIntervalMs?: number, timeoutMs?: number): Promise<ComposeData>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Decode the OFTComposeMsgCodec message bytes from a ComposeSent event.
|
|
1159
|
+
*
|
|
1160
|
+
* Layout (bytes):
|
|
1161
|
+
* 0–7 amountSD (uint64)
|
|
1162
|
+
* 8–11 srcEid (uint32)
|
|
1163
|
+
* 12–43 amountLD (uint256)
|
|
1164
|
+
* 44–75 composeFrom (bytes32, last 20 = depositor address)
|
|
1165
|
+
* 76+ composeMsgPayload = abi.encode(SendParam, uint256 minMsgValue)
|
|
1166
|
+
*
|
|
1167
|
+
* The SendParam inside composeMsgPayload carries dstEid (spoke EID) and
|
|
1168
|
+
* to (bytes32, last 20 = receiver address on spoke).
|
|
1169
|
+
*/
|
|
1170
|
+
declare function decodeComposeMessage(message: string): {
|
|
1171
|
+
srcEid: number;
|
|
1172
|
+
amountLD: bigint;
|
|
1173
|
+
depositor: string;
|
|
1174
|
+
dstEid?: number;
|
|
1175
|
+
receiver?: string;
|
|
1176
|
+
};
|
|
1177
|
+
/**
|
|
1178
|
+
* Find a specific pending compose on the hub chain by GUID.
|
|
1179
|
+
*
|
|
1180
|
+
* Scans `ComposeSent` events on the LZ Endpoint until it finds an event matching
|
|
1181
|
+
* the given GUID directed at `composer`, then verifies it is still pending.
|
|
1182
|
+
*
|
|
1183
|
+
* @param hubProvider Provider on the hub chain
|
|
1184
|
+
* @param endpoint LZ EndpointV2 address on the hub
|
|
1185
|
+
* @param composer MoreVaultsComposer address on the hub
|
|
1186
|
+
* @param guid The LZ GUID to locate
|
|
1187
|
+
* @param fromBlock Block to start scanning from (default: last 200k blocks)
|
|
1188
|
+
* @param hubChainId Hub chain ID embedded in returned ComposeData (fetched if omitted)
|
|
1189
|
+
* @param chunkSize Block chunk size per getLogs call (default 2000)
|
|
1190
|
+
* @throws {ComposeAlreadyExecutedError} If the compose was already executed
|
|
1191
|
+
* @throws {Error} If the GUID is not found in the scanned block range
|
|
1192
|
+
*/
|
|
1193
|
+
declare function findComposeByGuid(hubProvider: Provider, endpoint: string, composer: string, guid: string, fromBlock?: bigint, hubChainId?: number, chunkSize?: bigint): Promise<ComposeData>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Scan the hub LZ Endpoint for all pending (unexecuted) composes for a composer.
|
|
1196
|
+
*
|
|
1197
|
+
* Returns every `ComposeSent` event where `to === composer` and the compose is
|
|
1198
|
+
* still pending in `composeQueue`. Useful for recovery: lists composes needing TX2.
|
|
1199
|
+
*
|
|
1200
|
+
* @param hubProvider Provider on the hub chain
|
|
1201
|
+
* @param endpoint LZ EndpointV2 address on the hub
|
|
1202
|
+
* @param composer MoreVaultsComposer address on the hub
|
|
1203
|
+
* @param fromBlock Block to start scanning from (default: last 200k blocks)
|
|
1204
|
+
* @param chunkSize Block chunk size per getLogs call (default 2000)
|
|
1205
|
+
*/
|
|
1206
|
+
declare function listPendingComposes(hubProvider: Provider, endpoint: string, composer: string, fromBlock?: bigint, chunkSize?: bigint): Promise<Array<{
|
|
1207
|
+
guid: string;
|
|
1208
|
+
blockNumber: bigint;
|
|
1209
|
+
from: string;
|
|
1210
|
+
index: number;
|
|
1211
|
+
message: string;
|
|
1212
|
+
decoded: ReturnType<typeof decodeComposeMessage>;
|
|
1213
|
+
}>>;
|
|
1141
1214
|
|
|
1142
1215
|
/**
|
|
1143
1216
|
* Redeem `shares` for underlying assets.
|
|
@@ -2678,4 +2751,4 @@ declare function quoteRouteDepositFee(route: InboundRoute, hubChainId: number, a
|
|
|
2678
2751
|
*/
|
|
2679
2752
|
declare function asSdkSigner(signer: unknown): Signer;
|
|
2680
2753
|
|
|
2681
|
-
export { ACCESS_CONTROL_ABI, ADMIN_CONFIG_ABI, ADMIN_WRITE_ABI, ActionType, type ActionTypeValue, ActionsStillPendingError, type AssetBalance, type AssetInfo, type AsyncRequestFinalResult, type AsyncRequestResult, type AsyncRequestStatus, type AsyncRequestStatusInfo, AsyncRequestTimeoutError, BRIDGE_ABI, BRIDGE_FACET_ABI, type BatchSwapParams, type BridgeParams, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CantProcessWithdrawRequestError, CapacityFullError, type ChainPortfolio, ComposeAlreadyExecutedError, ComposeTimeoutError, ComposerNotConfiguredError, type CrossChainRequestInfo, type CuratorAction, type CuratorBridgeParams, type CuratorVaultStatus, DEX_ABI, type DepositBlockReason, type DepositEligibility, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, type ERC7540RequestStatus, ERC7540_FACET_ABI, EscrowNotConfiguredError, type InboundRoute, type InboundRouteWithBalance, InsufficientBalanceError, InsufficientLiquidityError, InvalidInputError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, type MaxWithdrawable, MissingEscrowAddressError, MoreVaultsError, type MultiChainPortfolio, type MultiChainUserPosition, NATIVE_SYMBOL, NoSuchActionsError, NotCuratorError, NotGuardianError, NotHubVaultError, NotOwnerError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, type OutboundRoute, type PendingAction, REGISTRY_ABI, type RedeemCostEstimate, type RedeemResult, SUB_VAULT_ABI, SlippageExceededError, type SpokeBalance, type SpokeRedeemRoute, type SubVaultInfo, type SubVaultPosition, type SubmitActionsResult, type SwapParams, TIMELOCK_CONFIG_ABI, UNISWAP_V3_ROUTERS, UnsupportedAssetError, UnsupportedChainError, type UserBalances, type UserPosition, VAULT_ABI, VAULT_ANALYSIS_ABI, type VaultAddresses, type VaultAnalysis, type VaultAssetBreakdown, type VaultConfiguration, type VaultDistribution, type VaultMetadata, type VaultMode, VaultPausedError, type VaultPortfolio, type VaultStatus, type VaultSummary, type VaultTopology, WhitelistQuotaExhaustedError, WithdrawalQueueDisabledError, WithdrawalTimelockActiveError, WrongChainError, acceptOwnership, addAvailableAsset, addAvailableAssets, asSdkSigner, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, canDeposit, checkProtocolWhitelist, depositAsync, depositCrossChainOracleOn, depositFromSpoke, depositFromSpokeAsync, depositMultiAsset, depositSimple, detectStargateOft, detectSubVaultType, disableAssetToDeposit, discoverVaultTopology, enableDepositWhitelist, encodeBridgeParams, encodeCuratorAction, encodeUniswapV3SwapCalldata, ensureAllowance, estimateRedeemCost, executeActions, executeCompose, executeCuratorBridge, findBridgeRoute, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getERC7540RequestStatus, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getSubVaultInfo, getSubVaultPositions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultAssetBreakdown, getVaultConfiguration, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultPortfolio, getVaultPortfolioMultiChain, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, mintAsync, pauseVault, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, previewSubVaultDeposit, previewSubVaultRedeem, quoteComposeFee, quoteCuratorBridgeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, recoverAssets, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, setDepositCapacity, setDepositWhitelist, setFeeRecipient, smartDeposit, smartRedeem, submitActions, unpauseVault, vetoActions, waitForAsyncRequest, waitForCompose, withdrawAssets };
|
|
2754
|
+
export { ACCESS_CONTROL_ABI, ADMIN_CONFIG_ABI, ADMIN_WRITE_ABI, ActionType, type ActionTypeValue, ActionsStillPendingError, type AssetBalance, type AssetInfo, type AsyncRequestFinalResult, type AsyncRequestResult, type AsyncRequestStatus, type AsyncRequestStatusInfo, AsyncRequestTimeoutError, BRIDGE_ABI, BRIDGE_FACET_ABI, type BatchSwapParams, type BridgeParams, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, COMPOSE_SCAN_CHUNK_SIZE, COMPOSE_SCAN_WINDOW_BLOCKS, CONFIG_ABI, CURATOR_CONFIG_ABI, CantProcessWithdrawRequestError, CapacityFullError, type ChainPortfolio, ComposeAlreadyExecutedError, ComposeTimeoutError, ComposerNotConfiguredError, type CrossChainRequestInfo, type CuratorAction, type CuratorBridgeParams, type CuratorVaultStatus, DEFAULT_LZ_ENDPOINT, DEX_ABI, type DepositBlockReason, type DepositEligibility, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, type ERC7540RequestStatus, ERC7540_FACET_ABI, EXECUTE_COMPOSE_GAS_LIMIT, EscrowNotConfiguredError, type InboundRoute, type InboundRouteWithBalance, InsufficientBalanceError, InsufficientLiquidityError, InvalidInputError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_ENDPOINT_BY_CHAIN, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, type MaxWithdrawable, MissingEscrowAddressError, MoreVaultsError, type MultiChainPortfolio, type MultiChainUserPosition, NATIVE_SYMBOL, NoSuchActionsError, NotCuratorError, NotGuardianError, NotHubVaultError, NotOwnerError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, type OutboundRoute, type PendingAction, REGISTRY_ABI, type RedeemCostEstimate, type RedeemResult, SUB_VAULT_ABI, SlippageExceededError, type SpokeBalance, type SpokeRedeemRoute, type SubVaultInfo, type SubVaultPosition, type SubmitActionsResult, type SwapParams, TIMELOCK_CONFIG_ABI, UNISWAP_V3_ROUTERS, UnsupportedAssetError, UnsupportedChainError, type UserBalances, type UserPosition, VAULT_ABI, VAULT_ANALYSIS_ABI, type VaultAddresses, type VaultAnalysis, type VaultAssetBreakdown, type VaultConfiguration, type VaultDistribution, type VaultMetadata, type VaultMode, VaultPausedError, type VaultPortfolio, type VaultStatus, type VaultSummary, type VaultTopology, WhitelistQuotaExhaustedError, WithdrawalQueueDisabledError, WithdrawalTimelockActiveError, WrongChainError, acceptOwnership, addAvailableAsset, addAvailableAssets, asSdkSigner, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, canDeposit, checkProtocolWhitelist, decodeComposeMessage, depositAsync, depositCrossChainOracleOn, depositFromSpoke, depositFromSpokeAsync, depositMultiAsset, depositSimple, detectStargateOft, detectSubVaultType, disableAssetToDeposit, discoverVaultTopology, enableDepositWhitelist, encodeBridgeParams, encodeCuratorAction, encodeUniswapV3SwapCalldata, ensureAllowance, estimateRedeemCost, executeActions, executeCompose, executeCuratorBridge, findBridgeRoute, findComposeByGuid, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getERC7540RequestStatus, getFullVaultTopology, getInboundRoutes, getLzEndpoint, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getSubVaultInfo, getSubVaultPositions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultAssetBreakdown, getVaultConfiguration, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultPortfolio, getVaultPortfolioMultiChain, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, listPendingComposes, mintAsync, pauseVault, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, previewSubVaultDeposit, previewSubVaultRedeem, quoteComposeFee, quoteCuratorBridgeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, recoverAssets, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, setDepositCapacity, setDepositWhitelist, setFeeRecipient, smartDeposit, smartRedeem, submitActions, unpauseVault, vetoActions, waitForAsyncRequest, waitForCompose, withdrawAssets };
|
package/dist/ethers/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContractTransactionReceipt, Signer, Provider } from 'ethers';
|
|
2
2
|
export { ContractTransactionReceipt, Provider, Signer } from 'ethers';
|
|
3
|
+
export { D as DEFAULT_GAS_BUFFER_BPS, a as applyGasBuffer, g as getDefaultGasBufferBps, s as setDefaultGasBufferBps } from '../gasBuffer-BMHxT7CX.js';
|
|
3
4
|
|
|
4
5
|
/** EVM Chain IDs for chains supported by MoreVaults */
|
|
5
6
|
declare const CHAIN_IDS: {
|
|
@@ -340,6 +341,15 @@ declare const OFT_ROUTES: {
|
|
|
340
341
|
* - FlowSwap V3 (Flow EVM, 0xeEDC...): derived from original UniV3, includes `deadline`
|
|
341
342
|
*/
|
|
342
343
|
declare const UNISWAP_V3_ROUTERS: Record<number, string>;
|
|
344
|
+
/**
|
|
345
|
+
* LayerZero V2 EndpointV2 address per chain.
|
|
346
|
+
* Flow EVM uses a chain-specific address; all other supported chains use the canonical address.
|
|
347
|
+
* Verified: Flow EVM endpoint 0xcb566e3b... confirmed from ComposeSent event emitter on-chain.
|
|
348
|
+
*/
|
|
349
|
+
declare const DEFAULT_LZ_ENDPOINT = "0x1a44076050125825900e736c501f859c50fe728c";
|
|
350
|
+
declare const LZ_ENDPOINT_BY_CHAIN: Partial<Record<number, string>>;
|
|
351
|
+
/** Returns the LZ EndpointV2 address for a given EVM chain ID. */
|
|
352
|
+
declare function getLzEndpoint(chainId: number): string;
|
|
343
353
|
/**
|
|
344
354
|
* Recommended timeouts for cross-chain operations (milliseconds).
|
|
345
355
|
* UIs should show a progress indicator and NOT timeout before these values.
|
|
@@ -1013,6 +1023,12 @@ declare function mintAsync(signer: Signer, addresses: VaultAddresses, shares: bi
|
|
|
1013
1023
|
*/
|
|
1014
1024
|
declare function smartDeposit(signer: Signer, provider: Provider, addresses: VaultAddresses, assets: bigint, receiver: string, extraOptions?: string): Promise<DepositResult | AsyncRequestResult>;
|
|
1015
1025
|
|
|
1026
|
+
/** Default block-range window scanned backwards when no `fromBlock` is given. */
|
|
1027
|
+
declare const COMPOSE_SCAN_WINDOW_BLOCKS = 200000n;
|
|
1028
|
+
/** Block chunk size per `getLogs` call when scanning `ComposeSent` events. */
|
|
1029
|
+
declare const COMPOSE_SCAN_CHUNK_SIZE = 2000n;
|
|
1030
|
+
/** Gas limit forwarded to `endpoint.lzCompose` when executing a pending compose. */
|
|
1031
|
+
declare const EXECUTE_COMPOSE_GAS_LIMIT = 5000000n;
|
|
1016
1032
|
/**
|
|
1017
1033
|
* D6 / D7 — Deposit from a spoke chain to the hub vault via OFT Compose.
|
|
1018
1034
|
*
|
|
@@ -1091,7 +1107,7 @@ declare function quoteComposeFee(provider: Provider, vault: string, spokeEid?: n
|
|
|
1091
1107
|
* @param index Compose index (default 0)
|
|
1092
1108
|
* @returns Transaction receipt
|
|
1093
1109
|
*/
|
|
1094
|
-
declare function executeCompose(signer: Signer, from: string, to: string, guid: string, message: string, fee: bigint, index?: number): Promise<{
|
|
1110
|
+
declare function executeCompose(signer: Signer, from: string, to: string, guid: string, message: string, fee: bigint, index?: number, hubChainId?: number): Promise<{
|
|
1095
1111
|
receipt: ContractTransactionReceipt;
|
|
1096
1112
|
}>;
|
|
1097
1113
|
/**
|
|
@@ -1138,6 +1154,63 @@ interface ComposeData {
|
|
|
1138
1154
|
* @returns Complete ComposeData ready for executeCompose
|
|
1139
1155
|
*/
|
|
1140
1156
|
declare function waitForCompose(hubProvider: Provider, composeData: ComposeData, receiver: string, pollIntervalMs?: number, timeoutMs?: number): Promise<ComposeData>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Decode the OFTComposeMsgCodec message bytes from a ComposeSent event.
|
|
1159
|
+
*
|
|
1160
|
+
* Layout (bytes):
|
|
1161
|
+
* 0–7 amountSD (uint64)
|
|
1162
|
+
* 8–11 srcEid (uint32)
|
|
1163
|
+
* 12–43 amountLD (uint256)
|
|
1164
|
+
* 44–75 composeFrom (bytes32, last 20 = depositor address)
|
|
1165
|
+
* 76+ composeMsgPayload = abi.encode(SendParam, uint256 minMsgValue)
|
|
1166
|
+
*
|
|
1167
|
+
* The SendParam inside composeMsgPayload carries dstEid (spoke EID) and
|
|
1168
|
+
* to (bytes32, last 20 = receiver address on spoke).
|
|
1169
|
+
*/
|
|
1170
|
+
declare function decodeComposeMessage(message: string): {
|
|
1171
|
+
srcEid: number;
|
|
1172
|
+
amountLD: bigint;
|
|
1173
|
+
depositor: string;
|
|
1174
|
+
dstEid?: number;
|
|
1175
|
+
receiver?: string;
|
|
1176
|
+
};
|
|
1177
|
+
/**
|
|
1178
|
+
* Find a specific pending compose on the hub chain by GUID.
|
|
1179
|
+
*
|
|
1180
|
+
* Scans `ComposeSent` events on the LZ Endpoint until it finds an event matching
|
|
1181
|
+
* the given GUID directed at `composer`, then verifies it is still pending.
|
|
1182
|
+
*
|
|
1183
|
+
* @param hubProvider Provider on the hub chain
|
|
1184
|
+
* @param endpoint LZ EndpointV2 address on the hub
|
|
1185
|
+
* @param composer MoreVaultsComposer address on the hub
|
|
1186
|
+
* @param guid The LZ GUID to locate
|
|
1187
|
+
* @param fromBlock Block to start scanning from (default: last 200k blocks)
|
|
1188
|
+
* @param hubChainId Hub chain ID embedded in returned ComposeData (fetched if omitted)
|
|
1189
|
+
* @param chunkSize Block chunk size per getLogs call (default 2000)
|
|
1190
|
+
* @throws {ComposeAlreadyExecutedError} If the compose was already executed
|
|
1191
|
+
* @throws {Error} If the GUID is not found in the scanned block range
|
|
1192
|
+
*/
|
|
1193
|
+
declare function findComposeByGuid(hubProvider: Provider, endpoint: string, composer: string, guid: string, fromBlock?: bigint, hubChainId?: number, chunkSize?: bigint): Promise<ComposeData>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Scan the hub LZ Endpoint for all pending (unexecuted) composes for a composer.
|
|
1196
|
+
*
|
|
1197
|
+
* Returns every `ComposeSent` event where `to === composer` and the compose is
|
|
1198
|
+
* still pending in `composeQueue`. Useful for recovery: lists composes needing TX2.
|
|
1199
|
+
*
|
|
1200
|
+
* @param hubProvider Provider on the hub chain
|
|
1201
|
+
* @param endpoint LZ EndpointV2 address on the hub
|
|
1202
|
+
* @param composer MoreVaultsComposer address on the hub
|
|
1203
|
+
* @param fromBlock Block to start scanning from (default: last 200k blocks)
|
|
1204
|
+
* @param chunkSize Block chunk size per getLogs call (default 2000)
|
|
1205
|
+
*/
|
|
1206
|
+
declare function listPendingComposes(hubProvider: Provider, endpoint: string, composer: string, fromBlock?: bigint, chunkSize?: bigint): Promise<Array<{
|
|
1207
|
+
guid: string;
|
|
1208
|
+
blockNumber: bigint;
|
|
1209
|
+
from: string;
|
|
1210
|
+
index: number;
|
|
1211
|
+
message: string;
|
|
1212
|
+
decoded: ReturnType<typeof decodeComposeMessage>;
|
|
1213
|
+
}>>;
|
|
1141
1214
|
|
|
1142
1215
|
/**
|
|
1143
1216
|
* Redeem `shares` for underlying assets.
|
|
@@ -2678,4 +2751,4 @@ declare function quoteRouteDepositFee(route: InboundRoute, hubChainId: number, a
|
|
|
2678
2751
|
*/
|
|
2679
2752
|
declare function asSdkSigner(signer: unknown): Signer;
|
|
2680
2753
|
|
|
2681
|
-
export { ACCESS_CONTROL_ABI, ADMIN_CONFIG_ABI, ADMIN_WRITE_ABI, ActionType, type ActionTypeValue, ActionsStillPendingError, type AssetBalance, type AssetInfo, type AsyncRequestFinalResult, type AsyncRequestResult, type AsyncRequestStatus, type AsyncRequestStatusInfo, AsyncRequestTimeoutError, BRIDGE_ABI, BRIDGE_FACET_ABI, type BatchSwapParams, type BridgeParams, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CantProcessWithdrawRequestError, CapacityFullError, type ChainPortfolio, ComposeAlreadyExecutedError, ComposeTimeoutError, ComposerNotConfiguredError, type CrossChainRequestInfo, type CuratorAction, type CuratorBridgeParams, type CuratorVaultStatus, DEX_ABI, type DepositBlockReason, type DepositEligibility, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, type ERC7540RequestStatus, ERC7540_FACET_ABI, EscrowNotConfiguredError, type InboundRoute, type InboundRouteWithBalance, InsufficientBalanceError, InsufficientLiquidityError, InvalidInputError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, type MaxWithdrawable, MissingEscrowAddressError, MoreVaultsError, type MultiChainPortfolio, type MultiChainUserPosition, NATIVE_SYMBOL, NoSuchActionsError, NotCuratorError, NotGuardianError, NotHubVaultError, NotOwnerError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, type OutboundRoute, type PendingAction, REGISTRY_ABI, type RedeemCostEstimate, type RedeemResult, SUB_VAULT_ABI, SlippageExceededError, type SpokeBalance, type SpokeRedeemRoute, type SubVaultInfo, type SubVaultPosition, type SubmitActionsResult, type SwapParams, TIMELOCK_CONFIG_ABI, UNISWAP_V3_ROUTERS, UnsupportedAssetError, UnsupportedChainError, type UserBalances, type UserPosition, VAULT_ABI, VAULT_ANALYSIS_ABI, type VaultAddresses, type VaultAnalysis, type VaultAssetBreakdown, type VaultConfiguration, type VaultDistribution, type VaultMetadata, type VaultMode, VaultPausedError, type VaultPortfolio, type VaultStatus, type VaultSummary, type VaultTopology, WhitelistQuotaExhaustedError, WithdrawalQueueDisabledError, WithdrawalTimelockActiveError, WrongChainError, acceptOwnership, addAvailableAsset, addAvailableAssets, asSdkSigner, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, canDeposit, checkProtocolWhitelist, depositAsync, depositCrossChainOracleOn, depositFromSpoke, depositFromSpokeAsync, depositMultiAsset, depositSimple, detectStargateOft, detectSubVaultType, disableAssetToDeposit, discoverVaultTopology, enableDepositWhitelist, encodeBridgeParams, encodeCuratorAction, encodeUniswapV3SwapCalldata, ensureAllowance, estimateRedeemCost, executeActions, executeCompose, executeCuratorBridge, findBridgeRoute, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getERC7540RequestStatus, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getSubVaultInfo, getSubVaultPositions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultAssetBreakdown, getVaultConfiguration, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultPortfolio, getVaultPortfolioMultiChain, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, mintAsync, pauseVault, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, previewSubVaultDeposit, previewSubVaultRedeem, quoteComposeFee, quoteCuratorBridgeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, recoverAssets, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, setDepositCapacity, setDepositWhitelist, setFeeRecipient, smartDeposit, smartRedeem, submitActions, unpauseVault, vetoActions, waitForAsyncRequest, waitForCompose, withdrawAssets };
|
|
2754
|
+
export { ACCESS_CONTROL_ABI, ADMIN_CONFIG_ABI, ADMIN_WRITE_ABI, ActionType, type ActionTypeValue, ActionsStillPendingError, type AssetBalance, type AssetInfo, type AsyncRequestFinalResult, type AsyncRequestResult, type AsyncRequestStatus, type AsyncRequestStatusInfo, AsyncRequestTimeoutError, BRIDGE_ABI, BRIDGE_FACET_ABI, type BatchSwapParams, type BridgeParams, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, COMPOSE_SCAN_CHUNK_SIZE, COMPOSE_SCAN_WINDOW_BLOCKS, CONFIG_ABI, CURATOR_CONFIG_ABI, CantProcessWithdrawRequestError, CapacityFullError, type ChainPortfolio, ComposeAlreadyExecutedError, ComposeTimeoutError, ComposerNotConfiguredError, type CrossChainRequestInfo, type CuratorAction, type CuratorBridgeParams, type CuratorVaultStatus, DEFAULT_LZ_ENDPOINT, DEX_ABI, type DepositBlockReason, type DepositEligibility, type DepositResult, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, type ERC7540RequestStatus, ERC7540_FACET_ABI, EXECUTE_COMPOSE_GAS_LIMIT, EscrowNotConfiguredError, type InboundRoute, type InboundRouteWithBalance, InsufficientBalanceError, InsufficientLiquidityError, InvalidInputError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_ENDPOINT_BY_CHAIN, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, type MaxWithdrawable, MissingEscrowAddressError, MoreVaultsError, type MultiChainPortfolio, type MultiChainUserPosition, NATIVE_SYMBOL, NoSuchActionsError, NotCuratorError, NotGuardianError, NotHubVaultError, NotOwnerError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, type OutboundRoute, type PendingAction, REGISTRY_ABI, type RedeemCostEstimate, type RedeemResult, SUB_VAULT_ABI, SlippageExceededError, type SpokeBalance, type SpokeRedeemRoute, type SubVaultInfo, type SubVaultPosition, type SubmitActionsResult, type SwapParams, TIMELOCK_CONFIG_ABI, UNISWAP_V3_ROUTERS, UnsupportedAssetError, UnsupportedChainError, type UserBalances, type UserPosition, VAULT_ABI, VAULT_ANALYSIS_ABI, type VaultAddresses, type VaultAnalysis, type VaultAssetBreakdown, type VaultConfiguration, type VaultDistribution, type VaultMetadata, type VaultMode, VaultPausedError, type VaultPortfolio, type VaultStatus, type VaultSummary, type VaultTopology, WhitelistQuotaExhaustedError, WithdrawalQueueDisabledError, WithdrawalTimelockActiveError, WrongChainError, acceptOwnership, addAvailableAsset, addAvailableAssets, asSdkSigner, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, canDeposit, checkProtocolWhitelist, decodeComposeMessage, depositAsync, depositCrossChainOracleOn, depositFromSpoke, depositFromSpokeAsync, depositMultiAsset, depositSimple, detectStargateOft, detectSubVaultType, disableAssetToDeposit, discoverVaultTopology, enableDepositWhitelist, encodeBridgeParams, encodeCuratorAction, encodeUniswapV3SwapCalldata, ensureAllowance, estimateRedeemCost, executeActions, executeCompose, executeCuratorBridge, findBridgeRoute, findComposeByGuid, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getERC7540RequestStatus, getFullVaultTopology, getInboundRoutes, getLzEndpoint, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getSubVaultInfo, getSubVaultPositions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultAssetBreakdown, getVaultConfiguration, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultPortfolio, getVaultPortfolioMultiChain, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, listPendingComposes, mintAsync, pauseVault, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, previewSubVaultDeposit, previewSubVaultRedeem, quoteComposeFee, quoteCuratorBridgeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, recoverAssets, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, setDepositCapacity, setDepositWhitelist, setFeeRecipient, smartDeposit, smartRedeem, submitActions, unpauseVault, vetoActions, waitForAsyncRequest, waitForCompose, withdrawAssets };
|
package/dist/ethers/index.js
CHANGED
|
@@ -342,6 +342,13 @@ var UNISWAP_V3_ROUTERS = {
|
|
|
342
342
|
[747]: "0xeEDC6Ff75e1b10B903D9013c358e446a73d35341"
|
|
343
343
|
// Flow EVM — FlowSwap V3 SwapRouter
|
|
344
344
|
};
|
|
345
|
+
var DEFAULT_LZ_ENDPOINT = "0x1a44076050125825900e736c501f859c50fe728c";
|
|
346
|
+
var LZ_ENDPOINT_BY_CHAIN = {
|
|
347
|
+
[CHAIN_IDS.flowEVMMainnet]: "0xcb566e3b6934fa77258d68ea18e931fa75e1aaaa"
|
|
348
|
+
};
|
|
349
|
+
function getLzEndpoint(chainId) {
|
|
350
|
+
return LZ_ENDPOINT_BY_CHAIN[chainId] ?? DEFAULT_LZ_ENDPOINT;
|
|
351
|
+
}
|
|
345
352
|
var PUBLIC_RPCS = {
|
|
346
353
|
1: ["https://ethereum-rpc.publicnode.com", "https://eth.drpc.org", "https://eth.llamarpc.com"],
|
|
347
354
|
10: ["https://mainnet.optimism.io", "https://optimism-rpc.publicnode.com"],
|
|
@@ -1015,9 +1022,13 @@ async function detectStargateOft(provider, oft) {
|
|
|
1015
1022
|
return false;
|
|
1016
1023
|
}
|
|
1017
1024
|
}
|
|
1018
|
-
var LZ_ENDPOINT =
|
|
1025
|
+
var LZ_ENDPOINT = DEFAULT_LZ_ENDPOINT;
|
|
1019
1026
|
var EMPTY_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
1020
1027
|
var RECEIVED_HASH = "0x0000000000000000000000000000000000000000000000000000000000000001";
|
|
1028
|
+
var COMPOSE_SENT_TOPIC = "0x0c68e6a0b0fb0f33c52455a8da89b21fc640a3dd4a1b21d9bfcc8aeee4a43e84";
|
|
1029
|
+
var COMPOSE_SCAN_WINDOW_BLOCKS = 200000n;
|
|
1030
|
+
var COMPOSE_SCAN_CHUNK_SIZE = 2000n;
|
|
1031
|
+
var EXECUTE_COMPOSE_GAS_LIMIT = 5000000n;
|
|
1021
1032
|
async function ensureAllowance2(signer, token, spender, amount) {
|
|
1022
1033
|
const owner = await signer.getAddress();
|
|
1023
1034
|
const erc20 = new Contract(token, ERC20_ABI, signer);
|
|
@@ -1145,8 +1156,13 @@ async function quoteComposeFee(provider, vault, spokeEid, receiver) {
|
|
|
1145
1156
|
return 500000000000000n;
|
|
1146
1157
|
}
|
|
1147
1158
|
}
|
|
1148
|
-
async function executeCompose(signer, from, to, guid, message, fee, index = 0) {
|
|
1149
|
-
|
|
1159
|
+
async function executeCompose(signer, from, to, guid, message, fee, index = 0, hubChainId) {
|
|
1160
|
+
let resolvedChainId = hubChainId;
|
|
1161
|
+
if (resolvedChainId === void 0 && signer.provider) {
|
|
1162
|
+
resolvedChainId = Number((await signer.provider.getNetwork()).chainId);
|
|
1163
|
+
}
|
|
1164
|
+
const endpointAddr = resolvedChainId ? getLzEndpoint(resolvedChainId) : LZ_ENDPOINT;
|
|
1165
|
+
const endpoint = new Contract(endpointAddr, LZ_ENDPOINT_ABI, signer);
|
|
1150
1166
|
const hash = await endpoint.composeQueue(from, to, guid, index);
|
|
1151
1167
|
if (hash === EMPTY_HASH) {
|
|
1152
1168
|
throw new Error("Compose not found in queue (hash = 0). Never sent or wrong parameters.");
|
|
@@ -1156,7 +1172,7 @@ async function executeCompose(signer, from, to, guid, message, fee, index = 0) {
|
|
|
1156
1172
|
}
|
|
1157
1173
|
const tx = await endpoint.lzCompose(from, to, guid, index, message, "0x", {
|
|
1158
1174
|
value: fee,
|
|
1159
|
-
gasLimit:
|
|
1175
|
+
gasLimit: EXECUTE_COMPOSE_GAS_LIMIT
|
|
1160
1176
|
});
|
|
1161
1177
|
const receipt = await tx.wait();
|
|
1162
1178
|
return { receipt };
|
|
@@ -1181,7 +1197,6 @@ async function waitForCompose(hubProvider, composeData, receiver, pollIntervalMs
|
|
|
1181
1197
|
);
|
|
1182
1198
|
const knownFromAddresses = stargateChecks.filter((c) => c.isSg).map((c) => c.addr);
|
|
1183
1199
|
const endpointContract = new Contract(endpoint, LZ_ENDPOINT_ABI, hubProvider);
|
|
1184
|
-
const COMPOSE_SENT_TOPIC = "0x0c68e6a0b0fb0f33c52455a8da89b21fc640a3dd4a1b21d9bfcc8aeee4a43e84";
|
|
1185
1200
|
let attempt = 0;
|
|
1186
1201
|
let scannedUpTo = startBlock - 1n;
|
|
1187
1202
|
while (Date.now() < deadline) {
|
|
@@ -1275,6 +1290,132 @@ async function waitForCompose(hubProvider, composeData, receiver, pollIntervalMs
|
|
|
1275
1290
|
`Timeout waiting for compose after ${timeoutMs / 6e4} min. Check LayerZero scan for composer ${composeData.to}.`
|
|
1276
1291
|
);
|
|
1277
1292
|
}
|
|
1293
|
+
function decodeComposeMessage(message) {
|
|
1294
|
+
const hex = message.startsWith("0x") ? message.slice(2) : message;
|
|
1295
|
+
const srcEid = parseInt(hex.slice(16, 24), 16);
|
|
1296
|
+
const amountLD = BigInt("0x" + hex.slice(24, 88));
|
|
1297
|
+
const depositor = getAddress("0x" + hex.slice(112, 152));
|
|
1298
|
+
let dstEid;
|
|
1299
|
+
let receiver;
|
|
1300
|
+
try {
|
|
1301
|
+
const payload = "0x" + hex.slice(152);
|
|
1302
|
+
const coder = AbiCoder.defaultAbiCoder();
|
|
1303
|
+
const [sendParam] = coder.decode(
|
|
1304
|
+
[
|
|
1305
|
+
"tuple(uint32 dstEid, bytes32 to, uint256 amountLD, uint256 minAmountLD, bytes extraOptions, bytes composeMsg, bytes oftCmd)",
|
|
1306
|
+
"uint256"
|
|
1307
|
+
],
|
|
1308
|
+
payload
|
|
1309
|
+
);
|
|
1310
|
+
dstEid = Number(sendParam.dstEid);
|
|
1311
|
+
receiver = getAddress("0x" + sendParam.to.slice(26));
|
|
1312
|
+
} catch {
|
|
1313
|
+
}
|
|
1314
|
+
return { srcEid, amountLD, depositor, dstEid, receiver };
|
|
1315
|
+
}
|
|
1316
|
+
async function findComposeByGuid(hubProvider, endpoint, composer, guid, fromBlock, hubChainId, chunkSize = COMPOSE_SCAN_CHUNK_SIZE) {
|
|
1317
|
+
const currentBlock = BigInt(await hubProvider.getBlockNumber());
|
|
1318
|
+
const scanFrom = fromBlock ?? (currentBlock > COMPOSE_SCAN_WINDOW_BLOCKS ? currentBlock - COMPOSE_SCAN_WINDOW_BLOCKS : 0n);
|
|
1319
|
+
const endpointContract = new Contract(endpoint, LZ_ENDPOINT_ABI, hubProvider);
|
|
1320
|
+
const coder = AbiCoder.defaultAbiCoder();
|
|
1321
|
+
const composerLc = composer.toLowerCase();
|
|
1322
|
+
let from = scanFrom;
|
|
1323
|
+
while (from <= currentBlock) {
|
|
1324
|
+
const chunkEnd = from + chunkSize > currentBlock ? currentBlock : from + chunkSize;
|
|
1325
|
+
const logs = await hubProvider.getLogs({
|
|
1326
|
+
address: endpoint,
|
|
1327
|
+
topics: [COMPOSE_SENT_TOPIC],
|
|
1328
|
+
fromBlock: `0x${from.toString(16)}`,
|
|
1329
|
+
toBlock: `0x${chunkEnd.toString(16)}`
|
|
1330
|
+
});
|
|
1331
|
+
for (const log of logs) {
|
|
1332
|
+
let decoded;
|
|
1333
|
+
try {
|
|
1334
|
+
decoded = coder.decode(["address", "address", "bytes32", "uint16", "bytes"], log.data);
|
|
1335
|
+
} catch {
|
|
1336
|
+
continue;
|
|
1337
|
+
}
|
|
1338
|
+
const logFrom = decoded[0];
|
|
1339
|
+
const logTo = decoded[1].toLowerCase();
|
|
1340
|
+
const logGuid = decoded[2];
|
|
1341
|
+
const logIndex = Number(decoded[3]);
|
|
1342
|
+
const logMessage = decoded[4];
|
|
1343
|
+
if (logGuid.toLowerCase() === guid.toLowerCase() && logTo === composerLc) {
|
|
1344
|
+
const hash = await endpointContract.composeQueue(logFrom, composer, guid, logIndex);
|
|
1345
|
+
if (hash === RECEIVED_HASH) throw new ComposeAlreadyExecutedError();
|
|
1346
|
+
if (hash === EMPTY_HASH) {
|
|
1347
|
+
throw new Error(`Compose ${guid} found in events but composeQueue hash is empty \u2014 may have been cleared externally.`);
|
|
1348
|
+
}
|
|
1349
|
+
const chainId = hubChainId ?? Number((await hubProvider.getNetwork()).chainId);
|
|
1350
|
+
return {
|
|
1351
|
+
endpoint,
|
|
1352
|
+
from: logFrom,
|
|
1353
|
+
to: composer,
|
|
1354
|
+
guid,
|
|
1355
|
+
index: logIndex,
|
|
1356
|
+
message: logMessage,
|
|
1357
|
+
isStargate: false,
|
|
1358
|
+
hubChainId: chainId,
|
|
1359
|
+
hubBlockStart: scanFrom
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
from = chunkEnd + 1n;
|
|
1364
|
+
}
|
|
1365
|
+
throw new Error(
|
|
1366
|
+
`Compose GUID ${guid} not found in ComposeSent events on blocks ${scanFrom}\u2192${currentBlock}. Pass a lower fromBlock to scan further back.`
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
async function listPendingComposes(hubProvider, endpoint, composer, fromBlock, chunkSize = COMPOSE_SCAN_CHUNK_SIZE) {
|
|
1370
|
+
const currentBlock = BigInt(await hubProvider.getBlockNumber());
|
|
1371
|
+
const scanFrom = fromBlock ?? (currentBlock > COMPOSE_SCAN_WINDOW_BLOCKS ? currentBlock - COMPOSE_SCAN_WINDOW_BLOCKS : 0n);
|
|
1372
|
+
const endpointContract = new Contract(endpoint, LZ_ENDPOINT_ABI, hubProvider);
|
|
1373
|
+
const coder = AbiCoder.defaultAbiCoder();
|
|
1374
|
+
const composerLc = composer.toLowerCase();
|
|
1375
|
+
const pending = [];
|
|
1376
|
+
for (let from = scanFrom; from <= currentBlock; from += chunkSize + 1n) {
|
|
1377
|
+
const chunkEnd = from + chunkSize > currentBlock ? currentBlock : from + chunkSize;
|
|
1378
|
+
try {
|
|
1379
|
+
const logs = await hubProvider.getLogs({
|
|
1380
|
+
address: endpoint,
|
|
1381
|
+
topics: [COMPOSE_SENT_TOPIC],
|
|
1382
|
+
fromBlock: `0x${from.toString(16)}`,
|
|
1383
|
+
toBlock: `0x${chunkEnd.toString(16)}`
|
|
1384
|
+
});
|
|
1385
|
+
for (const log of logs) {
|
|
1386
|
+
let decoded;
|
|
1387
|
+
try {
|
|
1388
|
+
decoded = coder.decode(["address", "address", "bytes32", "uint16", "bytes"], log.data);
|
|
1389
|
+
} catch {
|
|
1390
|
+
continue;
|
|
1391
|
+
}
|
|
1392
|
+
const logFrom = decoded[0];
|
|
1393
|
+
const logTo = decoded[1].toLowerCase();
|
|
1394
|
+
const logGuid = decoded[2];
|
|
1395
|
+
const logIndex = Number(decoded[3]);
|
|
1396
|
+
const logMessage = decoded[4];
|
|
1397
|
+
if (logTo !== composerLc) continue;
|
|
1398
|
+
try {
|
|
1399
|
+
const hash = await endpointContract.composeQueue(logFrom, composer, logGuid, logIndex);
|
|
1400
|
+
if (hash !== EMPTY_HASH && hash !== RECEIVED_HASH) {
|
|
1401
|
+
pending.push({
|
|
1402
|
+
guid: logGuid,
|
|
1403
|
+
blockNumber: BigInt(log.blockNumber),
|
|
1404
|
+
from: logFrom,
|
|
1405
|
+
index: logIndex,
|
|
1406
|
+
message: logMessage,
|
|
1407
|
+
decoded: decodeComposeMessage(logMessage)
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
} catch {
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
} catch {
|
|
1414
|
+
continue;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
return pending;
|
|
1418
|
+
}
|
|
1278
1419
|
|
|
1279
1420
|
// src/ethers/preflight.ts
|
|
1280
1421
|
async function preflightAsync(provider, vault, escrow) {
|
|
@@ -1775,6 +1916,23 @@ function getAllVaultChainIds(topology) {
|
|
|
1775
1916
|
return [topology.hubChainId, ...topology.spokeChainIds];
|
|
1776
1917
|
}
|
|
1777
1918
|
|
|
1919
|
+
// src/common/gasBuffer.ts
|
|
1920
|
+
var DEFAULT_GAS_BUFFER_BPS = 4000n;
|
|
1921
|
+
var BPS_DENOMINATOR = 10000n;
|
|
1922
|
+
var currentDefaultBps = DEFAULT_GAS_BUFFER_BPS;
|
|
1923
|
+
function setDefaultGasBufferBps(bps) {
|
|
1924
|
+
if (bps < 0n) throw new RangeError(`gas buffer bps must be >= 0, got ${bps}`);
|
|
1925
|
+
currentDefaultBps = bps;
|
|
1926
|
+
}
|
|
1927
|
+
function getDefaultGasBufferBps() {
|
|
1928
|
+
return currentDefaultBps;
|
|
1929
|
+
}
|
|
1930
|
+
function applyGasBuffer(estimate, bufferBps) {
|
|
1931
|
+
const bps = bufferBps ?? currentDefaultBps;
|
|
1932
|
+
if (bps < 0n) throw new RangeError(`gas buffer bps must be >= 0, got ${bps}`);
|
|
1933
|
+
return estimate * (BPS_DENOMINATOR + bps) / BPS_DENOMINATOR;
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1778
1936
|
// src/ethers/redeemFlows.ts
|
|
1779
1937
|
async function ensureAllowance4(signer, token, spender, amount) {
|
|
1780
1938
|
const owner = await signer.getAddress();
|
|
@@ -1955,7 +2113,7 @@ async function estimateRedeemCost(provider, addresses, shares, receiver, owner,
|
|
|
1955
2113
|
extraOptions,
|
|
1956
2114
|
{ value: lzFee, from: owner }
|
|
1957
2115
|
);
|
|
1958
|
-
requestGas = BigInt(raw.toString())
|
|
2116
|
+
requestGas = applyGasBuffer(BigInt(raw.toString()));
|
|
1959
2117
|
} catch {
|
|
1960
2118
|
}
|
|
1961
2119
|
const approveGas = 60000n;
|
|
@@ -3758,6 +3916,6 @@ function asSdkSigner(signer) {
|
|
|
3758
3916
|
return signer;
|
|
3759
3917
|
}
|
|
3760
3918
|
|
|
3761
|
-
export { ACCESS_CONTROL_ABI, ADMIN_CONFIG_ABI, ADMIN_WRITE_ABI, ActionType, ActionsStillPendingError, AsyncRequestTimeoutError, BRIDGE_ABI, BRIDGE_FACET_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, CONFIG_ABI, CURATOR_CONFIG_ABI, CantProcessWithdrawRequestError, CapacityFullError, ComposeAlreadyExecutedError, ComposeTimeoutError, ComposerNotConfiguredError, DEX_ABI, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EscrowNotConfiguredError, InsufficientBalanceError, InsufficientLiquidityError, InvalidInputError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NoSuchActionsError, NotCuratorError, NotGuardianError, NotHubVaultError, NotOwnerError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, REGISTRY_ABI, SUB_VAULT_ABI, SlippageExceededError, TIMELOCK_CONFIG_ABI, UNISWAP_V3_ROUTERS, UnsupportedAssetError, UnsupportedChainError, VAULT_ABI, VAULT_ANALYSIS_ABI, VaultPausedError, WhitelistQuotaExhaustedError, WithdrawalQueueDisabledError, WithdrawalTimelockActiveError, WrongChainError, acceptOwnership, addAvailableAsset, addAvailableAssets, asSdkSigner, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, canDeposit, checkProtocolWhitelist, depositAsync, depositCrossChainOracleOn, depositFromSpoke, depositFromSpokeAsync, depositMultiAsset, depositSimple, detectStargateOft, detectSubVaultType, disableAssetToDeposit, discoverVaultTopology, enableDepositWhitelist, encodeBridgeParams, encodeCuratorAction, encodeUniswapV3SwapCalldata, ensureAllowance, estimateRedeemCost, executeActions, executeCompose, executeCuratorBridge, findBridgeRoute, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getERC7540RequestStatus, getFullVaultTopology, getInboundRoutes, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getSubVaultInfo, getSubVaultPositions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultAssetBreakdown, getVaultConfiguration, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultPortfolio, getVaultPortfolioMultiChain, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, mintAsync, pauseVault, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, previewSubVaultDeposit, previewSubVaultRedeem, quoteComposeFee, quoteCuratorBridgeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, recoverAssets, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, setDepositCapacity, setDepositWhitelist, setFeeRecipient, smartDeposit, smartRedeem, submitActions, unpauseVault, vetoActions, waitForAsyncRequest, waitForCompose, withdrawAssets };
|
|
3919
|
+
export { ACCESS_CONTROL_ABI, ADMIN_CONFIG_ABI, ADMIN_WRITE_ABI, ActionType, ActionsStillPendingError, AsyncRequestTimeoutError, BRIDGE_ABI, BRIDGE_FACET_ABI, CCManagerNotConfiguredError, CHAIN_IDS, CHAIN_ID_TO_EID, COMPOSE_SCAN_CHUNK_SIZE, COMPOSE_SCAN_WINDOW_BLOCKS, CONFIG_ABI, CURATOR_CONFIG_ABI, CantProcessWithdrawRequestError, CapacityFullError, ComposeAlreadyExecutedError, ComposeTimeoutError, ComposerNotConfiguredError, DEFAULT_GAS_BUFFER_BPS, DEFAULT_LZ_ENDPOINT, DEX_ABI, EID_TO_CHAIN_ID, ERC20_ABI, ERC4626_FACET_ABI, ERC7540_FACET_ABI, EXECUTE_COMPOSE_GAS_LIMIT, EscrowNotConfiguredError, InsufficientBalanceError, InsufficientLiquidityError, InvalidInputError, LZ_ADAPTER_ABI, LZ_EIDS, LZ_ENDPOINT_ABI, LZ_ENDPOINT_BY_CHAIN, LZ_TIMEOUTS, METADATA_ABI, MULTICALL_ABI, MissingEscrowAddressError, MoreVaultsError, NATIVE_SYMBOL, NoSuchActionsError, NotCuratorError, NotGuardianError, NotHubVaultError, NotOwnerError, NotWhitelistedError, OFT_ABI, OFT_ROUTES, OMNI_FACTORY_ADDRESS, REGISTRY_ABI, SUB_VAULT_ABI, SlippageExceededError, TIMELOCK_CONFIG_ABI, UNISWAP_V3_ROUTERS, UnsupportedAssetError, UnsupportedChainError, VAULT_ABI, VAULT_ANALYSIS_ABI, VaultPausedError, WhitelistQuotaExhaustedError, WithdrawalQueueDisabledError, WithdrawalTimelockActiveError, WrongChainError, acceptOwnership, addAvailableAsset, addAvailableAssets, applyGasBuffer, asSdkSigner, bridgeAssetsToSpoke, bridgeSharesToHub, buildCuratorBatch, buildUniswapV3Swap, canDeposit, checkProtocolWhitelist, decodeComposeMessage, depositAsync, depositCrossChainOracleOn, depositFromSpoke, depositFromSpokeAsync, depositMultiAsset, depositSimple, detectStargateOft, detectSubVaultType, disableAssetToDeposit, discoverVaultTopology, enableDepositWhitelist, encodeBridgeParams, encodeCuratorAction, encodeUniswapV3SwapCalldata, ensureAllowance, estimateRedeemCost, executeActions, executeCompose, executeCuratorBridge, findBridgeRoute, findComposeByGuid, getAllVaultChainIds, getAsyncRequestStatus, getAsyncRequestStatusLabel, getCuratorVaultStatus, getDefaultGasBufferBps, getERC7540RequestStatus, getFullVaultTopology, getInboundRoutes, getLzEndpoint, getMaxWithdrawable, getOutboundRoutes, getPendingActions, getSubVaultInfo, getSubVaultPositions, getUserBalances, getUserBalancesForRoutes, getUserPosition, getUserPositionMultiChain, getVaultAnalysis, getVaultAssetBreakdown, getVaultConfiguration, getVaultDistribution, getVaultDistributionWithTopology, getVaultMetadata, getVaultPortfolio, getVaultPortfolioMultiChain, getVaultStatus, getVaultSummary, getVaultTopology, getWithdrawalRequest, isAsyncMode, isCurator, isOnHubChain, listPendingComposes, mintAsync, pauseVault, preflightAsync, preflightRedeemLiquidity, preflightSpokeDeposit, preflightSpokeRedeem, preflightSync, previewDeposit, previewRedeem, previewSubVaultDeposit, previewSubVaultRedeem, quoteComposeFee, quoteCuratorBridgeFee, quoteDepositFromSpokeFee, quoteLzFee, quoteRouteDepositFee, quoteShareBridgeFee, recoverAssets, redeemAsync, redeemShares, requestRedeem, resolveRedeemAddresses, setDefaultGasBufferBps, setDepositCapacity, setDepositWhitelist, setFeeRecipient, smartDeposit, smartRedeem, submitActions, unpauseVault, vetoActions, waitForAsyncRequest, waitForCompose, withdrawAssets };
|
|
3762
3920
|
//# sourceMappingURL=index.js.map
|
|
3763
3921
|
//# sourceMappingURL=index.js.map
|