tx · U2iTDoJ8YUy9yQNb8ZqVY294QPq4JhkeFSX2XuyNiKn 3NBZkTq4XgvS9cWHQPutnUm3C1ZS4tDMqJa: -0.14000000 Waves 2022.10.18 17:25 [2277954] smart account 3NBZkTq4XgvS9cWHQPutnUm3C1ZS4tDMqJa > SELF 0.00000000 Waves
{ "type": 13, "id": "U2iTDoJ8YUy9yQNb8ZqVY294QPq4JhkeFSX2XuyNiKn", "fee": 14000000, "feeAssetId": null, "timestamp": 1666103179919, "version": 2, "chainId": 84, "sender": "3NBZkTq4XgvS9cWHQPutnUm3C1ZS4tDMqJa", "senderPublicKey": "HJ4MXkC5hCwrUSxdnzS5VVpQGe5zYXcUVukdiKcGNVnV", "proofs": [ "3B7Sj578vbvMbQMznmDwNZMeM5BkoXYPDDu5Sfm4GwmN8vAjksEW4o67k6HacyecRpZ1rh13YQLjKxjtrD9XyWL9", "MjgBpcqGaDrbDPgHMnbEDtZqQZYSNNrt2UL6LC6ZKLvL3WuvTydHXLP6cWdJJCurSYPZJbWGpqUxMo8x8APvXFY" ], "script": "base64:BgIMCAISBAoCCAESABIALAAHa0FjdGl2ZQIGYWN0aXZlAA1rZXlBY3RpdmVHbG9iAhRhY3RpdmVfYWxsX2NvbnRyYWN0cwAGa0NhdXNlAg5zaHV0ZG93bl9jYXVzZQANa1VzZXJQb29sVm90ZQIQX3VzZXJfdm90ZV9nU1dPUAAOa1VzZXJUb3RhbFZvdGUCFl91c2VyX3RvdGFsX3ZvdGVfZ1NXT1AACWtQb29sVm90ZQIQX3Bvb2xfdm90ZV9nU1dPUAAKa1RvdGFsVm90ZQIQdG90YWxfdm90ZV9nU1dPUAAQa0hhcnZlc3RQb29sVm90ZQIYX2hhcnZlc3RfcG9vbF92b3RlX2dTV09QABRrSGFydmVzdFVzZXJQb29sVm90ZQIdX2hhcnZlc3RfdXNlcl9wb29sX3ZvdGVfZ1NXT1AADGtTdGFydEhlaWdodAIMc3RhcnRfaGVpZ2h0AAtrQmFzZVBlcmlvZAIL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bid0IHNwZWNpZmllZAkBB3N1c3BlbmQBAg9QYXVzZWQgYnkgYWRtaW4BaQEIYWN0aXZhdGUACQELdmFsdWVPckVsc2UCCQELaXNBZG1pbkNhbGwBBQFpAwUGYWN0aXZlCQACAQIWREFwcCBpcyBhbHJlYWR5IGFjdGl2ZQkAzAgCCQEMQm9vbGVhbkVudHJ5AgUHa0FjdGl2ZQYJAMwIAgkBC0RlbGV0ZUVudHJ5AQUGa0NhdXNlBQNuaWwBAnR4AQZ2ZXJpZnkABBJhZG1pblB1YktleTFTaWduZWQDCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQxhZG1pblB1YktleTEAAQAABBJhZG1pblB1YktleTJTaWduZWQDCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwABBQxhZG1pblB1YktleTIAAQAABBJhZG1pblB1YktleTNTaWduZWQDCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwACBQxhZG1pblB1YktleTMAAQAACQBnAgkAZAIJAGQCBRJhZG1pblB1YktleTFTaWduZWQFEmFkbWluUHViS2V5MlNpZ25lZAUSYWRtaW5QdWJLZXkzU2lnbmVkAAJd5nMr", "height": 2277954, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9AxvRwgi5vFDHyjEHpcLNGAEyqZ9rCvSqPT4fucGz2jX Next: Fqj6uWC9eK7VDxUzznFuWSET2paGFLyG25811mqBD9ZH Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let kActive = "active" | |
5 | 5 | ||
6 | - | let | |
6 | + | let keyActiveGlob = "active_all_contracts" | |
7 | 7 | ||
8 | - | let | |
8 | + | let kCause = "shutdown_cause" | |
9 | 9 | ||
10 | - | let | |
10 | + | let kUserPoolVote = "_user_vote_gSWOP" | |
11 | 11 | ||
12 | - | let | |
12 | + | let kUserTotalVote = "_user_total_vote_gSWOP" | |
13 | 13 | ||
14 | - | let | |
14 | + | let kPoolVote = "_pool_vote_gSWOP" | |
15 | 15 | ||
16 | - | let | |
16 | + | let kTotalVote = "total_vote_gSWOP" | |
17 | 17 | ||
18 | - | let | |
18 | + | let kHarvestPoolVote = "_harvest_pool_vote_gSWOP" | |
19 | 19 | ||
20 | - | let kTotalVoteSWOP = "total_vote_SWOP" | |
21 | - | ||
22 | - | let kTotalStruc = "total_struc" | |
23 | - | ||
24 | - | let keyAdminPubKey1 = "admin_pub_1" | |
25 | - | ||
26 | - | let keyAdminPubKey2 = "admin_pub_2" | |
27 | - | ||
28 | - | let keyAdminPubKey3 = "admin_pub_3" | |
29 | - | ||
30 | - | let kHarvestPoolActiveVoteStruc = "_harvest_pool_activeVote_struc" | |
31 | - | ||
32 | - | let kHarvestUserPoolActiveVoteStruc = "_harvest_user_pool_activeVote_struc" | |
20 | + | let kHarvestUserPoolVote = "_harvest_user_pool_vote_gSWOP" | |
33 | 21 | ||
34 | 22 | let kStartHeight = "start_height" | |
35 | 23 | ||
37 | 25 | ||
38 | 26 | let kPeriodLength = "period_length" | |
39 | 27 | ||
40 | - | let | |
28 | + | let kAdminPubKey1 = "admin_pub_1" | |
41 | 29 | ||
42 | - | let | |
30 | + | let kAdminPubKey2 = "admin_pub_2" | |
43 | 31 | ||
44 | - | let | |
32 | + | let kAdminPubKey3 = "admin_pub_3" | |
45 | 33 | ||
46 | - | let active = valueOrElse(getBoolean(this, keyActive), true) | |
34 | + | let kFarmingAddr = "farming_address" | |
35 | + | ||
36 | + | let kGovAddress = "governance_address" | |
37 | + | ||
38 | + | let kPoolFirstHarvestEndHeight = "first_harvest_height" | |
39 | + | ||
40 | + | let kPoolStruc = "_pool_struc" | |
41 | + | ||
42 | + | let kUserPoolStruc = "_user_pool_struc" | |
43 | + | ||
44 | + | let kUserTotalStruc = "_user_total_struc" | |
45 | + | ||
46 | + | let kTotalStruc = "total_struc" | |
47 | + | ||
48 | + | let kHarvestPoolActiveVoteStruc = "_harvest_pool_activeVote_struc" | |
49 | + | ||
50 | + | let kHarvestUserPoolActiveVoteStruc = "_harvest_user_pool_activeVote_struc" | |
51 | + | ||
52 | + | let oracle = Address(base58'3MvVBtsXroQpy1tsPw21TU2ET9A8WfmrNjz') | |
53 | + | ||
54 | + | let active = valueOrElse(getBoolean(this, kActive), true) | |
55 | + | ||
56 | + | let activeGlob = valueOrElse(getBoolean(oracle, keyActiveGlob), true) | |
47 | 57 | ||
48 | 58 | let basePeriod = valueOrErrorMessage(getInteger(this, kBasePeriod), "Empty kBasePeriod") | |
49 | 59 | ||
51 | 61 | ||
52 | 62 | let periodLength = valueOrErrorMessage(getInteger(this, kPeriodLength), "Empty kPeriodLength") | |
53 | 63 | ||
54 | - | let durationFullVotePower = valueOrErrorMessage(getInteger(this, kDurationFullVotePower), "Empty kDurationFullVotePower") | |
55 | - | ||
56 | - | let minVotePower = valueOrErrorMessage(getInteger(this, kMinVotePower), "Empty kMinVotePower") | |
57 | - | ||
58 | - | let govAddr = Address(base58'3N8E9LU71MDkdP8FWtbP4TBXCNhoc15hWfs') | |
59 | - | ||
60 | - | let oracle = Address(base58'3MvVBtsXroQpy1tsPw21TU2ET9A8WfmrNjz') | |
61 | - | ||
62 | - | func getAdminPub (keyAdminPub) = match getString(oracle, keyAdminPub) { | |
64 | + | func getBase58FromOracle (key) = match getString(oracle, key) { | |
63 | 65 | case string: String => | |
64 | 66 | fromBase58String(string) | |
65 | 67 | case nothing => | |
66 | - | throw( | |
68 | + | throw((key + "is empty")) | |
67 | 69 | } | |
68 | 70 | ||
69 | 71 | ||
70 | - | let adminPubKey1 = | |
72 | + | let adminPubKey1 = getBase58FromOracle(kAdminPubKey1) | |
71 | 73 | ||
72 | - | let adminPubKey2 = | |
74 | + | let adminPubKey2 = getBase58FromOracle(kAdminPubKey2) | |
73 | 75 | ||
74 | - | let adminPubKey3 = | |
76 | + | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
75 | 77 | ||
76 | - | let adminPubKeyStartStop = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
78 | + | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
79 | + | ||
80 | + | let farmingAddr = Address(getBase58FromOracle(kFarmingAddr)) | |
77 | 81 | ||
78 | 82 | let currPeriod = (basePeriod + ((height - startHeight) / periodLength)) | |
79 | 83 | ||
80 | - | func isActive () = if (active) | |
84 | + | func isActive () = if (if (active) | |
85 | + | then activeGlob | |
86 | + | else false) | |
81 | 87 | then unit | |
82 | 88 | else throw("DApp is inactive at this moment") | |
83 | 89 | ||
84 | 90 | ||
85 | - | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
91 | + | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
92 | + | then unit | |
93 | + | else throw("Only admin can call this function") | |
86 | 94 | ||
87 | 95 | ||
88 | - | func isCallerInGovernance (user) = if ((valueOrElse(getInteger(govAddr, (toString(user) + "_SWOP_amount")), 0) > 0)) | |
89 | - | then true | |
90 | - | else false | |
96 | + | func isCallerInGovernance (user) = (valueOrElse(getInteger(govAddress, (toString(user) + "_SWOP_amount")), 0) > 0) | |
91 | 97 | ||
92 | 98 | ||
93 | - | func isPoolInGovernance (poolAddress) = isDefined(getInteger( | |
99 | + | func isPoolInGovernance (poolAddress) = isDefined(getInteger(govAddress, (poolAddress + "_current_pool_fraction_reward"))) | |
94 | 100 | ||
95 | 101 | ||
96 | - | func votingCoef () = { | |
97 | - | let votingDuration = (height - (startHeight + (currPeriod * periodLength))) | |
98 | - | if ((durationFullVotePower > votingDuration)) | |
99 | - | then scale8 | |
100 | - | else { | |
101 | - | let x1 = durationFullVotePower | |
102 | - | let y1 = scale8 | |
103 | - | let x2 = periodLength | |
104 | - | let y2 = minVotePower | |
105 | - | let k = (((y2 - y1) * scale8) / (x2 - x1)) | |
106 | - | let b = ((y1 * scale8) - (k * x1)) | |
107 | - | (((votingDuration * k) / scale8) + (b / scale8)) | |
108 | - | } | |
109 | - | } | |
102 | + | func getPoolFirstHarvestStartHeight (poolAddress) = (valueOrElse(getInteger(Address(fromBase58String(poolAddress)), kPoolFirstHarvestEndHeight), 0) - periodLength) | |
110 | 103 | ||
111 | 104 | ||
112 | - | func calcDeleteEntry (caller,poolAddress,userPoolVoteSWOPnew) = { | |
105 | + | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
106 | + | ||
107 | + | ||
108 | + | func calcDeleteEntry (caller,poolAddress) = { | |
113 | 109 | func deleteIfExists (list,key) = if (isDefined(getInteger(this, key))) | |
114 | 110 | then (list :+ DeleteEntry(key)) | |
115 | 111 | else list | |
116 | 112 | ||
117 | - | deleteIfExists(deleteIfExists(deleteIfExists(deleteIfExists(nil, (((caller + "_") + poolAddress) + | |
113 | + | deleteIfExists(deleteIfExists(deleteIfExists(deleteIfExists(deleteIfExists(deleteIfExists(nil, (((caller + "_") + poolAddress) + kUserPoolStruc)), (caller + kUserTotalStruc)), (poolAddress + kPoolStruc)), kTotalStruc), (poolAddress + kHarvestPoolActiveVoteStruc)), (((caller + "_") + poolAddress) + kHarvestUserPoolActiveVoteStruc)) | |
118 | 114 | } | |
119 | 115 | ||
120 | 116 | ||
121 | 117 | @Callable(i) | |
122 | - | func votePoolWeight (poolAddressesL,poolsVoteSWOPNewL) = valueOrElse(isActive(), if (if ((size(poolAddressesL) > 1)) | |
123 | - | then true | |
124 | - | else (size(poolsVoteSWOPNewL) > 1)) | |
125 | - | then throw("poolAddressesL.size > 1 or poolsVoteSWOPNewL.size > 1") | |
118 | + | func votePoolWeight (poolAddress,userPoolVoteNew) = valueOrElse(isActive(), if (!(isPoolInGovernance(poolAddress))) | |
119 | + | then throw("This pool is not in Governance dApp") | |
126 | 120 | else { | |
127 | - | let poolAddress = poolAddressesL[0] | |
128 | - | let userPoolVoteSWOPnew = poolsVoteSWOPNewL[0] | |
129 | - | if (!(isPoolInGovernance(poolAddress))) | |
130 | - | then throw("This pool has no _current_pool_fraction_reward in Governance dApp") | |
131 | - | else { | |
132 | - | let userSWOPinGovernance = valueOrErrorMessage(getInteger(govAddr, (toString(i.caller) + "_SWOP_amount")), "Empty _SWOP_amount at gov. address") | |
133 | - | let $t042184849 = if (isDefined(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)))) | |
134 | - | then { | |
135 | - | let data = split(valueOrErrorMessage(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)), "Empty kUserPoolStruc"), "_") | |
136 | - | $Tuple4(parseIntValue(data[0]), parseIntValue(data[1]), parseIntValue(data[2]), parseIntValue(data[3])) | |
121 | + | let userSWOPinGovernance = valueOrErrorMessage(getInteger(govAddress, (toString(i.caller) + "_SWOP_amount")), "Empty _SWOP_amount at gov. address") | |
122 | + | let userGSWOPinGovernance = valueOrElse(getInteger(govAddress, (toString(i.caller) + "_GSwop_amount")), userSWOPinGovernance) | |
123 | + | let userPoolVote = if (isDefined(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)))) | |
124 | + | then parseIntValue(split(value(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc))), "_")[0]) | |
125 | + | else valueOrElse(getInteger(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolVote)), 0) | |
126 | + | let userTotalVote = if (isDefined(getString(this, (toString(i.caller) + kUserTotalStruc)))) | |
127 | + | then parseIntValue(split(value(getString(this, (toString(i.caller) + kUserTotalStruc))), "_")[0]) | |
128 | + | else valueOrElse(getInteger(this, (toString(i.caller) + kUserTotalVote)), 0) | |
129 | + | let poolVote = if (isDefined(getString(this, (poolAddress + kPoolStruc)))) | |
130 | + | then parseIntValue(split(value(getString(this, (poolAddress + kPoolStruc))), "_")[0]) | |
131 | + | else valueOrElse(getInteger(this, (poolAddress + kPoolVote)), 0) | |
132 | + | let totalVote = if (isDefined(getString(this, kTotalStruc))) | |
133 | + | then parseIntValue(split(value(getString(this, kTotalStruc)), "_")[0]) | |
134 | + | else valueOrElse(getInteger(this, kTotalVote), 0) | |
135 | + | let poolVoteDiff = (userPoolVoteNew - userPoolVote) | |
136 | + | let userTotalVoteNew = (userTotalVote + poolVoteDiff) | |
137 | + | if ((userTotalVoteNew > userGSWOPinGovernance)) | |
138 | + | then throw(((((toString(i.caller) + " has ") + toString(userGSWOPinGovernance)) + " GSWOP in governance. New GSWOP in voting ") + toString(userTotalVoteNew))) | |
139 | + | else if ((0 > userTotalVoteNew)) | |
140 | + | then throw("New userTotalVoteSWOPnew < 0") | |
141 | + | else if ((0 > userPoolVoteNew)) | |
142 | + | then throw("New userPoolVoteSWOPnew < 0") | |
143 | + | else { | |
144 | + | let removePoolVote = -(poolVoteDiff) | |
145 | + | let poolVoteNew = if ((userPoolVoteNew >= userPoolVote)) | |
146 | + | then (poolVote + poolVoteDiff) | |
147 | + | else (poolVote - removePoolVote) | |
148 | + | let totalVoteNew = if ((userPoolVoteNew >= userPoolVote)) | |
149 | + | then (totalVote + poolVoteDiff) | |
150 | + | else (totalVote - removePoolVote) | |
151 | + | if (if ((0 > poolVoteNew)) | |
152 | + | then true | |
153 | + | else (0 > totalVoteNew)) | |
154 | + | then throw("One or more values are negative") | |
155 | + | else { | |
156 | + | let harvestEntries = if ((height > getPoolFirstHarvestStartHeight(poolAddress))) | |
157 | + | then [IntegerEntry((poolAddress + kHarvestPoolVote), poolVoteNew), IntegerEntry((((toString(i.caller) + "_") + poolAddress) + kHarvestUserPoolVote), userPoolVoteNew)] | |
158 | + | else nil | |
159 | + | let upUIntr = invoke(farmingAddr, "updateUserBoostInterest", [poolAddress, toString(i.caller)], nil) | |
160 | + | if ((upUIntr == upUIntr)) | |
161 | + | then (([IntegerEntry((((toString(i.caller) + "_") + poolAddress) + kUserPoolVote), userPoolVoteNew), IntegerEntry((toString(i.caller) + kUserTotalVote), userTotalVoteNew), IntegerEntry((poolAddress + kPoolVote), poolVoteNew), IntegerEntry(kTotalVote, totalVoteNew)] ++ calcDeleteEntry(toString(i.caller), poolAddress)) ++ harvestEntries) | |
162 | + | else throw("Strict value is not equal to itself.") | |
163 | + | } | |
137 | 164 | } | |
138 | - | else { | |
139 | - | let uPoolVoteSWOP = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolVoteSWOP)), 0) | |
140 | - | $Tuple4(uPoolVoteSWOP, uPoolVoteSWOP, 0, 0) | |
141 | - | } | |
142 | - | let userPoolVoteSWOP = $t042184849._1 | |
143 | - | let userPoolActiveVoteSWOP = $t042184849._2 | |
144 | - | let userPoolVotePeriod = $t042184849._3 | |
145 | - | let userPoolFreezeSWOP = $t042184849._4 | |
146 | - | let $t048555361 = if (isDefined(getString(this, (toString(i.caller) + kUserTotalStruc)))) | |
147 | - | then { | |
148 | - | let data = split(valueOrErrorMessage(getString(this, (toString(i.caller) + kUserTotalStruc)), "Empty kUserTotalStruc"), "_") | |
149 | - | $Tuple3(parseIntValue(data[0]), parseIntValue(data[1]), parseIntValue(data[2])) | |
150 | - | } | |
151 | - | else { | |
152 | - | let uPoolTotalSWOP = valueOrElse(getInteger(this, (toString(i.caller) + kUserTotalVoteSWOP)), 0) | |
153 | - | $Tuple3(uPoolTotalSWOP, 0, 0) | |
154 | - | } | |
155 | - | let userTotalVoteSWOP = $t048555361._1 | |
156 | - | let userUnvoted = $t048555361._2 | |
157 | - | let userUnvotedPeriod = $t048555361._3 | |
158 | - | let $t053665832 = if (isDefined(getString(this, (poolAddress + kPoolStruc)))) | |
159 | - | then { | |
160 | - | let data = split(valueOrErrorMessage(getString(this, (poolAddress + kPoolStruc)), "Empty kPoolStruc"), "_") | |
161 | - | $Tuple3(parseIntValue(data[0]), parseIntValue(data[1]), parseIntValue(data[2])) | |
162 | - | } | |
163 | - | else { | |
164 | - | let uPoolVoteSWOP = valueOrElse(getInteger(this, (poolAddress + kPoolVoteSWOP)), 0) | |
165 | - | $Tuple4(uPoolVoteSWOP, uPoolVoteSWOP, 0, 0) | |
166 | - | } | |
167 | - | let poolVoteSWOP = $t053665832._1 | |
168 | - | let poolActiveSWOP = $t053665832._2 | |
169 | - | let poolPeriod = $t053665832._3 | |
170 | - | let $t058386272 = if (isDefined(getString(this, kTotalStruc))) | |
171 | - | then { | |
172 | - | let data = split(valueOrErrorMessage(getString(this, kTotalStruc), "Empty kTotalStruc"), "_") | |
173 | - | $Tuple3(parseIntValue(data[0]), parseIntValue(data[1]), parseIntValue(data[2])) | |
174 | - | } | |
175 | - | else { | |
176 | - | let uTotalVoteSWOP = valueOrElse(getInteger(this, kTotalVoteSWOP), 0) | |
177 | - | $Tuple4(uTotalVoteSWOP, uTotalVoteSWOP, 0, 0) | |
178 | - | } | |
179 | - | let totalVoteSWOP = $t058386272._1 | |
180 | - | let totalActiveSWOP = $t058386272._2 | |
181 | - | let totalPeriod = $t058386272._3 | |
182 | - | let poolVoteDiffSWOP = (userPoolVoteSWOPnew - userPoolVoteSWOP) | |
183 | - | let userTotalVoteSWOPnew = (userTotalVoteSWOP + poolVoteDiffSWOP) | |
184 | - | if (!(isCallerInGovernance(i.caller))) | |
185 | - | then throw("This address has 0 SWOP in Governance dApp") | |
186 | - | else if ((userTotalVoteSWOPnew > userSWOPinGovernance)) | |
187 | - | then throw(((((toString(this) + " has ") + toString(userSWOPinGovernance)) + " SWOP in governance. New SWOP in voting ") + toString(userTotalVoteSWOPnew))) | |
188 | - | else if ((0 > userTotalVoteSWOPnew)) | |
189 | - | then throw("New userTotalVoteSWOPnew < 0") | |
190 | - | else if ((0 > userPoolVoteSWOPnew)) | |
191 | - | then throw("New userPoolVoteSWOPnew < 0") | |
192 | - | else { | |
193 | - | let amountOfVoting = split(valueOrElse(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)), ""), "_") | |
194 | - | let amountPoolStract = split(valueOrElse(getString(this, (poolAddress + kPoolStruc)), ""), "_") | |
195 | - | let harvestPoolActiveVoteStrucEntry = if (if ((valueOrElse(getString(this, (poolAddress + kPoolStruc)), "") != "")) | |
196 | - | then (currPeriod != valueOrElse(parseInt(amountPoolStract[2]), 0)) | |
197 | - | else false) | |
198 | - | then { | |
199 | - | let harvestPoolActiveVoteStruc = ((amountPoolStract[1] + "_") + amountPoolStract[2]) | |
200 | - | [StringEntry((poolAddress + kHarvestPoolActiveVoteStruc), harvestPoolActiveVoteStruc)] | |
201 | - | } | |
202 | - | else nil | |
203 | - | let harvestUserPoolActiveVoteStrucEntry = if (if ((valueOrElse(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)), "") != "")) | |
204 | - | then (currPeriod != valueOrElse(parseInt(amountOfVoting[2]), 0)) | |
205 | - | else false) | |
206 | - | then { | |
207 | - | let harvestUserPoolActiveVoteStruc = ((amountOfVoting[1] + "_") + amountOfVoting[2]) | |
208 | - | [StringEntry((((toString(i.caller) + "_") + poolAddress) + kHarvestUserPoolActiveVoteStruc), harvestUserPoolActiveVoteStruc)] | |
209 | - | } | |
210 | - | else nil | |
211 | - | if ((userPoolVoteSWOPnew >= userPoolVoteSWOP)) | |
212 | - | then { | |
213 | - | let coef = votingCoef() | |
214 | - | let userPoolActiveVoteSWOPnew = if ((userPoolVotePeriod == currPeriod)) | |
215 | - | then (userPoolActiveVoteSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
216 | - | else (userPoolVoteSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
217 | - | let userPoolFreezeSWOPnew = if ((userPoolVotePeriod == currPeriod)) | |
218 | - | then userPoolFreezeSWOP | |
219 | - | else userPoolVoteSWOP | |
220 | - | let userUnvotedNew = if ((userUnvotedPeriod == currPeriod)) | |
221 | - | then max([0, (userUnvoted - poolVoteDiffSWOP)]) | |
222 | - | else 0 | |
223 | - | let userUnvotedPeriodNew = currPeriod | |
224 | - | let userPoolStrucNew = ((((((toString(userPoolVoteSWOPnew) + "_") + toString(userPoolActiveVoteSWOPnew)) + "_") + toString(currPeriod)) + "_") + toString(userPoolFreezeSWOPnew)) | |
225 | - | let userPoolEntry = [StringEntry((((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc), userPoolStrucNew)] | |
226 | - | let userTotalStrucNew = ((((toString(userTotalVoteSWOPnew) + "_") + toString(userUnvotedNew)) + "_") + toString(userUnvotedPeriodNew)) | |
227 | - | let userTotalEntry = [StringEntry((toString(i.caller) + kUserTotalStruc), userTotalStrucNew)] | |
228 | - | let poolVoteSWOPnew = (poolVoteSWOP + poolVoteDiffSWOP) | |
229 | - | let poolActiveSWOPnew = if ((poolPeriod == currPeriod)) | |
230 | - | then (poolActiveSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
231 | - | else (poolVoteSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
232 | - | let poolStrucNew = ((((toString(poolVoteSWOPnew) + "_") + toString(poolActiveSWOPnew)) + "_") + toString(currPeriod)) | |
233 | - | let poolEntry = [StringEntry((poolAddress + kPoolStruc), poolStrucNew)] | |
234 | - | let totalVoteSWOPnew = (totalVoteSWOP + poolVoteDiffSWOP) | |
235 | - | let totalActiveSWOPnew = if ((totalPeriod == currPeriod)) | |
236 | - | then (totalActiveSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
237 | - | else (totalVoteSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
238 | - | let totalStrucNew = ((((toString(totalVoteSWOPnew) + "_") + toString(totalActiveSWOPnew)) + "_") + toString(currPeriod)) | |
239 | - | let totalEntry = [StringEntry(kTotalStruc, totalStrucNew)] | |
240 | - | ((((((userPoolEntry ++ userTotalEntry) ++ poolEntry) ++ totalEntry) ++ calcDeleteEntry(toString(i.caller), poolAddress, userPoolVoteSWOPnew)) ++ harvestPoolActiveVoteStrucEntry) ++ harvestUserPoolActiveVoteStrucEntry) | |
241 | - | } | |
242 | - | else { | |
243 | - | let removePoolVote = -(poolVoteDiffSWOP) | |
244 | - | let userPoolFreezeSWOPnew = if ((userPoolVotePeriod == currPeriod)) | |
245 | - | then userPoolFreezeSWOP | |
246 | - | else userPoolVoteSWOP | |
247 | - | let userPoolFreezeSWOP2 = min([userPoolFreezeSWOP, userPoolVoteSWOP]) | |
248 | - | let userPoolFreezeSWOPnew2 = min([userPoolFreezeSWOPnew, userPoolVoteSWOPnew]) | |
249 | - | let userPoolActiveVoteSWOPnew = (userPoolFreezeSWOPnew2 + (if (((userPoolVoteSWOP - userPoolFreezeSWOP) == 0)) | |
250 | - | then 0 | |
251 | - | else fraction((userPoolActiveVoteSWOP - userPoolFreezeSWOP), (userPoolVoteSWOPnew - userPoolFreezeSWOPnew2), (userPoolVoteSWOP - userPoolFreezeSWOP)))) | |
252 | - | let userPoolActiveVoteDiff = (userPoolActiveVoteSWOPnew - (if ((userPoolVotePeriod == currPeriod)) | |
253 | - | then userPoolActiveVoteSWOP | |
254 | - | else userPoolVoteSWOP)) | |
255 | - | let newUnvoted = max([0, (removePoolVote - (if ((userPoolVotePeriod == currPeriod)) | |
256 | - | then (userPoolVoteSWOP - userPoolFreezeSWOP2) | |
257 | - | else 0))]) | |
258 | - | let userUnvotedNew = (newUnvoted + (if ((userUnvotedPeriod == currPeriod)) | |
259 | - | then userUnvoted | |
260 | - | else 0)) | |
261 | - | let userUnvotedPeriodNew = if ((newUnvoted > 0)) | |
262 | - | then currPeriod | |
263 | - | else userUnvotedPeriod | |
264 | - | let userPoolStrucNew = ((((((toString(userPoolVoteSWOPnew) + "_") + toString(userPoolActiveVoteSWOPnew)) + "_") + toString(currPeriod)) + "_") + toString(userPoolFreezeSWOPnew)) | |
265 | - | let userPoolEntry = [StringEntry((((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc), userPoolStrucNew)] | |
266 | - | let userTotalStrucNew = ((((toString(userTotalVoteSWOPnew) + "_") + toString(userUnvotedNew)) + "_") + toString(userUnvotedPeriodNew)) | |
267 | - | let userTotalEntry = [StringEntry((toString(i.caller) + kUserTotalStruc), userTotalStrucNew)] | |
268 | - | let poolVoteSWOPnew = (poolVoteSWOP - removePoolVote) | |
269 | - | let poolActiveSWOPnew = if ((poolPeriod == currPeriod)) | |
270 | - | then (poolActiveSWOP + userPoolActiveVoteDiff) | |
271 | - | else (poolVoteSWOP + userPoolActiveVoteDiff) | |
272 | - | let poolStrucNew = ((((toString(poolVoteSWOPnew) + "_") + toString(poolActiveSWOPnew)) + "_") + toString(currPeriod)) | |
273 | - | let poolEntry = [StringEntry((poolAddress + kPoolStruc), poolStrucNew)] | |
274 | - | let totalVoteSWOPnew = (totalVoteSWOP - removePoolVote) | |
275 | - | let totalActiveSWOPnew = if ((totalPeriod == currPeriod)) | |
276 | - | then (totalActiveSWOP + userPoolActiveVoteDiff) | |
277 | - | else (totalVoteSWOP + userPoolActiveVoteDiff) | |
278 | - | let totalStrucNew = ((((toString(totalVoteSWOPnew) + "_") + toString(totalActiveSWOPnew)) + "_") + toString(currPeriod)) | |
279 | - | let totalEntry = [StringEntry(kTotalStruc, totalStrucNew)] | |
280 | - | let allNewValues = [currPeriod, userPoolFreezeSWOPnew, userPoolActiveVoteSWOPnew, userPoolFreezeSWOPnew, userUnvotedNew, userUnvotedPeriodNew, poolVoteSWOPnew, poolActiveSWOPnew, totalVoteSWOPnew, totalActiveSWOPnew] | |
281 | - | if ((0 > min(allNewValues))) | |
282 | - | then throw("One or more values are negative") | |
283 | - | else ((((((userPoolEntry ++ userTotalEntry) ++ poolEntry) ++ totalEntry) ++ calcDeleteEntry(toString(i.caller), poolAddress, userPoolVoteSWOPnew)) ++ harvestPoolActiveVoteStrucEntry) ++ harvestUserPoolActiveVoteStrucEntry) | |
284 | - | } | |
285 | - | } | |
286 | - | } | |
287 | 165 | }) | |
288 | 166 | ||
289 | 167 | ||
290 | 168 | ||
291 | 169 | @Callable(i) | |
292 | - | func shutdown () = if (!(active)) | |
293 | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified"))) | |
294 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
295 | - | then throw("Only admin can call this function") | |
296 | - | else suspend("Paused by admin") | |
170 | + | func shutdown () = valueOrElse(isAdminCall(i), if (!(active)) | |
171 | + | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
172 | + | else suspend("Paused by admin")) | |
297 | 173 | ||
298 | 174 | ||
299 | 175 | ||
300 | 176 | @Callable(i) | |
301 | - | func activate () = if (active) | |
177 | + | func activate () = valueOrElse(isAdminCall(i), if (active) | |
302 | 178 | then throw("DApp is already active") | |
303 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
304 | - | then throw("Only admin can call this function") | |
305 | - | else [BooleanEntry(keyActive, true), DeleteEntry(keyCause)] | |
179 | + | else [BooleanEntry(kActive, true), DeleteEntry(kCause)]) | |
306 | 180 | ||
307 | 181 | ||
308 | 182 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let kActive = "active" | |
5 | 5 | ||
6 | - | let | |
6 | + | let keyActiveGlob = "active_all_contracts" | |
7 | 7 | ||
8 | - | let | |
8 | + | let kCause = "shutdown_cause" | |
9 | 9 | ||
10 | - | let | |
10 | + | let kUserPoolVote = "_user_vote_gSWOP" | |
11 | 11 | ||
12 | - | let | |
12 | + | let kUserTotalVote = "_user_total_vote_gSWOP" | |
13 | 13 | ||
14 | - | let | |
14 | + | let kPoolVote = "_pool_vote_gSWOP" | |
15 | 15 | ||
16 | - | let | |
16 | + | let kTotalVote = "total_vote_gSWOP" | |
17 | 17 | ||
18 | - | let | |
18 | + | let kHarvestPoolVote = "_harvest_pool_vote_gSWOP" | |
19 | 19 | ||
20 | - | let kTotalVoteSWOP = "total_vote_SWOP" | |
21 | - | ||
22 | - | let kTotalStruc = "total_struc" | |
23 | - | ||
24 | - | let keyAdminPubKey1 = "admin_pub_1" | |
25 | - | ||
26 | - | let keyAdminPubKey2 = "admin_pub_2" | |
27 | - | ||
28 | - | let keyAdminPubKey3 = "admin_pub_3" | |
29 | - | ||
30 | - | let kHarvestPoolActiveVoteStruc = "_harvest_pool_activeVote_struc" | |
31 | - | ||
32 | - | let kHarvestUserPoolActiveVoteStruc = "_harvest_user_pool_activeVote_struc" | |
20 | + | let kHarvestUserPoolVote = "_harvest_user_pool_vote_gSWOP" | |
33 | 21 | ||
34 | 22 | let kStartHeight = "start_height" | |
35 | 23 | ||
36 | 24 | let kBasePeriod = "base_period" | |
37 | 25 | ||
38 | 26 | let kPeriodLength = "period_length" | |
39 | 27 | ||
40 | - | let | |
28 | + | let kAdminPubKey1 = "admin_pub_1" | |
41 | 29 | ||
42 | - | let | |
30 | + | let kAdminPubKey2 = "admin_pub_2" | |
43 | 31 | ||
44 | - | let | |
32 | + | let kAdminPubKey3 = "admin_pub_3" | |
45 | 33 | ||
46 | - | let active = valueOrElse(getBoolean(this, keyActive), true) | |
34 | + | let kFarmingAddr = "farming_address" | |
35 | + | ||
36 | + | let kGovAddress = "governance_address" | |
37 | + | ||
38 | + | let kPoolFirstHarvestEndHeight = "first_harvest_height" | |
39 | + | ||
40 | + | let kPoolStruc = "_pool_struc" | |
41 | + | ||
42 | + | let kUserPoolStruc = "_user_pool_struc" | |
43 | + | ||
44 | + | let kUserTotalStruc = "_user_total_struc" | |
45 | + | ||
46 | + | let kTotalStruc = "total_struc" | |
47 | + | ||
48 | + | let kHarvestPoolActiveVoteStruc = "_harvest_pool_activeVote_struc" | |
49 | + | ||
50 | + | let kHarvestUserPoolActiveVoteStruc = "_harvest_user_pool_activeVote_struc" | |
51 | + | ||
52 | + | let oracle = Address(base58'3MvVBtsXroQpy1tsPw21TU2ET9A8WfmrNjz') | |
53 | + | ||
54 | + | let active = valueOrElse(getBoolean(this, kActive), true) | |
55 | + | ||
56 | + | let activeGlob = valueOrElse(getBoolean(oracle, keyActiveGlob), true) | |
47 | 57 | ||
48 | 58 | let basePeriod = valueOrErrorMessage(getInteger(this, kBasePeriod), "Empty kBasePeriod") | |
49 | 59 | ||
50 | 60 | let startHeight = valueOrErrorMessage(getInteger(this, kStartHeight), "Empty kStartHeight") | |
51 | 61 | ||
52 | 62 | let periodLength = valueOrErrorMessage(getInteger(this, kPeriodLength), "Empty kPeriodLength") | |
53 | 63 | ||
54 | - | let durationFullVotePower = valueOrErrorMessage(getInteger(this, kDurationFullVotePower), "Empty kDurationFullVotePower") | |
55 | - | ||
56 | - | let minVotePower = valueOrErrorMessage(getInteger(this, kMinVotePower), "Empty kMinVotePower") | |
57 | - | ||
58 | - | let govAddr = Address(base58'3N8E9LU71MDkdP8FWtbP4TBXCNhoc15hWfs') | |
59 | - | ||
60 | - | let oracle = Address(base58'3MvVBtsXroQpy1tsPw21TU2ET9A8WfmrNjz') | |
61 | - | ||
62 | - | func getAdminPub (keyAdminPub) = match getString(oracle, keyAdminPub) { | |
64 | + | func getBase58FromOracle (key) = match getString(oracle, key) { | |
63 | 65 | case string: String => | |
64 | 66 | fromBase58String(string) | |
65 | 67 | case nothing => | |
66 | - | throw( | |
68 | + | throw((key + "is empty")) | |
67 | 69 | } | |
68 | 70 | ||
69 | 71 | ||
70 | - | let adminPubKey1 = | |
72 | + | let adminPubKey1 = getBase58FromOracle(kAdminPubKey1) | |
71 | 73 | ||
72 | - | let adminPubKey2 = | |
74 | + | let adminPubKey2 = getBase58FromOracle(kAdminPubKey2) | |
73 | 75 | ||
74 | - | let adminPubKey3 = | |
76 | + | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
75 | 77 | ||
76 | - | let adminPubKeyStartStop = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
78 | + | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
79 | + | ||
80 | + | let farmingAddr = Address(getBase58FromOracle(kFarmingAddr)) | |
77 | 81 | ||
78 | 82 | let currPeriod = (basePeriod + ((height - startHeight) / periodLength)) | |
79 | 83 | ||
80 | - | func isActive () = if (active) | |
84 | + | func isActive () = if (if (active) | |
85 | + | then activeGlob | |
86 | + | else false) | |
81 | 87 | then unit | |
82 | 88 | else throw("DApp is inactive at this moment") | |
83 | 89 | ||
84 | 90 | ||
85 | - | func suspend (cause) = [BooleanEntry(keyActive, false), StringEntry(keyCause, cause)] | |
91 | + | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
92 | + | then unit | |
93 | + | else throw("Only admin can call this function") | |
86 | 94 | ||
87 | 95 | ||
88 | - | func isCallerInGovernance (user) = if ((valueOrElse(getInteger(govAddr, (toString(user) + "_SWOP_amount")), 0) > 0)) | |
89 | - | then true | |
90 | - | else false | |
96 | + | func isCallerInGovernance (user) = (valueOrElse(getInteger(govAddress, (toString(user) + "_SWOP_amount")), 0) > 0) | |
91 | 97 | ||
92 | 98 | ||
93 | - | func isPoolInGovernance (poolAddress) = isDefined(getInteger( | |
99 | + | func isPoolInGovernance (poolAddress) = isDefined(getInteger(govAddress, (poolAddress + "_current_pool_fraction_reward"))) | |
94 | 100 | ||
95 | 101 | ||
96 | - | func votingCoef () = { | |
97 | - | let votingDuration = (height - (startHeight + (currPeriod * periodLength))) | |
98 | - | if ((durationFullVotePower > votingDuration)) | |
99 | - | then scale8 | |
100 | - | else { | |
101 | - | let x1 = durationFullVotePower | |
102 | - | let y1 = scale8 | |
103 | - | let x2 = periodLength | |
104 | - | let y2 = minVotePower | |
105 | - | let k = (((y2 - y1) * scale8) / (x2 - x1)) | |
106 | - | let b = ((y1 * scale8) - (k * x1)) | |
107 | - | (((votingDuration * k) / scale8) + (b / scale8)) | |
108 | - | } | |
109 | - | } | |
102 | + | func getPoolFirstHarvestStartHeight (poolAddress) = (valueOrElse(getInteger(Address(fromBase58String(poolAddress)), kPoolFirstHarvestEndHeight), 0) - periodLength) | |
110 | 103 | ||
111 | 104 | ||
112 | - | func calcDeleteEntry (caller,poolAddress,userPoolVoteSWOPnew) = { | |
105 | + | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
106 | + | ||
107 | + | ||
108 | + | func calcDeleteEntry (caller,poolAddress) = { | |
113 | 109 | func deleteIfExists (list,key) = if (isDefined(getInteger(this, key))) | |
114 | 110 | then (list :+ DeleteEntry(key)) | |
115 | 111 | else list | |
116 | 112 | ||
117 | - | deleteIfExists(deleteIfExists(deleteIfExists(deleteIfExists(nil, (((caller + "_") + poolAddress) + | |
113 | + | deleteIfExists(deleteIfExists(deleteIfExists(deleteIfExists(deleteIfExists(deleteIfExists(nil, (((caller + "_") + poolAddress) + kUserPoolStruc)), (caller + kUserTotalStruc)), (poolAddress + kPoolStruc)), kTotalStruc), (poolAddress + kHarvestPoolActiveVoteStruc)), (((caller + "_") + poolAddress) + kHarvestUserPoolActiveVoteStruc)) | |
118 | 114 | } | |
119 | 115 | ||
120 | 116 | ||
121 | 117 | @Callable(i) | |
122 | - | func votePoolWeight (poolAddressesL,poolsVoteSWOPNewL) = valueOrElse(isActive(), if (if ((size(poolAddressesL) > 1)) | |
123 | - | then true | |
124 | - | else (size(poolsVoteSWOPNewL) > 1)) | |
125 | - | then throw("poolAddressesL.size > 1 or poolsVoteSWOPNewL.size > 1") | |
118 | + | func votePoolWeight (poolAddress,userPoolVoteNew) = valueOrElse(isActive(), if (!(isPoolInGovernance(poolAddress))) | |
119 | + | then throw("This pool is not in Governance dApp") | |
126 | 120 | else { | |
127 | - | let poolAddress = poolAddressesL[0] | |
128 | - | let userPoolVoteSWOPnew = poolsVoteSWOPNewL[0] | |
129 | - | if (!(isPoolInGovernance(poolAddress))) | |
130 | - | then throw("This pool has no _current_pool_fraction_reward in Governance dApp") | |
131 | - | else { | |
132 | - | let userSWOPinGovernance = valueOrErrorMessage(getInteger(govAddr, (toString(i.caller) + "_SWOP_amount")), "Empty _SWOP_amount at gov. address") | |
133 | - | let $t042184849 = if (isDefined(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)))) | |
134 | - | then { | |
135 | - | let data = split(valueOrErrorMessage(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)), "Empty kUserPoolStruc"), "_") | |
136 | - | $Tuple4(parseIntValue(data[0]), parseIntValue(data[1]), parseIntValue(data[2]), parseIntValue(data[3])) | |
121 | + | let userSWOPinGovernance = valueOrErrorMessage(getInteger(govAddress, (toString(i.caller) + "_SWOP_amount")), "Empty _SWOP_amount at gov. address") | |
122 | + | let userGSWOPinGovernance = valueOrElse(getInteger(govAddress, (toString(i.caller) + "_GSwop_amount")), userSWOPinGovernance) | |
123 | + | let userPoolVote = if (isDefined(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)))) | |
124 | + | then parseIntValue(split(value(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc))), "_")[0]) | |
125 | + | else valueOrElse(getInteger(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolVote)), 0) | |
126 | + | let userTotalVote = if (isDefined(getString(this, (toString(i.caller) + kUserTotalStruc)))) | |
127 | + | then parseIntValue(split(value(getString(this, (toString(i.caller) + kUserTotalStruc))), "_")[0]) | |
128 | + | else valueOrElse(getInteger(this, (toString(i.caller) + kUserTotalVote)), 0) | |
129 | + | let poolVote = if (isDefined(getString(this, (poolAddress + kPoolStruc)))) | |
130 | + | then parseIntValue(split(value(getString(this, (poolAddress + kPoolStruc))), "_")[0]) | |
131 | + | else valueOrElse(getInteger(this, (poolAddress + kPoolVote)), 0) | |
132 | + | let totalVote = if (isDefined(getString(this, kTotalStruc))) | |
133 | + | then parseIntValue(split(value(getString(this, kTotalStruc)), "_")[0]) | |
134 | + | else valueOrElse(getInteger(this, kTotalVote), 0) | |
135 | + | let poolVoteDiff = (userPoolVoteNew - userPoolVote) | |
136 | + | let userTotalVoteNew = (userTotalVote + poolVoteDiff) | |
137 | + | if ((userTotalVoteNew > userGSWOPinGovernance)) | |
138 | + | then throw(((((toString(i.caller) + " has ") + toString(userGSWOPinGovernance)) + " GSWOP in governance. New GSWOP in voting ") + toString(userTotalVoteNew))) | |
139 | + | else if ((0 > userTotalVoteNew)) | |
140 | + | then throw("New userTotalVoteSWOPnew < 0") | |
141 | + | else if ((0 > userPoolVoteNew)) | |
142 | + | then throw("New userPoolVoteSWOPnew < 0") | |
143 | + | else { | |
144 | + | let removePoolVote = -(poolVoteDiff) | |
145 | + | let poolVoteNew = if ((userPoolVoteNew >= userPoolVote)) | |
146 | + | then (poolVote + poolVoteDiff) | |
147 | + | else (poolVote - removePoolVote) | |
148 | + | let totalVoteNew = if ((userPoolVoteNew >= userPoolVote)) | |
149 | + | then (totalVote + poolVoteDiff) | |
150 | + | else (totalVote - removePoolVote) | |
151 | + | if (if ((0 > poolVoteNew)) | |
152 | + | then true | |
153 | + | else (0 > totalVoteNew)) | |
154 | + | then throw("One or more values are negative") | |
155 | + | else { | |
156 | + | let harvestEntries = if ((height > getPoolFirstHarvestStartHeight(poolAddress))) | |
157 | + | then [IntegerEntry((poolAddress + kHarvestPoolVote), poolVoteNew), IntegerEntry((((toString(i.caller) + "_") + poolAddress) + kHarvestUserPoolVote), userPoolVoteNew)] | |
158 | + | else nil | |
159 | + | let upUIntr = invoke(farmingAddr, "updateUserBoostInterest", [poolAddress, toString(i.caller)], nil) | |
160 | + | if ((upUIntr == upUIntr)) | |
161 | + | then (([IntegerEntry((((toString(i.caller) + "_") + poolAddress) + kUserPoolVote), userPoolVoteNew), IntegerEntry((toString(i.caller) + kUserTotalVote), userTotalVoteNew), IntegerEntry((poolAddress + kPoolVote), poolVoteNew), IntegerEntry(kTotalVote, totalVoteNew)] ++ calcDeleteEntry(toString(i.caller), poolAddress)) ++ harvestEntries) | |
162 | + | else throw("Strict value is not equal to itself.") | |
163 | + | } | |
137 | 164 | } | |
138 | - | else { | |
139 | - | let uPoolVoteSWOP = valueOrElse(getInteger(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolVoteSWOP)), 0) | |
140 | - | $Tuple4(uPoolVoteSWOP, uPoolVoteSWOP, 0, 0) | |
141 | - | } | |
142 | - | let userPoolVoteSWOP = $t042184849._1 | |
143 | - | let userPoolActiveVoteSWOP = $t042184849._2 | |
144 | - | let userPoolVotePeriod = $t042184849._3 | |
145 | - | let userPoolFreezeSWOP = $t042184849._4 | |
146 | - | let $t048555361 = if (isDefined(getString(this, (toString(i.caller) + kUserTotalStruc)))) | |
147 | - | then { | |
148 | - | let data = split(valueOrErrorMessage(getString(this, (toString(i.caller) + kUserTotalStruc)), "Empty kUserTotalStruc"), "_") | |
149 | - | $Tuple3(parseIntValue(data[0]), parseIntValue(data[1]), parseIntValue(data[2])) | |
150 | - | } | |
151 | - | else { | |
152 | - | let uPoolTotalSWOP = valueOrElse(getInteger(this, (toString(i.caller) + kUserTotalVoteSWOP)), 0) | |
153 | - | $Tuple3(uPoolTotalSWOP, 0, 0) | |
154 | - | } | |
155 | - | let userTotalVoteSWOP = $t048555361._1 | |
156 | - | let userUnvoted = $t048555361._2 | |
157 | - | let userUnvotedPeriod = $t048555361._3 | |
158 | - | let $t053665832 = if (isDefined(getString(this, (poolAddress + kPoolStruc)))) | |
159 | - | then { | |
160 | - | let data = split(valueOrErrorMessage(getString(this, (poolAddress + kPoolStruc)), "Empty kPoolStruc"), "_") | |
161 | - | $Tuple3(parseIntValue(data[0]), parseIntValue(data[1]), parseIntValue(data[2])) | |
162 | - | } | |
163 | - | else { | |
164 | - | let uPoolVoteSWOP = valueOrElse(getInteger(this, (poolAddress + kPoolVoteSWOP)), 0) | |
165 | - | $Tuple4(uPoolVoteSWOP, uPoolVoteSWOP, 0, 0) | |
166 | - | } | |
167 | - | let poolVoteSWOP = $t053665832._1 | |
168 | - | let poolActiveSWOP = $t053665832._2 | |
169 | - | let poolPeriod = $t053665832._3 | |
170 | - | let $t058386272 = if (isDefined(getString(this, kTotalStruc))) | |
171 | - | then { | |
172 | - | let data = split(valueOrErrorMessage(getString(this, kTotalStruc), "Empty kTotalStruc"), "_") | |
173 | - | $Tuple3(parseIntValue(data[0]), parseIntValue(data[1]), parseIntValue(data[2])) | |
174 | - | } | |
175 | - | else { | |
176 | - | let uTotalVoteSWOP = valueOrElse(getInteger(this, kTotalVoteSWOP), 0) | |
177 | - | $Tuple4(uTotalVoteSWOP, uTotalVoteSWOP, 0, 0) | |
178 | - | } | |
179 | - | let totalVoteSWOP = $t058386272._1 | |
180 | - | let totalActiveSWOP = $t058386272._2 | |
181 | - | let totalPeriod = $t058386272._3 | |
182 | - | let poolVoteDiffSWOP = (userPoolVoteSWOPnew - userPoolVoteSWOP) | |
183 | - | let userTotalVoteSWOPnew = (userTotalVoteSWOP + poolVoteDiffSWOP) | |
184 | - | if (!(isCallerInGovernance(i.caller))) | |
185 | - | then throw("This address has 0 SWOP in Governance dApp") | |
186 | - | else if ((userTotalVoteSWOPnew > userSWOPinGovernance)) | |
187 | - | then throw(((((toString(this) + " has ") + toString(userSWOPinGovernance)) + " SWOP in governance. New SWOP in voting ") + toString(userTotalVoteSWOPnew))) | |
188 | - | else if ((0 > userTotalVoteSWOPnew)) | |
189 | - | then throw("New userTotalVoteSWOPnew < 0") | |
190 | - | else if ((0 > userPoolVoteSWOPnew)) | |
191 | - | then throw("New userPoolVoteSWOPnew < 0") | |
192 | - | else { | |
193 | - | let amountOfVoting = split(valueOrElse(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)), ""), "_") | |
194 | - | let amountPoolStract = split(valueOrElse(getString(this, (poolAddress + kPoolStruc)), ""), "_") | |
195 | - | let harvestPoolActiveVoteStrucEntry = if (if ((valueOrElse(getString(this, (poolAddress + kPoolStruc)), "") != "")) | |
196 | - | then (currPeriod != valueOrElse(parseInt(amountPoolStract[2]), 0)) | |
197 | - | else false) | |
198 | - | then { | |
199 | - | let harvestPoolActiveVoteStruc = ((amountPoolStract[1] + "_") + amountPoolStract[2]) | |
200 | - | [StringEntry((poolAddress + kHarvestPoolActiveVoteStruc), harvestPoolActiveVoteStruc)] | |
201 | - | } | |
202 | - | else nil | |
203 | - | let harvestUserPoolActiveVoteStrucEntry = if (if ((valueOrElse(getString(this, (((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc)), "") != "")) | |
204 | - | then (currPeriod != valueOrElse(parseInt(amountOfVoting[2]), 0)) | |
205 | - | else false) | |
206 | - | then { | |
207 | - | let harvestUserPoolActiveVoteStruc = ((amountOfVoting[1] + "_") + amountOfVoting[2]) | |
208 | - | [StringEntry((((toString(i.caller) + "_") + poolAddress) + kHarvestUserPoolActiveVoteStruc), harvestUserPoolActiveVoteStruc)] | |
209 | - | } | |
210 | - | else nil | |
211 | - | if ((userPoolVoteSWOPnew >= userPoolVoteSWOP)) | |
212 | - | then { | |
213 | - | let coef = votingCoef() | |
214 | - | let userPoolActiveVoteSWOPnew = if ((userPoolVotePeriod == currPeriod)) | |
215 | - | then (userPoolActiveVoteSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
216 | - | else (userPoolVoteSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
217 | - | let userPoolFreezeSWOPnew = if ((userPoolVotePeriod == currPeriod)) | |
218 | - | then userPoolFreezeSWOP | |
219 | - | else userPoolVoteSWOP | |
220 | - | let userUnvotedNew = if ((userUnvotedPeriod == currPeriod)) | |
221 | - | then max([0, (userUnvoted - poolVoteDiffSWOP)]) | |
222 | - | else 0 | |
223 | - | let userUnvotedPeriodNew = currPeriod | |
224 | - | let userPoolStrucNew = ((((((toString(userPoolVoteSWOPnew) + "_") + toString(userPoolActiveVoteSWOPnew)) + "_") + toString(currPeriod)) + "_") + toString(userPoolFreezeSWOPnew)) | |
225 | - | let userPoolEntry = [StringEntry((((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc), userPoolStrucNew)] | |
226 | - | let userTotalStrucNew = ((((toString(userTotalVoteSWOPnew) + "_") + toString(userUnvotedNew)) + "_") + toString(userUnvotedPeriodNew)) | |
227 | - | let userTotalEntry = [StringEntry((toString(i.caller) + kUserTotalStruc), userTotalStrucNew)] | |
228 | - | let poolVoteSWOPnew = (poolVoteSWOP + poolVoteDiffSWOP) | |
229 | - | let poolActiveSWOPnew = if ((poolPeriod == currPeriod)) | |
230 | - | then (poolActiveSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
231 | - | else (poolVoteSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
232 | - | let poolStrucNew = ((((toString(poolVoteSWOPnew) + "_") + toString(poolActiveSWOPnew)) + "_") + toString(currPeriod)) | |
233 | - | let poolEntry = [StringEntry((poolAddress + kPoolStruc), poolStrucNew)] | |
234 | - | let totalVoteSWOPnew = (totalVoteSWOP + poolVoteDiffSWOP) | |
235 | - | let totalActiveSWOPnew = if ((totalPeriod == currPeriod)) | |
236 | - | then (totalActiveSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
237 | - | else (totalVoteSWOP + fraction(poolVoteDiffSWOP, coef, scale8)) | |
238 | - | let totalStrucNew = ((((toString(totalVoteSWOPnew) + "_") + toString(totalActiveSWOPnew)) + "_") + toString(currPeriod)) | |
239 | - | let totalEntry = [StringEntry(kTotalStruc, totalStrucNew)] | |
240 | - | ((((((userPoolEntry ++ userTotalEntry) ++ poolEntry) ++ totalEntry) ++ calcDeleteEntry(toString(i.caller), poolAddress, userPoolVoteSWOPnew)) ++ harvestPoolActiveVoteStrucEntry) ++ harvestUserPoolActiveVoteStrucEntry) | |
241 | - | } | |
242 | - | else { | |
243 | - | let removePoolVote = -(poolVoteDiffSWOP) | |
244 | - | let userPoolFreezeSWOPnew = if ((userPoolVotePeriod == currPeriod)) | |
245 | - | then userPoolFreezeSWOP | |
246 | - | else userPoolVoteSWOP | |
247 | - | let userPoolFreezeSWOP2 = min([userPoolFreezeSWOP, userPoolVoteSWOP]) | |
248 | - | let userPoolFreezeSWOPnew2 = min([userPoolFreezeSWOPnew, userPoolVoteSWOPnew]) | |
249 | - | let userPoolActiveVoteSWOPnew = (userPoolFreezeSWOPnew2 + (if (((userPoolVoteSWOP - userPoolFreezeSWOP) == 0)) | |
250 | - | then 0 | |
251 | - | else fraction((userPoolActiveVoteSWOP - userPoolFreezeSWOP), (userPoolVoteSWOPnew - userPoolFreezeSWOPnew2), (userPoolVoteSWOP - userPoolFreezeSWOP)))) | |
252 | - | let userPoolActiveVoteDiff = (userPoolActiveVoteSWOPnew - (if ((userPoolVotePeriod == currPeriod)) | |
253 | - | then userPoolActiveVoteSWOP | |
254 | - | else userPoolVoteSWOP)) | |
255 | - | let newUnvoted = max([0, (removePoolVote - (if ((userPoolVotePeriod == currPeriod)) | |
256 | - | then (userPoolVoteSWOP - userPoolFreezeSWOP2) | |
257 | - | else 0))]) | |
258 | - | let userUnvotedNew = (newUnvoted + (if ((userUnvotedPeriod == currPeriod)) | |
259 | - | then userUnvoted | |
260 | - | else 0)) | |
261 | - | let userUnvotedPeriodNew = if ((newUnvoted > 0)) | |
262 | - | then currPeriod | |
263 | - | else userUnvotedPeriod | |
264 | - | let userPoolStrucNew = ((((((toString(userPoolVoteSWOPnew) + "_") + toString(userPoolActiveVoteSWOPnew)) + "_") + toString(currPeriod)) + "_") + toString(userPoolFreezeSWOPnew)) | |
265 | - | let userPoolEntry = [StringEntry((((toString(i.caller) + "_") + poolAddress) + kUserPoolStruc), userPoolStrucNew)] | |
266 | - | let userTotalStrucNew = ((((toString(userTotalVoteSWOPnew) + "_") + toString(userUnvotedNew)) + "_") + toString(userUnvotedPeriodNew)) | |
267 | - | let userTotalEntry = [StringEntry((toString(i.caller) + kUserTotalStruc), userTotalStrucNew)] | |
268 | - | let poolVoteSWOPnew = (poolVoteSWOP - removePoolVote) | |
269 | - | let poolActiveSWOPnew = if ((poolPeriod == currPeriod)) | |
270 | - | then (poolActiveSWOP + userPoolActiveVoteDiff) | |
271 | - | else (poolVoteSWOP + userPoolActiveVoteDiff) | |
272 | - | let poolStrucNew = ((((toString(poolVoteSWOPnew) + "_") + toString(poolActiveSWOPnew)) + "_") + toString(currPeriod)) | |
273 | - | let poolEntry = [StringEntry((poolAddress + kPoolStruc), poolStrucNew)] | |
274 | - | let totalVoteSWOPnew = (totalVoteSWOP - removePoolVote) | |
275 | - | let totalActiveSWOPnew = if ((totalPeriod == currPeriod)) | |
276 | - | then (totalActiveSWOP + userPoolActiveVoteDiff) | |
277 | - | else (totalVoteSWOP + userPoolActiveVoteDiff) | |
278 | - | let totalStrucNew = ((((toString(totalVoteSWOPnew) + "_") + toString(totalActiveSWOPnew)) + "_") + toString(currPeriod)) | |
279 | - | let totalEntry = [StringEntry(kTotalStruc, totalStrucNew)] | |
280 | - | let allNewValues = [currPeriod, userPoolFreezeSWOPnew, userPoolActiveVoteSWOPnew, userPoolFreezeSWOPnew, userUnvotedNew, userUnvotedPeriodNew, poolVoteSWOPnew, poolActiveSWOPnew, totalVoteSWOPnew, totalActiveSWOPnew] | |
281 | - | if ((0 > min(allNewValues))) | |
282 | - | then throw("One or more values are negative") | |
283 | - | else ((((((userPoolEntry ++ userTotalEntry) ++ poolEntry) ++ totalEntry) ++ calcDeleteEntry(toString(i.caller), poolAddress, userPoolVoteSWOPnew)) ++ harvestPoolActiveVoteStrucEntry) ++ harvestUserPoolActiveVoteStrucEntry) | |
284 | - | } | |
285 | - | } | |
286 | - | } | |
287 | 165 | }) | |
288 | 166 | ||
289 | 167 | ||
290 | 168 | ||
291 | 169 | @Callable(i) | |
292 | - | func shutdown () = if (!(active)) | |
293 | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, keyCause), "the cause wasn't specified"))) | |
294 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
295 | - | then throw("Only admin can call this function") | |
296 | - | else suspend("Paused by admin") | |
170 | + | func shutdown () = valueOrElse(isAdminCall(i), if (!(active)) | |
171 | + | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
172 | + | else suspend("Paused by admin")) | |
297 | 173 | ||
298 | 174 | ||
299 | 175 | ||
300 | 176 | @Callable(i) | |
301 | - | func activate () = if (active) | |
177 | + | func activate () = valueOrElse(isAdminCall(i), if (active) | |
302 | 178 | then throw("DApp is already active") | |
303 | - | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3, adminPubKeyStartStop], i.callerPublicKey))) | |
304 | - | then throw("Only admin can call this function") | |
305 | - | else [BooleanEntry(keyActive, true), DeleteEntry(keyCause)] | |
179 | + | else [BooleanEntry(kActive, true), DeleteEntry(kCause)]) | |
306 | 180 | ||
307 | 181 | ||
308 | 182 | @Verifier(tx) | |
309 | 183 | func verify () = { | |
310 | 184 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
311 | 185 | then 1 | |
312 | 186 | else 0 | |
313 | 187 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2)) | |
314 | 188 | then 1 | |
315 | 189 | else 0 | |
316 | 190 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3)) | |
317 | 191 | then 1 | |
318 | 192 | else 0 | |
319 | 193 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
320 | 194 | } | |
321 | 195 |
github/deemru/w8io/169f3d6 73.51 ms ◑