8000 manta-farming by zqhxuyuan · Pull Request #1141 · Manta-Network/Manta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

manta-farming #1141

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 31 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d66df3d
add farming
zqhxuyuan Jun 5, 2023
c006a34
clean
zqhxuyuan Jun 5, 2023
bce3c29
update origin
zqhxuyuan Jun 5, 2023
b040026
clean
zqhxuyuan Jun 5, 2023
5d61914
comments and clean
zqhxuyuan Jun 6, 2023
8cca668
Merge branch 'manta' into farming
Dengjianping Jun 8, 2023
13794db
fix comments
zqhxuyuan Jun 9, 2023
38962cd
Merge branch 'manta' into farming
zqhxuyuan Jun 19, 2023
6162060
refactor reward calculation
zqhxuyuan Jun 27, 2023
6124dfe
Merge remote-tracking branch 'origin/manta' into farming
zqhxuyuan Jun 27, 2023
7e1664a
update version
zqhxuyuan Jun 27, 2023
4497fdd
format
zqhxuyuan Jun 27, 2023
2db5d5a
set non-native asset allow death
zqhxuyuan Jun 27, 2023
fcae992
refactor gauge too
zqhxuyuan Jun 27, 2023
b162343
refactor gauge rate
zqhxuyuan Jun 27, 2023
1b4a908
add charge weight and refactor gauge add
zqhxuyuan Jun 28, 2023
25ca1e5
rpc async
zqhxuyuan Jun 28, 2023
16c0230
update tests
zqhxuyuan Jun 28, 2023
04ef987
manta farming
zqhxuyuan Jun 9, 2023
cd8c224
add to manta
zqhxuyuan Jun 28, 2023
f08f9c2
merge
zqhxuyuan Jun 29, 2023
4440e47
more tests
zqhxuyuan Jun 29, 2023
00551cb
gauge error
zqhxuyuan Jun 30, 2023
184438b
native token allowdeath
zqhxuyuan Jun 30, 2023
db1f76d
more tests
zqhxuyuan Jul 3, 2023
44cb6a5
address comments
zqhxuyuan Jul 3, 2023
ee8a9a6
Merge branch 'manta' into farming
zqhxuyuan Jul 3, 2023
23c4374
pid to pool_id and add min deposit
zqhxuyuan Jul 3, 2023
5d5153c
event use pid
zqhxuyuan Jul 3, 2023
e6d5bc9
ensure retire limit not zero
zqhxuyuan Jul 4, 2023
9e70eb0
retire limit
zqhxuyuan Jul 4, 2023
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
59 changes: 59 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jsonrpsee = { version = "0.16.2", features = ["server"] }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }

pallet-farming-rpc-api = { path = "../pallets/farming/rpc" }
pallet-farming-rpc-runtime-api = { path = "../pallets/farming/rpc/runtime-api" }
zenlink-protocol = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37" }
zenlink-protocol-rpc = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37" }
zenlink-protocol-runtime-api = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37" }
Expand Down
66 changes: 39 additions & 27 deletions node/src/chain_specs/manta/local_testnets_geneses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,39 +47,51 @@ pub fn genesis_spec_dev() -> MantaChainSpec {
)
}

pub fn genesis_spec_local() -> MantaChainSpec {
let genesis_collators: Vec<Collator> = vec![
Collator::new(
pub fn genesis_spec_local(localdev: bool) -> MantaChainSpec {
let genesis_collators: Vec<Collator> = if localdev {
vec![Collator::new(
unchecked_account_id::<sr25519::Public>("Alice"),
None,
SessionKeys::from_seed_unchecked("Alice"),
),
Collator::new(
unchecked_account_id::<sr25519::Public>("Bob"),
None,
SessionKeys::from_seed_unchecked("Bob"),
),
Collator::new(
unchecked_account_id::<sr25519::Public>("Charlie"),
None,
SessionKeys::from_seed_unchecked("Charlie"),
),
Collator::new(
unchecked_account_id::<sr25519::Public>("Dave"),
None,
SessionKeys::from_seed_unchecked("Dave"),
),
Collator::new(
unchecked_account_id::<sr25519::Public>("Eve"),
None,
SessionKeys::from_seed_unchecked("Eve"),
),
];
)]
} else {
vec![
Collator::new(
unchecked_account_id::<sr25519::Public>("Alice"),
None,
SessionKeys::from_seed_unchecked("Alice"),
),
Collator::new(
unchecked_account_id::<sr25519::Public>("Bob"),
None,
SessionKeys::from_seed_unchecked("Bob"),
),
Collator::new(
unchecked_account_id::<sr25519::Public>("Charlie"),
None,
SessionKeys::from_seed_unchecked("Charlie"),
),
Collator::new(
unchecked_account_id::<sr25519::Public>("Dave"),
None,
SessionKeys::from_seed_unchecked("Dave"),
),
Collator::new(
unchecked_account_id::<sr25519::Public>("Eve"),
None,
SessionKeys::from_seed_unchecked("Eve"),
),
]
};
let genesis_collators_clone = genesis_collators.clone(); // so we can move it into the constructor closure

let id = if localdev {
"manta_localdev"
} else {
"manta_local"
};
MantaChainSpec::from_genesis(
"Manta Parachain Local",
"manta",
id,
ChainType::Local,
move || manta_devnet_genesis(genesis_collators_clone.clone()),
genesis_collators
Expand Down
4 changes: 2 additions & 2 deletions node/src/chain_specs/manta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ pub fn manta_testnet_config() -> MantaChainSpec {
public_testnet_genesis::genesis_spec()
}
/// Returns the Manta development chainspec.
pub fn manta_local_config() -> MantaChainSpec {
local_testnets_geneses::genesis_spec_local()
pub fn manta_local_config(localdev: bool) -> MantaChainSpec {
local_testnets_geneses::genesis_spec_local(localdev)
}
/// Returns the Manta development chainspec.
pub fn manta_development_config() -> MantaChainSpec {
Expand Down
3 changes: 2 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ fn load_spec(id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
match id {
// manta chainspec
"manta-dev" => Ok(Box::new(chain_specs::manta_development_config())),
"manta-local" => Ok(Box::new(chain_specs::manta_local_config())),
"manta-local" => Ok(Box::new(chain_specs::manta_local_config(false))),
"manta-localdev" => Ok(Box::new(chain_specs::manta_local_config(true))),
"manta-testnet" => Ok(Box::new(chain_specs::manta_testnet_config())),
"manta" => Ok(Box::new(chain_specs::manta_mainnet_config()?)),
// calamari chainspec
Expand Down
10 changes: 9 additions & 1 deletion node/src/rpc/calamari.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
//! Calamari RPC Extensions

use super::*;
use manta_primitives::types::{CalamariAssetId, PoolId};
use pallet_farming_rpc_api::{FarmingRpc, FarmingRpcApiServer};
use pallet_farming_rpc_runtime_api::FarmingRuntimeApi;
use pallet_manta_pay::{
rpc::{Pull, PullApiServer},
runtime::PullLedgerDiffApi,
Expand Down Expand Up @@ -45,6 +48,7 @@ where
C::Api: BlockBuilder<Block>,
C::Api: PullLedgerDiffApi<Block>,
C::Api: SBTPullLedgerDiffApi<Block>,
C::Api: FarmingRuntimeApi<Block, AccountId, CalamariAssetId, PoolId>,
C::Api: ZenlinkProtocolRuntimeApi<Block, AccountId, ZenlinkAssetId>,
P: TransactionPool + Sync + Send + 'static,
{
Expand Down Expand Up @@ -77,7 +81,11 @@ where
.map_err(|e| sc_service::Error::Other(e.to_string()))?;

module
.merge(ZenlinkProtocol::new(client).into_rpc())
.merge(ZenlinkProtocol::new(client.clone()).into_rpc())
.map_err(|e| sc_service::Error::Other(e.to_string()))?;

module
.merge(FarmingRpc::new(client).into_rpc())
.map_err(|e| sc_service::Error::Other(e.to_string()))?;

Ok(module)
Expand Down
19 changes: 18 additions & 1 deletion node/src/rpc/manta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
//! Manta RPC Extensions

use super::*;
use manta_primitives::types::{MantaAssetId, PoolId};
use pallet_farming_rpc_api::{FarmingRpc, FarmingRpcApiServer};
use pallet_farming_rpc_runtime_api::FarmingRuntimeApi;
use pallet_manta_pay::{
rpc::{Pull, PullApiServer},
runtime::PullLedgerDiffApi,
Expand All @@ -25,6 +28,9 @@ use pallet_manta_sbt::{
rpc::{SBTPull, SBTPullApiServer},
runtime::SBTPullLedgerDiffApi,
};
use zenlink_protocol::AssetId as ZenlinkAssetId;
use zenlink_protocol_rpc::{ZenlinkProtocol, ZenlinkProtocolApiServer};
use zenlink_protocol_runtime_api::ZenlinkProtocolApi as ZenlinkProtocolRuntimeApi;

/// Instantiate all RPC extensions for manta.
pub fn create_manta_full<C, P>(deps: FullDeps<C, P>) -> Result<RpcExtension, sc_service::Error>
Expand All @@ -41,6 +47,8 @@ where
C::Api: BlockBuilder<Block>,
C::Api: PullLedgerDiffApi<Block>,
C::Api: SBTPullLedgerDiffApi<Block>,
C::Api: FarmingRuntimeApi<Block, AccountId, MantaAssetId, PoolId>,
C::Api: ZenlinkProtocolRuntimeApi<Block, AccountId, ZenlinkAssetId>,
P: TransactionPool + Sync + Send + 'static,
{
use frame_rpc_system::{System, SystemApiServer};
Expand All @@ -65,10 +73,19 @@ where
.merge(manta_pay_rpc)
.map_err(|e| sc_service::Error::Other(e.to_string()))?;

let manta_sbt_rpc: jsonrpsee::RpcModule<SBTPull<Block, C>> = SBTPull::new(client).into_rpc();
let manta_sbt_rpc: jsonrpsee::RpcModule<SBTPull<Block, C>> =
SBTPull::new(client.clone()).into_rpc();
module
.merge(manta_sbt_rpc)
.map_err(|e| sc_service::Error::Other(e.to_string()))?;

module
.merge(ZenlinkProtocol::new(client.clone()).into_rpc())
.map_err(|e| sc_service::Error::Other(e.to_string()))?;

module
.merge(FarmingRpc::new(client).into_rpc())
.map_err(|e| sc_service::Error::Other(e.to_string()))?;

Ok(module)
}
63 changes: 63 additions & 0 deletions pallets/farming/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[package]
authors = ['Manta Network']
description = 'Pallet implementing farming protocol.'
edition = "2021"
homepage = "https://manta.network"
license = "GPL-3.0"
name = "pallet-farming"
repository = 'https://github.com/Manta-Network/Manta/'
version = "4.2.0"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false, features = ["derive"] }
hex-literal = { version = "0.3.1" }
log = { version = "0.4.16", default-features = false }
scale-info = { version = "2.3.1", default-features = false, features = ["derive"] }

frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false, optional = true }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false }

manta-primitives = { path = '../../primitives/manta', default-features = false }
orml-traits = { git = "https://github.com/manta-network/open-runtime-module-library.git", branch = "polkadot-v0.9.37", default-features = false }
pallet-asset-manager = { path = "../asset-manager", default-features = false, optional = true }
pallet-assets = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37", default-features = false, optional = true }
xcm = { git = "https://github.com/paritytech/polkadot.git", branch = "release-v0.9.37", default-features = false, optional = true }

[dev-dependencies]
pallet-assets = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.37" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[features]
default = ["std"]
std = [
"codec/std",
"log/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"manta-primitives/std",
"scale-info/std",
"pallet-assets/std",
"pallet-asset-manager/std",
"xcm/std",
]

runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"xcm",
"pallet-asset-manager",
]
try-runtime = ["frame-support/try-runtime"]
22 changes: 22 additions & 0 deletions pallets/farming/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
authors = ['Manta Network']
edition = "2021"
homepage = "https://manta.network"
license = "GPL-3.0"
name = "pallet-farming-rpc-api"
repository = 'https://github.com/Manta-Network/Manta/'
version = "4.2.0"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false, features = ["derive"] }
jsonrpsee = { version = "0.16.2", features = ["server", "macros"] }
serde = { version = "1.0.140", features = ["derive"] }

sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }

manta-primitives = { path = '../../../primitives/manta', default-features = false }
pallet-farming-rpc-runtime-api = { path = "./runtime-api" }
Loading
0