Skip to content

Commit

Permalink
Merge pull request #23 from Cardinal-Cryptography/rm-uniswap
Browse files Browse the repository at this point in the history
  • Loading branch information
deuszx authored Sep 11, 2023
2 parents b9b9d72 + 7314b47 commit 21c9b42
Show file tree
Hide file tree
Showing 40 changed files with 93 additions and 100 deletions.
60 changes: 30 additions & 30 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
members = ["uniswap-v2/contracts/**", "farm/contracts"]
members = ["amm/contracts/**", "farm/contracts"]

exclude = ["e2e-tests", "uniswap-v2/logics"]
exclude = ["e2e-tests", "amm/logics"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ build-node-arm64:
build-node-x86_64:
@docker buildx build --pull --platform linux/amd64 -t aleph-onenode-chain-x86_64 --load docker

UNI_CONTRACTS = ./uniswap-v2/contracts
UNI_CONTRACTS = ./amm/contracts
UNI_CONTRACTS_PATHS := $(shell find $(UNI_CONTRACTS) -mindepth 1 -maxdepth 1 -type d)

FARM_CONTRACTS = ./farm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pair_contract = { path = "../pair", default-features = false, features = [
"ink-as-dependency",
] }
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", tag = "3.1.1", default-features = false }
uniswap_v2 = { path = "../../logics", default-features = false }
amm = { path = "../../logics", default-features = false }

[lib]
name = "factory_contract"
Expand All @@ -31,7 +31,7 @@ std = [
"scale/std",
"scale-info/std",
"openbrush/std",
"uniswap_v2/std",
"amm/std",
"pair_contract/std",
]
ink-as-dependency = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@

#[openbrush::contract]
pub mod factory {
use amm::{
ensure,
impls::factory::{
factory::{
only_fee_setter,
Internal,
},
*,
},
traits::factory::*,
};
use ink::{
codegen::{
EmitEvent,
Expand All @@ -19,17 +30,6 @@ pub mod factory {
},
};
use pair_contract::pair::PairContractRef;
use uniswap_v2::{
ensure,
impls::factory::{
factory::{
only_fee_setter,
Internal,
},
*,
},
traits::factory::*,
};

#[ink(event)]
pub struct PairCreated {
Expand Down Expand Up @@ -202,10 +202,7 @@ pub mod factory {
fn initialize_works() {
let accounts = default_accounts::<ink::env::DefaultEnvironment>();
let factory = FactoryContract::new(accounts.alice, Hash::default());
assert_eq!(
factory.factory.fee_to,
uniswap_v2::helpers::ZERO_ADDRESS.into()
);
assert_eq!(factory.factory.fee_to, amm::helpers::ZERO_ADDRESS.into());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", tag =
"psp22",
"reentrancy_guard",
] }
uniswap_v2 = { path = "../../logics", default-features = false }
amm = { path = "../../logics", default-features = false }
primitive-types = { version = "0.11.1", default-features = false, features = [
"codec",
] }
Expand All @@ -31,13 +31,7 @@ doctest = false

[features]
default = ["std"]
std = [
"ink/std",
"scale/std",
"scale-info/std",
"openbrush/std",
"uniswap_v2/std",
]
std = ["ink/std", "scale/std", "scale-info/std", "openbrush/std", "amm/std"]
ink-as-dependency = []

[profile.dev]
Expand Down
34 changes: 17 additions & 17 deletions uniswap-v2/contracts/pair/lib.rs → amm/contracts/pair/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,7 @@

#[openbrush::contract]
pub mod pair {
use ink::{
codegen::{
EmitEvent,
Env,
},
prelude::vec::Vec,
};
use openbrush::{
contracts::{
psp22::*,
reentrancy_guard::*,
},
modifiers,
traits::Storage,
};
use sp_arithmetic::traits::IntegerSquareRoot;
use uniswap_v2::{
use amm::{
ensure,
helpers::{
math::casted_mul,
Expand All @@ -38,6 +22,22 @@ pub mod pair {
types::WrappedU256,
},
};
use ink::{
codegen::{
EmitEvent,
Env,
},
prelude::vec::Vec,
};
use openbrush::{
contracts::{
psp22::*,
reentrancy_guard::*,
},
modifiers,
traits::Storage,
};
use sp_arithmetic::traits::IntegerSquareRoot;

#[ink(event)]
pub struct Mint {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ scale-info = { version = "2.3", default-features = false, features = [
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", tag = "3.1.1", default-features = false, features = [
"psp22",
] }
uniswap_v2 = { path = "../../logics", default-features = false }
amm = { path = "../../logics", default-features = false }

[lib]
name = "router_contract"
Expand All @@ -34,7 +34,7 @@ std = [
"scale-info",
"scale-info/std",
"openbrush/std",
"uniswap_v2/std",
"amm/std",
]
ink-as-dependency = []

Expand Down
20 changes: 10 additions & 10 deletions uniswap-v2/contracts/router/lib.rs → amm/contracts/router/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@

#[openbrush::contract]
pub mod router {
use ink::{
codegen::Env,
env::CallFlags,
prelude::vec::Vec,
};
use openbrush::{
modifiers,
traits::Storage,
};
use uniswap_v2::{
use amm::{
ensure,
helpers::{
helper::*,
Expand All @@ -30,6 +21,15 @@ pub mod router {
router::*,
},
};
use ink::{
codegen::Env,
env::CallFlags,
prelude::vec::Vec,
};
use openbrush::{
modifiers,
traits::Storage,
};

#[ink(storage)]
#[derive(Default, Storage)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ scale-info = { version = "2.3", default-features = false, features = [
openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", tag = "3.1.1", default-features = false, features = [
"psp22",
] }
uniswap_v2 = { path = "../../logics", default-features = false }
amm = { path = "../../logics", default-features = false }

[lib]
name = "wnative_contract"
Expand All @@ -31,7 +31,7 @@ std = [
"scale-info",
"scale-info/std",
"openbrush/std",
"uniswap_v2/std",
"amm/std",
]
ink-as-dependency = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#[openbrush::contract]
pub mod wnative {
use amm::traits::wnative::{
wnative_external,
Wnative,
};
use ink::{
codegen::{
EmitEvent,
Expand All @@ -17,10 +21,6 @@ pub mod wnative {
String,
},
};
use uniswap_v2::traits::wnative::{
wnative_external,
Wnative,
};

#[ink(event)]
pub struct Transfer {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions uniswap-v2/logics/Cargo.toml → amm/logics/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "uniswap_v2"
name = "amm"
version = "0.2.0"
authors = ["Cardinal Cryptography"]
edition = "2021"
Expand Down Expand Up @@ -30,7 +30,7 @@ curve25519-dalek = { version = "4.0.0-rc.2", features = ["digest"] }
sha2 = "0.10.6"

[lib]
name = "uniswap_v2"
name = "amm"
path = "lib.rs"
crate-type = ["rlib"]

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 21c9b42

Please sign in to comment.