-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from input-output-hk/MetaLamp/lending-pool/cha…
…nge-folder-structure [WIP] Change folder structure
- Loading branch information
Showing
46 changed files
with
1,347 additions
and
873 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Ext.Plutus.Ledger.Value where | ||
|
||
import qualified Data.Map as Map | ||
import Ledger (TxOut (txOutValue), | ||
TxOutTx (txOutTxOut), Value) | ||
import Ledger.AddressMap (UtxoMap) | ||
import Plutus.V1.Ledger.Value (Value) | ||
|
||
utxoValue :: UtxoMap -> Value | ||
utxoValue = foldMap (txOutValue . txOutTxOut . snd) . Map.toList |
85 changes: 85 additions & 0 deletions
85
MetaLamp/lending-pool/src/Plutus/Abstract/ContractResponse.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
module Plutus.Abstract.ContractResponse where | ||
|
||
import qualified Control.Lens as Lens | ||
import Control.Monad hiding (fmap) | ||
import qualified Data.ByteString as BS | ||
import qualified Data.Map as Map | ||
import Data.Monoid (Last (..)) | ||
import Data.Proxy (Proxy (..)) | ||
import Data.Text (Text, pack) | ||
import qualified Data.Text as Text | ||
import Data.Void (Void) | ||
import Ledger hiding (singleton) | ||
import Ledger.Constraints as Constraints | ||
import Ledger.Constraints.OnChain as Constraints | ||
import Ledger.Constraints.TxConstraints as Constraints | ||
import qualified Ledger.Scripts as Scripts | ||
import qualified Ledger.Typed.Scripts as Scripts | ||
import Playground.Contract | ||
import Plutus.Abstract.OutputValue (OutputValue (..)) | ||
import qualified Plutus.Abstract.TxUtils as TxUtils | ||
import Plutus.Contract hiding (when) | ||
import Plutus.Contracts.Currency as Currency | ||
import Plutus.Contracts.LendingPool.OnChain.Core (Aave, | ||
AaveDatum (..), | ||
AaveRedeemer (..), | ||
Reserve (..), | ||
UserConfig (..)) | ||
import qualified Plutus.Contracts.LendingPool.OnChain.Core as Core | ||
import qualified Plutus.Contracts.Service.FungibleToken as FungibleToken | ||
import Plutus.V1.Ledger.Ada (adaValueOf, | ||
lovelaceValueOf) | ||
import qualified Plutus.V1.Ledger.Address as Addr | ||
import Plutus.V1.Ledger.Value as Value | ||
import qualified PlutusTx | ||
import qualified PlutusTx.AssocMap as AssocMap | ||
import PlutusTx.Prelude hiding (Monoid (..), | ||
Semigroup (..), | ||
mconcat, unless) | ||
import Prelude (Monoid (..), | ||
Semigroup (..), | ||
show, subtract) | ||
import qualified Prelude | ||
import Text.Printf (printf) | ||
|
||
data ContractResponse e a = ContractSuccess a | ContractError e | ContractPending | ||
deriving stock (Prelude.Eq, Show, Generic) | ||
deriving anyclass (ToJSON, FromJSON) | ||
|
||
instance Semigroup (ContractResponse e a) where | ||
a <> b = b | ||
|
||
instance Monoid (ContractResponse e a) where | ||
mempty = ContractPending | ||
mappend = (<>) | ||
|
||
withContractResponse :: forall l a p r s. | ||
HasEndpoint l p s | ||
=> Proxy l | ||
-> (a -> r) | ||
-> (p -> Contract (ContractResponse Text r) s Text a) | ||
-> Contract (ContractResponse Text r) s Void () | ||
withContractResponse _ g c = do | ||
e <- runError $ do | ||
p <- endpoint @l | ||
_ <- tell ContractPending | ||
errorHandler `handleError` c p | ||
tell $ case e of | ||
Left err -> ContractError err | ||
Right a -> ContractSuccess $ g a | ||
where | ||
errorHandler e = do | ||
logInfo @Text ("Error submiting the transaction: " <> e) | ||
throwError e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Plutus.Abstract.State (module Export) | ||
|
||
where | ||
|
||
import Plutus.Abstract.State.Select as Export | ||
import Plutus.Abstract.State.Update as Export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.