Skip to content

Simple dex #612

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

Merged
merged 32 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c7c0e96
implementation sur course
fbielejec Sep 8, 2022
71d9c48
swaps done
fbielejec Sep 8, 2022
9f71ad0
add new role
fbielejec Sep 8, 2022
79b9e0a
added events
fbielejec Sep 8, 2022
974f056
wut
fbielejec Sep 8, 2022
ed2ad45
edited events
fbielejec Sep 8, 2022
56a4b04
set AC
fbielejec Sep 8, 2022
4476eaa
give why
fbielejec Sep 8, 2022
b12d883
docstring
fbielejec Sep 8, 2022
23f0cf3
modified docstring
fbielejec Sep 8, 2022
2012cfe
cleanup
fbielejec Sep 8, 2022
3be6987
Update contracts/simple_dex/lib.rs
fbielejec Sep 14, 2022
99952a4
simplified artihmetic
fbielejec Sep 14, 2022
e4d8211
moved roles to own mod
fbielejec Sep 15, 2022
1e31342
wZERO
fbielejec Sep 15, 2022
67cb4c8
dumbed down LP
fbielejec Sep 15, 2022
ff4e744
slippage check
fbielejec Sep 15, 2022
c2a36fc
check pool composition
fbielejec Sep 15, 2022
71523bf
explicitely check swap fee value that is set
fbielejec Sep 15, 2022
be7a316
change parameter name to avoid confusion, use integer operations
fbielejec Sep 16, 2022
b70278c
not payabale
fbielejec Sep 16, 2022
2c4213c
refactor
fbielejec Sep 16, 2022
d3fef1c
ok semver
fbielejec Sep 16, 2022
7210d54
refactor role check
fbielejec Sep 19, 2022
e767379
remove duplicated check
fbielejec Sep 19, 2022
ab507bf
Update contracts/wrapped_azero/lib.rs
fbielejec Sep 19, 2022
bed038f
remove unused dep
fbielejec Sep 19, 2022
bb854e9
Merge branch 'benjamin' into simple-dex
fbielejec Sep 20, 2022
00224a5
Update contracts/simple_dex/lib.rs
fbielejec Sep 23, 2022
40a42de
Update contracts/simple_dex/lib.rs
fbielejec Sep 23, 2022
65be1ac
added swap pairs
fbielejec Sep 23, 2022
9a67828
edited docstring
fbielejec Sep 23, 2022
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
2 changes: 1 addition & 1 deletion contracts/access_control/Cargo.lock

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

2 changes: 1 addition & 1 deletion contracts/access_control/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "access_control"
version = "0.1.0"
version = "0.2.0"
authors = ["Cardinal Cryptography"]
edition = "2021"
publish = false
Expand Down
24 changes: 5 additions & 19 deletions contracts/access_control/lib.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub use crate::access_control::{
AccessControlError, Role, ACCESS_CONTROL_PUBKEY, CHECK_ROLE_SELECTOR, HAS_ROLE_SELECTOR,
AccessControlError, ACCESS_CONTROL_PUBKEY, CHECK_ROLE_SELECTOR, HAS_ROLE_SELECTOR,
};
pub mod roles;
pub mod traits;
use ink_lang as ink;

#[ink::contract]
mod access_control {

use ink_lang::{codegen::EmitEvent, reflect::ContractEventBase};
use ink_storage::{
traits::{PackedLayout, SpreadAllocate, SpreadLayout},
Mapping,
};
use ink_storage::{traits::SpreadAllocate, Mapping};
use scale::{Decode, Encode};

use crate::roles::Role;

// address placeholder, to be set in the bytecode
// 4465614444656144446561444465614444656144446561444465614444656144 => 5DcPEG9AQ4Y9Lo9C5WXuKJDDawens77jWxZ6zGChnm8y8FUX
pub const ACCESS_CONTROL_PUBKEY: [u8; 32] = *b"DeaDDeaDDeaDDeaDDeaDDeaDDeaDDeaD";
pub const HAS_ROLE_SELECTOR: [u8; 4] = [0, 0, 0, 3];
pub const CHECK_ROLE_SELECTOR: [u8; 4] = [0, 0, 0, 5];

#[derive(Debug, Encode, Decode, Clone, Copy, SpreadLayout, PackedLayout, PartialEq, Eq)]
#[cfg_attr(
feature = "std",
derive(scale_info::TypeInfo, ink_storage::traits::StorageLayout)
)]
pub enum Role {
/// Indicates a superuser.
Admin(AccountId),
/// Indicates account can terminate a contract.
Owner(AccountId),
/// Indicates account can initialize a contract from a given code hash.
Initializer(Hash),
}

#[ink(storage)]
#[derive(SpreadAllocate)]
pub struct AccessControl {
Expand Down
19 changes: 19 additions & 0 deletions contracts/access_control/roles.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use ink_env::{AccountId, Hash};
use ink_storage::traits::{PackedLayout, SpreadLayout};
use scale::{Decode, Encode};

#[derive(Debug, Encode, Decode, Clone, Copy, SpreadLayout, PackedLayout, PartialEq, Eq)]
#[cfg_attr(
feature = "std",
derive(scale_info::TypeInfo, ink_storage::traits::StorageLayout)
)]
pub enum Role {
/// Indicates a superuser.
Admin(AccountId),
/// Indicates account can terminate a contract.
Owner(AccountId),
/// Indicates account can initialize a contract from a given code hash.
Initializer(Hash),
/// Indicates account can add liquidity to a DEX contract (call certain functions)
LiquidityProvider(AccountId),
}
2 changes: 1 addition & 1 deletion contracts/access_control/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ink_env::{
AccountId, DefaultEnvironment, Error as InkEnvError,
};

use crate::access_control::{Role, HAS_ROLE_SELECTOR};
use crate::{access_control::HAS_ROLE_SELECTOR, roles::Role};

pub trait AccessControlled {
type ContractError;
Expand Down
Loading