🇺🇲
Protocolink
  • 🔮Overview
  • 🌟Why Protocolink?
  • 💡Use Cases
    • Flash Loans
    • Permit2 Amplifier
    • Zap-in & Zap-out
    • Position Management
    • Multi-Action Bundling
  • 📋Networks & Protocols
  • 🛡️Security & Audits
  • 💎Fees
  • ❓FAQ
  • Protocolink API
    • 🔮Overview
      • Swap & Supply (Example)
    • 📗Swagger
      • Request Protocols
      • Request Tokens
      • Request Quote
      • Estimate Logics Result
      • Request Transaction Data
  • Protocolink SDK
    • 🔮Overview
    • 1️⃣Install SDK
    • 2️⃣Build Logics
    • 3️⃣Estimate Router Data
    • 4️⃣Send Router Transaction
    • ⚒️API SDK Interfaces
      • Global Types
      • FlashLoan Logic
      • Aave V2
      • Aave V3
      • Balancer V2
      • Compound V3
      • Iolend
      • Magicsea
      • Morphoblue
      • OpenOcean V2
      • ParaSwap V5
      • Permit2
      • Spark
      • Stargate
      • Stargate V2
      • SyncSwap
      • Uniswap V3
      • Utility
      • Wagmi
      • ZeroEx V4
    • ⚒️Common SDK Interfaces
      • Constants
      • Network
      • Token
      • Web3Toolkit
      • Utility Functions
  • Lending SDK
    • 🔮Overview
    • ✳️SDK
      • Open By Collateral
      • Open By Debt
      • Close
      • Leverage By Collateral
      • Leverage By Debt
      • Deleverage
      • Collateral swap
      • Debt swap
      • Zap supply
      • Zap withdraw
      • Zap repay
      • Zap borrow
  • Smart Contract
    • 🔮Overview
      • Router
      • Agent
      • Callback
      • Fees
      • Utility
      • Data Type
      • ERC721/ERC1155 Support
    • 📑Deployment Addresses
    • 🧑‍💻Security Review Details
  • COMPOUND KIT
    • 🔮Overview
    • ✳️SDK
      • Leverage
      • Deleverage
      • Collateral Swap
      • Zap Supply
      • Zap Withdraw
      • Zap Repay
      • Zap Borrow
    • 📗API
  • Video Tutorials
    • 1. Introducing Protocolink
    • 2. Lending SDK
    • 3. Protocolink Q&A
  • Social medias
    • Twitter
  • Support
Powered by GitBook
On this page
  • On-Chain Fee
  • Off-Chain Fee
  1. Smart Contract
  2. Overview

Fees

Protocolink charges fees based on the token amount and transaction type

PreviousCallbackNextUtility

Last updated 1 year ago

This page explains the fee mechanism in the Protocolink contracts. The overview fee structure can be found at .

Protocolink calculates the fees on-chain or off-chain depending on the user called function. When users call the Protocolink contract directly (e.g., ), Protocolink calculates the fees on-chain. When users call the Protocolink contract with API data (e.g., ), Protocolink charges the off-chain fee.

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 function, and for native tokens, the on-chain fee is charged in the 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 .

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);
}
🔮
_doPermit2()
_chargeByMsgValue()
AaveV3FlashloanCallback
Execute Transactions
Execute Transactions with API Data
Fee Structure