Omnify Docs
  • Welcome
  • Getting Started
    • Introduction
  • Deep Dive
    • OmniTransfers
    • OmniPay
    • OmniTrust
    • OmniBridge
    • OmniEscrow
    • OmniRefuel
  • Resources
    • Github Repo
    • Contract Addresses
    • Contracts Source Codes
    • Contracts Interfaces
    • Omnify Fees
    • Omnify Home
    • Omnify App
    • Omnify Blog
Powered by GitBook
On this page
  • Conduct Transfers
  • ParamTransfer: A single transfer
  • Calculating msgValue based on transfers and their fees
  • Steps to reproduce
  1. Deep Dive

OmniTransfers

PreviousIntroductionNextOmniPay

Last updated 4 months ago

OmniTransfers make possible the execution of multiple ERC20 or native token transfers to multiple recipients in the same transaction. Accesible from and

Conduct Transfers

ParamTransfer: A single transfer

ParamTransfer is the struct contained in the array passed as a parameter to conductTransfers , it represents a single transfer.

struct ParamTransfer {
    address asset; // address of the asset, use address(0) for native token
    uint256 amount; // amount of the asset in wei
    address payable recipient; // address of the recipient
    string id; // your assigned ID of the transfer, should not be a duplicate
}

Calculating msgValue based on transfers and their fees

Steps to reproduce

1

Define OmniTransfers variable

ITransfers99 public omnitransfers = ITransfers99(0x8eAC1C3eD1e78bd373965818816987d525158148); // address on Avalanche C-Chain
2

Define a ParamTransfer[] variable

This will contain all the transfers you wish to conduct.

ITransfers99.ParamTransfer[] memory paramTransfers = new ITransfers99.ParamTransfer[](2); // can be any length
3

Add your transfers as ParamTransfer struct to the paramTransfers array

We use address(0) for the asset if we wish to transfer the native token, and the contract address if the asset is an ERC20 token.

ITransfers99.ParamTransfer nativeTokenTransfer = ITransfers99.ParamTransfer(address(0), 1 * 10**15, address(0x6BF6D002b5140b7CE0A0a4993621ecE52271e5f0), 'ID1');
ITransfers99.ParamTransfer usdcTransfer = ITransfers99.ParamTransfer(address(0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664), 1 * 10**3, address(0x6BF6D002b5140b7CE0A0a4993621ecE52271e5f0), 'ID2');
paramTransfers[0] = nativeTokenTransfer;
paramTransfers[1] = ercTokenTransfer;
4

Get the altcoin & tier fees

Call altcoinFee() and tier1(), tier2(), tier3(), tier4()

5

Define a variable msgVal

This will be the msg.value of the conductTransfers function call.

uint256 public msgVal = 0;
6

Match fee tiers

Run a for loop for the array of ParamTransfer you defined to add transfer values and fee values to msgVal:

    uint256 public msgVal = 0;
    function _matchFeeTier(uint256 _amount) private view returns (TransferFee memory) {
        if (_amount >= tier1.lowerThreshold && _amount <= tier1.higherThreshold) {
            return tier1;
        }
        if (_amount >= tier2.lowerThreshold && _amount <= tier2.higherThreshold) {
            return tier2;
        }
        if (_amount >= tier3.lowerThreshold && _amount <= tier3.higherThreshold) {
            return tier3;
        }
        if (_amount >= tier4.lowerThreshold) {
            return tier4;
        }
        return tier1;
    }

    function _calculateFeeFromTier(TransferFee memory _tier) private pure returns (uint256) {
        return _tier.fee;
    }

    for (uint256 i = 0; i < paramTransfers.length; i++) {
        ParamTransfer memory _t = paramTransfers[i];
        address _asset = _t.asset;
        uint256 _amount = _t.amount;
        if (_asset == address(0)) {
            msgVal += _amount;
            TransferFee memory matchedTier = matchFeeTier(_amount);
            uint256 fee = _calculateFeeFromTier(matchedTier);
            msgVal += fee;
        } else {
            msgVal += altCoinFee;
        }
    }
7

Call conductTransfers

omnitransfers.conductTransfers{value: msgVal}(paramTransfers);

We have conducted our first multisending transaction with OmniTransfers. 🎉

Calling the OmniTransfers contract to conduct a set of transfers is simple. Start by downloading the found in our github repo. Before getting into making a call, let's talk about the conductTransfers payable function which takes ParamTransfer[] as its only parameter, that array can be of any length.

Omnify charges a fee for each transfer it processes, so we need to make sure the total amount of msgValue includes the total value of native tokens being transferred in all the transfers (if any), and total value of fees charged from each transfer. You can find a list of all Omnify services' tiers and fees at .

OmniTransfers interface
omnify.finance/fees
transfer.omnify.finance
app.omnify.finance/transfers
Visualization of how the OmniTransfer contract functions