Skip to content

Latest commit

 

History

History
106 lines (77 loc) · 4.52 KB

AmarokFacet.md

File metadata and controls

106 lines (77 loc) · 4.52 KB

Amarok Facet

How it works

The Amarok Facet works by forwarding Amarok specific calls to Connext Amarok BridgeFacet contract.

graph LR;
    D{LiFiDiamond}-- DELEGATECALL -->C(AmarokDiamond);
    C(AmarokDiamond) -- DELEGATECALL --> O(Amarok BridgeFacet)
Loading

Public Methods

  • function startBridgeTokensViaAmarokBridge(BridgeData calldata _bridgeData, AmarokData calldata _amarokData)
    • Simply bridges tokens using Amarok BridgeFacet
  • function swapAndStartBridgeTokensViaAmarokBridge(BridgeData memory _bridgeData, SwapData[] calldata _swapData, AmarokData calldata _amarokData)
    • Performs swap(s) before bridging tokens using Amarok BridgeFacet

Amarok Specific Parameters

Some of the methods listed above take a variable labeled _amarokData.

This data is specific to Amarok BridgeFacet and is represented as the following struct type:

/// @param callData The data to execute on the receiving chain. If no crosschain call is needed, then leave empty.
/// @param callTo The address of the contract on dest chain that will receive bridged funds and execute data.
/// @param relayerFee The amount of relayer fee the tx called xcall with.
/// @param slippageTol Max bps of original due to slippage (i.e. would be 9995 to tolerate .05% slippage).
/// @param delegate Destination delegate address.
/// @param destChainDomainId The Amarok-specific domainId of the destination chain.
/// @param payFeeWithSendingAsset Whether to pay the relayer fee with the sending asset or not.
struct AmarokData {
  bytes callData;
  address callTo;
  uint256 relayerFee;
  uint256 slippageTol;
  address delegate;
  uint32 destChainDomainId;
  bool payFeeWithSendingAsset;
}

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 various 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 BridgeData _bridgeData 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. BridgeData 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:

const quoteResult = {
  id: '0x...', // quote id
  type: 'lifi', // the type of the quote (all lifi contract calls have the type "lifi")
  tool: 'amarok', // the bridge tool used for the transaction
  action: {}, // information about what is going to happen
  estimate: {}, // information about the estimated outcome of the call
  includedSteps: [], // steps that are executed by the contract as part of this transaction, e.g. a swap step and a cross step
  transactionRequest: {
    // the transaction that can be sent using a wallet
    data: '0x...',
    to: '0x...',
    value: '0x00',
    from: '{YOUR_WALLET_ADDRESS}',
    chainId: 100,
    gasLimit: '0x...',
    gasPrice: '0x...',
  },
}

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 20 DAI on Ethereum to DAI on Amarok you can execute the following request:

curl 'https://li.quest/v1/quote?fromChain=ETH&fromAmount=20000000000000000000&fromToken=DAI&toChain=AMA&toToken=DAI&slippage=0.03&allowBridges=Amarok&fromAddress={YOUR_WALLET_ADDRESS}'

Swap & Cross

To get a transaction for a transfer from 10 USDT on Ethereum to DAI on Amarok you can execute the following request:

curl 'https://li.quest/v1/quote?fromChain=ETH&fromAmount=10000000&fromToken=USDT&toChain=AMA&toToken=DAI&slippage=0.03&allowBridges=Amarok&fromAddress={YOUR_WALLET_ADDRESS}'