-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev-7. Weighted pools. For audit (#29)
* Balance Pool. Swap, Deposit, Redeem, DepositSingleAsset operations * cleanup * fix treasury validation * Redeem & Swap for random weights and fees fixes. * Fixes and looped test example fixed. * DEV-7. Balance pool. Optimizations (#36) * DEV-7. Balance pools. Deposit, Redeem balance orders contracts (#30) * add daoBalanceMintPolicyValidator * DEV-7. Balance pool: optimizations, redundant logic removed. ValidDelta bug fix (#39) * Balance pool. Optimizations, redundant logic removed, validDelta bug fix * update balanceFeeSwitch * remove redundant variable in ppow10 * Fix incorrect flow in deposit, redeem contracts * Balance pool. New approach (#43) * New approach for balance pools * remove invariant * fix balance contract --------- Co-authored-by: Ilya <[email protected]> --------- Co-authored-by: AOranov <[email protected]> Co-authored-by: Alex Oranov <[email protected]> Co-authored-by: Ilya <[email protected]>
- Loading branch information
1 parent
223a06c
commit 81e4288
Showing
27 changed files
with
2,376 additions
and
246 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 was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
plutarch-validators/WhalePoolsDex/Contracts/BalancePool.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,65 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
module WhalePoolsDex.Contracts.BalancePool ( | ||
BalancePoolConfig (..), | ||
BalancePoolAction (..), | ||
BalancePoolRedeemer (..) | ||
) where | ||
|
||
import PlutusTx.Builtins | ||
import qualified PlutusTx | ||
import PlutusLedgerApi.V1.Value | ||
import PlutusLedgerApi.V1.Crypto (PubKeyHash) | ||
import PlutusLedgerApi.V1.Scripts (ValidatorHash) | ||
import PlutusLedgerApi.V1.Credential | ||
|
||
data BalancePoolConfig = BalancePoolConfig | ||
{ poolNft :: AssetClass | ||
, poolX :: AssetClass | ||
, poolY :: AssetClass | ||
, poolLq :: AssetClass | ||
, poolFeeNum :: Integer | ||
, treasuryFee :: Integer | ||
, treasuryX :: Integer | ||
, treasuryY :: Integer | ||
, daoPolicy :: [StakingCredential] | ||
, treasuryAddress :: ValidatorHash | ||
} | ||
deriving stock (Show) | ||
|
||
PlutusTx.makeIsDataIndexed ''BalancePoolConfig [('BalancePoolConfig, 0)] | ||
|
||
data BalancePoolAction = Deposit | Redeem | Swap | DAOAction | ||
deriving (Show) | ||
|
||
instance PlutusTx.FromData BalancePoolAction where | ||
{-# INLINE fromBuiltinData #-} | ||
fromBuiltinData d = matchData' d (\_ _ -> Nothing) (const Nothing) (const Nothing) chooseAction (const Nothing) | ||
where | ||
chooseAction i | ||
| i == 0 = Just Deposit | ||
| i == 1 = Just Redeem | ||
| i == 2 = Just Swap | ||
| i == 3 = Just DAOAction | ||
| otherwise = Nothing | ||
|
||
instance PlutusTx.UnsafeFromData BalancePoolAction where | ||
{-# INLINE unsafeFromBuiltinData #-} | ||
unsafeFromBuiltinData = maybe (Prelude.error "Couln't convert BalancePoolAction from builtin data") id . PlutusTx.fromBuiltinData | ||
|
||
instance PlutusTx.ToData BalancePoolAction where | ||
{-# INLINE toBuiltinData #-} | ||
toBuiltinData a = mkI $ case a of | ||
Deposit -> 0 | ||
Redeem -> 1 | ||
Swap -> 2 | ||
DAOAction -> 3 | ||
|
||
data BalancePoolRedeemer = BalancePoolRedeemer | ||
{ action :: BalancePoolAction | ||
, selfIx :: Integer | ||
} | ||
deriving (Show) | ||
|
||
PlutusTx.makeIsDataIndexed ''BalancePoolRedeemer [('BalancePoolRedeemer, 0)] |
23 changes: 23 additions & 0 deletions
23
plutarch-validators/WhalePoolsDex/Contracts/Proxy/DepositBalance.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,23 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
module WhalePoolsDex.Contracts.Proxy.DepositBalance where | ||
|
||
import PlutusLedgerApi.V1.Crypto (PubKeyHash) | ||
import PlutusLedgerApi.V1.Value | ||
import qualified PlutusTx | ||
import PlutusTx.Builtins | ||
|
||
data DepositBalanceConfig = DepositBalanceConfig | ||
{ poolNft :: AssetClass | ||
, tokenA :: AssetClass | ||
, tokenB :: AssetClass | ||
, tokenLp :: AssetClass | ||
, exFee :: Integer | ||
, rewardPkh :: PubKeyHash | ||
, stakePkh :: Maybe PubKeyHash | ||
, collateralAda :: Integer | ||
} | ||
deriving stock (Show) | ||
|
||
PlutusTx.makeIsDataIndexed ''DepositBalanceConfig [('DepositBalanceConfig, 0)] |
22 changes: 22 additions & 0 deletions
22
plutarch-validators/WhalePoolsDex/Contracts/Proxy/RedeemBalance.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,22 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
module WhalePoolsDex.Contracts.Proxy.RedeemBalance where | ||
|
||
import PlutusLedgerApi.V1.Crypto (PubKeyHash) | ||
import PlutusLedgerApi.V1.Value | ||
import qualified PlutusTx | ||
import PlutusTx.Builtins | ||
|
||
data RedeemBalanceConfig = RedeemBalanceConfig | ||
{ poolNft :: AssetClass | ||
, poolX :: AssetClass | ||
, poolY :: AssetClass | ||
, poolLp :: AssetClass | ||
, exFee :: Integer | ||
, rewardPkh :: PubKeyHash | ||
, stakePkh :: Maybe PubKeyHash | ||
} | ||
deriving stock (Show) | ||
|
||
PlutusTx.makeIsDataIndexed ''RedeemBalanceConfig [('RedeemBalanceConfig, 0)] |
Oops, something went wrong.