CollateralSettlerERC20is here to settle the positions associated to a collateral for a given stablecoin if this collateral is revoked for this stablecoin. If a collateral is revoked for a stablecoin, it means that SLPs and HAs cannot open or close their positions on it and that it is impossible to use it to issue stablecoins or to redeem this collateral against the stablecoin.
CollateralSettlerContractmust be activated by the
StableMasterwhich freezes oracle values for HAs and exchange rates for SLPs.
perpetualManager: Address of the
sanToken: Address of the
agToken: Address of the
poolManager: Address of the
underlyingToken: Collateral of interest
angle: Governance token of the protocol
oracle: Address of the Oracle contract corresponding to the pool being closed. It is used to fetch the price at which stablecoins are going to be converted in collateral at the end of the settlement period
collatBase: this is not a reference to a contract, but this represents the base used in the collateral implementation
proportionalRatioGovUser: Used to compute the portion of the user claim that is going to be considered as a claim for governance tokens for a unit amount of governance tokens brought. This ratio should be between an amount of governance tokens and an amout of stablecoins
proportionalRatioGovLP: Used to compute the portion of the HA or SLP claim that is going to be considered as a claim for governance tokens for a unit amount of governance tokens brought
claimTime: Time after the trigger in which users and LPs can come and claim their collateral
triggerSettlementfunction, they cannot be changed after that.
oracleValueHA: Value of the oracle at settlement trigger time used to compute HA claims
sanRate: Exchange rate between sanTokens and collateral at settlement trigger time
maxStablecoinsClaimable: Maximum number of stablecoins that can be claimed using this collateral type. The reason for this parameter is that in case of generalized collateral settlement where all collateral types are settled, it prevents users from all claiming the same collateral thus penalizing HAs and SLPs of this collateral and advantaging HAs and SLPs of other collateral types. This parameter is set equal to the
stocksUsersfor this collateral type at the time of activation
amountToRedistribute: Total amount of collateral to redistribute. This parameter can still be adjusted by governance during the claim period
startTimestamp: Time at which settlement was triggered
oracleValueUsers: This value is not defined at the activation of the contract, it is just computed at the end of the claim period. It is the value of the oracle used to settle users. The reason for using a different value than for HAs is that the real value of the oracle could change during the claim time. In case of the revokation of a single collateral, there could be if we used the same value as HAs arbitrages among users seeing that the value of the oracle at which they are going to be settled differ from the current oracle value. Or in case of multiple collateral being revoked at the same time, users could see a bargain in a collateral and all come to redeem one collateral in particular
totalUserClaims: Sum of the claims of users which did not bring governance tokens (expressed in stablecoin value)
totalUserClaimsWithGov: Sum of the claims of users which brought governance tokens (expressed in stablecoin value)
totalLpClaims: Sum of the claims from LPs (expressed in collateral)
totalLpClaimsWithGov: Sum of the claims from LPs which had governance tokens (expressed in collateral)
baseAmountToUserGov: Ratio between what can be given and the claim for each user with gov tokens. It is going to be updated (like the quantities below) at the end of the claim period.
baseAmountToUser: Ratio between what can be given and the claim for each user
baseAmountToLpGov: Ratio between what can be given and the claim for each LP with gov tokens
baseAmountToLp: Ratio between what can be given and the claim for each LP
baseAmountToEachComputed: Number to see if the setAmountToRedistributeEach function has already been called. This function can only be called once throughout the lifetime of the contract
userClaims: Mapping between an address and a claim (in collateral) for a stable holder
userClaimsWithGov: Mapping between an address and a claim and number of gov tokens due to a user
lpClaims: Mapping between the address of a LP and a claim
lpClaimsWithGov: Mapping between the address of a LP, its claim and the number of gov tokens brought
haClaimCheck: Mapping to check whether a HA perpetual has already been redeemed
GOVERNOR_ROLE: Given the importance of collateral settlement for the protocol and the need for decentralization in the process, it would not make sense to introduce a
StableMastercontract is the only one able to activate the contract
StableMastercontract after governance called
_oracleValue: Value of the oracle that will be used for the settlement to get the price of the concerned collateral with respect to that of the stablecoin
_sanRate: Value of the
sanRateat time of settlement to be able to convert an amount of sanTokens to an amount of collateral
_stocksUsers: Maximum amount of stablecoins that will be redeemable by users for this collateral
destaddress by sending agTokens and gov tokens (optional). The more gov tokens a user sent, the more preferably it ends up being treated during the redeem period
dest: Address of the user to claim collateral for
amountAgToken: Amount of agTokens sent
amountGovToken: Amount of governance sent
perpetualIDand gov tokens (optional). The contract automatically recognizes the beneficiary of the perpetual.
perpetualID: Perpetual owned by the HA
amountGovToken: Amount of governance sent
destby sending sanTokens and gov tokens (optional).
dest: Address to claim collateral for
amountSanToken: Amount of sanTokens sent
amountGovToken: Amount of governance tokens sent
setAmountToRedistributeEachfunction has been called. The entry point to redeem is the same for users, HAs and SLPs.
setAmountToDistributeEachfunction has been called to allocate the surplus of the contract elsewhere.
tokenAddress: Address of the token to recover
to: Address to send the remaining tokens to
amountToRecover: Amount to recover from the contract
_proportionalRatioGovUser: New ratio for users
_proportionalRatioGovLP: New Ratio for LPs (both SLPs and HAs)