Smart Contract Integrations

Integrate syrupUSDC & syrupUSDT via smart contracts. Lenders (your smart contracts) must deposit through SyrupRouter with authorization handled by PoolPermissionManager.

Step-by-step

Deposit:

  1. Determine lender authorization (onchain via PoolPermissionManager)

  2. Execute the deposit (authorize-and-deposit or deposit)

Withdraw:

  1. Calculate shares to redeem (full balance or convertToExitShares for partial)

  2. Execute the withdrawal (requestRedeem)

Overview

1. Syrup Protocol Overview

Smart contracts integrating with syrupUSDC & syrupUSDT act as lenders and must interact via SyrupRouter. Authorization is enforced by PoolPermissionManager. First-time deposits require an authorization signature; subsequent deposits can call deposit directly once authorized.

2. Syrup Addresses

All ABIs are available on GitHub: Maple JS (ABIs)

3. Testing on Sepolia

Contact [email protected] for test USDC/USDT and access. See the Sepolia tab above for addresses.


Deposit

1. Determine Lender Authorization (onchain)

Use PoolPermissionManager to verify lender authorization for a specific pool. You can derive the manager onchain from the Pool.

interface IPool { function manager() external view returns (address); }
interface IPoolManager { function poolPermissionManager() external view returns (address); }
interface IPoolPermissionManager {
    function lenderBitmaps(address lender) external view returns (uint256);
    function poolBitmaps(address pool) external view returns (uint256);
}

function getPoolPermissionManager(address pool) internal view returns (address) {
    address manager = IPool(pool).manager();
    return IPoolManager(manager).poolPermissionManager();
}

function isAuthorized(address pool, address lender) internal view returns (bool) {
    address ppm = getPoolPermissionManager(pool);
    uint256 lenderBitmap = IPoolPermissionManager(ppm).lenderBitmaps(lender);
    uint256 poolBitmap   = IPoolPermissionManager(ppm).poolBitmaps(pool);
    // Authorized if XOR equals the pool bitmap
    return (lenderBitmap ^ poolBitmap) == poolBitmap;
}

Mainnet PoolPermissionManager (for reference): 0xBe10aDcE8B6E3E02Db384E7FaDA5395DD113D8b3

2. Retrieve Authorization Signature

If not authorized, contact [email protected] to obtain:

  • bitmap, deadline, v, r, s

  • depositData - conventionally "0:<integrator-name>", encoded as bytes32. Keep within 32 bytes when hex-encoded.

3. Execute the Deposit

Minimal SC calls (lender must hold sufficient USDC/USDT):

interface IERC20 { function approve(address spender, uint256 amount) external returns (bool); }
interface ISyrupRouter {
    function deposit(uint256 amount, bytes32 depositData) external returns (uint256 shares);
    function authorizeAndDeposit(
        uint256 bitmap,
        uint256 deadline,
        uint8   v,
        bytes32 r,
        bytes32 s,
        uint256 amount,
        bytes32 depositData
    ) external returns (uint256 shares);
}

function depositAuthorized(
    address asset,
    address router,
    uint256 amount,
    bytes32 depositData
) external {
    IERC20(asset).approve(router, amount);
    ISyrupRouter(router).deposit(amount, depositData);
}

function authorizeAndDeposit(
    address asset,
    address router,
    uint256 amount,
    bytes32 depositData,
    uint256 bitmap,
    uint256 deadline,
    uint8   v,
    bytes32 r,
    bytes32 s
) external {
    IERC20(asset).approve(router, amount);
    ISyrupRouter(router).authorizeAndDeposit(bitmap, deadline, v, r, s, amount, depositData);
}

Deposit data

  • Replace 0:<integrator-name> with your integrator identifier (e.g. 0:acme-protocol).

  • Maple will provide the final depositData for production.

  • Must be passed as bytes32 (32-byte hex).


Withdraw

1. Retrieve Lender’s Balance

interface IPool {
    function balanceOf(address account) external view returns (uint256);
    function convertToExitAssets(uint256 shares) external view returns (uint256);
}

function getLenderPosition(address pool, address lender) external view returns (uint256 shares, uint256 exitAssets) {
    shares     = IPool(pool).balanceOf(lender);
    exitAssets = IPool(pool).convertToExitAssets(shares);
}

2. Calculate Shares to Redeem

Use full balance for full redemption, or compute shares for a specific asset amount.

interface IPool { function convertToExitShares(uint256 assets) external view returns (uint256); }

function sharesForAssets(address pool, uint256 assetAmount) external view returns (uint256) {
    return IPool(pool).convertToExitShares(assetAmount);
}

3. Execute the Withdrawal

Submit a withdrawal request to the pool.

interface IPool { function requestRedeem(uint256 shares, address receiver) external returns (uint256); }

function requestWithdrawal(address pool, uint256 shares, address receiver) external {
    IPool(pool).requestRedeem(shares, receiver);
}

Withdrawals are processed automatically by Maple. If there is sufficient liquidity in the pool, the withdrawal will be processed within a few minutes. Expected processing time is typically less than 2 days, but it can take up to 30 days depending on available liquidity.


Edge Cases

  • Not authorized → use authorizeAndDeposit with signature

  • Insufficient allowance → call approve(router, amount) before depositing


FAQ

Why must deposits go through SyrupRouter?

Authorization and routing are enforced via `SyrupRouter` and `PoolPermissionManager`. This ensures only authorized lenders can deposit.

What is depositData and who provides it?

`depositData` is provided by Maple. It typically follows `0:` and your company name. It must be provided as a `bytes32` value (32-byte hex).

How do I verify lender authorization onchain?

Read lenderBitmaps(lender) and poolBitmaps(pool) in PoolPermissionManager and check (lenderBitmap ^ poolBitmap) == poolBitmap.

Do I need authorization for smart contract integration?

Yes, authorization is required for all Syrup deposits. Syrup protocol is built by Maple, which uses a permissioning system for institutional-grade security.

Authorization Process

  1. Contact us at [email protected] for eligibility verification

  2. Receive authorization signature parameters

  3. Use authorizeAndDeposit or authorizeAndDepositWithPermit for first deposit

  4. Subsequent deposits only need deposit or depositWithPermit

Once authorized, the permission persists across all Syrup pools and future deposits.

How do withdrawals work?

Withdrawals follow a queue-based system:

  1. Request: Call requestRedeem() to enter the withdrawal queue

  2. Queue Position: Withdrawals are processed first-in, first-out (FIFO)

  3. Processing: When pool liquidity is available, withdrawals are automatically processed

  4. Completion: Assets are sent directly to the wallet (no additional transaction required)

Timeline

  • Expected processing time is typically less than 2 days

  • During low liquidity periods, it may take up to 30 days

  • No penalties for withdrawing, but yield stops accumulating once withdrawal is requested

How long do withdrawals take?

syrupUSDC & syrupUSDT normally have instant liquidity, but in rare cases withdrawals can take around 24h with the maximum possible time being 30 days. You can see the available funds to withdraw in the Liquidity section of the Details page.

How can I get the APY data for syrupUSDC or syrupUSDT?

Querying the GraphQL API is the simplest way to get APY data for syrupUSDC or syrupUSDT into your app.

Example request

{
  poolV2(id: "0x80ac24aa929eaf5013f6436cda2a7ba190f5cc0b") {
    name
    weeklyApy
    monthlyApy
  }
  syrupGlobals {
    dripsYieldBoost
  }
}

This returns

{
  "data": {
    "poolV2": {
      "name": "Syrup USDC",
      "weeklyApy": "69937809610000000000000000000",
      "monthlyApy": "67212806350000000000000000000"
    },
    "syrupGlobals": {
      "apy": "69731920498003078965054825961",
      "dripsYieldBoost": "22000"
    }
  }
}

In the example above, the monthly base APY is 6.72% with the Drips rewards adding an extra 2.2% on top.

How can I get the price received on redemption for syrupUSDC or syrupUSDT?

syrupUSDC and syrupUSDT are redeemed at the smart contract exchange rate at the point of processing the withdrawal, incurring no slippage.

You can get the spot exchange rate for syrupUSDC to USDC or syrupUSDT to USDT by querying the GraphQL API.

Example request

{
  account(id: "0xyourwallet") {
    poolV2Positions {
      pool {
        asset {
          symbol
          decimals
        }
        id
        name
      }
      lendingBalance
      totalShares
    }
  }
}

This returns

{
  "data": {
    "account": {
      "poolV2Positions": [
        {
          "pool": {
            "asset": {
              "symbol": "USDC",
              "decimals": 6
            },
            "id": "0x80ac24aa929eaf5013f6436cda2a7ba190f5cc0b",
            "name": "Syrup USDC"
          },
          "lendingBalance": "3102053352414",
          "totalShares": "2742550894631"
        }
      ]
    }
  }
}

The ratio of lendingBalance / totalShares is the spot exchange rate.

Last updated