Comment on page
CDP
The full name of CDP is Collateralized Debt Position.
UDT:user defined token.
The number of collaterals kept, the number of stablecoins minted, the type of collateral, as well as owner information, interest, time, etc.
The contract has 3 business logic: staking (borrowing), redemption (repayment), liquidation.
Code: https://github.com/NexisDao/NexisDao-core/tree/main/contracts/cdp.
Confirm that the value of the collateralized asset is greater than the loan amount * stake rate.
- 1.Judging the number of the script in the output is only 1.
- 2.Data: TAI.amount, UDT.amount, UDT_id(config id), owner.hash.
- 3.Read the lock hash verification from the configuration.
- 4.output[0].lock==lock in the configuration.
- 5.Verify output[1].lock=output[0].lock.
- 6.Verify that output[0].type is UDT, and the u128 of data is consistent with the parameter UDT.amount
- 7.Read the UDT mortgage rate and other information from the configuration.
- 8.Calculate how much TAI can be minted at most, and ensure that the value in data is less than this value.

Repay TAI and pay a small amount of interest, redeem the collateral assets.
- 1.Make sure that there is only one CDP in the input.
- 2.Make sure that input[0].lock==input[1].lock==UDTLock, and there are only two locks.
- 3.Make sure that input[0] is UDT; input[0].UDT.amount=CPD .udt.amount.
- 4.Ensure that output[0].lock=CPD.owner and UDT; output[0].amount=CPD.udt.amount.
- 5.Ensure that input.TAI.amount-output.TAI.amount=CDP.TAI.
- 6.Ensure output [1].lock=CommunityLock, is TAI and amount>=handling fee.

When the price of UDT falls and the bottom line is triggered, the collaterals will be liquidated.
The bottom line is the stake rate of assets; the stake rate of different UDTs may be different.
Liquidation process:
- 1.When UDT price drops, UDT price * quantity <= TAI quantity * pledge rate, the order is allowed to be liquidated.
- 2.UDT.lock verifies the existence of CDP.
- 3.CDP.lock verifies the existence of CDP.
- 4.CDP.type verifies that the number of UDTs is correct.
- 5.CDP.type confirms that the input has no TAI, then go through the liquidation process.
- 6.CDP.type verifies that the UDT value is lower than the staking threshold.
- 7.Debt exists in output.
- 8.Debt.type verifies that CDP exists.
- 9.Debt.type verifies that the locks of UDT and Debt are correct

Last modified 1yr ago