tx · EzZTHNEoHpEMXLweurdkiaRzE3UaXmwmtujmaB5S4Aqq

3NDCcfUw3NdSjTPHukj85CQZrt1WmB9aWA9:  -0.01400000 Waves

2021.10.26 22:51 [1763709] smart account 3NDCcfUw3NdSjTPHukj85CQZrt1WmB9aWA9 > SELF 0.00000000 Waves

{ "type": 13, "id": "EzZTHNEoHpEMXLweurdkiaRzE3UaXmwmtujmaB5S4Aqq", "fee": 1400000, "feeAssetId": null, "timestamp": 1635277911186, "version": 1, "sender": "3NDCcfUw3NdSjTPHukj85CQZrt1WmB9aWA9", "senderPublicKey": "Ft1jz1c1eR7JbyAxdiSRJ1d4qkBH7DSdv89PspmNK5dq", "proofs": [ "MHuCkkxJxRa8XnzijXSq8cQXtKY6J3UiSshXV8D2jXW9oQvWmP94Pyk5tPi9xsQeNiTuAu5HBJJhNuzyhEfT2J2" ], "script": "base64:AAIFAAAAAAAAACQIAhIGCgQICAgBEgQKAggEEgMKAQESBAoCCAQSABIDCgEBEgAAAAALAAAAAA5TV09QZ292ZXJuYW5jZQkABCYAAAABCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAAD1NXT1BfZ292ZXJuYW5jZQIAAAAhRW1wdHkga2V5IFNXT1BfZ292ZXJuYW5jZV9hZGRyZXNzAAAAAA1XYXZlc1VzZG5Qb29sCQEAAAAFdmFsdWUAAAABCQAEJgAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAPV0FWRVNfVVNETl9Qb29sAgAAACFFbXB0eSBrZXkgU1dPUF9nb3Zlcm5hbmNlX2FkZHJlc3MAAAAAF2RlZmloZWxwZXJNYW5hZ2VyUHViS2V5CQACWQAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAZZGVmaWhlbHBlcl9tYW5hZ2VyX1B1YktleQIAAAAjRW1wdHkga2V5IGRlZmloZWxwZXJfbWFu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AC3dpdGhkcmF3QW10BQAAAA1jYWxsZXJCYWxhbmNlCQAAAgAAAAECAAAAG3dpdGhkcmF3QW10ID4gY2FsbGVyQmFsYW5jZQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkAASwAAAACBQAAAAljYWxsZXJTdHIFAAAACmtleUJhbGFuY2UJAABlAAAAAgUAAAANY2FsbGVyQmFsYW5jZQUAAAALd2l0aGRyYXdBbXQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAt3aXRoZHJhd0FtdAUAAAAEdW5pdAUAAAADbmlsAAAAAWkBAAAACHNodXRkb3duAAAAAAMJAQAAAAEhAAAAAQUAAAAQaXNQcm90b2NvbEFjdGl2ZQkAAAIAAAABAgAAABdQcm90b2wgc3RvcHBlZCBieSBhZG1pbgMJAQAAAAEhAAAAAQkBAAAAD2NvbnRhaW5zRWxlbWVudAAAAAIJAARMAAAAAgUAAAAMYWRtaW5QdWJLZXkxCQAETAAAAAIFAAAADGFkbWluUHViS2V5MgkABEwAAAACBQAAAAxhZG1pblB1YktleTMJAARMAAAAAgUAAAAXZGVmaWhlbHBlck1hbmFnZXJQdWJLZXkFAAAAA25pbAgFAAAAAWkAAAAPY2FsbGVyUHVibGljS2V5CQAAAgAAAAECAAAAIU9ubHkgYWRtaW4gY2FuIGNhbGwgdGhpcyBmdW5jdGlvbgkABEwAAAACCQEAAAAMQm9vbGVhbkVudHJ5AAAAAgIAAAAQaXNQcm90b2NvbEFjdGl2ZQcFAAAAA25pbAAAAAB5f6wF", "chainId": 84, "height": 1763709, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: A4fk2dJdU4AkEp7eFUNcteuBJrvLd668bPRM5v73cpsk Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 5 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let SWOPgovernance = addressFromString(valueOrElse(getString(this, "SWOP_governance"), "Empty key SWOP_governance_address"))
5+
6+let WavesUsdnPool = value(addressFromString(valueOrElse(getString(this, "WAVES_USDN_Pool"), "Empty key SWOP_governance_address")))
7+
8+let defihelperManagerPubKey = fromBase58String(valueOrElse(getString(this, "defihelper_manager_PubKey"), "Empty key defihelper_manager_PubKey"))
9+
10+let adminPubKey1 = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv'
11+
12+let adminPubKey2 = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv'
13+
14+let adminPubKey3 = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv'
15+
16+let keyBalance = "_balance"
17+
18+let keyFeeInUSDN = "fee_in_usdn"
19+
20+let isProtocolActive = valueOrErrorMessage(getBoolean(this, "isProtocolActive"), "Empty key isProtocolActive")
21+
22+func getCallerBalance (callerStr) = {
23+ let callerBalance = match getInteger(this, (callerStr + keyBalance)) {
24+ case cb: Int =>
25+ cb
26+ case empty: Unit =>
27+ 0
28+ case _ =>
29+ throw("Match error")
30+ }
31+ callerBalance
32+ }
33+
34+
35+func calcWavesProtocolFee () = {
36+ let balanceUSDN = valueOrErrorMessage(getInteger(WavesUsdnPool, "B_asset_balance"), "Empty B_asset_balance")
37+ let balanceWAVES = valueOrErrorMessage(getInteger(WavesUsdnPool, "A_asset_balance"), "Empty A_asset_balance")
38+ let feeInUSDN = valueOrErrorMessage(getInteger(this, "protocol_fee_in_usdn"), "Empty protocol_fee_in_usdn")
39+ let priceWAVES = fraction(feeInUSDN, balanceWAVES, balanceUSDN)
40+ priceWAVES
41+ }
42+
43+
44+@Callable(i)
45+func init (defihelperManagerPubKey,WavesUsdnPool,SWOPgovernanceAdr,feeInUSDN) = if (if (isDefined(getString(this, "WAVES_USDN_Pool")))
46+ then true
47+ else isDefined(getString(this, "defihelper_manager_PubKey")))
48+ then throw("Already initialized")
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+
51+
52+
53+@Callable(i)
54+func updateAutomateStatus (automate,status) = if (!(isProtocolActive))
55+ then throw("Protol stopped by admin")
56+ else if (!(containsElement([defihelperManagerPubKey], i.callerPublicKey)))
57+ then throw("Only admin can call this function")
58+ else [BooleanEntry(automate, status)]
59+
60+
61+
62+@Callable(i)
63+func updateProtocolFee (newFeeInUSDN) = if (!(isProtocolActive))
64+ then throw("Protol stopped by admin")
65+ else if (!(containsElement([defihelperManagerPubKey], i.callerPublicKey)))
66+ then throw("Only admin can call this function")
67+ else [IntegerEntry("protocol_fee_in_usdn", newFeeInUSDN)]
68+
69+
70+
71+@Callable(i)
72+func extractFee (user,isFeeExtract) = if (!(isProtocolActive))
73+ then throw("Protol stopped by admin")
74+ else {
75+ let isAutomateActive = valueOrErrorMessage(getBoolean(this, toString(i.caller)), ("Empty key i.caller: " + toString(i.caller)))
76+ if (!(isAutomateActive))
77+ then throw("This automate is inactive")
78+ else {
79+ let protocolFee = if (isFeeExtract)
80+ then calcWavesProtocolFee()
81+ else 0
82+ let automateBalance = valueOrErrorMessage(getInteger(this, (user + keyBalance)), (("Empty key user + keyBalance: " + user) + keyBalance))
83+ let newBalance = (automateBalance - protocolFee)
84+ if ((0 > newBalance))
85+ then throw(("Insufficient balance:" + toString(newBalance)))
86+ else [IntegerEntry((user + keyBalance), newBalance)]
87+ }
88+ }
89+
90+
91+
92+@Callable(i)
93+func replanishBalance () = if (!(isProtocolActive))
94+ then throw("Protol stopped by admin")
95+ else {
96+ let $t037243799 = $Tuple2(i.payments[0].amount, i.payments[0].assetId)
97+ let pmtAmount = $t037243799._1
98+ let pmtAssetId = $t037243799._2
99+ if ((pmtAssetId != unit))
100+ then throw("Only WAVES available for replanishment")
101+ else {
102+ let callerStr = toString(i.caller)
103+ let callerBalance = getCallerBalance(callerStr)
104+[IntegerEntry((callerStr + keyBalance), (callerBalance + pmtAmount))]
105+ }
106+ }
107+
108+
109+
110+@Callable(i)
111+func withdraw (withdrawAmt) = if (!(isProtocolActive))
112+ then throw("Protol stopped by admin")
113+ else {
114+ let callerStr = toString(i.caller)
115+ let callerBalance = getCallerBalance(callerStr)
116+ if ((withdrawAmt > callerBalance))
117+ then throw("withdrawAmt > callerBalance")
118+ else [IntegerEntry((callerStr + keyBalance), (callerBalance - withdrawAmt)), ScriptTransfer(i.caller, withdrawAmt, unit)]
119+ }
120+
121+
122+
123+@Callable(i)
124+func shutdown () = if (!(isProtocolActive))
125+ then throw("Protol stopped by admin")
126+ else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, defihelperManagerPubKey], i.callerPublicKey)))
127+ then throw("Only admin can call this function")
128+ else [BooleanEntry("isProtocolActive", false)]
129+
130+

github/deemru/w8io/026f985 
20.18 ms