RebalanceResolver

Description:

Proxy contract enabling upgradeable smart contract patterns. Delegates calls to an implementation contract.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "contracts/helpers/rebalanceHelperGelato.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.28;

import "../interfaces/IResolverGelato.sol";
import "../../altitude-v2/contracts/interfaces/internal/misc/incentives/rebalance/IRebalanceIncentivesController.sol";
import "../../altitude-v2/contracts/interfaces/internal/vault/extensions/groomable/IGroomableVault.sol";


contract RebalanceResolver is IResolverGelato {
    function checker(address rebalanceIncentivesController)
        external
        view
        override
        returns (bool canExec, bytes memory execPayload)
    {
        canExec = (
            IRebalanceIncentivesController(rebalanceIncentivesController)
                .canRebalance()
        );

        if (canExec) {
            execPayload = abi.encodeWithSelector(
                IGroomableVaultV1.rebalance.selector,
                address(
                    IRebalanceIncentivesController(
                        rebalanceIncentivesController
                    ).vault()
                )
            );
        }
    }
}"
    },
    "contracts/interfaces/IResolverGelato.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.28;

interface IResolverGelato {
    function checker(address rebalanceIncentivesController)
        external
        view
        returns (bool canExec, bytes memory execPayload);
}"
    },
    "altitude-v2/contracts/interfaces/internal/misc/incentives/rebalance/IRebalanceIncentivesController.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0.
pragma solidity 0.8.28;

/**
 * @author Altitude Labs
 **/

interface IRebalanceIncentivesController {
    event UpdateRebalanceDeviation(uint256 minDeviation_, uint256 maxDeviation_);
    event UpdateForceRebalance(bool forceRebalance_);

    // Rebalance Incentives Controller Errors
    error RIC_CAN_NOT_REBALANCE();
    error RIC_INVALID_DEVIATIONS();

    function vault() external view returns (address);

    function minDeviation() external view returns (uint256);

    function maxDeviation() external view returns (uint256);

    function rewardToken() external view returns (address);

    function forceRebalance() external view returns (bool);

    function currentThreshold() external view returns (uint256);

    function canRebalance() external view returns (bool);

    function setDeviation(uint256 minDeviation_, uint256 maxDeviation_) external;

    function setForceRebalance(bool forceRebalance_) external;

    function rebalance() external;
}
"
    },
    "altitude-v2/contracts/interfaces/internal/vault/extensions/groomable/IGroomableVault.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0.
pragma solidity 0.8.28;

import "../../../../../libraries/types/VaultTypes.sol";
import "./IGroomableManager.sol";

/**
 * @author Altitude Protocol
 **/

interface IGroomableVaultV1 is IGroomableManager {
    // Groomable Vault Errors
    error GR_V1_MIGRATION_PERCENTAGE_OUT_OF_RANGE();

    function migrateLender(address newStrategy) external;

    function migrateFarmDispatcher(address newFarmDispatcher) external;

    function rebalance() external;

    function setGroomableConfig(VaultTypes.GroomableConfig memory) external;

    function getGroomableConfig() external view returns (address, address, uint256);
}
"
    },
    "altitude-v2/contracts/libraries/types/VaultTypes.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;

/**
 * @title VaultTypes
 * @dev Input parameters for not having "Stack too deep"
 * @author Altitude Labs
 **/

library VaultTypes {
    /// @notice RegistryConfiguration parameters
    struct RegistryConfiguration {
        address registryAdmin; // global registry admin used to grant roles/access
        address tokensFactory; // tokens factory implementation
        address vaultInitImpl; // vault init implementation
        address proxyAdmin; // proxy admin implementation
    }

    /// @notice Vault BorrowLimit configuration parameters
    struct BorrowLimits {
        uint256 supplyThreshold; // loan-to-value up to which the user can borrow
        uint256 liquidationThreshold; // loan-to-value after which the user can be liquidated
        uint256 targetThreshold; // loan-to-value the vault targets to rebalance to
    }

    /// @notice Vault DefiProviders configuration parameters
    struct DefiProviders {
        address lending; // address of lending provider
        address farming; // address of farming provider
    }

    /// @notice Vault configuration parameters
    struct SnapshotableConfig {
        address snapshotableManager; // snapshotable manager implementation
        uint256 reserveFactor; // percentage of earnings to be allocated to the reserve
    }

    /// @notice Vault configuration parameters
    struct VaultConfig {
        address borrowVerifier; // borrow verifier implementation
        uint256 withdrawFeeFactor; // percentage of the withdraw fee
        uint256 withdrawFeePeriod; // number of blocks the withdraw fee is applied
        address configurableManager; // configurable manager implementation
        address swapStrategy; // swap strategy implementation
        address ingressControl; // ingress control implementation
    }

    /// @notice Vault Liquidation configuration parameters
    struct LiquidatableConfig {
        address liquidatableManager; // liquidatable manager implementation
        uint256 maxPositionLiquidation; // The maximum liquidation allowed by the contract, 18 decimals
        uint256 liquidationBonus; // The supply bonus that will be received by the liquidator, 18 decimals
    }

    /// @notice Vault Groomable configuration parameters
    struct GroomableConfig {
        address groomableManager; // groomable manager implementation
        address flashLoanStrategy; // flash loan strategy implementation
        uint256 maxMigrationFeePercentage; // a fixed percentage to check if the given flash loan strategy charges higher fees than we expect
    }

    /// @notice Vault Init configuration parameters
    struct VaultInit {
        VaultConfig vaultConfig; // vault configuration
        BorrowLimits borrowLimits; // borrow limits
        DefiProviders providers; // defi providers
    }

    /// @notice Vault Data parameters
    struct VaultData {
        VaultInit vaultInit; // vault init configuration
        LiquidatableConfig liquidatableConfig; // liquidatable configuration
        GroomableConfig groomableConfig; // groomable configuration
        SnapshotableConfig snapshotableConfig; // snapshotable configuration
    }
}
"
    },
    "altitude-v2/contracts/interfaces/internal/vault/extensions/groomable/IGroomableManager.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0.
pragma solidity 0.8.28;

import "../../../strategy/IFlashLoanCallback.sol";

/**
 * @author Altitude Protocol
 **/

interface IGroomableManager is IFlashLoanCallback {
    event RebalanceVaultLimit(bool shouldBorrow, uint256 calculatedAmount);
    event RebalanceVaultBorrow(uint256 amountToBorrow);
    event RebalanceVaultRepay(uint256 amountToRepay, uint256 amountWithdrawn);
    event MigrateLenderStrategy(address oldStrategy, address newStrategy);
    event MigrateFarmDispatcher(address oldFarmDispatcher, address newFarmDispatcher);

    // Groomable Manager Errors
    error GR_V1_MIGRATION_FEE_TOO_HIGH();
    error GR_V1_NOT_FLASH_LOAN_STRATEGY();
    error GR_V1_MIGRATION_OLD_SUPPLY_ERROR();
    error GR_V1_MIGRATION_OLD_BORROW_ERROR();
    error GR_V1_MIGRATION_NEW_SUPPLY_ERROR();
    error GR_V1_MIGRATION_NEW_BORROW_ERROR();
    error GR_V1_FARM_DISPATCHER_ALREADY_ACTIVE();
    error GR_V1_FARM_DISPATCHER_NOT_EMPTY();
    error GR_V1_LENDER_STRATEGY_ALREADY_ACTIVE();

    function migrateLender(address newStrategy) external;

    function migrateFarmDispatcher(address newFarmDispatcher) external;

    function rebalance() external;
}
"
    },
    "altitude-v2/contracts/interfaces/internal/strategy/IFlashLoanCallback.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0.
pragma solidity 0.8.28;

/**
 * @author Altitude Protocol
 **/

interface IFlashLoanCallback {
    function flashLoanCallback(bytes calldata, uint256) external;
}
"
    }
  },
  "settings": {
    "remappings": [
      "@altitude/=altitude-v2/",
      "@chainlink-local/contracts/=node_modules/@chainlink/contracts/",
      "@arbitrum/=node_modules/@arbitrum/",
      "@chainlink/=node_modules/@chainlink/",
      "@eth-optimism/=node_modules/@eth-optimism/",
      "@morpho-org/=altitude-v2/node_modules/@morpho-org/",
      "@offchainlabs/=node_modules/@offchainlabs/",
      "@openzeppelin/=node_modules/@openzeppelin/",
      "@pendle/=altitude-v2/node_modules/@pendle/",
      "@scroll-tech/=node_modules/@scroll-tech/",
      "@uniswap/=altitude-v2/node_modules/@uniswap/",
      "@zksync/=node_modules/@zksync/",
      "base64-sol/=altitude-v2/node_modules/base64-sol/",
      "forge-std/=altitude-v2/lib/forge-std/src/",
      "hardhat/=altitude-v2/node_modules/hardhat/",
      "solady/=node_modules/solady/"
    ],
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "metadata": {
      "useLiteralContent": false,
      "bytecodeHash": "ipfs",
      "appendCBOR": true
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "cancun",
    "viaIR": false
  }
}}

Tags:
Proxy, Swap, Upgradeable, Factory, Oracle|addr:0x59da17255d0f81ce4be640862c5e3bc6bcb09ce4|verified:true|block:23468347|tx:0x22cef5c6eee0a5142626530ea8963e9d8afaeae2f00ad64bef357c0b52339036|first_check:1759148912

Submitted on: 2025-09-29 14:28:33

Comments

Log in to comment.

No comments yet.