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.
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.lock==lock in the configuration.
- 5.Verify output.lock=output.lock.
- 6.Verify that output.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.lock==input.lock==UDTLock, and there are only two locks.
- 3.Make sure that input is UDT; input.UDT.amount=CPD .udt.amount.
- 4.Ensure that output.lock=CPD.owner and UDT; output.amount=CPD.udt.amount.
- 5.Ensure that input.TAI.amount-output.TAI.amount=CDP.TAI.
- 6.Ensure output .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.
- 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