FactoryFA12

Code

quipuswap-core/FactoryFA12.ligo at master · madfish-solutions/quipuswap-core
GitHub

State-Changing Functions

setDexFunction(func, index)

1
(pair %setDexFunction
2
(lambda %func
3
(pair
4
(pair
5
(or
6
(or
7
(or
8
(pair %divestLiquidity
9
(pair (nat %min_tez) (nat %min_tokens))
10
(nat %shares))
11
(nat %initializeExchange))
12
(or (nat %investLiquidity)
13
(pair %tezToTokenPayment (nat %min_out)
14
(address %receiver))))
15
(or
16
(or
17
(pair %tokenToTezPayment
18
(pair (nat %amount) (nat %min_out))
19
(address %receiver))
20
(pair %veto (nat %value) (address %voter)))
21
(or
22
(pair %vote (pair (key_hash %candidate) (nat %value))
23
(address %voter))
24
(address %withdrawProfit))))
25
(pair
26
(pair
27
(pair
28
(pair
29
(pair (address %baker_validator)
30
(option %current_candidate key_hash))
31
(pair (option %current_delegated key_hash)
32
(timestamp %last_update_time)))
33
(pair
34
(pair (timestamp %last_veto)
35
(big_map %ledger address
36
(pair
37
(pair
38
(map %allowances address nat)
39
(nat %balance))
40
(nat %frozen_balance))))
41
(pair (timestamp %period_finish) (nat %reward))))
42
(pair
43
(pair (pair (nat %reward_paid) (nat %reward_per_sec))
44
(pair (nat %reward_per_share) (nat %tez_pool)))
45
(pair (pair (address %token_address) (nat %token_pool))
46
(pair (nat %total_reward) (nat %total_supply)))))
47
(pair
48
(pair
49
(pair (nat %total_votes)
50
(big_map %user_rewards address
51
(pair (nat %reward)
52
(nat %reward_paid))))
53
(pair (nat %veto) (big_map %vetos key_hash timestamp)))
54
(pair
55
(big_map %voters address
56
(pair
57
(pair (option %candidate key_hash)
58
(timestamp %last_veto))
59
(pair (nat %veto) (nat %vote))))
60
(big_map %votes key_hash nat)))))
61
address)
62
(pair (list operation)
63
(pair
64
(pair
65
(pair
66
(pair
67
(pair (address %baker_validator)
68
(option %current_candidate key_hash))
69
(pair (option %current_delegated key_hash)
70
(timestamp %last_update_time)))
71
(pair
72
(pair (timestamp %last_veto)
73
(big_map %ledger address
74
(pair
75
(pair
76
(map %allowances address
77
nat)
78
(nat %balance))
79
(nat %frozen_balance))))
80
(pair (timestamp %period_finish) (nat %reward))))
81
(pair
82
(pair (pair (nat %reward_paid) (nat %reward_per_sec))
83
(pair (nat %reward_per_share) (nat %tez_pool)))
84
(pair (pair (address %token_address) (nat %token_pool))
85
(pair (nat %total_reward) (nat %total_supply)))))
86
(pair
87
(pair
88
(pair (nat %total_votes)
89
(big_map %user_rewards address
90
(pair (nat %reward)
91
(nat %reward_paid))))
92
(pair (nat %veto) (big_map %vetos key_hash timestamp)))
93
(pair
94
(big_map %voters address
95
(pair
96
(pair (option %candidate key_hash)
97
(timestamp %last_veto))
98
(pair (nat %veto) (nat %vote))))
99
(big_map %votes key_hash nat))))))
100
(nat %index))
Copied!
Sets the Dex specific function. Should be used before the whole system is launched. Fails if the function was set before or the index exceeds the number of Dex functions minus one(8).
Parameter
Type
Description
index
nat
The key in functions map
func
lambda
Function code
Each index is designed for a specific func:
1
%initializeExchange -> 0n
2
%tezToTokenPayment -> 1n
3
%iokenToTezPayment -> 2n
4
%withdrawProfit -> 3n
5
%investLiquidity -> 4n
6
%divestLiquidity -> 5n
7
%vote -> 6n
8
%veto -> 7n
Copied!

setTokenFunction(func, index)

1
(pair %setTokenFunction
2
(lambda %func
3
(pair
4
(pair
5
(or
6
(or
7
(or (pair %iApprove (address %spender) (nat %value))
8
(pair %iGetAllowance
9
(pair (address %owner) (address %spender))
10
(contract nat)))
11
(or (pair %iGetBalance (address %owner) (contract nat))
12
(pair %iGetTotalSupply unit (contract nat))))
13
(pair %iTransfer (address %from) (pair (address %to) (nat %value))))
14
(pair
15
(pair
16
(pair
17
(pair
18
(pair (address %baker_validator)
19
(option %current_candidate key_hash))
20
(pair (option %current_delegated key_hash)
21
(timestamp %last_update_time)))
22
(pair
23
(pair (timestamp %last_veto)
24
(big_map %ledger address
25
(pair
26
(pair (map %allowances address nat)
27
(nat %balance))
28
(nat %frozen_balance))))
29
(pair (timestamp %period_finish) (nat %reward))))
30
(pair
31
(pair (pair (nat %reward_paid) (nat %reward_per_sec))
32
(pair (nat %reward_per_share) (nat %tez_pool)))
33
(pair (pair (address %token_address) (nat %token_pool))
34
(pair (nat %total_reward) (nat %total_supply)))))
35
(pair
36
(pair
37
(pair (nat %total_votes)
38
(big_map %user_rewards address
39
(pair (nat %reward)
40
(nat %reward_paid))))
41
(pair (nat %veto) (big_map %vetos key_hash timestamp)))
42
(pair
43
(big_map %voters address
44
(pair
45
(pair (option %candidate key_hash)
46
(timestamp %last_veto))
47
(pair (nat %veto) (nat %vote))))
48
(big_map %votes key_hash nat)))))
49
address)
50
(pair (list operation)
51
(pair
52
(pair
53
(pair
54
(pair
55
(pair (address %baker_validator)
56
(option %current_candidate key_hash))
57
(pair (option %current_delegated key_hash)
58
(timestamp %last_update_time)))
59
(pair
60
(pair (timestamp %last_veto)
61
(big_map %ledger address
62
(pair
63
(pair
64
(map %allowances address nat)
65
(nat %balance))
66
(nat %frozen_balance))))
67
(pair (timestamp %period_finish) (nat %reward))))
68
(pair
69
(pair (pair (nat %reward_paid) (nat %reward_per_sec))
70
(pair (nat %reward_per_share) (nat %tez_pool)))
71
(pair (pair (address %token_address) (nat %token_pool))
72
(pair (nat %total_reward) (nat %total_supply)))))
73
(pair
74
(pair
75
(pair (nat %total_votes)
76
(big_map %user_rewards address
77
(pair (nat %reward)
78
(nat %reward_paid))))
79
(pair (nat %veto) (big_map %vetos key_hash timestamp)))
80
(pair
81
(big_map %voters address
82
(pair
83
(pair (option %candidate key_hash)
84
(timestamp %last_veto))
85
(pair (nat %veto) (nat %vote))))
86
(big_map %votes key_hash nat))))))
87
(nat %index))
Copied!
Sets the FA1.2 function. Should be used before the whole system is launched. Fails if the function was set before or the index exceeds the number of Dex functions minus one(4).
Parameter
Type
Description
index
nat
The key in functions map
func
lambda
Function code
Each index is designed for a specific func which functionality in described in TZIP-7:
1
%transfer -> 0n
2
%approve -> 1n
3
%getBalance -> 2n
4
%getAllowance -> 3n
5
%getTotalSupply -> 4n
Copied!

launchExchange

1
(pair %launchExchange (address %token) (nat %token_amount))
Copied!
Deploys a new empty Dex for token, stores the address of the new contract, and puts initial liquidity; has to be called with XTZ amount that will be used as initial liquidity. The token_amount of token should be allowed to be spent by Factory. Initial liquidity can't be zero.
Parameter
Type
Description
token
address
Address of the paired token
token_amount
nat
Amount of tokens that will be withdrawn from the user account and used as initial liquidity.
tez_amount
tez
Attached XTZ for initial liquidity should be sent along with the launch transaction.

Interface

1
parameter (or
2
(or (pair %launchExchange (address %token) (nat %token_amount))
3
(pair %setDexFunction
4
(lambda %func
5
(pair
6
(pair
7
(or
8
(or
9
(or
10
(pair %divestLiquidity
11
(pair (nat %min_tez) (nat %min_tokens))
12
(nat %shares))
13
(nat %initializeExchange))
14
(or (nat %investLiquidity)
15
(pair %tezToTokenPayment (nat %min_out)
16
(address %receiver))))
17
(or
18
(or
19
(pair %tokenToTezPayment
20
(pair (nat %amount) (nat %min_out))
21
(address %receiver))
22
(pair %veto (nat %value) (address %voter)))
23
(or
24
(pair %vote (pair (key_hash %candidate) (nat %value))
25
(address %voter))
26
(address %withdrawProfit))))
27
(pair
28
(pair
29
(pair
30
(pair
31
(pair (address %baker_validator)
32
(option %current_candidate key_hash))
33
(pair (option %current_delegated key_hash)
34
(timestamp %last_update_time)))
35
(pair
36
(pair (timestamp %last_veto)
37
(big_map %ledger address
38
(pair
39
(pair
40
(map %allowances address nat)
41
(nat %balance))
42
(nat %frozen_balance))))
43
(pair (timestamp %period_finish) (nat %reward))))
44
(pair
45
(pair (pair (nat %reward_paid) (nat %reward_per_sec))
46
(pair (nat %reward_per_share) (nat %tez_pool)))
47
(pair (pair (address %token_address) (nat %token_pool))
48
(pair (nat %total_reward) (nat %total_supply)))))
49
(pair
50
(pair
51
(pair (nat %total_votes)
52
(big_map %user_rewards address
53
(pair (nat %reward)
54
(nat %reward_paid))))
55
(pair (nat %veto) (big_map %vetos key_hash timestamp)))
56
(pair
57
(big_map %voters address
58
(pair
59
(pair (option %candidate key_hash)
60
(timestamp %last_veto))
61
(pair (nat %veto) (nat %vote))))
62
(big_map %votes key_hash nat)))))
63
address)
64
(pair (list operation)
65
(pair
66
(pair
67
(pair
68
(pair
69
(pair (address %baker_validator)
70
(option %current_candidate key_hash))
71
(pair (option %current_delegated key_hash)
72
(timestamp %last_update_time)))
73
(pair
74
(pair (timestamp %last_veto)
75
(big_map %ledger address
76
(pair
77
(pair
78
(map %allowances address
79
nat)
80
(nat %balance))
81
(nat %frozen_balance))))
82
(pair (timestamp %period_finish) (nat %reward))))
83
(pair
84
(pair (pair (nat %reward_paid) (nat %reward_per_sec))
85
(pair (nat %reward_per_share) (nat %tez_pool)))
86
(pair (pair (address %token_address) (nat %token_pool))
87
(pair (nat %total_reward) (nat %total_supply)))))
88
(pair
89
(pair
90
(pair (nat %total_votes)
91
(big_map %user_rewards address
92
(pair (nat %reward)
93
(nat %reward_paid))))
94
(pair (nat %veto) (big_map %vetos key_hash timestamp)))
95
(pair
96
(big_map %voters address
97
(pair
98
(pair (option %candidate key_hash)
99
(timestamp %last_veto))
100
(pair (nat %veto) (nat %vote))))
101
(big_map %votes key_hash nat))))))
102
(nat %index)))
103
(pair %setTokenFunction
104
(lambda %func
105
(pair
106
(pair
107
(or
108
(or
109
(or (pair %iApprove (address %spender) (nat %value))
110
(pair %iGetAllowance
111
(pair (address %owner) (address %spender))
112
(contract nat)))
113
(or (pair %iGetBalance (address %owner) (contract nat))
114
(pair %iGetTotalSupply unit (contract nat))))
115
(pair %iTransfer (address %from) (pair (address %to) (nat %value))))
116
(pair
117
(pair
118
(pair
119
(pair
120
(pair (address %baker_validator)
121
(option %current_candidate key_hash))
122
(pair (option %current_delegated key_hash)
123
(timestamp %last_update_time)))
124
(pair
125
(pair (timestamp %last_veto)
126
(big_map %ledger address
127
(pair
128
(pair (map %allowances address nat)
129
(nat %balance))
130
(nat %frozen_balance))))
131
(pair (timestamp %period_finish) (nat %reward))))
132
(pair
133
(pair (pair (nat %reward_paid) (nat %reward_per_sec))
134
(pair (nat %reward_per_share) (nat %tez_pool)))
135
(pair (pair (address %token_address) (nat %token_pool))
136
(pair (nat %total_reward) (nat %total_supply)))))
137
(pair
138
(pair
139
(pair (nat %total_votes)
140
(big_map %user_rewards address
141
(pair (nat %reward)
142
(nat %reward_paid))))
143
(pair (nat %veto) (big_map %vetos key_hash timestamp)))
144
(pair
145
(big_map %voters address
146
(pair
147
(pair (option %candidate key_hash)
148
(timestamp %last_veto))
149
(pair (nat %veto) (nat %vote))))
150
(big_map %votes key_hash nat)))))
151
address)
152
(pair (list operation)
153
(pair
154
(pair
155
(pair
156
(pair
157
(pair (address %baker_validator)
158
(option %current_candidate key_hash))
159
(pair (option %current_delegated key_hash)
160
(timestamp %last_update_time)))
161
(pair
162
(pair (timestamp %last_veto)
163
(big_map %ledger address
164
(pair
165
(pair
166
(map %allowances address nat)
167
(nat %balance))
168
(nat %frozen_balance))))
169
(pair (timestamp %period_finish) (nat %reward))))
170
(pair
171
(pair (pair (nat %reward_paid) (nat %reward_per_sec))
172
(pair (nat %reward_per_share) (nat %tez_pool)))
173
(pair (pair (address %token_address) (nat %token_pool))
174
(pair (nat %total_reward) (nat %total_supply)))))
175
(pair
176
(pair
177
(pair (nat %total_votes)
178
(big_map %user_rewards address
179
(pair (nat %reward)
180
(nat %reward_paid))))
181
(pair (nat %veto) (big_map %vetos key_hash timestamp)))
182
(pair
183
(big_map %voters address
184
(pair
185
(pair (option %candidate key_hash)
186
(timestamp %last_veto))
187
(pair (nat %veto) (nat %vote))))
188
(big_map %votes key_hash nat))))))
189
(nat %index)));
Copied!
Last modified 6mo ago