DebtToken
Debt tokens are interest-accruing tokens that are minted and burned on borrow
and repay
, representing the debt owed by the token holder. There are 2 types of debt tokens:
Stable Debt Tokens: represent a debt to the protocol with stable interest rate.
Variable Debt Tokens: represent a debt to the protocol with variable interest rate.
Stable Debt Tokens are not currently being used in SparkLend, they are a legacy piece of technology that will be fully deprecated at some point in the future.
Debt tokens are not transferable.
The s/vToken value is pegged 1:1 to the value of underlying borrowed asset and represents the current total amount owed to the protocol i.e. principal debt + interest accrued.
EIP20 Methods
Although debt tokens are modelled on the ERC20/EIP20 standard, they are non-transferrable. Therefore they do not implement any of the standard ERC20/EIP20 functions relating to transfer()
and allowance()
.
Following are the standard EIP20 methods that are implemented for the debt tokens:
balanceOf
function balanceOf(address account)
Returns the most up to date accumulated debt (principal+interest) of the user.
totalSupply
function totalSupply()
Returns the most up to date total debt accrued by all protocol users for that specific type (stable or variable rate) of debt token.
decimals
function decimals()
Returns decimals of the token contract.
symbol
function symbol()
Returns the symbol of the token contract.
name
function name()
Returns the name of the token contract.
EIP712 Methods
DOMAIN_SEPARATOR
function DOMAIN_SEPARATOR()
Get the domain separator for the token at current chain.
nonces
function nonces(address owner)
Returns the nonce value for address specified as parameter. This is the nonce used when calling permit()
SparkLend Specific Methods
Shared View Methods
Below are the view methods available for both type, stable and variable, of debt tokens.
POOL
function POOL()
Returns the address of the associated Pool for the debt token.
borrowAllowance
function borrowAllowance(address fromUser, address toUser)
UNDERLYING_ASSET_ADDRESS
function UNDERLYING_ASSET_ADDRESS()
Returns the underlying asset of the debt token.
getIncentivesController
function getIncentivesController()
Returns the address of the Incentives Controller contract
Shared Write Methods
Below are the write methods available for both type, stable and variable, of debt tokens.
approveDelegation
function approveDelegation(address delegatee, uint256 amount)
Sets the amount
of allowance for delegatee
to borrow of a particular debt token.
delegationWithSig
function delegationWithSig(address delegator, address delegatee, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
Sets the value
of allowance for delegatee
to borrow of a particular debt token via permit function.
setIncentivesController
function setIncentivesController(ISparkIncentivesController controller)
Sets a new Incentives Controller.
Only Pool Admin can call this methods. To update Incentives Controller on main Spark market, Governance Proposal must be submitted.
Stable Debt Token Methods
getAverageStableRate
function getAverageStableRate()
Returns the average stable rate across all the stable rate debt in the protocol as uint256
.
getUserLastUpdated
function getUserLastUpdated(address user)
Returns the timestamp of the last action taken by user
as uint40
.
getUserStableRate
function getUserStableRate(address user)
Returns the stable rate of user
as uint256
.
getSupplyData
function getSupplyData()
Returns the principal, the total supply, the average stable rate and the timestamp for the last update.
Return Values
getTotalSupplyAndAvgRate
function getTotalSupplyAndAvgRate()
Returns the total supply and average stable rate of the token.
Return Values
getTotalSupplyLastUpdated
function getTotalSupplyLastUpdated()
Returns the timestamp of the last update of the total supply in uint40
.
principalBalanceOf
function principalBalanceOf(address user)
Returns the principal debt balance of the user since the last burn/mint action.
Variable Debt Token Methods
scaledBalanceOf
function scaledBalanceOf(address user)
Returns the scaled debt balance of user
. The scaled balance is the sum of all the updated stored balance divided by the reserve's liquidity index at the moment of the update.
getScaledUserBalanceAndSupply
function getScaledUserBalanceAndSupply(address user)
Returns the scaled balance of the user and the scaled total supply.
scaledTotalSupply
function scaledTotalSupply()
Returns the scaled total supply of the debt token. Represents sum(debt/index)
getPreviousIndex
function getPreviousIndex(address user)
Returns last index interest that was accrued to the user's balance (expressed in ray).
Last updated