tx · 53sAX32qwPVN2HodRM1PU8mprkhTKunBVwxU6tULu1eh 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S: -0.01400000 Waves 2021.03.26 22:49 [1455155] smart account 3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S > SELF 0.00000000 Waves
{ "type": 13, "id": "53sAX32qwPVN2HodRM1PU8mprkhTKunBVwxU6tULu1eh", "fee": 1400000, "feeAssetId": null, "timestamp": 1616788277592, "version": 2, "chainId": 84, "sender": "3MwLcJy3MSb2kq6dUaUR5uBgm8zCKZMjz2S", "senderPublicKey": "CgByewRUvLk7UtWSfRMLSYw4Ap2wT5dcdVYKideqDp9M", "proofs": [ "5kZ5U2GPqJ5fHbMFVrrsRwHeaw2KtYesxd5MSxdbrD55FdUKweE6D39iD4usgnrL6PBNjidG43hJDDsZxs7fGPGN" ], "script": "base64:AAIEAAAAAAAAAAYIAhIAEgAAAAAPAAAAAA50b3RhbEZlZUV0aEtleQIAAAANdG90YWxfZmVlX2V0aAAAAAAOdG90YWxGZWVVc2RLZXkCAAAADXRvdGFsX2ZlZV91c2QAAAAAEnRvdGFsRmVlRHl6cmFwdEtleQIAAAARdG90YWxfZmVlX2R5enJhcHQAAAAADnByaWNlT2ZEeXpyYXB0AgAAAANkeXoAAAAACnByaWNlT2ZFdGgCAAAAA2V0aAAAAAANb3JhY2xlQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVL4/7s2JD7wFpgWNJdKO/aqFvcIdJFtzlgAAAAAOZHl6cmFwdEFzc2V0SWQBAAAAIJ8Z6XPZJu9QR4hmGj9/o7LyMJ48jRPQD0CePJOEpwQjAAAAAApldGhBc3NldElkAQAAACAiJlO6kpv9VYDdwqxzfY0rRQ9rtHAOIBs/eo3GguMLoQAAAAALdXNkbkFzc2V0SWQBAAAAIHxpwWtkcIB0JFIbiNXtI38nVRmozWmXoaigru9h4HfCAQAAAAxnZXRGZWVBbW91bnQAAAABAAAABmFtb3VudAQAAA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c2RuVG9EeXpyYXB0AAAAAAQAAAADcG10CQEAAAAFdmFsdWUAAAABCQABkQAAAAIIBQAAAAFpAAAACHBheW1lbnRzAAAAAAAAAAAABAAAAAdhc3NldElkCAUAAAADcG10AAAAB2Fzc2V0SWQEAAAAC3RvdGFsQW1vdW50CAUAAAADcG10AAAABmFtb3VudAMJAQAAAAIhPQAAAAIFAAAAB2Fzc2V0SWQFAAAAC3VzZG5Bc3NldElkCQAAAgAAAAECAAAAKU9ubHkgdXNkbiB0b2tlbnMgYXJlIGFsbG93ZWQgZm9yIHN3YXBwaW5nBAAAAANmZWUJAQAAAAxnZXRGZWVBbW91bnQAAAABBQAAAAt0b3RhbEFtb3VudAQAAAAGYW1vdW50CQAAZQAAAAIFAAAAC3RvdGFsQW1vdW50BQAAAANmZWUEAAAADWR5enJhcHRBbW91bnQJAQAAAA11c2RuVG9EeXpyYXB0AAAAAQUAAAAGYW1vdW50BAAAAAh0b3RhbEZlZQkBAAAADmdldFRvdGFsRmVlVXNkAAAAAAkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAd0b3RhbDogCQABpAAAAAEFAAAAC3RvdGFsQW1vdW50AgAAAAc7IGZlZTogCQABpAAAAAEFAAAAA2ZlZQIAAAAKOyBhbW91bnQ6IAkAAaQAAAABBQAAAAZhbW91bnQCAAAACzsgZHl6cmFwdDogCQABpAAAAAEFAAAADWR5enJhcHRBbW91bnQCAAAADDsgdG90YWxGZWU6IAkAAaQAAAABBQAAAAh0b3RhbEZlZQAAAAATWv5D", "height": 1455155, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6wG5C4uHb58SdVvwbqPqF4YGmw34DFZh7JP1XXTJNoaz Next: Fm35RrkjvLNf4dZYggTUdmDGAtDW7KV7VRWJWcH1tMFc Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let totalFeeEthKey = "total_fee_eth" | |
5 | 5 | ||
6 | 6 | let totalFeeUsdKey = "total_fee_usd" | |
7 | 7 | ||
8 | 8 | let totalFeeDyzraptKey = "total_fee_dyzrapt" | |
9 | 9 | ||
10 | 10 | let priceOfDyzrapt = "dyz" | |
11 | 11 | ||
12 | 12 | let priceOfEth = "eth" | |
13 | 13 | ||
14 | 14 | let oracleAddress = Address(base58'3N7G2kVtBTh94aEnDHQ9dpi4EdsDxAiDXjB') | |
15 | 15 | ||
16 | 16 | let dyzraptAssetId = base58'Bi4jxKEFjjYG2emeyxZfpkVMS88N7uAogHNsi1urkoJA' | |
17 | 17 | ||
18 | 18 | let ethAssetId = base58'3JJkzB4pFXcqdJvC9TcV8ys1FLgesr5SxbhmykkpceQp' | |
19 | 19 | ||
20 | 20 | let usdnAssetId = base58'9Nf5wpj6jds3VRZKDryp6Dtf3R9d8MdbjNhencLogCr5' | |
21 | 21 | ||
22 | 22 | func getFeeAmount (amount) = { | |
23 | 23 | let fee = fraction(amount, 3, 100) | |
24 | 24 | fee | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getIntKeyData (key) = { | |
29 | 29 | let v = valueOrElse(getInteger(this, key), 0) | |
30 | 30 | v | |
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getTotalFeeEth () = getIntKeyData(totalFeeEthKey) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func getTotalFeeUsd () = getIntKeyData(totalFeeUsdKey) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getTotalFeeDyzrapt () = getIntKeyData(totalFeeDyzraptKey) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func usdnToDyzrapt (amount) = { | |
44 | 44 | let dyzraptPrice = valueOrErrorMessage(getInteger(oracleAddress, "dyz"), "Unable to load price") | |
45 | 45 | fraction(amount, 10000, dyzraptPrice) | |
46 | 46 | } | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | @Callable(i) | |
50 | 50 | func test () = { | |
51 | 51 | let pmt = value(i.payments[0]) | |
52 | 52 | let assetId = pmt.assetId | |
53 | 53 | let amount = pmt.amount | |
54 | 54 | if ((assetId == dyzraptAssetId)) | |
55 | 55 | then throw(("its a dyzrapt. Amount=" + toString(amount))) | |
56 | 56 | else throw("its not a dyzrapt") | |
57 | 57 | } | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | ||
61 | 61 | @Callable(i) | |
62 | 62 | func swapUsdnToDyzrapt () = { | |
63 | 63 | let pmt = value(i.payments[0]) | |
64 | 64 | let assetId = pmt.assetId | |
65 | 65 | let totalAmount = pmt.amount | |
66 | 66 | if ((assetId != usdnAssetId)) | |
67 | 67 | then throw("Only usdn tokens are allowed for swapping") | |
68 | 68 | else { | |
69 | 69 | let fee = getFeeAmount(totalAmount) | |
70 | 70 | let amount = (totalAmount - fee) | |
71 | 71 | let dyzraptAmount = usdnToDyzrapt(amount) | |
72 | 72 | let totalFee = getTotalFeeUsd() | |
73 | 73 | throw(((((((((("total: " + toString(totalAmount)) + "; fee: ") + toString(fee)) + "; amount: ") + toString(amount)) + "; dyzrapt: ") + toString(dyzraptAmount)) + "; totalFee: ") + toString(totalFee))) | |
74 | 74 | } | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 |
github/deemru/w8io/026f985 39.18 ms ◑