Skip to content

Commit

Permalink
feat(maker): add fee swapper contract (maker) (#14)
Browse files Browse the repository at this point in the history
* WIP: add custom maker for Osmosis deployment

* WIP: maker first version

* WIP: add maker tests

* WIP: preapare test suite

* covering with tests

* more tests

* use spot price query instead of twap

* add test-tube based tests for maker

* linter happy

* bump deps

* add migration from dummy maker

* fix comment

* bump main crate version
  • Loading branch information
epanchee authored Apr 11, 2024
1 parent 136bd0e commit 95b95c4
Show file tree
Hide file tree
Showing 25 changed files with 2,914 additions and 266 deletions.
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

0 comments on commit 95b95c4

Please sign in to comment.