-
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.
- Loading branch information
1 parent
bbfa664
commit f57adab
Showing
12 changed files
with
475 additions
and
383 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
44 changes: 44 additions & 0 deletions
44
MetaLamp/lending-pool/src/Plutus/Abstract/IncentivizedAmount.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,44 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DeriveFunctor #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# OPTIONS_GHC -fno-specialise #-} | ||
{-# OPTIONS_GHC -fno-strictness #-} | ||
{-# OPTIONS_GHC -fno-ignore-interface-pragmas #-} | ||
{-# OPTIONS_GHC -fno-omit-interface-pragmas #-} | ||
{-# OPTIONS_GHC -fobject-code #-} | ||
|
||
module Plutus.Abstract.IncentivizedAmount where | ||
|
||
import qualified Control.Lens as Lens | ||
import Data.Aeson (FromJSON, ToJSON) | ||
import GHC.Generics | ||
import qualified Plutus.Abstract.TxUtils as TxUtils | ||
import Plutus.V1.Ledger.Slot (Slot (..)) | ||
import qualified PlutusTx | ||
import PlutusTx.Prelude | ||
import PlutusTx.Ratio (Ratio) | ||
import qualified Prelude | ||
import Schema (ToSchema) | ||
|
||
data IncentivizedAmount = IncentivizedAmount{ iaSlot :: Slot, iaRate :: Rational, iaAmount :: Rational } | ||
deriving stock (Prelude.Eq, Prelude.Show, Generic) | ||
deriving anyclass (ToJSON, FromJSON) | ||
|
||
Lens.makeClassy_ ''IncentivizedAmount | ||
|
||
instance Eq IncentivizedAmount where | ||
a == b = iaSlot a == iaSlot b && iaAmount a == iaAmount b && iaRate a == iaRate b | ||
|
||
{-# INLINABLE accrue #-} | ||
accrue :: Rational -> Slot -> IncentivizedAmount -> IncentivizedAmount | ||
accrue newRate newSlot (IncentivizedAmount oldSlot oldRate amount) = IncentivizedAmount newSlot newRate (amount * oldRate) |
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.