### Bash: Building and Testing with Foundry Source: https://context7.com/symbioticfi/periphery/llms.txt Commands for setting up, compiling, testing, and formatting the project using the Foundry framework. This includes installing dependencies, configuring environment variables, running tests with different options, and code formatting. ```bash # Install dependencies forge install # Create environment configuration cp .env.example .env # Edit .env and add: # ETH_RPC_URL=https://mainnet.infura.io/v3/YOUR_KEY # ETH_RPC_URL_HOLESKY=https://holesky.infura.io/v3/YOUR_KEY (optional) # ETHERSCAN_API_KEY=YOUR_API_KEY (optional) # Compile contracts forge build # Run tests with mainnet fork forge test # Run specific test forge test --match-test test_Migrate -vvv # Run tests with gas reporting forge test --gas-report # Format code forge fmt # Generate gas snapshots forge snapshot ``` -------------------------------- ### Solidity: Complete Collateral Migration Flow Source: https://context7.com/symbioticfi/periphery/llms.txt End-to-end example demonstrating the full migration process of default collateral tokens to a Symbiotic Vault. It covers checking balances, approving the migrator, executing the migration, and verifying the results. This snippet assumes standard ERC-20 tokens and standard vault interactions. ```solidity // Initial setup: User has default collateral tokens address user = 0xABCD...; IDefaultCollateral collateral = IDefaultCollateral(0x1234...); IVault targetVault = IVault(0x5678...); DefaultCollateralMigrator migrator = DefaultCollateralMigrator(0x9ABC...); // Check user's collateral balance uint256 userBalance = collateral.balanceOf(user); require(userBalance >= 1000 * 1e18, "Insufficient balance"); // Step 1: Approve migrator to spend collateral collateral.approve(address(migrator), 1000 * 1e18); // Step 2: Execute migration (uint256 deposited, uint256 shares) = migrator.migrate( address(collateral), address(targetVault), user, 1000 * 1e18 ); // Step 3: Verify migration results assert(collateral.balanceOf(user) == userBalance - 1000 * 1e18); assert(targetVault.balanceOf(user) == shares); assert(targetVault.slashableBalanceOf(user) == deposited); // The migrator automatically: // 1. Transferred collateral tokens from user // 2. Withdrew underlying assets from collateral // 3. Approved vault to spend underlying assets (infinite approval) // 4. Deposited underlying assets to vault on behalf of user ``` -------------------------------- ### Solidity: Fee-on-Transfer Token Migration Source: https://context7.com/symbioticfi/periphery/llms.txt Example of migrating fee-on-transfer tokens, where tokens are deducted during transfer. The migrator contract automatically accounts for these fees by checking the actual balance received after withdrawal. This ensures accurate accounting of deposited assets in the target vault. ```solidity // Setup with fee-on-transfer token FeeOnTransferToken feeToken = FeeOnTransferToken(0x2222...); IDefaultCollateral feeCollateral = IDefaultCollateral(0x3333...); IVault feeVault = IVault(0x4444...); DefaultCollateralMigrator migrator = DefaultCollateralMigrator(0x9ABC...); // Approve and migrate uint256 migrateAmount = 500 * 1e18; feeCollateral.approve(address(migrator), migrateAmount); (uint256 deposited, uint256 shares) = migrator.migrate( address(feeCollateral), address(feeVault), msg.sender, migrateAmount ); // Note: deposited amount will be less than migrateAmount due to transfer fees // Example: if fee is 2 tokens per transfer (2 transfers = 4 tokens total) // deposited = 500 * 1e18 - 2 (approximately) // The migrator uses balanceOf() to get actual amount received after withdrawal assert(deposited < migrateAmount); assert(feeVault.slashableBalanceOf(msg.sender) == deposited); ``` -------------------------------- ### Generate Gas Snapshots for Symbiotic Periphery Contracts using Forge Source: https://github.com/symbioticfi/periphery/blob/main/README.md Command to generate gas usage snapshots for the Symbiotic Periphery contracts using Forge. This is useful for tracking gas optimizations and understanding contract efficiency. ```shell forge snapshot ``` -------------------------------- ### Format Symbiotic Periphery Contracts using Forge Source: https://github.com/symbioticfi/periphery/blob/main/README.md Command to format the Solidity code in the Symbiotic Periphery project according to predefined style guidelines using Forge's formatting tool. Promotes code consistency and readability. ```shell forge fmt ``` -------------------------------- ### Build Symbiotic Periphery Contracts using Forge Source: https://github.com/symbioticfi/periphery/blob/main/README.md Command to compile the Solidity smart contracts within the Symbiotic Periphery project using the Forge build tool. This is a standard step before testing or deploying contracts. ```shell forge build ``` -------------------------------- ### Environment Variables for Symbiotic Periphery Development Source: https://github.com/symbioticfi/periphery/blob/main/README.md Defines the necessary environment variables for setting up the development environment for Symbiotic Periphery contracts. Includes RPC URLs for Ethereum and Holesky networks, and an optional Etherscan API key. ```env ETH_RPC_URL= ETH_RPC_URL_HOLESKY= ETHERSCAN_API_KEY= ``` -------------------------------- ### IDefaultCollateral API Source: https://context7.com/symbioticfi/periphery/llms.txt API reference for the IDefaultCollateral contract, including methods for depositing assets to mint collateral tokens and withdrawing assets by burning collateral tokens. ```APIDOC ## POST /deposit (IDefaultCollateral) ### Description Deposit underlying assets to mint default collateral tokens. ### Method POST ### Endpoint /deposit ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **recipient** (address) - Required - The address that will receive the newly minted collateral tokens. - **amount** (uint256) - Required - The amount of underlying tokens to deposit. ### Request Example ```json { "recipient": "0xabcd...", "amount": "1000000000000000000" } ``` ### Response #### Success Response (200) - **amountMinted** (uint256) - The amount of collateral tokens minted. #### Response Example ```json { "amountMinted": "1000000000000000000" } ``` ## POST /withdraw (IDefaultCollateral) ### Description Withdraw underlying assets by burning default collateral tokens. ### Method POST ### Endpoint /withdraw ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **recipient** (address) - Required - The address that will receive the underlying assets. - **amount** (uint256) - Required - The amount of underlying assets to withdraw (this will burn the corresponding collateral tokens from the caller). ### Request Example ```json { "recipient": "0xabcd...", "amount": "500000000000000000" } ``` ### Response #### Success Response (200) This endpoint does not return specific data upon success, but the transaction will result in the transfer of underlying assets to the recipient and the burning of collateral tokens from the caller. #### Response Example (No specific JSON response) ``` -------------------------------- ### Test Symbiotic Periphery Contracts using Forge Source: https://github.com/symbioticfi/periphery/blob/main/README.md Command to execute the test suite for the Symbiotic Periphery contracts using the Forge testing framework. Ensures the contracts function as expected and helps identify regressions. ```shell forge test ``` -------------------------------- ### Deposit Collateral Assets to Vault (Solidity) Source: https://context7.com/symbioticfi/periphery/llms.txt The IVault.deposit function allows users to deposit collateral assets into a Symbiotic vault. In return for the deposited assets, the user receives vault shares, representing their stake in the vault's pooled assets. ```solidity // Setup vault and asset IVault vault = IVault(0x5678...); IERC20 asset = IERC20(vault.collateral()); // Approve vault to spend your assets uint256 depositAmount = 1000 * 1e18; asset.approve(address(vault), depositAmount); // Deposit to vault (uint256 depositedAmount, uint256 mintedShares) = vault.deposit( msg.sender, // beneficiary who receives shares depositAmount // amount of assets to deposit ); // Returns: // - depositedAmount: actual amount deposited (may differ for fee-on-transfer tokens) // - mintedShares: amount of vault shares minted ``` -------------------------------- ### Deposit Underlying Assets to Mint Default Collateral (Solidity) Source: https://context7.com/symbioticfi/periphery/llms.txt The IDefaultCollateral.deposit function allows users to deposit underlying assets into a default collateral contract to mint corresponding collateral tokens. This function is typically used in conjunction with a collateral factory to create new collateral contracts. ```solidity // Setup: Assume we have a token and collateral factory Token token = Token(0x1111...); IDefaultCollateralFactory factory = IDefaultCollateralFactory(0x1BC8FCFbE6Aa17e4A7610F51B888f34583D202Ec); // Create a default collateral for the token address collateralAddress = factory.create( address(token), type(uint256).max, // maximum supply limit address(0) // no limit increaser ); IDefaultCollateral collateral = IDefaultCollateral(collateralAddress); // Approve the collateral contract to spend your tokens token.approve(address(collateral), 1000 * 1e18); // Deposit tokens and mint collateral uint256 amountMinted = collateral.deposit( msg.sender, // recipient of collateral tokens 1000 * 1e18 // amount of underlying tokens to deposit ); // amountMinted equals 1000 * 1e18 collateral tokens ``` -------------------------------- ### DefaultCollateralMigrator.migrate Source: https://context7.com/symbioticfi/periphery/llms.txt Migrates default collateral to a vault in a single atomic transaction. This involves unwrapping the collateral and depositing the underlying assets into the specified vault, returning the deposited amount and minted vault shares. ```APIDOC ## POST /migrate ### Description Migrate default collateral to a vault in a single transaction by unwrapping collateral and depositing the underlying asset. ### Method POST ### Endpoint /migrate ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **collateralAddress** (address) - Required - The address of the default collateral contract. - **vaultAddress** (address) - Required - The address of the target vault. - **beneficiary** (address) - Required - The address that will receive the vault shares. - **amountToMigrate** (uint256) - Required - The amount of collateral tokens to migrate. ### Request Example ```json { "collateralAddress": "0x1234...", "vaultAddress": "0x5678...", "beneficiary": "0xabcd...", "amountToMigrate": "1000000000000000000" } ``` ### Response #### Success Response (200) - **depositedAmount** (uint256) - The actual amount of underlying asset deposited to the vault. - **mintedShares** (uint256) - The amount of vault shares minted to the beneficiary. #### Response Example ```json { "depositedAmount": "999000000000000000", "mintedShares": "999000000000000000" } ``` ``` -------------------------------- ### Withdraw Underlying Assets by Burning Default Collateral (Solidity) Source: https://context7.com/symbioticfi/periphery/llms.txt The IDefaultCollateral.withdraw function enables users to redeem underlying assets by burning their default collateral tokens. This process transfers the specified amount of underlying assets from the collateral contract to the user. ```solidity IDefaultCollateral collateral = IDefaultCollateral(0x1234...); // Withdraw underlying assets (burns collateral tokens from caller) collateral.withdraw( msg.sender, // recipient of underlying assets 500 * 1e18 // amount of underlying assets to withdraw ); // This burns 500 * 1e18 collateral tokens from msg.sender // and transfers 500 * 1e18 underlying tokens to msg.sender ``` -------------------------------- ### IVault.deposit Source: https://context7.com/symbioticfi/periphery/llms.txt Deposits collateral assets into a Symbiotic vault to receive vault shares. Returns the actual amount deposited and the amount of vault shares minted. ```APIDOC ## POST /deposit (IVault) ### Description Deposit collateral assets into a Symbiotic vault to receive vault shares. ### Method POST ### Endpoint /deposit ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **beneficiary** (address) - Required - The address who will receive the vault shares. - **depositAmount** (uint256) - Required - The amount of assets to deposit. ### Request Example ```json { "beneficiary": "0xabcd...", "depositAmount": "1000000000000000000" } ``` ### Response #### Success Response (200) - **depositedAmount** (uint256) - The actual amount deposited. This may differ for fee-on-transfer tokens. - **mintedShares** (uint256) - The amount of vault shares minted. #### Response Example ```json { "depositedAmount": "999000000000000000", "mintedShares": "999000000000000000" } ``` ``` -------------------------------- ### Migrate Default Collateral to Vaults (Solidity) Source: https://context7.com/symbioticfi/periphery/llms.txt The DefaultCollateralMigrator contract allows users to migrate assets from default collateral contracts to Symbiotic vaults in a single, atomic transaction. It handles unwrapping collateral and redepositing the underlying assets, simplifying the process and reducing transaction costs. ```solidity // Deploy the migrator contract DefaultCollateralMigrator migrator = new DefaultCollateralMigrator(); // Prepare the migration address collateralAddress = 0x1234...; // Default collateral contract address address vaultAddress = 0x5678...; // Target vault address address beneficiary = msg.sender; // Who receives the vault shares uint256 amountToMigrate = 1000 * 1e18; // Amount of collateral tokens // Approve the migrator to spend your collateral tokens IERC20(collateralAddress).approve(address(migrator), amountToMigrate); // Execute the migration (uint256 depositedAmount, uint256 mintedShares) = migrator.migrate( collateralAddress, vaultAddress, beneficiary, amountToMigrate ); // Returns: // - depositedAmount: actual amount of underlying asset deposited to vault // - mintedShares: amount of vault shares minted to beneficiary ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.