tx · 8jFHQcDxsxospWLNmL5RxpL3CoXmRCGG7J9nVqGqbHse 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S: -0.01400000 Waves 2021.04.03 19:56 [1466529] smart account 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S > SELF 0.00000000 Waves
{ "type": 13, "id": "8jFHQcDxsxospWLNmL5RxpL3CoXmRCGG7J9nVqGqbHse", "fee": 1400000, "feeAssetId": null, "timestamp": 1617469038570, "version": 2, "chainId": 84, "sender": "3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S", "senderPublicKey": "CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M", "proofs": [ "2ZQksfP2c3vsb6X1HVrpHsajLd8wKTKy3FotEjM7fmZEVbvVnP7prn86jT7zKeY3Z7EtcHjn898LztoZHjP95jHV" ], "script": "base64:AAIEAAAAAAAAAAYIAhIAEgAAAAAPAAAAABJ1c2RuRHl6QUJhbGFuY2VLZXkCAAAAGHVzZG5fZHl6X2FfYXNzZXRfYmFsYW5jZQAAAAASdXNkbkR5ekJCYWxhbmNlS2V5AgAAABh1c2RuX2R5el9iX2Fzc2V0X2JhbGFuY2UAAAAAEWV0aER5ekFCYWxhbmNlS2V5AgAAABdldGhfZHl6X2FfYXNzZXRfYmFsYW5jZQAAAAARZXRoRHl6QkJhbGFuY2VLZXkCAAAAF2V0aF9keXpfYl9hc3NldF9iYWxhbmNlAAAAABZ1c2RuRHl6UGFpcklzQWN0aXZlS2V5AgAAABJ1c2RuX2R5el9pc19hY3RpdmUAAAAAFWV0aER5elBhaXJJc0FjdGl2ZUtleQIAAAARZXRoX2R5el9pc19hY3RpdmUAAAAABmZlZUtleQIAAAADZmVlAAAAAA5keXpyYXB0QXNzZXRJZAEAAAAgnxnpc9km71BHiGYaP3+jsvIwnjyNE9APQJ48k4SnBCMAAAAACmV0aEFzc2V0SWQBAAAAICImU7qSm/1VgN3CrHN9jStFD2u0cA4gGz96jcaC4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AgJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAEAAAAHYXNzZXRJZAQAAAAKcG10QW1vdW50QggFAAAACyR0MDIwNDMyMTIwAAAAAl8xBAAAAAtwbXRBc3NldElkQggFAAAACyR0MDIwNDMyMTIwAAAAAl8yCQEAAAAFdGhyb3cAAAAAAAAAAWkBAAAAD2V4Y2hhbmdlVXNkbkR5egAAAAADCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCQAEGwAAAAIFAAAABHRoaXMFAAAAFnVzZG5EeXpQYWlySXNBY3RpdmVLZXkJAAACAAAAAQIAAAASUGFpciBpcyBub3QgYWN0aXZlBAAAAANwbXQJAQAAAAV2YWx1ZQAAAAEJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAEAAAAB2Fzc2V0SWQIBQAAAANwbXQAAAAHYXNzZXRJZAQAAAAGYW1vdW50CAUAAAADcG10AAAABmFtb3VudAMDCQEAAAACIT0AAAACBQAAAAdhc3NldElkBQAAAAt1c2RuQXNzZXRJZAYJAQAAAAIhPQAAAAIFAAAAB2Fzc2V0SWQFAAAADmR5enJhcHRBc3NldElkCQAAAgAAAAECAAAAJE9ubHkgdXNkbiBhbmQgZHl6cnVwdCBhcmUgc3VwcG9ydGluZwQAAAAHckFtb3VudAkBAAAAEGdldFVzZG5EeXpBbW91bnQAAAACBQAAAAdhc3NldElkBQAAAAZhbW91bnQJAQAAAAV0aHJvdwAAAAAAAAAA66da4g==", "height": 1466529, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DNeFe6dQefHNtjr2TMwcKqeTMJyXSEa8zPRP53tLTsDU Next: BQ7BaSGiBxDqM5RFonsZfFTYCHESRD1axrwCbbKh8Pkt Diff:
Old | New | Differences | |
---|---|---|---|
69 | 69 | let $t020432120 = $Tuple2(i.payments[1].amount, i.payments[1].assetId) | |
70 | 70 | let pmtAmountB = $t020432120._1 | |
71 | 71 | let pmtAssetIdB = $t020432120._2 | |
72 | - | if ((pmtAssetIdA != usdnAssetId)) | |
73 | - | then throw("A asset is not a usdn") | |
74 | - | else if ((pmtAssetIdB != dyzraptAssetId)) | |
75 | - | then throw("B asset is not a dyzrupt") | |
76 | - | else [BooleanEntry(usdnDyzPairIsActiveKey, true), IntegerEntry(usdnDyzABalanceKey, pmtAmountA), IntegerEntry(usdnDyzBBalanceKey, pmtAmountB), IntegerEntry(feeKey, 300)] | |
72 | + | throw() | |
77 | 73 | } | |
78 | 74 | ||
79 | 75 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let usdnDyzABalanceKey = "usdn_dyz_a_asset_balance" | |
5 | 5 | ||
6 | 6 | let usdnDyzBBalanceKey = "usdn_dyz_b_asset_balance" | |
7 | 7 | ||
8 | 8 | let ethDyzABalanceKey = "eth_dyz_a_asset_balance" | |
9 | 9 | ||
10 | 10 | let ethDyzBBalanceKey = "eth_dyz_b_asset_balance" | |
11 | 11 | ||
12 | 12 | let usdnDyzPairIsActiveKey = "usdn_dyz_is_active" | |
13 | 13 | ||
14 | 14 | let ethDyzPairIsActiveKey = "eth_dyz_is_active" | |
15 | 15 | ||
16 | 16 | let feeKey = "fee" | |
17 | 17 | ||
18 | 18 | let dyzraptAssetId = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA' | |
19 | 19 | ||
20 | 20 | let ethAssetId = base58'3JJkzB4pFXcqdJvC9TcV8ys1FLgesr5SxbhmykkpceQp' | |
21 | 21 | ||
22 | 22 | let usdnAssetId = base58'9Nf5wpj6jds3VRZKDryp6Dtf3R9d8MdbjNhencLogCr5' | |
23 | 23 | ||
24 | 24 | let adminPublicKey = base58'CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M' | |
25 | 25 | ||
26 | 26 | let feeAddress = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB') | |
27 | 27 | ||
28 | 28 | func getIntKeyDataOrError (key) = { | |
29 | 29 | let v = valueOrErrorMessage(getInteger(this, key), "unable to read key") | |
30 | 30 | v | |
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getFeeAmount (amount) = { | |
35 | 35 | let fee = getIntKeyDataOrError(feeKey) | |
36 | 36 | let feeAmount = fraction(amount, fee, 10000) | |
37 | 37 | fee | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func getUsdnDyzAmount (assetId,amount) = { | |
42 | 42 | let feeAmount = getFeeAmount(amount) | |
43 | 43 | let amountWithoutFee = (amount - feeAmount) | |
44 | 44 | let balanceA = getIntegerValue(this, usdnDyzABalanceKey) | |
45 | 45 | let balanceB = getIntegerValue(this, usdnDyzBBalanceKey) | |
46 | 46 | if ((assetId == usdnAssetId)) | |
47 | 47 | then { | |
48 | 48 | let rAmount = fraction(balanceB, amountWithoutFee, (amountWithoutFee + balanceA)) | |
49 | 49 | throw(("usdn" + toString(rAmount))) | |
50 | 50 | } | |
51 | 51 | else if ((assetId == dyzraptAssetId)) | |
52 | 52 | then { | |
53 | 53 | let rAmount = fraction(balanceA, amountWithoutFee, (amountWithoutFee + balanceB)) | |
54 | 54 | throw(("dyzrupt " + toString(rAmount))) | |
55 | 55 | } | |
56 | 56 | else throw("Incorrect asset attached") | |
57 | 57 | } | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | @Callable(i) | |
61 | 61 | func initUsdnDyzPair () = if (isDefined(getBoolean(this, usdnDyzPairIsActiveKey))) | |
62 | 62 | then throw("Pair is already active") | |
63 | 63 | else if ((i.callerPublicKey != adminPublicKey)) | |
64 | 64 | then throw("Only admin can activate pair") | |
65 | 65 | else { | |
66 | 66 | let $t019572034 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
67 | 67 | let pmtAmountA = $t019572034._1 | |
68 | 68 | let pmtAssetIdA = $t019572034._2 | |
69 | 69 | let $t020432120 = $Tuple2(i.payments[1].amount, i.payments[1].assetId) | |
70 | 70 | let pmtAmountB = $t020432120._1 | |
71 | 71 | let pmtAssetIdB = $t020432120._2 | |
72 | - | if ((pmtAssetIdA != usdnAssetId)) | |
73 | - | then throw("A asset is not a usdn") | |
74 | - | else if ((pmtAssetIdB != dyzraptAssetId)) | |
75 | - | then throw("B asset is not a dyzrupt") | |
76 | - | else [BooleanEntry(usdnDyzPairIsActiveKey, true), IntegerEntry(usdnDyzABalanceKey, pmtAmountA), IntegerEntry(usdnDyzBBalanceKey, pmtAmountB), IntegerEntry(feeKey, 300)] | |
72 | + | throw() | |
77 | 73 | } | |
78 | 74 | ||
79 | 75 | ||
80 | 76 | ||
81 | 77 | @Callable(i) | |
82 | 78 | func exchangeUsdnDyz () = if (!(isDefined(getBoolean(this, usdnDyzPairIsActiveKey)))) | |
83 | 79 | then throw("Pair is not active") | |
84 | 80 | else { | |
85 | 81 | let pmt = value(i.payments[0]) | |
86 | 82 | let assetId = pmt.assetId | |
87 | 83 | let amount = pmt.amount | |
88 | 84 | if (if ((assetId != usdnAssetId)) | |
89 | 85 | then true | |
90 | 86 | else (assetId != dyzraptAssetId)) | |
91 | 87 | then throw("Only usdn and dyzrupt are supporting") | |
92 | 88 | else { | |
93 | 89 | let rAmount = getUsdnDyzAmount(assetId, amount) | |
94 | 90 | throw() | |
95 | 91 | } | |
96 | 92 | } | |
97 | 93 | ||
98 | 94 |
github/deemru/w8io/169f3d6 43.37 ms ◑