-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpartial.clsp
More file actions
55 lines (53 loc) · 2.71 KB
/
partial.clsp
File metadata and controls
55 lines (53 loc) · 2.71 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
(mod (
MOD_HASH ; self puzzle hash
FEE_PH ; puzzle hash that will receive the fee (XCH puzzle hash)
FEE_RATE ; fee rate (0-10000), e.g., 1% is represented as 100
MAKER_PH ; maker puzzle hash (XCH puzzle hash used in both receive and clawback)
CLAWBACK_MOD ; clawback puzzle
OFFER_TAIL_HASH ; offer CAT tail hash (0 if XCH)
OFFER_MOJOS ; amount of initial offer in mojos
REQUEST_TAIL_HASH ; request CAT tail hash (0 if XCH)
REQUEST_MOJOS ; amount of initial request in mojos
REQUEST_SETTLEMENT_HASH ; settlement puzzle hash of the request coin
my_amount ; amount of partial offer coin
my_id ; coin id of the partial offer coin
my_puzzle_hash ; puzzle hash of the partial offer coin
taken_mojos_or_clawback ; amount of mojos taken, or 0 if clawback
. clawback_solution ; optional clawback mod solution
)
(include *standard-cl-23*)
(include "fns.clsp")
(if (> taken_mojos_or_clawback 0)
(let
(
(new_partial_coin_amount (- my_amount taken_mojos_or_clawback))
(request_mojos (calculate-request-mojos
OFFER_MOJOS REQUEST_MOJOS
taken_mojos_or_clawback
)
)
(fee_mojos (calculate-fee-mojos FEE_RATE taken_mojos_or_clawback))
)
(c
(list ASSERT_MY_AMOUNT my_amount)
(c
; if new_partial_coin_amount is greater than 0, create a new partial coin
(if (> new_partial_coin_amount 0)
; changed by CAT wrapper
(list CREATE_COIN my_puzzle_hash new_partial_coin_amount (list my_puzzle_hash))
(list REMARK)
)
; partial coin settlement conditions
(list
(list ASSERT_MY_COIN_ID my_id)
(assert-my-puzzle-hash OFFER_TAIL_HASH my_puzzle_hash)
(assert-taker-announcement MAKER_PH REQUEST_SETTLEMENT_HASH my_id request_mojos)
(create-settlement-coin (- taken_mojos_or_clawback fee_mojos))
(list CREATE_COIN FEE_PH fee_mojos (list FEE_PH))
)
)
)
)
(a CLAWBACK_MOD clawback_solution)
)
)