tx · 3j52eLVYVDuorqRuLD72tVUribSSFNaQPZ81aXnR5XNe 3Mpi3QbvFhQsrszgyTFuG1bt8kc9BdDWawi: -0.01400000 Waves 2021.10.31 12:58 [1770335] smart account 3Mpi3QbvFhQsrszgyTFuG1bt8kc9BdDWawi > SELF 0.00000000 Waves
{ "type": 13, "id": "3j52eLVYVDuorqRuLD72tVUribSSFNaQPZ81aXnR5XNe", "fee": 1400000, "feeAssetId": null, "timestamp": 1635674385119, "version": 1, "sender": "3Mpi3QbvFhQsrszgyTFuG1bt8kc9BdDWawi", "senderPublicKey": "43YXEdz1m2UqUbnKrEMbVAj85oFMTFSueQnQk2Tuhxg3", "proofs": [ "MFwprmCNarRU2adS6qFDPdRT7TjpPHNzfxGgEizFvNuG5RrpUZQdsHbTXanMuEBmTucVTCifzUUbtsdDb3EeDPA" ], "script": "base64:AAIFAAAAAAAAACEIAhIAEgQKAggEEgQKAggEEgMKAQgSAwoBARIDCgEIEgAAAAATAAAAAAZvcmFjbGUJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVSHvFG381ml7KNO68DKO7kWwhLf3O+iLwUAAAAAEVNXT1Bnb3Zlcm5hbmNlQWRyCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABCQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAGb3JhY2xlAgAAAA9zd29wX2dvdmVybmFuY2UCAAAAGUVtcHR5IGtleSBzd29wX2dvdmVybmFuY2UAAAAADVdhdmVzVXNkblBvb2wJAQAAAAV2YWx1ZQAAAAEJAAQmAAAAAQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAZvcmFjbGUCAAAAD1dBVkVTX1VTRE5fcG9vbAIAAAAhRW1wdHkga2V5IFNXT1BfZ292ZXJuYW5jZV9hZGRyZXNzAAAAAAljb25zdW1lcnMJAAS1AAAAAgkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAZvcmFjbGU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CBub3QgYXBwcm92ZWQgYnkgYWRtaW5zBuETHGE=", "chainId": 84, "height": 1770335, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let oracle = Address(base58'3N2HnbTykz6n3YcFoWsx28mtk5fuAGqvDG8') | |
5 | + | ||
6 | + | let SWOPgovernanceAdr = addressFromStringValue(valueOrErrorMessage(getString(oracle, "swop_governance"), "Empty key swop_governance")) | |
7 | + | ||
8 | + | let WavesUsdnPool = value(addressFromString(valueOrElse(getString(oracle, "WAVES_USDN_pool"), "Empty key SWOP_governance_address"))) | |
9 | + | ||
10 | + | let consumers = split(valueOrElse(getString(oracle, "consumers"), "Empty key consumer"), ",") | |
11 | + | ||
12 | + | let admin1 = addressFromStringValue(valueOrElse(getString(oracle, "admin_1"), "Empty key admin_1")) | |
13 | + | ||
14 | + | let admin2 = addressFromStringValue(valueOrElse(getString(oracle, "admin_2"), "Empty key admin_2")) | |
15 | + | ||
16 | + | let admin3 = addressFromStringValue(valueOrElse(getString(oracle, "admin_3"), "Empty key admin_3")) | |
17 | + | ||
18 | + | let feeInUSDN = valueOrErrorMessage(getInteger(oracle, "protocol_fee_in_usdn"), "Empty protocol_fee_in_usdn") | |
19 | + | ||
20 | + | let isProtocolActive = valueOrErrorMessage(getBoolean(oracle, "is_protocol_active"), "Empty key is_protocol_active") | |
21 | + | ||
22 | + | let keyBalance = "_balance" | |
23 | + | ||
24 | + | let keyFeeInUSDN = "fee_in_usdn" | |
25 | + | ||
26 | + | let keyIsDappActive = "is_dapp_active" | |
27 | + | ||
28 | + | let keyOverallBalance = "overall_balance" | |
29 | + | ||
30 | + | let isDappActive = valueOrErrorMessage(getBoolean(this, keyIsDappActive), "Empty key is_dapp_active") | |
31 | + | ||
32 | + | let orverallBalance = valueOrErrorMessage(getInteger(this, keyOverallBalance), "Empty key overall_balance") | |
33 | + | ||
34 | + | let blockchainFee = 500000 | |
35 | + | ||
36 | + | func getUserBalance (userStr) = { | |
37 | + | let userBalance = match getInteger(this, (userStr + keyBalance)) { | |
38 | + | case ub: Int => | |
39 | + | ub | |
40 | + | case empty: Unit => | |
41 | + | 0 | |
42 | + | case _ => | |
43 | + | throw("Match error") | |
44 | + | } | |
45 | + | userBalance | |
46 | + | } | |
47 | + | ||
48 | + | ||
49 | + | func calcWavesProtocolFee () = { | |
50 | + | let balanceUSDN = valueOrErrorMessage(getInteger(WavesUsdnPool, "B_asset_balance"), "Empty B_asset_balance") | |
51 | + | let balanceWAVES = valueOrErrorMessage(getInteger(WavesUsdnPool, "A_asset_balance"), "Empty A_asset_balance") | |
52 | + | let feeInWAVES = fraction(feeInUSDN, balanceWAVES, balanceUSDN) | |
53 | + | (feeInWAVES + blockchainFee) | |
54 | + | } | |
55 | + | ||
56 | + | ||
57 | + | func isTransactionApproved (txStr) = { | |
58 | + | let admin1Signed = if (valueOrElse(getBoolean(admin1, "txStr"), false)) | |
59 | + | then 1 | |
60 | + | else 0 | |
61 | + | let admin2Signed = if (valueOrElse(getBoolean(admin2, "txStr"), false)) | |
62 | + | then 1 | |
63 | + | else 0 | |
64 | + | let admin3Signed = if (valueOrElse(getBoolean(admin3, "txStr"), false)) | |
65 | + | then 1 | |
66 | + | else 0 | |
67 | + | (((admin1Signed + admin2Signed) + admin3Signed) >= 2) | |
68 | + | } | |
69 | + | ||
70 | + | ||
71 | + | @Callable(i) | |
72 | + | func init () = if (if (isDefined(getString(this, "is_dapp_active"))) | |
73 | + | then true | |
74 | + | else isDefined(getInteger(this, "overall_balance"))) | |
75 | + | then throw("Already initialized") | |
76 | + | else [IntegerEntry("overall_balance", 0), BooleanEntry("is_dapp_active", true)] | |
77 | + | ||
78 | + | ||
79 | + | ||
80 | + | @Callable(i) | |
81 | + | func updateAutomateStatus (automate,status) = if (!(if (isProtocolActive) | |
82 | + | then isDappActive | |
83 | + | else false)) | |
84 | + | then throw("Protol stopped by admin") | |
85 | + | else if (!(containsElement(consumers, toBase58String(i.caller.bytes)))) | |
86 | + | then throw("Only admin can call this function") | |
87 | + | else [BooleanEntry(automate, status)] | |
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | @Callable(i) | |
92 | + | func extractFee (user,isFeeExtract) = if (!(if (isProtocolActive) | |
93 | + | then isDappActive | |
94 | + | else false)) | |
95 | + | then throw("Protol stopped by admin") | |
96 | + | else { | |
97 | + | let isAutomateActive = valueOrErrorMessage(getBoolean(this, toString(i.caller)), ("Empty key i.caller: " + toString(i.caller))) | |
98 | + | if (!(isAutomateActive)) | |
99 | + | then throw("This automate is inactive") | |
100 | + | else { | |
101 | + | let protocolFee = if (isFeeExtract) | |
102 | + | then calcWavesProtocolFee() | |
103 | + | else 0 | |
104 | + | let userBalance = valueOrErrorMessage(getInteger(this, (user + keyBalance)), (("Empty key user + keyBalance: " + user) + keyBalance)) | |
105 | + | let newUserBalance = (userBalance - protocolFee) | |
106 | + | let newOrverallBalance = (orverallBalance - protocolFee) | |
107 | + | if ((0 > newUserBalance)) | |
108 | + | then throw(((("Insufficient new balance:" + toString(newUserBalance)) + " for user ") + user)) | |
109 | + | else [IntegerEntry((user + keyBalance), newUserBalance), IntegerEntry(keyOverallBalance, newOrverallBalance)] | |
110 | + | } | |
111 | + | } | |
112 | + | ||
113 | + | ||
114 | + | ||
115 | + | @Callable(i) | |
116 | + | func replenishBalance (userToReplenish) = if (!(if (isProtocolActive) | |
117 | + | then isDappActive | |
118 | + | else false)) | |
119 | + | then throw("Protol stopped by admin") | |
120 | + | else { | |
121 | + | let userToReplenishAddress = valueOrErrorMessage(addressFromString(userToReplenish), "Argument must be base58 string") | |
122 | + | let $t045614636 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
123 | + | let pmtAmount = $t045614636._1 | |
124 | + | let pmtAssetId = $t045614636._2 | |
125 | + | if ((pmtAssetId != unit)) | |
126 | + | then throw("Only WAVES available for replenishment") | |
127 | + | else { | |
128 | + | let userToReplenishBalance = getUserBalance(userToReplenish) | |
129 | + | let newUserBalance = (userToReplenishBalance + pmtAmount) | |
130 | + | let newOrverallBalance = (orverallBalance + pmtAmount) | |
131 | + | [IntegerEntry((toBase58String(userToReplenishAddress.bytes) + keyBalance), newUserBalance), IntegerEntry(keyOverallBalance, newOrverallBalance)] | |
132 | + | } | |
133 | + | } | |
134 | + | ||
135 | + | ||
136 | + | ||
137 | + | @Callable(i) | |
138 | + | func withdraw (withdrawAmt) = if (!(if (isProtocolActive) | |
139 | + | then isDappActive | |
140 | + | else false)) | |
141 | + | then throw("Protol stopped by admin") | |
142 | + | else { | |
143 | + | let callerStr = toString(i.caller) | |
144 | + | let callerBalance = getUserBalance(callerStr) | |
145 | + | let newCallerBalance = (callerBalance - withdrawAmt) | |
146 | + | let newOrverallBalance = (orverallBalance - withdrawAmt) | |
147 | + | if ((withdrawAmt > callerBalance)) | |
148 | + | then throw("withdrawAmt > callerBalance") | |
149 | + | else [IntegerEntry((callerStr + keyBalance), newCallerBalance), IntegerEntry(keyOverallBalance, newOrverallBalance), ScriptTransfer(i.caller, withdrawAmt, unit), BooleanEntry(keyIsDappActive, true)] | |
150 | + | } | |
151 | + | ||
152 | + | ||
153 | + | ||
154 | + | @Callable(i) | |
155 | + | func incomeProtocolWithdraw (addresForSendingIncome) = if (!(if (isProtocolActive) | |
156 | + | then isDappActive | |
157 | + | else false)) | |
158 | + | then throw("Protol stopped by admin") | |
159 | + | else if (!(isTransactionApproved(toBase58String(i.transactionId)))) | |
160 | + | then throw("Transaction id not approved by admins") | |
161 | + | else { | |
162 | + | let income = (wavesBalance(this).available - orverallBalance) | |
163 | + | if ((0 >= income)) | |
164 | + | then throw("income <= 0 ") | |
165 | + | else [ScriptTransfer(addressFromStringValue(addresForSendingIncome), income, unit)] | |
166 | + | } | |
167 | + | ||
168 | + | ||
169 | + | ||
170 | + | @Callable(i) | |
171 | + | func shutdownDapp () = if (!(isDappActive)) | |
172 | + | then throw("Protol stopped by admin") | |
173 | + | else if (if (!(containsElement([admin1, admin2, admin3], i.caller))) | |
174 | + | then !(containsElement(consumers, toBase58String(i.caller.bytes))) | |
175 | + | else false) | |
176 | + | then throw("Only admin can call this function") | |
177 | + | else [BooleanEntry("is_dapp_active", false)] | |
178 | + | ||
179 | + | ||
180 | + | @Verifier(tx) | |
181 | + | func verify () = if (!(isTransactionApproved(toBase58String(tx.id)))) | |
182 | + | then throw("Transaction id not approved by admins") | |
183 | + | else true | |
184 | + |
github/deemru/w8io/026f985 19.02 ms ◑