-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfns.clsp
More file actions
58 lines (51 loc) · 1.96 KB
/
fns.clsp
File metadata and controls
58 lines (51 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(
(include *standard-cl-23*)
(include condition_codes.clib)
(include curry.clib)
(include sha256tree.clib)
(defconstant CAT_MOD_HASH 0x37bef360ee858133b69d595a906dc45d01af50379dad515eb9518abb7c1d2a7a)
(defconstant OFFER_MOD_HASH 0xcfbfdeed5c4ca2de3d0bf520b9cb4bb7743a359bd2e6a188d19ce7dffc21d3e7)
(defun calculate-request-mojos (OFFER_MOJOS REQUEST_MOJOS taken_mojos)
(/ (* REQUEST_MOJOS taken_mojos) OFFER_MOJOS)
)
(defun calculate-fee-mojos (FEE_RATE taken_mojos)
(/ (* FEE_RATE taken_mojos) 10000)
)
; if the XCH is offerred, assert the input puzzle hash (partial puzzle hash)
; if the CAT is offerred, assert the wrapped CAT puzzle hash
(defun assert-my-puzzle-hash (OFFER_TAIL_HASH my_puzzle_hash)
(let (
(xch_or_cat_puzzle_hash
(if OFFER_TAIL_HASH
(curry_hashes CAT_MOD_HASH
(sha256 1 CAT_MOD_HASH)
(sha256 1 OFFER_TAIL_HASH)
my_puzzle_hash
)
my_puzzle_hash
)
)
)
(list ASSERT_MY_PUZZLEHASH xch_or_cat_puzzle_hash)
)
)
; assert the payment announcement from taker settlement
(defun assert-taker-announcement (MAKER_PH REQUEST_SETTLEMENT_HASH my_id request_mojos)
(let (
(msg
(sha256tree
(list
my_id ; use coin_id as nonce
(list MAKER_PH request_mojos (list MAKER_PH))
)
)
)
)
(list ASSERT_PUZZLE_ANNOUNCEMENT (sha256 REQUEST_SETTLEMENT_HASH msg))
)
)
(defun create-settlement-coin (amount)
; changed by CAT wrapper if it's CAT
(list CREATE_COIN OFFER_MOD_HASH amount (list OFFER_MOD_HASH))
)
)