Backend Integrations
Enable your users to deposit into syrupUSDC & syrupUSDT through your own app. Manage deposits programmatically. For wallets, exchanges, custody solutions etc.
SDK and GraphQL API
All necessary ABIs and addresses are available in the Maple SDK or via GitHub:
Within the SDK, both ABIs and network-specific addresses are accessible. The package can also be installed and used within applications.
To access the necessary data, use the GraphQL API:
https://api.maple.finance/v2/graphql
https://sepolia.api.maple.finance/v2/graphql
NOTE: In order to perform the integration in Sepolia, you'll need to contact us at [email protected] to receive Sepolia USDC/USDT tokens.
Deposit
1. Query the Maple API
Syrup's main contract, the SyrupRouter, is designed to allow authorized participants to securely access the yields available in the Maple ecosystem, abstracting all the complexity of the permissioning system. Each Syrup PoolV2 has an associated SyrupRouter.
syrupUSDC
SyrupRouter
WithdrawalManagerQueue
syrupUSDT
SyrupRouter
WithdrawalManagerQueue
syrupUSDC
SyrupRouter
WithdrawalManagerQueue
syrupUSDT
SyrupRouter
WithdrawalManagerQueue
Router addresses can also be accessed via the GraphQL API.
Example query
Code example using graphql-request
Listen for Router DepositData events (optional)
If you want to correlate deposits off-chain, subscribe to DepositData(address owner, uint256 amount, bytes32 depositData) on the syrupRouter address returned by GraphQL. Emitters include the caller’s address, raw deposit amount, and a bytes32 opaque identifier you pass in the deposit call.
Authorization signature verification (auditors)
Maple returns an authorization signature (v/r/s) used by authorizeAndDeposit. The router verifies a digest constructed from chainId, router address, owner, owner nonce, bitmap, and deadline. For internal reviews, auditors can reproduce the ecrecover and confirm the signer is a permissionAdmin in PoolPermissionManager.
It is important to note that the query uses the syrupRouter_not filter to return specifically Syrup pools.
Response Fields:
poolV2S.id: The Syrup Pool contract address.poolV2S.syrupRouter.id: TheSyrupRoutercontract address.
These addresses can then be used to interact with the SyrupRouter contract.
2. Determine User Authorization
Before depositing, check if a user is already authorized by querying the Account entity. This is necessary to perform a deposit.
Example Query
NOTE: The account ID must be provided in lowercase.
Code example using graphql-request
If isSyrupLender = true, the user is already authorized in the Pool Permission Manager and can deposit into Syrup pools. Otherwise, the user must perform authorization before their initial deposit.
3. Retrieve Authorization Signature
Note: This step is only required if isSyrupLender = false was returned in the previous step. Otherwise, continue to the next step.
The Maple Protocol is geared towards institutions and has a permissioning system that requires allowlisting for executing most functions. For pool deposits, in general, lenders need to have their wallet allowlisted in Maple's Pool Permission Manager. Aiming to abstract and simplify the process, the SyrupRouter integrates directly with the Pool Permission Manager to allow for valid users to self-authorize and deposit in a single transaction assuming the user meets eligibility requirements.
To retrieve the authorization signature, contact us at [email protected].
4. Execute the Deposit
The first time an asset (e.g., USDC, USDT) is lent to Syrup, it may be necessary to allow the contract to interact with the asset. This is a common transaction on Ethereum.
Depositing into a pool requires a transaction. Once the transaction has been processed, SyrupRouter will accept the lending tokens and Pool LP (Liquidity Provider) tokens will be received.
Each pool contract inherits the ERC-4626 standard, also known as the Tokenized Vault Standard. This standard informs how the LP Tokens accrue value from borrower repayments of loans.
isSyrupLender = true - User is Already Authorized
isSyrupLender = true - User is Already AuthorizedThe deposit or depositWithPermit method can be called directly on SyrupRouter.
NOTE: depositData is an optional field that does not need to be provided.
Code example using Maple SDK for USDC or USDT.
USDC or USDT.Deposits into Syrup can also be made with gasless approval using permit. For more information, see https://eips.ethereum.org/EIPS/eip-2612.
NOTE: depositWithPermit is only available for Syrup USDC.
Code example using Maple SDK
isSyrupLender = false - User Requires Authorization
isSyrupLender = false - User Requires AuthorizationRetrieve a signature from the Maple API. Follow the instructions received from the team as mentioned in the step above.
Use the retrieved signature with the
authorizeAndDepositorauthorizeAndDepositWithPermitmethod onSyrupRouter.
Code example using Maple SDK for USDC or USDT.
USDC or USDT.Deposits into Syrup can also be made with gasless approval using permit. For more information, see https://eips.ethereum.org/EIPS/eip-2612.
NOTE: authorizeAndDepositWithPermit is only available for Syrup USDC.
Code example using Maple SDK
Withdraw
1. Retrieve Pool Position
Query the Maple API for the user's pool position data using the PoolV2Position field in the Account query:
Data model
Example query
Code example using graphql-request
2. Calculate Shares to Redeem
Withdrawal requests must be expressed in shares. Although the Maple API provides both
availableSharesandavailableBalance, losses or impairments on the pool may affect the value of assets relative to shares.To ensure accuracy, convert the desired asset amount to "exit shares" using the pool contract's conversion method.
These transactions leverage the
ERC-4626tokenized vault standard. For more information, see https://ethereum.org/en/developers/docs/standards/tokens/erc-4626/.
Function signature
Code example using Maple SDK
3. Execute the Withdrawal
After calculating sharesToRedeem or fetching availableShares, call the requestRedeem method on the Pool contract to initiate the withdrawal.
Function signature
Code example using Maple SDK
4. Await Withdrawal Completion
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. The current status of the withdrawal queue can be retrieved either directly from the WithdrawalManagerQueue contract or through the Maple GraphQL API:
Example query
Code example using graphql-request
Edge Cases
FAQ
Last updated