tx · 7iTTAt7vkMLEitMPw4ehLrVto1YiETMZwgnTv3UEQZLC 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J: -0.01400000 Waves 2021.10.25 17:58 [1761994] smart account 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J > SELF 0.00000000 Waves
{ "type": 13, "id": "7iTTAt7vkMLEitMPw4ehLrVto1YiETMZwgnTv3UEQZLC", "fee": 1400000, "feeAssetId": null, "timestamp": 1635173917285, "version": 1, "sender": "3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J", "senderPublicKey": "B7ayemTreAJnAMuzH9P3MnVXhpL6PTtRBrV29h7EUS1H", "proofs": [ "2EBegLJ8CF2JfG4F4Qtoa8NzDF7ANPWtxmFr6Wzkj6Yx6xhKypTZo9rgnUh9hrmqbFx9p4qkeywcEHnQ5MLLmY8k" ], "script": "base64:AAIFAAAAAAAAACMIAhIGCgQICAgBEgQKAggEEgMKAQESAwoBCBIAEgMKAQESAAAAAAsAAAAADlNXT1Bnb3Zlcm5hbmNlCQAEJgAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAPU1dPUF9nb3Zlcm5hbmNlAgAAACFFbXB0eSBrZXkgU1dPUF9nb3Zlcm5hbmNlX2FkZHJlc3MAAAAADVdhdmVzVXNkblBvb2wJAQAAAAV2YWx1ZQAAAAEJAAQmAAAAAQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAAA9XQVZFU19VU0ROX1Bvb2wCAAAAIUVtcHR5IGtleSBTV09QX2dvdmVybmFuY2VfYWRkcmVzcwAAAAAXZGVmaWhlbHBlck1hbmFnZXJQdWJLZXkJAAJZAAAAAQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAABlkZWZpaGVscGVyX21hbmFnZXJfUHViS2V5AgAAACNFbXB0eSBrZXkgZGVmaWhlbHBlcl9t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JhbGFuY2UAAAABBQAAAAljYWxsZXJTdHIDCQAAZgAAAAIFAAAAC3dpdGhkcmF3QW10BQAAAA1jYWxsZXJCYWxhbmNlCQAAAgAAAAECAAAAG3dpdGhkcmF3QW10ID4gY2FsbGVyQmFsYW5jZQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkAASwAAAACBQAAAAljYWxsZXJTdHIFAAAACmtleUJhbGFuY2UJAABlAAAAAgUAAAANY2FsbGVyQmFsYW5jZQUAAAALd2l0aGRyYXdBbXQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAt3aXRoZHJhd0FtdAUAAAAEdW5pdAUAAAADbmlsAAAAAWkBAAAACHNodXRkb3duAAAAAAMJAQAAAAEhAAAAAQUAAAAQaXNQcm90b2NvbEFjdGl2ZQkAAAIAAAABAgAAABdQcm90b2wgc3RvcHBlZCBieSBhZG1pbgMJAQAAAAEhAAAAAQkBAAAAD2NvbnRhaW5zRWxlbWVudAAAAAIJAARMAAAAAgUAAAAMYWRtaW5QdWJLZXkxCQAETAAAAAIFAAAADGFkbWluUHViS2V5MgkABEwAAAACBQAAAAxhZG1pblB1YktleTMJAARMAAAAAgUAAAAXZGVmaWhlbHBlck1hbmFnZXJQdWJLZXkFAAAAA25pbAgFAAAAAWkAAAAPY2FsbGVyUHVibGljS2V5CQAAAgAAAAECAAAAIU9ubHkgYWRtaW4gY2FuIGNhbGwgdGhpcyBmdW5jdGlvbgkABEwAAAACCQEAAAAMQm9vbGVhbkVudHJ5AAAAAgIAAAAQaXNQcm90b2NvbEFjdGl2ZQcFAAAAA25pbAAAAACzQSh9", "chainId": 84, "height": 1761994, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Bt4VnjXRnW3DdyHzpWcrNYkPJJT17pSt1dcYm5AHzLDx Next: GYcNiEmFAhfXeYXEKy7gwFXxT8BWMp7FT41nmcdjWM8d Diff:
Old | New | Differences | |
---|---|---|---|
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 | - | let priceWAVES = (fraction(100000000, balanceWAVES, | |
39 | + | let priceWAVES = (fraction((100000000 * feeInUSDN), balanceWAVES, balanceUSDN) / 100) | |
40 | 40 | priceWAVES | |
41 | 41 | } | |
42 | 42 |
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 | - | let priceWAVES = (fraction(100000000, balanceWAVES, | |
39 | + | let priceWAVES = (fraction((100000000 * feeInUSDN), balanceWAVES, balanceUSDN) / 100) | |
40 | 40 | priceWAVES | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | @Callable(i) | |
45 | 45 | func init (defihelperManagerPubKey,WavesUsdnPool,SWOPgovernanceAdr,newFeeInUSDN) = 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", newFeeInUSDN), 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) = 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 = calcWavesProtocolFee() | |
80 | 80 | if (true) | |
81 | 81 | then throw(toString(protocolFee)) | |
82 | 82 | else { | |
83 | 83 | let automateBalance = valueOrErrorMessage(getInteger(this, (user + keyBalance)), (("Empty key user + keyBalance: " + user) + keyBalance)) | |
84 | 84 | let newBalance = (automateBalance - protocolFee) | |
85 | 85 | if ((0 > newBalance)) | |
86 | 86 | then throw(("Insufficient balance:" + toString(newBalance))) | |
87 | 87 | else [IntegerEntry((user + keyBalance), newBalance)] | |
88 | 88 | } | |
89 | 89 | } | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | ||
94 | 94 | @Callable(i) | |
95 | 95 | func replanishBalance () = if (!(isProtocolActive)) | |
96 | 96 | then throw("Protol stopped by admin") | |
97 | 97 | else { | |
98 | 98 | let $t039073982 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
99 | 99 | let pmtAmount = $t039073982._1 | |
100 | 100 | let pmtAssetId = $t039073982._2 | |
101 | 101 | if ((pmtAssetId != unit)) | |
102 | 102 | then throw("Only WAVES available for replanishment") | |
103 | 103 | else { | |
104 | 104 | let callerStr = toString(i.caller) | |
105 | 105 | let callerBalance = getCallerBalance(callerStr) | |
106 | 106 | [IntegerEntry((callerStr + keyBalance), (callerBalance + pmtAmount))] | |
107 | 107 | } | |
108 | 108 | } | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | 112 | @Callable(i) | |
113 | 113 | func withdraw (withdrawAmt) = if (!(isProtocolActive)) | |
114 | 114 | then throw("Protol stopped by admin") | |
115 | 115 | else { | |
116 | 116 | let callerStr = toString(i.caller) | |
117 | 117 | let callerBalance = getCallerBalance(callerStr) | |
118 | 118 | if ((withdrawAmt > callerBalance)) | |
119 | 119 | then throw("withdrawAmt > callerBalance") | |
120 | 120 | else [IntegerEntry((callerStr + keyBalance), (callerBalance - withdrawAmt)), ScriptTransfer(i.caller, withdrawAmt, unit)] | |
121 | 121 | } | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | ||
125 | 125 | @Callable(i) | |
126 | 126 | func shutdown () = if (!(isProtocolActive)) | |
127 | 127 | then throw("Protol stopped by admin") | |
128 | 128 | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, defihelperManagerPubKey], i.callerPublicKey))) | |
129 | 129 | then throw("Only admin can call this function") | |
130 | 130 | else [BooleanEntry("isProtocolActive", false)] | |
131 | 131 | ||
132 | 132 |
github/deemru/w8io/169f3d6 28.95 ms ◑