Smart Contract Integration

Integrate syrupUSDC & syrupUSDT via smart contracts on Ethereum mainnet. Your contracts must deposit through SyrupRouter with authorization handled PoolPermissionManager.

circle-info

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. SyrupRouter Interface

Below are the primary functions exposed by SyrupRouter for integrators. These mirror the onchain interface and are stable entry points for deposits:

Notes for implementers:

  • Authorization signature: For first-time deposits, Maple (a permission admin) provides an ECDSA signature authorizing the lender’s bitmap permissions. The signature digest includes chainId, the SyrupRouter address, the owner (msg.sender), a nonce, the bitmap, and deadline. Your smart contract should pass this signature through to authorizeAndDeposit/authorizeAndDepositWithPermit.

  • Permissions: The router enforces PoolPermissionManager.hasPermission(poolManager, owner, "P:deposit"). Your address must be permissioned (via allowlist or bitmaps) before deposits succeed.

  • Deposit metadata: depositData is a bytes32 field emitted via DepositData for off-chain correlation (e.g., internal IDs). Use a pre-hashed value if longer than 32 bytes.

  • Gas optimization: Prefer depositWithPermit where the asset supports EIP‑2612 to avoid a separate approval step.

3. Syrup Addresses

All ABIs are available on GitHub: Maple JS (ABIs)arrow-up-right

3. Testing on Sepolia

Contact [email protected]envelope 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.

Onchain permission checks are equivalent to a bitmap AND comparison. A lender is authorized for a function if all required bits in the pool’s bitmap are present in the lender’s bitmap:

  • Condition: (poolBitmap & lenderBitmap) == poolBitmap

Example (optional introspection, prefer hasPermission in production):

Mainnet PoolPermissionManager (for reference): 0xBe10aDcE8B6E3E02Db384E7FaDA5395DD113D8b3

2. Retrieve Authorization Signature

If not authorized, contact [email protected]envelope 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):

circle-info

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

2. Calculate Shares to Redeem

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

3. Execute the Withdrawal

Submit a withdrawal request to the pool.

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

chevron-rightWhy must deposits go through SyrupRouter?hashtag

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

chevron-rightWhat is depositData and who provides it?hashtag

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

chevron-rightHow do I verify lender authorization onchain?hashtag

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

chevron-rightDo I need authorization for smart contract integration?hashtag

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]envelope 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.

chevron-rightHow do withdrawals work?hashtag

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

chevron-rightHow long do withdrawals take?hashtag

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 pagearrow-up-right.

chevron-rightHow can I get the APY data for syrupUSDC or syrupUSDT?hashtag

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

Example request

This returns

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

chevron-rightHow can I get the price received on redemption for syrupUSDC or syrupUSDT?hashtag

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

This returns

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

Last updated

Was this helpful?