### Definition and Example of Arbitrage on Curve Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/pools/deposit-faqs.md Defines arbitrage in the context of cryptocurrency markets and Curve, providing an Etherscan transaction example to illustrate how traders profit from price discrepancies. ```APIDOC Arbitrage is the simultaneous buying and selling of, in our case, a token to make a profit. Because cryptocurrency markets can often lack liquidity, there are often opportunities for traders to take advantage of price discrepancies to make a profit which can be helped by protocols like Curve. An example transaction: ​[**Etherscan**](https://etherscan.io/tx/0x259b7ac1f50554fe5ddcfeea7b4fa90ad70356ddfbbd341289db0dfbf99447f9)​ In this transaction, someone used Curve and OasisDex and made around $200. This goes back to what was discussed earlier with liquidity pools. The idea is that is you incentivize traders to take advantage of price discrepancies which we all get rewarded for. ``` -------------------------------- ### Understanding Incentivized Pools on Curve Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/pools/deposit-faqs.md Explains the concept of incentivized pools on Curve, where companies provide additional rewards to liquidity providers to help stablecoins maintain their pegs. ```APIDOC Liquidity pools (particularly one without an opportunity cost) are a great way to help stable coins keep their pegs. It makes easy for traders to arb (see question above) when the price slips off the peg which is very important for all the companies and foundations developing stable coins as having a $0.98 stablecoin is never a good look. As a result, some pools on Curve are “incentivized”. That means that on top of trading fees and lending fees, the companies will give rewards to people providing liquidity to the pools with their coins. ``` -------------------------------- ### Understanding Curve Deposit Bonuses Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/pools/deposit-faqs.md Explains the concept of deposit bonuses on Curve, detailing how they are influenced by token price discrepancies and the pool's rebalancing mechanism. ```APIDOC On the screenshot above, you can see GUSD is quite low as it should make up 50% of the total pool because it's a metapool paired against 3crv. So if your plan was to join the gusd-pool, you would ideally deposit GUSD into it. As you can see on the screenshot, you would get an instant 0.0082% bonus for depositing GUSD into the pool. The main reason for this is that GUSD is currently slightly more expensive so if you went to a centralized exchange you might sell it for $1.007 instead of $1. The deposit bonus reflects that. The other reason behind this is that the pools are always trying to balance themselves and go back to equal parts (in this case 50% GUSD) so depositing the coin with the lowest share will get you a deposit bonus. ``` -------------------------------- ### Example Calculation of scrvUSD Yield Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/crvusd/scrvusd.md This example demonstrates how the annual yield for scrvUSD is calculated under different scenarios, considering the circulating supply of crvUSD, total yearly fees, average borrow rate, and the percentage of crvUSD staked in scrvUSD, within DAO-defined minimum and maximum revenue allocation limits. ```Text Parameters: - Timeframe: 1 year - Circulating supply of crvUSD: 100M - crvUSD yearly fees: 10M crvUSD - Average borrow rate: 10% - crvUSD revenue to scrvUSD: 5% min, 50% max Example yield calculation changing the ratio of crvUSD staked in scrvUSD vs crvUSD circulating supply: - 1M staked (1%): 5% of fees ($500k) → 50% yield - 32M staked (32%): 32% of fees ($3.2M) → 10% yield - 60M staked (60%): 50% of fees ($5M) → 8% yield (50% max rev/60% staked) ``` -------------------------------- ### Liquidity Provision Mechanics: Token Splitting on Curve Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/pools/deposit-faqs.md Describes how deposited stablecoins are split among pool tokens on Curve, emphasizing that balances constantly change due to trading and arbitrage. ```APIDOC When you go to the deposit page and deposit one stablecoin, it then gets split between each token in the pool. That’s something you have to keep in mind because if you were to deposit 1000 DAI in the Pool, as per the screenshot below, your balance would be roughly equal to 390.7 GUSD, 120 DAI, 119.8 USDC and 362.6 USDT. Those values change constantly as people trade and arb the price of stable coins. ``` -------------------------------- ### Understanding 'Deposit Wrapped' Option on Curve Metapools Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/pools/deposit-faqs.md Explains the 'deposit wrapped' option for metapools or pools with c-tokens/a-tokens, detailing its purpose for pre-lent tokens and its applicability to basepool tokens like 3Crv. ```APIDOC (This applies to metapools or pools with c-tokens or a-tokens). If you deposit a stablecoin to one of the pools with lending, Curve will automatically wrap your token to a cToken (for Compound) or aToken (for Aave). The option is simply there if you have already previously lent them on Compound or Aave. If your stablecoin is in its original form, you can ignore this option. If you deposit into metapools and you have the corresponding basepool token (for example, 3Crv), you can also use the "deposit wrapped" option to deposit this token. ``` -------------------------------- ### Withdrawal Principles and Bonuses on Curve Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/pools/deposit-faqs.md Clarifies that withdrawal principles mirror deposit bonuses, allowing users to choose their preferred stablecoin while potentially receiving a bonus for withdrawing the largest share. ```APIDOC When you withdraw, the same principle as in the question above applies- but reversed. If you withdraw the stable coin with the biggest share, you would get a bonus but you still choose what stable coin you want to withdraw. ``` -------------------------------- ### Interest Accrual and Compounding on Curve Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/pools/deposit-faqs.md Details the frequency and automatic nature of interest accrual and compounding for Curve pools utilizing lending protocols. ```APIDOC Interests for pools using lending protocols compound every block or 15 seconds or immediately after fees are paid. It’s also compounded automatically. ``` -------------------------------- ### Define URL Redirect Mappings Source: https://github.com/curvedocs/curve-resources/blob/main/overrides/404.html This JavaScript object maps old documentation paths to their new, updated locations. It's used by the client-side redirect logic to guide users to the correct content when they access deprecated URLs. ```JavaScript // Create an object containing all your redirects const redirects = { "/crv-token/crv-basics": "/crv-token/faq", "/crv-token/crv-tokenomics": "/crv-token/supply-distribution", "/lending/about": "/lending/overview", "/lending/loan-creation": "/lending/how-to-borrow", "/lending/supplying-assets": "/lending/how-to-supply", "/crvusd/loan-management": "/crvusd/loan-strategies", "/crvusd/loan-details": "/crvusd/loan-concepts", "/resources/branding": "/glossary-branding/branding", "/resources/glossary": "/glossary-branding/glossary", "/resources/risks/pool": "/risks-security/risks/pool", "/resources/risks/crvusd": "/risks-security/risks/crvusd", "/resources/risks/lending": "/risks-security/risks/lending", "/resources/security": "/risks-security/security", "/governance/fee-collection-distribution": "/vecrv/overview", "/crv-token/claiming-trading-fees": "/vecrv/claiming-trading-fees", "/lending/understanding-lending": "/lending/overview", "/crvusd/loan-details": "/crvusd/loan-concepts", "/factory-pools/creating-a-twocrypto-ng-pool": "/pool-creation/creating-a-cryptoswap-pool", "/factory-pools/creating-a-stableswap-ng-pool": "/pool-creation/creating-a-stableswap-pool", "/base-features/understanding-crypto-pools": "/pools/overview", "/lp/calculating-yield/#base-vapy": "/pools/calculating-yield/#base-vapy", "/lp/calculating-yield": "/pools/calculating-yield" }; ``` -------------------------------- ### Bridge Contract Method: bridge Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Documentation for the 'bridge' method on a blockchain bridge contract, detailing its required parameters for transferring tokens from an L1 blockchain to Ethereum. ```APIDOC Method: bridge( bridge: ETH amount for the bridge fee (denominated in Ether, quoted amount / 1e18), _amount: Amount of tokens to bridge (in 1e18 format), _receiver: Wallet address to receive the tokens ) ``` -------------------------------- ### Python Dependencies for MkDocs Documentation Project Source: https://github.com/curvedocs/curve-resources/blob/main/requirements.txt This snippet provides a list of Python packages commonly used in an MkDocs project. These packages are typically installed via pip and define the project's build environment for documentation generation, including themes, plugins for features like autolinks, minification, and internationalization, and extensions for Markdown processing. ```Python mkdocs mkdocs-material mkdocs-autolinks-plugin mkdocs-minify-plugin pymdown-extensions mkdocs-git-revision-date-localized-plugin mkdocs-static-i18n ``` -------------------------------- ### scrvUSD Token Contract Addresses Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Provides the scrvUSD token contract address for Ethereum. ```APIDOC scrvUSD Token Addresses: Ethereum: 0x0655977FEb2f289A4aB78af67BAB0d17aAb84367 ``` -------------------------------- ### Impact of Deposited Coin Choice on Curve Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/pools/deposit-faqs.md Discusses whether the choice of deposited coin matters, highlighting considerations like deposit bonuses and potential slippage for large deposits or low-liquidity pools. ```APIDOC For most typical deposits, it doesn't matter which coin you use - your tokens will automatically get split into the pool proportions. However, there are two important considerations: 1. There's a deposit bonus explained below that can affect your choice. 2. If you're making a large deposit relative to the pool's size or if the pool has low liquidity, depositing a single token could result in unfavorable exchange rates due to slippage. In these cases, it's better to pre-swap your tokens to match the pool's proportions before depositing. For normal-sized deposits into liquid pools, you can comfortably deposit one, some, or all the coins without worrying about it affecting your returns. ``` -------------------------------- ### Curve Resource Contract Addresses Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Lists various contract addresses associated with Curve resources on different blockchain networks, including Binance Smart Chain, Avalanche, and Fantom. ```APIDOC Binance Smart Chain: 0x0094Ad026643994c8fB2136ec912D508B15fe0E5 Avalanche: 0xA3ea433509F7941df3e33857D9c9f212Ad4A4e64 Fantom: 0x5191946500e75f0A74476F146dF7d386e52961d9 ``` -------------------------------- ### Approve Bridge Contract to Spend Tokens on L1 Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Explains how to approve the bridge contract to spend a specified amount of tokens on the L1 network before bridging them to Ethereum. This is a prerequisite for the bridging transaction. ```APIDOC Method: approve Description: Approves a specified bridge contract to spend a certain amount of tokens on the L1 network. Parameters: _spender: bridge_contract_address - The contract address of the bridge on the L1 blockchain. _value: token_amount_1e18 (e.g., for 100 crvUSD, enter 100000000000000000000) - The amount of tokens to approve in 1e18 format. ``` -------------------------------- ### Bridge Tokens from L2 to L1 (Ethereum) Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Details how to use the 'bridge' method on the bridge contract to transfer tokens from an L2 to an L1 blockchain, specifically Ethereum. This involves specifying the ETH amount, token amount, and receiver address. ```APIDOC Method: bridge Description: Initiates the bridging of tokens from an L2 to an L1 blockchain (Ethereum). Parameters: bridge: ETH_amount (denominated in Ether, quoted amount / 1e18) - The ETH amount for the bridge. _amount: token_amount_1e18 (amount of tokens to bridge in 1e18 format) - The amount of tokens to bridge. _receiver: wallet_address - The wallet address to receive the tokens. ``` -------------------------------- ### Quote Bridging Fee on L1 Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Describes how to use the 'quote' function on the L1 bridge contract to determine the cost of bridging tokens to Ethereum. This quote represents the cost in the L1's gas token, excluding additional gas costs. ```APIDOC Method: quote Description: Determines the bridging cost (in the gas token of the L1 blockchain) for a transaction. Parameters: None Returns: quote_amount (cost in L1 gas token) - The cost of calling the bridge method. ``` -------------------------------- ### Cross-Chain Bridge Contract Addresses Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Provides a table of bridge contract addresses on Ethereum for various L1 blockchains (Binance Smart Chain, Avalanche, Fantom), facilitating cross-chain token transfers. Each entry includes links to Etherscan for both Ethereum and the respective L1 chain. ```APIDOC Chain: BinanceSmartChain Bridge Address: 0xAE0666C978500f2C05784242B79B08C478Dd999c Links: Ethereum: https://etherscan.io/address/0xAE0666C978500f2C05784242B79B08C478Dd999c BSC: https://bscscan.com/address/0xAE0666C978500f2C05784242B79B08C478Dd999c Chain: Avalanche Bridge Address: 0x26E91B1f142b9bF0bB37e82959bA79D2Aa6b99b8 Links: Ethereum: https://etherscan.io/address/0x26E91B1f142b9bF0bB37e82959bA79D2Aa6b99b8 Avalanche: https://snowscan.xyz/address/0x26E91B1f142b9bF0bB37e82959bA79D2Aa6b99b8 Chain: Fantom Bridge Address: 0x08132eA9b02750E118cF5F5C640B7c46A8E638E8 Links: Ethereum: https://etherscan.io/address/0x08132eA9b02750E118cF5F5C640B7c46A8E638E8 Fantom: https://ftmscout.com/address/0x08132eA9b02750E118cF5F5C640B7c46A8E638E8 ``` -------------------------------- ### CRV Token and Bridge Contract Addresses Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Provides the CRV token contract addresses for Ethereum, Binance Smart Chain, Avalanche, and Fantom, along with the mirrored bridge contract addresses required for cross-chain transfers between Ethereum and these L1 blockchains. ```APIDOC CRV Token Addresses: Ethereum: 0xD533a949740bb3306d119CC777fa900bA034cd52 Binance Smart Chain: 0x9996D0276612d23b35f90C51EE935520B3d7355B Avalanche: 0xEEbC562d445F4bC13aC75c8caABb438DFae42A1B Fantom: 0xE6c259bc0FCE25b71fE95A00361D3878E16232C3 CRV Bridge Contract Addresses: BinanceSmartChain Bridge: 0xC91113B4Dd89dd20FDEECDAC82477Bc99A840355 (Ethereum, BSC) Avalanche Bridge: 0x5cc0144A511807608eF644c9e99B486124D1cFd6 (Ethereum, Avalanche) Fantom Bridge: 0x7ce8aF75A9180B602445bE230860DDcb4cAc3E42 (Ethereum, Fantom) ``` -------------------------------- ### Approve Token Spending on Etherscan Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Details the process of approving a bridge contract to spend tokens on behalf of a user via Etherscan's 'Write Contract' interface. This is a prerequisite for bridging tokens and involves calling the 'approve' method on the token's contract. ```APIDOC Method: approve(address _spender, uint256 _value) Description: Approves a specified address to spend a certain amount of tokens. Parameters: _spender (address): The address of the bridge contract to be approved. Value: 0x0A92Fd5271dB1C41564BD01ef6b1a75fC1db4d4f (same for all tokens) _value (uint256): The amount of tokens to approve, in 1e18 format. Example: For 100 crvUSD, enter 100000000000000000000. Action: Click 'Write' and sign the transaction in your wallet. ``` -------------------------------- ### crvUSD Token and Bridge Contract Addresses Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Provides the crvUSD token contract addresses for Ethereum, Binance Smart Chain, Avalanche, and Fantom, along with the mirrored bridge contract addresses required for cross-chain transfers between Ethereum and these L1 blockchains. ```APIDOC crvUSD Token Addresses: Ethereum: 0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E Binance Smart Chain: 0xe2fb3F127f5450DeE44afe054385d74C392BdeF4 Avalanche: 0xCb7c161602d04C4e8aF1832046EE08AAF96d855D Fantom: 0xD823D2a2B5AF77835e972A0D5B77f5F5A9a003A6 crvUSD Bridge Contract Addresses: BinanceSmartChain Bridge: 0x0A92Fd5271dB1C41564BD01ef6b1a75fC1db4d4f (Ethereum, BSC) Avalanche Bridge: 0x26D01ce989037befd7Ff63837A86e2da32E7D7e2 (Ethereum, Avalanche) Fantom Bridge: 0x76EAfda658C54548B460B3f190386699DE3827d8 (Ethereum, Fantom) ``` -------------------------------- ### Quote Bridging Cost on Etherscan Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/cross-chain/bridging-curve-eco-tokens.md Explains how to use the 'quote' function on the bridge contract via Etherscan's 'Read Contract' interface to determine the ETH cost for calling the bridge method. This quoted amount does not include additional gas costs. ```APIDOC Method: quote() Description: Determines the cost (in ETH) for calling the bridge method in a subsequent step. Return: uint256 (amount in ETH) Note: This amount does not include gas costs, which need to be paid on top of the quoted amount. ``` -------------------------------- ### Curve Lending Market Parameters Reference Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/how-to-borrow.md Defines the key parameters and their descriptions for the Curve lending markets, including various fees, discount factors, and pricing mechanisms that govern loan behavior and liquidity. ```APIDOC LendingMarketParameters: Fee: The current exchange fee for swapping tokens in the AMM. Admin Fee: The percentage of the total fee, which is awarded to veCRV holders. Currently, all fees go to liquidity providers in the AMM (which are the borrowers). Band Width Factor: The band width factor (sometimes denoted as A) defines the density of liquidity and band width. Loan Discount: The percentage used to discount the collateral for calculating the maximum borrowable amount when creating a loan. Liquidation Discount: The percentage used to discount the collateral for calculating the recoverable value upon liquidation at the current market price. Base Price: The base price is the price of the band number 0. Oracle Price: The oracle price is the current price of the collateral as determined by the oracle. The oracle price is used to calculate the collateral's value and the loan's health. ``` -------------------------------- ### Configure Chart.js Tooltip and Initialize Rate Chart Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/create-lending-market.md This JavaScript snippet defines custom tooltip behavior for a Chart.js chart, including filtering datasets and formatting label text to display utilization, borrow APR, and lend APR. It also includes logic to destroy an existing chart instance before creating a new one, ensuring proper chart updates. ```javascript return tooltipItem.datasetIndex === 0; }, enabled: true, backgroundColor: 'rgba(0, 0, 0, 0.7)', bodyColor: '#ffffff', bodyFont: { size: 12, }, borderColor: 'rgba(0, 0, 0, 0.7)', borderWidth: 1, usePointStyle: false, padding: 4, displayColors: false, callbacks: { title: function() { return ''; }, label: function(context) { const utilization = context.parsed.x.toFixed(2); const borrowRate = context.chart.data.datasets[0].data[context.dataIndex].y.toFixed(2); const lendRate = context.chart.data.datasets[1].data[context.dataIndex].y.toFixed(2); return [ `Utilization: ${utilization}%`, `Borrow APR: ${borrowRate}%`, `Lend APR: ${lendRate}%` ]; } } }, }, legend: { position: 'bottom' } } }; if (rateChart) { rateChart.destroy(); } rateChart = new Chart(ctx, config); } ``` -------------------------------- ### OneWay Lending Factory: create Method for Lending Market Deployment with Custom Oracle Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/create-lending-market.md Deploys a new lending market using a custom price oracle. This method requires the address of the custom price oracle contract, along with various market parameters. Parameters like `band_width_factor` are simple numbers, while others like `fee`, `loan_discount`, `liquidation_discount`, and borrow rates are $10^{18}$ scaled numbers. ```APIDOC OneWay Lending Factory: create( price_oracle: address, borrowed_token: address, collateral_token: address, band_width_factor: uint256, fee: uint256, loan_discount: uint256, liquidation_discount: uint256, name: string, min_borrow_rate: uint256 (optional), max_borrow_rate: uint256 (optional) ) Parameters: price_oracle: Address of the custom price oracle contract. borrowed_token: Address of the token to be supplied and borrowed. collateral_token: Address of the token to be used as collateral. band_width_factor: The band width factor (A). Most markets use a value between 10-30. Use lower values for riskier assets. Input as a normal number, e.g., 10 = 10. fee: The AMM swap fee. Most pools use between 0.3-1.5%. Input as a 10^18 number, e.g., 0.06% = 6000000000000000. loan_discount: The amount to discount collateral for calculating maximum LTV. Usually higher than liquidation_discount by 3-4%. Input as a 10^18 number, e.g., 11% = 110000000000000000. liquidation_discount: The amount to discount collateral for health and hard-liquidation calculations. Usually less than loan_discount by 3-4%. Input as a 10^18 number, e.g., 8% = 80000000000000000. name: The name of the market. min_borrow_rate (optional): The minimum borrow rate, as rate/sec. Input as a 10^18 number, e.g., 1% APR = 317097919. max_borrow_rate (optional): The maximum borrow rate, as rate/sec. Input as a 10^18 number, e.g., 80% APR = 25367833587. ``` -------------------------------- ### HTML Structure for Soft-liquidation Applet UI Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/llamalend/educational/liquidations.md This HTML snippet defines the user interface for the soft-liquidation applet, including input fields for collateral amount and liquidation range, a slider, a canvas for charting, and external script inclusions for Chart.js and a custom liquidations.js file. It uses inline styles for basic layout and functionality integration. ```HTML

Soft-liquidation Collateral Conversion

Bottom of SL Range: Top of SL Range:
``` -------------------------------- ### OneWay Lending Factory: create_from_pool Method for Lending Market Deployment Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/create-lending-market.md Deploys a new lending market using an existing Curve pool. This method requires the address of a pre-existing pool that includes both the borrowed and collateral tokens, along with various market parameters. Parameters like `band_width_factor` are simple numbers, while others like `fee`, `loan_discount`, `liquidation_discount`, and borrow rates are $10^{18}$ scaled numbers. ```APIDOC OneWay Lending Factory: create_from_pool( pool: address, borrowed_token: address, collateral_token: address, band_width_factor: uint256, fee: uint256, loan_discount: uint256, liquidation_discount: uint256, name: string, min_borrow_rate: uint256 (optional), max_borrow_rate: uint256 (optional) ) Parameters: pool: The address of the pool which includes both the borrowed_token and collateral_token. borrowed_token: Address of the token to be supplied and borrowed. collateral_token: Address of the token to be used as collateral. band_width_factor: The band width factor (A). Most markets use a value between 10-30. Use lower values for riskier assets. Input as a normal number, e.g., 10 = 10. fee: The AMM swap fee. Most pools use between 0.3-1.5%. Input as a 10^18 number, e.g., 0.06% = 6000000000000000. loan_discount: The amount to discount collateral for calculating maximum LTV. Usually higher than liquidation_discount by 3-4%. Input as a 10^18 number, e.g., 11% = 110000000000000000. liquidation_discount: The amount to discount collateral for health and hard-liquidation calculations. Usually less than loan_discount by 3-4%. Input as a 10^18 number, e.g., 8% = 80000000000000000. name: The name of the market. min_borrow_rate (optional): The minimum borrow rate, as rate/sec. Input as a 10^18 number, e.g., 1% APR = 317097919. max_borrow_rate (optional): The maximum borrow rate, as rate/sec. Input as a 10^18 number, e.g., 80% APR = 25367833587. ``` -------------------------------- ### Deploy Sidechain Pool Gauge via Curve UI Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/reward-gauges/creating-a-pool-gauge.md This section outlines the process of deploying a sidechain gauge using the Curve Finance web interface. It involves a two-step deployment: first the child gauge on the sidechain, then its mirror parent gauge on Ethereum Mainnet. It is crucial that the same wallet address is used for both deployments to ensure proper linking. ```APIDOC // Step 1: Deploy Child Gauge on Sidechain Action: Navigate to Curve Finance Deploy Gauge page. Input: - LP Token Address (pool address) - Pool Type (select from dropdown) Operation: Click "Deploy Gauge" button. Chain: Target Sidechain (e.g., Base) // Step 2: Deploy Parent Gauge on Ethereum Mainnet Action: Click arrow to proceed to Step 2. Input: - Network (select sidechain where child gauge was deployed, e.g., Base) - Pool Type (must match Step 1) - LP Token Address (must match Step 1) Operation: Click "Deploy" button and confirm transaction. Chain: Ethereum Mainnet Constraint: The same address MUST deploy both the child and parent gauges. ``` -------------------------------- ### UI Theme Change Listener and Dark Mode Detection (JavaScript) Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/create-lending-market.md JavaScript utility functions to detect if the user is in dark mode (based on `data-md-color-scheme`) and to trigger a page reload when the theme palette input changes, ensuring UI consistency. ```JavaScript document.addEventListener("change", function (event) { if (event.target.matches('input[name="__palette"]')) { location.reload(); } }); function isUserDarkmode() { var colorScheme = document.querySelector('body').getAttribute('data-md-color-scheme'); return colorScheme === 'slate'; } ``` -------------------------------- ### Convert APR to Borrow Rate (Interest per Second) Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/create-lending-market.md Mathematical formula used in smart contracts to convert a desired Annual Percentage Rate (APR) into an interest rate per second, based on the total seconds in a year. ```Math $$\text{borrow_rate} = \frac{\text{APR}}{\text{seconds_in_year}} = \frac{\text{APR}}{86400 \times 365}$$ ``` -------------------------------- ### Generate Dynamic HTML Table and CSV Data Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/create-lending-market.md This JavaScript function creates and populates an HTML table based on a 'tableData' array, displaying utilization, borrow APR, lend APR, and spread. It also generates a CSV string of the same data, filtering to include only rows where utilization steps are multiples of 5%. ```javascript function updateTable() { // Create and populate the table const tableContainer = document.getElementById('dataTable'); let csv = `Utilization; Borrow APR; Lend APR; Spread`; let tableHTML = ` `; for (let i = 0; i < tableData.length; i++) { if (i % 5 === 0) { // Only add rows for every 5% step const row = tableData[i]; csv += `${row.utilization};${row.borrowAPR};${row.lendAPR};${row.spread}`; tableHTML += ` `; } } tableHTML += `
Utilization (%) Borrow APR (%) Lend APR (%) Spread (%)
${row.utilization} ${row.borrowAPR} ${row.lendAPR} ${row.spread}
`; tableContainer.innerHTML = tableHTML; console.log(csv); } ``` -------------------------------- ### Generate Lend and Borrow APR Graph with Chart.js Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/overview.md This JavaScript code snippet uses the Chart.js library to create a dynamic scatter plot visualizing the relationship between Borrow APR, Lend APR, and utilization rates. It calculates data points for both rates based on a non-linear formula and renders them on a canvas element. The graph includes interactive tooltips to display precise utilization, Borrow APR, and Lend APR values. ```javascript document.addEventListener('DOMContentLoaded', function() { updateGraph(); // Draw the initial graph with hardcoded values }); let myChart = null; function updateGraph() { const rateMin = 0.01; const rateMax = 0.8; let borrowDataPoints = []; for (let u = 0; u <= 1.01; u += 0.01) { let rate = rateMin * Math.pow((rateMax / rateMin), u); borrowDataPoints.push({x: u * 100, y: rate * 100}); } let lendDataPoints = []; for (let u = 0; u <= 1.01; u += 0.01) { let rate = u * rateMin * Math.pow((rateMax / rateMin), u); lendDataPoints.push({x: u * 100, y: rate * 100}); } const ctx = document.getElementById('graphContainer').getContext('2d'); const data = { datasets: [ { label: 'Borrow APR', data: borrowDataPoints, borderColor: 'rgba(75, 192, 192, 0.9)', fill: false, pointRadius: 0, showLine: true, borderWidth: 2 }, { label: 'Lend APR', data: lendDataPoints, borderColor: 'rgba(255, 99, 132, 0.9)', fill: false, pointRadius: 0, showLine: true, borderWidth: 2 } ] }; const config = { type: 'scatter', data: data, options: { scales: { x: { type: 'linear', position: 'bottom', title: { display: true, text: 'Utilization (%)' }, max: 100 }, y: { title: { display: true, text: 'APR (%)' }, beginAtZero: true } }, interaction: { mode: 'nearest', intersect: false, axis: 'x' }, plugins: { tooltip: { mode: 'index', intersect: false, filter: function(tooltipItem) { return tooltipItem.datasetIndex === 0; }, enabled: true, backgroundColor: 'rgba(0, 0, 0, 0.7)', bodyColor: '#ffffff', bodyFont: { size: 12 }, borderColor: 'rgba(0, 0, 0, 0.7)', borderWidth: 1, usePointStyle: false, padding: 4, displayColors: false, callbacks: { title: function() { return ''; }, label: function(context) { const utilization = context.parsed.x.toFixed(2); const borrowRate = context.chart.data.datasets[0].data[context.dataIndex].y.toFixed(2); const lendRate = context.chart.data.datasets[1].data[context.dataIndex].y.toFixed(2); return [ `Utilization: ${utilization}%`, `Borrow APR: ${borrowRate}%`, `Lend APR: ${lendRate}%` ]; } } } } } }; if (myChart) { myChart.destroy(); } myChart = new Chart(ctx, config); } ``` -------------------------------- ### Deploy Sidechain Child Liquidity Gauge Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/reward-gauges/creating-a-pool-gauge.md Details the process of deploying a child liquidity gauge on a sidechain using the ChildLiquidityGaugeFactory contract. It specifies connecting a Web3 wallet, finding the deploy_gauge function, and providing parameters like _lp_token (pool address), _salt (unique identifier, must match root gauge), and optionally _manager (your address). ```APIDOC Contract: ChildLiquidityGaugeFactory Function: deploy_gauge Parameters: _lp_token: address (The address of the pool's LP token, often the pool address itself) _salt: bytes32 (A unique identifier for the gauge address, must be consistent with root gauge deployment) _manager: address (Optional, defaults to caller's address if not provided. Must be the caller's address for linking to root gauge) Action: Submit transaction via "Write Contract" interface. ``` -------------------------------- ### HTML Includes for Charting Libraries Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/crvusd/loan-strategies.md HTML snippet to include external JavaScript libraries (Chart.js, Chart.js Annotation Plugin) and a custom loan strategies script. These scripts are essential dependencies for rendering interactive charts and implementing specific loan-related functionalities on the page. ```HTML ``` -------------------------------- ### Deploy Ethereum Mainnet Gauge via Etherscan Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/reward-gauges/creating-a-pool-gauge.md This section describes how to deploy a gauge for an Ethereum Mainnet pool directly by interacting with the factory contract on Etherscan. This method requires identifying the correct factory contract that deployed the pool and calling its `deploy_gauge` function. ```APIDOC Contract Interaction: Factory Contract on Etherscan Method: deploy_gauge Parameters: - _pool_address: Address of the LP Token / Pool for which to deploy the gauge. Pre-requisites: - Wallet connected to Web3 on Etherscan. - Function must be called on the specific Factory contract that deployed the pool. Steps: 1. Search for the corresponding Factory contract on Etherscan. 2. Navigate to "Contract" -> "Write Contract" -> "deploy_gauge". 3. Input the pool address. 4. Click "Write" and sign the transaction. ``` -------------------------------- ### Deploy Sidechain Gauge via Etherscan Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/reward-gauges/creating-a-pool-gauge.md This section details the two-part process for deploying a sidechain gauge using Etherscan: first the 'Child Gauge' on the sidechain, followed by the 'Root (Parent) Gauge' on Ethereum Mainnet. A critical requirement is that both gauges must be deployed using the exact same wallet address and the same salt to ensure they are linked correctly. ```APIDOC // Step 1: Deploy Child Gauge on Sidechain Contract Interaction: Sidechain Factory Contract on Etherscan Method: deploy_gauge Parameters: - _pool_address: Address of the LP Token / Pool on the sidechain. Chain: Target Sidechain // Step 2: Deploy Root (Parent) Gauge on Ethereum Mainnet Contract Interaction: Ethereum Mainnet Factory Contract on Etherscan Method: deploy_gauge Parameters: - _pool_address: Address of the LP Token / Pool on the sidechain (same as child gauge). Chain: Ethereum Mainnet Critical Constraints: - Both Child and Root Gauges MUST be deployed using the SAME wallet address. - Both Child and Root Gauges MUST be deployed using the SAME salt (implied by "same address" and contract logic for deterministic addresses). - If addresses are not identical, gauges cannot be linked. ``` -------------------------------- ### Implement Collapsible Table Interaction with JavaScript Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/create-lending-market.md This JavaScript code adds interactivity to a collapsible table. It initializes the table to a collapsed state with an 'expand' text indicator and toggles the collapsed state (and updates the text) when the heading is clicked, showing or hiding the table content. ```javascript document.addEventListener('DOMContentLoaded', function() { const heading = document.querySelector('.collapsible-heading'); const table = document.querySelector('.collapsible-table'); const expandText = heading.querySelector('.expand-text'); // Set initial state to collapsed and set initial text table.classList.add('collapsed'); heading.classList.add('collapsed'); expandText.textContent = '(click to expand)'; heading.addEventListener('click', function() { table.classList.toggle('collapsed'); heading.classList.toggle('collapsed'); // Update expand/collapse text expandText.textContent = table.classList.contains('collapsed') ? '(click to expand)' : '(click to collapse)'; }); }); ``` -------------------------------- ### OneWay Lending Factory: deploy_gauge Method for CRV Rewards Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/create-lending-market.md Deploys a gauge linked to a lending market's supply vault, which is a prerequisite for suppliers to stake their vault shares and receive CRV incentives/rewards. This method requires the address of the newly created vault contract. ```APIDOC OneWay Lending Factory: deploy_gauge( vault: address ) Parameters: vault: The newly created vault contract address. ``` -------------------------------- ### Curve Lending Market Entities and Roles Source: https://github.com/curvedocs/curve-resources/blob/main/docs/en/lending/overview.md Describes the key entities within a Curve Lending market and their respective roles and interactions, illustrating how borrowing and lending activities are facilitated. ```APIDOC Business Llama: Role: Represents the lending market and smart contracts in the system. Details: Uses CRV as collateral, and lends out crvUSD. Charges interest on crvUSD users borrow (Borrow APY), and pays interest to lenders who supply crvUSD (Lend APY). Bob: Role: User who supplies crvUSD. Details: Bob supplies his crvUSD and Business Llama lends it out and pays Bob interest (Lend APY). Alice: Role: User who borrows crvUSD. Details: Deposits CRV and uses it as collateral to borrow crvUSD. Charged the Borrow APY on her debt while the loan is open. Benefits from LLAMMA and soft-liquidations. Charlie & Daisy: Role: Users interacting with lending markets. Details: Illustrates that all Curve Lending Markets are one-way and isolated. Users must find the specific Business Llama (lending market) that lends out the desired asset with the correct collateral. ```