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 |
---|
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]) |
---|
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 |
---|
274 | 274 | | else throwInvalidAssetPair(), if (if (isManager(i)) |
---|
275 | 275 | | then true |
---|
276 | 276 | | else if (isVerified(amountAssetId)) |
---|
277 | 277 | | then isVerified(priceAssetId) |
---|
278 | 278 | | else false) |
---|
279 | 279 | | then true |
---|
280 | 280 | | else throwInvalidAssetPair(), if (if (containsElement(priceAssetsList, amountAssetId)) |
---|
281 | 281 | | then true |
---|
282 | 282 | | else containsElement(priceAssetsList, priceAssetId)) |
---|
283 | 283 | | then true |
---|
284 | 284 | | else throwInvalidAssetPair(), if (if (isManager(i)) |
---|
285 | 285 | | then true |
---|
286 | 286 | | else (getString(keyFeeAssetId()) == feeAssetId)) |
---|
287 | 287 | | then true |
---|
288 | 288 | | else throwInvalidFeeAsset(), if (if (isManager(i)) |
---|
289 | 289 | | then true |
---|
290 | 290 | | else (amountAssetAmount >= getIntegerValue(keyAmountAssetMinAmount()))) |
---|
291 | 291 | | then true |
---|
292 | 292 | | else throwInvalidAmountAsset(), if (if (isManager(i)) |
---|
293 | 293 | | then true |
---|
294 | 294 | | else (priceAssetAmount >= priceAssetMinAmount)) |
---|
295 | 295 | | then true |
---|
296 | 296 | | else throwInvalidPriceAssetAmount(), if (if (isManager(i)) |
---|
297 | 297 | | then true |
---|
298 | 298 | | else (feeAssetAmount == getInteger(keyFeeAmount()))) |
---|
299 | 299 | | then true |
---|
300 | 300 | | else throwInvalidFee()] |
---|
301 | 301 | | if ((checks == checks)) |
---|
302 | 302 | | then { |
---|
303 | 303 | | let paymentsWithFeeSize = 3 |
---|
304 | 304 | | let burnEmissionInv = if ((size(i.payments) >= paymentsWithFeeSize)) |
---|
305 | 305 | | then invoke(emissionContract, "burn", nil, [AttachedPayment(fromBase58String(feeAssetId), feeAssetAmount)]) |
---|
306 | 306 | | else unit |
---|
307 | 307 | | if ((burnEmissionInv == burnEmissionInv)) |
---|
308 | 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)] |
---|
309 | 309 | | else throw("Strict value is not equal to itself.") |
---|
310 | 310 | | } |
---|
311 | 311 | | else throw("Strict value is not equal to itself.") |
---|
312 | 312 | | } |
---|
313 | 313 | | |
---|
314 | 314 | | |
---|
315 | 315 | | @Callable(i) |
---|
316 | 316 | | func constructor (factoryV2Address,assetsStoreAddress,emissionAddress,priceAssetsMinAmount,amountAssetMinAmount,feeAssetId,feeAmount) = { |
---|
317 | 317 | | let checkCaller = mustManager(i) |
---|
318 | 318 | | if ((checkCaller == checkCaller)) |
---|
319 | 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)] |
---|
320 | 320 | | else throw("Strict value is not equal to itself.") |
---|
321 | 321 | | } |
---|
322 | 322 | | |
---|
323 | 323 | | |
---|
324 | 324 | | |
---|
325 | 325 | | @Callable(i) |
---|
326 | 326 | | func create () = _create(i, VLTPOOL) |
---|
327 | 327 | | |
---|
328 | 328 | | |
---|
329 | 329 | | |
---|
330 | 330 | | @Callable(i) |
---|
331 | 331 | | func createStable () = { |
---|
332 | 332 | | let checkCaller = mustManager(i) |
---|
333 | 333 | | if ((checkCaller == checkCaller)) |
---|
334 | 334 | | then _create(i, STBLPOOL) |
---|
335 | 335 | | else throw("Strict value is not equal to itself.") |
---|
336 | 336 | | } |
---|
337 | 337 | | |
---|
338 | 338 | | |
---|
339 | 339 | | |
---|
340 | 340 | | @Callable(i) |
---|
341 | 341 | | func activate (poolAddress,amountAssetId,amountAssetTicker,priceAssetId,priceAssetTicker,logo) = { |
---|
342 | 342 | | let checks = [mustAdmin(i), if (isCreateCalled(amountAssetId, priceAssetId)) |
---|
343 | 343 | | then true |
---|
344 | 344 | | else throwCreateNotCalled(), if ((value(getString(keyStatus(amountAssetId, priceAssetId))) == statusPending)) |
---|
345 | 345 | | then true |
---|
346 | 346 | | else throwCanActivateOnlyPendingPool()] |
---|
347 | 347 | | if ((checks == checks)) |
---|
348 | 348 | | then { |
---|
349 | 349 | | let poolTypeOption = getString(this, keyPoolType(amountAssetId, priceAssetId)) |
---|
350 | 350 | | let activateNewPoolInv = invoke(factoryContract, "activateNewPool", [poolAddress, amountAssetId, priceAssetId, ((amountAssetTicker + priceAssetTicker) + "LP"), (((amountAssetTicker + "/") + priceAssetTicker) + " pool liquidity provider token"), 0, if ((poolTypeOption == unit)) |
---|
351 | 351 | | then "VLTPOOL" |
---|
352 | 352 | | else value(poolTypeOption), logo], nil) |
---|
353 | 353 | | if ((activateNewPoolInv == activateNewPoolInv)) |
---|
354 | 354 | | then { |
---|
355 | 355 | | let lpAssetId = match activateNewPoolInv { |
---|
356 | 356 | | case id: String => |
---|
357 | 357 | | id |
---|
358 | 358 | | case _ => |
---|
359 | 359 | | throwFactoryReturnedNotString() |
---|
360 | 360 | | } |
---|
361 | 361 | | if ((lpAssetId == lpAssetId)) |
---|
362 | 362 | | then { |
---|
363 | 363 | | let beforePut = assetBalance(this, fromBase58String(lpAssetId)) |
---|
364 | 364 | | if ((beforePut == beforePut)) |
---|
365 | 365 | | then { |
---|
366 | 366 | | let put = invoke(addressFromStringValue(poolAddress), "put", [0, false], [AttachedPayment(if ((amountAssetId == "WAVES")) |
---|
367 | 367 | | then unit |
---|
368 | 368 | | else fromBase58String(amountAssetId), value(getInteger(keyAmountAssetAmount(amountAssetId, priceAssetId)))), AttachedPayment(if ((priceAssetId == "WAVES")) |
---|
369 | 369 | | then unit |
---|
370 | 370 | | else fromBase58String(priceAssetId), value(getInteger(keyPriceAssetAmount(amountAssetId, priceAssetId))))]) |
---|
371 | 371 | | if ((put == put)) |
---|
372 | 372 | | then { |
---|
373 | 373 | | let afterPut = assetBalance(this, fromBase58String(lpAssetId)) |
---|
374 | 374 | | if ((afterPut == afterPut)) |
---|
375 | 375 | | then { |
---|
376 | 376 | | let user = value(addressFromString(value(getString(keyCreateCaller(amountAssetId, priceAssetId))))) |
---|
377 | 377 | | let res = invoke(votingEmissionCandidateContract, "approve", [amountAssetId, priceAssetId], nil) |
---|
378 | 378 | | if ((res == res)) |
---|
379 | 379 | | then [StringEntry(keyStatus(amountAssetId, priceAssetId), statusActive), ScriptTransfer(user, (afterPut - beforePut), fromBase58String(lpAssetId))] |
---|
380 | 380 | | else throw("Strict value is not equal to itself.") |
---|
381 | 381 | | } |
---|
382 | 382 | | else throw("Strict value is not equal to itself.") |
---|
383 | 383 | | } |
---|
384 | 384 | | else throw("Strict value is not equal to itself.") |
---|
385 | 385 | | } |
---|
386 | 386 | | else throw("Strict value is not equal to itself.") |
---|
387 | 387 | | } |
---|
388 | 388 | | else throw("Strict value is not equal to itself.") |
---|
389 | 389 | | } |
---|
390 | 390 | | else throw("Strict value is not equal to itself.") |
---|
391 | 391 | | } |
---|
392 | 392 | | else throw("Strict value is not equal to itself.") |
---|
393 | 393 | | } |
---|
394 | 394 | | |
---|
395 | 395 | | |
---|
396 | 396 | | |
---|
397 | 397 | | @Callable(i) |
---|
398 | 398 | | func setAdmins (adminPubKeys) = { |
---|
399 | 399 | | let checkCaller = mustManager(i) |
---|
400 | 400 | | if ((checkCaller == checkCaller)) |
---|
401 | 401 | | then [StringEntry(keyAdminPubKeys(), makeString(adminPubKeys, SEP))] |
---|
402 | 402 | | else throw("Strict value is not equal to itself.") |
---|
403 | 403 | | } |
---|
404 | 404 | | |
---|
405 | 405 | | |
---|
406 | 406 | | |
---|
407 | 407 | | @Callable(i) |
---|
408 | 408 | | func priceAssetsREADONLY () = $Tuple2(nil, stringOptionToList(getString(keyPriceAssets()))) |
---|
409 | 409 | | |
---|
410 | 410 | | |
---|
411 | 411 | | |
---|
412 | 412 | | @Callable(i) |
---|
413 | 413 | | func statusREADONLY (amountAssetId,priceAssetId) = { |
---|
414 | 414 | | let status = match getString(keyStatus(amountAssetId, priceAssetId)) { |
---|
415 | 415 | | case s: String => |
---|
416 | 416 | | s |
---|
417 | 417 | | case _ => |
---|
418 | 418 | | unit |
---|
419 | 419 | | } |
---|
420 | 420 | | $Tuple2(nil, status) |
---|
421 | 421 | | } |
---|
422 | 422 | | |
---|
423 | 423 | | |
---|
424 | 424 | | @Verifier(tx) |
---|
425 | 425 | | func verify () = { |
---|
426 | 426 | | let targetPublicKey = match managerPublicKeyOrUnit() { |
---|
427 | 427 | | case pk: ByteVector => |
---|
428 | 428 | | pk |
---|
429 | 429 | | case _: Unit => |
---|
430 | 430 | | tx.senderPublicKey |
---|
431 | 431 | | case _ => |
---|
432 | 432 | | throw("Match error") |
---|
433 | 433 | | } |
---|
434 | 434 | | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) |
---|
435 | 435 | | } |
---|
436 | 436 | | |
---|