V2 Fringe Finance Smart Contract Documentation
  • bToken
    • BErc20
    • BErc20Interface
    • BErc20Storage
    • BLendingToken
    • BToken
    • BTokenInterface
    • BTokenStorage
  • bondtroller
    • Bondtroller
    • BondtrollerV1Storage
    • BondtrollerV2Storage
    • BondtrollerV3Storage
    • BondtrollerV4Storage
    • BondtrollerV5Storage
  • interestRateModel
    • BaseJumpRateModelV2
    • InterestRateModel
    • JumpRateModelV3
  • interfaces
    • EIP20Interface
    • EIP20NonStandardInterface
    • IBErc20Token
    • IBLendingToken
    • IBPrimaryLendingPlatform
    • IComptroller
    • IPRJ
    • IPriceOracle
    • IPriceProviderAggregator
    • IPrimaryLendingPlatform
    • IPrimaryLendingPlatformLeverage
    • IPrimaryLendingPlatformLiquidation
    • ISimplePriceOracle
    • IUSDCTest
    • IWETH
    • IWstETH
  • mock
    • MockToken
    • MockWstETH
    • PRJ
    • WETH9
  • priceOracle
    • PriceOracle
    • PriceProviderAggregator
    • PriceProviderAggregatorPyth
    • priceproviders
      • ChainlinkPriceProvider
      • ChainlinkPriceProviderL2
      • ERC4626PriceProvider
      • LPPriceProvider
      • MutePriceProvider
      • PriceProvider
      • PythPriceProvider
      • UniswapV2PriceProvider
      • UniswapV2PriceProviderMock
      • UniswapV3PriceProvider
      • wstETHPriceProvider
      • wstETHPriceProviderL2
      • chainlink
        • AggregatorV3Interface
      • mute
        • IMuteSwitchPairDynamic
      • pyth
        • IPyth
        • PythStructs
      • uniswapV2
        • IUniswapV2Factory
        • IUniswapV2Pair
        • IUniswapV2Router02
        • SafeMath
        • UniswapV2Library
      • uniswapV3
        • v3-core
          • interfaces
            • IERC20Minimal
            • IUniswapV3Factory
            • IUniswapV3Pool
            • IUniswapV3PoolDeployer
            • pool
              • IUniswapV3PoolActions
              • IUniswapV3PoolDerivedState
              • IUniswapV3PoolEvents
              • IUniswapV3PoolImmutables
              • IUniswapV3PoolOwnerActions
              • IUniswapV3PoolState
          • libraries
            • TickMath
        • v3-periphery
          • libraries
            • OracleLibrary
  • primaryLendingPlatform
    • PrimaryLendingPlatformAtomicRepaymentCore
    • PrimaryLendingPlatformLeverageCore
    • PrimaryLendingPlatformLiquidationCore
    • PrimaryLendingPlatformModerator
    • PrimaryLendingPlatformProxyAdmin
    • PrimaryLendingPlatformV2Core
    • PrimaryLendingPlatformWrappedTokenGatewayCore
    • zksync
      • PrimaryLendingPlatformAtomicRepaymentZksync
      • PrimaryLendingPlatformLeverageZksync
      • PrimaryLendingPlatformLiquidationZksync
      • PrimaryLendingPlatformV2Zksync
      • PrimaryLendingPlatformWrappedTokenGatewayZksync
  • util
    • Asset
    • BondtrollerErrorReporter
    • CarefulMath
    • Errors
    • Exponential
    • ExponentialNoError
    • HomoraMath
    • TokenErrorReporter
  • paraswap
    • interfaces
      • IParaSwapAugustus
      • IParaSwapAugustusRegistry
Powered by GitBook
On this page
  • Overview
  • Enums info
  • Type
  • Structs info
  • Info
  • Functions info
  • _unwrap
  • _wrap
  • _redeem
  • _safeIncreaseAllowance
  1. util

Asset

Overview

License: MIT

library Asset

A library for handling different types of assets, including ERC20 tokens, ERC4626 tokens, and Uniswap V2 LP tokens.

Enums info

Type

enum Type {
	 ERC20,
	 ERC4626,
	 LP
}

Structs info

Info

struct Info {
	address addr;
	Asset.Type tokenType;
}

Functions info

_unwrap

function _unwrap(
    Asset.Info memory _tokenInfo,
    uint256 _tokenAmount
) internal returns (address[] memory assets, uint256[] memory assetAmounts)

Unwraps the specified amount of tokens based on their type.

Parameters:

Name
Type
Description

_tokenInfo

struct Asset.Info

Information about the token, including its address and type.

_tokenAmount

uint256

The amount of tokens to unwrap.

Return values:

Name
Type
Description

assets

address[]

The unwrapped assets' addresses.

assetAmounts

uint256[]

The amounts of the unwrapped assets.

_wrap

function _wrap(
    address[] memory _assets,
    uint256[] memory _assetAmounts,
    Asset.Info memory _tokenInfo
) internal returns (uint256 tokenAmount)

Wraps the specified amounts of assets into a token.

Parameters:

Name
Type
Description

_assets

address[]

The addresses of the assets to wrap.

_assetAmounts

uint256[]

The amounts of the assets to wrap.

_tokenInfo

struct Asset.Info

Information about the token, including its address and type.

Return values:

Name
Type
Description

tokenAmount

uint256

The amount of the wrapped token.

_redeem

function _redeem(
    Asset.Info memory _tokenInfo,
    address _receiver
) internal returns (address[] memory assets, uint256[] memory assetAmounts)

Redeems the redundant amount of tokens for the underlying assets.

Parameters:

Name
Type
Description

_tokenInfo

struct Asset.Info

Information about the token, including its address and type.

_receiver

address

The address that will receive the redeemed assets.

Return values:

Name
Type
Description

assets

address[]

The redeemed assets' addresses.

assetAmounts

uint256[]

The amounts of the redeemed assets.

_safeIncreaseAllowance

function _safeIncreaseAllowance(
    address _spender,
    address _token,
    uint256 _tokenAmount
) internal

Safely increases the allowance of a spender for a given token.

Parameters:

Name
Type
Description

_spender

address

The address allowed to spend the tokens.

_token

address

The address of the token.

_tokenAmount

uint256

The amount of tokens to allow.

PreviousutilNextBondtrollerErrorReporter

Last updated 7 months ago