Git Product home page Git Product logo

pallet-dex's Introduction

DEX Pallet


Custom DEX pallet using the Polkadot SDK based of UniswapV2 implementation.

Disclaimer

This code has not been audited. Use at your own risk.

Usage

Configuring pallet-dex v2 to a solo-chain or a parachain is a simple process.

First, add the following to your Cargo.toml:

pallet-dex-v2 = { version = "0.0.3", default-features = false}
# if you don't use pallet-assets in  your runtime before, you need to add it to your runtime
pallet-assets = { version = "32.0.0", default-features = false }

Then, add the following to your runtime's lib.rs:

pub use pallet_dex_v2 as dex;

// declare pallet id for dex
parameter_types! {
    // pallet ID
    pub const DexPallet: PalletId = PalletId(*b"DCitadel");
}

// declare types used in asset pallet
parameter_types! {
	pub const AssetDeposit: Balance = 100;
	pub const ApprovalDeposit: Balance = 1;
	pub const StringLimit: u32 = 50;
	pub const MetadataDepositBase: Balance = 10;
	pub const MetadataDepositPerByte: Balance = 1;
}

/// Configure the assets pallet
impl pallet_assets::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type Balance = u128;
	type AssetId = u32;
	type AssetIdParameter = codec::Compact<u32>;
	type Currency = Balances;
	type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
	type ForceOrigin = EnsureRoot<AccountId>;
	type AssetDeposit = AssetDeposit;
	type AssetAccountDeposit = ConstU128<1>;
	type MetadataDepositBase = MetadataDepositBase;
	type MetadataDepositPerByte = MetadataDepositPerByte;
	type ApprovalDeposit = ApprovalDeposit;
	type StringLimit = StringLimit;
	type Freezer = ();
	type Extra = ();
	type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
	type RemoveItemsLimit = ConstU32<1000>;
	type CallbackHandle = ();
	#[cfg(feature = "runtime-benchmarks")]
	type BenchmarkHelper = ();
}

/// Configure the dex pallet
impl pallet_dex::Config for Runtime {
    type RuntimeEvent = RuntimeEvent;
    type NativeBalance = Balances;
    type Fungibles = Assets;
    type PalletId = DexPallet;
}

License

Do wathever you want with this code. No warranty, no liability, no nothing.

Contributing

Make a PR and I'll review it. If it's good, I'll merge it. If it's not, I'll tell you why and we can work on it together. :)

pallet-dex's People

Contributors

developeruche avatar

Stargazers

 avatar Adeoye Adefemi avatar

Watchers

 avatar  avatar

Forkers

tomaszwaszczyk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.