tx · yBuydcbhmM11yHjwq2TRPaaZs39AYMQKaJLvGaapsHw 3N85YW6NZ9pLYvSdt1ASMQTGxvncnU1vUNx: -0.10000000 Waves 2022.11.17 15:23 [2321106] smart account 3N85YW6NZ9pLYvSdt1ASMQTGxvncnU1vUNx > SELF 0.00000000 Waves
{ "type": 13, "id": "yBuydcbhmM11yHjwq2TRPaaZs39AYMQKaJLvGaapsHw", "fee": 10000000, "feeAssetId": null, "timestamp": 1668687810255, "version": 2, "chainId": 84, "sender": "3N85YW6NZ9pLYvSdt1ASMQTGxvncnU1vUNx", "senderPublicKey": "EKZmHJ5bK3qKKgRdq8rAamt9qrDbVMLARzRqXoQW258v", "proofs": [ "2ZZhfc9yuo38RoZQNCyNUZYgXBsywKcjZLn4Rq49fc1P4XqoGzweSW169R313T6LnJhh66gufngkE3kRBtGRnjXs" ], "script": "base64:AAIFAAAAAAAAAC0IAhIDCgEBEg8KDQEBAQEICAgICAEICAgSAwoBCBIDCgEIEgMKAQgSBAoCCAEAAAAmAAAAAAlzZXBhcmF0b3ICAAAAAV8AAAAACGtBdWN0aW9uAgAAAAdhdWN0aW9uAAAAAAVrU2VsbAIAAAAEc2VsbAAAAAAIa1RydXN0ZWQCAAAAB3RydXN0ZWQAAAAABmtQcmljZQIAAAAFcHJpY2UBAAAACmdldFNsb3RLZXkAAAACAAAABnByZWZpeAAAAAVuZnRJZAkAASwAAAACCQABLAAAAAIFAAAABnByZWZpeAUAAAAJc2VwYXJhdG9yCQACWAAAAAEFAAAABW5mdElkAQAAAAtnZXRQcmljZUtleQAAAAEAAAAFbmZ0SWQJAAEsAAAAAgkAASwAAAACBQAAAAZrUHJpY2UFAAAACXNlcGFyYXRvcgkAAlgAAAABBQAAAAVuZnRJZAEAAAAKZ2V0U2VsbEtleQAAAAEAAAAFbmZ0SWQJAAEsAAAAAgkAASwAAAACBQAAAAVrU2VsbAUAAAAJc2VwYXJhdG9yCQACWAAAAAEFAAAABW5mdElkAQAAAA1nZXRBdWN0aW9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AAAFpAQAAABdnZXRQcmljZUF0Q3VycmVudE1vbWVudAAAAAIAAAAFbmZ0SWQAAAAGbW9tZW50BAAAAAdhc3NldElkCQACWQAAAAEFAAAABW5mdElkBAAAAAskdDA5MDcxOTEzNAkBAAAAGGNhbGNQcmljZUF0Q3VycmVudE1vbWVudAAAAAIFAAAAB2Fzc2V0SWQFAAAABm1vbWVudAQAAAAGc2VsbGVyCAUAAAALJHQwOTA3MTkxMzQAAAACXzEEAAAABXByaWNlCAUAAAALJHQwOTA3MTkxMzQAAAACXzIJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAAtnZXRQcmljZUtleQAAAAEFAAAAB2Fzc2V0SWQFAAAABXByaWNlBQAAAANuaWwAAAAAH7oK6Q==", "height": 2321106, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AFZHWFFWCYh2mHjGGRdMnEdvyLM4Ep3roPXHeEX3HkkW Next: G1bSyyrZspz5LaMzX81oGa9VMKu4XA6UXBfdjFWpqbvq Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "_" | |
5 | 5 | ||
6 | - | let | |
6 | + | let kAuction = "auction" | |
7 | 7 | ||
8 | 8 | let kSell = "sell" | |
9 | 9 | ||
10 | + | let kTrusted = "trusted" | |
11 | + | ||
10 | 12 | let kPrice = "price" | |
13 | + | ||
14 | + | func getSlotKey (prefix,nftId) = ((prefix + separator) + toBase58String(nftId)) | |
15 | + | ||
16 | + | ||
17 | + | func getPriceKey (nftId) = ((kPrice + separator) + toBase58String(nftId)) | |
18 | + | ||
19 | + | ||
20 | + | func getSellKey (nftId) = ((kSell + separator) + toBase58String(nftId)) | |
21 | + | ||
22 | + | ||
23 | + | func getAuctionKey (nftId) = ((kAuction + separator) + toBase58String(nftId)) | |
24 | + | ||
25 | + | ||
26 | + | func getTrustedKey (issuer) = ((kTrusted + separator) + toString(issuer)) | |
27 | + | ||
28 | + | ||
29 | + | func addToList (accum,nextValue) = (accum ++ [nextValue]) | |
30 | + | ||
31 | + | ||
32 | + | func joinString (params) = { | |
33 | + | let length = size(params) | |
34 | + | if ((length == 0)) | |
35 | + | then throw("Empty params") | |
36 | + | else if ((length == 1)) | |
37 | + | then makeString({ | |
38 | + | let $l = params | |
39 | + | let $s = size($l) | |
40 | + | let $acc0 = nil | |
41 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
42 | + | then $a | |
43 | + | else addToList($a, $l[$i]) | |
44 | + | ||
45 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
46 | + | then $a | |
47 | + | else throw("List size exceeds 1") | |
48 | + | ||
49 | + | $f0_2($f0_1($acc0, 0), 1) | |
50 | + | }, separator) | |
51 | + | else if ((length == 2)) | |
52 | + | then makeString({ | |
53 | + | let $l = params | |
54 | + | let $s = size($l) | |
55 | + | let $acc0 = nil | |
56 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
57 | + | then $a | |
58 | + | else addToList($a, $l[$i]) | |
59 | + | ||
60 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
61 | + | then $a | |
62 | + | else throw("List size exceeds 2") | |
63 | + | ||
64 | + | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
65 | + | }, separator) | |
66 | + | else if ((length == 3)) | |
67 | + | then makeString({ | |
68 | + | let $l = params | |
69 | + | let $s = size($l) | |
70 | + | let $acc0 = nil | |
71 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
72 | + | then $a | |
73 | + | else addToList($a, $l[$i]) | |
74 | + | ||
75 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
76 | + | then $a | |
77 | + | else throw("List size exceeds 3") | |
78 | + | ||
79 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
80 | + | }, separator) | |
81 | + | else if ((length == 4)) | |
82 | + | then makeString({ | |
83 | + | let $l = params | |
84 | + | let $s = size($l) | |
85 | + | let $acc0 = nil | |
86 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
87 | + | then $a | |
88 | + | else addToList($a, $l[$i]) | |
89 | + | ||
90 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
91 | + | then $a | |
92 | + | else throw("List size exceeds 4") | |
93 | + | ||
94 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4) | |
95 | + | }, separator) | |
96 | + | else if ((length == 5)) | |
97 | + | then makeString({ | |
98 | + | let $l = params | |
99 | + | let $s = size($l) | |
100 | + | let $acc0 = nil | |
101 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | + | then $a | |
103 | + | else addToList($a, $l[$i]) | |
104 | + | ||
105 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | + | then $a | |
107 | + | else throw("List size exceeds 5") | |
108 | + | ||
109 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
110 | + | }, separator) | |
111 | + | else throw("Max number of parameters exceeded") | |
112 | + | } | |
113 | + | ||
114 | + | ||
115 | + | func parseAsAuction (details) = { | |
116 | + | let res = split(details, separator) | |
117 | + | $Tuple5(addressFromStringValue(res[0]), parseIntValue(res[1]), parseIntValue(res[2]), parseIntValue(res[3]), parseIntValue(res[4])) | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | func parseAsSell (details) = { | |
122 | + | let res = split(details, separator) | |
123 | + | $Tuple2(addressFromStringValue(res[0]), parseIntValue(res[1])) | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | func joinStruct (params) = match params { | |
128 | + | case auction: (Address, Int, Int, Int, Int) => | |
129 | + | joinString([toString(auction._1), toString(auction._2), toString(auction._3), toString(auction._4), toString(auction._5)]) | |
130 | + | case sell: (Address, Int) => | |
131 | + | joinString([toString(sell._1), toString(sell._2)]) | |
132 | + | case _ => | |
133 | + | throw("Wrong params tupple") | |
134 | + | } | |
135 | + | ||
136 | + | ||
137 | + | func setAuction (seller,nftId,startPrice,endPrice,start,end) = StringEntry(getAuctionKey(nftId), joinStruct($Tuple5(seller, startPrice, endPrice, start, end))) | |
138 | + | ||
139 | + | ||
140 | + | func setSell (nftId,celler,price) = StringEntry(getSellKey(nftId), joinStruct($Tuple2(celler, price))) | |
141 | + | ||
142 | + | ||
143 | + | func getAuction (nftId) = value(getString(this, getAuctionKey(nftId))) | |
144 | + | ||
145 | + | ||
146 | + | func getSell (nftId) = value(getString(this, getSellKey(nftId))) | |
147 | + | ||
148 | + | ||
149 | + | func calcPriceAtCurrentMoment (assetId,moment) = { | |
150 | + | let details = getAuction(assetId) | |
151 | + | let $t028172921 = parseAsAuction(details) | |
152 | + | let seller = $t028172921._1 | |
153 | + | let startPriceValue = $t028172921._2 | |
154 | + | let endPriceValue = $t028172921._3 | |
155 | + | let startPeriodValue = $t028172921._4 | |
156 | + | let endPeriodValue = $t028172921._5 | |
157 | + | if ((moment >= endPeriodValue)) | |
158 | + | then $Tuple2(seller, endPriceValue) | |
159 | + | else { | |
160 | + | let deltaPrice = (startPriceValue - endPriceValue) | |
161 | + | let period = (endPeriodValue - startPeriodValue) | |
162 | + | let spended = (moment - startPeriodValue) | |
163 | + | $Tuple2(seller, (startPriceValue - fraction(spended, deltaPrice, period))) | |
164 | + | } | |
165 | + | } | |
166 | + | ||
11 | 167 | ||
12 | 168 | func isNft (assetId) = match assetInfo(assetId) { | |
13 | 169 | case token: Asset => | |
21 | 177 | } | |
22 | 178 | ||
23 | 179 | ||
180 | + | func isTrustedNft (assetId) = { | |
181 | + | let issuer = value(assetInfo(assetId)).issuer | |
182 | + | valueOrElse(getBoolean(this, getTrustedKey(issuer)), false) | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | func isSellExist (assetId) = isDefined(getString(this, getSellKey(assetId))) | |
187 | + | ||
188 | + | ||
189 | + | func isAuctionExist (assetId) = isDefined(getString(this, getAuctionKey(assetId))) | |
190 | + | ||
191 | + | ||
192 | + | func isCorrectSellPrice (price) = (price > 0) | |
193 | + | ||
194 | + | ||
195 | + | func isCorrectAuctionPeriod (start,end) = (end > start) | |
196 | + | ||
197 | + | ||
198 | + | func isCorrectAuctionPrices (startPrice,endPrice) = (startPrice > endPrice) | |
199 | + | ||
200 | + | ||
201 | + | func isAdmin (caller) = (caller == this) | |
202 | + | ||
203 | + | ||
204 | + | func isValidCaller (caller,seller) = if ((caller == this)) | |
205 | + | then true | |
206 | + | else (caller == seller) | |
207 | + | ||
208 | + | ||
209 | + | func isAuctionEnded (now,end) = (now > end) | |
210 | + | ||
211 | + | ||
212 | + | func isEnoughFunds (payment,currentMomentPrice) = (payment >= currentMomentPrice) | |
213 | + | ||
214 | + | ||
215 | + | func isWawes (assetId) = (assetId == unit) | |
216 | + | ||
217 | + | ||
218 | + | func isCorrectNft (nftId) = if (!(isNft(nftId))) | |
219 | + | then throw("Token is not Nft") | |
220 | + | else if (isSellExist(nftId)) | |
221 | + | then throw("Sell already exists") | |
222 | + | else if (isAuctionExist(nftId)) | |
223 | + | then throw("Auction already exists") | |
224 | + | else unit | |
225 | + | ||
226 | + | ||
227 | + | func isCorrectPayments (paymentAsset,paymentAmount,price) = if (!(isWawes(paymentAsset))) | |
228 | + | then throw("Payment must be at WAVES") | |
229 | + | else if (!(isEnoughFunds(paymentAmount, price))) | |
230 | + | then throw("Not enough funds") | |
231 | + | else unit | |
232 | + | ||
233 | + | ||
234 | + | func calcFee () = 0 | |
235 | + | ||
236 | + | ||
237 | + | func calcTrustedFee () = 0 | |
238 | + | ||
239 | + | ||
240 | + | func resultFundsAmounts (isTrusted,paymentAmount,actualPrice) = if (isTrusted) | |
241 | + | then $Tuple2((actualPrice - calcTrustedFee()), (paymentAmount - actualPrice)) | |
242 | + | else $Tuple2((actualPrice - calcFee()), (paymentAmount - actualPrice)) | |
243 | + | ||
244 | + | ||
245 | + | func getSlot (nftId) = if (isSellExist(nftId)) | |
246 | + | then $Tuple2(kSell, getSell(nftId)) | |
247 | + | else if (isAuctionExist(nftId)) | |
248 | + | then $Tuple2(kAuction, getAuction(nftId)) | |
249 | + | else throw("Slot doesn`t exist") | |
250 | + | ||
251 | + | ||
24 | 252 | @Callable(i) | |
25 | - | func createNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = { | |
26 | - | let newToken = Issue(nft_name, nft_description, 1, 0, false) | |
27 | - | let issueId = calculateAssetId(newToken) | |
28 | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(issueId) + separator) + "nft_tags"), nft_tags), StringEntry(((toBase58String(issueId) + separator) + "nft_dAppAddress"), nft_dAppAddress), IntegerEntry(((toBase58String(issueId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(issueId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(issueId) + separator) + "nft_data"), nft_data)] | |
253 | + | func addSell (price) = { | |
254 | + | let nftId = value(i.payments[0].assetId) | |
255 | + | valueOrElse(isCorrectNft(nftId), if (!(isCorrectSellPrice(price))) | |
256 | + | then throw("Price must be > 0") | |
257 | + | else [setSell(nftId, i.caller, price)]) | |
29 | 258 | } | |
30 | 259 | ||
31 | 260 | ||
32 | 261 | ||
33 | 262 | @Callable(i) | |
34 | - | func issueNft (name,meta) = { | |
35 | - | let newToken = Issue(name, meta, 1, 0, false) | |
36 | - | let issueId = calculateAssetId(newToken) | |
37 | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller))] | |
263 | + | func addAuction (startPrice,endPrice,start,end,nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = { | |
264 | + | let nftId = value(i.payments[0].assetId) | |
265 | + | valueOrElse(isCorrectNft(nftId), if (!(isCorrectAuctionPeriod(start, end))) | |
266 | + | then throw("Period is not correct") | |
267 | + | else if (!(isCorrectAuctionPrices(startPrice, endPrice))) | |
268 | + | then throw("Start price must be > endPrice") | |
269 | + | else [setAuction(i.caller, nftId, startPrice, endPrice, start, end), StringEntry(((toBase58String(nftId) + separator) + "nft_owner"), toString(i.caller)), StringEntry(((toBase58String(nftId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(nftId) + separator) + "nft_tags"), nft_tags), StringEntry(((toBase58String(nftId) + separator) + "nft_dAppAddress"), nft_dAppAddress), IntegerEntry(((toBase58String(nftId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(nftId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(nftId) + separator) + "nft_data"), nft_data)]) | |
38 | 270 | } | |
39 | 271 | ||
40 | 272 | ||
41 | 273 | ||
42 | 274 | @Callable(i) | |
43 | - | func buyNFT (nftID) = { | |
44 | - | let assetId = fromBase58String(nftID) | |
45 | - | let amount = value(i.payments[0].amount) | |
46 | - | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
47 | - | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
48 | - | if ((i.payments[0].assetId != unit)) | |
49 | - | then throw("Pay in waves") | |
50 | - | else if ((parseIntValue(price) > amount)) | |
51 | - | then throw("Invalid payment") | |
52 | - | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
275 | + | func buyFromSlot (nftId) = { | |
276 | + | let $t067816870 = $Tuple2(i.payments[0].assetId, value(i.payments[0].amount)) | |
277 | + | let paymentAsset = $t067816870._1 | |
278 | + | let paymentAmount = $t067816870._2 | |
279 | + | let assetId = fromBase58String(nftId) | |
280 | + | let $t069146952 = getSlot(assetId) | |
281 | + | let type = $t069146952._1 | |
282 | + | let details = $t069146952._2 | |
283 | + | let baseRes = [ScriptTransfer(i.caller, 1, assetId), DeleteEntry(getSlotKey(type, assetId))] | |
284 | + | if ((type == kSell)) | |
285 | + | then { | |
286 | + | let $t070947141 = parseAsSell(details) | |
287 | + | let seller = $t070947141._1 | |
288 | + | let priceValue = $t070947141._2 | |
289 | + | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, priceValue), { | |
290 | + | let $t072267328 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, priceValue) | |
291 | + | let sellerAmount = $t072267328._1 | |
292 | + | let buyerAmount = $t072267328._2 | |
293 | + | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
294 | + | if ((buyerAmount > 0)) | |
295 | + | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
296 | + | else updatedRes | |
297 | + | }) | |
298 | + | } | |
299 | + | else { | |
300 | + | let $t075457614 = calcPriceAtCurrentMoment(assetId, height) | |
301 | + | let seller = $t075457614._1 | |
302 | + | let actualPrice = $t075457614._2 | |
303 | + | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, actualPrice), { | |
304 | + | let $t077007803 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, actualPrice) | |
305 | + | let sellerAmount = $t077007803._1 | |
306 | + | let buyerAmount = $t077007803._2 | |
307 | + | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
308 | + | if ((buyerAmount > 0)) | |
309 | + | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
310 | + | else updatedRes | |
311 | + | }) | |
312 | + | } | |
53 | 313 | } | |
54 | 314 | ||
55 | 315 | ||
56 | 316 | ||
57 | 317 | @Callable(i) | |
58 | - | func sellNFT (price) = { | |
59 | - | let $t023692454 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
60 | - | let token0 = $t023692454._1 | |
61 | - | let amount0 = $t023692454._2 | |
62 | - | if (!(isNft(token0))) | |
63 | - | then throw("Token is not NFT") | |
64 | - | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
318 | + | func declineSlot (nftId) = { | |
319 | + | let assetId = fromBase58String(nftId) | |
320 | + | let $t081048142 = getSlot(assetId) | |
321 | + | let type = $t081048142._1 | |
322 | + | let details = $t081048142._2 | |
323 | + | let baseRes = [DeleteEntry(getSlotKey(type, assetId))] | |
324 | + | if ((type == kSell)) | |
325 | + | then { | |
326 | + | let $t082348281 = parseAsSell(details) | |
327 | + | let seller = $t082348281._1 | |
328 | + | let priceValue = $t082348281._2 | |
329 | + | if (!(isValidCaller(i.caller, seller))) | |
330 | + | then throw("Invalid caller") | |
331 | + | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
332 | + | } | |
333 | + | else { | |
334 | + | let $t084268530 = parseAsAuction(details) | |
335 | + | let seller = $t084268530._1 | |
336 | + | let startPriceValue = $t084268530._2 | |
337 | + | let endPriceValue = $t084268530._3 | |
338 | + | let startPeriodValue = $t084268530._4 | |
339 | + | let endPeriodValue = $t084268530._5 | |
340 | + | if (!(isValidCaller(i.caller, seller))) | |
341 | + | then throw("Invalid caller") | |
342 | + | else if (!(isAuctionEnded(height, endPeriodValue))) | |
343 | + | then throw("Wait for end of auction") | |
344 | + | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
345 | + | } | |
346 | + | } | |
347 | + | ||
348 | + | ||
349 | + | ||
350 | + | @Callable(i) | |
351 | + | func setTrustedIssuer (trustedAddr) = if (!(isAdmin(i.caller))) | |
352 | + | then throw("Only admin") | |
353 | + | else [BooleanEntry(getTrustedKey(addressFromStringValue(trustedAddr)), true)] | |
354 | + | ||
355 | + | ||
356 | + | ||
357 | + | @Callable(i) | |
358 | + | func getPriceAtCurrentMoment (nftId,moment) = { | |
359 | + | let assetId = fromBase58String(nftId) | |
360 | + | let $t090719134 = calcPriceAtCurrentMoment(assetId, moment) | |
361 | + | let seller = $t090719134._1 | |
362 | + | let price = $t090719134._2 | |
363 | + | [IntegerEntry(getPriceKey(assetId), price)] | |
65 | 364 | } | |
66 | 365 | ||
67 | 366 |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "_" | |
5 | 5 | ||
6 | - | let | |
6 | + | let kAuction = "auction" | |
7 | 7 | ||
8 | 8 | let kSell = "sell" | |
9 | 9 | ||
10 | + | let kTrusted = "trusted" | |
11 | + | ||
10 | 12 | let kPrice = "price" | |
13 | + | ||
14 | + | func getSlotKey (prefix,nftId) = ((prefix + separator) + toBase58String(nftId)) | |
15 | + | ||
16 | + | ||
17 | + | func getPriceKey (nftId) = ((kPrice + separator) + toBase58String(nftId)) | |
18 | + | ||
19 | + | ||
20 | + | func getSellKey (nftId) = ((kSell + separator) + toBase58String(nftId)) | |
21 | + | ||
22 | + | ||
23 | + | func getAuctionKey (nftId) = ((kAuction + separator) + toBase58String(nftId)) | |
24 | + | ||
25 | + | ||
26 | + | func getTrustedKey (issuer) = ((kTrusted + separator) + toString(issuer)) | |
27 | + | ||
28 | + | ||
29 | + | func addToList (accum,nextValue) = (accum ++ [nextValue]) | |
30 | + | ||
31 | + | ||
32 | + | func joinString (params) = { | |
33 | + | let length = size(params) | |
34 | + | if ((length == 0)) | |
35 | + | then throw("Empty params") | |
36 | + | else if ((length == 1)) | |
37 | + | then makeString({ | |
38 | + | let $l = params | |
39 | + | let $s = size($l) | |
40 | + | let $acc0 = nil | |
41 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
42 | + | then $a | |
43 | + | else addToList($a, $l[$i]) | |
44 | + | ||
45 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
46 | + | then $a | |
47 | + | else throw("List size exceeds 1") | |
48 | + | ||
49 | + | $f0_2($f0_1($acc0, 0), 1) | |
50 | + | }, separator) | |
51 | + | else if ((length == 2)) | |
52 | + | then makeString({ | |
53 | + | let $l = params | |
54 | + | let $s = size($l) | |
55 | + | let $acc0 = nil | |
56 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
57 | + | then $a | |
58 | + | else addToList($a, $l[$i]) | |
59 | + | ||
60 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
61 | + | then $a | |
62 | + | else throw("List size exceeds 2") | |
63 | + | ||
64 | + | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
65 | + | }, separator) | |
66 | + | else if ((length == 3)) | |
67 | + | then makeString({ | |
68 | + | let $l = params | |
69 | + | let $s = size($l) | |
70 | + | let $acc0 = nil | |
71 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
72 | + | then $a | |
73 | + | else addToList($a, $l[$i]) | |
74 | + | ||
75 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
76 | + | then $a | |
77 | + | else throw("List size exceeds 3") | |
78 | + | ||
79 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
80 | + | }, separator) | |
81 | + | else if ((length == 4)) | |
82 | + | then makeString({ | |
83 | + | let $l = params | |
84 | + | let $s = size($l) | |
85 | + | let $acc0 = nil | |
86 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
87 | + | then $a | |
88 | + | else addToList($a, $l[$i]) | |
89 | + | ||
90 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
91 | + | then $a | |
92 | + | else throw("List size exceeds 4") | |
93 | + | ||
94 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4) | |
95 | + | }, separator) | |
96 | + | else if ((length == 5)) | |
97 | + | then makeString({ | |
98 | + | let $l = params | |
99 | + | let $s = size($l) | |
100 | + | let $acc0 = nil | |
101 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | + | then $a | |
103 | + | else addToList($a, $l[$i]) | |
104 | + | ||
105 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | + | then $a | |
107 | + | else throw("List size exceeds 5") | |
108 | + | ||
109 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
110 | + | }, separator) | |
111 | + | else throw("Max number of parameters exceeded") | |
112 | + | } | |
113 | + | ||
114 | + | ||
115 | + | func parseAsAuction (details) = { | |
116 | + | let res = split(details, separator) | |
117 | + | $Tuple5(addressFromStringValue(res[0]), parseIntValue(res[1]), parseIntValue(res[2]), parseIntValue(res[3]), parseIntValue(res[4])) | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | func parseAsSell (details) = { | |
122 | + | let res = split(details, separator) | |
123 | + | $Tuple2(addressFromStringValue(res[0]), parseIntValue(res[1])) | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | func joinStruct (params) = match params { | |
128 | + | case auction: (Address, Int, Int, Int, Int) => | |
129 | + | joinString([toString(auction._1), toString(auction._2), toString(auction._3), toString(auction._4), toString(auction._5)]) | |
130 | + | case sell: (Address, Int) => | |
131 | + | joinString([toString(sell._1), toString(sell._2)]) | |
132 | + | case _ => | |
133 | + | throw("Wrong params tupple") | |
134 | + | } | |
135 | + | ||
136 | + | ||
137 | + | func setAuction (seller,nftId,startPrice,endPrice,start,end) = StringEntry(getAuctionKey(nftId), joinStruct($Tuple5(seller, startPrice, endPrice, start, end))) | |
138 | + | ||
139 | + | ||
140 | + | func setSell (nftId,celler,price) = StringEntry(getSellKey(nftId), joinStruct($Tuple2(celler, price))) | |
141 | + | ||
142 | + | ||
143 | + | func getAuction (nftId) = value(getString(this, getAuctionKey(nftId))) | |
144 | + | ||
145 | + | ||
146 | + | func getSell (nftId) = value(getString(this, getSellKey(nftId))) | |
147 | + | ||
148 | + | ||
149 | + | func calcPriceAtCurrentMoment (assetId,moment) = { | |
150 | + | let details = getAuction(assetId) | |
151 | + | let $t028172921 = parseAsAuction(details) | |
152 | + | let seller = $t028172921._1 | |
153 | + | let startPriceValue = $t028172921._2 | |
154 | + | let endPriceValue = $t028172921._3 | |
155 | + | let startPeriodValue = $t028172921._4 | |
156 | + | let endPeriodValue = $t028172921._5 | |
157 | + | if ((moment >= endPeriodValue)) | |
158 | + | then $Tuple2(seller, endPriceValue) | |
159 | + | else { | |
160 | + | let deltaPrice = (startPriceValue - endPriceValue) | |
161 | + | let period = (endPeriodValue - startPeriodValue) | |
162 | + | let spended = (moment - startPeriodValue) | |
163 | + | $Tuple2(seller, (startPriceValue - fraction(spended, deltaPrice, period))) | |
164 | + | } | |
165 | + | } | |
166 | + | ||
11 | 167 | ||
12 | 168 | func isNft (assetId) = match assetInfo(assetId) { | |
13 | 169 | case token: Asset => | |
14 | 170 | if (if ((token.decimals == 0)) | |
15 | 171 | then (token.quantity == 1) | |
16 | 172 | else false) | |
17 | 173 | then (token.reissuable == false) | |
18 | 174 | else false | |
19 | 175 | case _ => | |
20 | 176 | false | |
21 | 177 | } | |
22 | 178 | ||
23 | 179 | ||
180 | + | func isTrustedNft (assetId) = { | |
181 | + | let issuer = value(assetInfo(assetId)).issuer | |
182 | + | valueOrElse(getBoolean(this, getTrustedKey(issuer)), false) | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | func isSellExist (assetId) = isDefined(getString(this, getSellKey(assetId))) | |
187 | + | ||
188 | + | ||
189 | + | func isAuctionExist (assetId) = isDefined(getString(this, getAuctionKey(assetId))) | |
190 | + | ||
191 | + | ||
192 | + | func isCorrectSellPrice (price) = (price > 0) | |
193 | + | ||
194 | + | ||
195 | + | func isCorrectAuctionPeriod (start,end) = (end > start) | |
196 | + | ||
197 | + | ||
198 | + | func isCorrectAuctionPrices (startPrice,endPrice) = (startPrice > endPrice) | |
199 | + | ||
200 | + | ||
201 | + | func isAdmin (caller) = (caller == this) | |
202 | + | ||
203 | + | ||
204 | + | func isValidCaller (caller,seller) = if ((caller == this)) | |
205 | + | then true | |
206 | + | else (caller == seller) | |
207 | + | ||
208 | + | ||
209 | + | func isAuctionEnded (now,end) = (now > end) | |
210 | + | ||
211 | + | ||
212 | + | func isEnoughFunds (payment,currentMomentPrice) = (payment >= currentMomentPrice) | |
213 | + | ||
214 | + | ||
215 | + | func isWawes (assetId) = (assetId == unit) | |
216 | + | ||
217 | + | ||
218 | + | func isCorrectNft (nftId) = if (!(isNft(nftId))) | |
219 | + | then throw("Token is not Nft") | |
220 | + | else if (isSellExist(nftId)) | |
221 | + | then throw("Sell already exists") | |
222 | + | else if (isAuctionExist(nftId)) | |
223 | + | then throw("Auction already exists") | |
224 | + | else unit | |
225 | + | ||
226 | + | ||
227 | + | func isCorrectPayments (paymentAsset,paymentAmount,price) = if (!(isWawes(paymentAsset))) | |
228 | + | then throw("Payment must be at WAVES") | |
229 | + | else if (!(isEnoughFunds(paymentAmount, price))) | |
230 | + | then throw("Not enough funds") | |
231 | + | else unit | |
232 | + | ||
233 | + | ||
234 | + | func calcFee () = 0 | |
235 | + | ||
236 | + | ||
237 | + | func calcTrustedFee () = 0 | |
238 | + | ||
239 | + | ||
240 | + | func resultFundsAmounts (isTrusted,paymentAmount,actualPrice) = if (isTrusted) | |
241 | + | then $Tuple2((actualPrice - calcTrustedFee()), (paymentAmount - actualPrice)) | |
242 | + | else $Tuple2((actualPrice - calcFee()), (paymentAmount - actualPrice)) | |
243 | + | ||
244 | + | ||
245 | + | func getSlot (nftId) = if (isSellExist(nftId)) | |
246 | + | then $Tuple2(kSell, getSell(nftId)) | |
247 | + | else if (isAuctionExist(nftId)) | |
248 | + | then $Tuple2(kAuction, getAuction(nftId)) | |
249 | + | else throw("Slot doesn`t exist") | |
250 | + | ||
251 | + | ||
24 | 252 | @Callable(i) | |
25 | - | func createNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = { | |
26 | - | let newToken = Issue(nft_name, nft_description, 1, 0, false) | |
27 | - | let issueId = calculateAssetId(newToken) | |
28 | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(issueId) + separator) + "nft_tags"), nft_tags), StringEntry(((toBase58String(issueId) + separator) + "nft_dAppAddress"), nft_dAppAddress), IntegerEntry(((toBase58String(issueId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(issueId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(issueId) + separator) + "nft_data"), nft_data)] | |
253 | + | func addSell (price) = { | |
254 | + | let nftId = value(i.payments[0].assetId) | |
255 | + | valueOrElse(isCorrectNft(nftId), if (!(isCorrectSellPrice(price))) | |
256 | + | then throw("Price must be > 0") | |
257 | + | else [setSell(nftId, i.caller, price)]) | |
29 | 258 | } | |
30 | 259 | ||
31 | 260 | ||
32 | 261 | ||
33 | 262 | @Callable(i) | |
34 | - | func issueNft (name,meta) = { | |
35 | - | let newToken = Issue(name, meta, 1, 0, false) | |
36 | - | let issueId = calculateAssetId(newToken) | |
37 | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller))] | |
263 | + | func addAuction (startPrice,endPrice,start,end,nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = { | |
264 | + | let nftId = value(i.payments[0].assetId) | |
265 | + | valueOrElse(isCorrectNft(nftId), if (!(isCorrectAuctionPeriod(start, end))) | |
266 | + | then throw("Period is not correct") | |
267 | + | else if (!(isCorrectAuctionPrices(startPrice, endPrice))) | |
268 | + | then throw("Start price must be > endPrice") | |
269 | + | else [setAuction(i.caller, nftId, startPrice, endPrice, start, end), StringEntry(((toBase58String(nftId) + separator) + "nft_owner"), toString(i.caller)), StringEntry(((toBase58String(nftId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(nftId) + separator) + "nft_tags"), nft_tags), StringEntry(((toBase58String(nftId) + separator) + "nft_dAppAddress"), nft_dAppAddress), IntegerEntry(((toBase58String(nftId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(nftId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(nftId) + separator) + "nft_data"), nft_data)]) | |
38 | 270 | } | |
39 | 271 | ||
40 | 272 | ||
41 | 273 | ||
42 | 274 | @Callable(i) | |
43 | - | func buyNFT (nftID) = { | |
44 | - | let assetId = fromBase58String(nftID) | |
45 | - | let amount = value(i.payments[0].amount) | |
46 | - | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
47 | - | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
48 | - | if ((i.payments[0].assetId != unit)) | |
49 | - | then throw("Pay in waves") | |
50 | - | else if ((parseIntValue(price) > amount)) | |
51 | - | then throw("Invalid payment") | |
52 | - | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
275 | + | func buyFromSlot (nftId) = { | |
276 | + | let $t067816870 = $Tuple2(i.payments[0].assetId, value(i.payments[0].amount)) | |
277 | + | let paymentAsset = $t067816870._1 | |
278 | + | let paymentAmount = $t067816870._2 | |
279 | + | let assetId = fromBase58String(nftId) | |
280 | + | let $t069146952 = getSlot(assetId) | |
281 | + | let type = $t069146952._1 | |
282 | + | let details = $t069146952._2 | |
283 | + | let baseRes = [ScriptTransfer(i.caller, 1, assetId), DeleteEntry(getSlotKey(type, assetId))] | |
284 | + | if ((type == kSell)) | |
285 | + | then { | |
286 | + | let $t070947141 = parseAsSell(details) | |
287 | + | let seller = $t070947141._1 | |
288 | + | let priceValue = $t070947141._2 | |
289 | + | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, priceValue), { | |
290 | + | let $t072267328 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, priceValue) | |
291 | + | let sellerAmount = $t072267328._1 | |
292 | + | let buyerAmount = $t072267328._2 | |
293 | + | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
294 | + | if ((buyerAmount > 0)) | |
295 | + | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
296 | + | else updatedRes | |
297 | + | }) | |
298 | + | } | |
299 | + | else { | |
300 | + | let $t075457614 = calcPriceAtCurrentMoment(assetId, height) | |
301 | + | let seller = $t075457614._1 | |
302 | + | let actualPrice = $t075457614._2 | |
303 | + | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, actualPrice), { | |
304 | + | let $t077007803 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, actualPrice) | |
305 | + | let sellerAmount = $t077007803._1 | |
306 | + | let buyerAmount = $t077007803._2 | |
307 | + | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
308 | + | if ((buyerAmount > 0)) | |
309 | + | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
310 | + | else updatedRes | |
311 | + | }) | |
312 | + | } | |
53 | 313 | } | |
54 | 314 | ||
55 | 315 | ||
56 | 316 | ||
57 | 317 | @Callable(i) | |
58 | - | func sellNFT (price) = { | |
59 | - | let $t023692454 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
60 | - | let token0 = $t023692454._1 | |
61 | - | let amount0 = $t023692454._2 | |
62 | - | if (!(isNft(token0))) | |
63 | - | then throw("Token is not NFT") | |
64 | - | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
318 | + | func declineSlot (nftId) = { | |
319 | + | let assetId = fromBase58String(nftId) | |
320 | + | let $t081048142 = getSlot(assetId) | |
321 | + | let type = $t081048142._1 | |
322 | + | let details = $t081048142._2 | |
323 | + | let baseRes = [DeleteEntry(getSlotKey(type, assetId))] | |
324 | + | if ((type == kSell)) | |
325 | + | then { | |
326 | + | let $t082348281 = parseAsSell(details) | |
327 | + | let seller = $t082348281._1 | |
328 | + | let priceValue = $t082348281._2 | |
329 | + | if (!(isValidCaller(i.caller, seller))) | |
330 | + | then throw("Invalid caller") | |
331 | + | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
332 | + | } | |
333 | + | else { | |
334 | + | let $t084268530 = parseAsAuction(details) | |
335 | + | let seller = $t084268530._1 | |
336 | + | let startPriceValue = $t084268530._2 | |
337 | + | let endPriceValue = $t084268530._3 | |
338 | + | let startPeriodValue = $t084268530._4 | |
339 | + | let endPeriodValue = $t084268530._5 | |
340 | + | if (!(isValidCaller(i.caller, seller))) | |
341 | + | then throw("Invalid caller") | |
342 | + | else if (!(isAuctionEnded(height, endPeriodValue))) | |
343 | + | then throw("Wait for end of auction") | |
344 | + | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
345 | + | } | |
346 | + | } | |
347 | + | ||
348 | + | ||
349 | + | ||
350 | + | @Callable(i) | |
351 | + | func setTrustedIssuer (trustedAddr) = if (!(isAdmin(i.caller))) | |
352 | + | then throw("Only admin") | |
353 | + | else [BooleanEntry(getTrustedKey(addressFromStringValue(trustedAddr)), true)] | |
354 | + | ||
355 | + | ||
356 | + | ||
357 | + | @Callable(i) | |
358 | + | func getPriceAtCurrentMoment (nftId,moment) = { | |
359 | + | let assetId = fromBase58String(nftId) | |
360 | + | let $t090719134 = calcPriceAtCurrentMoment(assetId, moment) | |
361 | + | let seller = $t090719134._1 | |
362 | + | let price = $t090719134._2 | |
363 | + | [IntegerEntry(getPriceKey(assetId), price)] | |
65 | 364 | } | |
66 | 365 | ||
67 | 366 |
github/deemru/w8io/169f3d6 125.17 ms ◑