Skip to content
Verified contractExactMIT

SymbiosisBridgeAdapter

Address0xb1248a5a2b1be2a7fb208505a18b8850a24c277d
Balance

0 ETH

 

Transactions

0

 

Compiler

solc 0.8.30

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 44,444,444 runs
EVM version
osaka
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,982,173
Creation transaction
0x4be1077088…768b94ec10

src/adapters/symbiosis/SymbiosisBridgeAdapter.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

import {IBridgeAdapter} from '../../interfaces/adapters/IBridgeAdapter.sol';
import {
  ISymbiosisBridgeAdapter
} from '../../interfaces/adapters/symbiosis/ISymbiosisBridgeAdapter.sol';

import {BaseBridgeAdapter} from '../BaseBridgeAdapter.sol';

import {IPortal} from '../../vendors/symbiosis/IPortal.sol';
import {MetaSynthesizeTransaction} from '../../vendors/symbiosis/MetaSynthesizeTransaction.sol';

import {TokenHelper} from 'ks-common-sc/src/libraries/token/TokenHelper.sol';

/**
 * @title SymbiosisBridgeAdapter
 * @notice Bridges over Symbiosis by locking the input in a `Portal` and requesting a meta-synthesis.
 * @dev Funds stop at the Portal on this chain. The request travels to Symbiosis' own manager chain,
 * where a synthetic of the locked token is minted, swapped through an Octopool, and burned again to
 * release the real token on the destination — which is why the params carry a second router and a
 * final call as well as a recipient.
 * @dev Only the amount and the token are the adapter's own: it writes what the router actually
 * bridged into the transaction and takes every other field from the quote, so a route stays valid
 * when less arrives than was quoted. Amounts further down the route are patched by Symbiosis itself
 * at `finalOffset`, not here. The Portal takes ERC20 and no value, so native cannot be bridged.
 */
contract SymbiosisBridgeAdapter is BaseBridgeAdapter, ISymbiosisBridgeAdapter {
  using TokenHelper for address;

  /// @inheritdoc IBridgeAdapter
  function bridge(
    address inputToken,
    uint256 inputAmount,
    bytes32, // destinationChainId
    bytes32, // bridgeOutputToken
    bytes calldata bridgeData
  ) external payable onlyDelegateCall returns (bytes memory result) {
    BridgeAdapterParams calldata params;
    assembly ('memory-safe') {
      params := add(bridgeData.offset, calldataload(bridgeData.offset))
    }

    (bool shouldApprove, address portal) = params.portal.unpack();
    if (shouldApprove) {
      inputToken.forceApprove(portal, type(uint256).max);
    }

    MetaSynthesizeTransaction memory transaction = MetaSynthesizeTransaction({
      stableBridgingFee: params.stableBridgingFee,
      amount: inputAmount,
      rtoken: inputToken,
      chain2address: params.chain2address,
      receiveSide: params.receiveSide,
      oppositeBridge: params.oppositeBridge,
      syntCaller: params.syntCaller,
      chainID: params.chainID,
      swapTokens: params.swapTokens,
      secondDexRouter: params.secondDexRouter,
      secondSwapCalldata: params.secondSwapCalldata,
      finalReceiveSide: params.finalReceiveSide,
      finalCalldata: params.finalCalldata,
      finalOffset: params.finalOffset,
      revertableAddress: params.revertableAddress,
      clientID: params.clientID
    });

    return abi.encode(IPortal(portal).metaSynthesize(transaction));
  }
}

lib/ks-common-sc/lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)

pragma solidity >=0.4.16;

import {IERC20} from "../token/ERC20/IERC20.sol";

lib/ks-common-sc/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

lib/ks-common-sc/src/libraries/CustomRevert.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Library for reverting with custom errors efficiently
/// @notice Contains functions for reverting with custom errors with different argument types efficiently
/// @dev To use this library, declare `using CustomRevert for bytes4;` and replace `revert CustomError()` with
/// `CustomError.selector.revertWith()`
/// @dev The functions may tamper with the free memory pointer but it is fine since the call context is exited immediately
library CustomRevert {
  /// @dev ERC-7751 error for wrapping bubbled up reverts
  error WrappedError(address target, bytes4 selector, bytes reason, bytes details);

  /// @dev Reverts with the selector of a custom error in the scratch space
  function revertWith(bytes4 selector) internal pure {
    assembly ('memory-safe') {
      mstore(0, selector)
      revert(0, 0x04)
    }
  }

  /// @dev Reverts with a custom error with an address argument in the scratch space
  function revertWith(bytes4 selector, address addr) internal pure {
    assembly ('memory-safe') {
      mstore(0, selector)
      mstore(0x04, and(addr, 0xffffffffffffffffffffffffffffffffffffffff))
      revert(0, 0x24)
    }
  }

  /// @dev Reverts with a custom error with an int24 argument in the scratch space
  function revertWith(bytes4 selector, int24 value) internal pure {
    assembly ('memory-safe') {
      mstore(0, selector)
      mstore(0x04, signextend(2, value))
      revert(0, 0x24)
    }
  }

  /// @dev Reverts with a custom error with a uint160 argument in the scratch space
  function revertWith(bytes4 selector, uint160 value) internal pure {
    assembly ('memory-safe') {
      mstore(0, selector)
      mstore(0x04, and(value, 0xffffffffffffffffffffffffffffffffffffffff))
      revert(0, 0x24)
    }
  }

  /// @dev Reverts with a custom error with two int24 arguments
  function revertWith(bytes4 selector, int24 value1, int24 value2) internal pure {
    assembly ('memory-safe') {
      let fmp := mload(0x40)
      mstore(fmp, selector)
      mstore(add(fmp, 0x04), signextend(2, value1))
      mstore(add(fmp, 0x24), signextend(2, value2))
      revert(fmp, 0x44)
    }
  }

  /// @dev Reverts with a custom error with two uint160 arguments
  function revertWith(bytes4 selector, uint160 value1, uint160 value2) internal pure {
    assembly ('memory-safe') {
      let fmp := mload(0x40)
      mstore(fmp, selector)
      mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
      mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
      revert(fmp, 0x44)
    }
  }

  /// @dev Reverts with a custom error with two address arguments
  function revertWith(bytes4 selector, address value1, address value2) internal pure {
    assembly ('memory-safe') {
      let fmp := mload(0x40)
      mstore(fmp, selector)
      mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
      mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
      revert(fmp, 0x44)
    }
  }

  /// @notice bubble up the revert message returned by a call and revert with a wrapped ERC-7751 error
  /// @dev this method can be vulnerable to revert data bombs
  function bubbleUpAndRevertWith(
    address revertingContract,
    bytes4 revertingFunctionSelector,
    bytes4 additionalContext
  ) internal pure {
    bytes4 wrappedErrorSelector = WrappedError.selector;
    assembly ('memory-safe') {
      // Ensure the size of the revert data is a multiple of 32 bytes
      let encodedDataSize := mul(div(add(returndatasize(), 31), 32), 32)

      let fmp := mload(0x40)

      // Encode wrapped error selector, address, function selector, offset, additional context, size, revert reason
      mstore(fmp, wrappedErrorSelector)
      mstore(add(fmp, 0x04), and(revertingContract, 0xffffffffffffffffffffffffffffffffffffffff))
      mstore(
        add(fmp, 0x24),
        and(
          revertingFunctionSelector,
          0xffffffff00000000000000000000000000000000000000000000000000000000
        )
      )
      // offset revert reason
      mstore(add(fmp, 0x44), 0x80)
      // offset additional context
      mstore(add(fmp, 0x64), add(0xa0, encodedDataSize))
      // size revert reason
      mstore(add(fmp, 0x84), returndatasize())
      // revert reason
      returndatacopy(add(fmp, 0xa4), 0, returndatasize())
      // size additional context
      mstore(add(fmp, add(0xa4, encodedDataSize)), 0x04)
      // additional context
      mstore(
        add(fmp, add(0xc4, encodedDataSize)),
        and(additionalContext, 0xffffffff00000000000000000000000000000000000000000000000000000000)
      )
      revert(fmp, add(0xe4, encodedDataSize))
    }
  }
}

lib/ks-common-sc/src/libraries/token/TokenHelper.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {CustomRevert} from '../CustomRevert.sol';

import {IERC20} from 'openzeppelin-contracts/contracts/interfaces/IERC20.sol';

/// @title Library for transferring, approving and holding native tokens and ERC20 tokens
/// @dev This library is based on CurrencyLibrary.sol from Uniswap/v4-core and SafeTransferLib.sol from transmissions11/solmate
library TokenHelper {
  /// @notice Additional context for ERC-7751 wrapped error when a native transfer fails
  error NativeTransferFailed();

  /// @notice Additional context for ERC-7751 wrapped error when an ERC20 transfer fails
  error ERC20TransferFailed();

  /// @notice Additional context for ERC-7751 wrapped error when an ERC20 approve fails
  error ERC20ApproveFailed();

  address internal constant NATIVE_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

  function isNative(address token) internal pure returns (bool) {
    return token == NATIVE_ADDRESS || token == address(0);
  }

  function safeTransferNative(address to, uint256 amount) internal {
    if (amount == 0) return;

    bool success;
    assembly ('memory-safe') {
      // Transfer the ETH and revert if it fails.
      success := call(gas(), to, amount, 0, 0, 0, 0)
    }
    // revert with NativeTransferFailed, containing the bubbled up error as an argument
    if (!success) {
      CustomRevert.bubbleUpAndRevertWith(to, bytes4(0), NativeTransferFailed.selector);
    }
  }

  function safeTransferERC20(address token, address to, uint256 amount) internal {
    if (amount == 0) return;

    bool success;
    assembly ('memory-safe') {
      // Get a pointer to some free memory.
      let fmp := mload(0x40)

      // Write the abi-encoded calldata into memory, beginning with the function selector.
      mstore(fmp, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
      mstore(add(fmp, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
      mstore(add(fmp, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

      success := and(
        // Set success to whether the call reverted, if not we check it either
        // returned exactly 1 (can't just be non-zero data), or had no return data.
        or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
        // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
        // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
        // Counterintuitively, this call must be positioned second to the or() call in the
        // surrounding and() call or else returndatasize() will be zero during the computation.
        call(gas(), token, 0, fmp, 68, 0, 32)
      )

      // Now clean the memory we used
      mstore(fmp, 0) // 4 byte `selector` and 28 bytes of `to` were stored here
      mstore(add(fmp, 0x20), 0) // 4 bytes of `to` and 28 bytes of `amount` were stored here
      mstore(add(fmp, 0x40), 0) // 4 bytes of `amount` were stored here
    }
    // revert with ERC20TransferFailed, containing the bubbled up error as an argument
    if (!success) {
      CustomRevert.bubbleUpAndRevertWith(
        token, IERC20.transfer.selector, ERC20TransferFailed.selector
      );
    }
  }

  function safeTransfer(address token, address to, uint256 amount) internal {
    if (isNative(token)) {
      safeTransferNative(to, amount);
    } else {
      safeTransferERC20(token, to, amount);
    }
  }

  function safeTransferFrom(address token, address from, address to, uint256 amount) internal {
    if (amount == 0) return;

    bool success;
    assembly ('memory-safe') {
      // Get a pointer to some free memory.
      let fmp := mload(0x40)

      // Write the abi-encoded calldata into memory, beginning with the function selector.
      mstore(fmp, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
      mstore(add(fmp, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument.
      mstore(add(fmp, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
      mstore(add(fmp, 68), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

      success := and(
        // Set success to whether the call reverted, if not we check it either
        // returned exactly 1 (can't just be non-zero data), or had no return data.
        or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
        // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
        // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
        // Counterintuitively, this call must be positioned second to the or() call in the
        // surrounding and() call or else returndatasize() will be zero during the computation.
        call(gas(), token, 0, fmp, 100, 0, 32)
      )

      // Now clean the memory we used
      mstore(fmp, 0) // 4 byte `selector` and 28 bytes of `from` were stored here
      mstore(add(fmp, 0x20), 0) // 4 bytes of `from` and 28 bytes of `to` were stored here
      mstore(add(fmp, 0x40), 0) // 4 bytes of `to` and 28 bytes of `amount` were stored here
      mstore(add(fmp, 0x60), 0) // 4 bytes of `amount` were stored here
    }
    // revert with ERC20TransferFailed, containing the bubbled up error as an argument
    if (!success) {
      CustomRevert.bubbleUpAndRevertWith(
        token, IERC20.transferFrom.selector, ERC20TransferFailed.selector
      );
    }
  }

  function trySafeApprove(address token, address spender, uint256 amount)
    internal
    returns (bool success)
  {
    assembly ('memory-safe') {
      // Get a pointer to some free memory.
      let fmp := mload(0x40)

      // Write the abi-encoded calldata into memory, beginning with the function selector.
      mstore(fmp, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
      mstore(add(fmp, 4), and(spender, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "spender" argument.
      mstore(add(fmp, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

      success := and(
        // Set success to whether the call reverted, if not we check it either
        // returned exactly 1 (can't just be non-zero data), or had no return data.
        or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
        // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
        // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
        // Counterintuitively, this call must be positioned second to the or() call in the
        // surrounding and() call or else returndatasize() will be zero during the computation.
        call(gas(), token, 0, fmp, 68, 0, 32)
      )

      // Now clean the memory we used
      mstore(fmp, 0) // 4 byte `selector` and 28 bytes of `to` were stored here
      mstore(add(fmp, 0x20), 0) // 4 bytes of `to` and 28 bytes of `amount` were stored here
      mstore(add(fmp, 0x40), 0) // 4 bytes of `amount` were stored here
    }
  }

  function safeApprove(address token, address spender, uint256 amount) internal {
    // revert with ERC20ApproveFailed, containing the bubbled up error as an argument
    if (!trySafeApprove(token, spender, amount)) {
      CustomRevert.bubbleUpAndRevertWith(
        token, IERC20.approve.selector, ERC20ApproveFailed.selector
      );
    }
  }

  function forceApprove(address token, address spender, uint256 amount) internal {
    // meant to be used with tokens that require the approval to be set to zero before setting it to a non-zero value, such as USDT
    if (!trySafeApprove(token, spender, amount)) {
      safeApprove(token, spender, 0);
      safeApprove(token, spender, amount);
    }
  }

  function balanceOf(address token, address account) internal view returns (uint256) {
    if (isNative(token)) {
      return account.balance;
    } else {
      return IERC20(token).balanceOf(account);
    }
  }

  function selfBalance(address token) internal view returns (uint256) {
    if (isNative(token)) {
      return address(this).balance;
    } else {
      return IERC20(token).balanceOf(address(this));
    }
  }
}

src/adapters/BaseBridgeAdapter.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IBridgeAdapter} from '../interfaces/adapters/IBridgeAdapter.sol';

/**
 * @title BaseBridgeAdapter
 * @notice Base for adapters that run inside a router's context.
 * @dev Records its own deployment address at construction so `onlyDelegateCall` can tell the two
 * apart: reached by `delegatecall`, `address(this)` is the router's, not this one's. An adapter
 * that must keep storage or an identity of its own cannot use this — see `BridgeForwarder`.
 */
abstract contract BaseBridgeAdapter is IBridgeAdapter {
  address internal immutable original;

  constructor() {
    original = address(this);
  }

  modifier onlyDelegateCall() {
    if (original == address(this)) {
      revert NotDelegateCall();
    }
    _;
  }
}

src/interfaces/adapters/IBridgeAdapter.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title IBridgeAdapter
 * @notice Common entry point every bridge adapter exposes to the routers.
 */
interface IBridgeAdapter {
  /// @notice Thrown when the function is not called via delegate call.
  error NotDelegateCall();

  /**
   * @notice Bridges the tokens.
   * @param inputToken The address of the input token.
   * @param inputAmount The amount of the input token.
   * @param destinationChainId The ID of the destination chain.
   * @param bridgeOutputToken The address of the bridge output token.
   * @param bridgeData The data for the bridge operation.
   * @return result The result of the bridge operation.
   */
  function bridge(
    address inputToken,
    uint256 inputAmount,
    bytes32 destinationChainId,
    bytes32 bridgeOutputToken,
    bytes calldata bridgeData
  ) external payable returns (bytes memory result);
}

src/interfaces/adapters/symbiosis/ISymbiosisBridgeAdapter.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {BoolAddress} from '../../../types/BoolAddress.sol';

/**
 * @title ISymbiosisBridgeAdapter
 * @notice Interface of the adapter bridging over Symbiosis.
 */
interface ISymbiosisBridgeAdapter {
  /**
   * @notice Parameters for bridging via Symbiosis.
   * @dev Everything the quote fixed. The amount and the token are not here: the adapter takes
   * those from what the router is actually bridging.
   * @param portal The address of the Symbiosis Portal, and whether to approve it for spending the
   * input token.
   * @notice The rest of the parameters are described in `MetaSynthesizeTransaction`.
   */
  struct BridgeAdapterParams {
    BoolAddress portal;
    uint256 stableBridgingFee;
    address chain2address;
    address receiveSide;
    address oppositeBridge;
    address syntCaller;
    uint256 chainID;
    address[] swapTokens;
    address secondDexRouter;
    bytes secondSwapCalldata;
    address finalReceiveSide;
    bytes finalCalldata;
    uint256 finalOffset;
    address revertableAddress;
    bytes32 clientID;
  }
}

src/libraries/BitMask.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

uint256 constant MASK_1_BIT = 0x1;
uint256 constant MASK_8_BITS = 0xff;
uint256 constant MASK_24_BITS = 0xffffff;
uint256 constant MASK_127_BITS = 0x7fffffffffffffffffffffffffffffff;
uint256 constant MASK_128_BITS = 0xffffffffffffffffffffffffffffffff;
uint160 constant MASK_160_BITS = 0x00ffffffffffffffffffffffffffffffffffffffff;

src/types/BoolAddress.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {MASK_160_BITS} from '../libraries/BitMask.sol';

/**
 * @notice BoolAddress is packed version of solidity structure.
 *
 * Layout: 1 bit boolean value | 160 bits address value
 */
type BoolAddress is uint256;

using BoolAddressLibrary for BoolAddress global;

function toBoolAddress(bool boolValue, address addressValue) pure returns (BoolAddress result) {
  assembly ('memory-safe') {
    result := or(shl(160, boolValue), addressValue)
  }
}

/**
 * @title BoolAddressLibrary
 * @notice Accessors for the packed {BoolAddress} type.
 */
library BoolAddressLibrary {
  uint256 internal constant BOOL_VALUE_OFFSET = 160;

  function boolValue(BoolAddress self) internal pure returns (bool _boolValue) {
    assembly ('memory-safe') {
      _boolValue := shr(BOOL_VALUE_OFFSET, self)
    }
  }

  function addressValue(BoolAddress self) internal pure returns (address _addressValue) {
    assembly ('memory-safe') {
      _addressValue := and(self, MASK_160_BITS)
    }
  }

  function unpack(BoolAddress self) internal pure returns (bool _boolValue, address _addressValue) {
    assembly ('memory-safe') {
      _boolValue := shr(BOOL_VALUE_OFFSET, self)
      _addressValue := and(self, MASK_160_BITS)
    }
  }
}

src/vendors/symbiosis/IPortal.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import {MetaSynthesizeTransaction} from './MetaSynthesizeTransaction.sol';

/**
 * @title IPortal
 * @notice The part of Symbiosis' `Portal` a bridge adapter needs.
 * @dev The Portal is the source-chain custodian: it holds the real token while its synthetic is in
 * circulation, and releases it again when that synthetic is burned.
 */
interface IPortal {
  /**
   * @notice Locks the real token and requests its synthesis on the manager chain.
   * @param transaction The request, described in `MetaSynthesizeTransaction`.
   * @return The id of the request, which is what the relayer network tracks it by.
   * @dev Pulls `transaction.amount` of `transaction.rtoken` from the caller, so the Portal has to
   * be approved for it first. Takes no value: the relayer fee is charged in the token itself.
   */
  function metaSynthesize(MetaSynthesizeTransaction memory transaction) external returns (bytes32);
}

src/vendors/symbiosis/MetaSynthesizeTransaction.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @notice A request to lock a real token in a `Portal` and mint its synthetic on the manager chain.
 * @dev Carries the whole onward route with it: the Octopool swap to run once the synthetic exists,
 * and the call that burns it again to release the real token on the destination chain.
 * @param stableBridgingFee The fee taken by the relayers network, denominated in `rtoken`.
 * @param amount The amount of `rtoken` pulled from the caller.
 * @param rtoken The real token locked in the Portal.
 * @param chain2address The recipient on the destination chain.
 * @param receiveSide The Synthesis contract on the manager chain.
 * @param oppositeBridge The Bridge contract on the manager chain.
 * @param syntCaller The account credited as the initiator of the request.
 * @param chainID The chain id of the manager chain.
 * @param swapTokens The token path of the Octopool swap performed on the manager chain.
 * @param secondDexRouter The router the Octopool swap is executed on.
 * @param secondSwapCalldata The Octopool swap performed on the manager chain.
 * @param finalReceiveSide The contract called on the manager chain after the Octopool swap.
 * @param finalCalldata The call performed on `finalReceiveSide`, typically the burn that releases
 * the tokens on the destination chain.
 * @param finalOffset The offset at which Symbiosis patches the amount into `finalCalldata`.
 * @param revertableAddress The address allowed to revert a stuck request.
 * @param clientID The integrator identifier.
 */
struct MetaSynthesizeTransaction {
  uint256 stableBridgingFee;
  uint256 amount;
  address rtoken;
  address chain2address;
  address receiveSide;
  address oppositeBridge;
  address syntCaller;
  uint256 chainID;
  address[] swapTokens;
  address secondDexRouter;
  bytes secondSwapCalldata;
  address finalReceiveSide;
  bytes finalCalldata;
  uint256 finalOffset;
  address revertableAddress;
  bytes32 clientID;
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 44444444,
    "enabled": true
  },
  "evmVersion": "osaka",
  "remappings": [
    "forge-std/=lib/ks-common-sc/lib/forge-std/src/",
    "hardhat/=node_modules/hardhat/",
    "ks-common-sc/=lib/ks-common-sc/",
    "ks-allowance-hub/=lib/ks-allowance-hub/",
    "openzeppelin-contracts/=lib/ks-common-sc/lib/openzeppelin-contracts/",
    "@openzeppelin/contracts/=lib/ks-common-sc/lib/openzeppelin-contracts/contracts/",
    "erc4626-tests/=lib/ks-common-sc/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/ks-common-sc/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.