Skip to content

Commit d6397a5

Browse files
authored
Merge pull request #1 from connext/minimal-interfaces
Minimal interfaces
2 parents 351e64a + 04ccfca commit d6397a5

8 files changed

Lines changed: 246 additions & 2 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# interfaces
2-
Minimal interfaces needed for integrations
1+
# Interfaces
2+
Minimal Connext contract interfaces needed for integrations.

interfaces/IConnext.sol

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.17;
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 xcallIntoLocal(
22+
uint32 _destination,
23+
address _to,
24+
address _asset,
25+
address _delegate,
26+
uint256 _amount,
27+
uint256 _slippage,
28+
bytes calldata _callData
29+
) external payable returns (bytes32);
30+
31+
function execute(ExecuteArgs calldata _args) external returns (bytes32 transferId);
32+
33+
function forceUpdateSlippage(TransferInfo calldata _params, uint256 _slippage) external;
34+
35+
function forceReceiveLocal(TransferInfo calldata _params) external;
36+
37+
function bumpTransfer(bytes32 _transferId) external payable;
38+
39+
function routedTransfers(bytes32 _transferId) external view returns (address[] memory);
40+
41+
function transferStatus(bytes32 _transferId) external view returns (DestinationTransferStatus);
42+
43+
function remote(uint32 _domain) external view returns (address);
44+
45+
function domain() external view returns (uint256);
46+
47+
function nonce() external view returns (uint256);
48+
49+
function approvedSequencers(address _sequencer) external view returns (bool);
50+
51+
function xAppConnectionManager() external view returns (address);
52+
53+
// ============ ROUTERS ==============
54+
55+
function LIQUIDITY_FEE_NUMERATOR() external view returns (uint256);
56+
57+
function LIQUIDITY_FEE_DENOMINATOR() external view returns (uint256);
58+
59+
function getRouterApproval(address _router) external view returns (bool);
60+
61+
function getRouterRecipient(address _router) external view returns (address);
62+
63+
function getRouterOwner(address _router) external view returns (address);
64+
65+
function getProposedRouterOwner(address _router) external view returns (address);
66+
67+
function getProposedRouterOwnerTimestamp(address _router) external view returns (uint256);
68+
69+
function maxRoutersPerTransfer() external view returns (uint256);
70+
71+
function routerBalances(address _router, address _asset) external view returns (uint256);
72+
73+
function getRouterApprovalForPortal(address _router) external view returns (bool);
74+
75+
function initializeRouter(address _owner, address _recipient) external;
76+
77+
function setRouterRecipient(address _router, address _recipient) external;
78+
79+
function proposeRouterOwner(address _router, address _proposed) external;
80+
81+
function acceptProposedRouterOwner(address _router) external;
82+
83+
function addRouterLiquidityFor(
84+
uint256 _amount,
85+
address _local,
86+
address _router
87+
) external payable;
88+
89+
function addRouterLiquidity(uint256 _amount, address _local) external payable;
90+
91+
function removeRouterLiquidityFor(
92+
TokenId memory _canonical,
93+
uint256 _amount,
94+
address payable _to,
95+
address _router
96+
) external;
97+
98+
function removeRouterLiquidity(TokenId memory _canonical, uint256 _amount, address payable _to) external;
99+
}

interfaces/IXReceiver.sol

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.17;
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+
}

libraries/LibConnextStorage.sol

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.17;
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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
pragma solidity ^0.8.17;
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+
}

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@connext/interfaces",
3+
"version": "1.0.0",
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+
}

0 commit comments

Comments
 (0)