tx · 5WSEGnwoCRENtvV1rAd3vrQ5Yec1oKP2FWTNBUy6cHUE 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J: -0.01400000 Waves 2021.10.25 00:15 [1760923] smart account 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J > SELF 0.00000000 Waves
{ "type": 13, "id": "5WSEGnwoCRENtvV1rAd3vrQ5Yec1oKP2FWTNBUy6cHUE", "fee": 1400000, "feeAssetId": null, "timestamp": 1635110116542, "version": 1, "sender": "3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J", "senderPublicKey": "B7ayemTreAJnAMuzH9P3MnVXhpL6PTtRBrV29h7EUS1H", "proofs": [ "4sTvvSaHge2FQFwhwmrtxyuMj9oQxo1MvrXXUZLDWJ9tLqQPJXG3d55kCeYb2WjccdXVQPDq2EuXFgHmPetAjo6g" ], "script": "base64:AAIFAAAAAAAAACIIAhIFCgMICAESBAoCCAQSAwoBARIDCgEBEgASAwoBARIAAAAACgAAAAAOU1dPUGdvdmVybmFuY2UJAAQmAAAAAQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAAA9TV09QX2dvdmVybmFuY2UCAAAAIUVtcHR5IGtleSBTV09QX2dvdmVybmFuY2VfYWRkcmVzcwAAAAANV2F2ZXNVc2RuUG9vbAkABCYAAAABCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAAD1dBVkVTX1VTRE5fUG9vbAIAAAAhRW1wdHkga2V5IFNXT1BfZ292ZXJuYW5jZV9hZGRyZXNzAAAAABdkZWZpaGVscGVyTWFuYWdlclB1YktleQkAAlkAAAABCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAAGWRlZmloZWxwZXJfbWFuYWdlcl9QdWJLZXkCAAAAI0VtcHR5IGtleSBkZWZpaGVscGVyX21hbmFnZXJfUHViS2V5AAAAAAxhZG1pblB1YktleTEBAAAA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EAAAAQZ2V0Q2FsbGVyQmFsYW5jZQAAAAEFAAAACWNhbGxlclN0cgMJAABmAAAAAgUAAAALd2l0aGRyYXdBbXQFAAAADWNhbGxlckJhbGFuY2UJAAACAAAAAQIAAAAbd2l0aGRyYXdBbXQgPiBjYWxsZXJCYWxhbmNlCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQABLAAAAAIFAAAACWNhbGxlclN0cgUAAAAKa2V5QmFsYW5jZQkAAGUAAAACBQAAAA1jYWxsZXJCYWxhbmNlBQAAAAt3aXRoZHJhd0FtdAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAAC3dpdGhkcmF3QW10BQAAAAR1bml0BQAAAANuaWwAAAABaQEAAAAIc2h1dGRvd24AAAAAAwkBAAAAASEAAAABBQAAABBpc1Byb3RvY29sQWN0aXZlCQAAAgAAAAECAAAAF1Byb3RvbCBzdG9wcGVkIGJ5IGFkbWluAwkBAAAAASEAAAABCQEAAAAPY29udGFpbnNFbGVtZW50AAAAAgkABEwAAAACBQAAAAxhZG1pblB1YktleTEJAARMAAAAAgUAAAAMYWRtaW5QdWJLZXkyCQAETAAAAAIFAAAADGFkbWluUHViS2V5MwkABEwAAAACBQAAABdkZWZpaGVscGVyTWFuYWdlclB1YktleQUAAAADbmlsCAUAAAABaQAAAA9jYWxsZXJQdWJsaWNLZXkJAAACAAAAAQIAAAAhT25seSBhZG1pbiBjYW4gY2FsbCB0aGlzIGZ1bmN0aW9uCQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACAgAAABBpc1Byb3RvY29sQWN0aXZlBwUAAAADbmlsAAAAAG8y0mw=", "chainId": 84, "height": 1760923, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FybcMDhK3CAF2ufBimTQuFdVvjTce5RypKofSsc6xDkU Next: 9npXyE9QumvxL87rrqYytAJ8tS2PHNU5EN3YZnTh5Nc3 Diff:
Old | New | Differences | |
---|---|---|---|
79 | 79 | func replanishBalance () = if (!(isProtocolActive)) | |
80 | 80 | then throw("Protol stopped by admin") | |
81 | 81 | else { | |
82 | - | let $ | |
83 | - | let pmtAmount = $ | |
84 | - | let pmtAssetId = $ | |
82 | + | let $t031223197 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
83 | + | let pmtAmount = $t031223197._1 | |
84 | + | let pmtAssetId = $t031223197._2 | |
85 | 85 | if ((pmtAssetId != unit)) | |
86 | 86 | then throw("Only WAVES available for replanishment") | |
87 | 87 | else { | |
89 | 89 | let callerBalance = getCallerBalance(callerStr) | |
90 | 90 | [IntegerEntry((callerStr + keyBalance), (callerBalance + pmtAmount))] | |
91 | 91 | } | |
92 | + | } | |
93 | + | ||
94 | + | ||
95 | + | ||
96 | + | @Callable(i) | |
97 | + | func withdraw (withdrawAmt) = if (!(isProtocolActive)) | |
98 | + | then throw("Protol stopped by admin") | |
99 | + | else { | |
100 | + | let callerStr = toString(i.caller) | |
101 | + | let callerBalance = getCallerBalance(callerStr) | |
102 | + | if ((withdrawAmt > callerBalance)) | |
103 | + | then throw("withdrawAmt > callerBalance") | |
104 | + | else [IntegerEntry((callerStr + keyBalance), (callerBalance - withdrawAmt)), ScriptTransfer(i.caller, withdrawAmt, unit)] | |
92 | 105 | } | |
93 | 106 | ||
94 | 107 |
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,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), IntegerEntry("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 updateBalance (fee) = if (!(isProtocolActive)) | |
64 | 64 | then throw("Protol stopped by admin") | |
65 | 65 | else { | |
66 | 66 | let automateAddrStr = toString(i.caller) | |
67 | 67 | let isAutomateActive = valueOrErrorMessage(getBoolean(this, automateAddrStr), ("Empty key newUser: " + automateAddrStr)) | |
68 | 68 | if (!(isAutomateActive)) | |
69 | 69 | then throw("This automate is inactive") | |
70 | 70 | else { | |
71 | 71 | let automateBalance = valueOrErrorMessage(getInteger(this, (automateAddrStr + keyBalance)), (("Empty key automateAddrStr + keyBalance: " + automateAddrStr) + keyBalance)) | |
72 | 72 | [IntegerEntry(automateAddrStr, (automateBalance - fee))] | |
73 | 73 | } | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | ||
78 | 78 | @Callable(i) | |
79 | 79 | func replanishBalance () = if (!(isProtocolActive)) | |
80 | 80 | then throw("Protol stopped by admin") | |
81 | 81 | else { | |
82 | - | let $ | |
83 | - | let pmtAmount = $ | |
84 | - | let pmtAssetId = $ | |
82 | + | let $t031223197 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
83 | + | let pmtAmount = $t031223197._1 | |
84 | + | let pmtAssetId = $t031223197._2 | |
85 | 85 | if ((pmtAssetId != unit)) | |
86 | 86 | then throw("Only WAVES available for replanishment") | |
87 | 87 | else { | |
88 | 88 | let callerStr = toString(i.caller) | |
89 | 89 | let callerBalance = getCallerBalance(callerStr) | |
90 | 90 | [IntegerEntry((callerStr + keyBalance), (callerBalance + pmtAmount))] | |
91 | 91 | } | |
92 | + | } | |
93 | + | ||
94 | + | ||
95 | + | ||
96 | + | @Callable(i) | |
97 | + | func withdraw (withdrawAmt) = if (!(isProtocolActive)) | |
98 | + | then throw("Protol stopped by admin") | |
99 | + | else { | |
100 | + | let callerStr = toString(i.caller) | |
101 | + | let callerBalance = getCallerBalance(callerStr) | |
102 | + | if ((withdrawAmt > callerBalance)) | |
103 | + | then throw("withdrawAmt > callerBalance") | |
104 | + | else [IntegerEntry((callerStr + keyBalance), (callerBalance - withdrawAmt)), ScriptTransfer(i.caller, withdrawAmt, unit)] | |
92 | 105 | } | |
93 | 106 | ||
94 | 107 | ||
95 | 108 | ||
96 | 109 | @Callable(i) | |
97 | 110 | func shutdown () = if (!(isProtocolActive)) | |
98 | 111 | then throw("Protol stopped by admin") | |
99 | 112 | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, defihelperManagerPubKey], i.callerPublicKey))) | |
100 | 113 | then throw("Only admin can call this function") | |
101 | 114 | else [BooleanEntry("isProtocolActive", false)] | |
102 | 115 | ||
103 | 116 |
github/deemru/w8io/169f3d6 27.88 ms ◑