1 | 1 | | {-# STDLIB_VERSION 6 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let contractFilename = "user_pools.ride" |
---|
5 | 5 | | |
---|
6 | 6 | | let SEP = "__" |
---|
7 | 7 | | |
---|
8 | 8 | | let wavesAssetId = "WAVES" |
---|
9 | 9 | | |
---|
10 | 10 | | let VLTPOOL = "VLTPOOL" |
---|
11 | 11 | | |
---|
12 | 12 | | let STBLPOOL = "STBLPOOL" |
---|
13 | 13 | | |
---|
14 | 14 | | let invalidPriceAsset = "Invalid price asset" |
---|
15 | 15 | | |
---|
16 | 16 | | func wrapErr (msg) = makeString([contractFilename, ": ", msg], "") |
---|
17 | 17 | | |
---|
18 | 18 | | |
---|
19 | 19 | | func throwErr (msg) = throw(wrapErr(msg)) |
---|
20 | 20 | | |
---|
21 | 21 | | |
---|
22 | 22 | | func throwPD () = throwErr("Permission denied") |
---|
23 | 23 | | |
---|
24 | 24 | | |
---|
25 | 25 | | func throwCreateNotCalled () = throwErr("Create is not called for assets pair") |
---|
26 | 26 | | |
---|
27 | 27 | | |
---|
28 | 28 | | func throwYouNotIssuer () = throwErr("You are not amountAsset issuer") |
---|
29 | 29 | | |
---|
30 | 30 | | |
---|
31 | 31 | | func throwPoolExists () = throwErr("Pool with such assets already exists") |
---|
32 | 32 | | |
---|
33 | 33 | | |
---|
34 | 34 | | func throwAssetNotVerified () = throwErr("Asset is not verified") |
---|
35 | 35 | | |
---|
36 | 36 | | |
---|
37 | 37 | | func throwInvalidPriceAsset () = throwErr(invalidPriceAsset) |
---|
38 | 38 | | |
---|
39 | 39 | | |
---|
40 | 40 | | func throwInvalidFeeAsset () = throwErr("Invalid fee asset") |
---|
41 | 41 | | |
---|
42 | 42 | | |
---|
43 | 43 | | func throwInvalidAmountAsset () = throwErr("Invalid amount asset attached") |
---|
44 | 44 | | |
---|
45 | 45 | | |
---|
46 | 46 | | func throwInvalidStatus () = throwErr("Invalid status") |
---|
47 | 47 | | |
---|
48 | 48 | | |
---|
49 | 49 | | func throwCanActivateOnlyPendingPool () = throwErr("Can activate pool only in 'pending' status") |
---|
50 | 50 | | |
---|
51 | 51 | | |
---|
52 | 52 | | func throwFactoryReturnedNotString () = throwErr("FactoryV2 returned not string") |
---|
53 | 53 | | |
---|
54 | 54 | | |
---|
55 | 55 | | func throwInvalidPriceAssetAmount () = throwErr("invalid price asset amount") |
---|
56 | 56 | | |
---|
57 | 57 | | |
---|
58 | 58 | | func throwInvalidFee () = throwErr("invalid fee") |
---|
59 | 59 | | |
---|
60 | 60 | | |
---|
61 | 61 | | func throwInvalidAssetPair () = throwErr("invalid asset pair") |
---|
62 | 62 | | |
---|
63 | 63 | | |
---|
64 | 64 | | func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) |
---|
65 | 65 | | |
---|
66 | 66 | | |
---|
67 | 67 | | func keyManagerVaultAddress () = "%s__managerVaultAddress" |
---|
68 | 68 | | |
---|
69 | 69 | | |
---|
70 | 70 | | func keyAdminPubKeys () = makeString(["%s", "adminPubKeys"], SEP) |
---|
71 | 71 | | |
---|
72 | 72 | | |
---|
73 | 73 | | func keyStatus (amountAssetId,priceAssetId) = makeString(["%s%s%s", "status", amountAssetId, priceAssetId], SEP) |
---|
74 | 74 | | |
---|
75 | 75 | | |
---|
76 | 76 | | func keyFactoryContract () = makeString(["%s", "factoryContract"], SEP) |
---|
77 | 77 | | |
---|
78 | 78 | | |
---|
79 | 79 | | func keyAssetsStoreContract () = makeString(["%s", "assetsStoreContract"], SEP) |
---|
80 | 80 | | |
---|
81 | 81 | | |
---|
82 | 82 | | func keyEmissionContract () = makeString(["%s", "emissionContract"], SEP) |
---|
83 | 83 | | |
---|
84 | 84 | | |
---|
85 | 85 | | func keySuffix (amountAssetId,priceAssetId) = makeString(["%s%s%s", "suffix", amountAssetId, priceAssetId], SEP) |
---|
86 | 86 | | |
---|
87 | 87 | | |
---|
88 | 88 | | func keyLastIndex () = makeString(["%s", "lastIndex"], SEP) |
---|
89 | 89 | | |
---|
90 | 90 | | |
---|
91 | 91 | | let indexSuffix = "u" |
---|
92 | 92 | | |
---|
93 | 93 | | let statusPending = "pending" |
---|
94 | 94 | | |
---|
95 | 95 | | let statusDeclined = "declined" |
---|
96 | 96 | | |
---|
97 | 97 | | let statusActive = "active" |
---|
98 | 98 | | |
---|
99 | 99 | | let statuses = [statusPending, statusDeclined, statusActive] |
---|
100 | 100 | | |
---|
101 | 101 | | func keyCreateCalled (amountAssetId,priceAssetId) = makeString(["%s%s%s", "createCalled", amountAssetId, priceAssetId], SEP) |
---|
102 | 102 | | |
---|
103 | 103 | | |
---|
104 | 104 | | func keyCreateCaller (amountAssetId,priceAssetId) = makeString(["%s%s%s", "createCaller", amountAssetId, priceAssetId], SEP) |
---|
105 | 105 | | |
---|
106 | 106 | | |
---|
107 | 107 | | func keyAmountAssetAmount (amountAssetId,priceAssetId) = makeString(["%s%s%s", "amountAssetAmount", amountAssetId, priceAssetId], SEP) |
---|
108 | 108 | | |
---|
109 | 109 | | |
---|
110 | 110 | | func keyPriceAssetAmount (amountAssetId,priceAssetId) = makeString(["%s%s%s", "priceAssetAmount", amountAssetId, priceAssetId], SEP) |
---|
111 | 111 | | |
---|
112 | 112 | | |
---|
113 | 113 | | func keyHeight (amountAssetId,priceAssetId) = makeString(["%s%s%s", "height", amountAssetId, priceAssetId], SEP) |
---|
114 | 114 | | |
---|
115 | 115 | | |
---|
116 | 116 | | func keyPoolType (amountAssetId,priceAssetId) = makeString(["%s%s%s", "poolType", amountAssetId, priceAssetId], SEP) |
---|
117 | 117 | | |
---|
118 | 118 | | |
---|
119 | 119 | | func keyFeeAssetId () = makeString(["%s", "feeAssetId"], SEP) |
---|
120 | 120 | | |
---|
121 | 121 | | |
---|
122 | 122 | | func keyFeeAmount () = makeString(["%s", "feeAmount"], SEP) |
---|
123 | 123 | | |
---|
124 | 124 | | |
---|
125 | 125 | | func keyAmountAssetMinAmount () = makeString(["%s", "amountAssetMinAmount"], SEP) |
---|
126 | 126 | | |
---|
127 | 127 | | |
---|
128 | 128 | | func keyPriceAssetsMinAmount () = makeString(["%s", "priceAssetsMinAmount"], SEP) |
---|
129 | 129 | | |
---|
130 | 130 | | |
---|
131 | 131 | | func keyPriceAssets () = makeString(["%s", "priceAssets"], SEP) |
---|
132 | 132 | | |
---|
133 | 133 | | |
---|
134 | 134 | | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { |
---|
135 | 135 | | case s: String => |
---|
136 | 136 | | addressFromStringValue(s) |
---|
137 | 137 | | case _ => |
---|
138 | 138 | | this |
---|
139 | 139 | | } |
---|
140 | 140 | | |
---|
141 | 141 | | |
---|
142 | 142 | | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (key + " is not defined")) |
---|
143 | 143 | | |
---|
144 | 144 | | |
---|
145 | 145 | | func stringOptionToList (stringOrUnit) = match stringOrUnit { |
---|
146 | 146 | | case s: String => |
---|
147 | 147 | | if ((size(s) == 0)) |
---|
148 | 148 | | then nil |
---|
149 | 149 | | else split(s, SEP) |
---|
150 | 150 | | case _: Unit => |
---|
151 | 151 | | nil |
---|
152 | 152 | | case _ => |
---|
153 | 153 | | throw("Match error") |
---|
154 | 154 | | } |
---|
155 | 155 | | |
---|
156 | 156 | | |
---|
157 | 157 | | let factoryContract = addressFromStringValue(getStringOrFail(keyFactoryContract())) |
---|
158 | 158 | | |
---|
159 | 159 | | let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], SEP) |
---|
160 | 160 | | |
---|
161 | 161 | | let votingEmissionContract = addressFromStringValue(valueOrErrorMessage(getString(factoryContract, keyVotingEmissionContract), wrapErr("voting emission contract address is required"))) |
---|
162 | 162 | | |
---|
163 | 163 | | let keyVotingEmissionCandidateContract = makeString(["%s", "votingEmissionCandidateContract"], SEP) |
---|
164 | 164 | | |
---|
165 | 165 | | let votingEmissionCandidateContract = addressFromStringValue(valueOrErrorMessage(getString(votingEmissionContract, keyVotingEmissionCandidateContract), wrapErr("voting emission candidate contract address is required"))) |
---|
166 | 166 | | |
---|
167 | 167 | | func isCreateCalled (amountAssetId,priceAssetId) = valueOrElse(getBoolean(keyCreateCalled(amountAssetId, priceAssetId)), false) |
---|
168 | 168 | | |
---|
169 | 169 | | |
---|
170 | 170 | | func mustCreateCalled (amountAssetId,priceAssetId) = if (isCreateCalled(amountAssetId, priceAssetId)) |
---|
171 | 171 | | then true |
---|
172 | 172 | | else throwCreateNotCalled() |
---|
173 | 173 | | |
---|
174 | 174 | | |
---|
175 | 175 | | func managerPublicKeyOrUnit () = { |
---|
176 | 176 | | let managerVaultAddress = getManagerVaultAddressOrThis() |
---|
177 | 177 | | match getString(managerVaultAddress, keyManagerPublicKey()) { |
---|
178 | 178 | | case s: String => |
---|
179 | 179 | | fromBase58String(s) |
---|
180 | 180 | | case _: Unit => |
---|
181 | 181 | | unit |
---|
182 | 182 | | case _ => |
---|
183 | 183 | | throw("Match error") |
---|
184 | 184 | | } |
---|
185 | 185 | | } |
---|
186 | 186 | | |
---|
187 | 187 | | |
---|
188 | 188 | | func isManager (i) = match managerPublicKeyOrUnit() { |
---|
189 | 189 | | case pk: ByteVector => |
---|
190 | 190 | | (i.callerPublicKey == pk) |
---|
191 | 191 | | case _: Unit => |
---|
192 | 192 | | (i.caller == this) |
---|
193 | 193 | | case _ => |
---|
194 | 194 | | throw("Match error") |
---|
195 | 195 | | } |
---|
196 | 196 | | |
---|
197 | 197 | | |
---|
198 | 198 | | func mustManager (i) = if (isManager(i)) |
---|
199 | 199 | | then true |
---|
200 | 200 | | else throwPD() |
---|
201 | 201 | | |
---|
202 | 202 | | |
---|
203 | 203 | | func mustAdmin (i) = { |
---|
204 | 204 | | let adminPKs = stringOptionToList(getString(keyAdminPubKeys())) |
---|
205 | 205 | | if (containsElement(adminPKs, toBase58String(i.callerPublicKey))) |
---|
206 | 206 | | then true |
---|
207 | 207 | | else mustManager(i) |
---|
208 | 208 | | } |
---|
209 | 209 | | |
---|
210 | 210 | | |
---|
211 | 211 | | func isVerified (assetId) = (valueOrElse(getInteger(addressFromStringValue(getStringOrFail(keyAssetsStoreContract())), (("status_<" + assetId) + ">")), 0) == 2) |
---|
212 | 212 | | |
---|
213 | 213 | | |
---|
214 | 214 | | func getIdAndInfo (payment) = match payment.assetId { |
---|
215 | 215 | | case id: ByteVector => |
---|
216 | 216 | | let info = value(assetInfo(id)) |
---|
217 | 217 | | $Tuple2(toBase58String(id), info) |
---|
218 | 218 | | case _: Unit => |
---|
219 | 219 | | $Tuple2(wavesAssetId, unit) |
---|
220 | 220 | | case _ => |
---|
221 | 221 | | throw("Match error") |
---|
222 | 222 | | } |
---|
223 | 223 | | |
---|
224 | 224 | | |
---|
225 | 225 | | func validStatus (status) = containsElement(statuses, status) |
---|
226 | 226 | | |
---|
227 | 227 | | |
---|
228 | 228 | | func _create (i,poolType) = { |
---|
229 | 229 | | let amountAssetPayment = value(i.payments[0]) |
---|
230 | 230 | | let priceAssetPayment = value(i.payments[1]) |
---|
231 | 231 | | let feeAssetPayment = value(i.payments[2]) |
---|
232 | 232 | | let $t064836555 = getIdAndInfo(amountAssetPayment) |
---|
233 | 233 | | let amountAssetId = $t064836555._1 |
---|
234 | 234 | | let amountAssetInfo = $t064836555._2 |
---|
235 | 235 | | let $t065586627 = getIdAndInfo(priceAssetPayment) |
---|
236 | 236 | | let priceAssetId = $t065586627._1 |
---|
237 | 237 | | let priceAssetInfo = $t065586627._2 |
---|
238 | 238 | | let $t066306693 = getIdAndInfo(feeAssetPayment) |
---|
239 | 239 | | let feeAssetId = $t066306693._1 |
---|
240 | 240 | | let feeAssetInfo = $t066306693._2 |
---|
241 | 241 | | let amountAssetAmount = amountAssetPayment.amount |
---|
242 | 242 | | let priceAssetAmount = priceAssetPayment.amount |
---|
243 | 243 | | let feeAssetAmount = feeAssetPayment.amount |
---|
244 | 244 | | let priceAssetsList = stringOptionToList(getString(factoryContract, keyPriceAssets())) |
---|
245 | 245 | | let assetMinAmountDefault = getIntegerValue(keyAmountAssetMinAmount()) |
---|
246 | 246 | | let allowedAssetsMinAmounts = stringOptionToList(getString(keyPriceAssetsMinAmount())) |
---|
247 | 247 | | let amountAssetMinAmount = if (containsElement(priceAssetsList, amountAssetId)) |
---|
248 | 248 | | then { |
---|
249 | 249 | | let priceAssetsIndex = valueOrErrorMessage(indexOf(priceAssetsList, amountAssetId), invalidPriceAsset) |
---|
250 | 250 | | value(parseInt(allowedAssetsMinAmounts[priceAssetsIndex])) |
---|
251 | 251 | | } |
---|
252 | 252 | | else assetMinAmountDefault |
---|
253 | 253 | | let priceAssetMinAmount = if (containsElement(priceAssetsList, priceAssetId)) |
---|
254 | 254 | | then { |
---|
255 | 255 | | let priceAssetsIndex = valueOrErrorMessage(indexOf(priceAssetsList, priceAssetId), invalidPriceAsset) |
---|
256 | 256 | | value(parseInt(allowedAssetsMinAmounts[priceAssetsIndex])) |
---|
257 | 257 | | } |
---|
258 | 258 | | else assetMinAmountDefault |
---|
259 | 259 | | let lastIndex = valueOrElse(getInteger(keyLastIndex()), 0) |
---|
260 | 260 | | let curIndex = (lastIndex + 1) |
---|
261 | 261 | | let emissionContract = addressFromStringValue(getStringOrFail(keyEmissionContract())) |
---|
262 | 262 | | let poolExists = { |
---|
263 | 263 | | let @ = invoke(factoryContract, "poolExistsREADONLY", [amountAssetId, priceAssetId], nil) |
---|
264 | 264 | | if ($isInstanceOf(@, "Boolean")) |
---|
265 | 265 | | then @ |
---|
266 | 266 | | else throw(($getType(@) + " couldn't be cast to Boolean")) |
---|
267 | 267 | | } |
---|
268 | 268 | | let checks = [if (!(isCreateCalled(amountAssetId, priceAssetId))) |
---|
269 | 269 | | then true |
---|
270 | 270 | | else throwPoolExists(), if (!(poolExists)) |
---|
271 | 271 | | then true |
---|
272 | 272 | | else throwPoolExists(), if ((amountAssetId != priceAssetId)) |
---|
273 | 273 | | then true |
---|
277 | 279 | | then true |
---|
278 | 280 | | else throwInvalidAssetPair(), if (if (containsElement(priceAssetsList, amountAssetId)) |
---|
279 | 281 | | then true |
---|
280 | 282 | | else containsElement(priceAssetsList, priceAssetId)) |
---|
281 | 283 | | then true |
---|
282 | 284 | | else throwInvalidAssetPair(), if (if (isManager(i)) |
---|
283 | 285 | | then true |
---|
284 | 286 | | else (getString(keyFeeAssetId()) == feeAssetId)) |
---|
285 | 287 | | then true |
---|
286 | 288 | | else throwInvalidFeeAsset(), if (if (isManager(i)) |
---|
287 | 289 | | then true |
---|
288 | 290 | | else (amountAssetAmount >= getIntegerValue(keyAmountAssetMinAmount()))) |
---|
289 | 291 | | then true |
---|
290 | 292 | | else throwInvalidAmountAsset(), if (if (isManager(i)) |
---|
291 | 293 | | then true |
---|
292 | 294 | | else (priceAssetAmount >= priceAssetMinAmount)) |
---|
293 | 295 | | then true |
---|
294 | 296 | | else throwInvalidPriceAssetAmount(), if (if (isManager(i)) |
---|
295 | 297 | | then true |
---|
296 | 298 | | else (feeAssetAmount == getInteger(keyFeeAmount()))) |
---|
297 | 299 | | then true |
---|
298 | 300 | | else throwInvalidFee()] |
---|
299 | 301 | | if ((checks == checks)) |
---|
300 | 302 | | then { |
---|
301 | 303 | | let paymentsWithFeeSize = 3 |
---|
302 | 304 | | let burnEmissionInv = if ((size(i.payments) >= paymentsWithFeeSize)) |
---|
303 | 305 | | then invoke(emissionContract, "burn", nil, [AttachedPayment(fromBase58String(feeAssetId), feeAssetAmount)]) |
---|
304 | 306 | | else unit |
---|
305 | 307 | | if ((burnEmissionInv == burnEmissionInv)) |
---|
306 | 308 | | then [BooleanEntry(keyCreateCalled(amountAssetId, priceAssetId), true), StringEntry(keyCreateCaller(amountAssetId, priceAssetId), toString(i.caller)), IntegerEntry(keyLastIndex(), curIndex), StringEntry(keySuffix(amountAssetId, priceAssetId), (toString(curIndex) + indexSuffix)), IntegerEntry(keyHeight(amountAssetId, priceAssetId), height), StringEntry(keyStatus(amountAssetId, priceAssetId), statusPending), IntegerEntry(keyAmountAssetAmount(amountAssetId, priceAssetId), amountAssetAmount), IntegerEntry(keyPriceAssetAmount(amountAssetId, priceAssetId), priceAssetAmount), StringEntry(keyPoolType(amountAssetId, priceAssetId), poolType)] |
---|
307 | 309 | | else throw("Strict value is not equal to itself.") |
---|
308 | 310 | | } |
---|
309 | 311 | | else throw("Strict value is not equal to itself.") |
---|
310 | 312 | | } |
---|
311 | 313 | | |
---|
312 | 314 | | |
---|
313 | 315 | | @Callable(i) |
---|
314 | 316 | | func constructor (factoryV2Address,assetsStoreAddress,emissionAddress,priceAssetsMinAmount,amountAssetMinAmount,feeAssetId,feeAmount) = { |
---|
315 | 317 | | let checkCaller = mustManager(i) |
---|
316 | 318 | | if ((checkCaller == checkCaller)) |
---|
317 | 319 | | then [StringEntry(keyFactoryContract(), factoryV2Address), StringEntry(keyAssetsStoreContract(), assetsStoreAddress), StringEntry(keyEmissionContract(), emissionAddress), StringEntry(keyPriceAssetsMinAmount(), makeString(priceAssetsMinAmount, SEP)), IntegerEntry(keyAmountAssetMinAmount(), amountAssetMinAmount), StringEntry(keyFeeAssetId(), feeAssetId), IntegerEntry(keyFeeAmount(), feeAmount)] |
---|
318 | 320 | | else throw("Strict value is not equal to itself.") |
---|
319 | 321 | | } |
---|
320 | 322 | | |
---|
321 | 323 | | |
---|
322 | 324 | | |
---|
323 | 325 | | @Callable(i) |
---|
324 | 326 | | func create () = _create(i, VLTPOOL) |
---|
325 | 327 | | |
---|
326 | 328 | | |
---|
327 | 329 | | |
---|
328 | 330 | | @Callable(i) |
---|
329 | 331 | | func createStable () = { |
---|
330 | 332 | | let checkCaller = mustManager(i) |
---|
331 | 333 | | if ((checkCaller == checkCaller)) |
---|
332 | 334 | | then _create(i, STBLPOOL) |
---|
333 | 335 | | else throw("Strict value is not equal to itself.") |
---|
334 | 336 | | } |
---|
335 | 337 | | |
---|
336 | 338 | | |
---|
337 | 339 | | |
---|
338 | 340 | | @Callable(i) |
---|
339 | 341 | | func activate (poolAddress,amountAssetId,amountAssetTicker,priceAssetId,priceAssetTicker,logo) = { |
---|
340 | 342 | | let checks = [mustAdmin(i), if (isCreateCalled(amountAssetId, priceAssetId)) |
---|
341 | 343 | | then true |
---|
342 | 344 | | else throwCreateNotCalled(), if ((value(getString(keyStatus(amountAssetId, priceAssetId))) == statusPending)) |
---|
343 | 345 | | then true |
---|
344 | 346 | | else throwCanActivateOnlyPendingPool()] |
---|
345 | 347 | | if ((checks == checks)) |
---|
346 | 348 | | then { |
---|
347 | 349 | | let poolTypeOption = getString(this, keyPoolType(amountAssetId, priceAssetId)) |
---|
348 | 350 | | let activateNewPoolInv = invoke(factoryContract, "activateNewPool", [poolAddress, amountAssetId, priceAssetId, ((amountAssetTicker + priceAssetTicker) + "LP"), (((amountAssetTicker + "/") + priceAssetTicker) + " pool liquidity provider token"), 0, if ((poolTypeOption == unit)) |
---|
349 | 351 | | then "VLTPOOL" |
---|
350 | 352 | | else value(poolTypeOption), logo], nil) |
---|
351 | 353 | | if ((activateNewPoolInv == activateNewPoolInv)) |
---|
352 | 354 | | then { |
---|
353 | 355 | | let lpAssetId = match activateNewPoolInv { |
---|
354 | 356 | | case id: String => |
---|
355 | 357 | | id |
---|
356 | 358 | | case _ => |
---|
357 | 359 | | throwFactoryReturnedNotString() |
---|
358 | 360 | | } |
---|
359 | 361 | | if ((lpAssetId == lpAssetId)) |
---|
360 | 362 | | then { |
---|
361 | 363 | | let beforePut = assetBalance(this, fromBase58String(lpAssetId)) |
---|
362 | 364 | | if ((beforePut == beforePut)) |
---|
363 | 365 | | then { |
---|
364 | 366 | | let put = invoke(addressFromStringValue(poolAddress), "put", [0, false], [AttachedPayment(if ((amountAssetId == "WAVES")) |
---|
365 | 367 | | then unit |
---|
366 | 368 | | else fromBase58String(amountAssetId), value(getInteger(keyAmountAssetAmount(amountAssetId, priceAssetId)))), AttachedPayment(if ((priceAssetId == "WAVES")) |
---|
367 | 369 | | then unit |
---|
368 | 370 | | else fromBase58String(priceAssetId), value(getInteger(keyPriceAssetAmount(amountAssetId, priceAssetId))))]) |
---|
369 | 371 | | if ((put == put)) |
---|
370 | 372 | | then { |
---|
371 | 373 | | let afterPut = assetBalance(this, fromBase58String(lpAssetId)) |
---|
372 | 374 | | if ((afterPut == afterPut)) |
---|
373 | 375 | | then { |
---|
374 | 376 | | let user = value(addressFromString(value(getString(keyCreateCaller(amountAssetId, priceAssetId))))) |
---|
375 | 377 | | let res = invoke(votingEmissionCandidateContract, "approve", [amountAssetId, priceAssetId], nil) |
---|
376 | 378 | | if ((res == res)) |
---|
377 | 379 | | then [StringEntry(keyStatus(amountAssetId, priceAssetId), statusActive), ScriptTransfer(user, (afterPut - beforePut), fromBase58String(lpAssetId))] |
---|
378 | 380 | | else throw("Strict value is not equal to itself.") |
---|
379 | 381 | | } |
---|
380 | 382 | | else throw("Strict value is not equal to itself.") |
---|
381 | 383 | | } |
---|
382 | 384 | | else throw("Strict value is not equal to itself.") |
---|
383 | 385 | | } |
---|
384 | 386 | | else throw("Strict value is not equal to itself.") |
---|
385 | 387 | | } |
---|
386 | 388 | | else throw("Strict value is not equal to itself.") |
---|
387 | 389 | | } |
---|
388 | 390 | | else throw("Strict value is not equal to itself.") |
---|
389 | 391 | | } |
---|
390 | 392 | | else throw("Strict value is not equal to itself.") |
---|
391 | 393 | | } |
---|
392 | 394 | | |
---|
393 | 395 | | |
---|
394 | 396 | | |
---|
395 | 397 | | @Callable(i) |
---|
396 | 398 | | func setAdmins (adminPubKeys) = { |
---|
397 | 399 | | let checkCaller = mustManager(i) |
---|
398 | 400 | | if ((checkCaller == checkCaller)) |
---|
399 | 401 | | then [StringEntry(keyAdminPubKeys(), makeString(adminPubKeys, SEP))] |
---|
400 | 402 | | else throw("Strict value is not equal to itself.") |
---|
401 | 403 | | } |
---|
402 | 404 | | |
---|
403 | 405 | | |
---|
404 | 406 | | |
---|
405 | 407 | | @Callable(i) |
---|
406 | 408 | | func priceAssetsREADONLY () = $Tuple2(nil, stringOptionToList(getString(keyPriceAssets()))) |
---|
407 | 409 | | |
---|
408 | 410 | | |
---|
409 | 411 | | |
---|
410 | 412 | | @Callable(i) |
---|
411 | 413 | | func statusREADONLY (amountAssetId,priceAssetId) = { |
---|
412 | 414 | | let status = match getString(keyStatus(amountAssetId, priceAssetId)) { |
---|
413 | 415 | | case s: String => |
---|
414 | 416 | | s |
---|
415 | 417 | | case _ => |
---|
416 | 418 | | unit |
---|
417 | 419 | | } |
---|
418 | 420 | | $Tuple2(nil, status) |
---|
419 | 421 | | } |
---|
420 | 422 | | |
---|
421 | 423 | | |
---|
422 | 424 | | @Verifier(tx) |
---|
423 | 425 | | func verify () = { |
---|
424 | 426 | | let targetPublicKey = match managerPublicKeyOrUnit() { |
---|
425 | 427 | | case pk: ByteVector => |
---|
426 | 428 | | pk |
---|
427 | 429 | | case _: Unit => |
---|
428 | 430 | | tx.senderPublicKey |
---|
429 | 431 | | case _ => |
---|
430 | 432 | | throw("Match error") |
---|
431 | 433 | | } |
---|
432 | 434 | | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) |
---|
433 | 435 | | } |
---|
434 | 436 | | |
---|