Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(maker): add fee swapper contract (maker) #14

Merged
merged 14 commits into from
Apr 11, 2024
429 changes: 244 additions & 185 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ astroport = { git = "https://github.com/astroport-fi/astroport-core", version =
astroport-pcl-common = { git = "https://github.com/astroport-fi/astroport-core", version = "1.1.0" }
astroport-circular-buffer = { git = "https://github.com/astroport-fi/astroport-core", version = "0.1.0" }
astroport-native-coin-registry = "1.0.1"
osmosis-std = "0.21"
osmosis-std = "0.22"
itertools = "0.12"
34 changes: 34 additions & 0 deletions contracts/maker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "astroport-maker-osmosis"
version = "1.0.0"
authors = ["Astroport"]
edition = "2021"
description = "Astroport maker contract for Osmosis"
license = "GPL-3.0-only"

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

[features]
library = []

[dependencies]
cosmwasm-std = { version = "1", features = ["cosmwasm_1_1"] }
cosmwasm-schema = "1"
cw-storage-plus = "0.15"
osmosis-std.workspace = true
cw-utils = "1"
cw2 = "1"
astroport.workspace = true
astroport-on-osmosis = { path = "../../packages/astroport_on_osmosis", version = "1" }
astro-satellite-package = "1"
thiserror = "1.0"
itertools.workspace = true

[dev-dependencies]
cw-multi-test = { version = "0.20.0", features = ["cosmwasm_1_1"] }
anyhow = "1"
derivative = "2"
astroport-native-coin-registry = { workspace = true }
astroport-factory = { package = "astroport-factory-osmosis", path = "../factory" }
astroport-pcl-osmo = { path = "../pair_concentrated" }
63 changes: 63 additions & 0 deletions contracts/maker/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use cosmwasm_std::{CheckedMultiplyRatioError, OverflowError, StdError};
use cw2::VersionError;
use cw_utils::PaymentError;
use thiserror::Error;

use astroport_on_osmosis::maker::{PoolRoute, MAX_ALLOWED_SPREAD, MAX_SWAPS_DEPTH};

#[derive(Error, Debug, PartialEq)]
pub enum ContractError {
#[error("{0}")]
Std(#[from] StdError),

#[error("{0}")]
OverflowError(#[from] OverflowError),

#[error("{0}")]
PaymentError(#[from] PaymentError),

#[error("{0}")]
CheckedMultiplyRatioError(#[from] CheckedMultiplyRatioError),

#[error("{0}")]
VersionError(#[from] VersionError),

#[error("Unauthorized")]
Unauthorized {},

#[error("Max spread too high. Max allowed: {MAX_ALLOWED_SPREAD}")]
MaxSpreadTooHigh {},

#[error("Incorrect cooldown. Min: {min}, Max: {max}")]
IncorrectCooldown { min: u64, max: u64 },

#[error("Empty routes")]
EmptyRoutes {},

#[error("Pool {pool_id} doesn't have denom {denom}")]
InvalidPoolDenom { pool_id: u64, denom: String },

#[error("Message contains duplicated routes")]
DuplicatedRoutes {},

#[error("Route cannot start with ASTRO. Error in route: {route:?}")]
AstroInRoute { route: PoolRoute },

#[error("No registered route for {denom}")]
RouteNotFound { denom: String },

#[error("Collect cooldown has not elapsed. Next collect is possible at {next_collect_ts}")]
Cooldown { next_collect_ts: u64 },

#[error("Failed to build route for {denom}. Max swap depth {MAX_SWAPS_DEPTH}. Check for possible loops. Route taken: {route_taken}")]
FailedToBuildRoute { denom: String, route_taken: String },

#[error("Invalid reply id")]
InvalidReplyId {},

#[error("Empty collectable assets vector")]
EmptyAssets {},

#[error("Nothing to collect")]
NothingToCollect {},
}
Loading
Loading