Fees

Protocolink charges fees based on the token amount and transaction type

On-Chain Fee

If users call the Router contract without the API data, Protocolink will calculate and charge the on-chain fee in the execute() function. The on-chain fee is charged from the token amounts transferred in the transaction. For ERC-20 tokens, the on-chain fee is charged in the _doPermit2() function, and for native tokens, the on-chain fee is charged in the _chargeByMsgValue() function. Protocolink charges the fee from the Agent.

function execute(
    bytes[] calldata permit2Datas,
    DataType.Logic[] calldata logics,
    address[] calldata tokensReturn
) external payable {
    if (msg.sender != router) revert NotRouter();
    _doPermit2(permit2Datas, true);
    _chargeByMsgValue();
    _executeLogics(logics, true);
    _returnTokens(tokensReturn);
}

Protocolink also charges the flash loan fee before returning the control flow back to flash loan services. You can find out more details in the AaveV3FlashloanCallback.

Off-Chain Fee

If users call the Router contract with API data, Protocolink will charge the off-chain fee in the executeWithSignerFee() function. The fees are calculated in Protocolink's API server off-chain and are charged by token types. If the token is an ERC-20 token, the fee is charged from the user address. If the token is a native token, the fee is charged from the Agent address.

function executeWithSignerFee(
    bytes[] calldata permit2Datas,
    DataType.Logic[] calldata logics,
    DataType.Fee[] calldata fees,
    bytes32[] calldata referrals,
    address[] calldata tokensReturn
) external payable {
    if (msg.sender != router) revert NotRouter();
    _doPermit2(permit2Datas, false);
    for (uint256 i; i < referrals.length; ) {
        _charge(fees, referrals[i], false);
        unchecked {
            ++i;
        }
    }
    _executeLogics(logics, false);
    _returnTokens(tokensReturn);
}

Last updated