onFlashLoan() :
This function is used to facilitate a flash loan on the DToken contract. A flash loan is a type of loan that is taken out and repaid in a single transaction. This allows users to borrow funds without having to provide collateral or go through a lengthy approval process. The flash loan is taken out from a liquidity pool and is repaid with the same amount of tokens plus a fee. The data parameter is used to provide the necessary information for the flash loan, such as the amount of tokens to be borrowed and the address of the liquidity pool. The onFlashLoan function will then execute the flash loan and return the borrowed tokens to the user. (autogenerated documentation)
CALLER() :
This function is used to retrieve the underlying asset, storage, proxy address, and message sender associated with a given dToken. It does this by first unpacking the trailing parameters of the call, which should include the proxy address of the dToken. It then looks up the corresponding eToken address in the dTokenLookup mapping, and uses that to look up the associated asset storage in the eTokenLookup mapping. Finally, it returns the underlying asset, storage, proxy address, and message sender. (autogenerated documentation)
name() :
This function is an external view function that returns a string containing the name of the Euler Debt token and the name of the underlying ERC20 token. It does this by first getting the address of the caller, then using that address to get the name of the underlying ERC20 token, and finally combining the two strings and returning the result. (autogenerated documentation)
symbol() :
This function is used to retrieve the symbol of an ERC20 token. It does this by using the CALLER() function to get the address of the underlying token, and then using the IERC20 interface to call the symbol() function of the token. The result is then encoded and returned as a string. (autogenerated documentation)
decimals() :
This function is used to retrieve the number of decimals associated with an asset stored in the AssetStorage contract. It does this by calling the CALLER() function to access the AssetStorage contract, and then returning the underlyingDecimals value stored in the contract. (autogenerated documentation)
underlyingAsset() :
This function is used to retrieve the address of the underlying asset associated with a particular contract. It works by calling the CALLER() function, which returns the address of the caller, and then using that address to look up the underlying asset associated with the contract. The function then returns the address of the underlying asset. (autogenerated documentation)
totalSupply() :
This function is used to calculate and return the total supply of a given asset. It does this by first retrieving the asset storage and asset cache from the caller, then calculating the total supply by dividing the total borrows by the internal debt precision and the underlying decimal scaler. (autogenerated documentation)
totalSupplyExact() :
This function is used to retrieve the total supply of a given asset. It works by first retrieving the underlying asset and the associated AssetStorage from the caller, then loading the AssetCache in read-only mode. Finally, it returns the totalBorrows value from the AssetCache, which is the total supply of the asset. (autogenerated documentation)
balanceOf(address) :
This function returns the balance of a given account in the underlying asset of the contract. It does this by first retrieving the underlying asset and the asset storage from the caller, then loading the asset cache in read-only mode. Finally, it calculates the current owed amount for the given account and divides it by the underlying asset's decimal scaler to get the balance in the underlying asset. (autogenerated documentation)
balanceOfExact(address) :
This function returns the exact balance of a given account. It does this by first retrieving the underlying asset and the asset storage from the caller, then loading the asset cache in a read-only mode. Finally, it uses the getCurrentOwedExact function to calculate the exact balance of the given account. (autogenerated documentation)
borrow() :
This function allows a user to borrow a specified amount of tokens from a pool of tokens. It first updates the average liquidity of the user's account, then emits a RequestBorrow event. It then loads the asset cache from the underlying asset storage and decodes the external amount of tokens to be borrowed. It then pushes the tokens to the user's account and increases the borrow amount in the asset storage. Finally, it checks the liquidity of the account and logs the asset status. (autogenerated documentation)
repay() :
This function allows a user to repay a loan from a sub-account. It first updates the average liquidity of the account, then emits a RequestRepay event. It then loads the asset cache from the underlying asset storage, and calculates the amount owed by the account. If the amount specified is greater than the amount owed, it is set to the amount owed. The function then pulls the tokens from the sender and decreases the borrow amount from the proxy address and the account. Finally, it logs the asset status. (autogenerated documentation)
flashLoan() :
This function allows a user to borrow a certain amount of a given underlying asset from the contract. The user must provide a data payload as part of the transaction. The contract then transfers the amount of the underlying asset to the user's address. The user can then use the asset for whatever purpose they wish. After the user is done with the asset, they must return it to the contract, otherwise an error will be thrown. (autogenerated documentation)
approveDebt(address) :
This function allows an account to approve a spender to spend a certain amount of debt on their behalf. It takes in a subAccountId, spender address, and amount as parameters. It first checks that the spender is not the same as the account, then it loads the assetCache from the assetStorage, and sets the dTokenAllowance for the account and spender to the amount specified, or to the maximum amount if the amount specified is the maximum amount. Finally, it emits an approval event via the proxy address. (autogenerated documentation)
debtAllowance(address,address) :
This function is used to retrieve the allowance of a given holder and spender for a given asset. It takes two addresses as parameters, the holder and the spender, and returns the allowance as a uint. The function first retrieves the underlying asset and the associated asset storage, then loads the asset cache in read-only mode. It then retrieves the allowance from the asset storage and divides it by the underlying asset's decimal scaler to get the allowance in the correct units. Finally, it returns the allowance as a uint. (autogenerated documentation)
transfer(address) :
This function is used to transfer a specified amount of tokens from the address of the contract (address(0)) to a specified address (to). It returns a boolean value indicating whether the transfer was successful or not. The function is marked as reentrantOK, which means that it can be called from other functions without causing any issues. (autogenerated documentation)
transferFrom(address,address) :
This function is used to transfer debt tokens (dTokens) from one address to another. It first checks that the from and to addresses are not the same, and then emits a RequestTransferDToken event. It then decodes the external amount of dTokens to be transferred and checks if the sender has sufficient allowance to transfer the dTokens. If so, it calls the transferBorrow function to transfer the dTokens and then checks the liquidity of the to address. Finally, it logs the asset status. (autogenerated documentation)