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

Farming contract #16

Merged
merged 41 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8d54617
Added farming contract
PierreOssun Oct 14, 2022
95f296b
Added storage + events
PierreOssun Oct 14, 2022
3245faf
separated Traits
PierreOssun Oct 14, 2022
aa90d40
Added Ownable + add
PierreOssun Oct 14, 2022
2d05454
update pool + storage refacto
PierreOssun Oct 17, 2022
b286a1c
Provide tentative stake/unstake features
HyunggyuJang Oct 18, 2022
0c0d7a0
Implement add correctly
HyunggyuJang Oct 18, 2022
bcc6192
Fix deposit (initialization is needed)
HyunggyuJang Oct 18, 2022
8e2dd3a
Refactor rewarders structure
HyunggyuJang Oct 18, 2022
9ba71f6
Merge pull request #12 from AstarNetwork/feature/farming-interface
HyunggyuJang Oct 19, 2022
031b7fb
updated toolchain
PierreOssun Oct 19, 2022
0bc28c9
Finished update all pools
PierreOssun Oct 19, 2022
9818239
pending arsw
PierreOssun Oct 19, 2022
d775935
set function
PierreOssun Oct 19, 2022
5681e3f
Merge branch 'main' into feature/farming-contract-add
PierreOssun Oct 19, 2022
164f293
fix mut of var
PierreOssun Oct 19, 2022
b5d89ea
fmt
PierreOssun Oct 19, 2022
c9d46ec
clean code - pr comments
PierreOssun Oct 20, 2022
b399ac5
Merge branch 'main' of github.com:AstarNetwork/uniswap-dex-example in…
PierreOssun Oct 20, 2022
d71ec07
refactor file structure
PierreOssun Oct 20, 2022
f148248
Impl rewarder
PierreOssun Oct 21, 2022
a10a9d2
withdraw & harvest
PierreOssun Oct 21, 2022
f1836b5
Finished update all pools
PierreOssun Oct 19, 2022
fce8b43
pending arsw
PierreOssun Oct 19, 2022
ddcaee7
set function
PierreOssun Oct 19, 2022
8248c1f
clean code - pr comments
PierreOssun Oct 20, 2022
09e2dfe
refactor file structure
PierreOssun Oct 20, 2022
d2e407c
Impl rewarder
PierreOssun Oct 21, 2022
79bbc70
withdraw & harvest
PierreOssun Oct 21, 2022
f438d6a
Merge branch 'feature/farming-contract-add' of github.com:AstarNetwor…
PierreOssun Oct 27, 2022
81b984b
Merge branch 'main' of github.com:AstarNetwork/uniswap-dex-example in…
PierreOssun Oct 27, 2022
3f6c0fa
Pr comments
PierreOssun Oct 27, 2022
801cf5c
Pr comments
PierreOssun Oct 27, 2022
c5c7232
Pr comments
PierreOssun Oct 27, 2022
5a8223d
Pr comments
PierreOssun Oct 28, 2022
3785d66
Added deposit_arsw + emergency_withdraw + withdraw_and_harvest
PierreOssun Oct 28, 2022
dd34a0b
refactor guards
PierreOssun Oct 28, 2022
995eb29
PR comments - clean code
PierreOssun Oct 31, 2022
115d004
PR comments
PierreOssun Oct 31, 2022
ce7eab0
cast as u128
PierreOssun Nov 4, 2022
cd310b9
Fixed error enum
PierreOssun Nov 4, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "farming_contract"
name = "master_chef_contract"
version = "0.1.0"
authors = ["Stake Technologies <devops@stake.co.jp>"]
edition = "2021"
Expand All @@ -19,7 +19,7 @@ openbrush = { version = "2.2.0", default-features = false, features = ["ownable"
farming = { path = "../../logics", default-features = false }

[lib]
name = "farming_contract"
name = "master_chef_contract"
path = "lib.rs"
crate-type = ["cdylib"]

Expand All @@ -38,4 +38,9 @@ std = [
"openbrush/std",
"farming/std"
]
ink-as-dependency = []

[profile.dev]
overflow-checks = false

[profile.release]
overflow-checks = false
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#![feature(min_specialization)]

#[openbrush::contract]
pub mod farming {
use farming::traits::{
pub mod master_chef_contract {
use farming::traits::master_chef::{
events::*,
farming::*,
getters::*,
Expand Down
45 changes: 45 additions & 0 deletions farming/contracts/rewarder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[package]
name = "rewarder_contract"
version = "0.1.0"
authors = ["Stake Technologies <devops@stake.co.jp>"]
edition = "2021"

[dependencies]
ink_primitives = { version = "~3.3.0", default-features = false }
ink_metadata = { version = "~3.3.0", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "~3.3.0", default-features = false }
ink_storage = { version = "~3.3.0", default-features = false }
ink_lang = { version = "~3.3.0", default-features = false }
ink_prelude = { version = "~3.3.0", default-features = false }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }

openbrush = { version = "2.2.0", default-features = false, features = ["psp22"] }
farming = { path = "../../logics", default-features = false }

[lib]
name = "rewarder_contract"
path = "lib.rs"
crate-type = ["cdylib"]

[features]
default = ["std"]
std = [
"ink_primitives/std",
"ink_metadata",
"ink_metadata/std",
"ink_env/std",
"ink_storage/std",
"ink_lang/std",
"scale/std",
"scale-info",
"scale-info/std",
"openbrush/std",
"farming/std"
]
[profile.dev]
overflow-checks = false

[profile.release]
overflow-checks = false
42 changes: 42 additions & 0 deletions farming/contracts/rewarder/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]

#[openbrush::contract]
pub mod rewarder {
use farming::traits::rewarder::{
data::*,
getters::*,
rewarder::*,
};
use ink_storage::traits::SpreadAllocate;
use openbrush::traits::Storage;

#[ink(storage)]
#[derive(Default, SpreadAllocate, Storage)]
pub struct Rewarderontract {
#[storage_field]
rewarder: Data,
}

impl Rewarder for Rewarderontract {}

impl RewarderGetters for Rewarderontract {}

impl Rewarderontract {
#[ink(constructor)]
pub fn new(
reward_multiplier: u32,
reward_token: AccountId,
master_chef: AccountId,
) -> Self {
ink_lang::codegen::initialize_contract(|instance: &mut Self| {
instance.rewarder.reward_multiplier = reward_multiplier;
instance.rewarder.reward_token = reward_token;
instance.rewarder.master_chef = master_chef;
})
}

#[ink(message)]
pub fn dummy(&self) {}
}
}
2 changes: 2 additions & 0 deletions farming/logics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ink_prelude = { version = "~3.3.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }

primitive-types = { version = "0.11.1", default-features = false, features = ["codec"] }
openbrush = { version = "2.2.0", default-features = false, features = ["ownable"] }

[lib]
Expand All @@ -37,4 +38,5 @@ std = [
"scale-info",
"scale-info/std",
"openbrush/std",
"primitive-types/std"
]
8 changes: 8 additions & 0 deletions farming/logics/helpers/helper.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#[macro_export]
macro_rules! ensure {
( $x:expr, $y:expr $(,)? ) => {{
if !$x {
return Err($y.into())
}
}};
}
5 changes: 5 additions & 0 deletions farming/logics/helpers/math.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use primitive_types::U256;

pub fn casted_mul(a: u128, b: u128) -> U256 {
U256::from(a) * U256::from(b)
}
2 changes: 2 additions & 0 deletions farming/logics/helpers/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod helper;
pub mod math;
2 changes: 2 additions & 0 deletions farming/logics/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
#![feature(mixed_integer_ops)]

pub mod helpers;
pub mod traits;
Loading