tx · CK4sYcu67kpWrryazaT54bguTXR2LWzHnenFWnhhvLGn 3N6HSS7Toat1RhyEsyqVGgVSRzH19W1FTbP: -0.01800000 Waves 2023.07.27 13:55 [2684165] smart account 3N6HSS7Toat1RhyEsyqVGgVSRzH19W1FTbP > SELF 0.00000000 Waves
{ "type": 13, "id": "CK4sYcu67kpWrryazaT54bguTXR2LWzHnenFWnhhvLGn", "fee": 1800000, "feeAssetId": null, "timestamp": 1690455309524, "version": 2, "chainId": 84, "sender": "3N6HSS7Toat1RhyEsyqVGgVSRzH19W1FTbP", "senderPublicKey": "AoKo4segKHU4DeJnxXQYJj2u7J6XJeux6r8KLW52cd2Q", "proofs": [ "4CeC9iB1N4yYNpFNwTv7hTAHK5AH2oa97qQ1tSEfT2W5uCHKF3NADucKGstFmEyGxdaJNhdqvYAjYk3UPPYLGo3t" ], "script": "base64:BgIrCAISBQoDCAEIEgMKAQgSBAoCCAQSAwoBCBIDCgEIEgUKAwgBCBIECgIIATAACXNlcGFyYXRvcgICX18ABU1VTFQ4AIDC1y8BB3dyYXBFcnIBA21zZwkAuQkCCQDMCAICGHZvdGluZ192ZXJpZmllZF92Mi5yaWRlOgkAzAgCBQNtc2cFA25pbAIBIAEIdGhyb3dFcnIBA21zZwkAAgEJAQd3cmFwRXJyAQUDbXNnAQVhc0ludAEDdmFsBAckbWF0Y2gwBQN2YWwDCQABAgUHJG1hdGNoMAIDSW50BAZ2YWxJbnQFByRtYXRjaDAFBnZhbEludAkAAgECG0ZhaWxlZCB0byBjYXN0IGludG8gSW50ZWdlcgEQZ2V0SW50ZWdlck9yWmVybwIHYWRkcmVzcwNrZXkJAQt2YWx1ZU9yRWxzZQIJAJoIAgUHYWRkcmVzcwUDa2V5AAABEGdldEludGVnZXJPckZhaWwCB2FkZHJlc3MDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJoIAgUHYWRkcmVzcwUDa2V5CQEHd3JhcEVycgEJAKwCAgUDa2V5Ag8gaXMgbm90IGRlZm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JkAwUNY2FsbGVyQWRkcmVzcwUHYXNzZXRJZAUFaW5kZXgFA25pbAkBCHRocm93RXJyAQIQbm90aGluZyB0byBjbGFpbQUMcmV3YXJkQWN0aW9uCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAQPdGFyZ2V0UHVibGljS2V5BAckbWF0Y2gwCQEWbWFuYWdlclB1YmxpY0tleU9yVW5pdAADCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQCcGsFByRtYXRjaDAFAnBrAwkAAQIFByRtYXRjaDACBFVuaXQIBQJ0eA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V53B5nmw==", "height": 2684165, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5jKFfKGXisRRwPZWTzWMaWd65RF2gEkYvZz5ghmjyy2U Next: 8a3BDFGh4g8n8JXpMTA6kD59wusUwGNTwyCMwavRs5Qm 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 separator = "__" | |
5 | 5 | ||
6 | - | let | |
6 | + | let MULT8 = 100000000 | |
7 | 7 | ||
8 | - | let SCALE8 = 100000000 | |
9 | - | ||
10 | - | let SCALE6 = 1000000 | |
11 | - | ||
12 | - | let PENDING = "PENDING" | |
13 | - | ||
14 | - | let FINISHED = "FINISHED" | |
15 | - | ||
16 | - | let WAVES = "WAVES" | |
17 | - | ||
18 | - | func wrapErr (s) = ((CONTRACT_NAME + ": ") + s) | |
8 | + | func wrapErr (msg) = makeString(["voting_verified_v2.ride:", msg], " ") | |
19 | 9 | ||
20 | 10 | ||
21 | - | func throwErr ( | |
11 | + | func throwErr (msg) = throw(wrapErr(msg)) | |
22 | 12 | ||
23 | 13 | ||
24 | - | func assetIdToString (assetId) = match assetId { | |
25 | - | case b: ByteVector => | |
26 | - | toBase58String(b) | |
27 | - | case _: Unit => | |
28 | - | WAVES | |
14 | + | func asInt (val) = match val { | |
15 | + | case valInt: Int => | |
16 | + | valInt | |
29 | 17 | case _ => | |
30 | - | throw(" | |
18 | + | throw("Failed to cast into Integer") | |
31 | 19 | } | |
32 | 20 | ||
33 | 21 | ||
34 | - | func abs (n) = if ((0 > n)) | |
35 | - | then -(n) | |
36 | - | else n | |
22 | + | func getIntegerOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
37 | 23 | ||
38 | 24 | ||
39 | - | func | |
25 | + | func getIntegerOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), wrapErr((key + " is not defined"))) | |
40 | 26 | ||
41 | 27 | ||
42 | - | func | |
28 | + | func getStringOrEmpty (address,key) = valueOrElse(getString(address, key), "") | |
43 | 29 | ||
44 | 30 | ||
45 | - | func | |
31 | + | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((key + " is not defined"))) | |
46 | 32 | ||
47 | 33 | ||
48 | - | func keyTreasuryAddress () = makeString(["%s", "treasury"], SEP) | |
34 | + | let keyBoostingContract = makeString(["%s", "boostingContract"], separator) | |
35 | + | ||
36 | + | let keyEmissionContract = makeString(["%s", "emissionContract"], separator) | |
37 | + | ||
38 | + | let keyAssetsStoreContract = makeString(["%s", "assetsStoreContract"], separator) | |
39 | + | ||
40 | + | let boostingContract = addressFromStringValue(getStringValue(keyBoostingContract)) | |
41 | + | ||
42 | + | let emissionContract = addressFromStringValue(getStringValue(keyEmissionContract)) | |
43 | + | ||
44 | + | let assetsStoreContract = addressFromStringValue(getStringValue(keyAssetsStoreContract)) | |
45 | + | ||
46 | + | let keyEmissionConfig = makeString(["%s", "config"], separator) | |
47 | + | ||
48 | + | let wxAssetIdStr = split(getStringOrFail(emissionContract, keyEmissionConfig), separator)[1] | |
49 | + | ||
50 | + | let wxAssetId = fromBase58String(wxAssetIdStr) | |
51 | + | ||
52 | + | let keyVotingThresholdAdd = makeString(["%s%s", "votingThreshold", "add"], separator) | |
53 | + | ||
54 | + | let keyVotingThresholdRemove = makeString(["%s%s", "votingThreshold", "remove"], separator) | |
55 | + | ||
56 | + | let keyPeriodLengthRemove = makeString(["%s", "periodLengthRemove"], separator) | |
57 | + | ||
58 | + | let keyMaxPeriodLength = makeString(["%s", "maxPeriodLength"], separator) | |
59 | + | ||
60 | + | let keyMinPeriodLength = makeString(["%s", "minPeriodLength"], separator) | |
61 | + | ||
62 | + | func keyVotingRewardAssetId (assetId,index) = makeString(["%s%s%d", "votingRewardAssetId", assetId, toString(index)], separator) | |
49 | 63 | ||
50 | 64 | ||
51 | - | func | |
65 | + | func keyVotingReward (userAddress,assetId,index) = makeString(["%s%s%s%d", "votingReward", toString(userAddress), assetId, toString(index)], separator) | |
52 | 66 | ||
53 | 67 | ||
54 | - | func | |
68 | + | func keyTotalVotingReward (assetId,index) = makeString(["%s%s%d", "totalVotingReward", assetId, toString(index)], separator) | |
55 | 69 | ||
56 | 70 | ||
57 | - | func keyClaimed (userAddress) = makeString(["%s%s", "claimed", toString(userAddress)], SEP) | |
71 | + | let keyFinalizeCallRewardAmount = makeString(["%s", "finalizeCallRewardAmount"], separator) | |
72 | + | ||
73 | + | let keyMinSuggestRemoveBalance = makeString(["%s", "minSuggestRemoveBalance"], separator) | |
74 | + | ||
75 | + | func keyCurrentIndex (assetId) = makeString(["%s%s", "currentIndex", assetId], separator) | |
58 | 76 | ||
59 | 77 | ||
60 | - | func | |
78 | + | func keyVote (assetId,index,caller) = makeString(["%s%s%d%s", "vote", assetId, toString(index), toString(caller)], separator) | |
61 | 79 | ||
62 | 80 | ||
63 | - | func | |
81 | + | func voteValue (inFavor,gwxAmount) = makeString(["%s%d", toString(inFavor), toString(gwxAmount)], separator) | |
64 | 82 | ||
65 | 83 | ||
66 | - | func | |
84 | + | func keySuggestIssuer (assetId,index) = makeString(["%s%s%d", "suggestIssuer", assetId, toString(index)], separator) | |
67 | 85 | ||
68 | 86 | ||
69 | - | func | |
87 | + | func keyClaimHistory (userAddress,assetId,index) = makeString(["%s%s%s%d", "history", toString(userAddress), assetId, toString(index)], separator) | |
70 | 88 | ||
71 | 89 | ||
72 | - | func keyBlockProcessingReward () = "%s__blockProcessingReward" | |
90 | + | let keyFeePerBlock = makeString(["%s", "feePerBlock"], separator) | |
91 | + | ||
92 | + | let feePerBlock = getIntegerOrFail(this, keyFeePerBlock) | |
93 | + | ||
94 | + | let keyMinWxMinForSuggestAddAmountRequired = makeString(["%s", "wxMinForSuggestAddAmountRequired"], separator) | |
95 | + | ||
96 | + | let keyWxForSuggestRemoveAmountRequired = makeString(["%s", "wxForSuggestRemoveAmountRequired"], separator) | |
97 | + | ||
98 | + | func keyVotingInfo (assetId,index) = makeString(["%s%s%d", "votingInfo", assetId, toString(index)], separator) | |
73 | 99 | ||
74 | 100 | ||
75 | - | func | |
101 | + | func votingInfoValue (isRewardExist,rewardAssetId,rewardAmount,votingType,status,votingStartHeight,votingEndHeight,votesQuorum,votesFor,votesAgainst) = makeString(["%s%s%d%s%s%d%d%d%d%d", toString(isRewardExist), rewardAssetId, toString(rewardAmount), votingType, status, toString(votingStartHeight), toString(votingEndHeight), toString(votesQuorum), toString(votesFor), toString(votesAgainst)], separator) | |
76 | 102 | ||
77 | 103 | ||
78 | - | func | |
104 | + | func keyAssetImage (assetId) = makeString(["%s%s", "assetImage", assetId], separator) | |
79 | 105 | ||
80 | 106 | ||
81 | - | func keyWithdrawal () = "%s__withdrawal" | |
107 | + | func getUserGwxAmountAtHeight (userAddress,targetHeight) = { | |
108 | + | let gwxAmount = invoke(boostingContract, "getUserGwxAmountAtHeightREADONLY", [userAddress, targetHeight], nil) | |
109 | + | asInt(gwxAmount) | |
110 | + | } | |
82 | 111 | ||
83 | 112 | ||
84 | - | func | |
113 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
85 | 114 | ||
86 | 115 | ||
87 | - | func valueWithdrawalRequest (status,lpAssetAmount,targetPeriod,claimTxId) = { | |
88 | - | let claimTxIdStr = match claimTxId { | |
89 | - | case b: ByteVector => | |
90 | - | toBase58String(b) | |
116 | + | func keyManagerPublicKey () = "%s__managerPublicKey" | |
117 | + | ||
118 | + | ||
119 | + | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
120 | + | case s: String => | |
121 | + | addressFromStringValue(s) | |
122 | + | case _ => | |
123 | + | this | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | func managerPublicKeyOrUnit () = { | |
128 | + | let managerVaultAddress = getManagerVaultAddressOrThis() | |
129 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
130 | + | case s: String => | |
131 | + | fromBase58String(s) | |
91 | 132 | case _: Unit => | |
92 | - | | |
133 | + | unit | |
93 | 134 | case _ => | |
94 | 135 | throw("Match error") | |
95 | 136 | } | |
96 | - | makeString(["%s%d%d%s", status, toString(lpAssetAmount), toString(targetPeriod), claimTxIdStr], SEP) | |
97 | 137 | } | |
98 | 138 | ||
99 | 139 | ||
100 | - | func parseWithdrawalRequestValueOrFail (s) = { | |
101 | - | let parts = split(s, SEP) | |
102 | - | if ((size(parts) == 5)) | |
103 | - | then { | |
104 | - | let status = parts[1] | |
105 | - | let lpAssetAmount = valueOrErrorMessage(parseInt(parts[2]), wrapErr("invalid lpAssetAmount")) | |
106 | - | let targetPeriod = valueOrErrorMessage(parseInt(parts[3]), wrapErr("invalid targetPeriod")) | |
107 | - | let claimTxId = parts[4] | |
108 | - | $Tuple4(status, lpAssetAmount, targetPeriod, claimTxId) | |
109 | - | } | |
110 | - | else throwErr("invalid withdrawal request value") | |
140 | + | func getVotingInfoParts (votingInfo) = { | |
141 | + | let votingInfoParts = split(votingInfo, separator) | |
142 | + | let isRewardExistStr = votingInfoParts[1] | |
143 | + | let isRewardExist = if ((isRewardExistStr == "true")) | |
144 | + | then true | |
145 | + | else false | |
146 | + | let rewardAssetId = votingInfoParts[2] | |
147 | + | let rewardAmount = parseIntValue(votingInfoParts[3]) | |
148 | + | let votingType = votingInfoParts[4] | |
149 | + | let status = votingInfoParts[5] | |
150 | + | let votingStartHeight = parseIntValue(votingInfoParts[6]) | |
151 | + | let votingEndHeight = parseIntValue(votingInfoParts[7]) | |
152 | + | let votesQuorum = parseIntValue(votingInfoParts[8]) | |
153 | + | let votesFor = parseIntValue(votingInfoParts[9]) | |
154 | + | let votesAgainst = parseIntValue(votingInfoParts[10]) | |
155 | + | $Tuple10(isRewardExist, rewardAssetId, rewardAmount, votingType, status, votingStartHeight, votingEndHeight, votesQuorum, votesFor, votesAgainst) | |
111 | 156 | } | |
112 | 157 | ||
113 | 158 | ||
114 | - | let factoryAddressOption = match getString(this, keyFactoryAddress()) { | |
115 | - | case s: String => | |
116 | - | addressFromString(s) | |
117 | - | case _: Unit => | |
118 | - | unit | |
119 | - | case _ => | |
120 | - | throw("Match error") | |
121 | - | } | |
122 | - | ||
123 | - | let factoryAddressOrFail = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address")) | |
124 | - | ||
125 | - | let lpAssetIdOption = match factoryAddressOption { | |
126 | - | case a: Address => | |
127 | - | match getString(a, keyLpAssetId()) { | |
128 | - | case s: String => | |
129 | - | fromBase58String(s) | |
130 | - | case _: Unit => | |
131 | - | unit | |
132 | - | case _ => | |
133 | - | throw("Match error") | |
134 | - | } | |
135 | - | case _: Unit => | |
136 | - | unit | |
137 | - | case _ => | |
138 | - | throw("Match error") | |
139 | - | } | |
140 | - | ||
141 | - | let lpAssetIdOrFail = valueOrErrorMessage(lpAssetIdOption, wrapErr("invalid lpAssetId")) | |
142 | - | ||
143 | - | let xtnAssetIdOption = match factoryAddressOption { | |
144 | - | case a: Address => | |
145 | - | match getString(a, keyXtnAssetId()) { | |
146 | - | case s: String => | |
147 | - | fromBase58String(s) | |
148 | - | case _: Unit => | |
149 | - | unit | |
150 | - | case _ => | |
151 | - | throw("Match error") | |
152 | - | } | |
153 | - | case _: Unit => | |
154 | - | unit | |
155 | - | case _ => | |
156 | - | throw("Match error") | |
157 | - | } | |
158 | - | ||
159 | - | let xtnAssetIdOrFail = valueOrErrorMessage(xtnAssetIdOption, wrapErr("invalid xtnAssetId")) | |
160 | - | ||
161 | - | let treasuryAddressOption = match factoryAddressOption { | |
162 | - | case a: Address => | |
163 | - | match getString(a, keyTreasuryAddress()) { | |
164 | - | case s: String => | |
165 | - | addressFromString(s) | |
166 | - | case _: Unit => | |
167 | - | unit | |
168 | - | case _ => | |
169 | - | throw("Match error") | |
170 | - | } | |
171 | - | case _: Unit => | |
172 | - | unit | |
173 | - | case _ => | |
174 | - | throw("Match error") | |
175 | - | } | |
176 | - | ||
177 | - | let treasuryAddressOrFail = valueOrErrorMessage(treasuryAddressOption, wrapErr("invalid treasury address")) | |
178 | - | ||
179 | - | func onlyAddress (i,address) = if ((i.caller == address)) | |
180 | - | then true | |
181 | - | else throwErr("permission denied") | |
159 | + | func votingExistChecks (assetId,currentIndex) = { | |
160 | + | let votingInfo = valueOrErrorMessage(getString(keyVotingInfo(assetId, currentIndex)), wrapErr("voting info not found")) | |
161 | + | let votingInfoArray = split(votingInfo, separator) | |
162 | + | let status = votingInfoArray[5] | |
163 | + | let votingEndHeight = valueOrErrorMessage(parseIntValue(votingInfoArray[7]), wrapErr("voting start height not found")) | |
164 | + | let suggestIssuer = valueOrErrorMessage(getString(keySuggestIssuer(assetId, currentIndex)), wrapErr("voting issuer not found")) | |
165 | + | let checks = [if ((status == "inProgress")) | |
166 | + | then true | |
167 | + | else throwErr("no voting in progress"), if ((votingEndHeight > height)) | |
168 | + | then true | |
169 | + | else throwErr("voting expired")] | |
170 | + | if ((checks == checks)) | |
171 | + | then $Tuple3(status, votingEndHeight, suggestIssuer) | |
172 | + | else throw("Strict value is not equal to itself.") | |
173 | + | } | |
182 | 174 | ||
183 | 175 | ||
184 | - | func onlyFactory (i) = onlyAddress(i, factoryAddressOrFail) | |
185 | - | ||
186 | - | ||
187 | - | func rewardForOption (rewards,target) = { | |
188 | - | let s = size(rewards) | |
189 | - | let $t040964121 = rewards[0] | |
190 | - | let a0 = $t040964121._1 | |
191 | - | let r0 = $t040964121._2 | |
192 | - | let $t041244149 = rewards[1] | |
193 | - | let a1 = $t041244149._1 | |
194 | - | let r1 = $t041244149._2 | |
195 | - | let $t041524177 = rewards[2] | |
196 | - | let a2 = $t041524177._1 | |
197 | - | let r2 = $t041524177._2 | |
198 | - | if (if ((s > 0)) | |
199 | - | then (a0 == target) | |
200 | - | else false) | |
201 | - | then r0 | |
202 | - | else if (if ((s > 1)) | |
203 | - | then (a1 == target) | |
204 | - | else false) | |
205 | - | then r1 | |
206 | - | else if (if ((s > 2)) | |
207 | - | then (a2 == target) | |
208 | - | else false) | |
209 | - | then r2 | |
210 | - | else unit | |
176 | + | func calculateReward (voter,assetId,index) = { | |
177 | + | let voteKey = keyVote(assetId, index, voter) | |
178 | + | let lastVote = valueOrErrorMessage(getString(voteKey), wrapErr("you have not voted")) | |
179 | + | let lastVoteParts = split(lastVote, separator) | |
180 | + | let gwxAmount = parseIntValue(lastVoteParts[2]) | |
181 | + | let votingInfoStr = valueOrErrorMessage(getString(keyVotingInfo(assetId, index)), wrapErr("voting info not found")) | |
182 | + | let votingParts = getVotingInfoParts(votingInfoStr) | |
183 | + | let votesFor = votingParts._9 | |
184 | + | let votesAgainst = votingParts._10 | |
185 | + | let partOfTheTotalVotesX8 = fraction(gwxAmount, MULT8, (votesFor + votesAgainst)) | |
186 | + | let totalVotingReward = valueOrElse(getInteger(keyTotalVotingReward(assetId, index)), 0) | |
187 | + | let voterRewardAmount = fraction(partOfTheTotalVotesX8, totalVotingReward, MULT8, FLOOR) | |
188 | + | voterRewardAmount | |
211 | 189 | } | |
212 | 190 | ||
213 | 191 | ||
214 | 192 | @Callable(i) | |
215 | - | func claimLP (userAddressBytes) = { | |
216 | - | let checkCaller = onlyFactory(i) | |
217 | - | if ((checkCaller == checkCaller)) | |
193 | + | func suggestAdd (assetId,periodLength,assetImage) = { | |
194 | + | let wxPayment = i.payments[0] | |
195 | + | let wxPaymentAssetId = value(wxPayment.assetId) | |
196 | + | let wxPaymentAmount = value(wxPayment.amount) | |
197 | + | let minPeriodLength = getIntegerValue(keyMinPeriodLength) | |
198 | + | let maxPeriodLength = getIntegerValue(keyMaxPeriodLength) | |
199 | + | let tokenIsVerified = { | |
200 | + | let @ = invoke(assetsStoreContract, "isVerifiedREADONLY", [assetId], nil) | |
201 | + | if ($isInstanceOf(@, "Boolean")) | |
202 | + | then @ | |
203 | + | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
204 | + | } | |
205 | + | let checks = [if (if ((periodLength >= minPeriodLength)) | |
206 | + | then (maxPeriodLength >= periodLength) | |
207 | + | else false) | |
208 | + | then true | |
209 | + | else throwErr("invalid periodLength"), if ((tokenIsVerified == false)) | |
210 | + | then true | |
211 | + | else throwErr("token already verified"), if ((wxPaymentAmount > (periodLength * feePerBlock))) | |
212 | + | then true | |
213 | + | else throwErr("not enough wx for given period"), if ((wxPaymentAmount >= getIntegerValue(keyMinWxMinForSuggestAddAmountRequired))) | |
214 | + | then true | |
215 | + | else throwErr("payment less then min for suggest")] | |
216 | + | if ((checks == checks)) | |
218 | 217 | then { | |
219 | - | let userAddress = Address(userAddressBytes) | |
220 | - | let available = valueOrElse(getInteger(factoryAddressOrFail, keyAvailable(userAddress)), 0) | |
221 | - | let claimed = valueOrElse(getInteger(factoryAddressOrFail, keyClaimed(userAddress)), 0) | |
222 | - | let factoryActions = if ((available > 0)) | |
223 | - | then [invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, available, lpAssetIdOrFail], nil), invoke(factoryAddressOrFail, "integerEntry", [keyAvailable(userAddress), 0], nil), invoke(factoryAddressOrFail, "integerEntry", [keyClaimed(userAddress), (claimed + available)], nil)] | |
224 | - | else throwErr("nothing to claim") | |
225 | - | $Tuple2(nil, factoryActions) | |
218 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
219 | + | let currentIndex = getInteger(currentIndexKey) | |
220 | + | let newIndex = if (isDefined(currentIndex)) | |
221 | + | then (value(currentIndex) + 1) | |
222 | + | else 0 | |
223 | + | let $t087849424 = if ((size(i.payments) > 1)) | |
224 | + | then { | |
225 | + | let votingRewardPayment = i.payments[1] | |
226 | + | let votingRewardPaymentAssetId = toBase58String(value(votingRewardPayment.assetId)) | |
227 | + | let votingRewardPaymentAmount = value(votingRewardPayment.amount) | |
228 | + | $Tuple4(true, votingRewardPaymentAssetId, votingRewardPaymentAmount, [StringEntry(keyVotingRewardAssetId(assetId, newIndex), votingRewardPaymentAssetId), IntegerEntry(keyTotalVotingReward(assetId, newIndex), votingRewardPaymentAmount)]) | |
229 | + | } | |
230 | + | else $Tuple4(false, "EMPTY", 0, nil) | |
231 | + | let isRewardExist = $t087849424._1 | |
232 | + | let rewardAssetId = $t087849424._2 | |
233 | + | let rewardAmount = $t087849424._3 | |
234 | + | let votingRewardActions = $t087849424._4 | |
235 | + | let votesQuorum = valueOrErrorMessage(getInteger(keyVotingThresholdAdd), wrapErr("votingThresholdAdd not set")) | |
236 | + | let votingInfo = votingInfoValue(isRewardExist, rewardAssetId, rewardAmount, "verification", "inProgress", height, (height + periodLength), votesQuorum, 0, 0) | |
237 | + | let finalizeCallRewardAmount = getIntegerValue(keyFinalizeCallRewardAmount) | |
238 | + | let burnWxAmount = (wxPaymentAmount - finalizeCallRewardAmount) | |
239 | + | ([IntegerEntry(currentIndexKey, newIndex), StringEntry(keySuggestIssuer(assetId, newIndex), toString(i.caller)), StringEntry(keyVotingInfo(assetId, newIndex), votingInfo), StringEntry(keyAssetImage(assetId), assetImage), Burn(wxPaymentAssetId, burnWxAmount)] ++ votingRewardActions) | |
226 | 240 | } | |
227 | 241 | else throw("Strict value is not equal to itself.") | |
228 | 242 | } | |
230 | 244 | ||
231 | 245 | ||
232 | 246 | @Callable(i) | |
233 | - | func finalize (userAddressBytes,newTreasuryVolumeInWaves,xtnPrice,pwrManagersBonus,treasuryVolumeDiffAllocationCoef) = { | |
234 | - | let checkCaller = onlyFactory(i) | |
235 | - | if ((checkCaller == checkCaller)) | |
247 | + | func suggestRemove (assetId) = { | |
248 | + | let gwxAmountAtNow = getUserGwxAmountAtHeight(toString(i.caller), height) | |
249 | + | let minSuggestRemoveBalance = getIntegerValue(keyMinSuggestRemoveBalance) | |
250 | + | let wxPayment = i.payments[0] | |
251 | + | let wxPaymentAssetId = value(wxPayment.assetId) | |
252 | + | let wxPaymentAmount = value(wxPayment.amount) | |
253 | + | let tokenIsVerified = { | |
254 | + | let @ = invoke(assetsStoreContract, "isVerifiedREADONLY", [assetId], nil) | |
255 | + | if ($isInstanceOf(@, "Boolean")) | |
256 | + | then @ | |
257 | + | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
258 | + | } | |
259 | + | let checks = [if (tokenIsVerified) | |
260 | + | then true | |
261 | + | else throwErr("token not verified"), if ((gwxAmountAtNow >= minSuggestRemoveBalance)) | |
262 | + | then true | |
263 | + | else throwErr("not enough gWXes"), if ((wxPaymentAmount >= getIntegerValue(keyWxForSuggestRemoveAmountRequired))) | |
264 | + | then true | |
265 | + | else throwErr("payment less then min for suggest")] | |
266 | + | if ((checks == checks)) | |
236 | 267 | then { | |
237 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
238 | - | let periodLength = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPeriodLength()), wrapErr("invalid period length")) | |
239 | - | let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height")) | |
240 | - | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
241 | - | let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process")) | |
242 | - | let periodEndHeight = ((currentStartHeight + periodLength) - 1) | |
243 | - | let checks = [if ((i.originCaller == treasuryAddressOrFail)) | |
268 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
269 | + | let currentIndex = getInteger(currentIndexKey) | |
270 | + | let newIndex = if (isDefined(currentIndex)) | |
271 | + | then (value(currentIndex) + 1) | |
272 | + | else 0 | |
273 | + | let periodLength = valueOrErrorMessage(getInteger(keyPeriodLengthRemove), wrapErr("periodLengthRemove not set")) | |
274 | + | let votingEndHeight = (height + periodLength) | |
275 | + | let votesQuorum = valueOrErrorMessage(getInteger(keyVotingThresholdRemove), wrapErr("votingThresholdRemove not set")) | |
276 | + | let votingInfo = votingInfoValue(false, "EMPTY", 0, "deverification", "inProgress", height, (height + periodLength), votesQuorum, 0, 0) | |
277 | + | [IntegerEntry(currentIndexKey, newIndex), StringEntry(keySuggestIssuer(assetId, newIndex), toString(i.caller)), StringEntry(keyVotingInfo(assetId, newIndex), votingInfo)] | |
278 | + | } | |
279 | + | else throw("Strict value is not equal to itself.") | |
280 | + | } | |
281 | + | ||
282 | + | ||
283 | + | ||
284 | + | @Callable(i) | |
285 | + | func vote (assetId,inFavor) = { | |
286 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
287 | + | let currentIndex = valueOrErrorMessage(getInteger(currentIndexKey), wrapErr("voting does not exist")) | |
288 | + | let votingInfo = votingExistChecks(assetId, currentIndex) | |
289 | + | if ((votingInfo == votingInfo)) | |
290 | + | then { | |
291 | + | let currentVotingEndHeight = votingInfo._2 | |
292 | + | let gwxAmountAtEnd = getUserGwxAmountAtHeight(toString(i.caller), currentVotingEndHeight) | |
293 | + | let voteKey = keyVote(assetId, currentIndex, i.caller) | |
294 | + | let checks = [if ((getString(voteKey) == unit)) | |
244 | 295 | then true | |
245 | - | else throwErr(" | |
296 | + | else throwErr("You have already voted"), if ((gwxAmountAtEnd > 0)) | |
246 | 297 | then true | |
247 | - | else throwErr("unprocessed blocks"), if ((newTreasuryVolumeInWaves >= 0)) | |
248 | - | then true | |
249 | - | else throwErr("invalid new treasury volume"), if ((xtnPrice >= 0)) | |
250 | - | then true | |
251 | - | else throwErr("invalid XTN price"), if (if ((pwrManagersBonus >= 0)) | |
252 | - | then (SCALE8 >= pwrManagersBonus) | |
253 | - | else false) | |
254 | - | then true | |
255 | - | else throwErr("invalid PWR managers bonus"), if (if ((treasuryVolumeDiffAllocationCoef >= -(SCALE8))) | |
256 | - | then (SCALE8 >= treasuryVolumeDiffAllocationCoef) | |
257 | - | else false) | |
258 | - | then true | |
259 | - | else throwErr("invalid treasury volume diff allocation coefficient")] | |
298 | + | else throw("You'll not have gWX at the end of voting")] | |
260 | 299 | if ((checks == checks)) | |
261 | 300 | then { | |
262 | - | let investedXtnAmount = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(xtnAssetIdOrFail)), 0) | |
263 | - | let investedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(unit)), 0) | |
264 | - | let investedXtnAmountInWaves = fraction(investedXtnAmount, xtnPrice, SCALE6) | |
265 | - | let currentTreasuryVolumeInWaves = (investedXtnAmountInWaves + investedWavesAmount) | |
266 | - | let profitRaw = (newTreasuryVolumeInWaves - currentTreasuryVolumeInWaves) | |
267 | - | let pwrManagersBonusAmount = if ((profitRaw > 0)) | |
268 | - | then fraction(profitRaw, pwrManagersBonus, SCALE8) | |
269 | - | else 0 | |
270 | - | let profit = (profitRaw - pwrManagersBonusAmount) | |
271 | - | let donationPart = if ((currentTreasuryVolumeInWaves > 0)) | |
272 | - | then fraction(investedXtnAmountInWaves, SCALE8, currentTreasuryVolumeInWaves) | |
273 | - | else 0 | |
274 | - | let donationProfitPartRaw = fraction(profit, donationPart, SCALE8) | |
275 | - | let investmentProfitPartRaw = (profit - donationProfitPartRaw) | |
276 | - | let treasuryVolumeDiffAllocationCoefAbs = abs(treasuryVolumeDiffAllocationCoef) | |
277 | - | let amountToDonation = fraction(investmentProfitPartRaw, if ((0 > treasuryVolumeDiffAllocationCoef)) | |
278 | - | then treasuryVolumeDiffAllocationCoefAbs | |
279 | - | else 0, SCALE8) | |
280 | - | let amountToInvestment = fraction(donationProfitPartRaw, if ((treasuryVolumeDiffAllocationCoef > 0)) | |
281 | - | then treasuryVolumeDiffAllocationCoefAbs | |
282 | - | else 0, SCALE8) | |
283 | - | let donationProfitPart = ((donationProfitPartRaw - amountToInvestment) + amountToDonation) | |
284 | - | let investmentProfitPart = ((investmentProfitPartRaw - amountToDonation) + amountToInvestment) | |
285 | - | let investedWavesAmountNew = (investedWavesAmount + investmentProfitPart) | |
286 | - | let investedXtnAmountNew = fraction((investedXtnAmountInWaves + donationProfitPart), SCALE6, xtnPrice) | |
287 | - | let newPeriod = (currentPeriodOrFail + 1) | |
288 | - | let lpAssetQuantity = valueOrErrorMessage(assetInfo(lpAssetIdOrFail), wrapErr("invalid lpAsset info")).quantity | |
289 | - | let newPrice = fraction(investedWavesAmountNew, SCALE8, lpAssetQuantity) | |
290 | - | let lpAssetAmountToBurn = valueOrElse(getInteger(factoryAddressOrFail, keyWithdrawal()), 0) | |
291 | - | let paymentAmountMin = max([0, fraction(lpAssetAmountToBurn, newPrice, SCALE8)]) | |
292 | - | let paymentOption = if ((size(i.payments) > 0)) | |
293 | - | then i.payments[0] | |
294 | - | else unit | |
295 | - | let paymentAmount = value(paymentOption).amount | |
296 | - | let paymentAssetId = value(paymentOption).assetId | |
297 | - | let checkPayment = if (if ((paymentAmountMin == 0)) | |
298 | - | then true | |
299 | - | else if (if ((paymentOption != unit)) | |
300 | - | then (paymentAssetId == unit) | |
301 | - | else false) | |
302 | - | then (paymentAmount >= paymentAmountMin) | |
303 | - | else false) | |
304 | - | then true | |
305 | - | else throwErr(("invalid payments, payment amount min: " + toString(paymentAmountMin))) | |
306 | - | if ((checkPayment == checkPayment)) | |
307 | - | then { | |
308 | - | let actions = if ((paymentOption != unit)) | |
309 | - | then [ScriptTransfer(factoryAddressOrFail, paymentAmount, paymentAssetId)] | |
310 | - | else nil | |
311 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyCurrentPeriod(), newPeriod], nil), invoke(factoryAddressOrFail, "integerEntry", [keyPriceForPeriod(newPeriod), newPrice], nil), invoke(factoryAddressOrFail, "integerEntry", [keyStartHeight(newPeriod), (periodEndHeight + 1)], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmountToBurn], nil), invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), 0], nil)] | |
312 | - | $Tuple2(actions, factoryActions) | |
313 | - | } | |
314 | - | else throw("Strict value is not equal to itself.") | |
301 | + | let votingInfoStr = valueOrErrorMessage(getString(keyVotingInfo(assetId, currentIndex)), wrapErr("voting info not found")) | |
302 | + | let votingInfoParts = getVotingInfoParts(votingInfoStr) | |
303 | + | let votesFor = votingInfoParts._9 | |
304 | + | let votesAgainst = votingInfoParts._10 | |
305 | + | let $t01274512906 = if (inFavor) | |
306 | + | then $Tuple2((votesFor + gwxAmountAtEnd), votesAgainst) | |
307 | + | else $Tuple2(votesFor, (votesAgainst + gwxAmountAtEnd)) | |
308 | + | let newVotesFor = $t01274512906._1 | |
309 | + | let newVotesAgainst = $t01274512906._2 | |
310 | + | let newVotingInfoValue = votingInfoValue(votingInfoParts._1, votingInfoParts._2, votingInfoParts._3, votingInfoParts._4, votingInfoParts._5, votingInfoParts._6, votingInfoParts._7, votingInfoParts._8, newVotesFor, newVotesAgainst) | |
311 | + | let votingRewardAction = match getString(keyVotingRewardAssetId(assetId, currentIndex)) { | |
312 | + | case pk: String => | |
313 | + | [StringEntry(keyVotingReward(i.caller, assetId, currentIndex), voteValue(inFavor, gwxAmountAtEnd))] | |
314 | + | case _: Unit => | |
315 | + | nil | |
316 | + | case _ => | |
317 | + | throw("Match error") | |
318 | + | } | |
319 | + | ([StringEntry(voteKey, voteValue(inFavor, gwxAmountAtEnd)), StringEntry(keyVotingInfo(assetId, currentIndex), newVotingInfoValue)] ++ votingRewardAction) | |
315 | 320 | } | |
316 | 321 | else throw("Strict value is not equal to itself.") | |
317 | 322 | } | |
321 | 326 | ||
322 | 327 | ||
323 | 328 | @Callable(i) | |
324 | - | func invest (userAddressBytes) = { | |
325 | - | let checkCaller = onlyFactory(i) | |
326 | - | if ((checkCaller == checkCaller)) | |
329 | + | func cancelVote (assetId) = { | |
330 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
331 | + | let currentIndex = valueOrErrorMessage(getInteger(currentIndexKey), wrapErr("voting does not exist")) | |
332 | + | let voteKey = keyVote(assetId, currentIndex, i.caller) | |
333 | + | let lastVote = valueOrErrorMessage(getString(voteKey), wrapErr("you have not voted")) | |
334 | + | let lastVoteParts = split(lastVote, separator) | |
335 | + | let inFavor = lastVoteParts[1] | |
336 | + | let gwxAmount = parseIntValue(lastVoteParts[2]) | |
337 | + | let votingInfo = votingExistChecks(assetId, currentIndex) | |
338 | + | if ((votingInfo == votingInfo)) | |
327 | 339 | then { | |
328 | - | let userAddress = Address(userAddressBytes) | |
329 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
330 | - | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
331 | - | let payment = if ((size(i.payments) == 1)) | |
332 | - | then i.payments[0] | |
333 | - | else throwErr("invalid payments") | |
334 | - | let $t01103511212 = if (if ((payment.assetId == unit)) | |
335 | - | then (payment.amount > 0) | |
336 | - | else false) | |
337 | - | then $Tuple2(payment.amount, payment.assetId) | |
338 | - | else throwErr("invalid payment amount") | |
339 | - | let paymentAmount = $t01103511212._1 | |
340 | - | let paymentAssetId = $t01103511212._2 | |
341 | - | let lpAssetAmount = if ((currentPriceOrFail > 0)) | |
342 | - | then fraction(paymentAmount, SCALE8, currentPriceOrFail) | |
343 | - | else 0 | |
344 | - | let invested = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(unit)), 0) | |
345 | - | let actions = [ScriptTransfer(treasuryAddressOrFail, paymentAmount, paymentAssetId)] | |
346 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyInvested(unit), (invested + paymentAmount)], nil), invoke(factoryAddressOrFail, "reissue", [lpAssetAmount], nil), invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, lpAssetAmount, lpAssetIdOrFail], nil)] | |
347 | - | $Tuple2(actions, factoryActions) | |
348 | - | } | |
349 | - | else throw("Strict value is not equal to itself.") | |
350 | - | } | |
351 | - | ||
352 | - | ||
353 | - | ||
354 | - | @Callable(i) | |
355 | - | func withdraw (userAddressBytes) = { | |
356 | - | let checkCaller = onlyFactory(i) | |
357 | - | if ((checkCaller == checkCaller)) | |
358 | - | then { | |
359 | - | let userAddress = Address(userAddressBytes) | |
360 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
361 | - | let payment = if ((size(i.payments) == 1)) | |
362 | - | then i.payments[0] | |
363 | - | else throwErr(wrapErr("invalid payments")) | |
364 | - | let paymentAssetId = if ((payment.assetId == lpAssetIdOrFail)) | |
365 | - | then lpAssetIdOrFail | |
366 | - | else throwErr("invalid payment asset") | |
367 | - | let paymentAmount = if ((payment.amount > 0)) | |
368 | - | then payment.amount | |
369 | - | else throwErr("invalid payment amount") | |
370 | - | let withdrawal = valueOrElse(getInteger(factoryAddressOrFail, keyWithdrawal()), 0) | |
371 | - | let actions = [ScriptTransfer(factoryAddressOrFail, paymentAmount, paymentAssetId)] | |
372 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), (withdrawal + paymentAmount)], nil), invoke(factoryAddressOrFail, "stringEntry", [keyWithdrawalRequest(userAddress, i.transactionId), valueWithdrawalRequest(PENDING, paymentAmount, (currentPeriodOrFail + 1), unit)], nil)] | |
373 | - | if ((factoryActions == factoryActions)) | |
374 | - | then $Tuple2(actions, factoryActions) | |
375 | - | else throw("Strict value is not equal to itself.") | |
376 | - | } | |
377 | - | else throw("Strict value is not equal to itself.") | |
378 | - | } | |
379 | - | ||
380 | - | ||
381 | - | ||
382 | - | @Callable(i) | |
383 | - | func cancelWithdraw (userAddressBytes,txId) = { | |
384 | - | let checkCaller = onlyFactory(i) | |
385 | - | if ((checkCaller == checkCaller)) | |
386 | - | then { | |
387 | - | let userAddress = Address(userAddressBytes) | |
388 | - | let withdrawalRequestOption = valueOrErrorMessage(getString(factoryAddressOrFail, keyWithdrawalRequest(userAddress, txId)), wrapErr("invalid withdrawal request")) | |
389 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
390 | - | let $t01361513728 = parseWithdrawalRequestValueOrFail(withdrawalRequestOption) | |
391 | - | let status = $t01361513728._1 | |
392 | - | let lpAssetAmount = $t01361513728._2 | |
393 | - | let targetPeriod = $t01361513728._3 | |
394 | - | let claimTxId = $t01361513728._4 | |
395 | - | let checks = [if ((status == PENDING)) | |
340 | + | let checks = [if (if ((inFavor == "true")) | |
396 | 341 | then true | |
397 | - | else | |
342 | + | else (inFavor == "false")) | |
398 | 343 | then true | |
399 | - | else throwErr("invalid | |
344 | + | else throwErr("invalid vote")] | |
400 | 345 | if ((checks == checks)) | |
401 | 346 | then { | |
402 | - | let withdrawal = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyWithdrawal()), wrapErr("invalid total withdrawal amount")) | |
403 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), if ((withdrawal >= lpAssetAmount)) | |
404 | - | then (withdrawal - lpAssetAmount) | |
405 | - | else throwErr("invalid withdrawal amount")], nil), invoke(factoryAddressOrFail, "deleteEntry", [keyWithdrawalRequest(userAddress, txId)], nil), invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, lpAssetAmount, lpAssetIdOrFail], nil)] | |
406 | - | if ((factoryActions == factoryActions)) | |
407 | - | then $Tuple2(nil, factoryActions) | |
408 | - | else throw("Strict value is not equal to itself.") | |
347 | + | let votingInfoStr = valueOrErrorMessage(getString(keyVotingInfo(assetId, currentIndex)), wrapErr("voting info not found")) | |
348 | + | let votingInfoParts = getVotingInfoParts(votingInfoStr) | |
349 | + | let votesFor = votingInfoParts._9 | |
350 | + | let votesAgainst = votingInfoParts._10 | |
351 | + | let $t01453114692 = if ((inFavor == "true")) | |
352 | + | then $Tuple2((votesFor - gwxAmount), votesAgainst) | |
353 | + | else $Tuple2(votesFor, (votesAgainst - gwxAmount)) | |
354 | + | let newVotesFor = $t01453114692._1 | |
355 | + | let newVotesAgainst = $t01453114692._2 | |
356 | + | let newVotingInfoValue = votingInfoValue(votingInfoParts._1, votingInfoParts._2, votingInfoParts._3, votingInfoParts._4, votingInfoParts._5, votingInfoParts._6, votingInfoParts._7, votingInfoParts._8, newVotesFor, newVotesAgainst) | |
357 | + | [StringEntry(keyVotingInfo(assetId, currentIndex), newVotingInfoValue), DeleteEntry(voteKey), DeleteEntry(keyVotingReward(i.caller, assetId, currentIndex))] | |
409 | 358 | } | |
410 | 359 | else throw("Strict value is not equal to itself.") | |
411 | 360 | } | |
415 | 364 | ||
416 | 365 | ||
417 | 366 | @Callable(i) | |
418 | - | func claimWaves (userAddressBytes,txId) = { | |
419 | - | let checkCaller = onlyFactory(i) | |
420 | - | if ((checkCaller == checkCaller)) | |
367 | + | func finalize (assetId) = { | |
368 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
369 | + | let currentIndex = valueOrElse(getInteger(currentIndexKey), 0) | |
370 | + | let votingThresholdAdd = valueOrErrorMessage(getInteger(keyVotingThresholdAdd), wrapErr("votingThresholdAdd not set")) | |
371 | + | let votingThresholdRemove = valueOrErrorMessage(getInteger(keyVotingThresholdRemove), wrapErr("votingThresholdRemove not set")) | |
372 | + | let votingInfoStr = valueOrErrorMessage(getString(keyVotingInfo(assetId, currentIndex)), wrapErr("voting info not found")) | |
373 | + | let votingInfoParts = getVotingInfoParts(votingInfoStr) | |
374 | + | let votingType = votingInfoParts._4 | |
375 | + | let status = votingInfoParts._5 | |
376 | + | let votingEndHeight = votingInfoParts._7 | |
377 | + | let votingQuorum = votingInfoParts._8 | |
378 | + | let votesFor = votingInfoParts._9 | |
379 | + | let votesAgainst = votingInfoParts._10 | |
380 | + | let checks = [if ((status == "inProgress")) | |
381 | + | then true | |
382 | + | else throwErr("voting not in progress"), if ((height >= votingEndHeight)) | |
383 | + | then true | |
384 | + | else throwErr("voting not finished"), if (isDefined(getString(keyAssetImage(assetId)))) | |
385 | + | then true | |
386 | + | else throwErr("asset image not set")] | |
387 | + | if ((checks == checks)) | |
421 | 388 | then { | |
422 | - | let userAddress = Address(userAddressBytes) | |
423 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
424 | - | let withdrawalRequestOption = valueOrErrorMessage(getString(factoryAddressOrFail, keyWithdrawalRequest(userAddress, txId)), wrapErr("invalid withdrawal request")) | |
425 | - | let $t01506015173 = parseWithdrawalRequestValueOrFail(withdrawalRequestOption) | |
426 | - | let status = $t01506015173._1 | |
427 | - | let lpAssetAmount = $t01506015173._2 | |
428 | - | let targetPeriod = $t01506015173._3 | |
429 | - | let claimTxId = $t01506015173._4 | |
430 | - | if ((status == FINISHED)) | |
431 | - | then throwErr("invalid withdrawal request status") | |
432 | - | else if ((targetPeriod > currentPeriodOrFail)) | |
433 | - | then throwErr("invalid withdrawal request period") | |
434 | - | else { | |
435 | - | let priceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(targetPeriod)), wrapErr("invalid price")) | |
436 | - | let amount = if ((priceOrFail > 0)) | |
437 | - | then fraction(lpAssetAmount, priceOrFail, SCALE8) | |
438 | - | else 0 | |
439 | - | let factoryActions = [invoke(factoryAddressOrFail, "stringEntry", [keyWithdrawalRequest(userAddress, txId), valueWithdrawalRequest(FINISHED, lpAssetAmount, targetPeriod, i.transactionId)], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmount], nil), invoke(factoryAddressOrFail, "transferWaves", [userAddressBytes, amount], nil)] | |
440 | - | $Tuple2(nil, factoryActions) | |
441 | - | } | |
389 | + | let votingAccepted = if (if (((votesFor + votesAgainst) >= votingQuorum)) | |
390 | + | then (votesFor > votesAgainst) | |
391 | + | else false) | |
392 | + | then true | |
393 | + | else false | |
394 | + | let newStatus = if (votingAccepted) | |
395 | + | then "accepted" | |
396 | + | else "rejected" | |
397 | + | let assetImage = getStringValue(keyAssetImage(assetId)) | |
398 | + | let isVotingAccepted = if (votingAccepted) | |
399 | + | then { | |
400 | + | let votingAcceptedInvokes = if ((votingType == "verification")) | |
401 | + | then invoke(assetsStoreContract, "createOrUpdate", [assetId, assetImage, true], nil) | |
402 | + | else invoke(assetsStoreContract, "setVerified", [assetId, false], nil) | |
403 | + | votingAcceptedInvokes | |
404 | + | } | |
405 | + | else nil | |
406 | + | if ((isVotingAccepted == isVotingAccepted)) | |
407 | + | then { | |
408 | + | let newVotingInfoValue = votingInfoValue(votingInfoParts._1, votingInfoParts._2, votingInfoParts._3, votingInfoParts._4, newStatus, votingInfoParts._6, votingInfoParts._7, votingInfoParts._8, votingInfoParts._9, votingInfoParts._10) | |
409 | + | let finalizeCallRewardAmount = getIntegerValue(keyFinalizeCallRewardAmount) | |
410 | + | [StringEntry(keyVotingInfo(assetId, currentIndex), newVotingInfoValue), ScriptTransfer(i.caller, finalizeCallRewardAmount, wxAssetId)] | |
411 | + | } | |
412 | + | else throw("Strict value is not equal to itself.") | |
442 | 413 | } | |
443 | 414 | else throw("Strict value is not equal to itself.") | |
444 | 415 | } | |
446 | 417 | ||
447 | 418 | ||
448 | 419 | @Callable(i) | |
449 | - | func processBlocks (userAddressBytes) = { | |
450 | - | let checkCaller = onlyFactory(i) | |
451 | - | if ((checkCaller == checkCaller)) | |
420 | + | func claimREADONLY (assetId,index,userAddressStr) = { | |
421 | + | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid address")) | |
422 | + | let votingRewardAssetIdStr = getString(keyVotingRewardAssetId(assetId, index)) | |
423 | + | let rewardAmount = if (isDefined(votingRewardAssetIdStr)) | |
424 | + | then calculateReward(userAddress, assetId, index) | |
425 | + | else 0 | |
426 | + | $Tuple2(nil, rewardAmount) | |
427 | + | } | |
428 | + | ||
429 | + | ||
430 | + | ||
431 | + | @Callable(i) | |
432 | + | func claim (assetId,index) = { | |
433 | + | let callerAddress = i.caller | |
434 | + | let claimHistoryKey = keyClaimHistory(callerAddress, assetId, index) | |
435 | + | let claimHistory = getInteger(claimHistoryKey) | |
436 | + | let checks = [if ((claimHistory == unit)) | |
437 | + | then true | |
438 | + | else throwErr("already claimed")] | |
439 | + | if ((checks == checks)) | |
452 | 440 | then { | |
453 | - | let userAddress = Address(userAddressBytes) | |
454 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
455 | - | let periodLength = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPeriodLength()), wrapErr("invalid period length")) | |
456 | - | let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height")) | |
457 | - | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
458 | - | let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process")) | |
459 | - | let periodEndHeight = ((currentStartHeight + periodLength) - 1) | |
460 | - | let blocksProcessingBatchSizeMax = 40 | |
461 | - | let blocksProcessingBatchSize = if (if (if ((height >= nextBlockToProcess)) | |
462 | - | then if ((nextBlockToProcess >= currentStartHeight)) | |
463 | - | then true | |
464 | - | else (currentPeriodOrFail == 0) | |
465 | - | else false) | |
466 | - | then (periodEndHeight >= nextBlockToProcess) | |
467 | - | else false) | |
468 | - | then min([((periodEndHeight - nextBlockToProcess) + 1), blocksProcessingBatchSizeMax]) | |
469 | - | else throwErr(wrapErr("invalid target block")) | |
470 | - | let blockProcessingReward = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyBlockProcessingReward()), wrapErr("invalid block processing reward")) | |
471 | - | let blockProcessingRewardByGenerator = (blockProcessingReward / blocksProcessingBatchSize) | |
472 | - | let blockProcessingRewardByGeneratorRemainder = (blockProcessingReward - (blockProcessingRewardByGenerator * blocksProcessingBatchSize)) | |
473 | - | func map (acc,inc) = if ((inc >= blocksProcessingBatchSize)) | |
474 | - | then acc | |
475 | - | else { | |
476 | - | let targetBlockHeight = (nextBlockToProcess + inc) | |
477 | - | let targetBlockInfo = valueOrErrorMessage(blockInfoByHeight(targetBlockHeight), wrapErr("invalid block info")) | |
478 | - | let treasuryRewardOrFail = valueOrErrorMessage(rewardForOption(targetBlockInfo.rewards, treasuryAddressOrFail), wrapErr(("invalid treasury reward for height " + toString(targetBlockHeight)))) | |
479 | - | let generator = targetBlockInfo.generator | |
480 | - | let available = valueOrElse(getInteger(factoryAddressOrFail, keyAvailable(generator)), 0) | |
481 | - | let callerReward = if ((inc == (blocksProcessingBatchSize - 1))) | |
482 | - | then (blockProcessingRewardByGenerator + blockProcessingRewardByGeneratorRemainder) | |
483 | - | else blockProcessingRewardByGenerator | |
484 | - | let lpAssetAmount = if ((currentPriceOrFail > 0)) | |
485 | - | then fraction((treasuryRewardOrFail - callerReward), SCALE8, currentPriceOrFail) | |
486 | - | else 0 | |
487 | - | let factoryActionsSingle = [invoke(factoryAddressOrFail, "stringEntry", [keyBlockProcessed(targetBlockHeight), makeString([toBase58String(i.transactionId), toString(currentPeriodOrFail), toString(generator), toBase58String(userAddressBytes), toString(treasuryRewardOrFail), toString(callerReward), toString(lpAssetAmount)], SEP)], nil), invoke(factoryAddressOrFail, "integerEntry", [keyAvailable(generator), (available + lpAssetAmount)], nil)] | |
488 | - | if ((factoryActionsSingle == factoryActionsSingle)) | |
489 | - | then (acc + lpAssetAmount) | |
490 | - | else throw("Strict value is not equal to itself.") | |
441 | + | let rewardAmount = if ((calculateReward(callerAddress, assetId, index) > 0)) | |
442 | + | then calculateReward(callerAddress, assetId, index) | |
443 | + | else throwErr("nothing to claim") | |
444 | + | let votingRewardAssetIdStr = getString(keyVotingRewardAssetId(assetId, index)) | |
445 | + | let rewardAction = if (isDefined(votingRewardAssetIdStr)) | |
446 | + | then { | |
447 | + | let votingRewardAssetId = fromBase58String(value(votingRewardAssetIdStr)) | |
448 | + | [ScriptTransfer(callerAddress, rewardAmount, votingRewardAssetId), IntegerEntry(claimHistoryKey, rewardAmount), DeleteEntry(keyVotingReward(callerAddress, assetId, index))] | |
491 | 449 | } | |
492 | - | ||
493 | - | let list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39] | |
494 | - | let lpAssetAmountTotal = { | |
495 | - | let $l = list | |
496 | - | let $s = size($l) | |
497 | - | let $acc0 = 0 | |
498 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
499 | - | then $a | |
500 | - | else map($a, $l[$i]) | |
501 | - | ||
502 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
503 | - | then $a | |
504 | - | else throw("List size exceeds 40") | |
505 | - | ||
506 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40) | |
507 | - | } | |
508 | - | if ((lpAssetAmountTotal == lpAssetAmountTotal)) | |
509 | - | then { | |
510 | - | let actions = [invoke(factoryAddressOrFail, "transferWaves", [userAddressBytes, blockProcessingReward], nil), invoke(factoryAddressOrFail, "reissue", [lpAssetAmountTotal], nil), invoke(factoryAddressOrFail, "integerEntry", [keyNextBlockToProcess(), (nextBlockToProcess + blocksProcessingBatchSize)], nil)] | |
511 | - | if ((actions == actions)) | |
512 | - | then $Tuple2(nil, unit) | |
513 | - | else throw("Strict value is not equal to itself.") | |
514 | - | } | |
515 | - | else throw("Strict value is not equal to itself.") | |
450 | + | else throwErr("nothing to claim") | |
451 | + | rewardAction | |
516 | 452 | } | |
517 | 453 | else throw("Strict value is not equal to itself.") | |
518 | 454 | } | |
519 | 455 | ||
520 | 456 | ||
521 | 457 | @Verifier(tx) | |
522 | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
458 | + | func verify () = { | |
459 | + | let targetPublicKey = match managerPublicKeyOrUnit() { | |
460 | + | case pk: ByteVector => | |
461 | + | pk | |
462 | + | case _: Unit => | |
463 | + | tx.senderPublicKey | |
464 | + | case _ => | |
465 | + | throw("Match error") | |
466 | + | } | |
467 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
468 | + | } | |
523 | 469 |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let separator = "__" | |
5 | 5 | ||
6 | - | let | |
6 | + | let MULT8 = 100000000 | |
7 | 7 | ||
8 | - | let SCALE8 = 100000000 | |
9 | - | ||
10 | - | let SCALE6 = 1000000 | |
11 | - | ||
12 | - | let PENDING = "PENDING" | |
13 | - | ||
14 | - | let FINISHED = "FINISHED" | |
15 | - | ||
16 | - | let WAVES = "WAVES" | |
17 | - | ||
18 | - | func wrapErr (s) = ((CONTRACT_NAME + ": ") + s) | |
8 | + | func wrapErr (msg) = makeString(["voting_verified_v2.ride:", msg], " ") | |
19 | 9 | ||
20 | 10 | ||
21 | - | func throwErr ( | |
11 | + | func throwErr (msg) = throw(wrapErr(msg)) | |
22 | 12 | ||
23 | 13 | ||
24 | - | func assetIdToString (assetId) = match assetId { | |
25 | - | case b: ByteVector => | |
26 | - | toBase58String(b) | |
27 | - | case _: Unit => | |
28 | - | WAVES | |
14 | + | func asInt (val) = match val { | |
15 | + | case valInt: Int => | |
16 | + | valInt | |
29 | 17 | case _ => | |
30 | - | throw(" | |
18 | + | throw("Failed to cast into Integer") | |
31 | 19 | } | |
32 | 20 | ||
33 | 21 | ||
34 | - | func abs (n) = if ((0 > n)) | |
35 | - | then -(n) | |
36 | - | else n | |
22 | + | func getIntegerOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
37 | 23 | ||
38 | 24 | ||
39 | - | func | |
25 | + | func getIntegerOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), wrapErr((key + " is not defined"))) | |
40 | 26 | ||
41 | 27 | ||
42 | - | func | |
28 | + | func getStringOrEmpty (address,key) = valueOrElse(getString(address, key), "") | |
43 | 29 | ||
44 | 30 | ||
45 | - | func | |
31 | + | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((key + " is not defined"))) | |
46 | 32 | ||
47 | 33 | ||
48 | - | func keyTreasuryAddress () = makeString(["%s", "treasury"], SEP) | |
34 | + | let keyBoostingContract = makeString(["%s", "boostingContract"], separator) | |
35 | + | ||
36 | + | let keyEmissionContract = makeString(["%s", "emissionContract"], separator) | |
37 | + | ||
38 | + | let keyAssetsStoreContract = makeString(["%s", "assetsStoreContract"], separator) | |
39 | + | ||
40 | + | let boostingContract = addressFromStringValue(getStringValue(keyBoostingContract)) | |
41 | + | ||
42 | + | let emissionContract = addressFromStringValue(getStringValue(keyEmissionContract)) | |
43 | + | ||
44 | + | let assetsStoreContract = addressFromStringValue(getStringValue(keyAssetsStoreContract)) | |
45 | + | ||
46 | + | let keyEmissionConfig = makeString(["%s", "config"], separator) | |
47 | + | ||
48 | + | let wxAssetIdStr = split(getStringOrFail(emissionContract, keyEmissionConfig), separator)[1] | |
49 | + | ||
50 | + | let wxAssetId = fromBase58String(wxAssetIdStr) | |
51 | + | ||
52 | + | let keyVotingThresholdAdd = makeString(["%s%s", "votingThreshold", "add"], separator) | |
53 | + | ||
54 | + | let keyVotingThresholdRemove = makeString(["%s%s", "votingThreshold", "remove"], separator) | |
55 | + | ||
56 | + | let keyPeriodLengthRemove = makeString(["%s", "periodLengthRemove"], separator) | |
57 | + | ||
58 | + | let keyMaxPeriodLength = makeString(["%s", "maxPeriodLength"], separator) | |
59 | + | ||
60 | + | let keyMinPeriodLength = makeString(["%s", "minPeriodLength"], separator) | |
61 | + | ||
62 | + | func keyVotingRewardAssetId (assetId,index) = makeString(["%s%s%d", "votingRewardAssetId", assetId, toString(index)], separator) | |
49 | 63 | ||
50 | 64 | ||
51 | - | func | |
65 | + | func keyVotingReward (userAddress,assetId,index) = makeString(["%s%s%s%d", "votingReward", toString(userAddress), assetId, toString(index)], separator) | |
52 | 66 | ||
53 | 67 | ||
54 | - | func | |
68 | + | func keyTotalVotingReward (assetId,index) = makeString(["%s%s%d", "totalVotingReward", assetId, toString(index)], separator) | |
55 | 69 | ||
56 | 70 | ||
57 | - | func keyClaimed (userAddress) = makeString(["%s%s", "claimed", toString(userAddress)], SEP) | |
71 | + | let keyFinalizeCallRewardAmount = makeString(["%s", "finalizeCallRewardAmount"], separator) | |
72 | + | ||
73 | + | let keyMinSuggestRemoveBalance = makeString(["%s", "minSuggestRemoveBalance"], separator) | |
74 | + | ||
75 | + | func keyCurrentIndex (assetId) = makeString(["%s%s", "currentIndex", assetId], separator) | |
58 | 76 | ||
59 | 77 | ||
60 | - | func | |
78 | + | func keyVote (assetId,index,caller) = makeString(["%s%s%d%s", "vote", assetId, toString(index), toString(caller)], separator) | |
61 | 79 | ||
62 | 80 | ||
63 | - | func | |
81 | + | func voteValue (inFavor,gwxAmount) = makeString(["%s%d", toString(inFavor), toString(gwxAmount)], separator) | |
64 | 82 | ||
65 | 83 | ||
66 | - | func | |
84 | + | func keySuggestIssuer (assetId,index) = makeString(["%s%s%d", "suggestIssuer", assetId, toString(index)], separator) | |
67 | 85 | ||
68 | 86 | ||
69 | - | func | |
87 | + | func keyClaimHistory (userAddress,assetId,index) = makeString(["%s%s%s%d", "history", toString(userAddress), assetId, toString(index)], separator) | |
70 | 88 | ||
71 | 89 | ||
72 | - | func keyBlockProcessingReward () = "%s__blockProcessingReward" | |
90 | + | let keyFeePerBlock = makeString(["%s", "feePerBlock"], separator) | |
91 | + | ||
92 | + | let feePerBlock = getIntegerOrFail(this, keyFeePerBlock) | |
93 | + | ||
94 | + | let keyMinWxMinForSuggestAddAmountRequired = makeString(["%s", "wxMinForSuggestAddAmountRequired"], separator) | |
95 | + | ||
96 | + | let keyWxForSuggestRemoveAmountRequired = makeString(["%s", "wxForSuggestRemoveAmountRequired"], separator) | |
97 | + | ||
98 | + | func keyVotingInfo (assetId,index) = makeString(["%s%s%d", "votingInfo", assetId, toString(index)], separator) | |
73 | 99 | ||
74 | 100 | ||
75 | - | func | |
101 | + | func votingInfoValue (isRewardExist,rewardAssetId,rewardAmount,votingType,status,votingStartHeight,votingEndHeight,votesQuorum,votesFor,votesAgainst) = makeString(["%s%s%d%s%s%d%d%d%d%d", toString(isRewardExist), rewardAssetId, toString(rewardAmount), votingType, status, toString(votingStartHeight), toString(votingEndHeight), toString(votesQuorum), toString(votesFor), toString(votesAgainst)], separator) | |
76 | 102 | ||
77 | 103 | ||
78 | - | func | |
104 | + | func keyAssetImage (assetId) = makeString(["%s%s", "assetImage", assetId], separator) | |
79 | 105 | ||
80 | 106 | ||
81 | - | func keyWithdrawal () = "%s__withdrawal" | |
107 | + | func getUserGwxAmountAtHeight (userAddress,targetHeight) = { | |
108 | + | let gwxAmount = invoke(boostingContract, "getUserGwxAmountAtHeightREADONLY", [userAddress, targetHeight], nil) | |
109 | + | asInt(gwxAmount) | |
110 | + | } | |
82 | 111 | ||
83 | 112 | ||
84 | - | func | |
113 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
85 | 114 | ||
86 | 115 | ||
87 | - | func valueWithdrawalRequest (status,lpAssetAmount,targetPeriod,claimTxId) = { | |
88 | - | let claimTxIdStr = match claimTxId { | |
89 | - | case b: ByteVector => | |
90 | - | toBase58String(b) | |
116 | + | func keyManagerPublicKey () = "%s__managerPublicKey" | |
117 | + | ||
118 | + | ||
119 | + | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
120 | + | case s: String => | |
121 | + | addressFromStringValue(s) | |
122 | + | case _ => | |
123 | + | this | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | func managerPublicKeyOrUnit () = { | |
128 | + | let managerVaultAddress = getManagerVaultAddressOrThis() | |
129 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
130 | + | case s: String => | |
131 | + | fromBase58String(s) | |
91 | 132 | case _: Unit => | |
92 | - | | |
133 | + | unit | |
93 | 134 | case _ => | |
94 | 135 | throw("Match error") | |
95 | 136 | } | |
96 | - | makeString(["%s%d%d%s", status, toString(lpAssetAmount), toString(targetPeriod), claimTxIdStr], SEP) | |
97 | 137 | } | |
98 | 138 | ||
99 | 139 | ||
100 | - | func parseWithdrawalRequestValueOrFail (s) = { | |
101 | - | let parts = split(s, SEP) | |
102 | - | if ((size(parts) == 5)) | |
103 | - | then { | |
104 | - | let status = parts[1] | |
105 | - | let lpAssetAmount = valueOrErrorMessage(parseInt(parts[2]), wrapErr("invalid lpAssetAmount")) | |
106 | - | let targetPeriod = valueOrErrorMessage(parseInt(parts[3]), wrapErr("invalid targetPeriod")) | |
107 | - | let claimTxId = parts[4] | |
108 | - | $Tuple4(status, lpAssetAmount, targetPeriod, claimTxId) | |
109 | - | } | |
110 | - | else throwErr("invalid withdrawal request value") | |
140 | + | func getVotingInfoParts (votingInfo) = { | |
141 | + | let votingInfoParts = split(votingInfo, separator) | |
142 | + | let isRewardExistStr = votingInfoParts[1] | |
143 | + | let isRewardExist = if ((isRewardExistStr == "true")) | |
144 | + | then true | |
145 | + | else false | |
146 | + | let rewardAssetId = votingInfoParts[2] | |
147 | + | let rewardAmount = parseIntValue(votingInfoParts[3]) | |
148 | + | let votingType = votingInfoParts[4] | |
149 | + | let status = votingInfoParts[5] | |
150 | + | let votingStartHeight = parseIntValue(votingInfoParts[6]) | |
151 | + | let votingEndHeight = parseIntValue(votingInfoParts[7]) | |
152 | + | let votesQuorum = parseIntValue(votingInfoParts[8]) | |
153 | + | let votesFor = parseIntValue(votingInfoParts[9]) | |
154 | + | let votesAgainst = parseIntValue(votingInfoParts[10]) | |
155 | + | $Tuple10(isRewardExist, rewardAssetId, rewardAmount, votingType, status, votingStartHeight, votingEndHeight, votesQuorum, votesFor, votesAgainst) | |
111 | 156 | } | |
112 | 157 | ||
113 | 158 | ||
114 | - | let factoryAddressOption = match getString(this, keyFactoryAddress()) { | |
115 | - | case s: String => | |
116 | - | addressFromString(s) | |
117 | - | case _: Unit => | |
118 | - | unit | |
119 | - | case _ => | |
120 | - | throw("Match error") | |
121 | - | } | |
122 | - | ||
123 | - | let factoryAddressOrFail = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address")) | |
124 | - | ||
125 | - | let lpAssetIdOption = match factoryAddressOption { | |
126 | - | case a: Address => | |
127 | - | match getString(a, keyLpAssetId()) { | |
128 | - | case s: String => | |
129 | - | fromBase58String(s) | |
130 | - | case _: Unit => | |
131 | - | unit | |
132 | - | case _ => | |
133 | - | throw("Match error") | |
134 | - | } | |
135 | - | case _: Unit => | |
136 | - | unit | |
137 | - | case _ => | |
138 | - | throw("Match error") | |
139 | - | } | |
140 | - | ||
141 | - | let lpAssetIdOrFail = valueOrErrorMessage(lpAssetIdOption, wrapErr("invalid lpAssetId")) | |
142 | - | ||
143 | - | let xtnAssetIdOption = match factoryAddressOption { | |
144 | - | case a: Address => | |
145 | - | match getString(a, keyXtnAssetId()) { | |
146 | - | case s: String => | |
147 | - | fromBase58String(s) | |
148 | - | case _: Unit => | |
149 | - | unit | |
150 | - | case _ => | |
151 | - | throw("Match error") | |
152 | - | } | |
153 | - | case _: Unit => | |
154 | - | unit | |
155 | - | case _ => | |
156 | - | throw("Match error") | |
157 | - | } | |
158 | - | ||
159 | - | let xtnAssetIdOrFail = valueOrErrorMessage(xtnAssetIdOption, wrapErr("invalid xtnAssetId")) | |
160 | - | ||
161 | - | let treasuryAddressOption = match factoryAddressOption { | |
162 | - | case a: Address => | |
163 | - | match getString(a, keyTreasuryAddress()) { | |
164 | - | case s: String => | |
165 | - | addressFromString(s) | |
166 | - | case _: Unit => | |
167 | - | unit | |
168 | - | case _ => | |
169 | - | throw("Match error") | |
170 | - | } | |
171 | - | case _: Unit => | |
172 | - | unit | |
173 | - | case _ => | |
174 | - | throw("Match error") | |
175 | - | } | |
176 | - | ||
177 | - | let treasuryAddressOrFail = valueOrErrorMessage(treasuryAddressOption, wrapErr("invalid treasury address")) | |
178 | - | ||
179 | - | func onlyAddress (i,address) = if ((i.caller == address)) | |
180 | - | then true | |
181 | - | else throwErr("permission denied") | |
159 | + | func votingExistChecks (assetId,currentIndex) = { | |
160 | + | let votingInfo = valueOrErrorMessage(getString(keyVotingInfo(assetId, currentIndex)), wrapErr("voting info not found")) | |
161 | + | let votingInfoArray = split(votingInfo, separator) | |
162 | + | let status = votingInfoArray[5] | |
163 | + | let votingEndHeight = valueOrErrorMessage(parseIntValue(votingInfoArray[7]), wrapErr("voting start height not found")) | |
164 | + | let suggestIssuer = valueOrErrorMessage(getString(keySuggestIssuer(assetId, currentIndex)), wrapErr("voting issuer not found")) | |
165 | + | let checks = [if ((status == "inProgress")) | |
166 | + | then true | |
167 | + | else throwErr("no voting in progress"), if ((votingEndHeight > height)) | |
168 | + | then true | |
169 | + | else throwErr("voting expired")] | |
170 | + | if ((checks == checks)) | |
171 | + | then $Tuple3(status, votingEndHeight, suggestIssuer) | |
172 | + | else throw("Strict value is not equal to itself.") | |
173 | + | } | |
182 | 174 | ||
183 | 175 | ||
184 | - | func onlyFactory (i) = onlyAddress(i, factoryAddressOrFail) | |
185 | - | ||
186 | - | ||
187 | - | func rewardForOption (rewards,target) = { | |
188 | - | let s = size(rewards) | |
189 | - | let $t040964121 = rewards[0] | |
190 | - | let a0 = $t040964121._1 | |
191 | - | let r0 = $t040964121._2 | |
192 | - | let $t041244149 = rewards[1] | |
193 | - | let a1 = $t041244149._1 | |
194 | - | let r1 = $t041244149._2 | |
195 | - | let $t041524177 = rewards[2] | |
196 | - | let a2 = $t041524177._1 | |
197 | - | let r2 = $t041524177._2 | |
198 | - | if (if ((s > 0)) | |
199 | - | then (a0 == target) | |
200 | - | else false) | |
201 | - | then r0 | |
202 | - | else if (if ((s > 1)) | |
203 | - | then (a1 == target) | |
204 | - | else false) | |
205 | - | then r1 | |
206 | - | else if (if ((s > 2)) | |
207 | - | then (a2 == target) | |
208 | - | else false) | |
209 | - | then r2 | |
210 | - | else unit | |
176 | + | func calculateReward (voter,assetId,index) = { | |
177 | + | let voteKey = keyVote(assetId, index, voter) | |
178 | + | let lastVote = valueOrErrorMessage(getString(voteKey), wrapErr("you have not voted")) | |
179 | + | let lastVoteParts = split(lastVote, separator) | |
180 | + | let gwxAmount = parseIntValue(lastVoteParts[2]) | |
181 | + | let votingInfoStr = valueOrErrorMessage(getString(keyVotingInfo(assetId, index)), wrapErr("voting info not found")) | |
182 | + | let votingParts = getVotingInfoParts(votingInfoStr) | |
183 | + | let votesFor = votingParts._9 | |
184 | + | let votesAgainst = votingParts._10 | |
185 | + | let partOfTheTotalVotesX8 = fraction(gwxAmount, MULT8, (votesFor + votesAgainst)) | |
186 | + | let totalVotingReward = valueOrElse(getInteger(keyTotalVotingReward(assetId, index)), 0) | |
187 | + | let voterRewardAmount = fraction(partOfTheTotalVotesX8, totalVotingReward, MULT8, FLOOR) | |
188 | + | voterRewardAmount | |
211 | 189 | } | |
212 | 190 | ||
213 | 191 | ||
214 | 192 | @Callable(i) | |
215 | - | func claimLP (userAddressBytes) = { | |
216 | - | let checkCaller = onlyFactory(i) | |
217 | - | if ((checkCaller == checkCaller)) | |
193 | + | func suggestAdd (assetId,periodLength,assetImage) = { | |
194 | + | let wxPayment = i.payments[0] | |
195 | + | let wxPaymentAssetId = value(wxPayment.assetId) | |
196 | + | let wxPaymentAmount = value(wxPayment.amount) | |
197 | + | let minPeriodLength = getIntegerValue(keyMinPeriodLength) | |
198 | + | let maxPeriodLength = getIntegerValue(keyMaxPeriodLength) | |
199 | + | let tokenIsVerified = { | |
200 | + | let @ = invoke(assetsStoreContract, "isVerifiedREADONLY", [assetId], nil) | |
201 | + | if ($isInstanceOf(@, "Boolean")) | |
202 | + | then @ | |
203 | + | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
204 | + | } | |
205 | + | let checks = [if (if ((periodLength >= minPeriodLength)) | |
206 | + | then (maxPeriodLength >= periodLength) | |
207 | + | else false) | |
208 | + | then true | |
209 | + | else throwErr("invalid periodLength"), if ((tokenIsVerified == false)) | |
210 | + | then true | |
211 | + | else throwErr("token already verified"), if ((wxPaymentAmount > (periodLength * feePerBlock))) | |
212 | + | then true | |
213 | + | else throwErr("not enough wx for given period"), if ((wxPaymentAmount >= getIntegerValue(keyMinWxMinForSuggestAddAmountRequired))) | |
214 | + | then true | |
215 | + | else throwErr("payment less then min for suggest")] | |
216 | + | if ((checks == checks)) | |
218 | 217 | then { | |
219 | - | let userAddress = Address(userAddressBytes) | |
220 | - | let available = valueOrElse(getInteger(factoryAddressOrFail, keyAvailable(userAddress)), 0) | |
221 | - | let claimed = valueOrElse(getInteger(factoryAddressOrFail, keyClaimed(userAddress)), 0) | |
222 | - | let factoryActions = if ((available > 0)) | |
223 | - | then [invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, available, lpAssetIdOrFail], nil), invoke(factoryAddressOrFail, "integerEntry", [keyAvailable(userAddress), 0], nil), invoke(factoryAddressOrFail, "integerEntry", [keyClaimed(userAddress), (claimed + available)], nil)] | |
224 | - | else throwErr("nothing to claim") | |
225 | - | $Tuple2(nil, factoryActions) | |
218 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
219 | + | let currentIndex = getInteger(currentIndexKey) | |
220 | + | let newIndex = if (isDefined(currentIndex)) | |
221 | + | then (value(currentIndex) + 1) | |
222 | + | else 0 | |
223 | + | let $t087849424 = if ((size(i.payments) > 1)) | |
224 | + | then { | |
225 | + | let votingRewardPayment = i.payments[1] | |
226 | + | let votingRewardPaymentAssetId = toBase58String(value(votingRewardPayment.assetId)) | |
227 | + | let votingRewardPaymentAmount = value(votingRewardPayment.amount) | |
228 | + | $Tuple4(true, votingRewardPaymentAssetId, votingRewardPaymentAmount, [StringEntry(keyVotingRewardAssetId(assetId, newIndex), votingRewardPaymentAssetId), IntegerEntry(keyTotalVotingReward(assetId, newIndex), votingRewardPaymentAmount)]) | |
229 | + | } | |
230 | + | else $Tuple4(false, "EMPTY", 0, nil) | |
231 | + | let isRewardExist = $t087849424._1 | |
232 | + | let rewardAssetId = $t087849424._2 | |
233 | + | let rewardAmount = $t087849424._3 | |
234 | + | let votingRewardActions = $t087849424._4 | |
235 | + | let votesQuorum = valueOrErrorMessage(getInteger(keyVotingThresholdAdd), wrapErr("votingThresholdAdd not set")) | |
236 | + | let votingInfo = votingInfoValue(isRewardExist, rewardAssetId, rewardAmount, "verification", "inProgress", height, (height + periodLength), votesQuorum, 0, 0) | |
237 | + | let finalizeCallRewardAmount = getIntegerValue(keyFinalizeCallRewardAmount) | |
238 | + | let burnWxAmount = (wxPaymentAmount - finalizeCallRewardAmount) | |
239 | + | ([IntegerEntry(currentIndexKey, newIndex), StringEntry(keySuggestIssuer(assetId, newIndex), toString(i.caller)), StringEntry(keyVotingInfo(assetId, newIndex), votingInfo), StringEntry(keyAssetImage(assetId), assetImage), Burn(wxPaymentAssetId, burnWxAmount)] ++ votingRewardActions) | |
226 | 240 | } | |
227 | 241 | else throw("Strict value is not equal to itself.") | |
228 | 242 | } | |
229 | 243 | ||
230 | 244 | ||
231 | 245 | ||
232 | 246 | @Callable(i) | |
233 | - | func finalize (userAddressBytes,newTreasuryVolumeInWaves,xtnPrice,pwrManagersBonus,treasuryVolumeDiffAllocationCoef) = { | |
234 | - | let checkCaller = onlyFactory(i) | |
235 | - | if ((checkCaller == checkCaller)) | |
247 | + | func suggestRemove (assetId) = { | |
248 | + | let gwxAmountAtNow = getUserGwxAmountAtHeight(toString(i.caller), height) | |
249 | + | let minSuggestRemoveBalance = getIntegerValue(keyMinSuggestRemoveBalance) | |
250 | + | let wxPayment = i.payments[0] | |
251 | + | let wxPaymentAssetId = value(wxPayment.assetId) | |
252 | + | let wxPaymentAmount = value(wxPayment.amount) | |
253 | + | let tokenIsVerified = { | |
254 | + | let @ = invoke(assetsStoreContract, "isVerifiedREADONLY", [assetId], nil) | |
255 | + | if ($isInstanceOf(@, "Boolean")) | |
256 | + | then @ | |
257 | + | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
258 | + | } | |
259 | + | let checks = [if (tokenIsVerified) | |
260 | + | then true | |
261 | + | else throwErr("token not verified"), if ((gwxAmountAtNow >= minSuggestRemoveBalance)) | |
262 | + | then true | |
263 | + | else throwErr("not enough gWXes"), if ((wxPaymentAmount >= getIntegerValue(keyWxForSuggestRemoveAmountRequired))) | |
264 | + | then true | |
265 | + | else throwErr("payment less then min for suggest")] | |
266 | + | if ((checks == checks)) | |
236 | 267 | then { | |
237 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
238 | - | let periodLength = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPeriodLength()), wrapErr("invalid period length")) | |
239 | - | let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height")) | |
240 | - | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
241 | - | let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process")) | |
242 | - | let periodEndHeight = ((currentStartHeight + periodLength) - 1) | |
243 | - | let checks = [if ((i.originCaller == treasuryAddressOrFail)) | |
268 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
269 | + | let currentIndex = getInteger(currentIndexKey) | |
270 | + | let newIndex = if (isDefined(currentIndex)) | |
271 | + | then (value(currentIndex) + 1) | |
272 | + | else 0 | |
273 | + | let periodLength = valueOrErrorMessage(getInteger(keyPeriodLengthRemove), wrapErr("periodLengthRemove not set")) | |
274 | + | let votingEndHeight = (height + periodLength) | |
275 | + | let votesQuorum = valueOrErrorMessage(getInteger(keyVotingThresholdRemove), wrapErr("votingThresholdRemove not set")) | |
276 | + | let votingInfo = votingInfoValue(false, "EMPTY", 0, "deverification", "inProgress", height, (height + periodLength), votesQuorum, 0, 0) | |
277 | + | [IntegerEntry(currentIndexKey, newIndex), StringEntry(keySuggestIssuer(assetId, newIndex), toString(i.caller)), StringEntry(keyVotingInfo(assetId, newIndex), votingInfo)] | |
278 | + | } | |
279 | + | else throw("Strict value is not equal to itself.") | |
280 | + | } | |
281 | + | ||
282 | + | ||
283 | + | ||
284 | + | @Callable(i) | |
285 | + | func vote (assetId,inFavor) = { | |
286 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
287 | + | let currentIndex = valueOrErrorMessage(getInteger(currentIndexKey), wrapErr("voting does not exist")) | |
288 | + | let votingInfo = votingExistChecks(assetId, currentIndex) | |
289 | + | if ((votingInfo == votingInfo)) | |
290 | + | then { | |
291 | + | let currentVotingEndHeight = votingInfo._2 | |
292 | + | let gwxAmountAtEnd = getUserGwxAmountAtHeight(toString(i.caller), currentVotingEndHeight) | |
293 | + | let voteKey = keyVote(assetId, currentIndex, i.caller) | |
294 | + | let checks = [if ((getString(voteKey) == unit)) | |
244 | 295 | then true | |
245 | - | else throwErr(" | |
296 | + | else throwErr("You have already voted"), if ((gwxAmountAtEnd > 0)) | |
246 | 297 | then true | |
247 | - | else throwErr("unprocessed blocks"), if ((newTreasuryVolumeInWaves >= 0)) | |
248 | - | then true | |
249 | - | else throwErr("invalid new treasury volume"), if ((xtnPrice >= 0)) | |
250 | - | then true | |
251 | - | else throwErr("invalid XTN price"), if (if ((pwrManagersBonus >= 0)) | |
252 | - | then (SCALE8 >= pwrManagersBonus) | |
253 | - | else false) | |
254 | - | then true | |
255 | - | else throwErr("invalid PWR managers bonus"), if (if ((treasuryVolumeDiffAllocationCoef >= -(SCALE8))) | |
256 | - | then (SCALE8 >= treasuryVolumeDiffAllocationCoef) | |
257 | - | else false) | |
258 | - | then true | |
259 | - | else throwErr("invalid treasury volume diff allocation coefficient")] | |
298 | + | else throw("You'll not have gWX at the end of voting")] | |
260 | 299 | if ((checks == checks)) | |
261 | 300 | then { | |
262 | - | let investedXtnAmount = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(xtnAssetIdOrFail)), 0) | |
263 | - | let investedWavesAmount = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(unit)), 0) | |
264 | - | let investedXtnAmountInWaves = fraction(investedXtnAmount, xtnPrice, SCALE6) | |
265 | - | let currentTreasuryVolumeInWaves = (investedXtnAmountInWaves + investedWavesAmount) | |
266 | - | let profitRaw = (newTreasuryVolumeInWaves - currentTreasuryVolumeInWaves) | |
267 | - | let pwrManagersBonusAmount = if ((profitRaw > 0)) | |
268 | - | then fraction(profitRaw, pwrManagersBonus, SCALE8) | |
269 | - | else 0 | |
270 | - | let profit = (profitRaw - pwrManagersBonusAmount) | |
271 | - | let donationPart = if ((currentTreasuryVolumeInWaves > 0)) | |
272 | - | then fraction(investedXtnAmountInWaves, SCALE8, currentTreasuryVolumeInWaves) | |
273 | - | else 0 | |
274 | - | let donationProfitPartRaw = fraction(profit, donationPart, SCALE8) | |
275 | - | let investmentProfitPartRaw = (profit - donationProfitPartRaw) | |
276 | - | let treasuryVolumeDiffAllocationCoefAbs = abs(treasuryVolumeDiffAllocationCoef) | |
277 | - | let amountToDonation = fraction(investmentProfitPartRaw, if ((0 > treasuryVolumeDiffAllocationCoef)) | |
278 | - | then treasuryVolumeDiffAllocationCoefAbs | |
279 | - | else 0, SCALE8) | |
280 | - | let amountToInvestment = fraction(donationProfitPartRaw, if ((treasuryVolumeDiffAllocationCoef > 0)) | |
281 | - | then treasuryVolumeDiffAllocationCoefAbs | |
282 | - | else 0, SCALE8) | |
283 | - | let donationProfitPart = ((donationProfitPartRaw - amountToInvestment) + amountToDonation) | |
284 | - | let investmentProfitPart = ((investmentProfitPartRaw - amountToDonation) + amountToInvestment) | |
285 | - | let investedWavesAmountNew = (investedWavesAmount + investmentProfitPart) | |
286 | - | let investedXtnAmountNew = fraction((investedXtnAmountInWaves + donationProfitPart), SCALE6, xtnPrice) | |
287 | - | let newPeriod = (currentPeriodOrFail + 1) | |
288 | - | let lpAssetQuantity = valueOrErrorMessage(assetInfo(lpAssetIdOrFail), wrapErr("invalid lpAsset info")).quantity | |
289 | - | let newPrice = fraction(investedWavesAmountNew, SCALE8, lpAssetQuantity) | |
290 | - | let lpAssetAmountToBurn = valueOrElse(getInteger(factoryAddressOrFail, keyWithdrawal()), 0) | |
291 | - | let paymentAmountMin = max([0, fraction(lpAssetAmountToBurn, newPrice, SCALE8)]) | |
292 | - | let paymentOption = if ((size(i.payments) > 0)) | |
293 | - | then i.payments[0] | |
294 | - | else unit | |
295 | - | let paymentAmount = value(paymentOption).amount | |
296 | - | let paymentAssetId = value(paymentOption).assetId | |
297 | - | let checkPayment = if (if ((paymentAmountMin == 0)) | |
298 | - | then true | |
299 | - | else if (if ((paymentOption != unit)) | |
300 | - | then (paymentAssetId == unit) | |
301 | - | else false) | |
302 | - | then (paymentAmount >= paymentAmountMin) | |
303 | - | else false) | |
304 | - | then true | |
305 | - | else throwErr(("invalid payments, payment amount min: " + toString(paymentAmountMin))) | |
306 | - | if ((checkPayment == checkPayment)) | |
307 | - | then { | |
308 | - | let actions = if ((paymentOption != unit)) | |
309 | - | then [ScriptTransfer(factoryAddressOrFail, paymentAmount, paymentAssetId)] | |
310 | - | else nil | |
311 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyCurrentPeriod(), newPeriod], nil), invoke(factoryAddressOrFail, "integerEntry", [keyPriceForPeriod(newPeriod), newPrice], nil), invoke(factoryAddressOrFail, "integerEntry", [keyStartHeight(newPeriod), (periodEndHeight + 1)], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmountToBurn], nil), invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), 0], nil)] | |
312 | - | $Tuple2(actions, factoryActions) | |
313 | - | } | |
314 | - | else throw("Strict value is not equal to itself.") | |
301 | + | let votingInfoStr = valueOrErrorMessage(getString(keyVotingInfo(assetId, currentIndex)), wrapErr("voting info not found")) | |
302 | + | let votingInfoParts = getVotingInfoParts(votingInfoStr) | |
303 | + | let votesFor = votingInfoParts._9 | |
304 | + | let votesAgainst = votingInfoParts._10 | |
305 | + | let $t01274512906 = if (inFavor) | |
306 | + | then $Tuple2((votesFor + gwxAmountAtEnd), votesAgainst) | |
307 | + | else $Tuple2(votesFor, (votesAgainst + gwxAmountAtEnd)) | |
308 | + | let newVotesFor = $t01274512906._1 | |
309 | + | let newVotesAgainst = $t01274512906._2 | |
310 | + | let newVotingInfoValue = votingInfoValue(votingInfoParts._1, votingInfoParts._2, votingInfoParts._3, votingInfoParts._4, votingInfoParts._5, votingInfoParts._6, votingInfoParts._7, votingInfoParts._8, newVotesFor, newVotesAgainst) | |
311 | + | let votingRewardAction = match getString(keyVotingRewardAssetId(assetId, currentIndex)) { | |
312 | + | case pk: String => | |
313 | + | [StringEntry(keyVotingReward(i.caller, assetId, currentIndex), voteValue(inFavor, gwxAmountAtEnd))] | |
314 | + | case _: Unit => | |
315 | + | nil | |
316 | + | case _ => | |
317 | + | throw("Match error") | |
318 | + | } | |
319 | + | ([StringEntry(voteKey, voteValue(inFavor, gwxAmountAtEnd)), StringEntry(keyVotingInfo(assetId, currentIndex), newVotingInfoValue)] ++ votingRewardAction) | |
315 | 320 | } | |
316 | 321 | else throw("Strict value is not equal to itself.") | |
317 | 322 | } | |
318 | 323 | else throw("Strict value is not equal to itself.") | |
319 | 324 | } | |
320 | 325 | ||
321 | 326 | ||
322 | 327 | ||
323 | 328 | @Callable(i) | |
324 | - | func invest (userAddressBytes) = { | |
325 | - | let checkCaller = onlyFactory(i) | |
326 | - | if ((checkCaller == checkCaller)) | |
329 | + | func cancelVote (assetId) = { | |
330 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
331 | + | let currentIndex = valueOrErrorMessage(getInteger(currentIndexKey), wrapErr("voting does not exist")) | |
332 | + | let voteKey = keyVote(assetId, currentIndex, i.caller) | |
333 | + | let lastVote = valueOrErrorMessage(getString(voteKey), wrapErr("you have not voted")) | |
334 | + | let lastVoteParts = split(lastVote, separator) | |
335 | + | let inFavor = lastVoteParts[1] | |
336 | + | let gwxAmount = parseIntValue(lastVoteParts[2]) | |
337 | + | let votingInfo = votingExistChecks(assetId, currentIndex) | |
338 | + | if ((votingInfo == votingInfo)) | |
327 | 339 | then { | |
328 | - | let userAddress = Address(userAddressBytes) | |
329 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
330 | - | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
331 | - | let payment = if ((size(i.payments) == 1)) | |
332 | - | then i.payments[0] | |
333 | - | else throwErr("invalid payments") | |
334 | - | let $t01103511212 = if (if ((payment.assetId == unit)) | |
335 | - | then (payment.amount > 0) | |
336 | - | else false) | |
337 | - | then $Tuple2(payment.amount, payment.assetId) | |
338 | - | else throwErr("invalid payment amount") | |
339 | - | let paymentAmount = $t01103511212._1 | |
340 | - | let paymentAssetId = $t01103511212._2 | |
341 | - | let lpAssetAmount = if ((currentPriceOrFail > 0)) | |
342 | - | then fraction(paymentAmount, SCALE8, currentPriceOrFail) | |
343 | - | else 0 | |
344 | - | let invested = valueOrElse(getInteger(factoryAddressOrFail, keyInvested(unit)), 0) | |
345 | - | let actions = [ScriptTransfer(treasuryAddressOrFail, paymentAmount, paymentAssetId)] | |
346 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyInvested(unit), (invested + paymentAmount)], nil), invoke(factoryAddressOrFail, "reissue", [lpAssetAmount], nil), invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, lpAssetAmount, lpAssetIdOrFail], nil)] | |
347 | - | $Tuple2(actions, factoryActions) | |
348 | - | } | |
349 | - | else throw("Strict value is not equal to itself.") | |
350 | - | } | |
351 | - | ||
352 | - | ||
353 | - | ||
354 | - | @Callable(i) | |
355 | - | func withdraw (userAddressBytes) = { | |
356 | - | let checkCaller = onlyFactory(i) | |
357 | - | if ((checkCaller == checkCaller)) | |
358 | - | then { | |
359 | - | let userAddress = Address(userAddressBytes) | |
360 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
361 | - | let payment = if ((size(i.payments) == 1)) | |
362 | - | then i.payments[0] | |
363 | - | else throwErr(wrapErr("invalid payments")) | |
364 | - | let paymentAssetId = if ((payment.assetId == lpAssetIdOrFail)) | |
365 | - | then lpAssetIdOrFail | |
366 | - | else throwErr("invalid payment asset") | |
367 | - | let paymentAmount = if ((payment.amount > 0)) | |
368 | - | then payment.amount | |
369 | - | else throwErr("invalid payment amount") | |
370 | - | let withdrawal = valueOrElse(getInteger(factoryAddressOrFail, keyWithdrawal()), 0) | |
371 | - | let actions = [ScriptTransfer(factoryAddressOrFail, paymentAmount, paymentAssetId)] | |
372 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), (withdrawal + paymentAmount)], nil), invoke(factoryAddressOrFail, "stringEntry", [keyWithdrawalRequest(userAddress, i.transactionId), valueWithdrawalRequest(PENDING, paymentAmount, (currentPeriodOrFail + 1), unit)], nil)] | |
373 | - | if ((factoryActions == factoryActions)) | |
374 | - | then $Tuple2(actions, factoryActions) | |
375 | - | else throw("Strict value is not equal to itself.") | |
376 | - | } | |
377 | - | else throw("Strict value is not equal to itself.") | |
378 | - | } | |
379 | - | ||
380 | - | ||
381 | - | ||
382 | - | @Callable(i) | |
383 | - | func cancelWithdraw (userAddressBytes,txId) = { | |
384 | - | let checkCaller = onlyFactory(i) | |
385 | - | if ((checkCaller == checkCaller)) | |
386 | - | then { | |
387 | - | let userAddress = Address(userAddressBytes) | |
388 | - | let withdrawalRequestOption = valueOrErrorMessage(getString(factoryAddressOrFail, keyWithdrawalRequest(userAddress, txId)), wrapErr("invalid withdrawal request")) | |
389 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
390 | - | let $t01361513728 = parseWithdrawalRequestValueOrFail(withdrawalRequestOption) | |
391 | - | let status = $t01361513728._1 | |
392 | - | let lpAssetAmount = $t01361513728._2 | |
393 | - | let targetPeriod = $t01361513728._3 | |
394 | - | let claimTxId = $t01361513728._4 | |
395 | - | let checks = [if ((status == PENDING)) | |
340 | + | let checks = [if (if ((inFavor == "true")) | |
396 | 341 | then true | |
397 | - | else | |
342 | + | else (inFavor == "false")) | |
398 | 343 | then true | |
399 | - | else throwErr("invalid | |
344 | + | else throwErr("invalid vote")] | |
400 | 345 | if ((checks == checks)) | |
401 | 346 | then { | |
402 | - | let withdrawal = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyWithdrawal()), wrapErr("invalid total withdrawal amount")) | |
403 | - | let factoryActions = [invoke(factoryAddressOrFail, "integerEntry", [keyWithdrawal(), if ((withdrawal >= lpAssetAmount)) | |
404 | - | then (withdrawal - lpAssetAmount) | |
405 | - | else throwErr("invalid withdrawal amount")], nil), invoke(factoryAddressOrFail, "deleteEntry", [keyWithdrawalRequest(userAddress, txId)], nil), invoke(factoryAddressOrFail, "transferAsset", [userAddressBytes, lpAssetAmount, lpAssetIdOrFail], nil)] | |
406 | - | if ((factoryActions == factoryActions)) | |
407 | - | then $Tuple2(nil, factoryActions) | |
408 | - | else throw("Strict value is not equal to itself.") | |
347 | + | let votingInfoStr = valueOrErrorMessage(getString(keyVotingInfo(assetId, currentIndex)), wrapErr("voting info not found")) | |
348 | + | let votingInfoParts = getVotingInfoParts(votingInfoStr) | |
349 | + | let votesFor = votingInfoParts._9 | |
350 | + | let votesAgainst = votingInfoParts._10 | |
351 | + | let $t01453114692 = if ((inFavor == "true")) | |
352 | + | then $Tuple2((votesFor - gwxAmount), votesAgainst) | |
353 | + | else $Tuple2(votesFor, (votesAgainst - gwxAmount)) | |
354 | + | let newVotesFor = $t01453114692._1 | |
355 | + | let newVotesAgainst = $t01453114692._2 | |
356 | + | let newVotingInfoValue = votingInfoValue(votingInfoParts._1, votingInfoParts._2, votingInfoParts._3, votingInfoParts._4, votingInfoParts._5, votingInfoParts._6, votingInfoParts._7, votingInfoParts._8, newVotesFor, newVotesAgainst) | |
357 | + | [StringEntry(keyVotingInfo(assetId, currentIndex), newVotingInfoValue), DeleteEntry(voteKey), DeleteEntry(keyVotingReward(i.caller, assetId, currentIndex))] | |
409 | 358 | } | |
410 | 359 | else throw("Strict value is not equal to itself.") | |
411 | 360 | } | |
412 | 361 | else throw("Strict value is not equal to itself.") | |
413 | 362 | } | |
414 | 363 | ||
415 | 364 | ||
416 | 365 | ||
417 | 366 | @Callable(i) | |
418 | - | func claimWaves (userAddressBytes,txId) = { | |
419 | - | let checkCaller = onlyFactory(i) | |
420 | - | if ((checkCaller == checkCaller)) | |
367 | + | func finalize (assetId) = { | |
368 | + | let currentIndexKey = keyCurrentIndex(assetId) | |
369 | + | let currentIndex = valueOrElse(getInteger(currentIndexKey), 0) | |
370 | + | let votingThresholdAdd = valueOrErrorMessage(getInteger(keyVotingThresholdAdd), wrapErr("votingThresholdAdd not set")) | |
371 | + | let votingThresholdRemove = valueOrErrorMessage(getInteger(keyVotingThresholdRemove), wrapErr("votingThresholdRemove not set")) | |
372 | + | let votingInfoStr = valueOrErrorMessage(getString(keyVotingInfo(assetId, currentIndex)), wrapErr("voting info not found")) | |
373 | + | let votingInfoParts = getVotingInfoParts(votingInfoStr) | |
374 | + | let votingType = votingInfoParts._4 | |
375 | + | let status = votingInfoParts._5 | |
376 | + | let votingEndHeight = votingInfoParts._7 | |
377 | + | let votingQuorum = votingInfoParts._8 | |
378 | + | let votesFor = votingInfoParts._9 | |
379 | + | let votesAgainst = votingInfoParts._10 | |
380 | + | let checks = [if ((status == "inProgress")) | |
381 | + | then true | |
382 | + | else throwErr("voting not in progress"), if ((height >= votingEndHeight)) | |
383 | + | then true | |
384 | + | else throwErr("voting not finished"), if (isDefined(getString(keyAssetImage(assetId)))) | |
385 | + | then true | |
386 | + | else throwErr("asset image not set")] | |
387 | + | if ((checks == checks)) | |
421 | 388 | then { | |
422 | - | let userAddress = Address(userAddressBytes) | |
423 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
424 | - | let withdrawalRequestOption = valueOrErrorMessage(getString(factoryAddressOrFail, keyWithdrawalRequest(userAddress, txId)), wrapErr("invalid withdrawal request")) | |
425 | - | let $t01506015173 = parseWithdrawalRequestValueOrFail(withdrawalRequestOption) | |
426 | - | let status = $t01506015173._1 | |
427 | - | let lpAssetAmount = $t01506015173._2 | |
428 | - | let targetPeriod = $t01506015173._3 | |
429 | - | let claimTxId = $t01506015173._4 | |
430 | - | if ((status == FINISHED)) | |
431 | - | then throwErr("invalid withdrawal request status") | |
432 | - | else if ((targetPeriod > currentPeriodOrFail)) | |
433 | - | then throwErr("invalid withdrawal request period") | |
434 | - | else { | |
435 | - | let priceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(targetPeriod)), wrapErr("invalid price")) | |
436 | - | let amount = if ((priceOrFail > 0)) | |
437 | - | then fraction(lpAssetAmount, priceOrFail, SCALE8) | |
438 | - | else 0 | |
439 | - | let factoryActions = [invoke(factoryAddressOrFail, "stringEntry", [keyWithdrawalRequest(userAddress, txId), valueWithdrawalRequest(FINISHED, lpAssetAmount, targetPeriod, i.transactionId)], nil), invoke(factoryAddressOrFail, "burn", [lpAssetAmount], nil), invoke(factoryAddressOrFail, "transferWaves", [userAddressBytes, amount], nil)] | |
440 | - | $Tuple2(nil, factoryActions) | |
441 | - | } | |
389 | + | let votingAccepted = if (if (((votesFor + votesAgainst) >= votingQuorum)) | |
390 | + | then (votesFor > votesAgainst) | |
391 | + | else false) | |
392 | + | then true | |
393 | + | else false | |
394 | + | let newStatus = if (votingAccepted) | |
395 | + | then "accepted" | |
396 | + | else "rejected" | |
397 | + | let assetImage = getStringValue(keyAssetImage(assetId)) | |
398 | + | let isVotingAccepted = if (votingAccepted) | |
399 | + | then { | |
400 | + | let votingAcceptedInvokes = if ((votingType == "verification")) | |
401 | + | then invoke(assetsStoreContract, "createOrUpdate", [assetId, assetImage, true], nil) | |
402 | + | else invoke(assetsStoreContract, "setVerified", [assetId, false], nil) | |
403 | + | votingAcceptedInvokes | |
404 | + | } | |
405 | + | else nil | |
406 | + | if ((isVotingAccepted == isVotingAccepted)) | |
407 | + | then { | |
408 | + | let newVotingInfoValue = votingInfoValue(votingInfoParts._1, votingInfoParts._2, votingInfoParts._3, votingInfoParts._4, newStatus, votingInfoParts._6, votingInfoParts._7, votingInfoParts._8, votingInfoParts._9, votingInfoParts._10) | |
409 | + | let finalizeCallRewardAmount = getIntegerValue(keyFinalizeCallRewardAmount) | |
410 | + | [StringEntry(keyVotingInfo(assetId, currentIndex), newVotingInfoValue), ScriptTransfer(i.caller, finalizeCallRewardAmount, wxAssetId)] | |
411 | + | } | |
412 | + | else throw("Strict value is not equal to itself.") | |
442 | 413 | } | |
443 | 414 | else throw("Strict value is not equal to itself.") | |
444 | 415 | } | |
445 | 416 | ||
446 | 417 | ||
447 | 418 | ||
448 | 419 | @Callable(i) | |
449 | - | func processBlocks (userAddressBytes) = { | |
450 | - | let checkCaller = onlyFactory(i) | |
451 | - | if ((checkCaller == checkCaller)) | |
420 | + | func claimREADONLY (assetId,index,userAddressStr) = { | |
421 | + | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid address")) | |
422 | + | let votingRewardAssetIdStr = getString(keyVotingRewardAssetId(assetId, index)) | |
423 | + | let rewardAmount = if (isDefined(votingRewardAssetIdStr)) | |
424 | + | then calculateReward(userAddress, assetId, index) | |
425 | + | else 0 | |
426 | + | $Tuple2(nil, rewardAmount) | |
427 | + | } | |
428 | + | ||
429 | + | ||
430 | + | ||
431 | + | @Callable(i) | |
432 | + | func claim (assetId,index) = { | |
433 | + | let callerAddress = i.caller | |
434 | + | let claimHistoryKey = keyClaimHistory(callerAddress, assetId, index) | |
435 | + | let claimHistory = getInteger(claimHistoryKey) | |
436 | + | let checks = [if ((claimHistory == unit)) | |
437 | + | then true | |
438 | + | else throwErr("already claimed")] | |
439 | + | if ((checks == checks)) | |
452 | 440 | then { | |
453 | - | let userAddress = Address(userAddressBytes) | |
454 | - | let currentPeriodOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyCurrentPeriod()), wrapErr("invalid period")) | |
455 | - | let periodLength = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPeriodLength()), wrapErr("invalid period length")) | |
456 | - | let currentStartHeight = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyStartHeight(currentPeriodOrFail)), wrapErr("invalid start height")) | |
457 | - | let currentPriceOrFail = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyPriceForPeriod(currentPeriodOrFail)), wrapErr("invalid price")) | |
458 | - | let nextBlockToProcess = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyNextBlockToProcess()), wrapErr("invalid next block to process")) | |
459 | - | let periodEndHeight = ((currentStartHeight + periodLength) - 1) | |
460 | - | let blocksProcessingBatchSizeMax = 40 | |
461 | - | let blocksProcessingBatchSize = if (if (if ((height >= nextBlockToProcess)) | |
462 | - | then if ((nextBlockToProcess >= currentStartHeight)) | |
463 | - | then true | |
464 | - | else (currentPeriodOrFail == 0) | |
465 | - | else false) | |
466 | - | then (periodEndHeight >= nextBlockToProcess) | |
467 | - | else false) | |
468 | - | then min([((periodEndHeight - nextBlockToProcess) + 1), blocksProcessingBatchSizeMax]) | |
469 | - | else throwErr(wrapErr("invalid target block")) | |
470 | - | let blockProcessingReward = valueOrErrorMessage(getInteger(factoryAddressOrFail, keyBlockProcessingReward()), wrapErr("invalid block processing reward")) | |
471 | - | let blockProcessingRewardByGenerator = (blockProcessingReward / blocksProcessingBatchSize) | |
472 | - | let blockProcessingRewardByGeneratorRemainder = (blockProcessingReward - (blockProcessingRewardByGenerator * blocksProcessingBatchSize)) | |
473 | - | func map (acc,inc) = if ((inc >= blocksProcessingBatchSize)) | |
474 | - | then acc | |
475 | - | else { | |
476 | - | let targetBlockHeight = (nextBlockToProcess + inc) | |
477 | - | let targetBlockInfo = valueOrErrorMessage(blockInfoByHeight(targetBlockHeight), wrapErr("invalid block info")) | |
478 | - | let treasuryRewardOrFail = valueOrErrorMessage(rewardForOption(targetBlockInfo.rewards, treasuryAddressOrFail), wrapErr(("invalid treasury reward for height " + toString(targetBlockHeight)))) | |
479 | - | let generator = targetBlockInfo.generator | |
480 | - | let available = valueOrElse(getInteger(factoryAddressOrFail, keyAvailable(generator)), 0) | |
481 | - | let callerReward = if ((inc == (blocksProcessingBatchSize - 1))) | |
482 | - | then (blockProcessingRewardByGenerator + blockProcessingRewardByGeneratorRemainder) | |
483 | - | else blockProcessingRewardByGenerator | |
484 | - | let lpAssetAmount = if ((currentPriceOrFail > 0)) | |
485 | - | then fraction((treasuryRewardOrFail - callerReward), SCALE8, currentPriceOrFail) | |
486 | - | else 0 | |
487 | - | let factoryActionsSingle = [invoke(factoryAddressOrFail, "stringEntry", [keyBlockProcessed(targetBlockHeight), makeString([toBase58String(i.transactionId), toString(currentPeriodOrFail), toString(generator), toBase58String(userAddressBytes), toString(treasuryRewardOrFail), toString(callerReward), toString(lpAssetAmount)], SEP)], nil), invoke(factoryAddressOrFail, "integerEntry", [keyAvailable(generator), (available + lpAssetAmount)], nil)] | |
488 | - | if ((factoryActionsSingle == factoryActionsSingle)) | |
489 | - | then (acc + lpAssetAmount) | |
490 | - | else throw("Strict value is not equal to itself.") | |
441 | + | let rewardAmount = if ((calculateReward(callerAddress, assetId, index) > 0)) | |
442 | + | then calculateReward(callerAddress, assetId, index) | |
443 | + | else throwErr("nothing to claim") | |
444 | + | let votingRewardAssetIdStr = getString(keyVotingRewardAssetId(assetId, index)) | |
445 | + | let rewardAction = if (isDefined(votingRewardAssetIdStr)) | |
446 | + | then { | |
447 | + | let votingRewardAssetId = fromBase58String(value(votingRewardAssetIdStr)) | |
448 | + | [ScriptTransfer(callerAddress, rewardAmount, votingRewardAssetId), IntegerEntry(claimHistoryKey, rewardAmount), DeleteEntry(keyVotingReward(callerAddress, assetId, index))] | |
491 | 449 | } | |
492 | - | ||
493 | - | let list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39] | |
494 | - | let lpAssetAmountTotal = { | |
495 | - | let $l = list | |
496 | - | let $s = size($l) | |
497 | - | let $acc0 = 0 | |
498 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
499 | - | then $a | |
500 | - | else map($a, $l[$i]) | |
501 | - | ||
502 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
503 | - | then $a | |
504 | - | else throw("List size exceeds 40") | |
505 | - | ||
506 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40) | |
507 | - | } | |
508 | - | if ((lpAssetAmountTotal == lpAssetAmountTotal)) | |
509 | - | then { | |
510 | - | let actions = [invoke(factoryAddressOrFail, "transferWaves", [userAddressBytes, blockProcessingReward], nil), invoke(factoryAddressOrFail, "reissue", [lpAssetAmountTotal], nil), invoke(factoryAddressOrFail, "integerEntry", [keyNextBlockToProcess(), (nextBlockToProcess + blocksProcessingBatchSize)], nil)] | |
511 | - | if ((actions == actions)) | |
512 | - | then $Tuple2(nil, unit) | |
513 | - | else throw("Strict value is not equal to itself.") | |
514 | - | } | |
515 | - | else throw("Strict value is not equal to itself.") | |
450 | + | else throwErr("nothing to claim") | |
451 | + | rewardAction | |
516 | 452 | } | |
517 | 453 | else throw("Strict value is not equal to itself.") | |
518 | 454 | } | |
519 | 455 | ||
520 | 456 | ||
521 | 457 | @Verifier(tx) | |
522 | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
458 | + | func verify () = { | |
459 | + | let targetPublicKey = match managerPublicKeyOrUnit() { | |
460 | + | case pk: ByteVector => | |
461 | + | pk | |
462 | + | case _: Unit => | |
463 | + | tx.senderPublicKey | |
464 | + | case _ => | |
465 | + | throw("Match error") | |
466 | + | } | |
467 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
468 | + | } | |
523 | 469 |
github/deemru/w8io/026f985 89.18 ms ◑