Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- poolStateCoinFromUniswapCurrency :: CurrencySymbol -> Coin PoolState
- liquidityCoin :: CurrencySymbol -> Coin A -> Coin B -> Coin Liquidity
- data CreateParams = CreateParams {}
- data SwapParams = SwapParams {}
- data CloseParams = CloseParams {}
- data RemoveParams = RemoveParams {}
- data AddParams = AddParams {}
- type UniswapUserSchema = ((((((Endpoint "create" CreateParams .\/ Endpoint "swap" SwapParams) .\/ Endpoint "close" CloseParams) .\/ Endpoint "remove" RemoveParams) .\/ Endpoint "add" AddParams) .\/ Endpoint "pools" ()) .\/ Endpoint "funds" ()) .\/ Endpoint "stop" ()
- data UserContractState
- type UniswapOwnerSchema = Endpoint "start" ()
- start :: forall w s. Contract w s Text Uniswap
- create :: forall w s. Uniswap -> CreateParams -> Contract w s Text ()
- add :: forall w s. Uniswap -> AddParams -> Contract w s Text ()
- remove :: forall w s. Uniswap -> RemoveParams -> Contract w s Text ()
- close :: forall w s. Uniswap -> CloseParams -> Contract w s Text ()
- swap :: forall w s. Uniswap -> SwapParams -> Contract w s Text ()
- pools :: forall w s. Uniswap -> Contract w s Text [((Coin A, Amount A), (Coin B, Amount B))]
- ownerEndpoint :: Contract (Last (Either Text Uniswap)) EmptySchema ContractError ()
- userEndpoints :: Uniswap -> Promise (Last (Either Text UserContractState)) UniswapUserSchema Void ()
- findSwapA :: Amount A -> Amount B -> Amount A -> Integer
- findSwapB :: Amount A -> Amount B -> Amount B -> Integer
- covIdx :: CoverageIndex
- findUniswapFactoryAndPool :: forall w s. Uniswap -> Coin A -> Coin B -> Contract w s Text ((TxOutRef, DecoratedTxOut, [LiquidityPool]), (TxOutRef, DecoratedTxOut, LiquidityPool, Amount Liquidity))
- uniswapInstance :: Uniswap -> TypedValidator Uniswapping
- liquidityPolicy :: Uniswap -> MintingPolicy
- uniswapScript :: Uniswap -> Validator
- poolStateCoin :: Uniswap -> Coin PoolState
- liquidityCurrency :: Uniswap -> CurrencySymbol
- lpTicker :: LiquidityPool -> TokenName
- calculateRemoval :: Amount A -> Amount B -> Amount Liquidity -> Amount Liquidity -> (Amount A, Amount B)
- funds :: forall w s. Contract w s Text Value
Documentation
poolStateCoinFromUniswapCurrency Source #
Gets the Coin
used to identity liquidity pools.
:: 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.
Instances
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.
Instances
data CloseParams Source #
Parameters for the close
-endpoint, which closes a liquidity pool.
Instances
data RemoveParams Source #
Parameters for the remove
-endpoint, which removes some liquidity from a liquidity pool.
Instances
Parameters for the add
-endpoint, which adds liquidity to a liquidity pool in exchange for liquidity tokens.
Instances
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.
Pools [((Coin A, Amount A), (Coin B, Amount B))] | |
Funds Value | |
Created | |
Swapped | |
Added | |
Removed | |
Closed | |
Stopped |
Instances
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.
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.
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.