tx · A4fk2dJdU4AkEp7eFUNcteuBJrvLd668bPRM5v73cpsk 3NDCcfUw3NdSjTPHukj85CQZrt1WmB9aWA9: -0.01400000 Waves 2021.10.26 23:07 [1763723] smart account 3NDCcfUw3NdSjTPHukj85CQZrt1WmB9aWA9 > SELF 0.00000000 Waves
{ "type": 13, "id": "A4fk2dJdU4AkEp7eFUNcteuBJrvLd668bPRM5v73cpsk", "fee": 1400000, "feeAssetId": null, "timestamp": 1635278884861, "version": 1, "sender": "3NDCcfUw3NdSjTPHukj85CQZrt1WmB9aWA9", "senderPublicKey": "Ft1jz1c1eR7JbyAxdiSRJ1d4qkBH7DSdv89PspmNK5dq", "proofs": [ "3mFSs9QjtW8kYKj9nSSGUuHTBnhLpjytNzV56xKtYLjcmzwcFSATkGycigLS7Jm5tmny53YxE73GQJXtR4B92ETa" ], "script": "base64:AAIFAAAAAAAAACQIAhIGCgQICAgBEgQKAggEEgMKAQESBAoCCAQSABIDCgEBEgAAAAALAAAAAA5TV09QZ292ZXJuYW5jZQkABCYAAAABCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAAD1NXT1BfZ292ZXJuYW5jZQIAAAAhRW1wdHkga2V5IFNXT1BfZ292ZXJuYW5jZV9hZGRyZXNzAAAAAA1XYXZlc1VzZG5Qb29sCQEAAAAFdmFsdWUAAAABCQAEJgAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAPV0FWRVNfVVNETl9Qb29sAgAAACFFbXB0eSBrZXkgU1dPUF9nb3Zlcm5hbmNlX2FkZHJlc3MAAAAAF2RlZmloZWxwZXJNYW5hZ2VyUHViS2V5CQACWQAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAZZGVmaWhlbHBlcl9tYW5hZ2VyX1B1YktleQIAAAAjRW1wdHkga2V5IGRlZmloZWxwZXJfbWFuYWdlcl9QdW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YW5jZQAAAAEFAAAACWNhbGxlclN0cgMJAABmAAAAAgUAAAALd2l0aGRyYXdBbXQFAAAADWNhbGxlckJhbGFuY2UJAAACAAAAAQIAAAAbd2l0aGRyYXdBbXQgPiBjYWxsZXJCYWxhbmNlCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQABLAAAAAIFAAAACWNhbGxlclN0cgUAAAAKa2V5QmFsYW5jZQkAAGUAAAACBQAAAA1jYWxsZXJCYWxhbmNlBQAAAAt3aXRoZHJhd0FtdAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAAC3dpdGhkcmF3QW10BQAAAAR1bml0BQAAAANuaWwAAAABaQEAAAAIc2h1dGRvd24AAAAAAwkBAAAAASEAAAABBQAAABBpc1Byb3RvY29sQWN0aXZlCQAAAgAAAAECAAAAF1Byb3RvbCBzdG9wcGVkIGJ5IGFkbWluAwkBAAAAASEAAAABCQEAAAAPY29udGFpbnNFbGVtZW50AAAAAgkABEwAAAACBQAAAAxhZG1pblB1YktleTEJAARMAAAAAgUAAAAMYWRtaW5QdWJLZXkyCQAETAAAAAIFAAAADGFkbWluUHViS2V5MwkABEwAAAACBQAAABdkZWZpaGVscGVyTWFuYWdlclB1YktleQUAAAADbmlsCAUAAAABaQAAAA9jYWxsZXJQdWJsaWNLZXkJAAACAAAAAQIAAAAhT25seSBhZG1pbiBjYW4gY2FsbCB0aGlzIGZ1bmN0aW9uCQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACAgAAABBpc1Byb3RvY29sQWN0aXZlBwUAAAADbmlsAAAAAHD6CW4=", "chainId": 84, "height": 1763723, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EzZTHNEoHpEMXLweurdkiaRzE3UaXmwmtujmaB5S4Aqq Next: 64QrNPvzCC2d6qBMo4UWPBMNKosw3hkmo1e2JxVqauRQ Diff:
Old | New | Differences | |
---|---|---|---|
82 | 82 | let automateBalance = valueOrErrorMessage(getInteger(this, (user + keyBalance)), (("Empty key user + keyBalance: " + user) + keyBalance)) | |
83 | 83 | let newBalance = (automateBalance - protocolFee) | |
84 | 84 | if ((0 > newBalance)) | |
85 | - | then throw(("Insufficient balance:" + toString(newBalance))) | |
85 | + | then throw(((("Insufficient new balance:" + toString(newBalance)) + " for user ") + user)) | |
86 | 86 | else [IntegerEntry((user + keyBalance), newBalance)] | |
87 | 87 | } | |
88 | 88 | } | |
93 | 93 | func replanishBalance () = if (!(isProtocolActive)) | |
94 | 94 | then throw("Protol stopped by admin") | |
95 | 95 | else { | |
96 | - | let $ | |
97 | - | let pmtAmount = $ | |
98 | - | let pmtAssetId = $ | |
96 | + | let $t037503825 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
97 | + | let pmtAmount = $t037503825._1 | |
98 | + | let pmtAssetId = $t037503825._2 | |
99 | 99 | if ((pmtAssetId != unit)) | |
100 | 100 | then throw("Only WAVES available for replanishment") | |
101 | 101 | 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 = value(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 | func calcWavesProtocolFee () = { | |
36 | 36 | let balanceUSDN = valueOrErrorMessage(getInteger(WavesUsdnPool, "B_asset_balance"), "Empty B_asset_balance") | |
37 | 37 | let balanceWAVES = valueOrErrorMessage(getInteger(WavesUsdnPool, "A_asset_balance"), "Empty A_asset_balance") | |
38 | 38 | let feeInUSDN = valueOrErrorMessage(getInteger(this, "protocol_fee_in_usdn"), "Empty protocol_fee_in_usdn") | |
39 | 39 | let priceWAVES = fraction(feeInUSDN, balanceWAVES, balanceUSDN) | |
40 | 40 | priceWAVES | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | @Callable(i) | |
45 | 45 | func init (defihelperManagerPubKey,WavesUsdnPool,SWOPgovernanceAdr,feeInUSDN) = if (if (isDefined(getString(this, "WAVES_USDN_Pool"))) | |
46 | 46 | then true | |
47 | 47 | else isDefined(getString(this, "defihelper_manager_PubKey"))) | |
48 | 48 | then throw("Already initialized") | |
49 | 49 | else [StringEntry("defihelper_manager_PubKey", defihelperManagerPubKey), StringEntry("WAVES_USDN_Pool", WavesUsdnPool), StringEntry("SWOP_governance", SWOPgovernanceAdr), IntegerEntry("protocol_fee_in_usdn", feeInUSDN), BooleanEntry("isProtocolActive", true)] | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | ||
53 | 53 | @Callable(i) | |
54 | 54 | func updateAutomateStatus (automate,status) = 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 [BooleanEntry(automate, status)] | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | ||
62 | 62 | @Callable(i) | |
63 | 63 | func updateProtocolFee (newFeeInUSDN) = if (!(isProtocolActive)) | |
64 | 64 | then throw("Protol stopped by admin") | |
65 | 65 | else if (!(containsElement([defihelperManagerPubKey], i.callerPublicKey))) | |
66 | 66 | then throw("Only admin can call this function") | |
67 | 67 | else [IntegerEntry("protocol_fee_in_usdn", newFeeInUSDN)] | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | 72 | func extractFee (user,isFeeExtract) = if (!(isProtocolActive)) | |
73 | 73 | then throw("Protol stopped by admin") | |
74 | 74 | else { | |
75 | 75 | let isAutomateActive = valueOrErrorMessage(getBoolean(this, toString(i.caller)), ("Empty key i.caller: " + toString(i.caller))) | |
76 | 76 | if (!(isAutomateActive)) | |
77 | 77 | then throw("This automate is inactive") | |
78 | 78 | else { | |
79 | 79 | let protocolFee = if (isFeeExtract) | |
80 | 80 | then calcWavesProtocolFee() | |
81 | 81 | else 0 | |
82 | 82 | let automateBalance = valueOrErrorMessage(getInteger(this, (user + keyBalance)), (("Empty key user + keyBalance: " + user) + keyBalance)) | |
83 | 83 | let newBalance = (automateBalance - protocolFee) | |
84 | 84 | if ((0 > newBalance)) | |
85 | - | then throw(("Insufficient balance:" + toString(newBalance))) | |
85 | + | then throw(((("Insufficient new balance:" + toString(newBalance)) + " for user ") + user)) | |
86 | 86 | else [IntegerEntry((user + keyBalance), newBalance)] | |
87 | 87 | } | |
88 | 88 | } | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | ||
92 | 92 | @Callable(i) | |
93 | 93 | func replanishBalance () = if (!(isProtocolActive)) | |
94 | 94 | then throw("Protol stopped by admin") | |
95 | 95 | else { | |
96 | - | let $ | |
97 | - | let pmtAmount = $ | |
98 | - | let pmtAssetId = $ | |
96 | + | let $t037503825 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
97 | + | let pmtAmount = $t037503825._1 | |
98 | + | let pmtAssetId = $t037503825._2 | |
99 | 99 | if ((pmtAssetId != unit)) | |
100 | 100 | then throw("Only WAVES available for replanishment") | |
101 | 101 | else { | |
102 | 102 | let callerStr = toString(i.caller) | |
103 | 103 | let callerBalance = getCallerBalance(callerStr) | |
104 | 104 | [IntegerEntry((callerStr + keyBalance), (callerBalance + pmtAmount))] | |
105 | 105 | } | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | @Callable(i) | |
111 | 111 | func withdraw (withdrawAmt) = if (!(isProtocolActive)) | |
112 | 112 | then throw("Protol stopped by admin") | |
113 | 113 | else { | |
114 | 114 | let callerStr = toString(i.caller) | |
115 | 115 | let callerBalance = getCallerBalance(callerStr) | |
116 | 116 | if ((withdrawAmt > callerBalance)) | |
117 | 117 | then throw("withdrawAmt > callerBalance") | |
118 | 118 | else [IntegerEntry((callerStr + keyBalance), (callerBalance - withdrawAmt)), ScriptTransfer(i.caller, withdrawAmt, unit)] | |
119 | 119 | } | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | 123 | @Callable(i) | |
124 | 124 | func shutdown () = if (!(isProtocolActive)) | |
125 | 125 | then throw("Protol stopped by admin") | |
126 | 126 | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, defihelperManagerPubKey], i.callerPublicKey))) | |
127 | 127 | then throw("Only admin can call this function") | |
128 | 128 | else [BooleanEntry("isProtocolActive", false)] | |
129 | 129 | ||
130 | 130 |
github/deemru/w8io/026f985 37.31 ms ◑