tx · 6HkGmmPw3FwSkeHnydmjHJJJK8nDxjMrReZEuRyctjMG 3MtsXxXqERvHEmkPiiuBESuixd9Y8qAU1PC: -0.14000000 Waves 2022.10.18 17:27 [2277956] smart account 3MtsXxXqERvHEmkPiiuBESuixd9Y8qAU1PC > SELF 0.00000000 Waves
{ "type": 13, "id": "6HkGmmPw3FwSkeHnydmjHJJJK8nDxjMrReZEuRyctjMG", "fee": 14000000, "feeAssetId": null, "timestamp": 1666103211181, "version": 2, "chainId": 84, "sender": "3MtsXxXqERvHEmkPiiuBESuixd9Y8qAU1PC", "senderPublicKey": "EBCSQaTtuxQBJyc62F142LxJ3hpQtCwuZ2z9kkoe6Vvt", "proofs": [ "3dzxBAHoo8u2RBE6nZJJfwr2zvxTZ26B6wSzqeuVmcW59WYHKvdjQHXyk1SfPATokc1fpLCxZUQTTgk6VPixXHA1", "SKiK949pccRHH8SxggyitEFtkKP3bUNi1YsJvJRgjmkhkoFCGDc6sfYJi8JLaQdfeqAZwnAX2kRGHeyM891KTDT" ], "script": "base64:BgIbCAISABIECgIICBIFCgMBBAESBAoCAQgSABIAPwAGb3JhY2xlCQEHQWRkcmVzcwEBGgFUSBOXDMDTM8wlMoC2KfenZGiAq+PMe0uZAAd2ZXJzaW9uAgUxLjAuMAAIa1ZlcnNpb24CB3ZlcnNpb24AB2tBY3RpdmUCBmFjdGl2ZQALa0FjdGl2ZUdsb2ICFGFjdGl2ZV9hbGxfY29udHJhY3RzAA9rTnVtYmVyT2ZWb3RpbmcCFHZvdGluZ19hY3RpdmVfbnVtYmVyAA1rSGVpZ2h0T2ZQb29sAg5fZmluaXNoX2hlaWdodAADa05vAg9fdG90YWxfdm90ZXNfbm8ABGtZZXMCEF90b3RhbF92b3Rlc195ZXMAB2tOb1VzZXICCF92b3RlX25vAAhrWWVzVXNlcgIJX3ZvdGVfeWVzAA9rU3RhdHVzT2ZWb3RpbmcCB19zdGF0dXMAD2tBbW91bnRPZlZvdGluZwIOdm90aW5nX2lkX2xh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AEFAWkDBQZhY3RpdmUJAAIBAhZEQXBwIGlzIGFscmVhZHkgYWN0aXZlCQDMCAIJAQxCb29sZWFuRW50cnkCBQdrQWN0aXZlBgkAzAgCCQELRGVsZXRlRW50cnkBBQZrQ2F1c2UFA25pbAECdHgBBnZlcmlmeQAEEmFkbWluUHViS2V5MVNpZ25lZAMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFDGFkbWluUHViS2V5MQABAAAEEmFkbWluUHViS2V5MlNpZ25lZAMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAEFDGFkbWluUHViS2V5MgABAAAEEmFkbWluUHViS2V5M1NpZ25lZAMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAIFDGFkbWluUHViS2V5MwABAAAJAGcCCQBkAgkAZAIFEmFkbWluUHViS2V5MVNpZ25lZAUSYWRtaW5QdWJLZXkyU2lnbmVkBRJhZG1pblB1YktleTNTaWduZWQAAub913Q=", "height": 2277956, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6NN1XcK3HGPbPXT9ZtW6qdWXB47267RkWpgVDcJvyNmd Next: 6sZEEaSg9e389m4azP6dugxRbKbPV1vYgw5e5vTySxUU Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let oracle = Address(base58'3MvVBtsXroQpy1tsPw21TU2ET9A8WfmrNjz') | |
5 | + | ||
4 | 6 | let version = "1.0.0" | |
5 | 7 | ||
6 | - | let | |
8 | + | let kVersion = "version" | |
7 | 9 | ||
8 | - | let | |
10 | + | let kActive = "active" | |
9 | 11 | ||
10 | - | let | |
12 | + | let kActiveGlob = "active_all_contracts" | |
11 | 13 | ||
12 | - | let | |
14 | + | let kNumberOfVoting = "voting_active_number" | |
13 | 15 | ||
14 | - | let | |
16 | + | let kHeightOfPool = "_finish_height" | |
15 | 17 | ||
16 | - | let | |
18 | + | let kNo = "_total_votes_no" | |
17 | 19 | ||
18 | - | let | |
20 | + | let kYes = "_total_votes_yes" | |
19 | 21 | ||
20 | - | let | |
22 | + | let kNoUser = "_vote_no" | |
21 | 23 | ||
22 | - | let | |
24 | + | let kYesUser = "_vote_yes" | |
23 | 25 | ||
24 | - | let | |
26 | + | let kStatusOfVoting = "_status" | |
25 | 27 | ||
26 | - | let | |
28 | + | let kAmountOfVoting = "voting_id_last" | |
27 | 29 | ||
28 | - | let | |
30 | + | let kMaxAmountOfVoting = "max_amount_voting" | |
29 | 31 | ||
30 | - | let | |
32 | + | let kMaxDayOfVoting = "max_day_voting" | |
31 | 33 | ||
32 | - | let | |
34 | + | let kCause = "shutdown_cause" | |
33 | 35 | ||
34 | - | let | |
36 | + | let kCancelCause = "_cancel_cause" | |
35 | 37 | ||
36 | - | let keyCancelCause = "_cancel_cause" | |
37 | - | ||
38 | - | let kUserTotalSWOP = "_SWOP_amount" | |
38 | + | let kUserTotalGSWOP = "_GSwop_amount" | |
39 | 39 | ||
40 | 40 | let kName = "_asset_name" | |
41 | 41 | ||
42 | 42 | let votingId = "_voting" | |
43 | - | ||
44 | - | let periodOfVoting = "period_voting" | |
45 | 43 | ||
46 | 44 | let activeVoteFirst = "voting_active_cell_1" | |
47 | 45 | ||
49 | 47 | ||
50 | 48 | let activeVoteThird = "voting_active_cell_3" | |
51 | 49 | ||
52 | - | let | |
50 | + | let kAdminPubKey1 = "admin_pub_1" | |
53 | 51 | ||
54 | - | let | |
52 | + | let kAdminPubKey2 = "admin_pub_2" | |
55 | 53 | ||
56 | - | let | |
54 | + | let kAdminPubKey3 = "admin_pub_3" | |
57 | 55 | ||
58 | - | let | |
56 | + | let kMoneyBoxAddress = "money_box_address" | |
59 | 57 | ||
60 | - | let | |
58 | + | let kGovAddress = "governance_address" | |
61 | 59 | ||
62 | - | let | |
60 | + | let kFarmingAddr = "farming_address" | |
63 | 61 | ||
64 | - | let | |
62 | + | let kUSDNAssetId = "usdn_asset_id" | |
65 | 63 | ||
66 | - | let | |
64 | + | let kSWOPid = "SWOP_id" | |
67 | 65 | ||
68 | - | let | |
66 | + | let numberOfVoting = getIntegerValue(this, kNumberOfVoting) | |
69 | 67 | ||
70 | - | let isActive = getBooleanValue(this, keyActive) | |
71 | - | ||
72 | - | let numberOfVoting = getIntegerValue(this, keyNumberOfVoting) | |
73 | - | ||
74 | - | let amountOfVoting = getIntegerValue(this, keyAmountOfVoting) | |
68 | + | let amountOfVoting = getIntegerValue(this, kAmountOfVoting) | |
75 | 69 | ||
76 | 70 | let firstActiveVote = valueOrElse(getString(this, activeVoteFirst), "") | |
77 | 71 | ||
79 | 73 | ||
80 | 74 | let thirdActiveVote = valueOrElse(getString(this, activeVoteThird), "") | |
81 | 75 | ||
76 | + | let active = getBooleanValue(this, kActive) | |
77 | + | ||
78 | + | let activeGlob = valueOrElse(getBoolean(oracle, kActiveGlob), true) | |
79 | + | ||
82 | 80 | let comissionForInitalizationOfVoting = 1000000000 | |
83 | - | ||
84 | - | let scaleValue3 = 1000 | |
85 | - | ||
86 | - | let scaleValue8 = 100000000 | |
87 | - | ||
88 | - | let slippageToleranceDelimiter = 1000 | |
89 | - | ||
90 | - | let scaleValue8Digits = 8 | |
91 | 81 | ||
92 | 82 | let maxAmountOfVoting = 3 | |
93 | 83 | ||
94 | 84 | let maxDayOfVoting = 7 | |
95 | 85 | ||
96 | 86 | let votingPeriodLength = (1443 * maxDayOfVoting) | |
87 | + | ||
88 | + | func getBase58FromOracle (key) = match getString(oracle, key) { | |
89 | + | case string: String => | |
90 | + | fromBase58String(string) | |
91 | + | case nothing => | |
92 | + | throw((key + "is empty")) | |
93 | + | } | |
94 | + | ||
95 | + | ||
96 | + | let adminPubKey1 = getBase58FromOracle(kAdminPubKey1) | |
97 | + | ||
98 | + | let adminPubKey2 = getBase58FromOracle(kAdminPubKey2) | |
99 | + | ||
100 | + | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
101 | + | ||
102 | + | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
103 | + | ||
104 | + | let farmingAddr = Address(getBase58FromOracle(kFarmingAddr)) | |
105 | + | ||
106 | + | let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress)) | |
107 | + | ||
108 | + | let USDN = getBase58FromOracle(kUSDNAssetId) | |
109 | + | ||
110 | + | let SWOP = fromBase58String(getStringValue(farmingAddr, kSWOPid)) | |
111 | + | ||
112 | + | func isActive () = if (if (active) | |
113 | + | then activeGlob | |
114 | + | else false) | |
115 | + | then unit | |
116 | + | else throw("DApp is inactive at this moment") | |
117 | + | ||
118 | + | ||
119 | + | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
120 | + | then unit | |
121 | + | else throw("Only admin can call this function") | |
122 | + | ||
97 | 123 | ||
98 | 124 | func getAssetInfo (assetId) = match assetId { | |
99 | 125 | case id: ByteVector => | |
121 | 147 | let voting = poolsData[2] | |
122 | 148 | let newPools = (((((assetA + "_") + assetB) + "_") + voting) + votingId) | |
123 | 149 | let isNewPoolDefine = isDefined(getInteger(this, newPools)) | |
124 | - | let heightOfVoting = valueOrElse(getInteger(this, (voting + | |
125 | - | let statusOfVoting = valueOrElse(getBoolean(this, (voting + | |
150 | + | let heightOfVoting = valueOrElse(getInteger(this, (voting + kHeightOfPool)), 0) | |
151 | + | let statusOfVoting = valueOrElse(getBoolean(this, (voting + kStatusOfVoting)), true) | |
126 | 152 | if (isNewPoolDefine) | |
127 | 153 | then if ((heightOfVoting > height)) | |
128 | 154 | then if (statusOfVoting) | |
144 | 170 | else false) | |
145 | 171 | then { | |
146 | 172 | let voting = poolsData[2] | |
147 | - | let heightOfVoting = valueOrElse(getInteger(this, (voting + | |
148 | - | let statusOfVoting = valueOrElse(getBoolean(this, (voting + | |
173 | + | let heightOfVoting = valueOrElse(getInteger(this, (voting + kHeightOfPool)), 0) | |
174 | + | let statusOfVoting = valueOrElse(getBoolean(this, (voting + kStatusOfVoting)), true) | |
149 | 175 | if ((heightOfVoting > height)) | |
150 | 176 | then if (statusOfVoting) | |
151 | 177 | then "" | |
164 | 190 | ||
165 | 191 | ||
166 | 192 | func getActivePool (voting) = { | |
167 | - | let heightOfVoting = valueOrElse(getInteger(this, (toString(voting) + | |
168 | - | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + | |
193 | + | let heightOfVoting = valueOrElse(getInteger(this, (toString(voting) + kHeightOfPool)), 0) | |
194 | + | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + kStatusOfVoting)), true) | |
169 | 195 | let currentHeight = height | |
170 | 196 | if ((0 > voting)) | |
171 | 197 | then 0 | |
194 | 220 | else fromBase58String(assetStr) | |
195 | 221 | ||
196 | 222 | ||
197 | - | func isCallerInGovernance (user) = if ((valueOrElse(getInteger( | |
223 | + | func isCallerInGovernance (user) = if ((valueOrElse(getInteger(govAddress, (toString(user) + kUserTotalGSWOP)), 0) > 0)) | |
198 | 224 | then true | |
199 | 225 | else false | |
200 | 226 | ||
201 | 227 | ||
202 | - | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
203 | - | ||
204 | - | ||
205 | - | func throwInsufficientAvailableBalance (amount,assetName) = throw(((((("Insufficient DApp balance to pay " + toString(amount)) + " ") + assetName) + " due to staking.") + ". Please contact support in Telegram: https://t.me/swopfisupport")) | |
228 | + | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
206 | 229 | ||
207 | 230 | ||
208 | 231 | @Callable(i) | |
209 | 232 | func init () = if ((i.caller != this)) | |
210 | 233 | then throw("Only the DApp itself can call this function") | |
211 | - | else if (isDefined(getBoolean(this, | |
234 | + | else if (isDefined(getBoolean(this, kActive))) | |
212 | 235 | then throw("DApp is already active") | |
213 | 236 | else { | |
214 | 237 | let initNumberOfVoting = 0 | |
215 | 238 | let initAmountOfVoting = 0 | |
216 | 239 | let initKeyActive = true | |
217 | 240 | let activeInit = "" | |
218 | - | [StringEntry( | |
241 | + | [StringEntry(kVersion, version), BooleanEntry(kActive, initKeyActive), IntegerEntry(kNumberOfVoting, initNumberOfVoting), IntegerEntry(kAmountOfVoting, initAmountOfVoting), IntegerEntry(kMaxAmountOfVoting, maxAmountOfVoting), IntegerEntry(kMaxDayOfVoting, maxDayOfVoting), StringEntry(activeVoteFirst, activeInit), StringEntry(activeVoteSecond, activeInit), StringEntry(activeVoteThird, activeInit)] | |
219 | 242 | } | |
220 | 243 | ||
221 | 244 | ||
222 | 245 | ||
223 | 246 | @Callable(i) | |
224 | - | func initVotingForNewPool (assetA,assetB) = { | |
225 | - | let $ | |
226 | - | let pmtAmount = $ | |
227 | - | let pmtAssetId = $ | |
228 | - | let $ | |
229 | - | let poolAssetIdA = $ | |
230 | - | let poolAssetIdB = $ | |
247 | + | func initVotingForNewPool (assetA,assetB) = valueOrElse(isActive(), { | |
248 | + | let $t070647139 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
249 | + | let pmtAmount = $t070647139._1 | |
250 | + | let pmtAssetId = $t070647139._2 | |
251 | + | let $t071447243 = $Tuple2(getAssetInfoFromString(assetA), getAssetInfoFromString(assetB)) | |
252 | + | let poolAssetIdA = $t071447243._1 | |
253 | + | let poolAssetIdB = $t071447243._2 | |
231 | 254 | let unactiveVote = getUnactiveVotingPool() | |
232 | 255 | let newNumberOfVoting = getActiveVotingPoolAmount() | |
233 | 256 | let isPoolExists = isLastActivePoolExists(assetA, assetB) | |
234 | - | let $ | |
235 | - | let pmtStrAssetIdA = $ | |
236 | - | let pmtAssetNameA = $ | |
237 | - | let pmtDecimalsA = $ | |
238 | - | let $ | |
239 | - | let pmtStrAssetIdB = $ | |
240 | - | let pmtAssetNameB = $ | |
241 | - | let pmtDecimalsB = $ | |
242 | - | if ( | |
243 | - | then throw(" | |
244 | - | else if ( | |
245 | - | then throw(" | |
246 | - | else if ( | |
247 | - | then throw(" | |
248 | - | else if ( | |
249 | - | then | |
250 | - | else ( | |
251 | - | then | |
252 | - | else | |
253 | - | then throw(" | |
254 | - | else if (( | |
255 | - | then throw("You | |
256 | - | else if (if (( | |
257 | + | let $t074137491 = getAssetInfo(poolAssetIdA) | |
258 | + | let pmtStrAssetIdA = $t074137491._1 | |
259 | + | let pmtAssetNameA = $t074137491._2 | |
260 | + | let pmtDecimalsA = $t074137491._3 | |
261 | + | let $t074967574 = getAssetInfo(poolAssetIdB) | |
262 | + | let pmtStrAssetIdB = $t074967574._1 | |
263 | + | let pmtAssetNameB = $t074967574._2 | |
264 | + | let pmtDecimalsB = $t074967574._3 | |
265 | + | if ((poolAssetIdA == poolAssetIdB)) | |
266 | + | then throw("Assets must be different") | |
267 | + | else if (isPoolExists) | |
268 | + | then throw("This pool already exists") | |
269 | + | else if ((size(i.payments) != 1)) | |
270 | + | then throw("One attached asset expected") | |
271 | + | else if ((pmtAssetId != SWOP)) | |
272 | + | then throw("You must use a SWOP token") | |
273 | + | else if (if ((assetA == "")) | |
274 | + | then true | |
275 | + | else (assetB == "")) | |
276 | + | then throw("Assets can't be empty") | |
277 | + | else if ((pmtAmount != comissionForInitalizationOfVoting)) | |
278 | + | then throw("You need to attach 10 SWOP tokens") | |
279 | + | else if (!(if (if ((poolAssetIdB == USDN)) | |
257 | 280 | then true | |
258 | - | else (assetB == "")) | |
259 | - | then throw("Assets can't be empty") | |
260 | - | else if ((pmtAmount != comissionForInitalizationOfVoting)) | |
261 | - | then throw("You need to attach 10 SWOP tokens") | |
262 | - | else if (!(if (if (if ((poolAssetIdB == USDN)) | |
263 | - | then true | |
264 | - | else (poolAssetIdB == unit)) | |
265 | - | then true | |
266 | - | else (poolAssetIdB == SWOP)) | |
267 | - | then true | |
268 | - | else (poolAssetIdB == EGG))) | |
269 | - | then throw("assetB must be USDN, WAVES or SWOP") | |
270 | - | else [IntegerEntry((((((assetA + "_") + assetB) + "_") + toString(amountOfVoting)) + votingId), amountOfVoting), IntegerEntry((toString(amountOfVoting) + keyHeightOfPool), (height + votingPeriodLength)), BooleanEntry((toString(amountOfVoting) + keyStatusOfVoting), true), IntegerEntry(keyAmountOfVoting, (amountOfVoting + 1)), IntegerEntry(keyNumberOfVoting, (newNumberOfVoting + 1)), StringEntry((assetA + kName), pmtAssetNameA), StringEntry((assetB + kName), pmtAssetNameB), StringEntry(unactiveVote, (((((assetA + "_") + assetB) + "_") + toString(amountOfVoting)) + votingId)), ScriptTransfer(walletAddress, pmtAmount, pmtAssetId)] | |
271 | - | } | |
281 | + | else (poolAssetIdB == unit)) | |
282 | + | then true | |
283 | + | else (poolAssetIdB == SWOP))) | |
284 | + | then throw("assetB must be USDN, WAVES or SWOP") | |
285 | + | else if (if (((newNumberOfVoting + 1) > maxAmountOfVoting)) | |
286 | + | then true | |
287 | + | else (unactiveVote == "")) | |
288 | + | then throw(("Too many votings. Maximum quantity: " + toString(maxAmountOfVoting))) | |
289 | + | else [IntegerEntry((((((assetA + "_") + assetB) + "_") + toString(amountOfVoting)) + votingId), amountOfVoting), IntegerEntry((toString(amountOfVoting) + kHeightOfPool), (height + votingPeriodLength)), BooleanEntry((toString(amountOfVoting) + kStatusOfVoting), true), IntegerEntry(kAmountOfVoting, (amountOfVoting + 1)), IntegerEntry(kNumberOfVoting, (newNumberOfVoting + 1)), StringEntry((assetA + kName), pmtAssetNameA), StringEntry((assetB + kName), pmtAssetNameB), StringEntry(unactiveVote, (((((assetA + "_") + assetB) + "_") + toString(amountOfVoting)) + votingId)), ScriptTransfer(moneyBoxAddress, pmtAmount, pmtAssetId)] | |
290 | + | }) | |
272 | 291 | ||
273 | 292 | ||
274 | 293 | ||
275 | 294 | @Callable(i) | |
276 | - | func voteForPool (voting,yesOrNo,voteAmt) = { | |
295 | + | func voteForPool (voting,yesOrNo,voteAmt) = valueOrElse(isActive(), { | |
277 | 296 | let currentHeight = height | |
278 | - | let poolInitHeight = valueOrErrorMessage(getIntegerValue(this, (toString(voting) + | |
279 | - | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + | |
280 | - | let userSWOPinGovernance = valueOrElse(getInteger( | |
297 | + | let poolInitHeight = valueOrErrorMessage(getIntegerValue(this, (toString(voting) + kHeightOfPool)), "Empty pool height") | |
298 | + | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + kStatusOfVoting)), true) | |
299 | + | let userSWOPinGovernance = valueOrElse(getInteger(govAddress, (toString(i.caller) + kUserTotalGSWOP)), 0) | |
281 | 300 | let totalVoteUser = if (yesOrNo) | |
282 | - | then (valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + | |
283 | - | else (valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + | |
301 | + | then (valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + kNoUser)), 0) + voteAmt) | |
302 | + | else (valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + kYesUser)), 0) + voteAmt) | |
284 | 303 | if (!(isCallerInGovernance(i.caller))) | |
285 | 304 | then throw("This address has 0 SWOP in Governance dApp") | |
286 | 305 | else if (!(statusOfVoting)) | |
293 | 312 | then throw((((toString(this) + " has ") + toString(userSWOPinGovernance)) + " SWOP in governance.")) | |
294 | 313 | else if (yesOrNo) | |
295 | 314 | then { | |
296 | - | let oldVoteUser = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + | |
297 | - | let newVote = ((valueOrElse(getInteger(this, (toString(voting) + | |
298 | - | [IntegerEntry((toString(voting) + | |
315 | + | let oldVoteUser = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + kYesUser)), 0) | |
316 | + | let newVote = ((valueOrElse(getInteger(this, (toString(voting) + kYes)), 0) - oldVoteUser) + voteAmt) | |
317 | + | [IntegerEntry((toString(voting) + kYes), newVote), IntegerEntry((((toString(i.caller) + "_") + toString(voting)) + kYesUser), voteAmt)] | |
299 | 318 | } | |
300 | 319 | else { | |
301 | - | let oldVoteUser = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + | |
302 | - | let newVote = ((valueOrElse(getInteger(this, (toString(voting) + | |
303 | - | [IntegerEntry((toString(voting) + | |
320 | + | let oldVoteUser = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + kNoUser)), 0) | |
321 | + | let newVote = ((valueOrElse(getInteger(this, (toString(voting) + kNo)), 0) - oldVoteUser) + voteAmt) | |
322 | + | [IntegerEntry((toString(voting) + kNo), newVote), IntegerEntry((((toString(i.caller) + "_") + toString(voting)) + kNoUser), voteAmt)] | |
304 | 323 | } | |
305 | - | } | |
324 | + | }) | |
306 | 325 | ||
307 | 326 | ||
308 | 327 | ||
309 | 328 | @Callable(i) | |
310 | - | func cancelVoting (voting,cause) = { | |
311 | - | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + keyStatusOfVoting)), true) | |
312 | - | if (!(isActive)) | |
313 | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified"))) | |
314 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))) | |
315 | - | then throw("Only admin can call this function") | |
316 | - | else if (!(statusOfVoting)) | |
317 | - | then throw((("Voting " + toString(voting)) + " has already been stopped")) | |
318 | - | else [IntegerEntry(keyNumberOfVoting, (numberOfVoting - 1)), BooleanEntry((toString(voting) + keyStatusOfVoting), false), StringEntry((toString(voting) + keyCancelCause), cause)] | |
319 | - | } | |
329 | + | func cancelVoting (voting,cause) = valueOrElse(isAdminCall(i), { | |
330 | + | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + kStatusOfVoting)), true) | |
331 | + | if (!(statusOfVoting)) | |
332 | + | then throw((("Voting " + toString(voting)) + " has already been stopped")) | |
333 | + | else [IntegerEntry(kNumberOfVoting, (numberOfVoting - 1)), BooleanEntry((toString(voting) + kStatusOfVoting), false), StringEntry((toString(voting) + kCancelCause), cause)] | |
334 | + | }) | |
320 | 335 | ||
321 | 336 | ||
322 | 337 | ||
323 | 338 | @Callable(i) | |
324 | - | func shutdown () = if (!(isActive)) | |
325 | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified"))) | |
326 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
327 | - | then throw("Only admin can call this function") | |
328 | - | else suspend("Paused by admin") | |
339 | + | func shutdown () = valueOrElse(isAdminCall(i), if (!(active)) | |
340 | + | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
341 | + | else suspend("Paused by admin")) | |
329 | 342 | ||
330 | 343 | ||
331 | 344 | ||
332 | 345 | @Callable(i) | |
333 | - | func activate () = if ( | |
346 | + | func activate () = valueOrElse(isAdminCall(i), if (active) | |
334 | 347 | then throw("DApp is already active") | |
335 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
336 | - | then throw("Only admin can call this function") | |
337 | - | else [BooleanEntry(keyActive, true), DeleteEntry(keyCause)] | |
348 | + | else [BooleanEntry(kActive, true), DeleteEntry(kCause)]) | |
338 | 349 | ||
339 | 350 | ||
340 | 351 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let oracle = Address(base58'3MvVBtsXroQpy1tsPw21TU2ET9A8WfmrNjz') | |
5 | + | ||
4 | 6 | let version = "1.0.0" | |
5 | 7 | ||
6 | - | let | |
8 | + | let kVersion = "version" | |
7 | 9 | ||
8 | - | let | |
10 | + | let kActive = "active" | |
9 | 11 | ||
10 | - | let | |
12 | + | let kActiveGlob = "active_all_contracts" | |
11 | 13 | ||
12 | - | let | |
14 | + | let kNumberOfVoting = "voting_active_number" | |
13 | 15 | ||
14 | - | let | |
16 | + | let kHeightOfPool = "_finish_height" | |
15 | 17 | ||
16 | - | let | |
18 | + | let kNo = "_total_votes_no" | |
17 | 19 | ||
18 | - | let | |
20 | + | let kYes = "_total_votes_yes" | |
19 | 21 | ||
20 | - | let | |
22 | + | let kNoUser = "_vote_no" | |
21 | 23 | ||
22 | - | let | |
24 | + | let kYesUser = "_vote_yes" | |
23 | 25 | ||
24 | - | let | |
26 | + | let kStatusOfVoting = "_status" | |
25 | 27 | ||
26 | - | let | |
28 | + | let kAmountOfVoting = "voting_id_last" | |
27 | 29 | ||
28 | - | let | |
30 | + | let kMaxAmountOfVoting = "max_amount_voting" | |
29 | 31 | ||
30 | - | let | |
32 | + | let kMaxDayOfVoting = "max_day_voting" | |
31 | 33 | ||
32 | - | let | |
34 | + | let kCause = "shutdown_cause" | |
33 | 35 | ||
34 | - | let | |
36 | + | let kCancelCause = "_cancel_cause" | |
35 | 37 | ||
36 | - | let keyCancelCause = "_cancel_cause" | |
37 | - | ||
38 | - | let kUserTotalSWOP = "_SWOP_amount" | |
38 | + | let kUserTotalGSWOP = "_GSwop_amount" | |
39 | 39 | ||
40 | 40 | let kName = "_asset_name" | |
41 | 41 | ||
42 | 42 | let votingId = "_voting" | |
43 | - | ||
44 | - | let periodOfVoting = "period_voting" | |
45 | 43 | ||
46 | 44 | let activeVoteFirst = "voting_active_cell_1" | |
47 | 45 | ||
48 | 46 | let activeVoteSecond = "voting_active_cell_2" | |
49 | 47 | ||
50 | 48 | let activeVoteThird = "voting_active_cell_3" | |
51 | 49 | ||
52 | - | let | |
50 | + | let kAdminPubKey1 = "admin_pub_1" | |
53 | 51 | ||
54 | - | let | |
52 | + | let kAdminPubKey2 = "admin_pub_2" | |
55 | 53 | ||
56 | - | let | |
54 | + | let kAdminPubKey3 = "admin_pub_3" | |
57 | 55 | ||
58 | - | let | |
56 | + | let kMoneyBoxAddress = "money_box_address" | |
59 | 57 | ||
60 | - | let | |
58 | + | let kGovAddress = "governance_address" | |
61 | 59 | ||
62 | - | let | |
60 | + | let kFarmingAddr = "farming_address" | |
63 | 61 | ||
64 | - | let | |
62 | + | let kUSDNAssetId = "usdn_asset_id" | |
65 | 63 | ||
66 | - | let | |
64 | + | let kSWOPid = "SWOP_id" | |
67 | 65 | ||
68 | - | let | |
66 | + | let numberOfVoting = getIntegerValue(this, kNumberOfVoting) | |
69 | 67 | ||
70 | - | let isActive = getBooleanValue(this, keyActive) | |
71 | - | ||
72 | - | let numberOfVoting = getIntegerValue(this, keyNumberOfVoting) | |
73 | - | ||
74 | - | let amountOfVoting = getIntegerValue(this, keyAmountOfVoting) | |
68 | + | let amountOfVoting = getIntegerValue(this, kAmountOfVoting) | |
75 | 69 | ||
76 | 70 | let firstActiveVote = valueOrElse(getString(this, activeVoteFirst), "") | |
77 | 71 | ||
78 | 72 | let secondActiveVote = valueOrElse(getString(this, activeVoteSecond), "") | |
79 | 73 | ||
80 | 74 | let thirdActiveVote = valueOrElse(getString(this, activeVoteThird), "") | |
81 | 75 | ||
76 | + | let active = getBooleanValue(this, kActive) | |
77 | + | ||
78 | + | let activeGlob = valueOrElse(getBoolean(oracle, kActiveGlob), true) | |
79 | + | ||
82 | 80 | let comissionForInitalizationOfVoting = 1000000000 | |
83 | - | ||
84 | - | let scaleValue3 = 1000 | |
85 | - | ||
86 | - | let scaleValue8 = 100000000 | |
87 | - | ||
88 | - | let slippageToleranceDelimiter = 1000 | |
89 | - | ||
90 | - | let scaleValue8Digits = 8 | |
91 | 81 | ||
92 | 82 | let maxAmountOfVoting = 3 | |
93 | 83 | ||
94 | 84 | let maxDayOfVoting = 7 | |
95 | 85 | ||
96 | 86 | let votingPeriodLength = (1443 * maxDayOfVoting) | |
87 | + | ||
88 | + | func getBase58FromOracle (key) = match getString(oracle, key) { | |
89 | + | case string: String => | |
90 | + | fromBase58String(string) | |
91 | + | case nothing => | |
92 | + | throw((key + "is empty")) | |
93 | + | } | |
94 | + | ||
95 | + | ||
96 | + | let adminPubKey1 = getBase58FromOracle(kAdminPubKey1) | |
97 | + | ||
98 | + | let adminPubKey2 = getBase58FromOracle(kAdminPubKey2) | |
99 | + | ||
100 | + | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
101 | + | ||
102 | + | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
103 | + | ||
104 | + | let farmingAddr = Address(getBase58FromOracle(kFarmingAddr)) | |
105 | + | ||
106 | + | let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress)) | |
107 | + | ||
108 | + | let USDN = getBase58FromOracle(kUSDNAssetId) | |
109 | + | ||
110 | + | let SWOP = fromBase58String(getStringValue(farmingAddr, kSWOPid)) | |
111 | + | ||
112 | + | func isActive () = if (if (active) | |
113 | + | then activeGlob | |
114 | + | else false) | |
115 | + | then unit | |
116 | + | else throw("DApp is inactive at this moment") | |
117 | + | ||
118 | + | ||
119 | + | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
120 | + | then unit | |
121 | + | else throw("Only admin can call this function") | |
122 | + | ||
97 | 123 | ||
98 | 124 | func getAssetInfo (assetId) = match assetId { | |
99 | 125 | case id: ByteVector => | |
100 | 126 | if (isDefined(assetInfo(id))) | |
101 | 127 | then { | |
102 | 128 | let stringId = toBase58String(id) | |
103 | 129 | let info = valueOrErrorMessage(assetInfo(id), (("Asset " + stringId) + " doesn't exist")) | |
104 | 130 | $Tuple3(stringId, info.name, info.decimals) | |
105 | 131 | } | |
106 | 132 | else throw("Asset is not defined") | |
107 | 133 | case waves: Unit => | |
108 | 134 | $Tuple3("WAVES", "WAVES", 8) | |
109 | 135 | case _ => | |
110 | 136 | throw("Match error") | |
111 | 137 | } | |
112 | 138 | ||
113 | 139 | ||
114 | 140 | func isActivePoolExists (pools,assetA,assetB) = { | |
115 | 141 | let poolsData = split(pools, "_") | |
116 | 142 | let isPoolDefine = isDefined(getInteger(this, pools)) | |
117 | 143 | if (if (isPoolDefine) | |
118 | 144 | then (pools != "") | |
119 | 145 | else false) | |
120 | 146 | then { | |
121 | 147 | let voting = poolsData[2] | |
122 | 148 | let newPools = (((((assetA + "_") + assetB) + "_") + voting) + votingId) | |
123 | 149 | let isNewPoolDefine = isDefined(getInteger(this, newPools)) | |
124 | - | let heightOfVoting = valueOrElse(getInteger(this, (voting + | |
125 | - | let statusOfVoting = valueOrElse(getBoolean(this, (voting + | |
150 | + | let heightOfVoting = valueOrElse(getInteger(this, (voting + kHeightOfPool)), 0) | |
151 | + | let statusOfVoting = valueOrElse(getBoolean(this, (voting + kStatusOfVoting)), true) | |
126 | 152 | if (isNewPoolDefine) | |
127 | 153 | then if ((heightOfVoting > height)) | |
128 | 154 | then if (statusOfVoting) | |
129 | 155 | then true | |
130 | 156 | else false | |
131 | 157 | else false | |
132 | 158 | else false | |
133 | 159 | } | |
134 | 160 | else false | |
135 | 161 | } | |
136 | 162 | ||
137 | 163 | ||
138 | 164 | func isUnactivePoolExists (poolsState) = { | |
139 | 165 | let pools = valueOrElse(getString(this, poolsState), "") | |
140 | 166 | let poolsData = split(pools, "_") | |
141 | 167 | let isPoolDefine = isDefined(getInteger(this, pools)) | |
142 | 168 | if (if (isPoolDefine) | |
143 | 169 | then (pools != "") | |
144 | 170 | else false) | |
145 | 171 | then { | |
146 | 172 | let voting = poolsData[2] | |
147 | - | let heightOfVoting = valueOrElse(getInteger(this, (voting + | |
148 | - | let statusOfVoting = valueOrElse(getBoolean(this, (voting + | |
173 | + | let heightOfVoting = valueOrElse(getInteger(this, (voting + kHeightOfPool)), 0) | |
174 | + | let statusOfVoting = valueOrElse(getBoolean(this, (voting + kStatusOfVoting)), true) | |
149 | 175 | if ((heightOfVoting > height)) | |
150 | 176 | then if (statusOfVoting) | |
151 | 177 | then "" | |
152 | 178 | else poolsState | |
153 | 179 | else poolsState | |
154 | 180 | } | |
155 | 181 | else poolsState | |
156 | 182 | } | |
157 | 183 | ||
158 | 184 | ||
159 | 185 | func isLastActivePoolExists (assetA,assetB) = if (if (isActivePoolExists(firstActiveVote, assetA, assetB)) | |
160 | 186 | then true | |
161 | 187 | else isActivePoolExists(secondActiveVote, assetA, assetB)) | |
162 | 188 | then true | |
163 | 189 | else isActivePoolExists(thirdActiveVote, assetA, assetB) | |
164 | 190 | ||
165 | 191 | ||
166 | 192 | func getActivePool (voting) = { | |
167 | - | let heightOfVoting = valueOrElse(getInteger(this, (toString(voting) + | |
168 | - | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + | |
193 | + | let heightOfVoting = valueOrElse(getInteger(this, (toString(voting) + kHeightOfPool)), 0) | |
194 | + | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + kStatusOfVoting)), true) | |
169 | 195 | let currentHeight = height | |
170 | 196 | if ((0 > voting)) | |
171 | 197 | then 0 | |
172 | 198 | else if (!(statusOfVoting)) | |
173 | 199 | then 0 | |
174 | 200 | else if ((heightOfVoting > currentHeight)) | |
175 | 201 | then 1 | |
176 | 202 | else 0 | |
177 | 203 | } | |
178 | 204 | ||
179 | 205 | ||
180 | 206 | func getActiveVotingPoolAmount () = ((getActivePool(valueOrElse(getInteger(this, firstActiveVote), -1)) + getActivePool(valueOrElse(getInteger(this, secondActiveVote), -1))) + getActivePool(valueOrElse(getInteger(this, thirdActiveVote), -1))) | |
181 | 207 | ||
182 | 208 | ||
183 | 209 | func getUnactiveVotingPool () = if ((isUnactivePoolExists(activeVoteFirst) != "")) | |
184 | 210 | then activeVoteFirst | |
185 | 211 | else if ((isUnactivePoolExists(activeVoteSecond) != "")) | |
186 | 212 | then activeVoteSecond | |
187 | 213 | else if ((isUnactivePoolExists(activeVoteThird) != "")) | |
188 | 214 | then activeVoteThird | |
189 | 215 | else "" | |
190 | 216 | ||
191 | 217 | ||
192 | 218 | func getAssetInfoFromString (assetStr) = if ((assetStr == "WAVES")) | |
193 | 219 | then unit | |
194 | 220 | else fromBase58String(assetStr) | |
195 | 221 | ||
196 | 222 | ||
197 | - | func isCallerInGovernance (user) = if ((valueOrElse(getInteger( | |
223 | + | func isCallerInGovernance (user) = if ((valueOrElse(getInteger(govAddress, (toString(user) + kUserTotalGSWOP)), 0) > 0)) | |
198 | 224 | then true | |
199 | 225 | else false | |
200 | 226 | ||
201 | 227 | ||
202 | - | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
203 | - | ||
204 | - | ||
205 | - | func throwInsufficientAvailableBalance (amount,assetName) = throw(((((("Insufficient DApp balance to pay " + toString(amount)) + " ") + assetName) + " due to staking.") + ". Please contact support in Telegram: https://t.me/swopfisupport")) | |
228 | + | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
206 | 229 | ||
207 | 230 | ||
208 | 231 | @Callable(i) | |
209 | 232 | func init () = if ((i.caller != this)) | |
210 | 233 | then throw("Only the DApp itself can call this function") | |
211 | - | else if (isDefined(getBoolean(this, | |
234 | + | else if (isDefined(getBoolean(this, kActive))) | |
212 | 235 | then throw("DApp is already active") | |
213 | 236 | else { | |
214 | 237 | let initNumberOfVoting = 0 | |
215 | 238 | let initAmountOfVoting = 0 | |
216 | 239 | let initKeyActive = true | |
217 | 240 | let activeInit = "" | |
218 | - | [StringEntry( | |
241 | + | [StringEntry(kVersion, version), BooleanEntry(kActive, initKeyActive), IntegerEntry(kNumberOfVoting, initNumberOfVoting), IntegerEntry(kAmountOfVoting, initAmountOfVoting), IntegerEntry(kMaxAmountOfVoting, maxAmountOfVoting), IntegerEntry(kMaxDayOfVoting, maxDayOfVoting), StringEntry(activeVoteFirst, activeInit), StringEntry(activeVoteSecond, activeInit), StringEntry(activeVoteThird, activeInit)] | |
219 | 242 | } | |
220 | 243 | ||
221 | 244 | ||
222 | 245 | ||
223 | 246 | @Callable(i) | |
224 | - | func initVotingForNewPool (assetA,assetB) = { | |
225 | - | let $ | |
226 | - | let pmtAmount = $ | |
227 | - | let pmtAssetId = $ | |
228 | - | let $ | |
229 | - | let poolAssetIdA = $ | |
230 | - | let poolAssetIdB = $ | |
247 | + | func initVotingForNewPool (assetA,assetB) = valueOrElse(isActive(), { | |
248 | + | let $t070647139 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
249 | + | let pmtAmount = $t070647139._1 | |
250 | + | let pmtAssetId = $t070647139._2 | |
251 | + | let $t071447243 = $Tuple2(getAssetInfoFromString(assetA), getAssetInfoFromString(assetB)) | |
252 | + | let poolAssetIdA = $t071447243._1 | |
253 | + | let poolAssetIdB = $t071447243._2 | |
231 | 254 | let unactiveVote = getUnactiveVotingPool() | |
232 | 255 | let newNumberOfVoting = getActiveVotingPoolAmount() | |
233 | 256 | let isPoolExists = isLastActivePoolExists(assetA, assetB) | |
234 | - | let $ | |
235 | - | let pmtStrAssetIdA = $ | |
236 | - | let pmtAssetNameA = $ | |
237 | - | let pmtDecimalsA = $ | |
238 | - | let $ | |
239 | - | let pmtStrAssetIdB = $ | |
240 | - | let pmtAssetNameB = $ | |
241 | - | let pmtDecimalsB = $ | |
242 | - | if ( | |
243 | - | then throw(" | |
244 | - | else if ( | |
245 | - | then throw(" | |
246 | - | else if ( | |
247 | - | then throw(" | |
248 | - | else if ( | |
249 | - | then | |
250 | - | else ( | |
251 | - | then | |
252 | - | else | |
253 | - | then throw(" | |
254 | - | else if (( | |
255 | - | then throw("You | |
256 | - | else if (if (( | |
257 | + | let $t074137491 = getAssetInfo(poolAssetIdA) | |
258 | + | let pmtStrAssetIdA = $t074137491._1 | |
259 | + | let pmtAssetNameA = $t074137491._2 | |
260 | + | let pmtDecimalsA = $t074137491._3 | |
261 | + | let $t074967574 = getAssetInfo(poolAssetIdB) | |
262 | + | let pmtStrAssetIdB = $t074967574._1 | |
263 | + | let pmtAssetNameB = $t074967574._2 | |
264 | + | let pmtDecimalsB = $t074967574._3 | |
265 | + | if ((poolAssetIdA == poolAssetIdB)) | |
266 | + | then throw("Assets must be different") | |
267 | + | else if (isPoolExists) | |
268 | + | then throw("This pool already exists") | |
269 | + | else if ((size(i.payments) != 1)) | |
270 | + | then throw("One attached asset expected") | |
271 | + | else if ((pmtAssetId != SWOP)) | |
272 | + | then throw("You must use a SWOP token") | |
273 | + | else if (if ((assetA == "")) | |
274 | + | then true | |
275 | + | else (assetB == "")) | |
276 | + | then throw("Assets can't be empty") | |
277 | + | else if ((pmtAmount != comissionForInitalizationOfVoting)) | |
278 | + | then throw("You need to attach 10 SWOP tokens") | |
279 | + | else if (!(if (if ((poolAssetIdB == USDN)) | |
257 | 280 | then true | |
258 | - | else (assetB == "")) | |
259 | - | then throw("Assets can't be empty") | |
260 | - | else if ((pmtAmount != comissionForInitalizationOfVoting)) | |
261 | - | then throw("You need to attach 10 SWOP tokens") | |
262 | - | else if (!(if (if (if ((poolAssetIdB == USDN)) | |
263 | - | then true | |
264 | - | else (poolAssetIdB == unit)) | |
265 | - | then true | |
266 | - | else (poolAssetIdB == SWOP)) | |
267 | - | then true | |
268 | - | else (poolAssetIdB == EGG))) | |
269 | - | then throw("assetB must be USDN, WAVES or SWOP") | |
270 | - | else [IntegerEntry((((((assetA + "_") + assetB) + "_") + toString(amountOfVoting)) + votingId), amountOfVoting), IntegerEntry((toString(amountOfVoting) + keyHeightOfPool), (height + votingPeriodLength)), BooleanEntry((toString(amountOfVoting) + keyStatusOfVoting), true), IntegerEntry(keyAmountOfVoting, (amountOfVoting + 1)), IntegerEntry(keyNumberOfVoting, (newNumberOfVoting + 1)), StringEntry((assetA + kName), pmtAssetNameA), StringEntry((assetB + kName), pmtAssetNameB), StringEntry(unactiveVote, (((((assetA + "_") + assetB) + "_") + toString(amountOfVoting)) + votingId)), ScriptTransfer(walletAddress, pmtAmount, pmtAssetId)] | |
271 | - | } | |
281 | + | else (poolAssetIdB == unit)) | |
282 | + | then true | |
283 | + | else (poolAssetIdB == SWOP))) | |
284 | + | then throw("assetB must be USDN, WAVES or SWOP") | |
285 | + | else if (if (((newNumberOfVoting + 1) > maxAmountOfVoting)) | |
286 | + | then true | |
287 | + | else (unactiveVote == "")) | |
288 | + | then throw(("Too many votings. Maximum quantity: " + toString(maxAmountOfVoting))) | |
289 | + | else [IntegerEntry((((((assetA + "_") + assetB) + "_") + toString(amountOfVoting)) + votingId), amountOfVoting), IntegerEntry((toString(amountOfVoting) + kHeightOfPool), (height + votingPeriodLength)), BooleanEntry((toString(amountOfVoting) + kStatusOfVoting), true), IntegerEntry(kAmountOfVoting, (amountOfVoting + 1)), IntegerEntry(kNumberOfVoting, (newNumberOfVoting + 1)), StringEntry((assetA + kName), pmtAssetNameA), StringEntry((assetB + kName), pmtAssetNameB), StringEntry(unactiveVote, (((((assetA + "_") + assetB) + "_") + toString(amountOfVoting)) + votingId)), ScriptTransfer(moneyBoxAddress, pmtAmount, pmtAssetId)] | |
290 | + | }) | |
272 | 291 | ||
273 | 292 | ||
274 | 293 | ||
275 | 294 | @Callable(i) | |
276 | - | func voteForPool (voting,yesOrNo,voteAmt) = { | |
295 | + | func voteForPool (voting,yesOrNo,voteAmt) = valueOrElse(isActive(), { | |
277 | 296 | let currentHeight = height | |
278 | - | let poolInitHeight = valueOrErrorMessage(getIntegerValue(this, (toString(voting) + | |
279 | - | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + | |
280 | - | let userSWOPinGovernance = valueOrElse(getInteger( | |
297 | + | let poolInitHeight = valueOrErrorMessage(getIntegerValue(this, (toString(voting) + kHeightOfPool)), "Empty pool height") | |
298 | + | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + kStatusOfVoting)), true) | |
299 | + | let userSWOPinGovernance = valueOrElse(getInteger(govAddress, (toString(i.caller) + kUserTotalGSWOP)), 0) | |
281 | 300 | let totalVoteUser = if (yesOrNo) | |
282 | - | then (valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + | |
283 | - | else (valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + | |
301 | + | then (valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + kNoUser)), 0) + voteAmt) | |
302 | + | else (valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + kYesUser)), 0) + voteAmt) | |
284 | 303 | if (!(isCallerInGovernance(i.caller))) | |
285 | 304 | then throw("This address has 0 SWOP in Governance dApp") | |
286 | 305 | else if (!(statusOfVoting)) | |
287 | 306 | then throw("This voting was canceled") | |
288 | 307 | else if ((currentHeight > poolInitHeight)) | |
289 | 308 | then throw("This voting was expired") | |
290 | 309 | else if ((0 > voteAmt)) | |
291 | 310 | then throw("The number of votes must be positive") | |
292 | 311 | else if ((totalVoteUser > userSWOPinGovernance)) | |
293 | 312 | then throw((((toString(this) + " has ") + toString(userSWOPinGovernance)) + " SWOP in governance.")) | |
294 | 313 | else if (yesOrNo) | |
295 | 314 | then { | |
296 | - | let oldVoteUser = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + | |
297 | - | let newVote = ((valueOrElse(getInteger(this, (toString(voting) + | |
298 | - | [IntegerEntry((toString(voting) + | |
315 | + | let oldVoteUser = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + kYesUser)), 0) | |
316 | + | let newVote = ((valueOrElse(getInteger(this, (toString(voting) + kYes)), 0) - oldVoteUser) + voteAmt) | |
317 | + | [IntegerEntry((toString(voting) + kYes), newVote), IntegerEntry((((toString(i.caller) + "_") + toString(voting)) + kYesUser), voteAmt)] | |
299 | 318 | } | |
300 | 319 | else { | |
301 | - | let oldVoteUser = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + | |
302 | - | let newVote = ((valueOrElse(getInteger(this, (toString(voting) + | |
303 | - | [IntegerEntry((toString(voting) + | |
320 | + | let oldVoteUser = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + toString(voting)) + kNoUser)), 0) | |
321 | + | let newVote = ((valueOrElse(getInteger(this, (toString(voting) + kNo)), 0) - oldVoteUser) + voteAmt) | |
322 | + | [IntegerEntry((toString(voting) + kNo), newVote), IntegerEntry((((toString(i.caller) + "_") + toString(voting)) + kNoUser), voteAmt)] | |
304 | 323 | } | |
305 | - | } | |
324 | + | }) | |
306 | 325 | ||
307 | 326 | ||
308 | 327 | ||
309 | 328 | @Callable(i) | |
310 | - | func cancelVoting (voting,cause) = { | |
311 | - | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + keyStatusOfVoting)), true) | |
312 | - | if (!(isActive)) | |
313 | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified"))) | |
314 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))) | |
315 | - | then throw("Only admin can call this function") | |
316 | - | else if (!(statusOfVoting)) | |
317 | - | then throw((("Voting " + toString(voting)) + " has already been stopped")) | |
318 | - | else [IntegerEntry(keyNumberOfVoting, (numberOfVoting - 1)), BooleanEntry((toString(voting) + keyStatusOfVoting), false), StringEntry((toString(voting) + keyCancelCause), cause)] | |
319 | - | } | |
329 | + | func cancelVoting (voting,cause) = valueOrElse(isAdminCall(i), { | |
330 | + | let statusOfVoting = valueOrElse(getBoolean(this, (toString(voting) + kStatusOfVoting)), true) | |
331 | + | if (!(statusOfVoting)) | |
332 | + | then throw((("Voting " + toString(voting)) + " has already been stopped")) | |
333 | + | else [IntegerEntry(kNumberOfVoting, (numberOfVoting - 1)), BooleanEntry((toString(voting) + kStatusOfVoting), false), StringEntry((toString(voting) + kCancelCause), cause)] | |
334 | + | }) | |
320 | 335 | ||
321 | 336 | ||
322 | 337 | ||
323 | 338 | @Callable(i) | |
324 | - | func shutdown () = if (!(isActive)) | |
325 | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified"))) | |
326 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
327 | - | then throw("Only admin can call this function") | |
328 | - | else suspend("Paused by admin") | |
339 | + | func shutdown () = valueOrElse(isAdminCall(i), if (!(active)) | |
340 | + | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
341 | + | else suspend("Paused by admin")) | |
329 | 342 | ||
330 | 343 | ||
331 | 344 | ||
332 | 345 | @Callable(i) | |
333 | - | func activate () = if ( | |
346 | + | func activate () = valueOrElse(isAdminCall(i), if (active) | |
334 | 347 | then throw("DApp is already active") | |
335 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
336 | - | then throw("Only admin can call this function") | |
337 | - | else [BooleanEntry(keyActive, true), DeleteEntry(keyCause)] | |
348 | + | else [BooleanEntry(kActive, true), DeleteEntry(kCause)]) | |
338 | 349 | ||
339 | 350 | ||
340 | 351 | @Verifier(tx) | |
341 | 352 | func verify () = { | |
342 | 353 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
343 | 354 | then 1 | |
344 | 355 | else 0 | |
345 | 356 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2)) | |
346 | 357 | then 1 | |
347 | 358 | else 0 | |
348 | 359 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3)) | |
349 | 360 | then 1 | |
350 | 361 | else 0 | |
351 | 362 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
352 | 363 | } | |
353 | 364 |
github/deemru/w8io/026f985 82.46 ms ◑