Skip to content
Open
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
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ members = [
"backend/external_canisters/sns_swap/c2c_client",
"backend/external_canisters/sns_wasm/api",
"backend/external_canisters/sns_wasm/c2c_client",
"backend/external_canisters/taco_exchange/api",
"backend/external_canisters/taco_exchange/c2c_client",
"backend/integration_tests",
"backend/legacy_bots/api",
"backend/legacy_bots/c2c_client",
Expand Down
15 changes: 15 additions & 0 deletions backend/canisters/user/api/src/updates/swap_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ pub struct Args {
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum ExchangeArgs {
ICPSwap(ICPSwapArgs),
Taco(TacoArgs),
}

impl ExchangeArgs {
pub fn exchange_id(&self) -> ExchangeId {
match self {
ExchangeArgs::ICPSwap(_) => ExchangeId::ICPSwap,
ExchangeArgs::Taco(_) => ExchangeId::Taco,
}
}

pub fn swap_canister_id(&self) -> CanisterId {
match self {
ExchangeArgs::ICPSwap(a) => a.swap_canister_id,
ExchangeArgs::Taco(a) => a.swap_canister_id,
}
}
}
Expand All @@ -44,6 +47,18 @@ pub struct ExchangeSwapArgs {

pub type ICPSwapArgs = ExchangeSwapArgs;

#[ts_export(user, swap_tokens)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct TacoArgs {
/// The TACO exchange canister that handles swap_multi_hop / swap_split_routes
/// (production: qioex-5iaaa-aaaan-q52ba-cai).
pub swap_canister_id: CanisterId,
/// The exchange-treasury canister that holds deposited tokens — this is the
/// account TACO's `checkReceive` validates the user's ICRC1 transfer against
/// (production: qbnpl-laaaa-aaaan-q52aq-cai). Distinct from swap_canister_id.
pub treasury_canister_id: CanisterId,
}

#[ts_export(user, swap_tokens)]
#[derive(Serialize, Deserialize, Debug)]
pub enum Response {
Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/user/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ sns_governance_canister_c2c_client = { path = "../../../external_canisters/sns_g
stable_memory = { path = "../../../libraries/stable_memory" }
stable_memory_map = { path = "../../../libraries/stable_memory_map" }
storage_bucket_client = { path = "../../../libraries/storage_bucket_client" }
taco_exchange_canister = { path = "../../../external_canisters/taco_exchange/api" }
taco_exchange_canister_c2c_client = { path = "../../../external_canisters/taco_exchange/c2c_client" }
timer_job_queues = { path = "../../../libraries/timer_job_queues" }
tracing = { workspace = true }
types = { path = "../../../libraries/types" }
Expand Down
7 changes: 6 additions & 1 deletion backend/canisters/user/impl/src/token_swaps/icpswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ impl SwapClient for ICPSwapClient {
}
}

async fn swap(&self, amount: u128, min_amount_out: u128) -> Result<Result<SwapSuccess, String>, C2CError> {
async fn swap(
&self,
amount: u128,
min_amount_out: u128,
_deposit_block_index: Option<u64>,
) -> Result<Result<SwapSuccess, String>, C2CError> {
let args = icpswap_swap_pool_canister::swap::Args {
operator: self.this_canister_id,
amount_in: amount.to_string(),
Expand Down
1 change: 1 addition & 0 deletions backend/canisters/user/impl/src/token_swaps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use types::{C2CError, CanisterId};

pub mod icpswap;
pub mod swap_client;
pub mod taco;

fn nat_to_u128(value: Nat) -> u128 {
value.0.try_into().unwrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ pub trait SwapClient {
}
async fn deposit_account(&self) -> Result<Account, C2CError>;
async fn deposit(&self, amount: u128) -> Result<u128, C2CError>;
async fn swap(&self, amount: u128, min_amount_out: u128) -> Result<Result<SwapSuccess, String>, C2CError>;
async fn swap(
&self,
amount: u128,
min_amount_out: u128,
deposit_block_index: Option<u64>,
) -> Result<Result<SwapSuccess, String>, C2CError>;
async fn withdraw(&self, successful_swap: bool, amount: u128) -> Result<u128, C2CError>;
}

Expand Down
Loading