plutus-use-cases-1.2.0.0: Collection of smart contracts to develop the plutus/wallet interface
Safe HaskellNone
LanguageHaskell2010

Plutus.Contracts.Uniswap.OffChain

Synopsis

Documentation

poolStateCoinFromUniswapCurrency Source #

Arguments

:: CurrencySymbol

The currency identifying the Uniswap instance.

-> Coin PoolState 

Gets the Coin used to identity liquidity pools.

liquidityCoin Source #

Arguments

:: CurrencySymbol

The currency identifying the Uniswap instance.

-> Coin A

One coin in the liquidity pair.

-> Coin B

The other coin in the liquidity pair.

-> Coin Liquidity 

Gets the liquidity token for a given liquidity pool.

data CreateParams Source #

Parameters for the create-endpoint, which creates a new liquidity pool.

Constructors

CreateParams 

Fields

Instances

Instances details
Show CreateParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Generic CreateParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Associated Types

type Rep CreateParams :: Type -> Type Source #

FromJSON CreateParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

parseJSON :: Value -> Parser CreateParams

parseJSONList :: Value -> Parser [CreateParams]

ToJSON CreateParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

toJSON :: CreateParams -> Value

toEncoding :: CreateParams -> Encoding

toJSONList :: [CreateParams] -> Value

toEncodingList :: [CreateParams] -> Encoding

type Rep CreateParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

type Rep CreateParams = D1 ('MetaData "CreateParams" "Plutus.Contracts.Uniswap.OffChain" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "CreateParams" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cpCoinA") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin A)) :*: S1 ('MetaSel ('Just "cpCoinB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin B))) :*: (S1 ('MetaSel ('Just "cpAmountA") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Amount A)) :*: S1 ('MetaSel ('Just "cpAmountB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Amount B)))))

data SwapParams Source #

Parameters for the swap-endpoint, which allows swaps between the two different coins in a liquidity pool. One of the provided amounts must be positive, the other must be zero.

Constructors

SwapParams 

Fields

Instances

Instances details
Show SwapParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Generic SwapParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Associated Types

type Rep SwapParams :: Type -> Type Source #

FromJSON SwapParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

parseJSON :: Value -> Parser SwapParams

parseJSONList :: Value -> Parser [SwapParams]

ToJSON SwapParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

toJSON :: SwapParams -> Value

toEncoding :: SwapParams -> Encoding

toJSONList :: [SwapParams] -> Value

toEncodingList :: [SwapParams] -> Encoding

type Rep SwapParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

type Rep SwapParams = D1 ('MetaData "SwapParams" "Plutus.Contracts.Uniswap.OffChain" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "SwapParams" 'PrefixI 'True) ((S1 ('MetaSel ('Just "spCoinA") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin A)) :*: S1 ('MetaSel ('Just "spCoinB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin B))) :*: (S1 ('MetaSel ('Just "spAmountA") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Amount A)) :*: S1 ('MetaSel ('Just "spAmountB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Amount B)))))

data CloseParams Source #

Parameters for the close-endpoint, which closes a liquidity pool.

Constructors

CloseParams 

Fields

Instances

Instances details
Show CloseParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Generic CloseParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Associated Types

type Rep CloseParams :: Type -> Type Source #

FromJSON CloseParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

parseJSON :: Value -> Parser CloseParams

parseJSONList :: Value -> Parser [CloseParams]

ToJSON CloseParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

toJSON :: CloseParams -> Value

toEncoding :: CloseParams -> Encoding

toJSONList :: [CloseParams] -> Value

toEncodingList :: [CloseParams] -> Encoding

type Rep CloseParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

type Rep CloseParams = D1 ('MetaData "CloseParams" "Plutus.Contracts.Uniswap.OffChain" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "CloseParams" 'PrefixI 'True) (S1 ('MetaSel ('Just "clpCoinA") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin A)) :*: S1 ('MetaSel ('Just "clpCoinB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin B))))

data RemoveParams Source #

Parameters for the remove-endpoint, which removes some liquidity from a liquidity pool.

Constructors

RemoveParams 

Fields

Instances

Instances details
Show RemoveParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Generic RemoveParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Associated Types

type Rep RemoveParams :: Type -> Type Source #

FromJSON RemoveParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

parseJSON :: Value -> Parser RemoveParams

parseJSONList :: Value -> Parser [RemoveParams]

ToJSON RemoveParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

toJSON :: RemoveParams -> Value

toEncoding :: RemoveParams -> Encoding

toJSONList :: [RemoveParams] -> Value

toEncodingList :: [RemoveParams] -> Encoding

type Rep RemoveParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

type Rep RemoveParams = D1 ('MetaData "RemoveParams" "Plutus.Contracts.Uniswap.OffChain" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "RemoveParams" 'PrefixI 'True) (S1 ('MetaSel ('Just "rpCoinA") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin A)) :*: (S1 ('MetaSel ('Just "rpCoinB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin B)) :*: S1 ('MetaSel ('Just "rpDiff") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Amount Liquidity)))))

data AddParams Source #

Parameters for the add-endpoint, which adds liquidity to a liquidity pool in exchange for liquidity tokens.

Constructors

AddParams 

Fields

Instances

Instances details
Show AddParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Generic AddParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Associated Types

type Rep AddParams :: Type -> Type Source #

FromJSON AddParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

parseJSON :: Value -> Parser AddParams

parseJSONList :: Value -> Parser [AddParams]

ToJSON AddParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

toJSON :: AddParams -> Value

toEncoding :: AddParams -> Encoding

toJSONList :: [AddParams] -> Value

toEncodingList :: [AddParams] -> Encoding

type Rep AddParams Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

type Rep AddParams = D1 ('MetaData "AddParams" "Plutus.Contracts.Uniswap.OffChain" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "AddParams" 'PrefixI 'True) ((S1 ('MetaSel ('Just "apCoinA") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin A)) :*: S1 ('MetaSel ('Just "apCoinB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Coin B))) :*: (S1 ('MetaSel ('Just "apAmountA") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Amount A)) :*: S1 ('MetaSel ('Just "apAmountB") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Amount B)))))

type UniswapUserSchema = ((((((Endpoint "create" CreateParams .\/ Endpoint "swap" SwapParams) .\/ Endpoint "close" CloseParams) .\/ Endpoint "remove" RemoveParams) .\/ Endpoint "add" AddParams) .\/ Endpoint "pools" ()) .\/ Endpoint "funds" ()) .\/ Endpoint "stop" () Source #

Schema for the endpoints for users of Uniswap.

data UserContractState Source #

Type of the Uniswap user contract state.

Constructors

Pools [((Coin A, Amount A), (Coin B, Amount B))] 
Funds Value 
Created 
Swapped 
Added 
Removed 
Closed 
Stopped 

Instances

Instances details
Show UserContractState Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Generic UserContractState Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Associated Types

type Rep UserContractState :: Type -> Type Source #

FromJSON UserContractState Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

Methods

parseJSON :: Value -> Parser UserContractState

parseJSONList :: Value -> Parser [UserContractState]

ToJSON UserContractState Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

type Rep UserContractState Source # 
Instance details

Defined in Plutus.Contracts.Uniswap.OffChain

type Rep UserContractState = D1 ('MetaData "UserContractState" "Plutus.Contracts.Uniswap.OffChain" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (((C1 ('MetaCons "Pools" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [((Coin A, Amount A), (Coin B, Amount B))])) :+: C1 ('MetaCons "Funds" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value))) :+: (C1 ('MetaCons "Created" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Swapped" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Added" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Removed" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Closed" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Stopped" 'PrefixI 'False) (U1 :: Type -> Type))))

type UniswapOwnerSchema = Endpoint "start" () Source #

start :: forall w s. Contract w s Text Uniswap Source #

Creates a Uniswap "factory". This factory will keep track of the existing liquidity pools and enforce that there will be at most one liquidity pool for any pair of tokens at any given time.

create :: forall w s. Uniswap -> CreateParams -> Contract w s Text () Source #

Creates a liquidity pool for a pair of coins. The creator provides liquidity for both coins and gets liquidity tokens in return.

add :: forall w s. Uniswap -> AddParams -> Contract w s Text () Source #

Adds some liquidity to an existing liquidity pool in exchange for newly minted liquidity tokens.

remove :: forall w s. Uniswap -> RemoveParams -> Contract w s Text () Source #

Removes some liquidity from a liquidity pool in exchange for liquidity tokens.

close :: forall w s. Uniswap -> CloseParams -> Contract w s Text () Source #

Closes a liquidity pool by burning all remaining liquidity tokens in exchange for all liquidity remaining in the pool.

swap :: forall w s. Uniswap -> SwapParams -> Contract w s Text () Source #

Uses a liquidity pool two swap one sort of coins in the pool against the other.

pools :: forall w s. Uniswap -> Contract w s Text [((Coin A, Amount A), (Coin B, Amount B))] Source #

Finds all liquidity pools and their liquidity belonging to the Uniswap instance. This merely inspects the blockchain and does not issue any transactions.

ownerEndpoint :: Contract (Last (Either Text Uniswap)) EmptySchema ContractError () Source #

userEndpoints :: Uniswap -> Promise (Last (Either Text UserContractState)) UniswapUserSchema Void () Source #

Provides the following endpoints for users of a Uniswap instance:

create
Creates a liquidity pool for a pair of coins. The creator provides liquidity for both coins and gets liquidity tokens in return.
swap
Uses a liquidity pool two swap one sort of coins in the pool against the other.
close
Closes a liquidity pool by burning all remaining liquidity tokens in exchange for all liquidity remaining in the pool.
remove
Removes some liquidity from a liquidity pool in exchange for liquidity tokens.
add
Adds some liquidity to an existing liquidity pool in exchange for newly minted liquidity tokens.
pools
Finds all liquidity pools and their liquidity belonging to the Uniswap instance. This merely inspects the blockchain and does not issue any transactions.
funds
Gets the caller's funds. This merely inspects the blockchain and does not issue any transactions.
stop
Stops the contract.

covIdx :: CoverageIndex Source #

findUniswapFactoryAndPool :: forall w s. Uniswap -> Coin A -> Coin B -> Contract w s Text ((TxOutRef, DecoratedTxOut, [LiquidityPool]), (TxOutRef, DecoratedTxOut, LiquidityPool, Amount Liquidity)) Source #

uniswapInstance :: Uniswap -> TypedValidator Uniswapping Source #

liquidityPolicy :: Uniswap -> MintingPolicy Source #

uniswapScript :: Uniswap -> Validator Source #

liquidityCurrency :: Uniswap -> CurrencySymbol Source #

lpTicker :: LiquidityPool -> TokenName Source #

Generate a unique token name for this particular pool; based on the tokens it exchanges. This should be such that looking for a pool exchanging any two tokens always yields a unique name.

funds :: forall w s. Contract w s Text Value Source #

Gets the caller's funds.