From a482cc68cd0990a225d8d52feb37512d9df04d26 Mon Sep 17 00:00:00 2001 From: jonathanprozzi Date: Thu, 24 Sep 2026 11:23:58 -0400 Subject: [PATCH] feat(periphery): add the FeeProxy surface and refresh the TrustSwapAndBridgeRouter artifacts (P08) - Add the FeeProxy ABI and bytecode and the fee-proxy wrappers: createAtomsWithUrisVia (+ calldata encoder), registerAffiliate, affiliateConfig, isAffiliateActive, previewCreationFee, pendingRefund, claimRefund, and the FeeGuard type. - Add getFeeProxyAddressFromChainId over a periphery-local FeeProxy deployment map (empty until a deployment exists; the helper throws). - Regenerate the TrustSwapAndBridgeRouter ABI and bytecode from the deployed contract and move the Base-mainnet address to 0xE485D9a5Dc39774b7A80864B625969Cf9d93E5D7. The ownership, initializer and configuration-setter entries in the previous ABI never existed on the deployed contract (owner() reverts at both addresses); the swapAndBridgeWithERC20 / swapAndBridgeWithETH wrappers now take the required deadline argument. - Keep INTUITION_MAINNET_CHAIN_ID sourced from @0xintuition/deployments. - Remove a stray non-source file from src/contracts. Ported from the private reference implementation at feat/intuition-app @ 1b877506d. Breaking: the two swap wrappers gain a required deadline argument, and the router ABI export drops stale administrative entries. Identity impact: none. Periphery carries no atom bytes. --- packages/periphery/README.md | 24 +- .../periphery/src/contracts/FeeProxy-abi.ts | 2039 +++++++++++++++++ .../src/contracts/FeeProxy-bytecode.ts | 4 + .../contracts/TrustSwapAndBridgeRouter-abi.ts | 661 +++--- .../TrustSwapAndBridgeRouter-bytecode.ts | 2 +- .../periphery/src/contracts/added_context.txt | 62 - packages/periphery/src/contracts/index.ts | 2 + packages/periphery/src/deployments.test.ts | 6 +- packages/periphery/src/deployments.ts | 5 +- .../src/fee-proxy/affiliate-config.ts | 28 + .../periphery/src/fee-proxy/claim-refund.ts | 21 + .../create-atoms-with-uris-via-encode.test.ts | 34 + .../create-atoms-with-uris-via-encode.ts | 27 + .../fee-proxy/create-atoms-with-uris-via.ts | 37 + packages/periphery/src/fee-proxy/index.ts | 9 + .../src/fee-proxy/is-affiliate-active.ts | 28 + .../periphery/src/fee-proxy/pending-refund.ts | 27 + .../src/fee-proxy/preview-creation-fee.ts | 27 + .../src/fee-proxy/register-affiliate.ts | 35 + packages/periphery/src/fee-proxy/types.ts | 5 + packages/periphery/src/index.ts | 2 + .../quote-exact-input.test.ts | 26 +- .../quote-exact-input.ts | 13 +- .../swap-and-bridge-with-erc20-encode.test.ts | 5 +- .../swap-and-bridge-with-erc20-encode.ts | 9 +- .../swap-and-bridge-with-erc20.test.ts | 5 +- .../swap-and-bridge-with-eth-encode.test.ts | 6 +- .../swap-and-bridge-with-eth-encode.ts | 9 +- .../swap-and-bridge-with-eth.test.ts | 5 +- ...et-fee-proxy-address-from-chain-id.test.ts | 11 + .../get-fee-proxy-address-from-chain-id.ts | 18 + 31 files changed, 2833 insertions(+), 359 deletions(-) create mode 100644 packages/periphery/src/contracts/FeeProxy-abi.ts create mode 100644 packages/periphery/src/contracts/FeeProxy-bytecode.ts delete mode 100644 packages/periphery/src/contracts/added_context.txt create mode 100644 packages/periphery/src/fee-proxy/affiliate-config.ts create mode 100644 packages/periphery/src/fee-proxy/claim-refund.ts create mode 100644 packages/periphery/src/fee-proxy/create-atoms-with-uris-via-encode.test.ts create mode 100644 packages/periphery/src/fee-proxy/create-atoms-with-uris-via-encode.ts create mode 100644 packages/periphery/src/fee-proxy/create-atoms-with-uris-via.ts create mode 100644 packages/periphery/src/fee-proxy/index.ts create mode 100644 packages/periphery/src/fee-proxy/is-affiliate-active.ts create mode 100644 packages/periphery/src/fee-proxy/pending-refund.ts create mode 100644 packages/periphery/src/fee-proxy/preview-creation-fee.ts create mode 100644 packages/periphery/src/fee-proxy/register-affiliate.ts create mode 100644 packages/periphery/src/fee-proxy/types.ts create mode 100644 packages/periphery/src/utils/get-fee-proxy-address-from-chain-id.test.ts create mode 100644 packages/periphery/src/utils/get-fee-proxy-address-from-chain-id.ts diff --git a/packages/periphery/README.md b/packages/periphery/README.md index 4ab4b08..8676e6d 100644 --- a/packages/periphery/README.md +++ b/packages/periphery/README.md @@ -1,6 +1,6 @@ # @0xintuition/periphery -TypeScript helpers for Intuition periphery contracts, currently focused on `TrustSwapAndBridgeRouter` and direct meta-bridge wrappers. +TypeScript helpers for Intuition periphery contracts, including `FeeProxy`, `TrustSwapAndBridgeRouter`, and direct meta-bridge wrappers. Alpha status: published under the alpha dist-tag. Periphery bridge/router addresses stay in this package; shared Intuition chain IDs come from `@0xintuition/deployments`. @@ -17,6 +17,7 @@ Peer dependency: `viem ^2.0.0`. Release smoke tests install `viem@2.31.4`. ## Scope - Deployment helpers for published Intuition periphery contracts. +- FeeProxy artifacts, URI-aware atom creation encoders and client wrappers, affiliate registration and fee reads, and refund helpers. - Calldata encoders and client wrappers for `TrustSwapAndBridgeRouter`. - Direct bridge helpers for `MetaERC20Hub`, `MetaERC20Spoke`, and `MetaNativeSpoke`. - Base bridge asset address helpers for `USDC` and `WETH` approval flows. @@ -27,6 +28,10 @@ Current deployments are mainnet-oriented: - Intuition mainnet for `MetaERC20Spoke` and `MetaNativeSpoke`. - Base mainnet bridge asset addresses for `USDC` and `WETH`. +Bridge helpers cover router-based TRUST transfers from Base to Intuition, direct TRUST transfers from Intuition to Base, and direct USDC and WETH transfers in both directions. No periphery testnet deployments are included. + +The FeeProxy deployment map is empty. `getFeeProxyAddressFromChainId` throws until an address is published; FeeProxy wrappers accept an explicit contract address. + ## Usage ```ts @@ -36,4 +41,21 @@ import { base } from 'viem/chains' const routerAddress = getTrustSwapAndBridgeRouterAddressFromChainId(base.id) ``` +Generate deterministic calldata for a bridge call: + +```ts +import { trustSwapAndBridgeRouterBridgeTrustEncode } from '@0xintuition/periphery' + +const calldata = trustSwapAndBridgeRouterBridgeTrustEncode( + 1_000n, + '0x2222222222222222222222222222222222222222' +) +``` + +Router swap encoders and client wrappers require a `deadline` Unix timestamp. `trustSwapAndBridgeRouterQuoteExactInput` returns `[amountOut, success]`; check `success` and abort the swap when it is `false` before deriving a minimum output. + +`feeProxyCreateAtomsWithUrisViaEncode` encodes the affiliate, atom data, gross assets, URI lists, and a `FeeGuard` with `maxFeeBps` and `maxFixedFee`. `feeProxyCreateAtomsWithUrisVia` simulates and submits that call with the gross transaction value. Use `feeProxyPreviewCreationFee` to read the fee and forwarded amount, and `feeProxyPendingRefund` / `feeProxyClaimRefund` for pull-fallback refunds. + `WrappedTrust`, `MultiVault`, and other core protocol deployment addresses resolve from `@0xintuition/deployments`, not this package. + +`@0xintuition/protocol` provides core contract helpers; router, bridge, meta-bridge, and FeeProxy helpers belong to `@0xintuition/periphery`. diff --git a/packages/periphery/src/contracts/FeeProxy-abi.ts b/packages/periphery/src/contracts/FeeProxy-abi.ts new file mode 100644 index 0000000..56dd1ab --- /dev/null +++ b/packages/periphery/src/contracts/FeeProxy-abi.ts @@ -0,0 +1,2039 @@ +export const FeeProxyAbi = [ + { + type: 'constructor', + inputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'receive', + stateMutability: 'payable', + }, + { + type: 'function', + name: 'BPS_DIVISOR', + inputs: [], + outputs: [ + { + name: '', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'DEFAULT_ADMIN_ROLE', + inputs: [], + outputs: [ + { + name: '', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'PAUSER_ROLE', + inputs: [], + outputs: [ + { + name: '', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'affiliateConfig', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: 'config', + type: 'tuple', + internalType: 'struct AffiliateConfig', + components: [ + { + name: 'fees', + type: 'tuple', + internalType: 'struct FeeConfig', + components: [ + { + name: 'depositBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + name: 'feeRecipient', + type: 'address', + internalType: 'address', + }, + { + name: 'registeredAt', + type: 'uint64', + internalType: 'uint64', + }, + { + name: 'paused', + type: 'bool', + internalType: 'bool', + }, + ], + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'affiliateStats', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: 'stats', + type: 'tuple', + internalType: 'struct AffiliateStats', + components: [ + { + name: 'txCount', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'uniqueUsers', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'totalGrossAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'totalFees', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'totalForwardedAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositCount', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositGrossAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositFees', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositForwardedAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationCount', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationGrossAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationFees', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationForwardedAssets', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'affiliateUserStats', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + { + name: 'user', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: 'stats', + type: 'tuple', + internalType: 'struct AffiliateUserStats', + components: [ + { + name: 'txCount', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'totalGrossAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'totalFees', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'totalForwardedAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositCount', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositGrossAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositFees', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositForwardedAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationCount', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationGrossAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationFees', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationForwardedAssets', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'claimRefund', + inputs: [], + outputs: [ + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'claimRefundTo', + inputs: [ + { + name: 'recipient', + type: 'address', + internalType: 'address payable', + }, + ], + outputs: [ + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'createAtomsVia', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + { + name: 'atomDatas', + type: 'bytes[]', + internalType: 'bytes[]', + }, + { + name: 'assets', + type: 'uint256[]', + internalType: 'uint256[]', + }, + { + name: 'feeGuard', + type: 'tuple', + internalType: 'struct FeeGuard', + components: [ + { + name: 'maxFeeBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'maxFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + outputs: [ + { + name: 'termIds', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'createAtomsWithUrisVia', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + { + name: 'atomDatas', + type: 'bytes[]', + internalType: 'bytes[]', + }, + { + name: 'assets', + type: 'uint256[]', + internalType: 'uint256[]', + }, + { + name: 'uris', + type: 'bytes[][]', + internalType: 'bytes[][]', + }, + { + name: 'feeGuard', + type: 'tuple', + internalType: 'struct FeeGuard', + components: [ + { + name: 'maxFeeBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'maxFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + outputs: [ + { + name: 'termIds', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'createTriplesVia', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + { + name: 'subjectIds', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + { + name: 'predicateIds', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + { + name: 'objectIds', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + { + name: 'assets', + type: 'uint256[]', + internalType: 'uint256[]', + }, + { + name: 'feeGuard', + type: 'tuple', + internalType: 'struct FeeGuard', + components: [ + { + name: 'maxFeeBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'maxFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + outputs: [ + { + name: 'termIds', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'depositBatchVia', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + { + name: 'receiver', + type: 'address', + internalType: 'address', + }, + { + name: 'termIds', + type: 'bytes32[]', + internalType: 'bytes32[]', + }, + { + name: 'curveIds', + type: 'uint256[]', + internalType: 'uint256[]', + }, + { + name: 'assets', + type: 'uint256[]', + internalType: 'uint256[]', + }, + { + name: 'minShares', + type: 'uint256[]', + internalType: 'uint256[]', + }, + { + name: 'feeGuard', + type: 'tuple', + internalType: 'struct FeeGuard', + components: [ + { + name: 'maxFeeBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'maxFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + outputs: [ + { + name: 'shares', + type: 'uint256[]', + internalType: 'uint256[]', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'depositVia', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + { + name: 'receiver', + type: 'address', + internalType: 'address', + }, + { + name: 'termId', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'curveId', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'grossAssets', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'minShares', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'feeGuard', + type: 'tuple', + internalType: 'struct FeeGuard', + components: [ + { + name: 'maxFeeBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'maxFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + outputs: [ + { + name: 'shares', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'getRoleAdmin', + inputs: [ + { + name: 'role', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + outputs: [ + { + name: '', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'grantRole', + inputs: [ + { + name: 'role', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'account', + type: 'address', + internalType: 'address', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'hasRole', + inputs: [ + { + name: 'role', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'account', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: '', + type: 'bool', + internalType: 'bool', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'initialize', + inputs: [ + { + name: 'multiVault_', + type: 'address', + internalType: 'address', + }, + { + name: 'treasury_', + type: 'address', + internalType: 'address', + }, + { + name: 'admin_', + type: 'address', + internalType: 'address', + }, + { + name: 'maxFeeBps_', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'maxFixedFee_', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'registrationFee_', + type: 'uint256', + internalType: 'uint256', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'isAffiliateActive', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: '', + type: 'bool', + internalType: 'bool', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'isAffiliateRegistered', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: '', + type: 'bool', + internalType: 'bool', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'maxFeeBps', + inputs: [], + outputs: [ + { + name: '', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'maxFixedFee', + inputs: [], + outputs: [ + { + name: '', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'multiVault', + inputs: [], + outputs: [ + { + name: '', + type: 'address', + internalType: 'address', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'pause', + inputs: [], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'pauseAffiliate', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'paused', + inputs: [], + outputs: [ + { + name: '', + type: 'bool', + internalType: 'bool', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'pendingRefund', + inputs: [ + { + name: 'user', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: 'amount', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'previewCreationFee', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + { + name: 'grossAssets', + type: 'uint256', + internalType: 'uint256', + }, + ], + outputs: [ + { + name: 'fee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'forwarded', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'previewDepositFee', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + { + name: 'grossAssets', + type: 'uint256', + internalType: 'uint256', + }, + ], + outputs: [ + { + name: 'fee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'forwarded', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'registerAffiliate', + inputs: [ + { + name: 'fees', + type: 'tuple', + internalType: 'struct FeeConfig', + components: [ + { + name: 'depositBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + name: 'feeRecipient', + type: 'address', + internalType: 'address', + }, + ], + outputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'registrationFee', + inputs: [], + outputs: [ + { + name: '', + type: 'uint256', + internalType: 'uint256', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'renounceRole', + inputs: [ + { + name: 'role', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'callerConfirmation', + type: 'address', + internalType: 'address', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'revokeRole', + inputs: [ + { + name: 'role', + type: 'bytes32', + internalType: 'bytes32', + }, + { + name: 'account', + type: 'address', + internalType: 'address', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'setMaxFeeBps', + inputs: [ + { + name: 'newMaxFeeBps', + type: 'uint256', + internalType: 'uint256', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'setMaxFixedFee', + inputs: [ + { + name: 'newMaxFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'setRegistrationFee', + inputs: [ + { + name: 'newRegistrationFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'supportsInterface', + inputs: [ + { + name: 'interfaceId', + type: 'bytes4', + internalType: 'bytes4', + }, + ], + outputs: [ + { + name: '', + type: 'bool', + internalType: 'bool', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'treasury', + inputs: [], + outputs: [ + { + name: '', + type: 'address', + internalType: 'address', + }, + ], + stateMutability: 'view', + }, + { + type: 'function', + name: 'unpause', + inputs: [], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'unpauseAffiliate', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'updateAffiliateFees', + inputs: [ + { + name: 'fees', + type: 'tuple', + internalType: 'struct FeeConfig', + components: [ + { + name: 'depositBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'updateFeeRecipient', + inputs: [ + { + name: 'recipient', + type: 'address', + internalType: 'address', + }, + ], + outputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'event', + name: 'AffiliateFeePaid', + inputs: [ + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'amount', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'AffiliateFeeRecipientUpdated', + inputs: [ + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'previous', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'current', + type: 'address', + indexed: true, + internalType: 'address', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'AffiliateFeesUpdated', + inputs: [ + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'previous', + type: 'tuple', + indexed: false, + internalType: 'struct FeeConfig', + components: [ + { + name: 'depositBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + name: 'current', + type: 'tuple', + indexed: false, + internalType: 'struct FeeConfig', + components: [ + { + name: 'depositBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'AffiliatePaused', + inputs: [ + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'AffiliateRegistered', + inputs: [ + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'feeRecipient', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'fees', + type: 'tuple', + indexed: false, + internalType: 'struct FeeConfig', + components: [ + { + name: 'depositBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationBps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'depositFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'creationFixedFee', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + name: 'registrationFee', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'AffiliateUnpaused', + inputs: [ + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'CreatedAtomsVia', + inputs: [ + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'totalGrossAssets', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'totalFee', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'totalForwardedAssets', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'atomCount', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'CreatedTriplesVia', + inputs: [ + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'totalGrossAssets', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'totalFee', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'totalForwardedAssets', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'tripleCount', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'DepositedBatchVia', + inputs: [ + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'totalGrossAssets', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'totalFee', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'totalForwardedAssets', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'DepositedVia', + inputs: [ + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'affiliate', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'termId', + type: 'bytes32', + indexed: true, + internalType: 'bytes32', + }, + { + name: 'grossAssets', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'fee', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'forwardedAssets', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'shares', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'Initialized', + inputs: [ + { + name: 'version', + type: 'uint64', + indexed: false, + internalType: 'uint64', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'MaxFeeBpsUpdated', + inputs: [ + { + name: 'previous', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'current', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'MaxFixedFeeUpdated', + inputs: [ + { + name: 'previous', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'current', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'Paused', + inputs: [ + { + name: 'account', + type: 'address', + indexed: false, + internalType: 'address', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'RefundClaimed', + inputs: [ + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'amount', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'RefundCredited', + inputs: [ + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'amount', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'RegistrationFeeForwarded', + inputs: [ + { + name: 'treasury', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'amount', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'RegistrationFeeUpdated', + inputs: [ + { + name: 'previous', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'current', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'RoleAdminChanged', + inputs: [ + { + name: 'role', + type: 'bytes32', + indexed: true, + internalType: 'bytes32', + }, + { + name: 'previousAdminRole', + type: 'bytes32', + indexed: true, + internalType: 'bytes32', + }, + { + name: 'newAdminRole', + type: 'bytes32', + indexed: true, + internalType: 'bytes32', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'RoleGranted', + inputs: [ + { + name: 'role', + type: 'bytes32', + indexed: true, + internalType: 'bytes32', + }, + { + name: 'account', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'sender', + type: 'address', + indexed: true, + internalType: 'address', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'RoleRevoked', + inputs: [ + { + name: 'role', + type: 'bytes32', + indexed: true, + internalType: 'bytes32', + }, + { + name: 'account', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'sender', + type: 'address', + indexed: true, + internalType: 'address', + }, + ], + anonymous: false, + }, + { + type: 'event', + name: 'Unpaused', + inputs: [ + { + name: 'account', + type: 'address', + indexed: false, + internalType: 'address', + }, + ], + anonymous: false, + }, + { + type: 'error', + name: 'AccessControlBadConfirmation', + inputs: [], + }, + { + type: 'error', + name: 'AccessControlUnauthorizedAccount', + inputs: [ + { + name: 'account', + type: 'address', + internalType: 'address', + }, + { + name: 'neededRole', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + }, + { + type: 'error', + name: 'EnforcedPause', + inputs: [], + }, + { + type: 'error', + name: 'ExpectedPause', + inputs: [], + }, + { + type: 'error', + name: 'FailedCall', + inputs: [], + }, + { + type: 'error', + name: 'FeeProxy_AffiliateAlreadyPaused', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_AffiliateAlreadyRegistered', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_AffiliateNotPaused', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_AffiliateNotRegistered', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_AffiliatePaused', + inputs: [ + { + name: 'affiliate', + type: 'address', + internalType: 'address', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_BpsExceedsCallerGuard', + inputs: [ + { + name: 'configured', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'callerMax', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_BpsExceedsCap', + inputs: [ + { + name: 'bps', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'cap', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_FeeExceedsGross', + inputs: [ + { + name: 'fee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'gross', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_FixedFeeExceedsCallerGuard', + inputs: [ + { + name: 'configured', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'callerMax', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_FixedFeeExceedsCap', + inputs: [ + { + name: 'fixedFee', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'cap', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_InsufficientValue', + inputs: [ + { + name: 'supplied', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'required', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_LengthMismatch', + inputs: [], + }, + { + type: 'error', + name: 'FeeProxy_MaxFeeBpsOutOfRange', + inputs: [ + { + name: 'requested', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_NoRefundOwed', + inputs: [], + }, + { + type: 'error', + name: 'FeeProxy_ProxyNotApprovedForCreation', + inputs: [ + { + name: 'creator', + type: 'address', + internalType: 'address', + }, + { + name: 'proxy', + type: 'address', + internalType: 'address', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_ProxyNotApprovedForDeposit', + inputs: [ + { + name: 'receiver', + type: 'address', + internalType: 'address', + }, + { + name: 'proxy', + type: 'address', + internalType: 'address', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_ReceiverNotApproved', + inputs: [ + { + name: 'receiver', + type: 'address', + internalType: 'address', + }, + { + name: 'caller', + type: 'address', + internalType: 'address', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_RefundRecipientIsProxy', + inputs: [], + }, + { + type: 'error', + name: 'FeeProxy_RegistrationFeeMismatch', + inputs: [ + { + name: 'sent', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'required', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_UnauthorizedEthSender', + inputs: [ + { + name: 'sender', + type: 'address', + internalType: 'address', + }, + ], + }, + { + type: 'error', + name: 'FeeProxy_ZeroAddress', + inputs: [], + }, + { + type: 'error', + name: 'FeeProxy_ZeroValue', + inputs: [], + }, + { + type: 'error', + name: 'InsufficientBalance', + inputs: [ + { + name: 'balance', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'needed', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'InvalidInitialization', + inputs: [], + }, + { + type: 'error', + name: 'NotInitializing', + inputs: [], + }, + { + type: 'error', + name: 'ReentrancyGuardReentrantCall', + inputs: [], + }, +] as const; diff --git a/packages/periphery/src/contracts/FeeProxy-bytecode.ts b/packages/periphery/src/contracts/FeeProxy-bytecode.ts new file mode 100644 index 0000000..ac8e51d --- /dev/null +++ b/packages/periphery/src/contracts/FeeProxy-bytecode.ts @@ -0,0 +1,4 @@ +import type { Hex } from 'viem'; + +export const FeeProxyBytecode: Hex = + '0x6080604052348015600e575f5ffd5b5060156019565b60c9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161560685760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b039081161460c65780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b614685806100d65f395ff3fe6080604052600436106102b9575f3560e01c8063728cdbca11610170578063b2678a9a116100d1578063cd7cde2b11610087578063e59519f111610062578063e59519f1146109db578063e63ab1e9146109fa578063f160d36914610a2d575f5ffd5b8063cd7cde2b146108ee578063d547741f1461099d578063d788dc3e146109bc575f5ffd5b8063bf769a3f116100b7578063bf769a3f1461089b578063c2b2671c146108b0578063c320c727146108cf575f5ffd5b8063b2678a9a14610874578063b5545a3c14610887575f5ffd5b806391d1485411610126578063a17314311161010c578063a17314311461082f578063a217fddf1461084e578063a3ad884414610861575f5ffd5b806391d14854146107a157806399d82c5f14610804575f5ffd5b80638456cb59116101565780638456cb591461075c5780638c3ecc45146107705780638c93fdda1461078e575f5ffd5b8063728cdbca1461071e5780637bdca1a81461073d575f5ffd5b806336568abe1161021a578063569ef79e116101d057806361d027b3116101b657806361d027b3146105d1578063649892c91461060857806368b938f0146106c3575f5ffd5b8063569ef79e1461057b5780635c975abb1461059b575f5ffd5b8063391a4df911610200578063391a4df9146105285780633f4ba83a14610547578063566b6e411461055b575f5ffd5b806336568abe146104ea57806338f8333214610509575f5ffd5b8063248a9ca31161026f5780632f2ff15d116102555780632f2ff15d146104825780633015377a146104a15780633442f4b0146104d5575f5ffd5b8063248a9ca3146103ba5780632696cbf914610407575f5ffd5b806314c44e091161029f57806314c44e0914610371578063191fe1ed14610386578063246d45691461039b575f5ffd5b806301ffc9a71461031c57806302e07b5014610350575f5ffd5b36610318575f546001600160a01b031633148015906102d85750333014155b15610316576040517fde73f9e50000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b005b5f5ffd5b348015610327575f5ffd5b5061033b610336366004613aa1565b610a4c565b60405190151581526020015b60405180910390f35b61036361035e366004613b15565b610ae4565b604051908152602001610347565b34801561037c575f5ffd5b5061036360045481565b348015610391575f5ffd5b5061036361271081565b3480156103a6575f5ffd5b506103166103b5366004613b80565b610db9565b3480156103c5575f5ffd5b506103636103d4366004613b80565b5f9081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b348015610412575f5ffd5b50610426610421366004613b97565b610e49565b60408051825180518252602080820151818401528184015183850152606091820151828401528401516001600160a01b031660808301529183015167ffffffffffffffff1660a0820152910151151560c082015260e001610347565b34801561048d575f5ffd5b5061031661049c366004613bb2565b610f07565b3480156104ac575f5ffd5b506104c06104bb366004613be0565b610f50565b60408051928352602083019190915201610347565b3480156104e0575f5ffd5b5061036360035481565b3480156104f5575f5ffd5b50610316610504366004613bb2565b610fa2565b348015610514575f5ffd5b50610363610523366004613b97565b610ff3565b348015610533575f5ffd5b50610316610542366004613b97565b6110b7565b348015610552575f5ffd5b50610316611210565b61056e610569366004613c52565b611225565b6040516103479190613d8c565b61058e610589366004613d9e565b611454565b6040516103479190613e8d565b3480156105a6575f5ffd5b507fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1661033b565b3480156105dc575f5ffd5b506001546105f0906001600160a01b031681565b6040516001600160a01b039091168152602001610347565b348015610613575f5ffd5b50610627610622366004613b97565b611523565b60405161034791905f6101a082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010083015161010083015261012083015161012083015261014083015161014083015261016083015161016083015261018083015161018083015292915050565b3480156106ce575f5ffd5b5061033b6106dd366004613b97565b6001600160a01b03165f9081526005602052604090206004015474010000000000000000000000000000000000000000900467ffffffffffffffff16151590565b348015610729575f5ffd5b50610316610738366004613ecf565b61162d565b348015610748575f5ffd5b50610316610757366004613b97565b6118db565b348015610767575f5ffd5b50610316611a74565b34801561077b575f5ffd5b505f546105f0906001600160a01b031681565b6105f061079c366004613f40565b611aa6565b3480156107ac575f5ffd5b5061033b6107bb366004613bb2565b5f9182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561080f575f5ffd5b5061036361081e366004613b97565b60066020525f908152604090205481565b34801561083a575f5ffd5b50610316610849366004613f6b565b611d3d565b348015610859575f5ffd5b506103635f81565b61058e61086f366004613f85565b611e56565b61058e610882366004614017565b612033565b348015610892575f5ffd5b50610363612221565b3480156108a6575f5ffd5b5061036360025481565b3480156108bb575f5ffd5b506104c06108ca366004613be0565b612261565b3480156108da575f5ffd5b506103166108e9366004613b80565b612291565b3480156108f9575f5ffd5b5061090d6109083660046140d9565b6122d9565b60405161034791905f61018082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010083015161010083015261012083015161012083015261014083015161014083015261016083015161016083015292915050565b3480156109a8575f5ffd5b506103166109b7366004613bb2565b6123df565b3480156109c7575f5ffd5b506103166109d6366004613b80565b612422565b3480156109e6575f5ffd5b5061033b6109f5366004613b97565b61246a565b348015610a05575f5ffd5b506103637f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b348015610a38575f5ffd5b50610316610a47366004613b97565b6124e2565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610ade57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b5f610aed612602565b610af5612660565b6001600160a01b038716610b35576040517ff0e4f71c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b3e876126e1565b835f03610b77576040517f74a14a8b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83341015610bba576040517fc50e52880000000000000000000000000000000000000000000000000000000081523460048201526024810185905260440161030d565b5f610bc48961289d565b80546002820154919250610bd79161298b565b80546002820154610be9919085612a19565b805460028201545f91610bfe91889190612aa9565b9050858110610c43576040517f84fcd80f000000000000000000000000000000000000000000000000000000008152600481018290526024810187905260440161030d565b5f610c4e8288614132565b6004840154909150610c6b906001600160a01b03168c3385612ad4565b5f546040517f2fb1d2700000000000000000000000000000000000000000000000000000000081526001600160a01b038c81166004830152602482018c9052604482018b90526064820189905290911690632fb1d27090839060840160206040518083038185885af1158015610ce3573d5f5f3e3d5ffd5b50505050506040513d601f19601f82011682018060405250810190610d089190614145565b9350610d188b338985855f612b8a565b610d2b33610d268934614132565b612e5e565b60408051888152602081018490529081018290526060810185905289906001600160a01b038d169033907f62be2ce96da4e877861c066204bd30d89a889d4bb27ca7e428d37a561ef5ea7f9060800160405180910390a4505050610dae60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b979650505050505050565b5f610dc381612f4d565b612710821115610e02576040517f0784e8ef0000000000000000000000000000000000000000000000000000000081526004810183905260240161030d565b600280549083905560408051828152602081018590527fcb160cc2f1db06f52755d5108650bbc0dc12d1b3af613578de6251fe56369d3091015b60405180910390a1505050565b610e51613a55565b506001600160a01b039081165f90815260056020908152604091829020825161010081018452815460808201908152600183015460a0830152600283015460c0830152600383015460e083015281526004909101549384169181019190915274010000000000000000000000000000000000000000830467ffffffffffffffff16918101919091527c010000000000000000000000000000000000000000000000000000000090910460ff161515606082015290565b5f8281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610f4081612f4d565b610f4a8383612f57565b50505050565b6001600160a01b0382165f90815260056020526040812080546002820154839291610f7d91869190612aa9565b925083831015610f9657610f918385614132565b610f98565b5f5b9150509250929050565b6001600160a01b0381163314610fe4576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610fee8282613041565b505050565b5f610ffc612660565b6001600160a01b03821661103c576040517ff0e4f71c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b306001600160a01b0383160361107e576040517feb59493c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61108782613103565b90506110b260017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b919050565b5f6110c181612f4d565b6001600160a01b0382165f908152600560205260408120600481015490917401000000000000000000000000000000000000000090910467ffffffffffffffff169003611145576040517f825ce9430000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260240161030d565b60048101547c0100000000000000000000000000000000000000000000000000000000900460ff166111ae576040517f15f056d80000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260240161030d565b6004810180547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690556040516001600160a01b038416907fc8233ed71698d3f297dc4b872dccd5ff591ecb8978f2f54d689d1688a3fe2711905f90a2505050565b5f61121a81612f4d565b61122261319f565b50565b606061122f612602565b611237612660565b6001600160a01b038b16611277576040517ff0e4f71c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112808b6126e1565b88158061128d5750888714155b806112985750888514155b806112a35750888314155b156112da576040517f2548ff6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6112e88d8888865f61322f565b90506112fe81606001518e338460200151612ad4565b5f5f9054906101000a90046001600160a01b03166001600160a01b031663dea9423a82604001518e8e8e8e8e88608001518d8d6040518a63ffffffff1660e01b81526004016113549897969594939291906141a5565b5f6040518083038185885af115801561136f573d5f5f3e3d5ffd5b50505050506040513d5f823e601f3d908101601f191682016040526113979190810190614284565b91506113b28d33835f0151846020015185604001515f612b8a565b80516113c4903390610d269034614132565b80516020808301516040808501518151948552928401919091528201526001600160a01b038e169033907fada70f19226061b6de8189b655b8dd74e63b39b6ea00acf85d6b99595234e54b9060600160405180910390a35061144560017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b9b9a5050505050505050505050565b606061145e612602565b611466612660565b8815806114735750888714155b8061147e5750888514155b806114895750888314155b156114c0576040517f2548ff6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6114c86133a5565b5f6114d78c868686600161322f565b90506114e98c8c8c8c8c8c8c8861346d565b91505061151560017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b9a9950505050505050505050565b611581604051806101a001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b506001600160a01b03165f9081526007602081815260409283902083516101a081018552815481526001820154928101929092526002810154938201939093526003830154606082015260048301546080820152600583015460a0820152600683015460c08201529082015460e082015260088201546101008201526009820154610120820152600a820154610140820152600b820154610160820152600c9091015461018082015290565b5f6116366135bd565b805490915060ff68010000000000000000820416159067ffffffffffffffff165f811580156116625750825b90505f8267ffffffffffffffff16600114801561167e5750303b155b90508115801561168c575080155b156116c3576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156117245784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b6001600160a01b038b16158061174157506001600160a01b038a16155b8061175357506001600160a01b038916155b1561178a576040517ff0e4f71c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127108811156117c9576040517f0784e8ef0000000000000000000000000000000000000000000000000000000081526004810189905260240161030d565b6117d16135e5565b6117d96135e5565b6117e16135ed565b6117eb5f8a612f57565b506118167f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a8a612f57565b505f80546001600160a01b03808e167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560018054928d169290911691909117905560028890556003879055600486905583156118ce5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a61190581612f4d565b6001600160a01b0382165f908152600560205260408120600481015490917401000000000000000000000000000000000000000090910467ffffffffffffffff169003611989576040517f825ce9430000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260240161030d565b60048101547c0100000000000000000000000000000000000000000000000000000000900460ff16156119f3576040517ff321dab10000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260240161030d565b6004810180547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c01000000000000000000000000000000000000000000000000000000001790556040516001600160a01b038416907fadccfc70b088705bc53a68ffc90184a1d6103bdb1b63b1cb5b38fccbb3190db5905f90a2505050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a611a9e81612f4d565b6112226135fd565b5f611aaf612602565b611ab7612660565b6001600160a01b038216611af7576040517ff0e4f71c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600454348114611b3c576040517fcac926c00000000000000000000000000000000000000000000000000000000081523460048201526024810182905260440161030d565b335f81815260056020526040902060048101549193509074010000000000000000000000000000000000000000900467ffffffffffffffff1615611bb7576040517fd9ee6ad00000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260240161030d565b611bc085613676565b8435815560208501356001820155604085013560028201556060850135600382015560048101805467ffffffffffffffff421674010000000000000000000000000000000000000000027fffffffff000000000000000000000000000000000000000000000000000000009091166001600160a01b038716171790558115611c9b57600154611c58906001600160a01b031683613697565b6001546040518381526001600160a01b03909116907f7574bc52269806b4289787a8442f0e97d2204029e41a86e51baa69901b1269019060200160405180910390a25b836001600160a01b0316836001600160a01b03167e4c88cd740cc13970f60a94ac602f4143e1b920e88a944d4f1cc433299043b08785604051611d0a92919082358152602080840135908201526040808401359082015260609283013592810192909252608082015260a00190565b60405180910390a35050610ade60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b335f908152600560205260408120600481015490917401000000000000000000000000000000000000000090910467ffffffffffffffff169003611daf576040517f825ce94300000000000000000000000000000000000000000000000000000000815233600482015260240161030d565b611db882613676565b604080516080810182528254815260018301546020820152600283015491810191909152600382015460608201528282611e138282813581556020820135600182015560408201356002820155606090910135600390910155565b505060405133907fb7e6d595e2aca72ca37fb8cc84fada223087f03debea7d4fff8b2cf579e3323a90611e499084908790614310565b60405180910390a2505050565b6060611e60612602565b611e68612660565b841580611e755750848314155b15611eac576040517f2548ff6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611eb46133a5565b5f611ec388868686600161322f565b9050611ed9816060015189338460200151612ad4565b5f54604080830151608084015191517fdf62fa880000000000000000000000000000000000000000000000000000000081526001600160a01b039093169263df62fa8892611f309133918d918d919060040161443c565b5f6040518083038185885af1158015611f4b573d5f5f3e3d5ffd5b50505050506040513d5f823e601f3d908101601f19168201604052611f739190810190614284565b9150611f8f8833835f0151846020015185604001516001612b8a565b8051611fa1903390610d269034614132565b8051602080830151604080850151815194855292840191909152820152606081018790526001600160a01b0389169033907f17b4daf0fd037ae01ac84521e7b8a10da326f1352391cba72318f6931b22948e9060800160405180910390a35061202960017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b9695505050505050565b606061203d612602565b612045612660565b8615806120525750868514155b8061205d5750868314155b15612094576040517f2548ff6b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61209c6133a5565b5f6120ab8a888886600161322f565b90506120c181606001518b338460200151612ad4565b5f54604080830151608084015191517fb15d75780000000000000000000000000000000000000000000000000000000081526001600160a01b039093169263b15d75789261211c9133918f918f91908d908d90600401614470565b5f6040518083038185885af1158015612137573d5f5f3e3d5ffd5b50505050506040513d5f823e601f3d908101601f1916820160405261215f9190810190614284565b915061217b8a33835f0151846020015185604001516001612b8a565b805161218d903390610d269034614132565b8051602080830151604080850151815194855292840191909152820152606081018990526001600160a01b038b169033907f17b4daf0fd037ae01ac84521e7b8a10da326f1352391cba72318f6931b22948e9060800160405180910390a35061221560017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b98975050505050505050565b5f61222a612660565b61223333613103565b905061225e60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b90565b6001600160a01b0382165f90815260056020526040812060018101546003820154839291610f7d91869190612aa9565b5f61229b81612f4d565b600480549083905560408051828152602081018590527f50b218c5a101ad05d53ab0a964d01da639ee79525ae4b7802ed714249740a8d59101610e3c565b6123316040518061018001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b506001600160a01b039182165f90815260086020818152604080842094909516835292835290839020835161018081018552815481526001820154938101939093526002810154938301939093526003830154606083015260048301546080830152600583015460a0830152600683015460c0830152600783015460e08301528201546101008201526009820154610120820152600a820154610140820152600b9091015461016082015290565b5f8281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015461241881612f4d565b610f4a8383613041565b5f61242c81612f4d565b600380549083905560408051828152602081018590527fc345cab0f0b4eb49dd93607724568f1cb3d4fe7e78ff847219404dbc540f13a69101610e3c565b6001600160a01b0381165f908152600560205260408120600481015474010000000000000000000000000000000000000000900467ffffffffffffffff16158015906124db575060048101547c0100000000000000000000000000000000000000000000000000000000900460ff16155b9392505050565b6001600160a01b038116612522576040517ff0e4f71c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f908152600560205260408120600481015490917401000000000000000000000000000000000000000090910467ffffffffffffffff169003612594576040517f825ce94300000000000000000000000000000000000000000000000000000000815233600482015260240161030d565b6004810180546001600160a01b038481167fffffffffffffffffffffffff00000000000000000000000000000000000000008316811790935560405191169190829033907fa15d439b19637f4f49a6c91b956d5234fce876baa18edb119f4df154677b4136905f90a4505050565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff161561265e576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016126db576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b5f546040517fab19bcd40000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03838116602483015290911690819063ab19bcd490604401602060405180830381865afa158015612749573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061276d919061456c565b6127b4576040517fe86c6cca0000000000000000000000000000000000000000000000000000000081526001600160a01b038316600482015230602482015260440161030d565b6001600160a01b038216331480159061285157506040517fab19bcd40000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03838116602483015282169063ab19bcd490604401602060405180830381865afa15801561282b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061284f919061456c565b155b15612899576040517fe73a1aba0000000000000000000000000000000000000000000000000000000081526001600160a01b038316600482015233602482015260440161030d565b5050565b6001600160a01b0381165f908152600560205260408120600481015490917401000000000000000000000000000000000000000090910467ffffffffffffffff169003612921576040517f825ce9430000000000000000000000000000000000000000000000000000000081526001600160a01b038316600482015260240161030d565b60048101547c0100000000000000000000000000000000000000000000000000000000900460ff16156110b2576040517f63f7b74c0000000000000000000000000000000000000000000000000000000081526001600160a01b038316600482015260240161030d565b600254600354818411156129d5576040517f4995c65d000000000000000000000000000000000000000000000000000000008152600481018590526024810183905260440161030d565b80831115610f4a576040517f7ee28b9f000000000000000000000000000000000000000000000000000000008152600481018490526024810182905260440161030d565b8035831115612a5e576040517fff844cd1000000000000000000000000000000000000000000000000000000008152600481018490528135602482015260440161030d565b8060200135821115610fee576040517f3525d835000000000000000000000000000000000000000000000000000000008152600481018390526020820135602482015260440161030d565b5f81612710612ab8858761458b565b612ac291906145a2565b612acc91906145da565b949350505050565b805f03612b2d57816001600160a01b0316836001600160a01b03167ff92f716a512f171e7e6573631112c7cfc0d0200c1eb5a8ab0ab22dbc481938b25f604051612b2091815260200190565b60405180910390a3610f4a565b612b378482613697565b816001600160a01b0316836001600160a01b03167ff92f716a512f171e7e6573631112c7cfc0d0200c1eb5a8ab0ab22dbc481938b283604051612b7c91815260200190565b60405180910390a350505050565b6001600160a01b038087165f90815260076020908152604080832060088352818420948a1684529390915281208054909103612bda576001826001015f828254612bd491906145da565b90915550505b6001825f015f828254612bed91906145da565b9250508190555085826002015f828254612c0791906145da565b9250508190555084826003015f828254612c2191906145da565b9250508190555083826004015f828254612c3b91906145da565b9091555050805460019082905f90612c549084906145da565b9250508190555085816001015f828254612c6e91906145da565b9250508190555084816002015f828254612c8891906145da565b9250508190555083816003015f828254612ca291906145da565b90915550508215612d83576001826009015f828254612cc191906145da565b925050819055508582600a015f828254612cdb91906145da565b925050819055508482600b015f828254612cf591906145da565b925050819055508382600c015f828254612d0f91906145da565b925050819055506001816008015f828254612d2a91906145da565b9250508190555085816009015f828254612d4491906145da565b925050819055508481600a015f828254612d5e91906145da565b925050819055508381600b015f828254612d7891906145da565b90915550612e549050565b6001826005015f828254612d9791906145da565b9250508190555085826006015f828254612db191906145da565b9250508190555084826007015f828254612dcb91906145da565b9250508190555083826008015f828254612de591906145da565b925050819055506001816004015f828254612e0091906145da565b9250508190555085816005015f828254612e1a91906145da565b9250508190555084816006015f828254612e3491906145da565b9250508190555083816007015f828254612e4e91906145da565b90915550505b5050505050505050565b805f03612e69575050565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114612eb2576040519150601f19603f3d011682016040523d82523d5f602084013e612eb7565b606091505b5050905080610fee576001600160a01b0383165f9081526006602052604081208054849290612ee79084906145da565b90915550506040518281526001600160a01b038416907f57b31d08aad1b08f38687f5d1a07c24f3c09768a493b5b11f4de021a3ac6fbb990602001611e49565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b611222813361373c565b5f8281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16613038575f848152602082815260408083206001600160a01b0387168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055612fee3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610ade565b5f915050610ade565b5f8281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff1615613038575f848152602082815260408083206001600160a01b038716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610ade565b335f908152600660205260408120549081900361314c576040517ff779648300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f908152600660205260408120556131658282613697565b60405181815233907f358fe4192934d3bf28ae181feda1f4bd08ca67f5e2fad55582cce5eb67304ae99060200160405180910390a2919050565b6131a76137c8565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b6132666040518060a001604052805f81526020015f81526020015f81526020015f6001600160a01b03168152602001606081525090565b5f6132708761289d565b90505f8361327f578154613285565b60018201545b90505f8461329757600283015461329d565b60038301545b90506132a9828261298b565b6132b4828288612a19565b5f6132bf8989613823565b905080341015613304576040517fc50e52880000000000000000000000000000000000000000000000000000000081523460048201526024810182905260440161030d565b5f613310828585612aa9565b9050818110613355576040517f84fcd80f000000000000000000000000000000000000000000000000000000008152600481018290526024810183905260440161030d565b818652602086018190526133698183614132565b6040870181905260048601546001600160a01b03166060880152613391908b908b90856138b6565b608087015250939998505050505050505050565b5f546040517f4656c5f10000000000000000000000000000000000000000000000000000000081523060048201523360248201526001600160a01b03909116908190634656c5f190604401602060405180830381865afa15801561340b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061342f919061456c565b611222576040517f2d07547600000000000000000000000000000000000000000000000000000000815233600482015230602482015260440161030d565b606061348382606001518a338560200151612ad4565b5f54604080840151608085015191517f7a9d980f0000000000000000000000000000000000000000000000000000000081526001600160a01b0390931692637a9d980f926134e29133918e918e918e918e918e918e91906004016145ed565b5f6040518083038185885af11580156134fd573d5f5f3e3d5ffd5b50505050506040513d5f823e601f3d908101601f191682016040526135259190810190614284565b90506135418933845f0151856020015186604001516001612b8a565b8151613553903390610d269034614132565b8151602080840151604080860151815194855292840191909152820152606081018890526001600160a01b038a169033907f972fb51dc9b3afd7a305482247d31628c9d4f433fc894b641c71491571447ff09060800160405180910390a398975050505050505050565b5f807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00610ade565b61265e6139b0565b6135f56139b0565b61265e6139ee565b613605612602565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833613211565b6136858135604083013561298b565b6112228160200135826060013561298b565b804710156136da576040517fcf4791810000000000000000000000000000000000000000000000000000000081524760048201526024810182905260440161030d565b5f5f836001600160a01b0316836040515f6040518083038185875af1925050503d805f8114613724576040519150601f19603f3d011682016040523d82523d5f602084013e613729565b606091505b509150915081610f4a57610f4a816139f6565b5f8281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408083206001600160a01b038516845290915290205460ff16612899576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b03821660048201526024810183905260440161030d565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff1661265e576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f81815b818110156138ae578484828181106138415761384161464b565b905060200201355f03613880576040517f74a14a8b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8484828181106138925761389261464b565b90506020020135836138a491906145da565b9250600101613827565b505092915050565b6060838067ffffffffffffffff8111156138d2576138d2614203565b6040519080825280602002602001820160405280156138fb578160200160208202803683370190505b5091505f61390a600183614132565b90505f805b8281101561397c575f86888b8b8581811061392c5761392c61464b565b9050602002013561393d919061458b565b61394791906145a2565b90508086838151811061395c5761395c61464b565b602090810291909101015261397181846145da565b92505060010161390f565b506139878187614132565b8483815181106139995761399961464b565b602002602001018181525050505050949350505050565b6139b8613a37565b61265e576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612f276139b0565b805115613a0557805160208201fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f613a406135bd565b5468010000000000000000900460ff16919050565b6040518060800160405280613a8760405180608001604052805f81526020015f81526020015f81526020015f81525090565b81525f602082018190526040820181905260609091015290565b5f60208284031215613ab1575f5ffd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146124db575f5ffd5b6001600160a01b0381168114611222575f5ffd5b80356110b281613ae0565b5f60408284031215613b0f575f5ffd5b50919050565b5f5f5f5f5f5f5f610100888a031215613b2c575f5ffd5b8735613b3781613ae0565b96506020880135613b4781613ae0565b955060408801359450606088013593506080880135925060a08801359150613b728960c08a01613aff565b905092959891949750929550565b5f60208284031215613b90575f5ffd5b5035919050565b5f60208284031215613ba7575f5ffd5b81356124db81613ae0565b5f5f60408385031215613bc3575f5ffd5b823591506020830135613bd581613ae0565b809150509250929050565b5f5f60408385031215613bf1575f5ffd5b8235613bfc81613ae0565b946020939093013593505050565b5f5f83601f840112613c1a575f5ffd5b50813567ffffffffffffffff811115613c31575f5ffd5b6020830191508360208260051b8501011115613c4b575f5ffd5b9250929050565b5f5f5f5f5f5f5f5f5f5f5f6101008c8e031215613c6d575f5ffd5b613c768c613af4565b9a50613c8460208d01613af4565b995060408c013567ffffffffffffffff811115613c9f575f5ffd5b613cab8e828f01613c0a565b909a5098505060608c013567ffffffffffffffff811115613cca575f5ffd5b613cd68e828f01613c0a565b90985096505060808c013567ffffffffffffffff811115613cf5575f5ffd5b613d018e828f01613c0a565b90965094505060a08c013567ffffffffffffffff811115613d20575f5ffd5b613d2c8e828f01613c0a565b9094509250613d4090508d60c08e01613aff565b90509295989b509295989b9093969950565b5f8151808452602084019350602083015f5b82811015613d82578151865260209586019590910190600101613d64565b5093949350505050565b602081525f6124db6020830184613d52565b5f5f5f5f5f5f5f5f5f5f60e08b8d031215613db7575f5ffd5b613dc08b613af4565b995060208b013567ffffffffffffffff811115613ddb575f5ffd5b613de78d828e01613c0a565b909a5098505060408b013567ffffffffffffffff811115613e06575f5ffd5b613e128d828e01613c0a565b90985096505060608b013567ffffffffffffffff811115613e31575f5ffd5b613e3d8d828e01613c0a565b90965094505060808b013567ffffffffffffffff811115613e5c575f5ffd5b613e688d828e01613c0a565b9094509250613e7c90508c60a08d01613aff565b90509295989b9194979a5092959850565b602080825282518282018190525f918401906040840190835b81811015613ec4578351835260209384019390920191600101613ea6565b509095945050505050565b5f5f5f5f5f5f60c08789031215613ee4575f5ffd5b8635613eef81613ae0565b95506020870135613eff81613ae0565b94506040870135613f0f81613ae0565b959894975094956060810135955060808101359460a0909101359350915050565b5f60808284031215613b0f575f5ffd5b5f5f60a08385031215613f51575f5ffd5b613f5b8484613f30565b91506080830135613bd581613ae0565b5f60808284031215613f7b575f5ffd5b6124db8383613f30565b5f5f5f5f5f5f60a08789031215613f9a575f5ffd5b8635613fa581613ae0565b9550602087013567ffffffffffffffff811115613fc0575f5ffd5b613fcc89828a01613c0a565b909650945050604087013567ffffffffffffffff811115613feb575f5ffd5b613ff789828a01613c0a565b909450925061400b90508860608901613aff565b90509295509295509295565b5f5f5f5f5f5f5f5f60c0898b03121561402e575f5ffd5b883561403981613ae0565b9750602089013567ffffffffffffffff811115614054575f5ffd5b6140608b828c01613c0a565b909850965050604089013567ffffffffffffffff81111561407f575f5ffd5b61408b8b828c01613c0a565b909650945050606089013567ffffffffffffffff8111156140aa575f5ffd5b6140b68b828c01613c0a565b90945092506140ca90508a60808b01613aff565b90509295985092959890939650565b5f5f604083850312156140ea575f5ffd5b82356140f581613ae0565b91506020830135613bd581613ae0565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b81810381811115610ade57610ade614105565b5f60208284031215614155575f5ffd5b5051919050565b8183525f7f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561418c575f5ffd5b8260051b80836020870137939093016020019392505050565b6001600160a01b038916815260a060208201525f6141c760a08301898b61415c565b82810360408401526141da81888a61415c565b905082810360608401526141ee8187613d52565b9050828103608084015261144581858761415c565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561425957614259614203565b604052919050565b5f67ffffffffffffffff82111561427a5761427a614203565b5060051b60200190565b5f60208284031215614294575f5ffd5b815167ffffffffffffffff8111156142aa575f5ffd5b8201601f810184136142ba575f5ffd5b80516142cd6142c882614261565b614230565b8082825260208201915060208360051b8501019250868311156142ee575f5ffd5b6020840193505b828410156120295783518252602093840193909101906142f5565b82518152602080840151818301526040808501518184015260608086015181850152843560808501529184013560a084015283013560c083015282013560e082015261010081016124db565b81835281816020850137505f602082840101525f6020601f19601f840116840101905092915050565b5f8383855260208501945060208460051b820101835f5b8681101561443057601f198484030188525f5f83357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18936030181126143e0575f5ffd5b880160208101925035905067ffffffffffffffff8111156143ff575f5ffd5b80360382131561440d575f5ffd5b61441885828461435c565b60209a8b019a9095509390930192505060010161439c565b50909695505050505050565b6001600160a01b0385168152606060208201525f61445e606083018587614385565b8281036040840152610dae8185613d52565b6001600160a01b0387168152608060208201525f614492608083018789614385565b82810360408401526144a48187613d52565b905082810360608401528084825260208201905060208560051b830101865f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1893603015b8882101561455a57601f198685030185528235818112614507575f5ffd5b8a0160208101903567ffffffffffffffff811115614523575f5ffd5b8060051b3603821315614534575f5ffd5b61453f868284614385565b955050506020830192506020850194506001820191506144e9565b50919c9b505050505050505050505050565b5f6020828403121561457c575f5ffd5b815180151581146124db575f5ffd5b8082028115828204841417610ade57610ade614105565b5f826145d5577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b500490565b80820180821115610ade57610ade614105565b6001600160a01b038916815260a060208201525f61460f60a08301898b61415c565b828103604084015261462281888a61415c565b9050828103606084015261463781868861415c565b905082810360808401526114458185613d52565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffdfea164736f6c634300081d000a'; diff --git a/packages/periphery/src/contracts/TrustSwapAndBridgeRouter-abi.ts b/packages/periphery/src/contracts/TrustSwapAndBridgeRouter-abi.ts index 20bf30f..c4eba43 100644 --- a/packages/periphery/src/contracts/TrustSwapAndBridgeRouter-abi.ts +++ b/packages/periphery/src/contracts/TrustSwapAndBridgeRouter-abi.ts @@ -1,391 +1,498 @@ export const TrustSwapAndBridgeRouterAbi = [ - { inputs: [], stateMutability: 'nonpayable', type: 'constructor' }, - { inputs: [], name: 'InvalidInitialization', type: 'error' }, - { inputs: [], name: 'NotInitializing', type: 'error' }, { - inputs: [{ internalType: 'address', name: 'owner', type: 'address' }], - name: 'OwnableInvalidOwner', - type: 'error', - }, - { - inputs: [{ internalType: 'address', name: 'account', type: 'address' }], - name: 'OwnableUnauthorizedAccount', - type: 'error', - }, - { inputs: [], name: 'ReentrancyGuardReentrantCall', type: 'error' }, - { - inputs: [{ internalType: 'address', name: 'token', type: 'address' }], - name: 'SafeERC20FailedOperation', - type: 'error', + type: 'receive', + stateMutability: 'payable', }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_AmountInZero', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_InsufficientBridgeFee', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_InsufficientETH', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_InvalidAddress', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_InvalidBridgeGasLimit', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_InvalidPath', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_InvalidRecipient', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_InvalidRecipientDomain', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_InvalidToken', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_PathDoesNotEndWithTRUST', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_PathDoesNotStartWithToken', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_PathDoesNotStartWithWETH', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_PoolDoesNotExist', type: 'error' }, - { inputs: [], name: 'TrustSwapAndBridgeRouter_TokenMismatch', type: 'error' }, { - anonymous: false, - inputs: [ - { indexed: false, internalType: 'uint256', name: 'newBridgeGasLimit', type: 'uint256' }, + type: 'function', + name: 'TRUST_ADDRESS', + inputs: [], + outputs: [ + { + name: '', + type: 'address', + internalType: 'address', + }, ], - name: 'BridgeGasLimitSet', - type: 'event', + stateMutability: 'view', }, { - anonymous: false, - inputs: [ + type: 'function', + name: 'WETH_ADDRESS', + inputs: [], + outputs: [ { - indexed: false, - internalType: 'enum FinalityState', - name: 'newFinalityState', - type: 'uint8', + name: '', + type: 'address', + internalType: 'address', }, ], - name: 'FinalityStateSet', - type: 'event', - }, - { - anonymous: false, - inputs: [{ indexed: false, internalType: 'uint64', name: 'version', type: 'uint64' }], - name: 'Initialized', - type: 'event', - }, - { - anonymous: false, - inputs: [{ indexed: true, internalType: 'address', name: 'newMetaERC20Hub', type: 'address' }], - name: 'MetaERC20HubSet', - type: 'event', + stateMutability: 'view', }, { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' }, - { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' }, + type: 'function', + name: 'bridgeGasLimit', + inputs: [], + outputs: [ + { + name: '', + type: 'uint256', + internalType: 'uint256', + }, ], - name: 'OwnershipTransferStarted', - type: 'event', + stateMutability: 'view', }, { - anonymous: false, + type: 'function', + name: 'bridgeTrust', inputs: [ - { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' }, - { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' }, + { + name: 'trustAmount', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'recipient', + type: 'address', + internalType: 'address', + }, ], - name: 'OwnershipTransferred', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: false, internalType: 'uint32', name: 'newRecipientDomain', type: 'uint32' }, + outputs: [ + { + name: 'transferId', + type: 'bytes32', + internalType: 'bytes32', + }, ], - name: 'RecipientDomainSet', - type: 'event', + stateMutability: 'payable', }, { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'newSlipstreamFactory', type: 'address' }, + type: 'function', + name: 'finalityState', + inputs: [], + outputs: [ + { + name: '', + type: 'uint8', + internalType: 'enum FinalityState', + }, ], - name: 'SlipstreamFactorySet', - type: 'event', + stateMutability: 'view', }, { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'newSlipstreamQuoter', type: 'address' }, + type: 'function', + name: 'metaERC20Hub', + inputs: [], + outputs: [ + { + name: '', + type: 'address', + internalType: 'contract IMetaERC20Hub', + }, ], - name: 'SlipstreamQuoterSet', - type: 'event', + stateMutability: 'view', }, { - anonymous: false, + type: 'function', + name: 'quoteBridgeFee', inputs: [ - { indexed: true, internalType: 'address', name: 'newSlipstreamSwapRouter', type: 'address' }, + { + name: 'trustAmount', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'recipient', + type: 'address', + internalType: 'address', + }, ], - name: 'SlipstreamSwapRouterSet', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'user', type: 'address' }, - { indexed: true, internalType: 'address', name: 'tokenIn', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'amountIn', type: 'uint256' }, - { indexed: false, internalType: 'uint256', name: 'trustOut', type: 'uint256' }, - { indexed: false, internalType: 'bytes32', name: 'recipientAddress', type: 'bytes32' }, - { indexed: false, internalType: 'bytes32', name: 'transferId', type: 'bytes32' }, + outputs: [ + { + name: 'bridgeFee', + type: 'uint256', + internalType: 'uint256', + }, ], - name: 'SwappedAndBridgedFromERC20', - type: 'event', + stateMutability: 'view', }, { - anonymous: false, + type: 'function', + name: 'quoteExactInput', inputs: [ - { indexed: true, internalType: 'address', name: 'user', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'ethSwapped', type: 'uint256' }, - { indexed: false, internalType: 'uint256', name: 'trustOut', type: 'uint256' }, - { indexed: false, internalType: 'bytes32', name: 'recipientAddress', type: 'bytes32' }, - { indexed: false, internalType: 'bytes32', name: 'transferId', type: 'bytes32' }, + { + name: 'path', + type: 'bytes', + internalType: 'bytes', + }, + { + name: 'amountIn', + type: 'uint256', + internalType: 'uint256', + }, ], - name: 'SwappedAndBridgedFromETH', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: 'address', name: 'user', type: 'address' }, - { indexed: false, internalType: 'uint256', name: 'trustAmount', type: 'uint256' }, - { indexed: false, internalType: 'bytes32', name: 'recipientAddress', type: 'bytes32' }, - { indexed: false, internalType: 'bytes32', name: 'transferId', type: 'bytes32' }, + outputs: [ + { + name: 'amountOut', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'success', + type: 'bool', + internalType: 'bool', + }, ], - name: 'TrustBridged', - type: 'event', + stateMutability: 'nonpayable', }, { + type: 'function', + name: 'recipientDomain', inputs: [], - name: 'TRUST_ADDRESS', - outputs: [{ internalType: 'address', name: '', type: 'address' }], + outputs: [ + { + name: '', + type: 'uint32', + internalType: 'uint32', + }, + ], stateMutability: 'view', - type: 'function', }, { + type: 'function', + name: 'slipstreamFactory', inputs: [], - name: 'WETH_ADDRESS', - outputs: [{ internalType: 'address', name: '', type: 'address' }], + outputs: [ + { + name: '', + type: 'address', + internalType: 'contract ICLFactory', + }, + ], stateMutability: 'view', - type: 'function', }, { - inputs: [], - name: 'acceptOwnership', - outputs: [], - stateMutability: 'nonpayable', type: 'function', + name: 'slipstreamQuoter', + inputs: [], + outputs: [ + { + name: '', + type: 'address', + internalType: 'address', + }, + ], + stateMutability: 'view', }, { + type: 'function', + name: 'slipstreamSwapRouter', inputs: [], - name: 'bridgeGasLimit', - outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + outputs: [ + { + name: '', + type: 'address', + internalType: 'address', + }, + ], stateMutability: 'view', - type: 'function', }, { + type: 'function', + name: 'swapAndBridgeWithERC20', inputs: [ - { internalType: 'uint256', name: 'trustAmount', type: 'uint256' }, - { internalType: 'address', name: 'recipient', type: 'address' }, + { + name: 'tokenIn', + type: 'address', + internalType: 'address', + }, + { + name: 'amountIn', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'path', + type: 'bytes', + internalType: 'bytes', + }, + { + name: 'minTrustOut', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'recipient', + type: 'address', + internalType: 'address', + }, + { + name: 'deadline', + type: 'uint256', + internalType: 'uint256', + }, + ], + outputs: [ + { + name: 'amountOut', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'transferId', + type: 'bytes32', + internalType: 'bytes32', + }, ], - name: 'bridgeTrust', - outputs: [{ internalType: 'bytes32', name: 'transferId', type: 'bytes32' }], stateMutability: 'payable', - type: 'function', }, { - inputs: [], - name: 'finalityState', - outputs: [{ internalType: 'enum FinalityState', name: '', type: 'uint8' }], - stateMutability: 'view', type: 'function', - }, - { + name: 'swapAndBridgeWithETH', inputs: [ - { internalType: 'address', name: '_owner', type: 'address' }, - { - components: [ - { internalType: 'address', name: 'slipstreamSwapRouter', type: 'address' }, - { internalType: 'address', name: 'slipstreamFactory', type: 'address' }, - { internalType: 'address', name: 'slipstreamQuoter', type: 'address' }, - { internalType: 'address', name: 'metaERC20Hub', type: 'address' }, - { internalType: 'uint32', name: 'recipientDomain', type: 'uint32' }, - { internalType: 'uint256', name: 'bridgeGasLimit', type: 'uint256' }, - { internalType: 'enum FinalityState', name: 'finalityState', type: 'uint8' }, - ], - internalType: 'struct RouterConfig', - name: 'config', - type: 'tuple', + { + name: 'path', + type: 'bytes', + internalType: 'bytes', + }, + { + name: 'minTrustOut', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'recipient', + type: 'address', + internalType: 'address', + }, + { + name: 'deadline', + type: 'uint256', + internalType: 'uint256', }, ], - name: 'initialize', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + outputs: [ + { + name: 'amountOut', + type: 'uint256', + internalType: 'uint256', + }, + { + name: 'transferId', + type: 'bytes32', + internalType: 'bytes32', + }, + ], + stateMutability: 'payable', }, { - inputs: [], - name: 'metaERC20Hub', - outputs: [{ internalType: 'contract IMetaERC20Hub', name: '', type: 'address' }], - stateMutability: 'view', type: 'function', - }, - { + name: 'trustToken', inputs: [], - name: 'owner', - outputs: [{ internalType: 'address', name: '', type: 'address' }], + outputs: [ + { + name: '', + type: 'address', + internalType: 'contract IERC20', + }, + ], stateMutability: 'view', - type: 'function', }, { - inputs: [], - name: 'pendingOwner', - outputs: [{ internalType: 'address', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', + type: 'event', + name: 'SwappedAndBridgedFromERC20', + inputs: [ + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'tokenIn', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'amountIn', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'trustOut', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'recipientAddress', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, + { + name: 'transferId', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, + ], + anonymous: false, }, { + type: 'event', + name: 'SwappedAndBridgedFromETH', inputs: [ - { internalType: 'uint256', name: 'trustAmount', type: 'uint256' }, - { internalType: 'address', name: 'recipient', type: 'address' }, + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'ethSwapped', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'trustOut', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'recipientAddress', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, + { + name: 'transferId', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, ], - name: 'quoteBridgeFee', - outputs: [{ internalType: 'uint256', name: 'bridgeFee', type: 'uint256' }], - stateMutability: 'view', - type: 'function', + anonymous: false, }, { + type: 'event', + name: 'TrustBridged', inputs: [ - { internalType: 'bytes', name: 'path', type: 'bytes' }, - { internalType: 'uint256', name: 'amountIn', type: 'uint256' }, + { + name: 'user', + type: 'address', + indexed: true, + internalType: 'address', + }, + { + name: 'trustAmount', + type: 'uint256', + indexed: false, + internalType: 'uint256', + }, + { + name: 'recipientAddress', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, + { + name: 'transferId', + type: 'bytes32', + indexed: false, + internalType: 'bytes32', + }, ], - name: 'quoteExactInput', - outputs: [{ internalType: 'uint256', name: 'amountOut', type: 'uint256' }], - stateMutability: 'nonpayable', - type: 'function', + anonymous: false, }, { + type: 'error', + name: 'ReentrancyGuardReentrantCall', inputs: [], - name: 'recipientDomain', - outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], - stateMutability: 'view', - type: 'function', }, { - inputs: [], - name: 'renounceOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + type: 'error', + name: 'SafeERC20FailedOperation', + inputs: [ + { + name: 'token', + type: 'address', + internalType: 'address', + }, + ], }, { - inputs: [{ internalType: 'uint256', name: 'newBridgeGasLimit', type: 'uint256' }], - name: 'setBridgeGasLimit', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_AmountInZero', + inputs: [], }, { - inputs: [{ internalType: 'enum FinalityState', name: 'newFinalityState', type: 'uint8' }], - name: 'setFinalityState', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_DeadlineExpired', + inputs: [], }, { - inputs: [{ internalType: 'address', name: 'newMetaERC20Hub', type: 'address' }], - name: 'setMetaERC20Hub', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_ETHRefundFailed', + inputs: [], }, { - inputs: [{ internalType: 'uint32', name: 'newRecipientDomain', type: 'uint32' }], - name: 'setRecipientDomain', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_InsufficientBridgeFee', + inputs: [], }, { - inputs: [{ internalType: 'address', name: 'newSlipstreamFactory', type: 'address' }], - name: 'setSlipstreamFactory', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_InsufficientETH', + inputs: [], }, { - inputs: [{ internalType: 'address', name: 'newSlipstreamQuoter', type: 'address' }], - name: 'setSlipstreamQuoter', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_InvalidAddress', + inputs: [], }, { - inputs: [{ internalType: 'address', name: 'newSlipstreamSwapRouter', type: 'address' }], - name: 'setSlipstreamSwapRouter', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_InvalidPath', + inputs: [], }, { + type: 'error', + name: 'TrustSwapAndBridgeRouter_InvalidRecipient', inputs: [], - name: 'slipstreamFactory', - outputs: [{ internalType: 'contract ICLFactory', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', }, { + type: 'error', + name: 'TrustSwapAndBridgeRouter_InvalidToken', inputs: [], - name: 'slipstreamQuoter', - outputs: [{ internalType: 'address', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', }, { + type: 'error', + name: 'TrustSwapAndBridgeRouter_MinTrustOutZero', inputs: [], - name: 'slipstreamSwapRouter', - outputs: [{ internalType: 'address', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', }, { - inputs: [ - { internalType: 'address', name: 'tokenIn', type: 'address' }, - { internalType: 'uint256', name: 'amountIn', type: 'uint256' }, - { internalType: 'bytes', name: 'path', type: 'bytes' }, - { internalType: 'uint256', name: 'minTrustOut', type: 'uint256' }, - { internalType: 'address', name: 'recipient', type: 'address' }, - ], - name: 'swapAndBridgeWithERC20', - outputs: [ - { internalType: 'uint256', name: 'amountOut', type: 'uint256' }, - { internalType: 'bytes32', name: 'transferId', type: 'bytes32' }, - ], - stateMutability: 'payable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_PathDoesNotEndWithTRUST', + inputs: [], }, { - inputs: [ - { internalType: 'bytes', name: 'path', type: 'bytes' }, - { internalType: 'uint256', name: 'minTrustOut', type: 'uint256' }, - { internalType: 'address', name: 'recipient', type: 'address' }, - ], - name: 'swapAndBridgeWithETH', - outputs: [ - { internalType: 'uint256', name: 'amountOut', type: 'uint256' }, - { internalType: 'bytes32', name: 'transferId', type: 'bytes32' }, - ], - stateMutability: 'payable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_PathDoesNotStartWithToken', + inputs: [], }, { - inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], - name: 'transferOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + type: 'error', + name: 'TrustSwapAndBridgeRouter_PathDoesNotStartWithWETH', + inputs: [], }, { + type: 'error', + name: 'TrustSwapAndBridgeRouter_PoolDoesNotExist', inputs: [], - name: 'trustToken', - outputs: [{ internalType: 'contract IERC20', name: '', type: 'address' }], - stateMutability: 'view', - type: 'function', }, ] as const; diff --git a/packages/periphery/src/contracts/TrustSwapAndBridgeRouter-bytecode.ts b/packages/periphery/src/contracts/TrustSwapAndBridgeRouter-bytecode.ts index f6ccaca..0a29d11 100644 --- a/packages/periphery/src/contracts/TrustSwapAndBridgeRouter-bytecode.ts +++ b/packages/periphery/src/contracts/TrustSwapAndBridgeRouter-bytecode.ts @@ -1,4 +1,4 @@ import type { Hex } from 'viem'; export const TrustSwapAndBridgeRouterBytecode: Hex = - '0x6080604052348015600e575f5ffd5b5060156019565b60c9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161560685760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b039081161460c65780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b61271b806100d65f395ff3fe6080604052600436106101a3575f3560e01c806378fa9a92116100e7578063cfca447411610087578063ef4bae7d11610062578063ef4bae7d14610491578063f2fde38b146104a4578063f9f3e184146104c3578063fbd8bd2f146104e2575f5ffd5b8063cfca44741461045e578063d13deb2f14610209578063e30c39781461047d575f5ffd5b806391b2777b116100c257806391b2777b146103d7578063bd40e522146103fd578063c5500cc31461042a578063cdca17531461043f575f5ffd5b806378fa9a921461036657806379ba5097146103af5780638da5cb5b146103c3575f5ffd5b80632e0f8d71116101525780635a3772f31161012d5780635a3772f3146102f55780635ad0e4e0146103145780636752cbe214610333578063715018a614610352575f5ffd5b80632e0f8d711461029657806349cce680146102b55780635602d49b146102d6575f5ffd5b806324bb307e1161018257806324bb307e14610230578063287a3f7a1461024f578063291f8a9614610277575f5ffd5b8062e69b69146101a7578063040141e5146101e25780630706848714610209575b5f5ffd5b3480156101b2575f5ffd5b505f546101c5906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101ed575f5ffd5b506101c573420000000000000000000000000000000000000681565b348015610214575f5ffd5b506101c5736cd905df2ed214b22e0d48ff17cd4200c1c6d8a381565b34801561023b575f5ffd5b506003546101c5906001600160a01b031681565b61026261025d3660046120a5565b610501565b604080519283526020830191909152016101d9565b348015610282575f5ffd5b506002546101c5906001600160a01b031681565b3480156102a1575f5ffd5b506001546101c5906001600160a01b031681565b3480156102c0575f5ffd5b506102d46102cf366004612100565b6108d4565b005b3480156102e1575f5ffd5b506102d46102f0366004612117565b6108e8565b348015610300575f5ffd5b506102d461030f366004612132565b6108f9565b34801561031f575f5ffd5b506102d461032e3660046121a0565b610b05565b34801561033e575f5ffd5b506102d461034d366004612117565b610b16565b34801561035d575f5ffd5b506102d4610b27565b348015610371575f5ffd5b5060035461039a9074010000000000000000000000000000000000000000900463ffffffff1681565b60405163ffffffff90911681526020016101d9565b3480156103ba575f5ffd5b506102d4610b3a565b3480156103ce575f5ffd5b506101c5610b9d565b3480156103e2575f5ffd5b506005546103f09060ff1681565b6040516101d99190612221565b348015610408575f5ffd5b5061041c61041736600461222f565b610bd1565b6040519081526020016101d9565b348015610435575f5ffd5b5061041c60045481565b34801561044a575f5ffd5b5061041c61045936600461225d565b610c8d565b348015610469575f5ffd5b506102d4610478366004612117565b610d92565b348015610488575f5ffd5b506101c5610da3565b61026261049f3660046122a5565b610dcb565b3480156104af575f5ffd5b506102d46104be366004612117565b6111e9565b3480156104ce575f5ffd5b506102d46104dd36600461231c565b611286565b3480156104ed575f5ffd5b506102d46104fc366004612117565b611297565b5f5f61050b6112a8565b73420000000000000000000000000000000000000661052a8787611329565b6001600160a01b03161461056a576040517f6ce1e46f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b736cd905df2ed214b22e0d48ff17cd4200c1c6d8a3610589878761136e565b6001600160a01b0316146105c9576040517f524d576500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6105d386866113d5565b6003546040517f8bd90b8200000000000000000000000000000000000000000000000000000000815274010000000000000000000000000000000000000000820463ffffffff1660048201526001600160a01b038581166024830181905260448301889052925f92911690638bd90b8290606401602060405180830381865afa158015610662573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610686919061233a565b90508034116106c1576040517f18f0046700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106cc823461237e565b90507342000000000000000000000000000000000000066001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004015f604051808303818588803b15801561071b575f5ffd5b505af115801561072d573d5f5f3e3d5ffd5b50505f5461075e935073420000000000000000000000000000000000000692506001600160a01b031690508361159a565b5f546040805160c06020601f8d01819004028201810190925260a081018b81526001600160a01b039093169263c04b8d59928291908e908e90819085018382808284375f92019190915250505090825250306020820152426040808301919091526060820186905260809091018b9052517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526108059190600401612391565b6020604051808303815f875af1158015610821573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610845919061233a565b9450610852858484611640565b60408051838152602081018890529081018590526060810182905290945033907f6c557e28f2f88581e47787541f2976de63ab38e05793c620a88a62140155b2a49060800160405180910390a25050506108cb60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b94509492505050565b6108dc61174c565b6108e581611797565b50565b6108f061174c565b6108e58161180c565b5f6109026118ad565b805490915060ff68010000000000000000820416159067ffffffffffffffff165f8115801561092e5750825b90505f8267ffffffffffffffff16600114801561094a5750303b155b905081158015610958575080155b1561098f576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016600117855583156109f05784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b6109f9876118d7565b610a016118e8565b610a16610a116020880188612117565b6118f8565b610a2e610a296040880160208901612117565b611997565b610a46610a416060880160408901612117565b61180c565b610a5e610a596080880160608901612117565b611a38565b610a76610a7160a08801608089016121a0565b611ad9565b610a838660a00135611797565b610a9b610a9660e0880160c0890161231c565b611b95565b8315610afc5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b610b0d61174c565b6108e581611ad9565b610b1e61174c565b6108e581611a38565b610b2f61174c565b610b385f611c06565b565b3380610b44610da3565b6001600160a01b031614610b94576040517f118cdaa70000000000000000000000000000000000000000000000000000000081526001600160a01b03821660048201526024015b60405180910390fd5b6108e581611c06565b5f807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b6003546040517f8bd90b8200000000000000000000000000000000000000000000000000000000815274010000000000000000000000000000000000000000820463ffffffff1660048201526001600160a01b0383811660248301819052604483018690525f939092911690638bd90b8290606401602060405180830381865afa158015610c61573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c85919061233a565b949350505050565b6002545f906001600160a01b0316610cd1576040517f78f605da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002546040517fcdca17530000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063cdca175390610d1e9087908790879060040161241f565b5f604051808303815f875af1925050508015610d7957506040513d5f823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610d769190810190612586565b60015b610d8457505f610d8b565b5091925050505b9392505050565b610d9a61174c565b6108e5816118f8565b5f807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00610bc1565b5f5f610dd56112a8565b865f03610e0e576040517fbb21c91300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0388161580610e4057506001600160a01b038816736cd905df2ed214b22e0d48ff17cd4200c1c6d8a3145b15610e77576040517f8fb1c50400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b876001600160a01b0316610e8b8787611329565b6001600160a01b031614610ecb576040517f65d5c92700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b736cd905df2ed214b22e0d48ff17cd4200c1c6d8a3610eea878761136e565b6001600160a01b031614610f2a576040517f524d576500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610f3486866113d5565b610f496001600160a01b03891633308a611c5a565b6003546040517f8bd90b8200000000000000000000000000000000000000000000000000000000815274010000000000000000000000000000000000000000820463ffffffff1660048201526001600160a01b038581166024830181905260448301889052925f92911690638bd90b8290606401602060405180830381865afa158015610fd8573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ffc919061233a565b905080341015611038576040517f0f60762900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f54611051906001600160a01b038c811691168b61159a565b5f546040805160c06020601f8c01819004028201810190925260a081018a81526001600160a01b039093169263c04b8d59928291908d908d90819085018382808284375f9201919091525050509082525030602082015242604080830191909152606082018e905260809091018a9052517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526110f89190600401612391565b6020604051808303815f875af1158015611114573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611138919061233a565b9350611145848383611640565b92505f611152823461237e565b905061115d81611cd6565b604080518b815260208101879052908101849052606081018590526001600160a01b038c169033907ff8864313f96e3bb1cc54a6c83cadf04e6695a7321efcb05d73872c557e4a60da9060800160405180910390a35050506111de60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b965096945050505050565b6111f161174c565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117825561124d610b9d565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b61128e61174c565b6108e581611b95565b61129f61174c565b6108e581611997565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01611323576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b5f602b821015611365576040517f244f6e8700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50503560601c90565b5f602b8210156113aa576040517f244f6e8700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec013560601c90565b602b811015611410576040517f244f6e8700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601761141d60148361237e565b611427919061268b565b1561145e576040517f244f6e8700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f601761146c60148461237e565b611476919061269e565b90505f805b82811015611593576001546040517f28af8d0b0000000000000000000000000000000000000000000000000000000081528387018035606090811c60048401819052601783013590911c6024840181905260149092013560e81d600281900b6044850152909390925f916001600160a01b0316906328af8d0b90606401602060405180830381865afa158015611513573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061153791906126b1565b6001600160a01b031603611577576040517f2f040fc300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115826017866126cc565b9450506001909201915061147b9050565b5050505050565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301525f919085169063dd62ed3e90604401602060405180830381865afa158015611600573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611624919061233a565b905061163a848461163585856126cc565b611d8b565b50505050565b6003545f9061166e90736cd905df2ed214b22e0d48ff17cd4200c1c6d8a3906001600160a01b03168661159a565b600354600480546005546040517f10a7265c0000000000000000000000000000000000000000000000000000000081526001600160a01b038516946310a7265c9488946116e5947401000000000000000000000000000000000000000090930463ffffffff16938b938d9360ff90911691016126df565b60206040518083038185885af1158015611701573d5f5f3e3d5ffd5b50505050506040513d601f19601f82011682018060405250810190610c85919061233a565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b33611755610b9d565b6001600160a01b031614610b38576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610b8b565b805f036117d0576040517f5f0140db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60048190556040518181527f825187707ba146d812dbda9e3ac6b8f2c878d3997af0f214d42bb7d68735e26c906020015b60405180910390a150565b6001600160a01b03811661184c576040517f78f605da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f9e45298aba860006d5687a978f080edd0ef10e1fe9606c52b1bd798f30848aca905f90a250565b5f807ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005b92915050565b6118df611e48565b6108e581611e86565b6118f0611e48565b610b38611ed0565b6001600160a01b038116611938576040517f78f605da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117825560405190917fb48937b89356a440b6c96c733e6fef581395e62d0bb1061897a74772104fb26291a250565b6001600160a01b0381166119d7576040517f78f605da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517fe69da881cbfe27263ea953edd2d2b781158e374e0dd13cecd00a406665439b6e905f90a250565b6001600160a01b038116611a78576040517f78f605da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f49b2c8b215c8bdcb989f1f9a0cbc8190688fdb4107c88663f66471d591444ddd905f90a250565b8063ffffffff165f03611b18576040517ffa6ef1b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600380547fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000063ffffffff8416908102919091179091556040519081527f6f0cc866158986e208ae3e8d65a003144d0dfe66ab7070b7f146f90600f620a190602001611801565b600580548291907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001836002811115611bd257611bd26121bb565b02179055507f7abfa5ecca95a3a190ae769c017f60088ee0f9f7d7c9e9f28bff754ac05146a5816040516118019190612221565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155611c5682611ed8565b5050565b6040516001600160a01b03848116602483015283811660448301526064820183905261163a9186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611f60565b80156108e5576040515f90339083908381818185875af1925050503d805f8114611d1b576040519150601f19603f3d011682016040523d82523d5f602084013e611d20565b606091505b5050905080611c56576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f45544820726566756e64206661696c65640000000000000000000000000000006044820152606401610b8b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052611e0a8482611fe5565b61163a576040516001600160a01b0384811660248301525f6044830152611e3e91869182169063095ea7b390606401611c8f565b61163a8482611f60565b611e5061202e565b610b38576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611e8e611e48565b6001600160a01b038116610b94576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081525f6004820152602401610b8b565b611726611e48565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080547fffffffffffffffffffffffff000000000000000000000000000000000000000081166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b5f5f60205f8451602086015f885af180611f7f576040513d5f823e3d81fd5b50505f513d91508115611f96578060011415611fa3565b6001600160a01b0384163b155b1561163a576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610b8b565b5f5f5f5f60205f8651602088015f8a5af192503d91505f519050828015612024575081156120165780600114612024565b5f866001600160a01b03163b115b9695505050505050565b5f6120376118ad565b5468010000000000000000900460ff16919050565b5f5f83601f84011261205c575f5ffd5b50813567ffffffffffffffff811115612073575f5ffd5b60208301915083602082850101111561208a575f5ffd5b9250929050565b6001600160a01b03811681146108e5575f5ffd5b5f5f5f5f606085870312156120b8575f5ffd5b843567ffffffffffffffff8111156120ce575f5ffd5b6120da8782880161204c565b9095509350506020850135915060408501356120f581612091565b939692955090935050565b5f60208284031215612110575f5ffd5b5035919050565b5f60208284031215612127575f5ffd5b8135610d8b81612091565b5f5f828403610100811215612145575f5ffd5b833561215081612091565b925060e07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082011215612181575f5ffd5b506020830190509250929050565b63ffffffff811681146108e5575f5ffd5b5f602082840312156121b0575f5ffd5b8135610d8b8161218f565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6003811061221d577f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b9052565b602081016118d182846121e8565b5f5f60408385031215612240575f5ffd5b82359150602083013561225281612091565b809150509250929050565b5f5f5f6040848603121561226f575f5ffd5b833567ffffffffffffffff811115612285575f5ffd5b6122918682870161204c565b909790965060209590950135949350505050565b5f5f5f5f5f5f60a087890312156122ba575f5ffd5b86356122c581612091565b955060208701359450604087013567ffffffffffffffff8111156122e7575f5ffd5b6122f389828a0161204c565b90955093505060608701359150608087013561230e81612091565b809150509295509295509295565b5f6020828403121561232c575f5ffd5b813560038110610d8b575f5ffd5b5f6020828403121561234a575f5ffd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b818103818111156118d1576118d1612351565b602081525f825160a0602084015280518060c0850152806020830160e086015e5f60e082860101526001600160a01b0360208601511660408501526040850151606085015260608501516080850152608085015160a085015260e07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b60408152826040820152828460608301375f606084830101525f60607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8601168301019050826020830152949350505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156124e8576124e8612474565b604052919050565b5f67ffffffffffffffff82111561250957612509612474565b5060051b60200190565b5f82601f830112612522575f5ffd5b8151612535612530826124f0565b6124a1565b8082825260208201915060208360051b860101925085831115612556575f5ffd5b602085015b8381101561257c57805161256e8161218f565b83526020928301920161255b565b5095945050505050565b5f5f5f5f60808587031215612599575f5ffd5b8451602086015190945067ffffffffffffffff8111156125b7575f5ffd5b8501601f810187136125c7575f5ffd5b80516125d5612530826124f0565b8082825260208201915060208360051b8501019250898311156125f6575f5ffd5b6020840193505b8284101561262157835161261081612091565b8252602093840193909101906125fd565b80965050505050604085015167ffffffffffffffff811115612641575f5ffd5b61264d87828801612513565b606096909601519497939650505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f826126995761269961265e565b500690565b5f826126ac576126ac61265e565b500490565b5f602082840312156126c1575f5ffd5b8151610d8b81612091565b808201808211156118d1576118d1612351565b5f60a08201905063ffffffff8716825285602083015284604083015283606083015261202460808301846121e856fea164736f6c634300081d000a'; + '0x6080604052348015600e575f5ffd5b5060015f55611def806100205f395ff3fe6080604052600436106100e6575f3560e01c80632e0f8d7111610087578063c5500cc311610057578063c5500cc3146102b7578063cdca1753146102cd578063d13deb2f1461018a578063fef6981a14610301575f5ffd5b80632e0f8d711461022757806378fa9a921461024e57806391b2777b14610278578063bd40e52214610298575f5ffd5b806307068487116100c2578063070684871461018a57806320da841e146101b157806324bb307e146101d9578063291f8a9614610200575f5ffd5b8062e69b69146100f1578063040141e51461014257806305cc32ce14610169575f5ffd5b366100ed57005b5f5ffd5b3480156100fc575f5ffd5b5061011873cbbb8035cac7d4b3ca7abb74cf7bdf900215ce0d81565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561014d575f5ffd5b5061011873420000000000000000000000000000000000000681565b61017c61017736600461180c565b610314565b604051908152602001610139565b348015610195575f5ffd5b50610118736cd905df2ed214b22e0d48ff17cd4200c1c6d8a381565b6101c46101bf36600461187f565b61052e565b60408051928352602083019190915201610139565b3480156101e4575f5ffd5b5061011873e12aaf1529ae21899029a9b51cca2f2bc2cfc42181565b34801561020b575f5ffd5b50610118733d4c22254f86f64b7ec90ab8f7aec1fbfd271c6c81565b348015610232575f5ffd5b5061011873ade65c38cd4849adba595a4323a8c7ddfe89716a81565b348015610259575f5ffd5b5061026361048381565b60405163ffffffff9091168152602001610139565b348015610283575f5ffd5b5061028b5f81565b604051610139919061191a565b3480156102a3575f5ffd5b5061017c6102b236600461180c565b6109f9565b3480156102c2575f5ffd5b5061017c620186a081565b3480156102d8575f5ffd5b506102ec6102e7366004611928565b610ab7565b60408051928352901515602083015201610139565b6101c461030f366004611970565b610b8b565b5f61031d6110d6565b825f03610356576040517fbb21c91300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82166103a3576040517fa2c5428900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff83166040517f8bd90b82000000000000000000000000000000000000000000000000000000008152610483600482015260248101829052604481018690529091505f9073e12aaf1529ae21899029a9b51cca2f2bc2cfc42190638bd90b8290606401602060405180830381865afa158015610436573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061045a91906119f2565b905080341015610496576040517f0f60762900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104b6736cd905df2ed214b22e0d48ff17cd4200c1c6d8a3333088611117565b6104c18583836111a6565b92505f6104ce8234611a36565b90506104d98161127a565b604080518781526020810185905290810185905233907f4bb8e3482255c12b120abdca0572cb126642e6e1834e34b942cf183c7bd2a0299060600160405180910390a250505061052860015f55565b92915050565b5f5f6105386110d6565b42831015610572576040517fd67cc3bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff84166105bf576040517fa2c5428900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845f036105f8576040517f89ee38cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73420000000000000000000000000000000000000661061888885f611304565b73ffffffffffffffffffffffffffffffffffffffff1614610665576040517f6ce1e46f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b736cd905df2ed214b22e0d48ff17cd4200c1c6d8a361069e8888601481101561068e575f611304565b61069960148b611a36565b611304565b73ffffffffffffffffffffffffffffffffffffffff16146106eb576040517f524d576500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6106f58787611392565b5f73ffffffffffffffffffffffffffffffffffffffff85166040517f8bd90b82000000000000000000000000000000000000000000000000000000008152610483600482015260248101829052604481018890529091505f9073e12aaf1529ae21899029a9b51cca2f2bc2cfc42190638bd90b8290606401602060405180830381865afa158015610788573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107ac91906119f2565b90508034116107e7576040517f18f0046700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6107f28234611a36565b905073420000000000000000000000000000000000000673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0826040518263ffffffff1660e01b81526004015f604051808303818588803b15801561084e575f5ffd5b505af1158015610860573d5f5f3e3d5ffd5b5061089c9350734200000000000000000000000000000000000006925073cbbb8035cac7d4b3ca7abb74cf7bdf900215ce0d915084905061156e565b6040805160c06020601f8d01819004028201810190925260a081018b815273cbbb8035cac7d4b3ca7abb74cf7bdf900215ce0d9263c04b8d59929182918f908f90819085018382808284375f9201919091525050509082525030602082015260408082018b90526060820186905260809091018c9052517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526109499190600401611a49565b6020604051808303815f875af1158015610965573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061098991906119f2565b94506109968584846111a6565b60408051838152602081018890529081018590526060810182905290945033907f6c557e28f2f88581e47787541f2976de63ab38e05793c620a88a62140155b2a49060800160405180910390a25050506109ef60015f55565b9550959350505050565b5f8073ffffffffffffffffffffffffffffffffffffffff83166040517f8bd90b820000000000000000000000000000000000000000000000000000000081526104836004820152602481018290526044810186905290915073e12aaf1529ae21899029a9b51cca2f2bc2cfc42190638bd90b8290606401602060405180830381865afa158015610a8b573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610aaf91906119f2565b949350505050565b6040517fcdca17530000000000000000000000000000000000000000000000000000000081525f908190733d4c22254f86f64b7ec90ab8f7aec1fbfd271c6c9063cdca175390610b0f90889088908890600401611ae4565b5f604051808303815f875af1925050508015610b6a57506040513d5f823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610b679190810190611c53565b60015b610b7857505f905080610b83565b509193506001925050505b935093915050565b5f5f610b956110d6565b42831015610bcf576040517fd67cc3bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b875f03610c08576040517fbb21c91300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8416610c55576040517fa2c5428900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845f03610c8e576040517f89ee38cb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff89161580610cda575073ffffffffffffffffffffffffffffffffffffffff8916736cd905df2ed214b22e0d48ff17cd4200c1c6d8a3145b15610d11576040517f8fb1c50400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8873ffffffffffffffffffffffffffffffffffffffff16610d3388885f611304565b73ffffffffffffffffffffffffffffffffffffffff1614610d80576040517f65d5c92700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b736cd905df2ed214b22e0d48ff17cd4200c1c6d8a3610da98888601481101561068e575f611304565b73ffffffffffffffffffffffffffffffffffffffff1614610df6576040517f524d576500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e008787611392565b610e2273ffffffffffffffffffffffffffffffffffffffff8a1633308b611117565b5f73ffffffffffffffffffffffffffffffffffffffff85166040517f8bd90b82000000000000000000000000000000000000000000000000000000008152610483600482015260248101829052604481018890529091505f9073e12aaf1529ae21899029a9b51cca2f2bc2cfc42190638bd90b8290606401602060405180830381865afa158015610eb5573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ed991906119f2565b905080341015610f15576040517f0f60762900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610f4a73ffffffffffffffffffffffffffffffffffffffff8c1673cbbb8035cac7d4b3ca7abb74cf7bdf900215ce0d8c61156e565b6040805160c06020601f8c01819004028201810190925260a081018a815273cbbb8035cac7d4b3ca7abb74cf7bdf900215ce0d9263c04b8d59929182918e908e90819085018382808284375f9201919091525050509082525030602082015260408082018a9052606082018f905260809091018b9052517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b168152610ff79190600401611a49565b6020604051808303815f875af1158015611013573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061103791906119f2565b93506110448483836111a6565b92505f6110518234611a36565b905061105c8161127a565b604080518c8152602081018790529081018490526060810185905273ffffffffffffffffffffffffffffffffffffffff8d169033907ff8864313f96e3bb1cc54a6c83cadf04e6695a7321efcb05d73872c557e4a60da9060800160405180910390a35050506110ca60015f55565b97509795505050505050565b60025f5403611111576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f55565b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526111a09186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061161b565b50505050565b5f6111da736cd905df2ed214b22e0d48ff17cd4200c1c6d8a373e12aaf1529ae21899029a9b51cca2f2bc2cfc4218661156e565b6040517f10a7265c00000000000000000000000000000000000000000000000000000000815273e12aaf1529ae21899029a9b51cca2f2bc2cfc421906310a7265c908490611239906104839088908a90620186a0905f90600401611d2b565b60206040518083038185885af1158015611255573d5f5f3e3d5ffd5b50505050506040513d601f19601f82011682018060405250810190610aaf91906119f2565b8015611301576040515f90339083908381818185875af1925050503d805f81146112bf576040519150601f19603f3d011682016040523d82523d5f602084013e6112c4565b606091505b50509050806112ff576040517fa2880b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b50565b5f602b831015611340576040517f244f6e8700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61134b601484611a36565b821115611384576040517f244f6e8700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50919091013560601c919050565b602b8110156113cd576040517f244f6e8700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60176113da601483611a36565b6113e49190611d87565b1561141b576040517f244f6e8700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6017611429601484611a36565b6114339190611d9a565b90505f805b82811015611567576040517f28af8d0b0000000000000000000000000000000000000000000000000000000081528286018035606090811c60048401819052601783013590911c6024840181905260149092013560e81d600281900b604485015290929091905f9073ade65c38cd4849adba595a4323a8c7ddfe89716a906328af8d0b90606401602060405180830381865afa1580156114da573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114fe9190611dad565b73ffffffffffffffffffffffffffffffffffffffff160361154b576040517f2f040fc300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611556601786611dcf565b945050600190920191506114389050565b5050505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301525f919085169063dd62ed3e90604401602060405180830381865afa1580156115e1573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061160591906119f2565b90506111a084846116168585611dcf565b6116be565b5f5f60205f8451602086015f885af18061163a576040513d5f823e3d81fd5b50505f513d9150811561165157806001141561166b565b73ffffffffffffffffffffffffffffffffffffffff84163b155b156111a0576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260240160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261174a8482611795565b6111a05760405173ffffffffffffffffffffffffffffffffffffffff84811660248301525f604483015261178b91869182169063095ea7b390606401611159565b6111a0848261161b565b5f5f5f5f60205f8651602088015f8a5af192503d91505f5190508280156117e1575081156117c657806001146117e1565b5f8673ffffffffffffffffffffffffffffffffffffffff163b115b9695505050505050565b73ffffffffffffffffffffffffffffffffffffffff81168114611301575f5ffd5b5f5f6040838503121561181d575f5ffd5b82359150602083013561182f816117eb565b809150509250929050565b5f5f83601f84011261184a575f5ffd5b50813567ffffffffffffffff811115611861575f5ffd5b602083019150836020828501011115611878575f5ffd5b9250929050565b5f5f5f5f5f60808688031215611893575f5ffd5b853567ffffffffffffffff8111156118a9575f5ffd5b6118b58882890161183a565b9096509450506020860135925060408601356118d0816117eb565b949793965091946060013592915050565b60038110611916577f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b9052565b6020810161052882846118e1565b5f5f5f6040848603121561193a575f5ffd5b833567ffffffffffffffff811115611950575f5ffd5b61195c8682870161183a565b909790965060209590950135949350505050565b5f5f5f5f5f5f5f60c0888a031215611986575f5ffd5b8735611991816117eb565b965060208801359550604088013567ffffffffffffffff8111156119b3575f5ffd5b6119bf8a828b0161183a565b9096509450506060880135925060808801356119da816117eb565b96999598509396929591949193505060a09091013590565b5f60208284031215611a02575f5ffd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b8181038181111561052857610528611a09565b602081525f825160a0602084015280518060c0850152806020830160e086015e5f60e0828601015273ffffffffffffffffffffffffffffffffffffffff60208601511660408501526040850151606085015260608501516080850152608085015160a085015260e07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b60408152826040820152828460608301375f606084830101525f60607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8601168301019050826020830152949350505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611bad57611bad611b39565b604052919050565b5f67ffffffffffffffff821115611bce57611bce611b39565b5060051b60200190565b5f82601f830112611be7575f5ffd5b8151611bfa611bf582611bb5565b611b66565b8082825260208201915060208360051b860101925085831115611c1b575f5ffd5b602085015b83811015611c4957805163ffffffff81168114611c3b575f5ffd5b835260209283019201611c20565b5095945050505050565b5f5f5f5f60808587031215611c66575f5ffd5b8451602086015190945067ffffffffffffffff811115611c84575f5ffd5b8501601f81018713611c94575f5ffd5b8051611ca2611bf582611bb5565b8082825260208201915060208360051b850101925089831115611cc3575f5ffd5b6020840193505b82841015611cee578351611cdd816117eb565b825260209384019390910190611cca565b80965050505050604085015167ffffffffffffffff811115611d0e575f5ffd5b611d1a87828801611bd8565b606096909601519497939650505050565b5f60a08201905063ffffffff871682528560208301528460408301528360608301526117e160808301846118e1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f82611d9557611d95611d5a565b500690565b5f82611da857611da8611d5a565b500490565b5f60208284031215611dbd575f5ffd5b8151611dc8816117eb565b9392505050565b8082018082111561052857610528611a0956fea164736f6c634300081d000a'; diff --git a/packages/periphery/src/contracts/added_context.txt b/packages/periphery/src/contracts/added_context.txt deleted file mode 100644 index b9dcebc..0000000 --- a/packages/periphery/src/contracts/added_context.txt +++ /dev/null @@ -1,62 +0,0 @@ -Here are a few things to expand your plan with. Here is an example of a successful call on the transfer remote method on one of these SPO contracts. It's also basically almost the same for hubs. - - -Decoded input data -Method id -81b4e8b4 -Call -transferRemote(uint32 _recipientDomain, bytes32 _recipientAddress, uint256 _amount) -Name -Type -Data -_recipientDomain -uint32 -8453 -_recipientAddress -bytes32 -0x000000000000000000000000b8e3452e62b45e654a300a296061597e3cf3e039 -_amount -uint256 -2000000000000000000 - - -One thing that you will notice is the fact that the recipient address is zero-padded to be in the bytes32 format. This was abstracted away in the trust swap and pre-drouter, but you need to do it manually for these. - - -recipient domains (chain ids): -Base: 8453 -Intuition Mainnet: 1155 - - - -Also, another important distinction is what the hub and spoke mean here. Hub is basically a locker that locks the token that we are bridging, let's say USDC from base. Spoke is the representation of this token on the other chain. - -The practical consequence of this is that, when bridging spokes (which are the presentations of these tokens on our network), you don't need an approval, actually. That is something to take into account. You don't need to approve the USDC MetaERC20 spoke to itself, and same goes for wrapped it. Also, obviously, for the MetaNative spoke (which is used for Trust and Intuition), you obviously don't need to approve the native token. That goes without saying. - - -RELEVANT ADDRESSES: - -Base mainnet (chain id: 8453) addresses: - -MetaERC20Hub (USDC) 0x7e41962bE9B2640e653BfA8c8713A905659FE157 -MetaERC20Hub (WETH) 0xFB4BAa05BF339AD6074047176F90757A6C87f944 -TRUST on Base (ERC20): 0x6cd905dF2Ed214b22e0d48FF17CD4200C1C6d8A3 -USDC on Base (ERC20): 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 -WETH on Base (ERC20): 0x4200000000000000000000000000000000000006 - -Intuition mainnet (chain id: 1155) addresses: - -MetaERC20Spoke (USDC) 0x7e41962bE9B2640e653BfA8c8713A905659FE157 -MetaERC20Spoke (WETH) 0xFB4BAa05BF339AD6074047176F90757A6C87f944 -MetaNativeSpoke (TRUST) 0x375135fe908dD62f3C7939FA4e65bf41Da721AB9 -WrappedTrust (WTRUST) 0x81cFb09cb44f7184Ad934C09F82000701A4bF672 - - -(I already added all relevant bytecodes and abis in the intuition/periphery/src/contracts folder) - -One other relevant bonus is to recognize WTRUST (Wrapped TRUST) token on the Intuition mainnet and offer to unwrap it before direct TRUST bridge from Intuition to Base (not that because TRUST is the native token on the Intuition network, there is still no need approve it after unwrapping if user wants to bridge this native TRUST token back to the Base mainnet) - -Slight UX bonus: don't let user wrap entire ETH balance on Base and entire TRUST balance on Intuition; let them keep at least 0.0005 ETH for gas and 1 TRUST for gas, respectively. Same goes for the ETH swaps on Base: cap it to max 0.0005 ETH left for gas etc. -NOTE: This applies EXCLUSIVELY for the native tokens on a given chain only! For ERC20 tokens, you're always free to do whateveramount you want up to your balance! - -Finally, for the best possible UX, make sure to include the easy <> type of button for swapping source/destination chains selectors etc. diff --git a/packages/periphery/src/contracts/index.ts b/packages/periphery/src/contracts/index.ts index c06193d..f91e689 100644 --- a/packages/periphery/src/contracts/index.ts +++ b/packages/periphery/src/contracts/index.ts @@ -1,3 +1,5 @@ +export { FeeProxyAbi } from './FeeProxy-abi'; +export { FeeProxyBytecode } from './FeeProxy-bytecode'; export { MetaERC20HubAbi } from './MetaERC20Hub-abi'; export { MetaERC20HubBytecode } from './MetaERC20Hub-bytecode'; export { MetaERC20SpokeAbi } from './MetaERC20Spoke-abi'; diff --git a/packages/periphery/src/deployments.test.ts b/packages/periphery/src/deployments.test.ts index d7849d7..a17c4fd 100644 --- a/packages/periphery/src/deployments.test.ts +++ b/packages/periphery/src/deployments.test.ts @@ -13,7 +13,7 @@ import { describe('intuitionPeripheryDeployments', () => { it('includes TrustSwapAndBridgeRouter on Base', () => { expect(intuitionPeripheryDeployments.TrustSwapAndBridgeRouter?.[base.id]).toBe( - '0xA1EC6f95A88Bfc7A8Fd35f1296b64ebaf91C93fb' + '0xE485D9a5Dc39774b7A80864B625969Cf9d93E5D7' ); }); @@ -45,6 +45,10 @@ describe('intuitionPeripheryDeployments', () => { expect(intuitionPeripheryDeployments.WrappedTrust).toBeUndefined(); }); + it('carries no FeeProxy addresses yet — nothing has been deployed', () => { + expect(intuitionPeripheryDeployments.FeeProxy).toEqual({}); + }); + it('maps recipient domains by direction', () => { expect(intuitionPeripheryBridgeRecipientDomainsByDirection.baseToIntuition).toBe( INTUITION_MAINNET_CHAIN_ID diff --git a/packages/periphery/src/deployments.ts b/packages/periphery/src/deployments.ts index 616cb5f..5df0e29 100644 --- a/packages/periphery/src/deployments.ts +++ b/packages/periphery/src/deployments.ts @@ -13,11 +13,14 @@ export const intuitionPeripheryDeployments: { }; } = { TrustSwapAndBridgeRouter: { - [base.id]: '0xA1EC6f95A88Bfc7A8Fd35f1296b64ebaf91C93fb', + [base.id]: '0xE485D9a5Dc39774b7A80864B625969Cf9d93E5D7', }, MetaNativeSpoke: { [INTUITION_MAINNET_CHAIN_ID]: '0x375135fe908dD62f3C7939FA4e65bf41Da721AB9', }, + // No addresses yet — FeeProxyDeploy.s.sol reads its deployment address from env vars + // at deploy time and nothing has been deployed. Populate once a real deployment exists. + FeeProxy: {}, }; export const intuitionPeripheryMetaERC20HubDeployments: Record< diff --git a/packages/periphery/src/fee-proxy/affiliate-config.ts b/packages/periphery/src/fee-proxy/affiliate-config.ts new file mode 100644 index 0000000..32e6935 --- /dev/null +++ b/packages/periphery/src/fee-proxy/affiliate-config.ts @@ -0,0 +1,28 @@ +import type { ContractFunctionArgs } from 'viem'; + +import { FeeProxyAbi } from '../contracts'; +import type { ReadConfig } from '../types'; + +/** + * Reads the full affiliate registry row. For an unregistered affiliate, returns a + * zero-valued struct. + * @param config Contract address and public client. + * @param inputs Function args for the affiliate lookup. + * @returns The stored `AffiliateConfig`. + */ +export async function feeProxyAffiliateConfig( + config: ReadConfig, + inputs: { + args: ContractFunctionArgs; + } +) { + const { address, publicClient } = config; + const { args } = inputs; + + return await publicClient.readContract({ + address, + abi: FeeProxyAbi, + functionName: 'affiliateConfig', + args, + }); +} diff --git a/packages/periphery/src/fee-proxy/claim-refund.ts b/packages/periphery/src/fee-proxy/claim-refund.ts new file mode 100644 index 0000000..cba6689 --- /dev/null +++ b/packages/periphery/src/fee-proxy/claim-refund.ts @@ -0,0 +1,21 @@ +import { FeeProxyAbi } from '../contracts'; +import type { WriteConfig } from '../types'; + +/** + * Simulates and submits a FeeProxy `claimRefund` transaction — withdraws the caller's + * full pending refund balance from the pull-fallback ledger to the caller. + * @param config Contract address and viem clients. + * @returns Transaction hash from the wallet client. + */ +export async function feeProxyClaimRefund(config: WriteConfig) { + const { address, walletClient, publicClient } = config; + + const { request } = await publicClient.simulateContract({ + account: walletClient.account, + address, + abi: FeeProxyAbi, + functionName: 'claimRefund', + }); + + return await walletClient.writeContract(request); +} diff --git a/packages/periphery/src/fee-proxy/create-atoms-with-uris-via-encode.test.ts b/packages/periphery/src/fee-proxy/create-atoms-with-uris-via-encode.test.ts new file mode 100644 index 0000000..4b6f02a --- /dev/null +++ b/packages/periphery/src/fee-proxy/create-atoms-with-uris-via-encode.test.ts @@ -0,0 +1,34 @@ +import { type Address, decodeFunctionData, isHex } from 'viem'; +import { describe, expect, it } from 'vitest'; + +import { FeeProxyAbi } from '../contracts'; +import { feeProxyCreateAtomsWithUrisViaEncode } from './create-atoms-with-uris-via-encode'; + +describe('feeProxyCreateAtomsWithUrisViaEncode', () => { + it('encodes createAtomsWithUrisVia calldata', () => { + const affiliate = '0x1111111111111111111111111111111111111111' as Address; + const atomDatas = ['0xdead' as const]; + const assets = [10n ** 18n]; + const uris = [['0xbeef' as const]]; + const feeGuard = { maxFeeBps: 500n, maxFixedFee: 0n }; + + const encoded = feeProxyCreateAtomsWithUrisViaEncode( + affiliate, + atomDatas, + assets, + uris, + feeGuard + ); + + expect(isHex(encoded)).toBe(true); + expect(encoded.startsWith('0x')).toBe(true); + + const decoded = decodeFunctionData({ + abi: FeeProxyAbi, + data: encoded, + }); + + expect(decoded.functionName).toBe('createAtomsWithUrisVia'); + expect(decoded.args).toEqual([affiliate, atomDatas, assets, uris, feeGuard]); + }); +}); diff --git a/packages/periphery/src/fee-proxy/create-atoms-with-uris-via-encode.ts b/packages/periphery/src/fee-proxy/create-atoms-with-uris-via-encode.ts new file mode 100644 index 0000000..2dc81d2 --- /dev/null +++ b/packages/periphery/src/fee-proxy/create-atoms-with-uris-via-encode.ts @@ -0,0 +1,27 @@ +import { type Address, encodeFunctionData, type Hex } from 'viem'; + +import { FeeProxyAbi } from '../contracts'; +import type { FeeGuard } from './types'; + +/** + * Encodes calldata for the FeeProxy `createAtomsWithUrisVia` function. + * @param affiliate The affiliate mediating the creation. + * @param atomDatas Per-atom data payloads. + * @param assets Per-atom gross creation assets (pre-fee). + * @param uris Per-atom lists of creation-time context pointers. + * @param feeGuard Per-call front-run guard, applied to every atom. + * @returns Hex-encoded calldata for `createAtomsWithUrisVia`. + */ +export function feeProxyCreateAtomsWithUrisViaEncode( + affiliate: Address, + atomDatas: Hex[], + assets: bigint[], + uris: Hex[][], + feeGuard: FeeGuard +) { + return encodeFunctionData({ + abi: FeeProxyAbi, + functionName: 'createAtomsWithUrisVia', + args: [affiliate, atomDatas, assets, uris, feeGuard], + }); +} diff --git a/packages/periphery/src/fee-proxy/create-atoms-with-uris-via.ts b/packages/periphery/src/fee-proxy/create-atoms-with-uris-via.ts new file mode 100644 index 0000000..b83e3da --- /dev/null +++ b/packages/periphery/src/fee-proxy/create-atoms-with-uris-via.ts @@ -0,0 +1,37 @@ +import type { ContractFunctionArgs } from 'viem'; + +import { FeeProxyAbi } from '../contracts'; +import type { WriteConfig } from '../types'; + +export type FeeProxyCreateAtomsWithUrisViaInputs = { + args: ContractFunctionArgs; + value: bigint; +}; + +/** + * Simulates and submits a FeeProxy `createAtomsWithUrisVia` transaction — routes atom + * creation with URI context through an affiliate, deducting the affiliate's creation + * fee, forwarding the remainder to `MultiVault.createAtomsWithUris`, and refunding any + * excess `msg.value` (push, with pull-fallback via `pendingRefund` on failure). + * @param config Contract address and viem clients. + * @param inputs Function args and the gross call value. + * @returns Transaction hash from the wallet client. + */ +export async function feeProxyCreateAtomsWithUrisVia( + config: WriteConfig, + inputs: FeeProxyCreateAtomsWithUrisViaInputs +) { + const { address, walletClient, publicClient } = config; + const { args, value } = inputs; + + const { request } = await publicClient.simulateContract({ + account: walletClient.account, + address, + abi: FeeProxyAbi, + functionName: 'createAtomsWithUrisVia', + args, + value, + }); + + return await walletClient.writeContract(request); +} diff --git a/packages/periphery/src/fee-proxy/index.ts b/packages/periphery/src/fee-proxy/index.ts new file mode 100644 index 0000000..73af3db --- /dev/null +++ b/packages/periphery/src/fee-proxy/index.ts @@ -0,0 +1,9 @@ +export * from './affiliate-config'; +export * from './claim-refund'; +export * from './create-atoms-with-uris-via'; +export * from './create-atoms-with-uris-via-encode'; +export * from './is-affiliate-active'; +export * from './pending-refund'; +export * from './preview-creation-fee'; +export * from './register-affiliate'; +export * from './types'; diff --git a/packages/periphery/src/fee-proxy/is-affiliate-active.ts b/packages/periphery/src/fee-proxy/is-affiliate-active.ts new file mode 100644 index 0000000..510e983 --- /dev/null +++ b/packages/periphery/src/fee-proxy/is-affiliate-active.ts @@ -0,0 +1,28 @@ +import type { ContractFunctionArgs } from 'viem'; + +import { FeeProxyAbi } from '../contracts'; +import type { ReadConfig } from '../types'; + +/** + * Reads whether an affiliate is registered and not paused — the condition every FeeProxy + * routing entry point checks. + * @param config Contract address and public client. + * @param inputs Function args for the affiliate lookup. + * @returns Whether the affiliate is active. + */ +export async function feeProxyIsAffiliateActive( + config: ReadConfig, + inputs: { + args: ContractFunctionArgs; + } +) { + const { address, publicClient } = config; + const { args } = inputs; + + return await publicClient.readContract({ + address, + abi: FeeProxyAbi, + functionName: 'isAffiliateActive', + args, + }); +} diff --git a/packages/periphery/src/fee-proxy/pending-refund.ts b/packages/periphery/src/fee-proxy/pending-refund.ts new file mode 100644 index 0000000..8433139 --- /dev/null +++ b/packages/periphery/src/fee-proxy/pending-refund.ts @@ -0,0 +1,27 @@ +import type { ContractFunctionArgs } from 'viem'; + +import { FeeProxyAbi } from '../contracts'; +import type { ReadConfig } from '../types'; + +/** + * Reads the pull-fallback refund balance owed to a user. + * @param config Contract address and public client. + * @param inputs Function args for the user lookup. + * @returns The amount owed and withdrawable via `claimRefund`. + */ +export async function feeProxyPendingRefund( + config: ReadConfig, + inputs: { + args: ContractFunctionArgs; + } +) { + const { address, publicClient } = config; + const { args } = inputs; + + return await publicClient.readContract({ + address, + abi: FeeProxyAbi, + functionName: 'pendingRefund', + args, + }); +} diff --git a/packages/periphery/src/fee-proxy/preview-creation-fee.ts b/packages/periphery/src/fee-proxy/preview-creation-fee.ts new file mode 100644 index 0000000..c96a884 --- /dev/null +++ b/packages/periphery/src/fee-proxy/preview-creation-fee.ts @@ -0,0 +1,27 @@ +import type { ContractFunctionArgs } from 'viem'; + +import { FeeProxyAbi } from '../contracts'; +import type { ReadConfig } from '../types'; + +/** + * Reads the effective creation-side fee math for an affiliate applied to gross assets. + * @param config Contract address and public client. + * @param inputs Function args: the affiliate and the pre-fee gross asset amount. + * @returns `[fee, forwarded]` — the affiliate fee that would be deducted, and the amount that would be forwarded to MultiVault. + */ +export async function feeProxyPreviewCreationFee( + config: ReadConfig, + inputs: { + args: ContractFunctionArgs; + } +) { + const { address, publicClient } = config; + const { args } = inputs; + + return await publicClient.readContract({ + address, + abi: FeeProxyAbi, + functionName: 'previewCreationFee', + args, + }); +} diff --git a/packages/periphery/src/fee-proxy/register-affiliate.ts b/packages/periphery/src/fee-proxy/register-affiliate.ts new file mode 100644 index 0000000..3dd570c --- /dev/null +++ b/packages/periphery/src/fee-proxy/register-affiliate.ts @@ -0,0 +1,35 @@ +import type { ContractFunctionArgs } from 'viem'; + +import { FeeProxyAbi } from '../contracts'; +import type { WriteConfig } from '../types'; + +export type FeeProxyRegisterAffiliateInputs = { + args: ContractFunctionArgs; + value: bigint; +}; + +/** + * Simulates and submits a FeeProxy `registerAffiliate` transaction. `value` must + * exactly match the current `registrationFee`. + * @param config Contract address and viem clients. + * @param inputs Function args and the registration fee value. + * @returns Transaction hash from the wallet client. + */ +export async function feeProxyRegisterAffiliate( + config: WriteConfig, + inputs: FeeProxyRegisterAffiliateInputs +) { + const { address, walletClient, publicClient } = config; + const { args, value } = inputs; + + const { request } = await publicClient.simulateContract({ + account: walletClient.account, + address, + abi: FeeProxyAbi, + functionName: 'registerAffiliate', + args, + value, + }); + + return await walletClient.writeContract(request); +} diff --git a/packages/periphery/src/fee-proxy/types.ts b/packages/periphery/src/fee-proxy/types.ts new file mode 100644 index 0000000..4bef8c9 --- /dev/null +++ b/packages/periphery/src/fee-proxy/types.ts @@ -0,0 +1,5 @@ +/** Mirrors the on-chain `FeeGuard` struct — the caller's per-call front-run guard. */ +export type FeeGuard = { + maxFeeBps: bigint; + maxFixedFee: bigint; +}; diff --git a/packages/periphery/src/index.ts b/packages/periphery/src/index.ts index 5acba67..cda060a 100644 --- a/packages/periphery/src/index.ts +++ b/packages/periphery/src/index.ts @@ -1,9 +1,11 @@ export * from './contracts'; export * from './deployments'; +export * from './fee-proxy'; export * from './meta-bridge'; export * from './trust-swap-and-bridge-router'; export * from './types'; export * from './utils/get-base-bridge-asset-address'; +export * from './utils/get-fee-proxy-address-from-chain-id'; export * from './utils/get-meta-erc20-hub-address-from-chain-id'; export * from './utils/get-meta-erc20-spoke-address-from-chain-id'; export * from './utils/get-meta-native-spoke-address-from-chain-id'; diff --git a/packages/periphery/src/trust-swap-and-bridge-router/quote-exact-input.test.ts b/packages/periphery/src/trust-swap-and-bridge-router/quote-exact-input.test.ts index 484cc93..ff31093 100644 --- a/packages/periphery/src/trust-swap-and-bridge-router/quote-exact-input.test.ts +++ b/packages/periphery/src/trust-swap-and-bridge-router/quote-exact-input.test.ts @@ -5,12 +5,12 @@ import { describe, expect, it, vi } from 'vitest'; import { trustSwapAndBridgeRouterQuoteExactInput } from './quote-exact-input'; describe('trustSwapAndBridgeRouterQuoteExactInput', () => { - it('simulates quoteExactInput and returns amountOut', async () => { + it('simulates quoteExactInput and returns the [amountOut, success] tuple', async () => { const address = '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' as Address; const path = '0x833589fcd6edb6e08f4c7c32d4f71b54bda029130000016cd905df2ed214b22e0d48ff17cd4200c1c6d8a3' as Hex; const amountIn = 1_000_000n; - const quote = 321n; + const quote = [321n, true] as const; const simulateContract = vi.fn().mockResolvedValue({ result: quote }); const publicClient = { simulateContract } as unknown as PublicClient; @@ -24,7 +24,7 @@ describe('trustSwapAndBridgeRouterQuoteExactInput', () => { } ); - expect(result).toBe(quote); + expect(result).toEqual(quote); expect(simulateContract).toHaveBeenCalledTimes(1); expect(simulateContract).toHaveBeenCalledWith( expect.objectContaining({ @@ -35,4 +35,24 @@ describe('trustSwapAndBridgeRouterQuoteExactInput', () => { }) ); }); + + it('surfaces success=false when the underlying quoter reverts', async () => { + const address = '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' as Address; + const path = + '0x833589fcd6edb6e08f4c7c32d4f71b54bda029130000016cd905df2ed214b22e0d48ff17cd4200c1c6d8a3' as Hex; + const amountIn = 1_000_000n; + const failedQuote = [0n, false] as const; + const simulateContract = vi.fn().mockResolvedValue({ result: failedQuote }); + const publicClient = { simulateContract } as unknown as PublicClient; + + const result = await trustSwapAndBridgeRouterQuoteExactInput( + { address, publicClient }, + { args: [path, amountIn] } + ); + + expect(result).toEqual(failedQuote); + const [amountOut, success] = result; + expect(amountOut).toBe(0n); + expect(success).toBe(false); + }); }); diff --git a/packages/periphery/src/trust-swap-and-bridge-router/quote-exact-input.ts b/packages/periphery/src/trust-swap-and-bridge-router/quote-exact-input.ts index 9aa2194..a15a5aa 100644 --- a/packages/periphery/src/trust-swap-and-bridge-router/quote-exact-input.ts +++ b/packages/periphery/src/trust-swap-and-bridge-router/quote-exact-input.ts @@ -9,10 +9,19 @@ export type TrustSwapAndBridgeRouterQuoteExactInputInputs = { /** * Calls TrustSwapAndBridgeRouter `quoteExactInput` via simulation. - * Note: the ABI marks this function `nonpayable`, so simulation is used instead of `readContract`. + * + * Returns a tuple `[amountOut, success]`. `success = false` indicates the + * underlying Slipstream quoter reverted (transient RPC failure, stale oracle, + * deprecated pool) — callers that derive `minTrustOut` from this preflight + * **must** branch on `success` and abort the swap when `false`, otherwise + * downstream slippage protection collapses on a subsequent swap call. + * + * Note: the ABI marks this function `nonpayable`, so simulation is used + * instead of `readContract`. + * * @param config Contract address and public client. * @param inputs Function args (path, amountIn). - * @returns Expected output amount from the quoter path. + * @returns Tuple `[amountOut, success]` from the quoter path. */ export async function trustSwapAndBridgeRouterQuoteExactInput( config: ReadConfig, diff --git a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20-encode.test.ts b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20-encode.test.ts index 09bd151..7964ec4 100644 --- a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20-encode.test.ts +++ b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20-encode.test.ts @@ -12,13 +12,15 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithERC20Encode', () => { '0x833589fcd6edb6e08f4c7c32d4f71b54bda029130000016cd905df2ed214b22e0d48ff17cd4200c1c6d8a3' as Hex; const minTrustOut = 123n; const recipient = '0x1111111111111111111111111111111111111111' as Address; + const deadline = 1_700_000_000n; const encoded = trustSwapAndBridgeRouterSwapAndBridgeWithERC20Encode( tokenIn, amountIn, path, minTrustOut, - recipient + recipient, + deadline ); expect(isHex(encoded)).toBe(true); @@ -34,5 +36,6 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithERC20Encode', () => { expect(decoded.args?.[2]).toBe(path); expect(decoded.args?.[3]).toBe(minTrustOut); expect(decoded.args?.[4]).toBe(recipient); + expect(decoded.args?.[5]).toBe(deadline); }); }); diff --git a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20-encode.ts b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20-encode.ts index 33d5dbd..cebf25c 100644 --- a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20-encode.ts +++ b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20-encode.ts @@ -9,6 +9,10 @@ import { TrustSwapAndBridgeRouterAbi } from '../contracts'; * @param path Packed Slipstream swap path. * @param minTrustOut Minimum TRUST output to accept from swap. * @param recipient Final recipient on destination chain. + * @param deadline Unix timestamp after which the swap reverts. Must satisfy + * `deadline >= block.timestamp` at execution; reverts with + * `TrustSwapAndBridgeRouter_DeadlineExpired` otherwise. Frontends should + * use a sensible future buffer (e.g. `now + 20 minutes`). * @returns Hex-encoded calldata for `swapAndBridgeWithERC20`. */ export function trustSwapAndBridgeRouterSwapAndBridgeWithERC20Encode( @@ -16,11 +20,12 @@ export function trustSwapAndBridgeRouterSwapAndBridgeWithERC20Encode( amountIn: bigint, path: Hex, minTrustOut: bigint, - recipient: Address + recipient: Address, + deadline: bigint ): Hex { return encodeFunctionData({ abi: TrustSwapAndBridgeRouterAbi, functionName: 'swapAndBridgeWithERC20', - args: [tokenIn, amountIn, path, minTrustOut, recipient], + args: [tokenIn, amountIn, path, minTrustOut, recipient, deadline], }); } diff --git a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20.test.ts b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20.test.ts index f754edc..01438ea 100644 --- a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20.test.ts +++ b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-erc20.test.ts @@ -12,6 +12,7 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithERC20', () => { '0x833589fcd6edb6e08f4c7c32d4f71b54bda029130000016cd905df2ed214b22e0d48ff17cd4200c1c6d8a3' as Hex; const minTrustOut = 1n; const recipient = '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' as Address; + const deadline = 1_700_000_000n; const value = 1_000_000_000_000_000n; const hash = '0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' as Hex; const account = { @@ -32,7 +33,7 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithERC20', () => { walletClient, }, { - args: [tokenIn, amountIn, path, minTrustOut, recipient], + args: [tokenIn, amountIn, path, minTrustOut, recipient, deadline], value, } ); @@ -43,7 +44,7 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithERC20', () => { account, address, functionName: 'swapAndBridgeWithERC20', - args: [tokenIn, amountIn, path, minTrustOut, recipient], + args: [tokenIn, amountIn, path, minTrustOut, recipient, deadline], value, }) ); diff --git a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth-encode.test.ts b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth-encode.test.ts index e079692..e73db85 100644 --- a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth-encode.test.ts +++ b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth-encode.test.ts @@ -10,11 +10,13 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithETHEncode', () => { '0x4200000000000000000000000000000000000006000032833589fcd6edb6e08f4c7c32d4f71b54bda029130000016cd905df2ed214b22e0d48ff17cd4200c1c6d8a3' as Hex; const minTrustOut = 123n; const recipient = '0x1111111111111111111111111111111111111111' as Address; + const deadline = 1_700_000_000n; const encoded = trustSwapAndBridgeRouterSwapAndBridgeWithETHEncode( path, minTrustOut, - recipient + recipient, + deadline ); expect(isHex(encoded)).toBe(true); @@ -24,6 +26,6 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithETHEncode', () => { }); expect(decoded.functionName).toBe('swapAndBridgeWithETH'); - expect(decoded.args).toEqual([path, minTrustOut, recipient]); + expect(decoded.args).toEqual([path, minTrustOut, recipient, deadline]); }); }); diff --git a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth-encode.ts b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth-encode.ts index e5a77bd..055afce 100644 --- a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth-encode.ts +++ b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth-encode.ts @@ -7,16 +7,21 @@ import { TrustSwapAndBridgeRouterAbi } from '../contracts'; * @param path Packed Slipstream swap path. * @param minTrustOut Minimum TRUST output to accept from swap. * @param recipient Final recipient on destination chain. + * @param deadline Unix timestamp after which the swap reverts. Must satisfy + * `deadline >= block.timestamp` at execution; reverts with + * `TrustSwapAndBridgeRouter_DeadlineExpired` otherwise. Frontends should + * use a sensible future buffer (e.g. `now + 20 minutes`). * @returns Hex-encoded calldata for `swapAndBridgeWithETH`. */ export function trustSwapAndBridgeRouterSwapAndBridgeWithETHEncode( path: Hex, minTrustOut: bigint, - recipient: Address + recipient: Address, + deadline: bigint ): Hex { return encodeFunctionData({ abi: TrustSwapAndBridgeRouterAbi, functionName: 'swapAndBridgeWithETH', - args: [path, minTrustOut, recipient], + args: [path, minTrustOut, recipient, deadline], }); } diff --git a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth.test.ts b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth.test.ts index e7f1c4d..fc42ae8 100644 --- a/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth.test.ts +++ b/packages/periphery/src/trust-swap-and-bridge-router/swap-and-bridge-with-eth.test.ts @@ -10,6 +10,7 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithETH', () => { '0x4200000000000000000000000000000000000006000032833589fcd6edb6e08f4c7c32d4f71b54bda029130000016cd905df2ed214b22e0d48ff17cd4200c1c6d8a3' as Hex; const minTrustOut = 1n; const recipient = '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' as Address; + const deadline = 1_700_000_000n; const value = 2_000_000_000_000_000n; const hash = '0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' as Hex; const account = { @@ -30,7 +31,7 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithETH', () => { walletClient, }, { - args: [path, minTrustOut, recipient], + args: [path, minTrustOut, recipient, deadline], value, } ); @@ -41,7 +42,7 @@ describe('trustSwapAndBridgeRouterSwapAndBridgeWithETH', () => { account, address, functionName: 'swapAndBridgeWithETH', - args: [path, minTrustOut, recipient], + args: [path, minTrustOut, recipient, deadline], value, }) ); diff --git a/packages/periphery/src/utils/get-fee-proxy-address-from-chain-id.test.ts b/packages/periphery/src/utils/get-fee-proxy-address-from-chain-id.test.ts new file mode 100644 index 0000000..993bf5c --- /dev/null +++ b/packages/periphery/src/utils/get-fee-proxy-address-from-chain-id.test.ts @@ -0,0 +1,11 @@ +import { describe, expect, it } from 'vitest'; + +import { getFeeProxyAddressFromChainId } from './get-fee-proxy-address-from-chain-id'; + +describe('getFeeProxyAddressFromChainId', () => { + it('throws for any chain — no FeeProxy has been deployed yet', () => { + expect(() => getFeeProxyAddressFromChainId(999_999)).toThrow( + 'Contract FeeProxy not found for chain ID 999999' + ); + }); +}); diff --git a/packages/periphery/src/utils/get-fee-proxy-address-from-chain-id.ts b/packages/periphery/src/utils/get-fee-proxy-address-from-chain-id.ts new file mode 100644 index 0000000..881b763 --- /dev/null +++ b/packages/periphery/src/utils/get-fee-proxy-address-from-chain-id.ts @@ -0,0 +1,18 @@ +import type { Address } from 'viem'; + +import { intuitionPeripheryDeployments } from '../deployments'; + +/** + * Resolves the FeeProxy contract address for a given chain ID. + * @param chainId Chain ID for the deployment. + * @returns FeeProxy contract address. + * @throws Error if the deployment is missing. + */ +export function getFeeProxyAddressFromChainId(chainId: number): Address { + const address = intuitionPeripheryDeployments.FeeProxy?.[chainId]; + if (!address) { + throw new Error(`Contract FeeProxy not found for chain ID ${chainId}`); + } + + return address; +}