-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement loan example #137
Comments
data LoanActions = RequestLoan | CancelLoan deriving Eq
data LoanBond = LB { borrower :: PubKeyHash
, request :: Ledger.Value
, duration :: POSIXTime
, collateral :: Ledger.Value
} |
{-# INLINABLE loanRequest #-}
loanRequest :: LoanBond -> LoanActions -> PlutusV2.ScriptContext -> Bool
loanRequest datum action sContext
| action == RequestLoan = requestLoan
| action == CancelLoan = cancelLoan
| otherwise = False
where
info :: LedgerV2.TxInfo
info = LedgerV2.scriptContextTxInfo sContext
timeoutReached :: Bool
timeoutReached = contains (from $ duration datum) (LedgerV2.txInfoValidRange info)
requestLoan :: Bool
requestLoan = timeoutReached
cancelLoan :: Bool
cancelLoan = if (length (txInfoOutputs info) == 1) then (pubKeyHashAddress $ borrower datum) == txOutAddress $ head ((txInfoOutputs info)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/Vortecsmaster/EA_PlutusExamples/tree/master/PlutusApps/V2_110/LendingPlatform
https://github.com/input-output-hk/plutus-use-cases
The text was updated successfully, but these errors were encountered: