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

[WIP] Stargaze VIP Program #16

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
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
623 changes: 418 additions & 205 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[workspace]
members = ["packages/*", "contracts/fair-burn", "test/*"]
members = [
"packages/*",
"contracts/fair-burn",
"contracts/vip/collection",
"contracts/vip/minter",
"contracts/vip/program",
"test/*",
]
resolver = "2"

[workspace.package]
Expand All @@ -19,7 +26,7 @@ cw-storage-plus = "1.1.0"
cw-controllers = "1.1.0"
cw2 = "1.1.0"
cw721 = "0.18.0"
cw721-base = "0.18.0"
cw721-base = { version = "0.18.0", feature = ["library"] }
cw-utils = "1.0.1"
schemars = "0.8.11"
semver = "1.0.16"
Expand Down
37 changes: 37 additions & 0 deletions contracts/vip/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Stargaze VIP Program (SVP)

The Stargaze VIP Program is a program that rewards users for staking STARS in the form of reduced fees. The program is implemented as a set of NFT smart contracts. Users are assigned to a tier based on the amount of STARS they have staked. The tier determines the amount of fees they pay.

A user mints a Stargaze VIP NFT (vNFT) to join the Stargaze VIP Program. It contains metadata that includes the amount of STARS they have staked that is periodically updated via end blocker. vNFTs are non-transferrable.

A Stargaze Name is required to mint a vNFT.

## VIP Collection (sg721-vip)

The VIP Collection is a contract that stores all the vNFTs, and periodically updates the metadata of each vNFT.

vNFTs are indexed by Stargaze Names, using the name for the `token_id`. If a name is transferred or burned, the associated vNFT is burned. This happens via a hook in the Stargaze Name collection contract.

The stake weight metadata can only be updated at specific intervals. The `updated_at` field is used to determine when the metadata can be updated. The `updated_at` field is set to the current block time when the vNFT is minted. The metadata can be updated when the current block time is greater than the `updated_at` field plus the `update_period` field in the config.


### Queries

```rs
pub enum QueryMsg {
Config {},
Metadata { address: String },
TotalStakedAmount { name: String },
}
```

Note that a user may have multiple wallets that stake. For example they may have a cold wallet that does the majority of staking, and a hot wallet for use for minting on Stargaze. To determine the tier of a user, we need to sum up the amount of STARS staked across all wallets. To associate wallets, a user can link their accounts in their Stargaze Name. The `TotalStakedAmount` query returns the total amount of STARS staked by a user across all wallets.

#### TODO

- [ ] Come up with a consistent way to link multiple accounts to one name (Version 2)

## vNFT Minter (vip-minter)

The vNFT Minter is a contract that allows users to mint vNFTs.

4 changes: 4 additions & 0 deletions contracts/vip/collection/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --bin schema"
47 changes: 47 additions & 0 deletions contracts/vip/collection/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "stargaze-vip-collection"
authors = ["Shane Vitarana <[email protected]>"]
description = "Stargaze VIP Collection"
version = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
license = { workspace = true }

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[[bin]]
name = "schema"
path = "src/bin/schema.rs"
doc = false

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []


[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true, features = ["cosmwasm_1_2"] }
cosmwasm-storage = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
cw721 = { workspace = true }
cw721-base = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
cw-multi-test = { workspace = true }
3 changes: 3 additions & 0 deletions contracts/vip/collection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Stargaze VIP Collection

This contract wraps the `cw721_base::Cw721Contract` struct to represent a collection that stores vNFTs (Stargaze VIP NFTs) with onchain metadata. The stake weight is stored as onchain metadata.
Loading
Loading