Smart Contract Integrations
Integrate syrupUSDC & syrupUSDT via smart contracts. Lenders (your smart contracts) must deposit through SyrupRouter with authorization handled by PoolPermissionManager.
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:
// Events
event DepositData(address indexed owner, uint256 amount, bytes32 depositData);
// Views
function asset() external view returns (address);
function pool() external view returns (address);
function poolManager() external view returns (address);
function poolPermissionManager() external view returns (address);
function nonces(address owner) external view returns (uint256);
// First-time (with authorization signature)
function authorizeAndDeposit(
uint256 bitmap,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s,
uint256 amount,
bytes32 depositData
) external returns (uint256 shares);
// First-time with ERC-2612 token permit
function authorizeAndDepositWithPermit(
uint256 bitmap,
uint256 authDeadline,
uint8 authV,
bytes32 authR,
bytes32 authS,
uint256 amount,
bytes32 depositData,
uint256 permitDeadline,
uint8 permitV,
bytes32 permitR,
bytes32 permitS
) external returns (uint256 shares);
// Subsequent deposits (already authorized)
function deposit(uint256 amount, bytes32 depositData) external returns (uint256 shares);
function depositWithPermit(
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s,
bytes32 depositData
) external returns (uint256 shares);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, theSyrupRouteraddress, theowner(msg.sender), anonce, thebitmap, anddeadline. Your smart contract should pass this signature through toauthorizeAndDeposit/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:
depositDatais abytes32field emitted viaDepositDatafor off-chain correlation (e.g., internal IDs). Use a pre-hashed value if longer than 32 bytes.Gas optimization: Prefer
depositWithPermitwhere the asset supports EIP‑2612 to avoid a separate approval step.
3. Syrup Addresses
All ABIs are available on GitHub: Maple JS (ABIs)
syrupUSDC
SyrupRouter
WithdrawalManagerQueue
syrupUSDT
SyrupRouter
WithdrawalManagerQueue
Shared (Global)
PoolPermissionManager
syrupUSDC
SyrupRouter
WithdrawalManagerQueue
syrupUSDT
SyrupRouter
WithdrawalManagerQueue
Shared (Global)
PoolPermissionManager
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.
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] to obtain:
bitmap,deadline,v,r,sdepositData- conventionally"0:<integrator-name>", encoded asbytes32. Keep within 32 bytes when hex-encoded.
3. Execute the Deposit
Minimal SC calls (lender must hold sufficient USDC/USDT):
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
authorizeAndDepositwith signatureInsufficient allowance → call
approve(router, amount)before depositing
FAQ
Last updated