Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ resolver = "2"
members = [
"contracts/tbrg-token",
"contracts/oracle",
"contracts/pool-factory"
"contracts/pool-factory",
"contracts/amm",
"contracts/liquidity-mining",
"contracts/synthetic-asset-factory",
"contracts/options",
"contracts/yield-strategy",
"contracts/flash-loan-router"
]

exclude = [
Expand Down
13 changes: 13 additions & 0 deletions contracts/amm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "amm"
version = "0.1.0"
edition = "2021"
authors = ["TrustBridge Team"]

[lib]
crate-type = ["cdylib"]

[dependencies]
soroban-sdk = { workspace = true }

Comment on lines +1 to +12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Verify if additional math dependencies are needed for AMM operations.

The manifest looks correct, but AMM contracts typically require advanced math operations (square root calculations, fixed-point arithmetic for pricing). Confirm that soroban-sdk provides all necessary numeric primitives, or consider adding specialized math libraries if needed.


🏁 Script executed:

#!/bin/bash
# Description: Check if soroban-sdk provides sqrt and other math operations needed for AMM

# Search for sqrt usage in AMM implementation
rg -n --type=rust -C3 'sqrt' contracts/amm/

# Search for math operations or numeric types
rg -n --type=rust -C3 '(U256|I256|fixed.*point|FixedPoint)' contracts/amm/

Length of output: 0



21 changes: 21 additions & 0 deletions contracts/amm/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use soroban_sdk::contracterror;

#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[repr(u32)]
pub enum AmmError {
/// Invalid token amount provided
InvalidAmount = 1,
/// Slippage tolerance exceeded
SlippageExceeded = 2,
/// Invalid token address
InvalidToken = 3,
/// Insufficient liquidity in pool
InsufficientLiquidity = 4,
/// Insufficient LP shares
InsufficientShares = 5,
/// Invalid token ordering
InvalidTokenOrder = 6,
/// Invalid fee rate
InvalidFeeRate = 7,
}
29 changes: 29 additions & 0 deletions contracts/amm/src/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use soroban_sdk::{contracttype, Address};

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct DepositEvent {
pub depositor: Address,
pub amount_a: i128,
pub amount_b: i128,
pub shares: i128,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct WithdrawEvent {
pub withdrawer: Address,
pub shares: i128,
pub amount_a: i128,
pub amount_b: i128,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SwapEvent {
pub from: Address,
pub sell_token: Address,
pub sell_amount: i128,
pub buy_token: Address,
pub buy_amount: i128,
}
Loading