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