-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from public-awesome/tasiov/reserve-auction-de…
…ploy-script Reserve Auction Mainnet
- Loading branch information
Showing
12 changed files
with
164 additions
and
119 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "stargaze-reserve-auction" | ||
version = "1.2.0" | ||
version = "1.0.0" | ||
authors = [ | ||
"Shane Vitarana <[email protected]>", | ||
"Tasio Victoria <[email protected]>", | ||
|
@@ -22,13 +22,19 @@ exclude = [ | |
[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] | ||
sg-marketplace-common = { version = "1.1.0" } | ||
stargaze-fair-burn = { workspace = true } | ||
cosmwasm-schema = { workspace = true } | ||
cosmwasm-std = { workspace = true } | ||
|
@@ -40,7 +46,6 @@ cw721 = { workspace = true } | |
cw721-base = { workspace = true } | ||
schemars = { workspace = true } | ||
serde = { workspace = true } | ||
sg-marketplace-common = { workspace = true } | ||
sg-std = { workspace = true } | ||
sg1 = { workspace = true } | ||
sg721-base = { workspace = true } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,21 @@ | ||
# Stargaze Reserve (Timed) Auctions | ||
# Stargaze Reserve Auction (aka Live Auction) | ||
|
||
Reserve auctions enable an NFT to receive bids of increasing value for a certain duration of time. | ||
|
||
This contract honors royalties. | ||
|
||
## State | ||
|
||
### `Config` | ||
|
||
These parameters will be set on contract instantiation. They can also be updated via Sudo. | ||
|
||
```rs | ||
pub struct Config { | ||
pub create_auction_fee: Uint128, | ||
pub min_reserve_price: Coin, | ||
pub min_bid_increment: u64, | ||
pub min_duration: u64, | ||
pub extend_duration: u64, | ||
pub trading_fee: Decimal, | ||
} | ||
``` | ||
|
||
### `Auction` | ||
|
||
```rs | ||
pub struct HighBid { | ||
pub coin: Coin, | ||
pub bidder: Addr, | ||
} | ||
|
||
pub struct Auction { | ||
pub token_id: String, | ||
pub collection: Addr, | ||
pub seller: Addr, | ||
pub reserve_price: Coin, | ||
pub start_time: Timestamp, | ||
pub end_time: Timestamp, | ||
pub seller_funds_recipient: Option<Addr>, | ||
pub high_bid: Option<HighBid>, | ||
pub first_bid_time: Option<Timestamp>, | ||
} | ||
``` | ||
This CosmWasm smart contract implements a reserve auction on the Stargaze network. In a reserve auction, an item is not sold unless the highest bid is equal to or greater than a predetermined reserve price. The contract includes several key features such as auction creation, bid placement, auction settlement, and cancellation. The auction also provides the ability to update the reserve price. | ||
|
||
## Messages | ||
|
||
### `Instantiate` | ||
|
||
```rs | ||
pub struct InstantiateMsg { | ||
pub create_auction_fee: Uint128, | ||
pub min_reserve_price: Coin, | ||
pub min_duration: u64, | ||
pub min_bid_increment: u64, | ||
pub extend_duration: u64, | ||
pub trading_fee_bps: u64, | ||
} | ||
``` | ||
|
||
### `CreateAuction` | ||
|
||
Creates an auction for the given NFT, the NFT is escrowed at the time of contract creation. The timer stars after `start_time`. The contract maintains custody of the NFT until the auction is finished. `Approval` must be given this contract so it can transfer the NFT to itself. `Approval` can be batched to run before `CreateAuction`. | ||
|
||
```rs | ||
CreateAuction { | ||
collection: String, | ||
token_id: String, | ||
reserve_price: Coin, | ||
start_time: Timestamp, | ||
end_time: Timestamp, | ||
seller_funds_recipient: Option<String>, | ||
} | ||
``` | ||
|
||
### `UpdateReservePrice` | ||
|
||
Updated the reserve price of an existing auction. This only runs if the auction hasn't started yet. | ||
|
||
```rs | ||
UpdateReservePrice { | ||
collection: String, | ||
token_id: String, | ||
reserve_price: Coin, | ||
} | ||
``` | ||
|
||
### `CancelAuction` | ||
|
||
Cancels an existing auction. This only runs if the auction hasn't started yet. | ||
The contract functionality is implemented in the following executable messages. | ||
|
||
```rs | ||
CancelAuction { | ||
collection: String, | ||
token_id: String, | ||
} | ||
``` | ||
**CreateAuction**: Allows the owner of an NFT to create an auction. The owner sets the reserve price, auction duration, and an optional recipient address for the auction proceeds. Upon creation, the contract verifies that the NFT owner has approved the auction contract to transfer the NFT. The function also handles the creation fee, which is sent to a fair-burn contract if applicable. The auction officially starts when the first bid has been placed. | ||
|
||
### `PlaceBid` | ||
**UpdateReservePrice**: Allows the seller to update the reserve price of an auction. This operation is only permissible if the auction has not yet started (i.e., no bids have been placed). | ||
|
||
Places a bid on the given NFT. Each bid must be a fixed amount greater than the last. The amount for the bid is held in escrow by the contract until either the auction ends or a higher bid is placed. When a higher bid is placed, the previous bid is refunded. If a bid is placed within `extend_duration` of the auction ending, the auction is extended by `extend_duration` seconds. | ||
**CancelAuction**: Allows the seller to cancel an auction. Like updating the reserve price, cancellation is only permissible if the auction has not yet started. | ||
|
||
```rs | ||
PlaceBid { | ||
collection: String, | ||
token_id: String, | ||
} | ||
``` | ||
**PlaceBid**: Allows a participant to place a bid on an NFT. If the participant is placing the first bid, then the bid must be higher than the reserve price. If it is not the first bid, then the bid must be higher than the previous highest bid. If a bid is placed near the end of an auction, the end time of the auction may be extended in order to allow for more bidding. | ||
|
||
### `SettleAuction` | ||
**SettleAuction**: Allows anyone to settle an auction after it has ended. The function distributes the winning bid to the seller, transfers the NFT to the winning bidder, and burns the platform fee. This message is also invoked within the CosmosSDK's EndBlocker to allow for timely settling of auctions. | ||
|
||
Ends the auction for the given NFT. It sends it to the highest bidder, and transfers the funds from the bid to the seller. Royalties are paid to the creator. Anyone can call this function. | ||
## Addresses | ||
|
||
```rs | ||
SettleAuction { | ||
collection: String, | ||
token_id: String, | ||
} | ||
``` | ||
- `elfagar-1: stars1dnadsd7tx0dmnpp26ms7d66zsp7tduygwjgfjzueh0lg9t5lq5vq9kn47c` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## Store WASM Code | ||
|
||
This uploads the code for Stargaze Live Auction v1.0.0 | ||
|
||
The source code is available at https://github.com/public-awesome/core/releases/tag/stargaze_reserve_auction-v1.0.0 | ||
|
||
This CosmWasm smart contract implements a reserve auction on the Stargaze network. In a reserve auction, an item is not sold unless the highest bid is equal to or greater than a predetermined reserve price. The contract includes several key features such as auction creation, bid placement, auction settlement, and cancellation. | ||
|
||
To integrate with the Stargaze Reserve Auction contract please refer to the following documentation https://crates.io/crates/stargaze-reserve-auction | ||
|
||
### Compile Instructions | ||
|
||
```sh | ||
docker run --rm -v "$(pwd)":/code --platform linux/amd64 \ | ||
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ | ||
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ | ||
cosmwasm/workspace-optimizer:0.12.13 | ||
``` | ||
|
||
This results in the following SHA256 checksum: | ||
|
||
``` | ||
f7cdf509a1889e21399c33eee9e68ac328abd4a456142db080d760d15135fe56 stargaze_reserve_auction.wasm | ||
``` | ||
|
||
### Verify On-chain Contract | ||
|
||
```sh | ||
starsd q gov proposal $id --output json \ | ||
| jq -r '.content.wasm_byte_code' \ | ||
| base64 -d \ | ||
| gzip -dc \ | ||
| sha256sum | ||
|
||
``` | ||
|
||
### Verify Local Contract | ||
|
||
``` | ||
sha256sum artifacts/stargaze_reserve_auction.wasm | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
set -eux | ||
|
||
CONTRACT=artifacts/stargaze_reserve_auction.wasm | ||
|
||
TITLE="Stargaze Live Auction v1.0.0" | ||
MARKDOWN="scripts/markdown/stargaze_reserve_auction-v1.0.0.md" | ||
DESCRIPTION=$(cat "$MARKDOWN" | base64 | tr -d '\n') | ||
SOURCE="https://github.com/public-awesome/core/releases/tag/stargaze_reserve_auction-v1.0.0" | ||
BUILDER="cosmwasm/workspace-optimizer:0.12.13" | ||
HASH="f7cdf509a1889e21399c33eee9e68ac328abd4a456142db080d760d15135fe56" | ||
|
||
FROM="hot-wallet" | ||
DEPOSIT="10000000000ustars" | ||
|
||
RUN_AS="stars19mmkdpvem2xvrddt8nukf5kfpjwfslrsu7ugt5" | ||
ANY_OF_ADDRS="stars19mmkdpvem2xvrddt8nukf5kfpjwfslrsu7ugt5,stars1r5ecq7zn6hwh5e68e79ume8rp9ht7kjz352drk" | ||
|
||
CHAIN_ID="stargaze-1" | ||
NODE="https://rpc.stargaze-apis.com:443" | ||
|
||
starsd tx gov submit-proposal wasm-store "$CONTRACT" \ | ||
--title "$TITLE" \ | ||
--description "$(echo "$DESCRIPTION" | base64 --decode)" \ | ||
--code-source-url "$SOURCE" \ | ||
--builder "$BUILDER" \ | ||
--code-hash "$HASH" \ | ||
--from "$FROM" \ | ||
--deposit "$DEPOSIT" \ | ||
--run-as "$RUN_AS" \ | ||
--instantiate-anyof-addresses "$ANY_OF_ADDRS" \ | ||
--chain-id "$CHAIN_ID" \ | ||
--node "$NODE" \ | ||
--gas-prices 1ustars \ | ||
--gas auto \ | ||
--gas-adjustment 1.5 |