NXTP Facet

How it works

The NXTP Facet works by forwarding NXTP (Connext) specific calls to NXTP's TransactionManager contract. This is accomplished by populating NXTP PrepareArgs and calling the prepare() method on the NXTP Transaction Manager. The NXTP documentation details how to get the data needed for PrepareArgs using their SDK.
The NXTP protocol also allows for calling contracts on the receiving chain once bridging is complete. This is accomplished by passing calldata in the invariantData property described in _nxtpData below. This is useful if we want to perform a swap on the recieving chain before sending to the receiver. This functionality is provided by Gelato Network under the hood.

Public Methods

  • function initNXTP(ITransactionManager _txMgrAddr)
    • Initializer method. Sets the chain specific NXTP Transaction Manager Contract
  • function startBridgeTokensViaNXTP(LiFiData memory _lifiData, ITransactionManager.PrepareArgs memory _nxtpData)
    • Simply bridges tokens using NXTP
  • function swapAndStartBridgeTokensViaNXTP( LiFiData memory _lifiData, LibSwap.SwapData[] calldata _swapData, ITransactionManager.PrepareArgs memory _nxtpData)
    • Performs swap(s) before bridging tokens using NXTP
  • function completeBridgeTokensViaNXTP( LiFiData memory _lifiData, address assetId, address receiver, uint256 amount)
    • Completes a bridge transaction on the receiving chain and sends the tokens to the receiver. Should be called by the NXTP Gelato Resolver.
  • function swapAndCompleteBridgeTokensViaNXTP( LiFiData memory _lifiData, LibSwap.SwapData[] calldata _swapData, address finalAssetId, address receiver)
    • Performs swap(s) before completing a bridge transaction on the receiving chain and sending the tokens to the receiver. Should be called by the NXTP Gelato Resolver.

NXTP Specific Parameters

Some of the methods listed above take a variable labeled _nxtpData. This data is specific to NXTP and is represented as the following struct type:
1
/// Arguments for calling prepare()
2
/// @param invariantData The data for a crosschain transaction that will
3
/// not change between sending and receiving chains.
4
/// The hash of this data is used as the key to store
5
/// the inforamtion that does change between chains
6
/// (amount,expiry,preparedBlock) for verification
7
/// @param amount The amount of the transaction on this chain
8
/// @param expiry The block.timestamp when the transaction will no longer be
9
/// fulfillable and is freely cancellable on this chain
10
/// @param encryptedCallData The calldata to be executed when the tx is
11
/// fulfilled. Used in the function to allow the user
12
/// to reconstruct the tx from events. Hash is stored
13
/// onchain to prevent shenanigans.
14
/// @param encodedBid The encoded bid that was accepted by the user for this
15
/// crosschain transfer. It is supplied as a param to the
16
/// function but is only used in event emission
17
/// @param bidSignature The signature of the bidder on the encoded bid for
18
/// this transaction. Only used within the function for
19
/// event emission. The validity of the bid and
20
/// bidSignature are enforced offchain
21
/// @param encodedMeta The meta for the function
22
struct PrepareArgs {
23
InvariantTransactionData invariantData;
24
uint256 amount;
25
uint256 expiry;
26
bytes encryptedCallData;
27
bytes encodedBid;
28
bytes bidSignature;
29
bytes encodedMeta;
30
}
Copied!

Swap Data

Some methods accept a SwapData _swapData parameter.
Swapping is performed by a swap specific library that expects an array of calldata to can be run on variaous DEXs (i.e. Uniswap) to make one or multiple swaps before performing another action.
The swap library can be found here.

LiFi Data

Some methods accept a LiFiData _lifiData parameter.
This parameter is strictly for analytics purposes. It's used to emit events that we can later track and index in our subgraphs and provide data on how our contracts are being used. LiFiData and the events we can emit can be found here.

Getting Sample Calls to interact with the Facet

In the following some sample calls are shown that allow you to retrieve a populated transaction that can be sent to our contract via your wallet.
All examples use our /quote endpoint to retrieve a quote which contains a transactionRequest. This request can directly be sent to your wallet to trigger the transaction.
The quote result looks like the following:
1
const quoteResult = {
2
id: '0x...', // quote id
3
type: 'lifi', // the type of the quote (all lifi contract calls have the type "lifi")
4
tool: 'hop', // the bridge tool used for the transaction
5
action: {}, // information about what is going to happen
6
estimate: {}, // information about the estimated outcome of the call
7
includedSteps: [], // steps that are executed by the contract as part of this transaction, e.g. a swap step and a cross step
8
transactionRequest: {
9
// the transaction that can be sent using a wallet
10
data: '0x...',
11
to: '0x...',
12
value: '0x00',
13
from: '{YOUR_WALLET_ADDRESS}',
14
chainId: 100,
15
gasLimit: '0x...',
16
gasPrice: '0x...',
17
},
18
}
Copied!
A detailed explanation on how to use the /quote endpoint and how to trigger the transaction can be found here.
Hint: Don't forget to replace {YOUR_WALLET_ADDRESS} with your real wallet address in the examples.

Cross Only

To get a transaction for a transfer from 1 MIVA on Gnosis to MIVA on Polygon you can execute the following request:
1
curl 'https://li.quest/v1/quote?fromChain=DAI&fromAmount=1000000000000000000&fromToken=MIVA&toChain=POL&toToken=MIVA&slippage=0.03&allowBridges=connext&fromAddress={YOUR_WALLET_ADDRESS}'
Copied!

Swap & Cross

To get a transaction for a transfer from 1 DAI on Gnosis to MIVA on Polygon you can execute the following request:
1
curl 'https://li.quest/v1/quote?fromChain=DAI&fromAmount=1000000000000000000&fromToken=DAI&toChain=POL&toToken=MIVA&slippage=0.03&allowBridges=connext&fromAddress={YOUR_WALLET_ADDRESS}'
Copied!

Swap & Cross & Swap

To get a transaction for a transfer from 1 DAI on Gnosis to MATIC on Polygon you can execute the following request:
1
curl 'https://li.quest/v1/quote?fromChain=DAI&fromAmount=1000000000000000000&fromToken=DAI&toChain=POL&toToken=MATIC&slippage=0.03&allowBridges=connext&fromAddress={YOUR_WALLET_ADDRESS}'
Copied!
Hint: Swaps on the destination chain are currently only possible with Connext.
Last modified 16d ago