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

add marketplace mock #4

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ smallvec = "1.13.1"
# Local dependencies
mythical-devnet = { path = "runtime/devnet" }
mythical-mainnet = { path = "runtime/mainnet" }
pallet-marketplace = { path = "pallets/marketplace", default-features = false }
runtime-common = { path = "runtime/common", default-features = false }

# Substrate
Expand Down
49 changes: 49 additions & 0 deletions pallets/marketplace/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
name = "pallet-marketplace"
version = "0.0.1"
description = "Marketplace FRAME pallet to provide creation of asks and bids on nfts"
authors = { workspace = true }
homepage = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
publish = false

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

[dependencies]
parity-scale-codec = { workspace = true, default-features = false, features = [
"derive",
] }
log = { workspace = true, default-features = false }
scale-info = { workspace = true, default-features = false, features = [
"derive",
] }
frame-benchmarking = { workspace = true, default-features = false, optional = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
sp-std = { workspace = true }
sp-runtime = { workspace = true, default-features = false }
pallet-nfts = { workspace = true, default-features = false }
sp-core = { workspace = true, default-features = false }

[dev-dependencies]
sp-io = { workspace = true, default-features = false }
pallet-balances = { workspace = true, default-features = false }

[features]
default = ["std"]
std = [
"parity-scale-codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"sp-std/std",
"pallet-balances/std",
"pallet-nfts/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime"]
26 changes: 26 additions & 0 deletions pallets/marketplace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Marketplace 2.0 Pallet

The Marketplace pallet provides a market to buy and sell Nfts from pallet-nft using Asks and Bids.

## Overview

Users who own NFTs have the ability to create 'Asks' to offer their items to potential buyers. Once an Ask is created, the respective item becomes locked and cannot be transferred until either the item is sold or the Ask is canceled.

In the event that a user desires an item that is not currently available for sale, they can initiate a 'Bid' by specifying the price they are willing to pay for the item. The amount pledged in the Bid is then locked from the user's balance.

Additionally, users have the option to set up an 'exchange,' where they can list the items they own for sale. Any profits generated from selling these items can automatically fund Ask purchases.

Both buyer and seller must pay fees for the operations that take place in the marketplace. This fees must be approved by the `FeeSigner` role, this approval is done by appending the signature of the FeeSigner in the creation of orders. Then the fees are payed to the `PayoutAddress` account configured inside the pallet.

## Dispatchable Functions

- `force_set_authority()`: Sets authority role which has owner rights, only callable by root origin.
- `set_fee_signer_address()`: Allows authority account to set the account that signs fees.
- `set_payout_address()`: Allows authority account to set the payout address.
- `create_order()`: Create Ask or Bid Order on an specific NFT (collectionId, ItemId). If orders match the transaction is executed.
- `cancel_order()`: Cancelation of Ask or Bid order.
- `create_exchange()`: Create an exchange with the NFTs that the user is looking to sell and the NFTs it's looking to buy with the profit of the sale.
- `fill_suggestion()`: Allows users to participate in the purchase of a suggestion inside an exchange.
- `execute_exchange()`: Trade suggested items with bidders that filled the suggestions and purchase the wantAsks.
- `cancel_suggestion()`: Cancel an already filled suggestion.
- `cancel_exchange()`: Cancels existing exchange marking it as closed
1 change: 1 addition & 0 deletions pallets/marketplace/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading
Loading