tx · BVPtun9bc8j2ioFCCUFm3zDwMxvx6v254qF96yLXyZGR 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J: -0.01400000 Waves 2021.10.25 17:30 [1761964] smart account 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J > SELF 0.00000000 Waves
{ "type": 13, "id": "BVPtun9bc8j2ioFCCUFm3zDwMxvx6v254qF96yLXyZGR", "fee": 1400000, "feeAssetId": null, "timestamp": 1635172211049, "version": 1, "sender": "3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J", "senderPublicKey": "B7ayemTreAJnAMuzH9P3MnVXhpL6PTtRBrV29h7EUS1H", "proofs": [ "j998YNdDK4V24GqMSdAUFBnPXRKu6jhD5ASQsyeZaGX72YF1c2aCErzebAV8VLs5hnJGw5PUZampoLAuyPth2fM" ], "script": "base64:AAIFAAAAAAAAACQIAhIGCgQICAgBEgQKAggEEgMKAQESBAoCAQgSABIDCgEBEgAAAAAKAAAAAA5TV09QZ292ZXJuYW5jZQkABCYAAAABCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAAD1NXT1BfZ292ZXJuYW5jZQIAAAAhRW1wdHkga2V5IFNXT1BfZ292ZXJuYW5jZV9hZGRyZXNzAAAAAA1XYXZlc1VzZG5Qb29sCQAEJgAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAPV0FWRVNfVVNETl9Qb29sAgAAACFFbXB0eSBrZXkgU1dPUF9nb3Zlcm5hbmNlX2FkZHJlc3MAAAAAF2RlZmloZWxwZXJNYW5hZ2VyUHViS2V5CQACWQAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAZZGVmaWhlbHBlcl9tYW5hZ2VyX1B1YktleQIAAAAjRW1wdHkga2V5IGRlZmloZWxwZXJfbWFuYWdlcl9QdWJLZXkAAAAADGFkbWluUHViS2V5M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GxlclN0cgkABCUAAAABCAUAAAABaQAAAAZjYWxsZXIEAAAADWNhbGxlckJhbGFuY2UJAQAAABBnZXRDYWxsZXJCYWxhbmNlAAAAAQUAAAAJY2FsbGVyU3RyAwkAAGYAAAACBQAAAAt3aXRoZHJhd0FtdAUAAAANY2FsbGVyQmFsYW5jZQkAAAIAAAABAgAAABt3aXRoZHJhd0FtdCA+IGNhbGxlckJhbGFuY2UJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgUAAAAJY2FsbGVyU3RyBQAAAAprZXlCYWxhbmNlCQAAZQAAAAIFAAAADWNhbGxlckJhbGFuY2UFAAAAC3dpdGhkcmF3QW10CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAALd2l0aGRyYXdBbXQFAAAABHVuaXQFAAAAA25pbAAAAAFpAQAAAAhzaHV0ZG93bgAAAAADCQEAAAABIQAAAAEFAAAAEGlzUHJvdG9jb2xBY3RpdmUJAAACAAAAAQIAAAAXUHJvdG9sIHN0b3BwZWQgYnkgYWRtaW4DCQEAAAABIQAAAAEJAQAAAA9jb250YWluc0VsZW1lbnQAAAACCQAETAAAAAIFAAAADGFkbWluUHViS2V5MQkABEwAAAACBQAAAAxhZG1pblB1YktleTIJAARMAAAAAgUAAAAMYWRtaW5QdWJLZXkzCQAETAAAAAIFAAAAF2RlZmloZWxwZXJNYW5hZ2VyUHViS2V5BQAAAANuaWwIBQAAAAFpAAAAD2NhbGxlclB1YmxpY0tleQkAAAIAAAABAgAAACFPbmx5IGFkbWluIGNhbiBjYWxsIHRoaXMgZnVuY3Rpb24JAARMAAAAAgkBAAAADEJvb2xlYW5FbnRyeQAAAAICAAAAEGlzUHJvdG9jb2xBY3RpdmUHBQAAAANuaWwAAAAA2lv76g==", "chainId": 84, "height": 1761964, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2ADxAXYA6kfNgyHVtebV4eiLV8fRVQMhPNC9vciJhjwf Next: 3cmV7haLVPsmk9pP2xgxyvC1dsMz4tFkAj6kjmsXa3Du Diff:
Old | New | Differences | |
---|---|---|---|
63 | 63 | func extractFee (fee,user) = if (!(isProtocolActive)) | |
64 | 64 | then throw("Protol stopped by admin") | |
65 | 65 | else { | |
66 | - | let isAutomateActive = valueOrErrorMessage(getBoolean(this, | |
66 | + | let isAutomateActive = valueOrErrorMessage(getBoolean(this, toString(i.caller)), ("Empty key i.caller: " + toString(i.caller))) | |
67 | 67 | if (!(isAutomateActive)) | |
68 | 68 | then throw("This automate is inactive") | |
69 | 69 | else { | |
78 | 78 | func replanishBalance () = if (!(isProtocolActive)) | |
79 | 79 | then throw("Protol stopped by admin") | |
80 | 80 | else { | |
81 | - | let $ | |
82 | - | let pmtAmount = $ | |
83 | - | let pmtAssetId = $ | |
81 | + | let $t031643239 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
82 | + | let pmtAmount = $t031643239._1 | |
83 | + | let pmtAssetId = $t031643239._2 | |
84 | 84 | if ((pmtAssetId != unit)) | |
85 | 85 | then throw("Only WAVES available for replanishment") | |
86 | 86 | else { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SWOPgovernance = addressFromString(valueOrElse(getString(this, "SWOP_governance"), "Empty key SWOP_governance_address")) | |
5 | 5 | ||
6 | 6 | let WavesUsdnPool = addressFromString(valueOrElse(getString(this, "WAVES_USDN_Pool"), "Empty key SWOP_governance_address")) | |
7 | 7 | ||
8 | 8 | let defihelperManagerPubKey = fromBase58String(valueOrElse(getString(this, "defihelper_manager_PubKey"), "Empty key defihelper_manager_PubKey")) | |
9 | 9 | ||
10 | 10 | let adminPubKey1 = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
11 | 11 | ||
12 | 12 | let adminPubKey2 = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
13 | 13 | ||
14 | 14 | let adminPubKey3 = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
15 | 15 | ||
16 | 16 | let keyBalance = "_balance" | |
17 | 17 | ||
18 | 18 | let keyFeeInUSDN = "fee_in_usdn" | |
19 | 19 | ||
20 | 20 | let isProtocolActive = valueOrErrorMessage(getBoolean(this, "isProtocolActive"), "Empty key isProtocolActive") | |
21 | 21 | ||
22 | 22 | func getCallerBalance (callerStr) = { | |
23 | 23 | let callerBalance = match getInteger(this, (callerStr + keyBalance)) { | |
24 | 24 | case cb: Int => | |
25 | 25 | cb | |
26 | 26 | case empty: Unit => | |
27 | 27 | 0 | |
28 | 28 | case _ => | |
29 | 29 | throw("Match error") | |
30 | 30 | } | |
31 | 31 | callerBalance | |
32 | 32 | } | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | @Callable(i) | |
36 | 36 | func init (defihelperManagerPubKey,WavesUsdnPool,SWOPgovernanceAdr,newFeeInUSDN) = if (if (isDefined(getString(this, "WAVES_USDN_Pool"))) | |
37 | 37 | then true | |
38 | 38 | else isDefined(getString(this, "defihelper_manager_PubKey"))) | |
39 | 39 | then throw("Already initialized") | |
40 | 40 | else [StringEntry("defihelper_manager_PubKey", defihelperManagerPubKey), StringEntry("WAVES_USDN_Pool", WavesUsdnPool), StringEntry("SWOP_governance", SWOPgovernanceAdr), IntegerEntry("protocol_fee_in_usdn", newFeeInUSDN), BooleanEntry("isProtocolActive", true)] | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | ||
44 | 44 | @Callable(i) | |
45 | 45 | func updateAutomateStatus (automate,status) = if (!(isProtocolActive)) | |
46 | 46 | then throw("Protol stopped by admin") | |
47 | 47 | else if (!(containsElement([defihelperManagerPubKey], i.callerPublicKey))) | |
48 | 48 | then throw("Only admin can call this function") | |
49 | 49 | else [BooleanEntry(automate, status)] | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | ||
53 | 53 | @Callable(i) | |
54 | 54 | func updateProtocolFee (newFeeInUSDN) = if (!(isProtocolActive)) | |
55 | 55 | then throw("Protol stopped by admin") | |
56 | 56 | else if (!(containsElement([defihelperManagerPubKey], i.callerPublicKey))) | |
57 | 57 | then throw("Only admin can call this function") | |
58 | 58 | else [IntegerEntry("protocol_fee_in_usdn", newFeeInUSDN)] | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | ||
62 | 62 | @Callable(i) | |
63 | 63 | func extractFee (fee,user) = if (!(isProtocolActive)) | |
64 | 64 | then throw("Protol stopped by admin") | |
65 | 65 | else { | |
66 | - | let isAutomateActive = valueOrErrorMessage(getBoolean(this, | |
66 | + | let isAutomateActive = valueOrErrorMessage(getBoolean(this, toString(i.caller)), ("Empty key i.caller: " + toString(i.caller))) | |
67 | 67 | if (!(isAutomateActive)) | |
68 | 68 | then throw("This automate is inactive") | |
69 | 69 | else { | |
70 | 70 | let automateBalance = valueOrErrorMessage(getInteger(this, (user + keyBalance)), (("Empty key user + keyBalance: " + user) + keyBalance)) | |
71 | 71 | [IntegerEntry((user + keyBalance), (automateBalance - fee))] | |
72 | 72 | } | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | 77 | @Callable(i) | |
78 | 78 | func replanishBalance () = if (!(isProtocolActive)) | |
79 | 79 | then throw("Protol stopped by admin") | |
80 | 80 | else { | |
81 | - | let $ | |
82 | - | let pmtAmount = $ | |
83 | - | let pmtAssetId = $ | |
81 | + | let $t031643239 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
82 | + | let pmtAmount = $t031643239._1 | |
83 | + | let pmtAssetId = $t031643239._2 | |
84 | 84 | if ((pmtAssetId != unit)) | |
85 | 85 | then throw("Only WAVES available for replanishment") | |
86 | 86 | else { | |
87 | 87 | let callerStr = toString(i.caller) | |
88 | 88 | let callerBalance = getCallerBalance(callerStr) | |
89 | 89 | [IntegerEntry((callerStr + keyBalance), (callerBalance + pmtAmount))] | |
90 | 90 | } | |
91 | 91 | } | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | ||
95 | 95 | @Callable(i) | |
96 | 96 | func withdraw (withdrawAmt) = if (!(isProtocolActive)) | |
97 | 97 | then throw("Protol stopped by admin") | |
98 | 98 | else { | |
99 | 99 | let callerStr = toString(i.caller) | |
100 | 100 | let callerBalance = getCallerBalance(callerStr) | |
101 | 101 | if ((withdrawAmt > callerBalance)) | |
102 | 102 | then throw("withdrawAmt > callerBalance") | |
103 | 103 | else [IntegerEntry((callerStr + keyBalance), (callerBalance - withdrawAmt)), ScriptTransfer(i.caller, withdrawAmt, unit)] | |
104 | 104 | } | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | ||
108 | 108 | @Callable(i) | |
109 | 109 | func shutdown () = if (!(isProtocolActive)) | |
110 | 110 | then throw("Protol stopped by admin") | |
111 | 111 | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, defihelperManagerPubKey], i.callerPublicKey))) | |
112 | 112 | then throw("Only admin can call this function") | |
113 | 113 | else [BooleanEntry("isProtocolActive", false)] | |
114 | 114 | ||
115 | 115 |
github/deemru/w8io/169f3d6 40.31 ms ◑