This document describes an architcture desgin of lending plapps (plasma apps). I outlined the specification referring to Dharma project functionalities. Special thanks to @ben_chain for review.
We defined 2 predicates, swap predicate and collateral predicate based on Plasma Group's specification.
You first use swap predicate to set up a collateral.
Then, lender will execute collateral predicate.
This is a setup phase of lending. The debtor makes a collateral state described in the next section and swap it for the loaned token.
It's basically the same design as swap predicate, but collateralizer wants to cancel collateral when a swap fails. Hence, requirements are
verifyTransaction
witness
is a signature by preState.data.owner
postState
is a collateral statepostState
has the ownership of collateralizerstruct lendingStateData:
collateralizer: address
lender: address
amount: uint256
grace_period: uint256
There are 2 methods.
refundCollateral
methodRefund collateral. Lender gets a refund on the collateral after debt enters default.
returnCollateral
methodCollateral is returned to the original collateralizer of the debt agreement.
The collateralizer can get collateral in exchange for the "repayment".
verifyTransaction
Refund collateral.
block.number
is bigger than preState.data.grace_period
witness
is a signature by preState.data.lender
block.number
is bigger than preState.data.grace_period
postState.range
has the same amount as transaction.range
postState
is a ownership state of prestate.data.lender
block.number
is smaller than preState.data.grace_period
witness
is a signature by preState.data.collateralizer
(Alice)preState.data.amount
postState.range
has the same amount as transaction.range
postState
has the ownership state of collateralizerI think she can, as far as she proves that her "repayment" is valid. It means recievers of tokenA should verify tokenB's history. It requires addtional amount of history.
When operator withholds a block, Alice should be able to exit her collateral state. The grace period should be added for its upcoming challenge period.
Bob can keep using tokenA after its grace period. When Bob attempts to use tokenA maliciously, for example when he (and colluded operator) transfers tokenA to someone before the grace period ends, Alice should be able to exit tokenA as soon as possible.