├── .github └── workflows │ └── npm-publish.yml ├── .gitignore ├── README.md ├── core ├── IConnext.sol ├── IWeth.sol └── IXReceiver.sol ├── libraries ├── LibConnextStorage.sol └── TokenId.sol ├── package-lock.json └── package.json /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish Package to npmjs 2 | on: 3 | release: 4 | types: [published] 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v3 10 | # Setup .npmrc file to publish to npm 11 | - uses: actions/setup-node@v3 12 | with: 13 | node-version: '18.x' 14 | registry-url: 'https://registry.npmjs.org' 15 | - run: npm ci 16 | - run: npm publish --access public 17 | env: 18 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Interfaces 2 | Minimal Connext contract interfaces needed for integrations. 3 | -------------------------------------------------------------------------------- /core/IConnext.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | import {ExecuteArgs, TransferInfo, DestinationTransferStatus} from "../libraries/LibConnextStorage.sol"; 5 | import {TokenId} from "../libraries/TokenId.sol"; 6 | 7 | interface IConnext { 8 | 9 | // ============ BRIDGE ============== 10 | 11 | function xcall( 12 | uint32 _destination, 13 | address _to, 14 | address _asset, 15 | address _delegate, 16 | uint256 _amount, 17 | uint256 _slippage, 18 | bytes calldata _callData 19 | ) external payable returns (bytes32); 20 | 21 | function xcall( 22 | uint32 _destination, 23 | address _to, 24 | address _asset, 25 | address _delegate, 26 | uint256 _amount, 27 | uint256 _slippage, 28 | bytes calldata _callData, 29 | uint256 _relayerFee 30 | ) external returns (bytes32); 31 | 32 | function xcallIntoLocal( 33 | uint32 _destination, 34 | address _to, 35 | address _asset, 36 | address _delegate, 37 | uint256 _amount, 38 | uint256 _slippage, 39 | bytes calldata _callData 40 | ) external payable returns (bytes32); 41 | 42 | function execute(ExecuteArgs calldata _args) external returns (bytes32 transferId); 43 | 44 | function forceUpdateSlippage(TransferInfo calldata _params, uint256 _slippage) external; 45 | 46 | function forceReceiveLocal(TransferInfo calldata _params) external; 47 | 48 | function bumpTransfer(bytes32 _transferId) external payable; 49 | 50 | function routedTransfers(bytes32 _transferId) external view returns (address[] memory); 51 | 52 | function transferStatus(bytes32 _transferId) external view returns (DestinationTransferStatus); 53 | 54 | function remote(uint32 _domain) external view returns (address); 55 | 56 | function domain() external view returns (uint256); 57 | 58 | function nonce() external view returns (uint256); 59 | 60 | function approvedSequencers(address _sequencer) external view returns (bool); 61 | 62 | function xAppConnectionManager() external view returns (address); 63 | 64 | // ============ ROUTERS ============== 65 | 66 | function LIQUIDITY_FEE_NUMERATOR() external view returns (uint256); 67 | 68 | function LIQUIDITY_FEE_DENOMINATOR() external view returns (uint256); 69 | 70 | function getRouterApproval(address _router) external view returns (bool); 71 | 72 | function getRouterRecipient(address _router) external view returns (address); 73 | 74 | function getRouterOwner(address _router) external view returns (address); 75 | 76 | function getProposedRouterOwner(address _router) external view returns (address); 77 | 78 | function getProposedRouterOwnerTimestamp(address _router) external view returns (uint256); 79 | 80 | function maxRoutersPerTransfer() external view returns (uint256); 81 | 82 | function routerBalances(address _router, address _asset) external view returns (uint256); 83 | 84 | function getRouterApprovalForPortal(address _router) external view returns (bool); 85 | 86 | function initializeRouter(address _owner, address _recipient) external; 87 | 88 | function setRouterRecipient(address _router, address _recipient) external; 89 | 90 | function proposeRouterOwner(address _router, address _proposed) external; 91 | 92 | function acceptProposedRouterOwner(address _router) external; 93 | 94 | function addRouterLiquidityFor( 95 | uint256 _amount, 96 | address _local, 97 | address _router 98 | ) external payable; 99 | 100 | function addRouterLiquidity(uint256 _amount, address _local) external payable; 101 | 102 | function removeRouterLiquidityFor( 103 | TokenId memory _canonical, 104 | uint256 _amount, 105 | address payable _to, 106 | address _router 107 | ) external; 108 | 109 | function removeRouterLiquidity(TokenId memory _canonical, uint256 _amount, address payable _to) external; 110 | 111 | // ============ TOKEN_FACET ============== 112 | function adoptedToCanonical(address _adopted) external view returns (TokenId memory); 113 | 114 | function approvedAssets(TokenId calldata _canonical) external view returns (bool); 115 | } 116 | -------------------------------------------------------------------------------- /core/IWeth.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | interface IWeth { 5 | function deposit() external payable; 6 | 7 | function withdraw(uint256 value) external; 8 | } 9 | -------------------------------------------------------------------------------- /core/IXReceiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | interface IXReceiver { 5 | function xReceive( 6 | bytes32 _transferId, 7 | uint256 _amount, 8 | address _asset, 9 | address _originSender, 10 | uint32 _origin, 11 | bytes memory _callData 12 | ) external returns (bytes memory); 13 | } 14 | -------------------------------------------------------------------------------- /libraries/LibConnextStorage.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | /** 5 | * @notice Enum representing status of destination transfer 6 | * @dev Status is only assigned on the destination domain, will always be "none" for the 7 | * origin domains 8 | * @return uint - Index of value in enum 9 | */ 10 | enum DestinationTransferStatus { 11 | None, // 0 12 | Reconciled, // 1 13 | Executed, // 2 14 | Completed // 3 - executed + reconciled 15 | } 16 | 17 | /** 18 | * @notice These are the parameters that will remain constant between the 19 | * two chains. They are supplied on `xcall` and should be asserted on `execute` 20 | * @property to - The account that receives funds, in the event of a crosschain call, 21 | * will receive funds if the call fails. 22 | * 23 | * @param originDomain - The originating domain (i.e. where `xcall` is called) 24 | * @param destinationDomain - The final domain (i.e. where `execute` / `reconcile` are called)\ 25 | * @param canonicalDomain - The canonical domain of the asset you are bridging 26 | * @param to - The address you are sending funds (and potentially data) to 27 | * @param delegate - An address who can execute txs on behalf of `to`, in addition to allowing relayers 28 | * @param receiveLocal - If true, will use the local asset on the destination instead of adopted. 29 | * @param callData - The data to execute on the receiving chain. If no crosschain call is needed, then leave empty. 30 | * @param slippage - Slippage user is willing to accept from original amount in expressed in BPS (i.e. if 31 | * a user takes 1% slippage, this is expressed as 1_000) 32 | * @param originSender - The msg.sender of the xcall 33 | * @param bridgedAmt - The amount sent over the bridge (after potential AMM on xcall) 34 | * @param normalizedIn - The amount sent to `xcall`, normalized to 18 decimals 35 | * @param nonce - The nonce on the origin domain used to ensure the transferIds are unique 36 | * @param canonicalId - The unique identifier of the canonical token corresponding to bridge assets 37 | */ 38 | struct TransferInfo { 39 | uint32 originDomain; 40 | uint32 destinationDomain; 41 | uint32 canonicalDomain; 42 | address to; 43 | address delegate; 44 | bool receiveLocal; 45 | bytes callData; 46 | uint256 slippage; 47 | address originSender; 48 | uint256 bridgedAmt; 49 | uint256 normalizedIn; 50 | uint256 nonce; 51 | bytes32 canonicalId; 52 | } 53 | 54 | /** 55 | * @notice 56 | * @param params - The TransferInfo. These are consistent across sending and receiving chains. 57 | * @param routers - The routers who you are sending the funds on behalf of. 58 | * @param routerSignatures - Signatures belonging to the routers indicating permission to use funds 59 | * for the signed transfer ID. 60 | * @param sequencer - The sequencer who assigned the router path to this transfer. 61 | * @param sequencerSignature - Signature produced by the sequencer for path assignment accountability 62 | * for the path that was signed. 63 | */ 64 | struct ExecuteArgs { 65 | TransferInfo params; 66 | address[] routers; 67 | bytes[] routerSignatures; 68 | address sequencer; 69 | bytes sequencerSignature; 70 | } -------------------------------------------------------------------------------- /libraries/TokenId.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.0; 3 | 4 | // ============= Structs ============= 5 | 6 | // Tokens are identified by a TokenId: 7 | // domain - 4 byte chain ID of the chain from which the token originates 8 | // id - 32 byte identifier of the token address on the origin chain, in that chain's address format 9 | struct TokenId { 10 | uint32 domain; 11 | bytes32 id; 12 | } 13 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@connext/interfaces", 3 | "version": "2.0.5", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@connext/interfaces", 9 | "version": "2.0.5", 10 | "license": "ISC" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@connext/interfaces", 3 | "version": "2.0.5", 4 | "description": "Minimal interfaces needed for integrations", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/connext/interfaces.git" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/connext/interfaces/issues" 17 | }, 18 | "homepage": "https://github.com/connext/interfaces#readme" 19 | } 20 | --------------------------------------------------------------------------------