From 11e2b17d37614225a8440a4b5258918486f9bc5b Mon Sep 17 00:00:00 2001 From: crzypatchwork Date: Fri, 4 Jun 2021 18:05:33 -0300 Subject: [PATCH] latest --- README.md | 7 + objkt-swap.py | 85 -- objkt-swap.tz | 1088 ------------------------ scs/curation.tz | 275 ++++++ fa2.tz => scs/fa2_hdao.tz | 412 ++++----- scs/fa2_objkts.tz | 802 ++++++++++++++++++ scs/objkt_swap.tz | 1689 +++++++++++++++++++++++++++++++++++++ scs/subjkts.tz | 355 ++++++++ scs/unregistry.tz | 27 + 9 files changed, 3376 insertions(+), 1364 deletions(-) delete mode 100644 objkt-swap.py delete mode 100644 objkt-swap.tz create mode 100644 scs/curation.tz rename fa2.tz => scs/fa2_hdao.tz (72%) create mode 100644 scs/fa2_objkts.tz create mode 100644 scs/objkt_swap.tz create mode 100644 scs/subjkts.tz create mode 100644 scs/unregistry.tz diff --git a/README.md b/README.md index 5459269..7216e79 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,13 @@ v2 contains sell orders only implementing xtz:[FA2](https://gitlab.com/tzip/tzip https://smartpy.io/ide?cid=QmXC34CuCfQ6Efg5YjfrcRW9RDq59Xkc7CrZk2eNck2J7D +hDAO: https://better-call.dev/mainnet/KT1AFA2mwNUMNd4SsujE1YYp29vd8BZejyKW +OBJKT-hDAO Curation: https://better-call.dev/mainnet/KT1TybhR7XraG75JFYKSrh7KnxukMBT5dor6 +Hic et Nunc Minter: https://better-call.dev/mainnet/KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9 +OBJKTs: https://better-call.dev/mainnet/KT1RJ6PbjHpwc3M5rw5s2Nbmefwbuwbdxton +SUBJKTs: https://better-call.dev/mainnet/KT1My1wDZHDGweCrJnQJi3wcFaS67iksirvj +Hic et nunc Unregistry: https://better-call.dev/mainnet/KT1MirRvstfYwjPPuyphBazSddgp8i1d8k8a + ` MIT license ` diff --git a/objkt-swap.py b/objkt-swap.py deleted file mode 100644 index 45a9fbf..0000000 --- a/objkt-swap.py +++ /dev/null @@ -1,85 +0,0 @@ -import smartpy as sp - -class OBJKTSwap(sp.Contract): - def __init__(self, objkt, manager, metadata): - self.fee = 0 - self.amount = 0 - self.royalties = 0 - self.init( - swaps = sp.big_map(tkey=sp.TNat, tvalue=sp.TRecord(issuer=sp.TAddress, xtz_per_objkt=sp.TMutez, objkt_id=sp.TNat, objkt_amount=sp.TNat)), - royalties = sp.big_map(tkey=sp.TNat, tvalue=sp.TRecord(issuer=sp.TAddress, royalties=sp.TNat)), - swap_id = 0, - objkt_id = 0, - objkt = objkt, - manager = manager, - metadata = metadata, - ) - - @sp.entry_point - def swap(self, params): - sp.verify(params.objkt_amount > 0) - self.fa2_transfer(self.data.objkt, sp.sender, sp.to_address(sp.self), params.objkt_id, params.objkt_amount) - self.data.swaps[self.data.swap_id] = sp.record(issuer=sp.sender, objkt_id=params.objkt_id, objkt_amount=params.objkt_amount, xtz_per_objkt=params.xtz_per_objkt) - self.data.swap_id += 1 - - - @sp.entry_point - def collect(self, params): - sp.verify( (params.objkt_amount > 0) & (sp.sender != self.data.swaps[params.swap_id].issuer) ) - sp.if (self.data.swaps[params.swap_id].xtz_per_objkt != sp.tez(0)): - - self.objkt_amount = sp.fst(sp.ediv(sp.amount, self.data.swaps[params.swap_id].xtz_per_objkt).open_some()) - - self.amount = self.objkt_amount * sp.fst(sp.ediv(self.data.swaps[params.swap_id].xtz_per_objkt, sp.mutez(1)).open_some()) - - sp.verify((params.objkt_amount == self.objkt_amount) & (sp.amount == sp.mutez(self.amount)) & (sp.amount > sp.tez(0))) - # calculate fees and royalties - self.fee = sp.fst(sp.ediv(sp.mutez(self.amount), sp.mutez(1)).open_some()) * (self.data.royalties[self.data.swaps[params.swap_id].objkt_id].royalties + 25) / 1000 - self.royalties = self.data.royalties[self.data.swaps[params.swap_id].objkt_id].royalties * self.fee / (self.data.royalties[self.data.swaps[params.swap_id].objkt_id].royalties + 25) - - # send royalties to NFT creator - sp.send(self.data.royalties[self.data.swaps[params.swap_id].objkt_id].issuer, sp.mutez(self.royalties)) - - # send management fees - sp.send(self.data.manager, sp.mutez(abs(self.fee - self.royalties))) - - # send value to issuer - sp.send(self.data.swaps[params.swap_id].issuer, sp.amount - sp.mutez(self.fee)) - - self.fa2_transfer(self.data.objkt, sp.to_address(sp.self), sp.sender, self.data.swaps[params.swap_id].objkt_id, params.objkt_amount) - - self.data.swaps[params.swap_id].objkt_amount = abs(self.data.swaps[params.swap_id].objkt_amount - params.objkt_amount) - - sp.if (self.data.swaps[params.swap_id].objkt_amount == 0): - del self.data.swaps[params.swap_id] - - @sp.entry_point - def mint_OBJKT(self, params): - sp.verify((params.amount > 0) & ((params.royalties >= 0) & (params.royalties <= 250)) & (sp.len(params.metadata) == 106)) - - c = sp.contract( - sp.TRecord( - address=sp.TAddress, - amount=sp.TNat, - token_id=sp.TNat, - token_info=sp.TMap(sp.TString, sp.TBytes) - ), - self.data.objkt, - entry_point = "mint").open_some() - - sp.transfer( - sp.record( - address=params.address, - amount=params.amount, - token_id=self.data.objkt_id, - token_info=params.metadata - ), - sp.mutez(0), - c) - - self.data.royalties[self.data.objkt_id] = sp.record(issuer=sp.sender, royalties=params.royalties) - self.data.objkt_id += 1 - - def fa2_transfer(self, fa2, from_, to_, objkt_id, objkt_amount): - c = sp.contract(sp.TList(sp.TRecord(from_=sp.TAddress, txs=sp.TList(sp.TRecord(amount=sp.TNat, to_=sp.TAddress, token_id=sp.TNat).layout(("to_", ("token_id", "amount")))))), fa2, entry_point='transfer').open_some() - sp.transfer(sp.list([sp.record(from_=from_, txs=sp.list([sp.record(amount=objkt_amount, to_=to_, token_id=objkt_id)]))]), sp.mutez(0), c) \ No newline at end of file diff --git a/objkt-swap.tz b/objkt-swap.tz deleted file mode 100644 index bd964f7..0000000 --- a/objkt-swap.tz +++ /dev/null @@ -1,1088 +0,0 @@ -# @hicetnunc2000 -parameter (or (pair %collect (nat %objkt_amount) (nat %swap_id)) (or (pair %mint_OBJKT (pair (address %address) (nat %amount)) (pair (map %metadata string bytes) (nat %royalties))) (pair %swap (nat %objkt_amount) (pair (nat %objkt_id) (mutez %xtz_per_objkt))))); -storage (pair (pair (address %manager) (pair (big_map %metadata string bytes) (address %objkt))) (pair (pair (nat %objkt_id) (big_map %royalties nat (pair (address %issuer) (nat %royalties)))) (pair (nat %swap_id) (big_map %swaps nat (pair (pair (address %issuer) (nat %objkt_amount)) (pair (nat %objkt_id) (mutez %xtz_per_objkt))))))); -code - { - UNPAIR; - IF_LEFT - { - DUP; - CAR; - PUSH nat 0; - COMPARE; - LT; - IF - { - SWAP; - DUP; - DUG 2; - GET 6; - SWAP; - DUP; - DUG 2; - CDR; - GET; - IF_SOME - {} - { - PUSH int 38; - FAILWITH; - }; - CAR; - CAR; - SENDER; - COMPARE; - NEQ; - } - { - PUSH bool False; - }; - IF - {} - { - PUSH string "WrongCondition: (params.objkt_amount > 0) & (sp.sender != self.data.swaps[params.swap_id].issuer)"; - FAILWITH; - }; - PUSH mutez 0; - DUP 3; - GET 6; - DUP 3; - CDR; - GET; - IF_SOME - {} - { - PUSH int 39; - FAILWITH; - }; - GET 4; - COMPARE; - NEQ; - IF - { - SWAP; - DUP; - DUG 2; - GET 6; - SWAP; - DUP; - DUG 2; - CDR; - GET; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - GET 4; - AMOUNT; - EDIV; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - CAR; - SWAP; - DUP; - DUG 2; - CAR; - COMPARE; - EQ; - IF - { - PUSH mutez 1; - DUP; - DUP 4; - GET 6; - DUP 4; - CDR; - GET; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - GET 4; - EDIV; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - CAR; - DUP 4; - GET 6; - DUP 4; - CDR; - GET; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - GET 4; - AMOUNT; - EDIV; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - CAR; - MUL; - MUL; - AMOUNT; - COMPARE; - EQ; - } - { - PUSH bool False; - }; - IF - { - PUSH mutez 0; - AMOUNT; - COMPARE; - GT; - } - { - PUSH bool False; - }; - IF - {} - { - PUSH string "WrongCondition: ((params.objkt_amount == sp.fst(sp.ediv(sp.amount, self.data.swaps[params.swap_id].xtz_per_objkt).open_some())) & (sp.amount == sp.mutez(sp.fst(sp.ediv(sp.amount, self.data.swaps[params.swap_id].xtz_per_objkt).open_some()) * sp.fst(sp.ediv(self.data.swaps[params.swap_id].xtz_per_objkt, sp.mutez(1)).open_some())))) & (sp.amount > sp.tez(0))"; - FAILWITH; - }; - NIL operation; - DIG 2; - DUP; - CDR; - CAR; - CDR; - SWAP; - DUP; - DUG 4; - GET 6; - DUP 4; - CDR; - GET; - IF_SOME - {} - { - PUSH int 51; - FAILWITH; - }; - GET 3; - GET; - IF_SOME - {} - { - PUSH int 51; - FAILWITH; - }; - CAR; - CONTRACT unit; - IF_SOME - {} - { - PUSH int 51; - FAILWITH; - }; - PUSH mutez 1; - PUSH nat 25; - DIG 5; - DUP; - CDR; - CAR; - CDR; - SWAP; - DUP; - DUG 7; - GET 6; - DUP 7; - CDR; - GET; - IF_SOME - {} - { - PUSH int 48; - FAILWITH; - }; - GET 3; - GET; - IF_SOME - {} - { - PUSH int 48; - FAILWITH; - }; - CDR; - ADD; - PUSH nat 1000; - PUSH nat 25; - DIG 7; - DUP; - CDR; - CAR; - CDR; - SWAP; - DUP; - DUG 9; - GET 6; - DUP 9; - CDR; - GET; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - GET 3; - GET; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - CDR; - ADD; - PUSH mutez 1; - DUP; - DUP; - DUP 11; - GET 6; - DUP 11; - CDR; - GET; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - GET 4; - EDIV; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - CAR; - DUP 11; - GET 6; - DUP 11; - CDR; - GET; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - GET 4; - AMOUNT; - EDIV; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - CAR; - MUL; - MUL; - EDIV; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - CAR; - MUL; - EDIV; - IF_SOME - { - CAR; - } - { - PUSH int 47; - FAILWITH; - }; - DIG 6; - DUP; - CDR; - CAR; - CDR; - SWAP; - DUP; - DUG 8; - GET 6; - DUP 8; - CDR; - GET; - IF_SOME - {} - { - PUSH int 48; - FAILWITH; - }; - GET 3; - GET; - IF_SOME - {} - { - PUSH int 48; - FAILWITH; - }; - CDR; - MUL; - EDIV; - IF_SOME - { - CAR; - } - { - PUSH int 48; - FAILWITH; - }; - MUL; - UNIT; - TRANSFER_TOKENS; - CONS; - DUP 3; - CAR; - CAR; - CONTRACT unit; - IF_SOME - {} - { - PUSH int 54; - FAILWITH; - }; - PUSH mutez 1; - PUSH nat 25; - DIG 5; - DUP; - CDR; - CAR; - CDR; - SWAP; - DUP; - DUG 7; - GET 6; - DUP 7; - CDR; - GET; - IF_SOME - {} - { - PUSH int 48; - FAILWITH; - }; - GET 3; - GET; - IF_SOME - {} - { - PUSH int 48; - FAILWITH; - }; - CDR; - ADD; - PUSH nat 1000; - PUSH nat 25; - DIG 7; - DUP; - CDR; - CAR; - CDR; - SWAP; - DUP; - DUG 9; - GET 6; - DUP 9; - CDR; - GET; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - GET 3; - GET; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - CDR; - ADD; - PUSH mutez 1; - DUP; - DUP; - DUP 11; - GET 6; - DUP 11; - CDR; - GET; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - GET 4; - EDIV; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - CAR; - DUP 11; - GET 6; - DUP 11; - CDR; - GET; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - GET 4; - AMOUNT; - EDIV; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - CAR; - MUL; - MUL; - EDIV; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - CAR; - MUL; - EDIV; - IF_SOME - { - CAR; - } - { - PUSH int 47; - FAILWITH; - }; - DIG 6; - DUP; - CDR; - CAR; - CDR; - SWAP; - DUP; - DUG 8; - GET 6; - DUP 8; - CDR; - GET; - IF_SOME - {} - { - PUSH int 48; - FAILWITH; - }; - GET 3; - GET; - IF_SOME - {} - { - PUSH int 48; - FAILWITH; - }; - CDR; - MUL; - EDIV; - IF_SOME - { - CAR; - } - { - PUSH int 48; - FAILWITH; - }; - PUSH nat 1000; - PUSH nat 25; - DIG 7; - DUP; - CDR; - CAR; - CDR; - SWAP; - DUP; - DUG 9; - GET 6; - DUP 9; - CDR; - GET; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - GET 3; - GET; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - CDR; - ADD; - PUSH mutez 1; - DUP; - DUP; - DUP 11; - GET 6; - DUP 11; - CDR; - GET; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - GET 4; - EDIV; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - CAR; - DUP 11; - GET 6; - DUP 11; - CDR; - GET; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - GET 4; - AMOUNT; - EDIV; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - CAR; - MUL; - MUL; - EDIV; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - CAR; - MUL; - EDIV; - IF_SOME - { - CAR; - } - { - PUSH int 47; - FAILWITH; - }; - SUB; - ABS; - MUL; - UNIT; - TRANSFER_TOKENS; - CONS; - DUP 3; - GET 6; - DUP 3; - CDR; - GET; - IF_SOME - {} - { - PUSH int 57; - FAILWITH; - }; - CAR; - CAR; - CONTRACT unit; - IF_SOME - {} - { - PUSH int 57; - FAILWITH; - }; - PUSH mutez 1; - PUSH nat 1000; - PUSH nat 25; - DIG 6; - DUP; - CDR; - CAR; - CDR; - SWAP; - DUP; - DUG 8; - GET 6; - DUP 8; - CDR; - GET; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - GET 3; - GET; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - CDR; - ADD; - PUSH mutez 1; - DUP; - DUP; - DUP 10; - GET 6; - DUP 10; - CDR; - GET; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - GET 4; - EDIV; - IF_SOME - {} - { - PUSH int 43; - FAILWITH; - }; - CAR; - DUP 10; - GET 6; - DUP 10; - CDR; - GET; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - GET 4; - AMOUNT; - EDIV; - IF_SOME - {} - { - PUSH int 41; - FAILWITH; - }; - CAR; - MUL; - MUL; - EDIV; - IF_SOME - {} - { - PUSH int 47; - FAILWITH; - }; - CAR; - MUL; - EDIV; - IF_SOME - { - CAR; - } - { - PUSH int 47; - FAILWITH; - }; - MUL; - AMOUNT; - SUB; - UNIT; - TRANSFER_TOKENS; - CONS; - } - { - NIL operation; - }; - DUP 3; - CAR; - CDR; - CDR; - CONTRACT %transfer (list (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount)))))); - IF_SOME - {} - { - PUSH int 94; - FAILWITH; - }; - PUSH mutez 0; - NIL (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount))))); - NIL (pair (address %to_) (pair (nat %token_id) (nat %amount))); - DUP 6; - CAR; - DUP 8; - GET 6; - DUP 8; - CDR; - GET; - IF_SOME - {} - { - PUSH int 59; - FAILWITH; - }; - GET 3; - PAIR; - SENDER; - PAIR; - CONS; - SELF_ADDRESS; - PAIR; - CONS; - TRANSFER_TOKENS; - CONS; - DUP 3; - UNPAIR; - SWAP; - UNPAIR; - SWAP; - UNPAIR; - SWAP; - DUP; - DUP 7; - CDR; - DUP; - DUG 2; - GET; - IF_SOME - {} - { - PUSH int 61; - FAILWITH; - }; - DUP; - CDR; - SWAP; - CAR; - CAR; - DUP 9; - CAR; - DIG 10; - GET 6; - DUP 11; - CDR; - GET; - IF_SOME - {} - { - PUSH int 61; - FAILWITH; - }; - CAR; - CDR; - SUB; - ABS; - SWAP; - PAIR; - PAIR; - SOME; - SWAP; - UPDATE; - SWAP; - PAIR; - SWAP; - PAIR; - SWAP; - PAIR; - DUG 2; - PUSH nat 0; - DUP 4; - GET 6; - DUP 4; - CDR; - GET; - IF_SOME - {} - { - PUSH int 63; - FAILWITH; - }; - CAR; - CDR; - COMPARE; - EQ; - IF - { - DIG 2; - UNPAIR; - SWAP; - UNPAIR; - SWAP; - UNPAIR; - SWAP; - NONE (pair (pair (address %issuer) (nat %objkt_amount)) (pair (nat %objkt_id) (mutez %xtz_per_objkt))); - DIG 6; - CDR; - UPDATE; - SWAP; - PAIR; - SWAP; - PAIR; - SWAP; - PAIR; - SWAP; - } - { - SWAP; - DROP; - }; - } - { - IF_LEFT - { - DUP; - CAR; - CDR; - PUSH nat 0; - COMPARE; - LT; - IF - { - DUP; - GET 4; - PUSH nat 0; - SWAP; - COMPARE; - GE; - IF - { - DUP; - GET 4; - PUSH nat 250; - SWAP; - COMPARE; - LE; - } - { - PUSH bool False; - }; - } - { - PUSH bool False; - }; - IF - { - DUP; - GET 3; - SIZE; - PUSH nat 106; - SWAP; - COMPARE; - LE; - } - { - PUSH bool False; - }; - IF - {} - { - PUSH string "WrongCondition: ((params.amount > 0) & ((params.royalties >= 0) & (params.royalties <= 250))) & (sp.len(params.metadata) <= 106)"; - FAILWITH; - }; - NIL operation; - DUP 3; - CAR; - CDR; - CDR; - CONTRACT %mint (pair (pair (address %address) (nat %amount)) (pair (nat %token_id) (map %token_info string bytes))); - IF_SOME - {} - { - PUSH int 70; - FAILWITH; - }; - PUSH mutez 0; - DUP 4; - GET 3; - DUP 6; - CDR; - CAR; - CAR; - PAIR; - DIG 4; - DUP; - CAR; - CDR; - SWAP; - DUP; - DUG 6; - CAR; - CAR; - PAIR; - PAIR; - TRANSFER_TOKENS; - CONS; - DUP 3; - UNPAIR; - SWAP; - UNPAIR; - UNPAIR; - SWAP; - DIG 5; - GET 4; - SENDER; - PAIR; - SOME; - DIG 6; - CDR; - CAR; - CAR; - UPDATE; - SWAP; - PUSH nat 1; - ADD; - PAIR; - PAIR; - SWAP; - PAIR; - SWAP; - } - { - DUP; - CAR; - PUSH nat 0; - COMPARE; - LT; - IF - {} - { - PUSH string "WrongCondition: params.objkt_amount > 0"; - FAILWITH; - }; - NIL operation; - DUP 3; - CAR; - CDR; - CDR; - CONTRACT %transfer (list (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount)))))); - IF_SOME - {} - { - PUSH int 94; - FAILWITH; - }; - PUSH mutez 0; - NIL (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount))))); - NIL (pair (address %to_) (pair (nat %token_id) (nat %amount))); - DIG 5; - DUP; - CAR; - SWAP; - DUP; - DUG 7; - GET 3; - PAIR; - SELF_ADDRESS; - PAIR; - CONS; - SENDER; - PAIR; - CONS; - TRANSFER_TOKENS; - CONS; - DUP 3; - UNPAIR; - SWAP; - UNPAIR; - SWAP; - UNPAIR; - SWAP; - DIG 5; - DUP; - GET 4; - SWAP; - DUP; - DUG 7; - GET 3; - PAIR; - DIG 6; - CAR; - SENDER; - PAIR; - PAIR; - SOME; - DIG 6; - GET 5; - UPDATE; - SWAP; - PUSH nat 1; - ADD; - PAIR; - SWAP; - PAIR; - SWAP; - PAIR; - SWAP; - }; - }; - NIL operation; - SWAP; - ITER - { - CONS; - }; - PAIR; - }; \ No newline at end of file diff --git a/scs/curation.tz b/scs/curation.tz new file mode 100644 index 0000000..37696b8 --- /dev/null +++ b/scs/curation.tz @@ -0,0 +1,275 @@ +parameter (or (pair %claim_hDAO (nat %hDAO_amount) (nat %objkt_id)) (or (pair %configure (address %fa2) (address %protocol)) (pair %curate (nat %hDAO_amount) (pair (address %issuer) (nat %objkt_id))))); +storage (pair (pair (big_map %curations nat (pair (nat %hDAO_balance) (address %issuer))) (pair (address %fa2) (bool %locked))) (pair (address %manager) (pair (big_map %metadata string bytes) (address %protocol)))); +code + { + UNPAIR; + IF_LEFT + { + SWAP; + DUP; + DUG 2; + CAR; + CAR; + SWAP; + DUP; + DUG 2; + CDR; + GET; + IF_SOME + {} + { + PUSH int 234; + FAILWITH; + }; + CDR; + SENDER; + COMPARE; + EQ; + IF + { + SWAP; + DUP; + DUG 2; + CAR; + CAR; + SWAP; + DUP; + DUG 2; + CDR; + GET; + IF_SOME + {} + { + PUSH int 234; + FAILWITH; + }; + CAR; + SWAP; + DUP; + DUG 2; + CAR; + COMPARE; + LE; + } + { + PUSH bool False; + }; + IF + {} + { + PUSH string "WrongCondition: (sp.sender == self.data.curations[params.objkt_id].issuer) & (params.hDAO_amount <= self.data.curations[params.objkt_id].hDAO_balance)"; + FAILWITH; + }; + NIL operation; + DUP 3; + CAR; + GET 3; + CONTRACT %transfer (list (pair address (list (pair address (pair nat nat))))); + IF_SOME + {} + { + PUSH int 240; + FAILWITH; + }; + PUSH mutez 0; + NIL (pair address (list (pair address (pair nat nat)))); + NIL (pair address (pair nat nat)); + DUP 6; + CAR; + PUSH nat 0; + SENDER; + PAIR 3; + CONS; + SELF_ADDRESS; + PAIR; + CONS; + TRANSFER_TOKENS; + CONS; + DUP 3; + UNPAIR; + UNPAIR; + DUP; + DUP 6; + CDR; + DUP; + DUG 2; + GET; + IF_SOME + {} + { + PUSH int 237; + FAILWITH; + }; + DUP 7; + CAR; + DIG 8; + CAR; + CAR; + DIG 8; + CDR; + GET; + IF_SOME + {} + { + PUSH int 237; + FAILWITH; + }; + CAR; + SUB; + ABS; + UPDATE 1; + SOME; + SWAP; + UPDATE; + PAIR; + PAIR; + SWAP; + } + { + IF_LEFT + { + SWAP; + DUP; + DUG 2; + GET 3; + SENDER; + COMPARE; + EQ; + IF + { + SWAP; + DUP; + DUG 2; + CAR; + GET 4; + NOT; + } + { + PUSH bool False; + }; + IF + {} + { + PUSH string "WrongCondition: (sp.sender == self.data.manager) & (~ self.data.locked)"; + FAILWITH; + }; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + CDR; + DUP 4; + CAR; + PAIR; + SWAP; + PAIR; + PAIR; + SWAP; + CDR; + UPDATE 6; + UNPAIR; + UNPAIR; + SWAP; + CAR; + PUSH bool True; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + } + { + SWAP; + DUP; + DUG 2; + GET 6; + SENDER; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: sp.sender == self.data.protocol"; + FAILWITH; + }; + SWAP; + DUP; + DUG 2; + CAR; + CAR; + SWAP; + DUP; + DUG 2; + GET 4; + MEM; + IF + { + SWAP; + UNPAIR; + UNPAIR; + DUP; + DUP 5; + GET 4; + DUP; + DUG 2; + GET; + IF_SOME + {} + { + PUSH int 247; + FAILWITH; + }; + DUP; + CAR; + DUP 7; + CAR; + ADD; + UPDATE 1; + SOME; + SWAP; + UPDATE; + DUP; + DUP 5; + GET 4; + DUP; + DUG 2; + GET; + IF_SOME + {} + { + PUSH int 248; + FAILWITH; + }; + DIG 5; + GET 3; + UPDATE 2; + SOME; + SWAP; + UPDATE; + PAIR; + PAIR; + } + { + SWAP; + UNPAIR; + UNPAIR; + DIG 3; + DUP; + GET 3; + SWAP; + DUP; + DUG 5; + CAR; + PAIR; + SOME; + DIG 4; + GET 4; + UPDATE; + PAIR; + PAIR; + }; + }; + NIL operation; + }; + PAIR; + }; \ No newline at end of file diff --git a/fa2.tz b/scs/fa2_hdao.tz similarity index 72% rename from fa2.tz rename to scs/fa2_hdao.tz index 4aec69e..9f81950 100644 --- a/fa2.tz +++ b/scs/fa2_hdao.tz @@ -1,5 +1,5 @@ -parameter (or (or (pair %balance_of (list %requests (pair (address %owner) (nat %token_id))) (contract %callback (list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))))) (or (pair %mint (pair (address %address) (nat %amount)) (pair (nat %token_id) (map %token_metadata_map string bytes))) (address %set_administrator))) (or (or (bool %set_pause) (pair %token_metadata (list %token_ids nat) (lambda %handler (list (pair (nat %token_id) (map %token_metadata_map string bytes))) unit))) (or (list %transfer (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount)))))) (list %update_operators (or (pair %add_operator (address %owner) (pair (address %operator) (nat %token_id))) (pair %remove_operator (address %owner) (pair (address %operator) (nat %token_id)))))))); -storage (pair (pair (address %administrator) (pair (nat %all_tokens) (big_map %ledger (pair address nat) nat))) (pair (pair (big_map %metadata string bytes) (big_map %operators (pair (address %owner) (pair (address %operator) (nat %token_id))) unit)) (pair (bool %paused) (big_map %token_metadata nat (pair (nat %token_id) (map %token_metadata_map string bytes)))))); +parameter (or (or (or (pair %balance_of (list %requests (pair (address %owner) (nat %token_id))) (contract %callback (list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))))) (list %hDAO_batch (pair (nat %amount) (address %to_)))) (or (pair %mint (pair (address %address) (nat %amount)) (pair (nat %token_id) (map %token_info string bytes))) (address %set_administrator))) (or (or (bool %set_pause) (pair %token_metadata (list %token_ids nat) (lambda %handler (list (pair (nat %token_id) (map %token_info string bytes))) unit))) (or (list %transfer (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount)))))) (list %update_operators (or (pair %add_operator (address %owner) (pair (address %operator) (nat %token_id))) (pair %remove_operator (address %owner) (pair (address %operator) (nat %token_id)))))))); +storage (pair (pair (address %administrator) (pair (nat %all_tokens) (big_map %ledger (pair address nat) nat))) (pair (pair (big_map %metadata string bytes) (big_map %operators (pair (address %owner) (pair (address %operator) (nat %token_id))) unit)) (pair (bool %paused) (big_map %token_metadata nat (pair (nat %token_id) (map %token_info string bytes)))))); code { UNPAIR; @@ -7,52 +7,38 @@ code { IF_LEFT { - SWAP; - DUP; - DUG 2; - GET 5; - IF - { - PUSH int 478; - FAILWITH; - } - {}; - DUP; - CAR; - MAP + IF_LEFT { - DUP 3; - GET 6; SWAP; DUP; DUG 2; - CDR; - MEM; + GET 5; IF - {} { - PUSH string "FA2_TOKEN_UNDEFINED"; + PUSH string "WrongCondition: ~ self.data.paused"; FAILWITH; - }; - DUP 3; - CAR; - CDR; - CDR; - SWAP; - DUP; - CDR; - SWAP; + } + {}; DUP; - DUG 3; CAR; - PAIR; - MEM; - IF + MAP { DUP 3; - CAR; - CDR; + GET 6; + SWAP; + DUP; + DUG 2; CDR; + MEM; + IF + {} + { + PUSH string "FA2_TOKEN_UNDEFINED"; + FAILWITH; + }; + DUP 3; + CAR; + GET 4; SWAP; DUP; CDR; @@ -61,29 +47,157 @@ code DUG 3; CAR; PAIR; - GET; - IF_SOME - {} + MEM; + IF { - PUSH int 485; - FAILWITH; + DUP 3; + CAR; + GET 4; + SWAP; + DUP; + CDR; + SWAP; + DUP; + DUG 3; + CAR; + PAIR; + GET; + IF_SOME + {} + { + PUSH int 871; + FAILWITH; + }; + SWAP; + PAIR; + } + { + PUSH nat 0; + SWAP; + PAIR; }; - SWAP; - PAIR; - } + }; + NIL operation; + DIG 2; + CDR; + PUSH mutez 0; + DIG 3; + TRANSFER_TOKENS; + CONS; + } + { + SWAP; + DUP; + DUG 2; + CAR; + CAR; + SENDER; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: sp.sender == self.data.administrator"; + FAILWITH; + }; + DUP; + ITER { + DUP 3; + CAR; + GET 4; PUSH nat 0; - SWAP; + DUP 3; + CDR; PAIR; + MEM; + IF + { + DIG 2; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + DUP; + PUSH nat 0; + DUP 7; + CDR; + PAIR; + DUP; + DUG 2; + GET; + IF_SOME + {} + { + PUSH int 923; + FAILWITH; + }; + DIG 6; + CAR; + ADD; + SOME; + SWAP; + UPDATE; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + SWAP; + } + { + DIG 2; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + DUP 5; + CAR; + SOME; + PUSH nat 0; + DIG 6; + CDR; + PAIR; + UPDATE; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + SWAP; + }; + SWAP; + DUP; + DUG 2; + GET 6; + PUSH nat 0; + MEM; + IF + {} + { + SWAP; + DUP; + GET 6; + EMPTY_MAP string bytes; + PUSH string "ipfs://QmSVsfwH8es7Ur2eqto9hVpcd2dfWASmEaNxTPpcymuJzg"; + PACK; + SOME; + PUSH string ""; + UPDATE; + PUSH nat 0; + PAIR; + SOME; + PUSH nat 0; + UPDATE; + UPDATE 6; + SWAP; + }; }; + DROP; + NIL operation; }; - NIL operation; - DIG 2; - CDR; - PUSH mutez 0; - DIG 3; - TRANSFER_TOKENS; - CONS; } { IF_LEFT @@ -99,21 +213,19 @@ code IF {} { - PUSH int 559; + PUSH string "WrongCondition: sp.sender == self.data.administrator"; FAILWITH; }; SWAP; DUP; DUG 2; UNPAIR; - DUP; - CAR; + UNPAIR; SWAP; - GET 4; - DIG 4; - CAR; CDR; + DIG 4; CAR; + GET 3; DUP; PUSH nat 1; DUP 7; @@ -138,8 +250,7 @@ code DUP; DUG 2; CAR; - CDR; - CDR; + GET 4; SWAP; DUP; GET 3; @@ -153,8 +264,6 @@ code IF { SWAP; - DUP; - DUG 2; UNPAIR; UNPAIR; SWAP; @@ -174,36 +283,14 @@ code DUG 2; GET; IF_SOME + {} { - DROP; - } - { - PUSH int 571; + PUSH int 974; FAILWITH; }; - DUP 6; + DUP 7; CAR; CDR; - DIG 7; - CAR; - CDR; - CDR; - DIG 7; - DUP; - GET 3; - SWAP; - DUP; - DUG 9; - CAR; - CAR; - PAIR; - GET; - IF_SOME - {} - { - PUSH int 571; - FAILWITH; - }; ADD; SOME; SWAP; @@ -222,20 +309,19 @@ code SWAP; UNPAIR; SWAP; - DIG 4; + DUP 5; + CAR; + CDR; + SOME; + DIG 5; DUP; GET 3; SWAP; DUP; - DUG 6; + DUG 7; CAR; CAR; PAIR; - DUP 6; - CAR; - CDR; - SOME; - SWAP; UPDATE; SWAP; PAIR; @@ -259,30 +345,21 @@ code } { SWAP; - UNPAIR; - SWAP; - UNPAIR; - SWAP; - UNPAIR; - SWAP; - DIG 4; DUP; - GET 3; - SWAP; + GET 6; + DIG 2; DUP; GET 4; SWAP; + DUP; + DUG 4; GET 3; PAIR; SOME; - SWAP; + DIG 3; + GET 3; UPDATE; - SWAP; - PAIR; - SWAP; - PAIR; - SWAP; - PAIR; + UPDATE 6; }; } { @@ -297,14 +374,11 @@ code IF {} { - PUSH int 544; + PUSH string "WrongCondition: sp.sender == self.data.administrator"; FAILWITH; }; SWAP; - DUP; - CDR; - SWAP; - CAR; + UNPAIR; CDR; DIG 2; PAIR; @@ -329,22 +403,10 @@ code IF {} { - PUSH int 553; + PUSH string "WrongCondition: sp.sender == self.data.administrator"; FAILWITH; }; - SWAP; - UNPAIR; - SWAP; - DUP; - CAR; - SWAP; - GET 4; - DIG 3; - PAIR; - SWAP; - PAIR; - SWAP; - PAIR; + UPDATE 5; } { SWAP; @@ -353,7 +415,7 @@ code GET 5; IF { - PUSH int 594; + PUSH string "WrongCondition: ~ self.data.paused"; FAILWITH; } {}; @@ -372,7 +434,7 @@ code IF_SOME {} { - PUSH int 604; + PUSH int 1007; FAILWITH; }; }; @@ -391,7 +453,7 @@ code GET 5; IF { - PUSH int 435; + PUSH string "WrongCondition: ~ self.data.paused"; FAILWITH; } {}; @@ -425,18 +487,16 @@ code } { DUP 4; - CDR; - CAR; + GET 3; CDR; SWAP; DUP; DUG 2; GET 3; SENDER; - PAIR; - DUP 4; + DUP 5; CAR; - PAIR; + PAIR 3; MEM; }; IF @@ -469,8 +529,7 @@ code GET 4; DUP 5; CAR; - CDR; - CDR; + GET 4; DUP 3; GET 3; DUP 5; @@ -480,7 +539,7 @@ code IF_SOME {} { - PUSH int 462; + PUSH int 848; FAILWITH; }; COMPARE; @@ -511,15 +570,14 @@ code DROP; } { - PUSH int 466; + PUSH int 852; FAILWITH; }; DUP 6; GET 4; DIG 9; CAR; - CDR; - CDR; + GET 4; DUP 8; GET 3; DUP 10; @@ -529,7 +587,7 @@ code IF_SOME {} { - PUSH int 466; + PUSH int 852; FAILWITH; }; SUB; @@ -537,7 +595,7 @@ code IF_SOME {} { - PUSH int 466; + PUSH int 852; FAILWITH; }; SOME; @@ -551,8 +609,7 @@ code DUP; DUG 4; CAR; - CDR; - CDR; + GET 4; SWAP; DUP; GET 3; @@ -564,7 +621,7 @@ code MEM; IF { - DUP 4; + DIG 3; UNPAIR; UNPAIR; SWAP; @@ -582,33 +639,14 @@ code DUP; DUG 2; GET; - IF_SOME - { - DROP; - } - { - PUSH int 469; - FAILWITH; - }; - DUP 6; - GET 4; - DIG 9; - CAR; - CDR; - CDR; - DIG 7; - DUP; - GET 3; - SWAP; - CAR; - PAIR; - GET; IF_SOME {} { - PUSH int 469; + PUSH int 855; FAILWITH; }; + DIG 6; + GET 4; ADD; SOME; SWAP; @@ -627,18 +665,15 @@ code SWAP; UNPAIR; SWAP; - DIG 4; + DUP 5; + GET 4; + SOME; + DIG 5; DUP; GET 3; SWAP; - DUP; - DUG 6; CAR; PAIR; - DIG 5; - GET 4; - SOME; - SWAP; UPDATE; SWAP; PAIR; @@ -682,7 +717,7 @@ code IF {} { - PUSH int 514; + PUSH string "WrongCondition: (add_operator.owner == sp.sender) | (sp.sender == self.data.administrator)"; FAILWITH; }; DIG 2; @@ -691,19 +726,16 @@ code UNPAIR; UNPAIR; SWAP; - DIG 4; + PUSH (option unit) (Some Unit); + DIG 5; DUP; GET 4; SWAP; DUP; - DUG 6; GET 3; - PAIR; - DIG 5; - CAR; - PAIR; - PUSH (option unit) (Some Unit); SWAP; + CAR; + PAIR 3; UPDATE; SWAP; PAIR; @@ -733,7 +765,7 @@ code IF {} { - PUSH int 521; + PUSH string "WrongCondition: (remove_operator.owner == sp.sender) | (sp.sender == self.data.administrator)"; FAILWITH; }; DIG 2; @@ -748,12 +780,10 @@ code GET 4; SWAP; DUP; - DUG 7; GET 3; - PAIR; - DIG 6; + SWAP; CAR; - PAIR; + PAIR 3; UPDATE; SWAP; PAIR; @@ -769,4 +799,4 @@ code NIL operation; }; PAIR; - }; + }; \ No newline at end of file diff --git a/scs/fa2_objkts.tz b/scs/fa2_objkts.tz new file mode 100644 index 0000000..9f81950 --- /dev/null +++ b/scs/fa2_objkts.tz @@ -0,0 +1,802 @@ +parameter (or (or (or (pair %balance_of (list %requests (pair (address %owner) (nat %token_id))) (contract %callback (list (pair (pair %request (address %owner) (nat %token_id)) (nat %balance))))) (list %hDAO_batch (pair (nat %amount) (address %to_)))) (or (pair %mint (pair (address %address) (nat %amount)) (pair (nat %token_id) (map %token_info string bytes))) (address %set_administrator))) (or (or (bool %set_pause) (pair %token_metadata (list %token_ids nat) (lambda %handler (list (pair (nat %token_id) (map %token_info string bytes))) unit))) (or (list %transfer (pair (address %from_) (list %txs (pair (address %to_) (pair (nat %token_id) (nat %amount)))))) (list %update_operators (or (pair %add_operator (address %owner) (pair (address %operator) (nat %token_id))) (pair %remove_operator (address %owner) (pair (address %operator) (nat %token_id)))))))); +storage (pair (pair (address %administrator) (pair (nat %all_tokens) (big_map %ledger (pair address nat) nat))) (pair (pair (big_map %metadata string bytes) (big_map %operators (pair (address %owner) (pair (address %operator) (nat %token_id))) unit)) (pair (bool %paused) (big_map %token_metadata nat (pair (nat %token_id) (map %token_info string bytes)))))); +code + { + UNPAIR; + IF_LEFT + { + IF_LEFT + { + IF_LEFT + { + SWAP; + DUP; + DUG 2; + GET 5; + IF + { + PUSH string "WrongCondition: ~ self.data.paused"; + FAILWITH; + } + {}; + DUP; + CAR; + MAP + { + DUP 3; + GET 6; + SWAP; + DUP; + DUG 2; + CDR; + MEM; + IF + {} + { + PUSH string "FA2_TOKEN_UNDEFINED"; + FAILWITH; + }; + DUP 3; + CAR; + GET 4; + SWAP; + DUP; + CDR; + SWAP; + DUP; + DUG 3; + CAR; + PAIR; + MEM; + IF + { + DUP 3; + CAR; + GET 4; + SWAP; + DUP; + CDR; + SWAP; + DUP; + DUG 3; + CAR; + PAIR; + GET; + IF_SOME + {} + { + PUSH int 871; + FAILWITH; + }; + SWAP; + PAIR; + } + { + PUSH nat 0; + SWAP; + PAIR; + }; + }; + NIL operation; + DIG 2; + CDR; + PUSH mutez 0; + DIG 3; + TRANSFER_TOKENS; + CONS; + } + { + SWAP; + DUP; + DUG 2; + CAR; + CAR; + SENDER; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: sp.sender == self.data.administrator"; + FAILWITH; + }; + DUP; + ITER + { + DUP 3; + CAR; + GET 4; + PUSH nat 0; + DUP 3; + CDR; + PAIR; + MEM; + IF + { + DIG 2; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + DUP; + PUSH nat 0; + DUP 7; + CDR; + PAIR; + DUP; + DUG 2; + GET; + IF_SOME + {} + { + PUSH int 923; + FAILWITH; + }; + DIG 6; + CAR; + ADD; + SOME; + SWAP; + UPDATE; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + SWAP; + } + { + DIG 2; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + DUP 5; + CAR; + SOME; + PUSH nat 0; + DIG 6; + CDR; + PAIR; + UPDATE; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + SWAP; + }; + SWAP; + DUP; + DUG 2; + GET 6; + PUSH nat 0; + MEM; + IF + {} + { + SWAP; + DUP; + GET 6; + EMPTY_MAP string bytes; + PUSH string "ipfs://QmSVsfwH8es7Ur2eqto9hVpcd2dfWASmEaNxTPpcymuJzg"; + PACK; + SOME; + PUSH string ""; + UPDATE; + PUSH nat 0; + PAIR; + SOME; + PUSH nat 0; + UPDATE; + UPDATE 6; + SWAP; + }; + }; + DROP; + NIL operation; + }; + } + { + IF_LEFT + { + SWAP; + DUP; + DUG 2; + CAR; + CAR; + SENDER; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: sp.sender == self.data.administrator"; + FAILWITH; + }; + SWAP; + DUP; + DUG 2; + UNPAIR; + UNPAIR; + SWAP; + CDR; + DIG 4; + CAR; + GET 3; + DUP; + PUSH nat 1; + DUP 7; + GET 3; + ADD; + DUP; + DUG 2; + COMPARE; + LE; + IF + { + DROP; + } + { + SWAP; + DROP; + }; + PAIR; + SWAP; + PAIR; + PAIR; + DUP; + DUG 2; + CAR; + GET 4; + SWAP; + DUP; + GET 3; + SWAP; + DUP; + DUG 3; + CAR; + CAR; + PAIR; + MEM; + IF + { + SWAP; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + DUP; + DIG 5; + DUP; + GET 3; + SWAP; + DUP; + DUG 7; + CAR; + CAR; + PAIR; + DUP; + DUG 2; + GET; + IF_SOME + {} + { + PUSH int 974; + FAILWITH; + }; + DUP 7; + CAR; + CDR; + ADD; + SOME; + SWAP; + UPDATE; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + SWAP; + } + { + SWAP; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + DUP 5; + CAR; + CDR; + SOME; + DIG 5; + DUP; + GET 3; + SWAP; + DUP; + DUG 7; + CAR; + CAR; + PAIR; + UPDATE; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + SWAP; + }; + SWAP; + DUP; + DUG 2; + GET 6; + SWAP; + DUP; + DUG 2; + GET 3; + MEM; + IF + { + DROP; + } + { + SWAP; + DUP; + GET 6; + DIG 2; + DUP; + GET 4; + SWAP; + DUP; + DUG 4; + GET 3; + PAIR; + SOME; + DIG 3; + GET 3; + UPDATE; + UPDATE 6; + }; + } + { + SWAP; + DUP; + DUG 2; + CAR; + CAR; + SENDER; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: sp.sender == self.data.administrator"; + FAILWITH; + }; + SWAP; + UNPAIR; + CDR; + DIG 2; + PAIR; + PAIR; + }; + NIL operation; + }; + } + { + IF_LEFT + { + IF_LEFT + { + SWAP; + DUP; + DUG 2; + CAR; + CAR; + SENDER; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: sp.sender == self.data.administrator"; + FAILWITH; + }; + UPDATE 5; + } + { + SWAP; + DUP; + DUG 2; + GET 5; + IF + { + PUSH string "WrongCondition: ~ self.data.paused"; + FAILWITH; + } + {}; + DUP; + CDR; + SWAP; + DUP; + DUG 2; + CAR; + MAP + { + DUP 4; + GET 6; + SWAP; + GET; + IF_SOME + {} + { + PUSH int 1007; + FAILWITH; + }; + }; + DIG 2; + DROP; + EXEC; + DROP; + }; + } + { + IF_LEFT + { + SWAP; + DUP; + DUG 2; + GET 5; + IF + { + PUSH string "WrongCondition: ~ self.data.paused"; + FAILWITH; + } + {}; + DUP; + ITER + { + DUP; + CDR; + ITER + { + DUP 4; + CAR; + CAR; + SENDER; + COMPARE; + EQ; + IF + { + PUSH bool True; + } + { + SENDER; + DUP 3; + CAR; + COMPARE; + EQ; + }; + IF + { + PUSH bool True; + } + { + DUP 4; + GET 3; + CDR; + SWAP; + DUP; + DUG 2; + GET 3; + SENDER; + DUP 5; + CAR; + PAIR 3; + MEM; + }; + IF + {} + { + PUSH string "FA2_NOT_OPERATOR"; + FAILWITH; + }; + DUP 4; + GET 6; + SWAP; + DUP; + DUG 2; + GET 3; + MEM; + IF + {} + { + PUSH string "FA2_TOKEN_UNDEFINED"; + FAILWITH; + }; + DUP; + GET 4; + PUSH nat 0; + COMPARE; + LT; + IF + { + DUP; + GET 4; + DUP 5; + CAR; + GET 4; + DUP 3; + GET 3; + DUP 5; + CAR; + PAIR; + GET; + IF_SOME + {} + { + PUSH int 848; + FAILWITH; + }; + COMPARE; + GE; + IF + {} + { + PUSH string "FA2_INSUFFICIENT_BALANCE"; + FAILWITH; + }; + DUP 4; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + DUP; + DUP 6; + GET 3; + DUP 8; + CAR; + PAIR; + DUP; + DUG 2; + GET; + IF_SOME + { + DROP; + } + { + PUSH int 852; + FAILWITH; + }; + DUP 6; + GET 4; + DIG 9; + CAR; + GET 4; + DUP 8; + GET 3; + DUP 10; + CAR; + PAIR; + GET; + IF_SOME + {} + { + PUSH int 852; + FAILWITH; + }; + SUB; + ISNAT; + IF_SOME + {} + { + PUSH int 852; + FAILWITH; + }; + SOME; + SWAP; + UPDATE; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + DUP; + DUG 4; + CAR; + GET 4; + SWAP; + DUP; + GET 3; + SWAP; + DUP; + DUG 3; + CAR; + PAIR; + MEM; + IF + { + DIG 3; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + DUP; + DIG 5; + DUP; + GET 3; + SWAP; + DUP; + DUG 7; + CAR; + PAIR; + DUP; + DUG 2; + GET; + IF_SOME + {} + { + PUSH int 855; + FAILWITH; + }; + DIG 6; + GET 4; + ADD; + SOME; + SWAP; + UPDATE; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + DUG 2; + } + { + DIG 3; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + DUP 5; + GET 4; + SOME; + DIG 5; + DUP; + GET 3; + SWAP; + CAR; + PAIR; + UPDATE; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + DUG 2; + }; + } + { + DROP; + }; + }; + DROP; + }; + DROP; + } + { + DUP; + ITER + { + IF_LEFT + { + DUP; + CAR; + SENDER; + COMPARE; + EQ; + IF + { + PUSH bool True; + } + { + DUP 3; + CAR; + CAR; + SENDER; + COMPARE; + EQ; + }; + IF + {} + { + PUSH string "WrongCondition: (add_operator.owner == sp.sender) | (sp.sender == self.data.administrator)"; + FAILWITH; + }; + DIG 2; + UNPAIR; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + PUSH (option unit) (Some Unit); + DIG 5; + DUP; + GET 4; + SWAP; + DUP; + GET 3; + SWAP; + CAR; + PAIR 3; + UPDATE; + SWAP; + PAIR; + PAIR; + SWAP; + PAIR; + SWAP; + } + { + DUP; + CAR; + SENDER; + COMPARE; + EQ; + IF + { + PUSH bool True; + } + { + DUP 3; + CAR; + CAR; + SENDER; + COMPARE; + EQ; + }; + IF + {} + { + PUSH string "WrongCondition: (remove_operator.owner == sp.sender) | (sp.sender == self.data.administrator)"; + FAILWITH; + }; + DIG 2; + UNPAIR; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + NONE unit; + DIG 5; + DUP; + GET 4; + SWAP; + DUP; + GET 3; + SWAP; + CAR; + PAIR 3; + UPDATE; + SWAP; + PAIR; + PAIR; + SWAP; + PAIR; + SWAP; + }; + }; + DROP; + }; + }; + NIL operation; + }; + PAIR; + }; \ No newline at end of file diff --git a/scs/objkt_swap.tz b/scs/objkt_swap.tz new file mode 100644 index 0000000..7433835 --- /dev/null +++ b/scs/objkt_swap.tz @@ -0,0 +1,1689 @@ +parameter (or (or (nat %cancel_swap) (or (pair %collect (nat %objkt_amount) (nat %swap_id)) (pair %curate (nat %hDAO_amount) (nat %objkt_id)))) (or (or (unit %genesis) (pair %mint_OBJKT (pair (address %address) (nat %amount)) (pair (bytes %metadata) (nat %royalties)))) (or (pair %swap (pair (address %kt) (nat %objkt_amount)) (pair (nat %objkt_id) (mutez %xtz_per_objkt))) (address %update_manager)))); +storage (pair (pair (pair (address %curate) (timestamp %genesis)) (pair (address %hdao) (pair (bool %locked) (address %manager)))) (pair (pair (big_map %metadata string bytes) (pair (address %objkt) (nat %objkt_id))) (pair (big_map %royalties nat (pair (address %issuer) (nat %royalties))) (pair (nat %swap_id) (big_map %swaps nat (pair (pair (address %issuer) (nat %objkt_amount)) (pair (nat %objkt_id) (mutez %xtz_per_objkt)))))))); +code + { + UNPAIR; + IF_LEFT + { + IF_LEFT + { + SENDER; + DUP 3; + GET 8; + DUP 3; + GET; + IF_SOME + {} + { + PUSH int 291; + FAILWITH; + }; + CAR; + CAR; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: self.data.swaps[params].issuer == sp.sender"; + FAILWITH; + }; + NIL operation; + DUP 3; + GET 3; + GET 3; + CONTRACT %transfer (list (pair address (list (pair address (pair nat nat))))); + IF_SOME + {} + { + PUSH int 399; + FAILWITH; + }; + PUSH mutez 0; + NIL (pair address (list (pair address (pair nat nat)))); + NIL (pair address (pair nat nat)); + DUP 7; + GET 8; + DUP 7; + GET; + IF_SOME + {} + { + PUSH int 292; + FAILWITH; + }; + CAR; + CDR; + DUP 8; + GET 8; + DUP 8; + GET; + IF_SOME + {} + { + PUSH int 292; + FAILWITH; + }; + GET 3; + SENDER; + PAIR 3; + CONS; + SELF_ADDRESS; + PAIR; + CONS; + TRANSFER_TOKENS; + CONS; + DIG 2; + DUP; + GET 8; + NONE (pair (pair address nat) (pair nat mutez)); + DIG 4; + UPDATE; + UPDATE 8; + SWAP; + } + { + IF_LEFT + { + DUP; + CAR; + PUSH nat 0; + COMPARE; + LT; + IF + { + SWAP; + DUP; + DUG 2; + GET 8; + SWAP; + DUP; + DUG 2; + CDR; + GET; + IF_SOME + {} + { + PUSH int 298; + FAILWITH; + }; + CAR; + CAR; + SENDER; + COMPARE; + NEQ; + } + { + PUSH bool False; + }; + IF + {} + { + PUSH string "WrongCondition: (params.objkt_amount > 0) & (sp.sender != self.data.swaps[params.swap_id].issuer)"; + FAILWITH; + }; + PUSH mutez 0; + DUP 3; + GET 8; + DUP 3; + CDR; + GET; + IF_SOME + {} + { + PUSH int 300; + FAILWITH; + }; + GET 4; + COMPARE; + NEQ; + IF + { + SWAP; + DUP; + DUG 2; + GET 8; + SWAP; + DUP; + DUG 2; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + SWAP; + DUP; + DUG 2; + CAR; + COMPARE; + EQ; + IF + { + PUSH mutez 1; + DUP; + DUP 4; + GET 8; + DUP 4; + CDR; + GET; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + GET 4; + EDIV; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + CAR; + DUP 4; + GET 8; + DUP 4; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + MUL; + MUL; + AMOUNT; + COMPARE; + EQ; + } + { + PUSH bool False; + }; + IF + { + PUSH mutez 0; + AMOUNT; + COMPARE; + GT; + } + { + PUSH bool False; + }; + IF + {} + { + PUSH string "WrongCondition: ((params.objkt_amount == sp.fst(sp.ediv(sp.amount, self.data.swaps[params.swap_id].xtz_per_objkt).open_some())) & (sp.amount == sp.mul(sp.fst(sp.ediv(sp.amount, self.data.swaps[params.swap_id].xtz_per_objkt).open_some()) * sp.fst(sp.ediv(self.data.swaps[params.swap_id].xtz_per_objkt, sp.mutez(1)).open_some()), sp.mutez(1)))) & (sp.amount > sp.tez(0))"; + FAILWITH; + }; + NIL operation; + DIG 2; + DUP; + GET 5; + SWAP; + DUP; + DUG 4; + GET 8; + DUP 4; + CDR; + GET; + IF_SOME + {} + { + PUSH int 312; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 312; + FAILWITH; + }; + CAR; + CONTRACT unit; + IF_SOME + {} + { + PUSH int 312; + FAILWITH; + }; + PUSH mutez 1; + PUSH nat 25; + DIG 5; + DUP; + GET 5; + SWAP; + DUP; + DUG 7; + GET 8; + DUP 7; + CDR; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + CDR; + ADD; + PUSH nat 1000; + PUSH nat 25; + DIG 7; + DUP; + GET 5; + SWAP; + DUP; + DUG 9; + GET 8; + DUP 9; + CDR; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CDR; + ADD; + PUSH mutez 1; + PUSH nat 1; + MUL; + PUSH mutez 1; + DUP; + DUP 11; + GET 8; + DUP 11; + CDR; + GET; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + GET 4; + EDIV; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + CAR; + DUP 11; + GET 8; + DUP 11; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + MUL; + MUL; + EDIV; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CAR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 308; + FAILWITH; + }; + DIG 6; + DUP; + GET 5; + SWAP; + DUP; + DUG 8; + GET 8; + DUP 8; + CDR; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + CDR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 309; + FAILWITH; + }; + MUL; + UNIT; + TRANSFER_TOKENS; + CONS; + DUP 3; + CAR; + GET 6; + CONTRACT unit; + IF_SOME + {} + { + PUSH int 315; + FAILWITH; + }; + PUSH mutez 1; + PUSH nat 25; + DIG 5; + DUP; + GET 5; + SWAP; + DUP; + DUG 7; + GET 8; + DUP 7; + CDR; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + CDR; + ADD; + PUSH nat 1000; + PUSH nat 25; + DIG 7; + DUP; + GET 5; + SWAP; + DUP; + DUG 9; + GET 8; + DUP 9; + CDR; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CDR; + ADD; + PUSH mutez 1; + PUSH nat 1; + MUL; + PUSH mutez 1; + DUP; + DUP 11; + GET 8; + DUP 11; + CDR; + GET; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + GET 4; + EDIV; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + CAR; + DUP 11; + GET 8; + DUP 11; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + MUL; + MUL; + EDIV; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CAR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 308; + FAILWITH; + }; + DIG 6; + DUP; + GET 5; + SWAP; + DUP; + DUG 8; + GET 8; + DUP 8; + CDR; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + CDR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 309; + FAILWITH; + }; + PUSH nat 1000; + PUSH nat 25; + DIG 7; + DUP; + GET 5; + SWAP; + DUP; + DUG 9; + GET 8; + DUP 9; + CDR; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CDR; + ADD; + PUSH mutez 1; + PUSH nat 1; + MUL; + PUSH mutez 1; + DUP; + DUP 11; + GET 8; + DUP 11; + CDR; + GET; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + GET 4; + EDIV; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + CAR; + DUP 11; + GET 8; + DUP 11; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + MUL; + MUL; + EDIV; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CAR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 308; + FAILWITH; + }; + SUB; + ABS; + MUL; + UNIT; + TRANSFER_TOKENS; + CONS; + DUP 3; + GET 8; + DUP 3; + CDR; + GET; + IF_SOME + {} + { + PUSH int 318; + FAILWITH; + }; + CAR; + CAR; + CONTRACT unit; + IF_SOME + {} + { + PUSH int 318; + FAILWITH; + }; + PUSH mutez 1; + PUSH nat 1000; + PUSH nat 25; + DIG 6; + DUP; + GET 5; + SWAP; + DUP; + DUG 8; + GET 8; + DUP 8; + CDR; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CDR; + ADD; + PUSH mutez 1; + PUSH nat 1; + MUL; + PUSH mutez 1; + DUP; + DUP 10; + GET 8; + DUP 10; + CDR; + GET; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + GET 4; + EDIV; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + CAR; + DUP 10; + GET 8; + DUP 10; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + MUL; + MUL; + EDIV; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CAR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 308; + FAILWITH; + }; + MUL; + AMOUNT; + SUB; + UNIT; + TRANSFER_TOKENS; + CONS; + DUP 3; + CAR; + CAR; + CDR; + NOW; + COMPARE; + LT; + IF + { + DUP 3; + CAR; + GET 3; + CONTRACT %hDAO_batch (list (pair nat address)); + IF_SOME + {} + { + PUSH int 384; + FAILWITH; + }; + PUSH mutez 0; + NIL (pair nat address); + DUP 6; + CAR; + GET 6; + PUSH nat 25; + DIG 7; + DUP; + GET 5; + SWAP; + DUP; + DUG 9; + GET 8; + DUP 9; + CDR; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + CDR; + ADD; + PUSH nat 1000; + PUSH nat 25; + DIG 9; + DUP; + GET 5; + SWAP; + DUP; + DUG 11; + GET 8; + DUP 11; + CDR; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CDR; + ADD; + PUSH mutez 1; + PUSH nat 1; + MUL; + PUSH mutez 1; + DUP; + DUP 13; + GET 8; + DUP 13; + CDR; + GET; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + GET 4; + EDIV; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + CAR; + DUP 13; + GET 8; + DUP 13; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + MUL; + MUL; + EDIV; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CAR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 308; + FAILWITH; + }; + DIG 8; + DUP; + GET 5; + SWAP; + DUP; + DUG 10; + GET 8; + DUP 10; + CDR; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 309; + FAILWITH; + }; + CDR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 309; + FAILWITH; + }; + PUSH nat 1000; + PUSH nat 25; + DIG 9; + DUP; + GET 5; + SWAP; + DUP; + DUG 11; + GET 8; + DUP 11; + CDR; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + GET 3; + GET; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CDR; + ADD; + PUSH mutez 1; + PUSH nat 1; + MUL; + PUSH mutez 1; + DUP; + DUP 13; + GET 8; + DUP 13; + CDR; + GET; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + GET 4; + EDIV; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + CAR; + DUP 13; + GET 8; + DUP 13; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + MUL; + MUL; + EDIV; + IF_SOME + {} + { + PUSH int 308; + FAILWITH; + }; + CAR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 308; + FAILWITH; + }; + SUB; + ABS; + PAIR; + CONS; + DUP 6; + GET 8; + DUP 6; + CDR; + GET; + IF_SOME + {} + { + PUSH int 322; + FAILWITH; + }; + CAR; + CAR; + PUSH nat 2; + PUSH mutez 1; + DUP 9; + GET 8; + DUP 9; + CDR; + GET; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + GET 4; + EDIV; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + CAR; + DUP 9; + GET 8; + DUP 9; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 322; + FAILWITH; + }; + PAIR; + CONS; + SENDER; + PUSH nat 2; + PUSH mutez 1; + DUP 9; + GET 8; + DUP 9; + CDR; + GET; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + GET 4; + EDIV; + IF_SOME + {} + { + PUSH int 304; + FAILWITH; + }; + CAR; + DUP 9; + GET 8; + DUP 9; + CDR; + GET; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + GET 4; + AMOUNT; + EDIV; + IF_SOME + {} + { + PUSH int 302; + FAILWITH; + }; + CAR; + MUL; + EDIV; + IF_SOME + { + CAR; + } + { + PUSH int 322; + FAILWITH; + }; + PAIR; + CONS; + TRANSFER_TOKENS; + CONS; + } + {}; + } + { + NIL operation; + }; + DUP 3; + GET 3; + GET 3; + CONTRACT %transfer (list (pair address (list (pair address (pair nat nat))))); + IF_SOME + {} + { + PUSH int 399; + FAILWITH; + }; + PUSH mutez 0; + NIL (pair address (list (pair address (pair nat nat)))); + NIL (pair address (pair nat nat)); + DUP 6; + CAR; + DUP 8; + GET 8; + DUP 8; + CDR; + GET; + IF_SOME + {} + { + PUSH int 324; + FAILWITH; + }; + GET 3; + SENDER; + PAIR 3; + CONS; + SELF_ADDRESS; + PAIR; + CONS; + TRANSFER_TOKENS; + CONS; + DUP 3; + DUP; + GET 8; + DUP; + DUP 5; + CDR; + DUP; + DUG 2; + GET; + IF_SOME + {} + { + PUSH int 326; + FAILWITH; + }; + UNPAIR; + CAR; + DUP 7; + CAR; + DIG 8; + GET 8; + DUP 9; + CDR; + GET; + IF_SOME + {} + { + PUSH int 326; + FAILWITH; + }; + CAR; + CDR; + SUB; + ABS; + SWAP; + PAIR; + PAIR; + SOME; + SWAP; + UPDATE; + UPDATE 8; + DUG 2; + PUSH nat 0; + DUP 4; + GET 8; + DUP 4; + CDR; + GET; + IF_SOME + {} + { + PUSH int 328; + FAILWITH; + }; + CAR; + CDR; + COMPARE; + EQ; + IF + { + DIG 2; + DUP; + GET 8; + NONE (pair (pair address nat) (pair nat mutez)); + DIG 4; + CDR; + UPDATE; + UPDATE 8; + SWAP; + } + { + SWAP; + DROP; + }; + } + { + NIL operation; + DUP 3; + CAR; + GET 3; + CONTRACT %transfer (list (pair address (list (pair address (pair nat nat))))); + IF_SOME + {} + { + PUSH int 399; + FAILWITH; + }; + PUSH mutez 0; + NIL (pair address (list (pair address (pair nat nat)))); + NIL (pair address (pair nat nat)); + DUP 6; + CAR; + PUSH nat 0; + DUP 9; + CAR; + CAR; + CAR; + PAIR 3; + CONS; + SENDER; + PAIR; + CONS; + TRANSFER_TOKENS; + CONS; + DUP 3; + CAR; + CAR; + CAR; + CONTRACT %curate (pair nat (pair address nat)); + IF_SOME + {} + { + PUSH int 362; + FAILWITH; + }; + PUSH mutez 0; + DUP 4; + CDR; + DUP 6; + GET 5; + DUP 6; + CDR; + GET; + IF_SOME + {} + { + PUSH int 372; + FAILWITH; + }; + CAR; + DIG 5; + CAR; + PAIR 3; + TRANSFER_TOKENS; + CONS; + }; + }; + } + { + IF_LEFT + { + IF_LEFT + { + DROP; + DUP; + CAR; + GET 6; + SENDER; + COMPARE; + EQ; + IF + { + DUP; + CAR; + GET 5; + NOT; + } + { + PUSH bool False; + }; + IF + {} + { + PUSH string "WrongCondition: (sp.sender == self.data.manager) & (~ self.data.locked)"; + FAILWITH; + }; + UNPAIR; + UNPAIR; + CAR; + NOW; + PUSH int 3888000; + ADD; + SWAP; + PAIR; + SWAP; + UNPAIR; + SWAP; + CDR; + PUSH bool True; + PAIR; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + NIL operation; + } + { + DUP; + CAR; + CDR; + PUSH nat 0; + COMPARE; + LT; + IF + { + DUP; + GET 4; + PUSH nat 0; + SWAP; + COMPARE; + GE; + IF + { + DUP; + GET 4; + PUSH nat 250; + SWAP; + COMPARE; + LE; + } + { + PUSH bool False; + }; + } + { + PUSH bool False; + }; + IF + { + DUP; + CAR; + CDR; + PUSH nat 10000; + SWAP; + COMPARE; + LE; + } + { + PUSH bool False; + }; + IF + {} + { + PUSH string "WrongCondition: ((params.amount > 0) & ((params.royalties >= 0) & (params.royalties <= 250))) & (params.amount <= 10000)"; + FAILWITH; + }; + NIL operation; + DUP 3; + GET 3; + GET 3; + CONTRACT %mint (pair (pair address nat) (pair nat (map string bytes))); + IF_SOME + {} + { + PUSH int 335; + FAILWITH; + }; + PUSH mutez 0; + EMPTY_MAP string bytes; + DUP 5; + GET 3; + SOME; + PUSH string ""; + UPDATE; + DUP 6; + GET 3; + GET 4; + PAIR; + DIG 4; + DUP; + CAR; + CDR; + SWAP; + DUP; + DUG 6; + CAR; + CAR; + PAIR; + PAIR; + TRANSFER_TOKENS; + CONS; + DUP 3; + DUP; + GET 5; + DIG 3; + GET 4; + SENDER; + PAIR; + SOME; + DIG 4; + GET 3; + GET 4; + UPDATE; + UPDATE 5; + UNPAIR; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + PUSH nat 1; + ADD; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + SWAP; + PAIR; + SWAP; + }; + } + { + IF_LEFT + { + DUP; + CAR; + CDR; + PUSH nat 0; + COMPARE; + LT; + IF + {} + { + PUSH string "WrongCondition: params.objkt_amount > 0"; + FAILWITH; + }; + NIL operation; + DUP 3; + GET 3; + GET 3; + CONTRACT %transfer (list (pair address (list (pair address (pair nat nat))))); + IF_SOME + {} + { + PUSH int 399; + FAILWITH; + }; + PUSH mutez 0; + NIL (pair address (list (pair address (pair nat nat)))); + NIL (pair address (pair nat nat)); + DIG 5; + DUP; + CAR; + CDR; + SWAP; + DUP; + DUG 7; + GET 3; + SELF_ADDRESS; + PAIR 3; + CONS; + SENDER; + PAIR; + CONS; + TRANSFER_TOKENS; + CONS; + DUP 3; + DUP; + GET 8; + DIG 3; + DUP; + GET 4; + SWAP; + DUP; + DUG 5; + GET 3; + PAIR; + DIG 4; + CAR; + CDR; + SENDER; + PAIR; + PAIR; + SOME; + DIG 4; + GET 7; + UPDATE; + UPDATE 8; + DUP; + GET 7; + PUSH nat 1; + ADD; + UPDATE 7; + SWAP; + } + { + SWAP; + DUP; + DUG 2; + CAR; + GET 6; + SENDER; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: sp.sender == self.data.manager"; + FAILWITH; + }; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + SWAP; + CAR; + DIG 4; + SWAP; + PAIR; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + NIL operation; + }; + }; + }; + NIL operation; + SWAP; + ITER + { + CONS; + }; + PAIR; + }; \ No newline at end of file diff --git a/scs/subjkts.tz b/scs/subjkts.tz new file mode 100644 index 0000000..8c0539f --- /dev/null +++ b/scs/subjkts.tz @@ -0,0 +1,355 @@ +parameter (or (or (pair %ban (address %address) (bytes %invoice)) (pair %registry (bytes %metadata) (bytes %subjkt))) (or (unit %unregistry) (address %update_manager))); +storage (pair (pair (big_map %entries address bool) (pair (big_map %invoices address (pair (bytes %invoice) (bytes %subjkt))) (address %manager))) (pair (pair (big_map %metadata string bytes) (big_map %registries address bytes)) (pair (big_map %subjkts bytes bool) (big_map %subjkts_metadata bytes bytes)))); +code + { + UNPAIR; + IF_LEFT + { + IF_LEFT + { + SWAP; + DUP; + DUG 2; + CAR; + GET 4; + SENDER; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: sp.sender == self.data.manager"; + FAILWITH; + }; + SWAP; + DUP; + DUG 2; + UNPAIR; + UNPAIR; + SWAP; + UNPAIR; + DIG 5; + GET 3; + CDR; + DUP 6; + CAR; + GET; + IF_SOME + {} + { + PUSH int 89; + FAILWITH; + }; + DUP 6; + CDR; + PAIR; + SOME; + DUP 6; + CAR; + UPDATE; + PAIR; + SWAP; + NONE bool; + DUP 5; + CAR; + UPDATE; + PAIR; + PAIR; + DUP; + DUG 2; + DUP; + GET 5; + NONE bool; + DIG 4; + GET 3; + CDR; + DUP 5; + CAR; + GET; + IF_SOME + {} + { + PUSH int 94; + FAILWITH; + }; + UPDATE; + UPDATE 5; + DUP; + DUG 2; + DUP; + GET 6; + NONE bytes; + DIG 4; + GET 3; + CDR; + DUP 5; + CAR; + GET; + IF_SOME + {} + { + PUSH int 95; + FAILWITH; + }; + UPDATE; + UPDATE 6; + UNPAIR; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + NONE bytes; + DIG 5; + CAR; + UPDATE; + SWAP; + PAIR; + PAIR; + SWAP; + PAIR; + } + { + SWAP; + DUP; + DUG 2; + GET 5; + SWAP; + DUP; + DUG 2; + CDR; + GET; + IF_SOME + {} + { + PUSH bool False; + }; + IF + { + DUP; + CDR; + DUP 3; + GET 3; + CDR; + SENDER; + GET; + IF_SOME + {} + { + PUSH int 71; + FAILWITH; + }; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: self.data.registries[sp.sender] == params.subjkt"; + FAILWITH; + }; + } + {}; + SWAP; + DUP; + DUG 2; + CAR; + CAR; + SENDER; + GET; + IF_SOME + {} + { + PUSH bool False; + }; + IF + { + SWAP; + UNPAIR; + UNPAIR; + NONE bool; + SENDER; + UPDATE; + PAIR; + PAIR; + DUP; + DUG 2; + DUP; + GET 5; + NONE bool; + DIG 4; + GET 3; + CDR; + SENDER; + GET; + IF_SOME + {} + { + PUSH int 94; + FAILWITH; + }; + UPDATE; + UPDATE 5; + DUP; + DUG 2; + DUP; + GET 6; + NONE bytes; + DIG 4; + GET 3; + CDR; + SENDER; + GET; + IF_SOME + {} + { + PUSH int 95; + FAILWITH; + }; + UPDATE; + UPDATE 6; + UNPAIR; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + NONE bytes; + SENDER; + UPDATE; + SWAP; + PAIR; + PAIR; + SWAP; + PAIR; + SWAP; + } + {}; + SWAP; + UNPAIR; + UNPAIR; + PUSH (option bool) (Some True); + SENDER; + UPDATE; + PAIR; + PAIR; + DUP; + GET 5; + PUSH (option bool) (Some True); + DUP 4; + CDR; + UPDATE; + UPDATE 5; + DUP; + GET 6; + DUP 3; + CAR; + SOME; + DUP 4; + CDR; + UPDATE; + UPDATE 6; + UNPAIR; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + DIG 4; + CDR; + SOME; + SENDER; + UPDATE; + SWAP; + PAIR; + PAIR; + SWAP; + PAIR; + }; + } + { + IF_LEFT + { + DROP; + UNPAIR; + UNPAIR; + NONE bool; + SENDER; + UPDATE; + PAIR; + PAIR; + DUP; + DUP; + GET 5; + NONE bool; + DIG 3; + GET 3; + CDR; + SENDER; + GET; + IF_SOME + {} + { + PUSH int 94; + FAILWITH; + }; + UPDATE; + UPDATE 5; + DUP; + DUP; + GET 6; + NONE bytes; + DIG 3; + GET 3; + CDR; + SENDER; + GET; + IF_SOME + {} + { + PUSH int 95; + FAILWITH; + }; + UPDATE; + UPDATE 6; + UNPAIR; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + NONE bytes; + SENDER; + UPDATE; + SWAP; + PAIR; + PAIR; + SWAP; + PAIR; + } + { + SWAP; + DUP; + DUG 2; + CAR; + GET 4; + SENDER; + COMPARE; + EQ; + IF + {} + { + PUSH string "WrongCondition: sp.sender == self.data.manager"; + FAILWITH; + }; + SWAP; + UNPAIR; + UNPAIR; + SWAP; + CAR; + DIG 3; + SWAP; + PAIR; + SWAP; + PAIR; + PAIR; + }; + }; + NIL operation; + PAIR; + }; \ No newline at end of file diff --git a/scs/unregistry.tz b/scs/unregistry.tz new file mode 100644 index 0000000..a77ad12 --- /dev/null +++ b/scs/unregistry.tz @@ -0,0 +1,27 @@ +parameter (or (unit %revert) (unit %sign)); +storage (pair (big_map %metadata string bytes) (big_map %signatures address bool)); +code + { + UNPAIR; + IF_LEFT + { + DROP; + DUP; + CDR; + NONE bool; + SENDER; + UPDATE; + UPDATE 2; + } + { + DROP; + DUP; + CDR; + PUSH (option bool) (Some True); + SENDER; + UPDATE; + UPDATE 2; + }; + NIL operation; + PAIR; + }; \ No newline at end of file