Skip to content

Commit

Permalink
Market Trade examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Aug 14, 2023
1 parent 906dd9b commit e281e6c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
7 changes: 3 additions & 4 deletions convex-core/src/main/cvx/convex/trust.cvx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@

(defn trusted?
^{:doc {:description ["Returns true if `subject` is trusted by `trust-monitor`, false otherwise."
"A trust monitor is an address, pointing to either:"
"- A user account that can only trust itself"
"A trust monitor is an (optionally scoped) address, pointing to either:"
"- A user account (that can only trust itself)"
"- An actor implementing `(check-trusted? subject action object)` which returns true or false."
"`action` and `object` are arbitrary values specific to the trust monitor."
"`subject` should usually be an address, although this is specific to the trust monitor as well."
"See `build-blacklist` and `build-whitelist`."]
"`subject` should usually be an address, although this is specific to the trust monitor as well."]
:examples [{:code "(trusted? my-blacklist *caller*)"}]
:signature [{:params [trust-monitor subject]}
{:params [trust-monitor subject action]}
Expand Down
36 changes: 36 additions & 0 deletions convex-core/src/test/resources/examples/market-trade.cvx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
;; Demo of market trade functionality

;; Libraries
(import asset.nft.basic :as nft)
(import convex.asset :as asset)
(import asset.market.trade :as trade)
(import asset.wrap.convex :as wcvx)

;; Mint an NFT
(def nft-id (call nft (create {:foo :bar})))

;; The item we want to list, i.e. a set of one NFT
(def item [nft #{nft-id}])

;; List the item for sale for price of 5000 tokens
(trade/post item [wcvx 5000])



;; =====================================
;; IN ANOTHER account
;; =====================================
;; Library imports
(import asset.market.trade :as trade)
(import asset.wrap.convex :as wcvx)
(import convex.asset :as asset)

;; Wrap some Convex Coins as a token to make purchase
(wcvx/wrap 1000000)

;; See available trades (raw data)
trade/trades

;; Buy a specific trade (insert chosen trade ID)
(trade/buy 1)

0 comments on commit e281e6c

Please sign in to comment.