An open API service indexing awesome lists of open source software.

https://github.com/efficacy-finance/kriya-dex-interface


https://github.com/efficacy-finance/kriya-dex-interface

Last synced: 5 months ago
JSON representation

Awesome Lists containing this project

README

          

# Kriya AMM interface

This document provides guidance on integrating the Kriya AMM contract.

## Deployed addresses

| Network | Latest published at address |
| ------- | ------------------------------------------------------------------ |
| mainnet | 0xa0eba10b173538c8fecca1dff298e488402cc9ff374f8a12ca7758eebe830b66 |
| testnet | 0xb5722117aec83525c71f84c31c1f28e29397feffa95c99cce72a150a555a63dd |

## Kriya protocol

This document will provide a comprehensive overview of the core features integral to the functionality of the Kriya AMM Interface.

### Structs

1. LP Token

```rust
struct KriyaLPToken has key, store {
id: UID,
pool_id: ID,
lsp: Coin>
}

```

2. Pool

```rust

/// Kriya AMM Pool object.
struct Pool has key {
id: UID,
/// Balance of Coin in the pool.
token_y: Balance,
/// Balance of Coin in the pool.
token_x: Balance,
/// LP total supply share.
lsp_supply: Supply>,
/// Minimum required liquidity, non-withdrawable
lsp_locked: Balance>,
/// LP fee percent. Range[1-10000] (30 -> 0.3% fee)
lp_fee_percent: u64,
/// Protocol fee percent. Range[1-10000] (30 -> 0.3% fee)
protocol_fee_percent: u64,
/// Protocol fee pool to hold collected Coin as fee.
protocol_fee_x: Balance,
/// Protocol fee pool to hold collected Coin as fee.
protocol_fee_y: Balance,
/// If the pool uses the table_curve_formula
is_stable: bool,
/// 10^ Decimals of Coin
scaleX: u64,
/// 10^ Decimals of Coin
scaleY: u64,
/// if trading is active for this pool
is_swap_enabled: bool,
/// if adding liquidity is enabled
is_deposit_enabled: bool,
/// if removing liquidity is enabled
is_withdraw_enabled: bool
}

```

### Core Features Overview

1. Create Pool

- amm/sources/spot_dex.move

```rust

/// Creates pool with following arguments
public fun create_pool(
protocol_configs: &ProtocolConfigs,
is_stable: bool,
coin_metadata_x: &CoinMetadata,
coin_metadata_y: &CoinMetadata,
ctx: &mut TxContext
): Pool {}

```

2. Add liquidity

- amm/sources/spot_dex.move

```rust

/// Add liquidity to the `Pool`. Sender needs to provide both
/// `Coin` and `Coin`, and in exchange he gets `Coin` -
/// liquidity provider tokens.
public fun add_liquidity(
pool: &mut Pool,
token_y: Coin,
token_x: Coin,
token_y_amount: u64,
token_x_amount: u64,
amount_y_min_deposit: u64,
amount_x_min_deposit: u64,
ctx: &mut TxContext
): KriyaLPToken {}

```

3. Remove liquidity

- amm/sources/spot_dex.move

```rust

/// Remove liquidity from the `Pool` by burning `Coin`.
/// Returns `Coin` and `Coin`.
public fun remove_liquidity(
pool: &mut Pool,
lp_token: KriyaLPToken,
amount: u64,
ctx: &mut TxContext
): (Coin, Coin) {}

```

4. Swap X

- amm/sources/spot_dex.move

```rust

/// Swap `Coin` for the `Coin`.
/// Returns the swapped `Coin`.
public fun swap_token_x(
pool: &mut Pool, token_x: Coin, amount: u64, min_recieve_y: u64, ctx: &mut TxContext
): Coin {}

```

5. Swap Y

- amm/sources/spot_dex.move

```rust

/// Swap `Coin` for the `Coin`.
/// Returns Coin.
public fun swap_token_y(
pool: &mut Pool, token_y: Coin, amount: u64, min_recieve_x: u64, ctx: &mut TxContext
): Coin {}

```

changes to move.toml to inlcude KriyaDEX as dependency.

```
[dependencies]
...
kriya_spot_dex = { git = "https://github.com/efficacy-finance/kriya-dex-interface.git", subdir = "./", rev = "latest", override = true }

[addresses]
kriya = "0xe10f85f47c6d11f63e650aa7daf168c55ead9abb6da4227eba5dd5e4f8d890b1"
```