here is the lib // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.19;…
- User
here is the lib // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.19;
import {AggregatorV3Interface} from "@chainlink/interfaces/AggregatorV3Interface.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {IDollarAmoMinter} from "../interfaces/IDollarAmoMinter.sol"; import {IERC20Ubiquity} from "../interfaces/IERC20Ubiquity.sol"; import {UBIQUITY_POOL_PRICE_PRECISION} from "./Constants.sol"; import {LibAppStorage} from "./LibAppStorage.sol"; import {LibTWAPOracle} from "./LibTWAPOracle.sol";
/**
-
@notice Ubiquity pool library
-
@notice Allows users to:
-
- deposit collateral in exchange for Ubiquity Dollars
-
- redeem Ubiquity Dollars in exchange for the earlier provided collateral */ library LibUbiquityPool { using SafeERC20 for IERC20; using SafeMath for uint256;
/// @notice Storage slot used to store data for this library bytes32 constant UBIQUITY_POOL_STORAGE_POSITION = bytes32( uint256(keccak256("ubiquity.contracts.ubiquity.pool.storage")) - 1 );
/// @notice Struct used as a storage for this library struct UbiquityPoolStorage { //======== // Core //======== // minter address -> is it enabled mapping(address amoMinter => bool isEnabled) isAmoMinterEnabled; //====================== // Collateral related //====================== // available collateral tokens address[] collateralAddresses; // collateral address -> collateral index mapping(address collateralAddress => uint256 collateralIndex) collateralIndex; // collateral index -> chainlink price feed addresses address[] collateralPriceFeedAddresses; // collateral index -> threshold in seconds when chainlink answer should be considered stale uint256[] collateralPriceFeedStalenessThresholds; // collateral index -> collateral price uint256[] collateralPrices; // array collateral symbols string[] collateralSymbols; // collateral address -> is it enabled mapping(address collateralAddress => bool isEnabled) isCollateralEnabled; // Number of decimals needed to get to E18. collateral index -> missing decimals uint256[] missingDecimals; // Total across all collaterals. Accounts for missing_decimals uint256[] poolCeilings; //==================== // Redeem related //==================== // user -> block number (collateral independent) mapping(address => uint256) lastRedeemedBlock; // 1010000 = 0.99 uint256 redeemPriceThreshold; // address -> collateral index -> balance mapping(address user => mapping(uint256 collateralIndex => uint256 amount)) redeemCollateralBalances; // number of blocks to wait before being able to collectRedemption() uint256 redemptionDelayBlocks; // collateral index -> balance uint256[] unclaimedPoolCollateral; //================ // Fees related //================ // minting fee of a particular collateral index, 1_000_000 = 100% uint256[] mintingFee; // redemption fee of a particular collateral index, 1_000_000 = 100% uint256[] redemptionFee; //================= // Pause related //================= // whether borrowing collateral by AMO minters is paused for a particular collateral index bool[] isBorrowPaused; // whether minting is paused for a particular collateral index bool[] isMintPaused; // whether redeeming is paused for a particular collateral index bool[] isRedeemPaused; }
-
- Assistant