Risk Marketplace
DEX providing liquidity for the SMART Tokens
The Risk Marketplace is a weighted constant product automated market maker (AMM) that enables decentralized token trading. It is a fork of Balancer V1, significantly modified for the specific use case of The Risk Protocol. The DEX supports two main types of swaps: standard swaps and split-and-swap operations.
1. Types of Swaps
Standard Swap: Users can trade between underlying assets and the SMART tokens within customized elastic supply pools.
Split and Swap: This function allows users to deposit the underlying token and simultaneously swap one of the resulting SMART tokens for the other in a single, atomic transaction. This is particularly useful for traders who prefer to hold only one type of SMART token.
2. Core Mechanism
The Risk Marketplace uses a weighted constant product invariant to determine token prices and swap outputs. Unlike traditional constant product AMMs (x × y = k), it extends the formula to support multiple tokens with customizable weights:
Where:
= Balance of token (i) in the pool
= Normalized weight of token (i)
= Invariant (remains constant during swaps)
This design allows pools to hold 2-8 tokens with arbitrary weight distributions (e.g., 80/20, 60/20/20), enabling more capital-efficient exposure to specific assets.
Spot Price
The spot price between any two tokens in the pool is derived from their balance and weight ratios:
Where:
: Balance of token i, the token being sold by the trader (going into the pool).
: Balance of token o, the token being bought by the trader (coming out of the pool).
: Weight of token i.
: Weight of token o.
3. Swap Calculations
3. a) Output Given Input (Exact In)
When a user specifies an exact input amount, the output is calculated as:
Where:
: Output token amount
: Input token amount
: Pool balances for tokens (i) and (o), respectively
: Weights of tokens (i) and (o)
3. b) Input Given Output (Exact Out)
When a user specifies an exact output amount, the required input is:
Where:
: Input token amount needed
: Desired output token amount
: Pool balances for tokens (i) and (o), respectively
: Weights of tokens (i) and (o)
Last updated
