Maple Finance 백서

Maple Finance

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 67쪽

(POOL_ADDRESS, provider.getSigner()); const usdcContract = erc20.core.connect(addresses['mainnet-prod'].USDC, provider.getSigner()); const account = '{YOUR_ACCOUNT}'; const oneDollar = BigNumber.from(1000000); await (await usdcContract.approve(POOL_ADDRESS, oneDollar)).wait(); await (await poolContract.deposit(oneDollar, account)).wait(); } main(); ``` ## Delegates * Delegates evaluate and approve/fund loan requests based on criteria specific to each pool. * Delegates accept or reject refinance proposals. * Delegates manage various pool utilities, such as adjusting the liquidity cap or authorizing certain lenders. **Code Example:** This snippet queries the `poolV2` contract to query the on-chain name of a given pool ```js import { providers } from 'ethers'; import { poolV2 } from '@maplelabs/maple-js'; const RPC_ENDPOINT = 'https://mainnet.infura.io/v3/{YOUR_KEY}'; async function main() { const contract = poolV2.core.connect('{POOL_ID}', new providers.JsonRpcProvider(RPC_ENDPOINT)); const name = await contract.name(); console.log({ name }); } main(); ``` # Usage Guide ## Overview The Maple SDK simplifies interaction with Maple Protocol smart contracts on Ethereum. It supports Mainnet, Base, and Sepolia networks, with production and development environments. This guide provides both conceptual understanding and practical examples, including a full integration with a React application. There are three networks: 1. **Mainnet**: main Ethereum network. 2. **Base Mainnet**: Ethereum L2 network. 3. **Sepolia**: Ethereum test network (testnet). Each network may have two environments: 1. **Prod**: production environment, where the official, stable versions of the contracts and subgraph, API and web applications are deployed. 2. **Dev**: development or staging environment, where new features or updates are tested before being deployed to the production environment. Access addresses from the `addresses` object exported from `maple-js`. See a list of available contracts in `src/addresses/*.ts`. The available combinations are: * `mainnet-prod`: Production environment on the main Ethereum network * `mainnet-dev`: Staging environment on the main Ethereum network * `base-mainnet-prod`: Production environment on the Base L2 network * `sepolia-prod`: Production environment on the Sepolia test network * `sepolia-dev`: Development environment on the Sepolia test network ## Getting started ### Addresses Access contract addresses using the `addresses` object: ```js import { addresses } from '@maplelabs/maple-js'; // Returns the contract address for MapleToken on Ethereum Mainnet const contractAddress = addresses.mainnet.MapleToken; ``` ### Connecting to a Contract To connect to a contract, you'll need its address and a signer. The `signer` should be an instance of a wallet that can sign transactions. Refer to the [ethers docs](https://docs.ethers.io/v5/) (or your choice of web3 library) for further assistance. **Connecting to a Contract Usage** ```js import { mapleGlobals } from '@maplelabs/maple-js'; const contractAddress = addresses.mainnet.MapleToken; const signer = 'yourSigner'; const contract = mapleGlobals.core.connect(contractAddress, signer); ``` ### Interacting with a Contract Once connected to a contract, you can call any available methods using the `contract` instance. `maple-js` contracts use typechain, so you can see all available methods using intellisense in your IDE. **Usage for Queries** Basic queries can be called using the standard `await` pattern: ```js const basicQuery = await contract.lpCooldownPeriod(); ``` **Usage for Transactions** When executing a transaction, use the `.wait()` method to resolve the Promise once the block containing your transaction has enough confirmations to be considered final: ```js import { pool } from '@maplelabs/maple-js'; const poolContract = pool.core.connect(poolAddress, signer); const method = await (await poolContract.deposit(depositAmount)).wait(); ``` ## Checking Permissions and Onboarding Before a wallet can deposit into a Maple pool, it must have a sufficient `permissionsBitmap` set. This is automatically managed when users onboard and verify their accounts on the Maple Webapp. Once verified, all wallets added to the account will receive the necessary permissions. For Syrup pools, permissions are granted after an initial deposit through the UI. ### Onboarding and Verification To ensure your wallet has the necessary permissions: 1. **Maple Webapp**: Onboard and verify your account at [Maple Webapp](https://app.maple.finance/). Add your wallets to the account to automatically receive the required permissions. 2. **Syrup Pools**: Make an initial deposit through the [Syrup UI](https://syrup.fi/) to set permissions. ### Querying Permissions with Subgraph For those interested in the technical details, you can query the subgraph to check permission information. This is useful for verifying the current state of permissions. **Example Query** The following GraphQL query can be used to retrieve the necessary permission information for a specific pool and account: ```graphql { poolV2(id: "0xc1dd3f011290f212227170f0d02f511ebf57e433") { permissionLevel poolLevelBitmap functionLevelBitmaps { id bitmap } } account(id: "0xAccountId") { permissionsBitmap } } ``` **API Endpoint** Use the following endpoint to execute the query: `https://api.maple.finance/v2/graphql` **Explanation** * **poolV2**: Retrieves pool permission details. * **account**: Retrieves the `permissionsBitmap` for the account. Ensure that the account's `permissionsBitmap` meets or exceeds the pool's requirements before attempting to deposit. For more details on permissions, refer to the [Pool Permission Manager documentation](https://github.com/maple-labs/maple-docs/blob/master/technical-resources/sdk/technical-resources/singletons/pool-permission-manager.md). ## Example Integration with React This section provides a practical example of how to integrate the Maple SDK into a React application. This example demonstrates connecting to a wallet, approving a token transfer, depositing into a pool, and requesting a withdrawal. ### Prerequisites Ensure you have the following installed and set up: * Node.js and npm * A React application (created using `create-react-app` or similar) * ethers v5 installed in your project * MetaMask/Rabby extension installed in your browser * A wallet with sufficient permissions to interact with the pool (see [Checking Permissions with Subgraph](#checking-permissions-with-subgraph)) ### Step-by-Step Guide 1. **Install the Maple SDK** First, ensure you have the Maple SDK installed in your project: ```bash npm install @maplelabs/maple-js ``` 2. **Set Up Your React Component** Below is a complete example of a React component that interacts with the Maple Protocol: ```typescript import React, { useEffect, useState } from 'react'; import { BigNumber, ethers } from 'ethers'; import { addresses, poolV2, environmentMocks } from '@maplelabs/maple-js'; const PROJECT = 'mainnet-prod'; const POOL_ADDRESS = '0xc1dd3f011290f212227170f0d02f511ebf57e433'; // Blue Chip Secured Pool const ONE_HUNDRED_USDC = BigNumber.from(100).mul(10 ** 6); async function getPoolContract(poolAddress: string) { const provider = new ethers.providers.Web3Provider( (window as any).ethereum ); const signer = provider.getSigner(); return poolV2.core.connect(poolAddress, signer); } async function getERC20Contract(erc20Address: string) { const provider = new ethers.providers.Web3Provider( (window as any).ethereum ); const signer = provider.getSigner(); return environmentMocks.erc20.connect(erc20Address, signer); } function App() { const [account, setAccount] = useState<string | null>(null); useEffect(() => { const connectWallet = async () => { if (typeof (window as any).ethereum !== 'undefined') { try { // Request account access const provider = new ethers.providers.Web3Provider( (window as any).ethereum ); await provider.send('eth_requestAccounts', []); // Get the signer const signer = provider.getSigner(); // Get the connected account const address = await signer.getAddress(); setAccount(address); console.log('Connected account:', address); } catch (error) { console.error('Error connecting to wallet:', error); } } else { console.error('MetaMask is not installed!'); } }; connectWallet(); }, []); const handleApprove = async () => { if (!account) { console.error('No account connected'); return; } const erc20Contract = await getERC20Contract(addresses[PROJECT].USDC); const transactionResponse = await erc20Contract.approve( POOL_ADDRESS, ONE_HUNDRED_USDC ); const receipt = await transactionResponse.wait(); console.log('Transaction confirmed:', receipt); }; const handleDeposit = async () => { if (!account) { console.error('No account connected'); return; } // Connect to the pool contract const poolContract = await getPoolContract(POOL_ADDRESS); // Execute the deposit method and wait for the transaction to be mined const transactionResponse = await poolContract.deposit( ONE_HUNDRED_USDC, account ); const receipt = await transactionResponse.wait(); console.log('Transaction confirmed:', receipt); }; const handleRequestWithdrawal = async () => { if (!account) { console.error('No account connected'); return; } const sharesAmount = BigNumber.from(10).mul(10 ** 6); // Connect to the pool contract const poolContract = await getPoolContract(POOL_ADDRESS); // Execute the requestRedeem method and wait for the transaction to be mined const receipt = await ( await poolContract.requestRedeem(sharesAmount, account) ).wait(); console.log('Transaction confirmed:', receipt); }; return ( <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh', }} > <div> <p>Interact with Maple Protocol</p> <button onClick={handleApprove}>Approve</button> <br /> <button onClick={handleDeposit}>Deposit</button> <br /> <button onClick={handleRequestWithdrawal}>Request withdrawal</button> </div> </div> ); } export default App; ``` 3. **Run Your Application** Ensure your application is running and MetaMask or any other wallet of your choice is connected to the desired network. You can now interact with the Maple Protocol using the buttons provided in the UI. # Get in touch ### Troubleshooting & support: **Intercom Chat** The chat can be accessed by clicking the chat icon on the right hand side of the [Maple WebApp](https://app.maple.finance/#/v2/lend). A Maple team member usually replies in just a few minutes. ### Partnerships: <partnerships@maple.finance> ### Join the community on [Telegram](https://t.me/maplefinance) ### Discover syrupUSDC yield opportunities [here](https://t.me/+S_U8ehtYPo40YTUx) # Access to deprecated Maple 1.0 Maple 1.0 has been deprecated following the migration to Maple 2.0, which occurred on December 11th 2022. If you have unclaimed MPL lending rewards, BPTs locked in cover or unclaimed staking rewards you can visit the Maple V1 UI to claim unclaimed MPL rewards or withdrawal BPTs. Orthogonal USDC 01: <https://app.maple.finance/#/v1/earn/pool/0xfebd6f15df3b73dc4307b1d7e65d46413e710c27> Maven 11 USDC 01: <https://app.maple.finance/#/v1/earn/pool/0x6f6c8013f639979c84b756c7fc1500eb5af18dc4> Maven wETH 01: <https://app.maple.finance/#/v1/earn/pool/0x1a066b0109545455bc771e49e6edef6303cb0a93> # Borrower MLA Prior to the disbursement of any funds, all prospective borrowers sign a legal agreement (the “Agreement”) prior to receipt of funds. This agreement is legally binding, ensures the rights and obligations of the parties involved, including, but not limited to, the unequivocal right of the lender to pursue all available legal remedies against the borrower in the event of default. The Agreement incorporates a forum selection clause and arbitration provision. Further, as a condition precedent to receiving funds, borrowers are required to execute an irrevocable waiver of all and any obligations to forum. In the event of default, the distribution of such recovered amounts is allocated as follows: i) All reasonable and documented costs incurred by Maple, as explicitly defined in the Agreement. ii) The outstanding principal balance owed to Lenders, to be distributed on a pro-rata basis calculated as of the date of default; iii) Any and all accrued interest owed to Lenders, similarly to be distributed on a pro-rata basis calculated as of the date of default; iv) Any fees owed to Maple, as expressly stipulated in the Agreement. For questions about KYC or legal agreements, please contact <contact@maple.finance>. # KYC Maple performs Know-Your-Customer checks on all Lenders and Borrowers across the platform. These checks include: i) The collection of documentation and information to identify the user. In case of an Entity, the Ultimate Beneficial Owners and Directors are identified as well. ii) Accreditation checks on Lenders. iii) PEP and Sanction scans for all users. iv) As a condition precedent to deposit, all lender wallets are scanned for risk factors using TRM Labs. Lender wallets that hit on risks (including interaction with high risk counterparty wallets) are blocked. Once onboarded, this gives users access to all the different pools on the Maple platform. # Interface Terms of Use Maple Labs Pty Ltd Legal Interface Terms of Use Maple Labs Pty Ltd Last Modified: April 14, 2025 Welcome to the Maple website and Maple Interface. The Following Terms of Use govern user access to and use of[ https://www.maple.finance/](https://www.maple.finance/) and app.maple.finance (collectively, the “Interface”). 1\. Acceptance of the Terms of Use These terms of use are entered into by and between you (the “User”) and Maple Labs Pty Ltd (“Company,” “we,” or “us”). The following terms and conditions, together with any documents they expressly incorporate by reference (collectively, “Terms of Use”), govern User’s access to and use of the Interface located at app.maple.finance, including any content, functionality, subpages, and services offered on or through the Interface. The Interface provides access to the Maple protocol that facilitates a novel decentralized method for decentralized peer-to-pool crypto-asset liquidity provision (the “Protocol”), including an ability for Participants to serve in certain capacities or perform certain functionalities when interacting with the Protocol. User must read the Terms of Use carefully before it starts to use the Interface. By using the Interface, or by clicking to accept or agree to the Terms of Use when this option is made available to the User, the User accepts and agrees to be bound and abide by these Terms of Use and our Privacy Policy, incorporated herein by reference. If the User does not want to agree to these Terms of Use, the Privacy Policy, or any documents applicable to them that are incorporated herein by reference, the User must not access or use the Interface. To the extent that there is a conflict between these Terms of Use and any applicable additional terms, these Terms will control unless expressly stated otherwise. If the User does not agree with these Terms of Use, that User may not visit or use the Interface. This Interface is offered and available to users who are 18 years of age or older. By using this Interface, the User represents and warrants that the User is at least the higher of legal age to form a binding contract with the Company in the User’s applicable jurisdiction or eighteen (18) years of age, and meet all of the foregoing eligibility requirements. If the User does not meet all of these requirements, the User must not access or use the Interface. User and Company shall undertake in good faith with respect to each other’s rights and undertake with the other to do all things reasonably that are necessary or desirable to give effect to the spirit and intent of this Agreement. 2\. Changes to the Terms of Use. We may revise and update these Terms of Use from time to time in our sole discretion. All changes are effective immediately when we post them and apply to all access to and use of the Interface thereafter. However, any changes to the dispute resolution provisions set out in[ Governing Law and Jurisdiction](https://docs.google.com/document/d/14A_4JfboIrv032uLxhVXU6HDEQTCZeUp/edit#bookmark=id.28h4qwu) will not apply to any disputes for which the parties have actual notice before the date the change is posted on the Interface. The User’s continued use of the Interface following the posting of revised Terms of Use means that the User accepts and agrees to the changes. The User is expected to check this page each time it accesses this Interface, so it is aware of any changes, as they are binding on the User. Notwithstanding the above, we will seek your consent to future modifications to the Terms of Use to the extent we are required to do so by law. 3\. Electronic Communication We may be required or choose to provide certain communications to User in written form. By agreeing to the Terms of Use, User consents to the delivery of those communications in electronic form, including e-mail or other electronic message. User agrees that all terms and conditions, disclosures, or agreements provided by Company electronically satisfy any legal requirement such communications would satisfy if they were provided in non-electronic writing. User waives any rights to require an original, wet, non-electronic signature, to the extent that such waiver is not prohibited under applicable law. 4\. Accessing the Interface and User Security. We reserve the right to withdraw or amend this Interface, and any service or material we provide on the Interface, in our sole discretion without notice. We will not be liable if for any reason all or any part of the Interface is unavailable at any time or for any period. From time to time, we may restrict access to some parts of the Interface, or the entire Interface, to those who access the Interface (“Participants”). The User is responsible for both: * Making all arrangements necessary for the User to have access to the Interface. * Ensuring that all persons who access the Interface through the User’s internet connection are aware of these Terms of Use and comply with them. To access the Interface or some of the resources it offers, the User may be asked to utilize certain Web3 capabilities, such as MetaMask or another crypto-asset wallet capable of interacting with the User’s web browser (“Web3 Utilities”). It is a condition of the User’s use of the Interface that all the information only operate such Web3 Utilities with a private key(s) that the User created or has the direct, explicit permission of the party who created the relevant private key(s). The User agree that all information it provides to interact with the Interface or otherwise, including, but not limited to, through the use of any interactive features on the Interface, is governed by our Privacy Policy, and the User consents to all actions we take with respect to the User’s information consistent with our Privacy Policy. If the User utilizes a Web3 Utility that relies on a username, password, private key, or any other piece of information as part of its security procedures, the User must treat such information as confidential, and the User must not disclose that information to any other person or entity. The User also acknowledges that any identity linked to its Web3 Utility is personal to the User and agrees not to provide any other person with access to such identity while using this Interface or portions of it using its Web3 Utility. The User also agrees to ensure that it will lock or otherwise prevent its Web3 Utility from unauthorized use on this Interface at the end of each session. The User should use particular cau
프로젝트로 돌아가기