-
Notifications
You must be signed in to change notification settings - Fork 9
/
new-nomination-pool.fif
79 lines (59 loc) · 2.4 KB
/
new-nomination-pool.fif
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"Asm.fif" include
"TonUtil.fif" include
"GetOpt.fif" include
{ show-options-help 1 halt } : usage
begin-options
"<validator-wallet-address> <validator-fee> <validator-cover> [<pool-asm-file>] [<savefile>]" +cr +tab
+"Creates a query to deploy nominator pool authorized for validator requests from <validator-wallet-address>" +cr +tab
+"<validator-fee> from 0 to 1 controls how much rewards validator retains for itself" +cr +tab
+"<validator-cover> from 0 to 1 controls required share of maximal fine coverable by validator balance" +cr +tab
+"code is assembled from <pool-asm-file> ('nominator-pool-code.fif' by default)" +cr +tab
+"and saves it into <savefile>-query.boc ('new-pool-query.boc' by default)" +cr +tab
+"The address file will be saved into <savefile>.addr ('new-pool.addr' by default)"
disable-digit-options generic-help-setopt
"h" "--help" { usage } short-long-option
"Shows a help message" option-help
parse-options
$# dup 3 < swap 5 > or ' usage if
5 :$1..n
$1 true parse-load-address drop 2=: dest_addr
$2 (number) dup 0= abort"<validator-fee> must be a real number 0..1"
1 = { 16 << } { 16 <</r } cond
dup 0 < over 65536 > or abort"<validator-fee> must be a real number 0..1"
=: validator_fee
$3 (number) dup 0= abort"<validator-cover> must be a real number 0..1"
1 = { 16 << } { 16 <</r } cond
dup 0 < over 65536 > or abort"<validator-cover> must be a real number 0..1"
=: validator_cover
$4 "nominator-pool-code.fif" replace-if-null =: codefile
$5 "new-pool" replace-if-null =: savefile
now =: nonce
<{
SETCP0 ACCEPT
nonce INT
codefile include PUSHREF SETCODE
}>s =: contract_code
<b dest_addr Addr,
0 Gram,
0 Gram,
0 56 i,
0 56 i,
validator_fee 16 u,
validator_cover 16 u,
dictnew dict,
dictnew dict,
dictnew dict,
b> =: contract_storage
-1 =: wc
<b b{00110} s, <b contract_code s, b> ref, contract_storage ref, b>
dup =: state_init
dup hashu wc swap 2constant contract_addr
."Contract address = " contract_addr .addr cr
contract_addr savefile +".addr" save-address-verbose
."Non-bounceable address (for init): " contract_addr 7 .Addr cr
."Bounceable address (for later access): " contract_addr 6 .Addr cr
<b b> <s =: init_message
<b b{1000100} s, contract_addr addr, b{000010} s, state_init <s s, b{0} s, init_message s, b>
2 boc+>B
savefile +"-query.boc" tuck B>file
."(Saved nominator pool contract creating query to file " type .")" cr