tx · BuDxLbzfHhTAMMSWGSuqi2m4qws1eKhjxMyTAgAQGASA 3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy: -0.02600000 Waves 2023.08.10 15:20 [2704480] smart account 3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy > SELF 0.00000000 Waves
{ "type": 13, "id": "BuDxLbzfHhTAMMSWGSuqi2m4qws1eKhjxMyTAgAQGASA", "fee": 2600000, "feeAssetId": null, "timestamp": 1691670082535, "version": 2, "chainId": 84, "sender": "3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy", "senderPublicKey": "9W33iCCNfmFxUbiC6XZcH5x7f6xfwC7Jb3BoExT5q2PV", "proofs": [ "2Ahq8ozGhJgeGn5VhYSEkyhTkbKfqabY7KaHqiN94CwsAQ5hEXjb1Q7xBrKLqBJ3NVNqkMTdVKyLvurHinF9z2Xu" ], "script": "base64:BgKULggCEggKBggIAQEBCBIFCgMBCAISAwoBARIECgIICBIECgIICBIECgIIARIDCgEIEgMKAQgSBAoCCAESAwoBCBIAEgASBQoDCAgEEgMKAQgSAwoBCBIECgIICBIECgIICCIDU0VQIgZTQ0FMRTgiBU1VTFQ4Ig5QT09MV0VJR0hUTVVMVCIQY29udHJhY3RGaWxlbmFtZSIHU0NBTEUxOCIGTVVMVDE4IghNVUxUMThCSSILYmxvY2tzSW5EYXkiDWJsb2Nrc0luTW9udGgiB3dyYXBFcnIiA21zZyIIdGhyb3dFcnIiD2dldFN0cmluZ09yRmFpbCIHYWRkcmVzcyIDa2V5IgxnZXRJbnRPclplcm8iD2dldEludE9yRGVmYXVsdCIKZGVmYXVsdFZhbCIMZ2V0SW50T3JGYWlsIgNhYnMiA3ZhbCIOZW5zdXJlUG9zaXRpdmUiAXYiAW0iG2tleVJlZmVycmFsc0NvbnRyYWN0QWRkcmVzcyIecmVmZXJyYWxzQ29udHJhY3RBZGRyZXNzT3JGYWlsIhZrZXlSZWZlcnJhbFByb2dyYW1OYW1lIhpyZWZlcnJ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Yk8JAJQKAgUDbmlsCQECZGoCBQJiRwUCYk8BAmZhAQJmYgAEAmZjBAJhSgkBAmFMAAMJAAECBQJhSgIKQnl0ZVZlY3RvcgQCYVEFAmFKBQJhUQMJAAECBQJhSgIEVW5pdAgFAmZhD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJmYQlib2R5Qnl0ZXMJAJEDAggFAmZhBnByb29mcwAABQJmYx6ZiY8=", "height": 2704480, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 993Xf1ymMd9qgpdSFig7GKr4bsBBimv4CVd2yJHaCmc1 Next: 5mLpGSjrJ9FY9CnVPpc53f3Rku6vtNeMtpswhY5LcNi6 Diff:
Old | New | Differences | |
---|---|---|---|
814 | 814 | let gwxBurned = fraction((t * blocksInPeriod), gWxAmountStart, maxLockDuration) | |
815 | 815 | let gwxRemaining = ensurePositive((gwxAmount - gwxBurned), "gwxRemaining") | |
816 | 816 | let lockedGwxAmount = getLockedGwxAmount(userAddress) | |
817 | - | if ((lockedGwxAmount > gwxRemaining)) | |
818 | - | then throwErr(("locked gwx amount: " + toString(lockedGwxAmount))) | |
819 | - | else if ((0 >= userAmount)) | |
820 | - | then throwErr("nothing to unlock") | |
821 | - | else { | |
822 | - | let gwxAmountTotal = getGwxAmountTotal() | |
823 | - | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
824 | - | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
825 | - | if ((gwxRewardInv == gwxRewardInv)) | |
826 | - | then ((((LockParamsEntry(userAddress, txId, userAmount, lockStart, lockDuration, gwxRemaining, (wxClaimed + amount)) ++ StatsEntry(-(amount), 0, 0, 0)) :+ HistoryEntry("unlock", userAddressStr, amount, lockStart, lockDuration, gwxBurned, i)) :+ ScriptTransfer(userAddress, amount, assetId)) ++ [IntegerEntry(keyGwxTotal(), ensurePositive((gwxAmountTotal - gwxBurned), "gwxTotal")), IntegerEntry(keyUserGwxAmountTotal(userAddress), ensurePositive((userGwxAmountTotal - gwxBurned), "userGwxAmountTotal"))]) | |
827 | - | else throw("Strict value is not equal to itself.") | |
828 | - | } | |
817 | + | if ((0 >= userAmount)) | |
818 | + | then throwErr("nothing to unlock") | |
819 | + | else { | |
820 | + | let gwxAmountTotal = getGwxAmountTotal() | |
821 | + | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
822 | + | let userGwxAmountTotalNew = ensurePositive((userGwxAmountTotal - gwxBurned), "userGwxAmountTotalNew") | |
823 | + | if ((lockedGwxAmount > userGwxAmountTotalNew)) | |
824 | + | then throwErr(("locked gwx amount: " + toString(lockedGwxAmount))) | |
825 | + | else { | |
826 | + | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
827 | + | if ((gwxRewardInv == gwxRewardInv)) | |
828 | + | then ((((LockParamsEntry(userAddress, txId, userAmount, lockStart, lockDuration, gwxRemaining, (wxClaimed + amount)) ++ StatsEntry(-(amount), 0, 0, 0)) :+ HistoryEntry("unlock", userAddressStr, amount, lockStart, lockDuration, gwxBurned, i)) :+ ScriptTransfer(userAddress, amount, assetId)) ++ [IntegerEntry(keyGwxTotal(), ensurePositive((gwxAmountTotal - gwxBurned), "gwxTotal")), IntegerEntry(keyUserGwxAmountTotal(userAddress), userGwxAmountTotalNew)]) | |
829 | + | else throw("Strict value is not equal to itself.") | |
830 | + | } | |
831 | + | } | |
829 | 832 | } | |
830 | 833 | } | |
831 | 834 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let SCALE8 = 8 | |
7 | 7 | ||
8 | 8 | let MULT8 = 100000000 | |
9 | 9 | ||
10 | 10 | let POOLWEIGHTMULT = MULT8 | |
11 | 11 | ||
12 | 12 | let contractFilename = "boosting.ride" | |
13 | 13 | ||
14 | 14 | let SCALE18 = 18 | |
15 | 15 | ||
16 | 16 | let MULT18 = 1000000000000000000 | |
17 | 17 | ||
18 | 18 | let MULT18BI = toBigInt(MULT18) | |
19 | 19 | ||
20 | 20 | let blocksInDay = 1440 | |
21 | 21 | ||
22 | 22 | let blocksInMonth = 43800 | |
23 | 23 | ||
24 | 24 | func wrapErr (msg) = makeString([contractFilename, ": ", msg], "") | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func throwErr (msg) = throw(wrapErr(msg)) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func abs (val) = if ((0 > val)) | |
43 | 43 | then -(val) | |
44 | 44 | else val | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func ensurePositive (v,m) = if ((v >= 0)) | |
48 | 48 | then v | |
49 | 49 | else throwErr((valueOrElse(m, "value") + " should be positive")) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP) | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | let referralsContractAddressOrFail = addressFromStringValue(getStringOrFail(this, keyReferralsContractAddress())) | |
56 | 56 | ||
57 | 57 | let keyReferralProgramName = makeString(["%s%s", "referral", "programName"], SEP) | |
58 | 58 | ||
59 | 59 | let referralProgramNameDefault = "wxlock" | |
60 | 60 | ||
61 | 61 | let referralProgramName = valueOrElse(getString(this, keyReferralProgramName), referralProgramNameDefault) | |
62 | 62 | ||
63 | 63 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | let IdxFactoryCfgStakingDapp = 1 | |
67 | 67 | ||
68 | 68 | let IdxFactoryCfgBoostingDapp = 2 | |
69 | 69 | ||
70 | 70 | let IdxFactoryCfgIdoDapp = 3 | |
71 | 71 | ||
72 | 72 | let IdxFactoryCfgTeamDapp = 4 | |
73 | 73 | ||
74 | 74 | let IdxFactoryCfgEmissionDapp = 5 | |
75 | 75 | ||
76 | 76 | let IdxFactoryCfgRestDapp = 6 | |
77 | 77 | ||
78 | 78 | let IdxFactoryCfgSlippageDapp = 7 | |
79 | 79 | ||
80 | 80 | let IdxFactoryCfgDaoDapp = 8 | |
81 | 81 | ||
82 | 82 | let IdxFactoryCfgMarketingDapp = 9 | |
83 | 83 | ||
84 | 84 | let IdxFactoryCfgGwxRewardDapp = 10 | |
85 | 85 | ||
86 | 86 | let IdxFactoryCfgBirdsDapp = 11 | |
87 | 87 | ||
88 | 88 | func keyFactoryCfg () = "%s__factoryConfig" | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func keyFactoryPoolWeightHistory (poolAddress,num) = ((("%s%s__poolWeight__" + poolAddress) + "__") + toString(num)) | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(this, keyFactoryAddress())) | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | func readFactoryCfgOrFail (factory) = split(getStringOrFail(factory, keyFactoryCfg()), SEP) | |
104 | 104 | ||
105 | 105 | ||
106 | 106 | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
110 | 110 | ||
111 | 111 | ||
112 | 112 | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
113 | 113 | ||
114 | 114 | ||
115 | 115 | func getGwxRewardAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgGwxRewardDapp]) | |
116 | 116 | ||
117 | 117 | ||
118 | 118 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
131 | 131 | ||
132 | 132 | ||
133 | 133 | func keyBoostingV2LastUpdateHeight () = "%s%s__boostingV2__startBlock" | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func keyBoostingV2Integral () = "%s%s__boostingV2__integral" | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
143 | 143 | ||
144 | 144 | ||
145 | 145 | func keyNextPergetIntOrDefault () = "%s__nextPeriod" | |
146 | 146 | ||
147 | 147 | ||
148 | 148 | func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight" | |
149 | 149 | ||
150 | 150 | ||
151 | 151 | let IdxCfgAssetId = 1 | |
152 | 152 | ||
153 | 153 | let IdxCfgMinLockAmount = 2 | |
154 | 154 | ||
155 | 155 | let IdxCfgMinLockDuration = 3 | |
156 | 156 | ||
157 | 157 | let IdxCfgMaxLockDuration = 4 | |
158 | 158 | ||
159 | 159 | let IdxCfgMathContract = 5 | |
160 | 160 | ||
161 | 161 | let IdxCfgBlocksInPeriod = 6 | |
162 | 162 | ||
163 | 163 | func keyConfig () = "%s__config" | |
164 | 164 | ||
165 | 165 | ||
166 | 166 | func readConfigArrayOrFail () = split(getStringOrFail(this, keyConfig()), SEP) | |
167 | 167 | ||
168 | 168 | ||
169 | 169 | let cfgArray = readConfigArrayOrFail() | |
170 | 170 | ||
171 | 171 | let assetId = fromBase58String(cfgArray[IdxCfgAssetId]) | |
172 | 172 | ||
173 | 173 | let minLockAmount = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMinLockAmount]), wrapErr("invalid min lock amount")) | |
174 | 174 | ||
175 | 175 | let minLockDuration = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMinLockDuration]), wrapErr("invalid min lock duration")) | |
176 | 176 | ||
177 | 177 | let maxLockDuration = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMaxLockDuration]), wrapErr("invalid max lock duration")) | |
178 | 178 | ||
179 | 179 | let mathContract = valueOrErrorMessage(addressFromString(cfgArray[IdxCfgMathContract]), wrapErr("invalid math contract address")) | |
180 | 180 | ||
181 | 181 | let blocksInPeriod = valueOrErrorMessage(parseInt(cfgArray[IdxCfgBlocksInPeriod]), wrapErr("invalid blocks in period")) | |
182 | 182 | ||
183 | 183 | func formatConfigS (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = makeString(["%s%d%d%d%s", assetId, minLockAmount, minLockDuration, maxLockDuration, mathContract], SEP) | |
184 | 184 | ||
185 | 185 | ||
186 | 186 | func formatConfig (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = formatConfigS(assetId, toString(minLockAmount), toString(minLockDuration), toString(maxLockDuration), mathContract) | |
187 | 187 | ||
188 | 188 | ||
189 | 189 | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
190 | 190 | case s: String => | |
191 | 191 | addressFromStringValue(s) | |
192 | 192 | case _ => | |
193 | 193 | this | |
194 | 194 | } | |
195 | 195 | ||
196 | 196 | ||
197 | 197 | func managerPublicKeyOrUnit () = { | |
198 | 198 | let managerVaultAddress = getManagerVaultAddressOrThis() | |
199 | 199 | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
200 | 200 | case s: String => | |
201 | 201 | fromBase58String(s) | |
202 | 202 | case _: Unit => | |
203 | 203 | unit | |
204 | 204 | case _ => | |
205 | 205 | throw("Match error") | |
206 | 206 | } | |
207 | 207 | } | |
208 | 208 | ||
209 | 209 | ||
210 | 210 | func mustManager (i) = { | |
211 | 211 | let pd = throwErr("Permission denied") | |
212 | 212 | match managerPublicKeyOrUnit() { | |
213 | 213 | case pk: ByteVector => | |
214 | 214 | if ((i.callerPublicKey == pk)) | |
215 | 215 | then true | |
216 | 216 | else pd | |
217 | 217 | case _: Unit => | |
218 | 218 | if ((i.caller == this)) | |
219 | 219 | then true | |
220 | 220 | else pd | |
221 | 221 | case _ => | |
222 | 222 | throw("Match error") | |
223 | 223 | } | |
224 | 224 | } | |
225 | 225 | ||
226 | 226 | ||
227 | 227 | let IdxLockAmount = 1 | |
228 | 228 | ||
229 | 229 | let IdxLockStart = 2 | |
230 | 230 | ||
231 | 231 | let IdxLockDuration = 3 | |
232 | 232 | ||
233 | 233 | let IdxLockLastUpdateTimestamp = 4 | |
234 | 234 | ||
235 | 235 | let IdxLockGwxAmount = 5 | |
236 | 236 | ||
237 | 237 | let IdxLockWxClaimed = 6 | |
238 | 238 | ||
239 | 239 | func keyLockParamsRecord (userAddress,txId) = makeString(["%s%s%s__lock", toString(userAddress), match txId { | |
240 | 240 | case b: ByteVector => | |
241 | 241 | toBase58String(b) | |
242 | 242 | case _: Unit => | |
243 | 243 | "legacy" | |
244 | 244 | case _ => | |
245 | 245 | throw("Match error") | |
246 | 246 | }], SEP) | |
247 | 247 | ||
248 | 248 | ||
249 | 249 | func readLockParamsRecordOrFail (userAddress,txId) = split(getStringOrFail(this, keyLockParamsRecord(userAddress, txId)), SEP) | |
250 | 250 | ||
251 | 251 | ||
252 | 252 | func keyUserGwxAmountTotal (userAddress) = makeString(["%s%s__gwxAmountTotal", toString(userAddress)], SEP) | |
253 | 253 | ||
254 | 254 | ||
255 | 255 | func formatLockParamsRecord (amount,start,duration,gwxAmount,wxClaimed) = makeString(["%d%d%d%d%d%d%d", toString(amount), toString(start), toString(duration), toString(lastBlock.timestamp), toString(gwxAmount), toString(wxClaimed)], SEP) | |
256 | 256 | ||
257 | 257 | ||
258 | 258 | func keyNextUserNum () = "%s__nextUserNum" | |
259 | 259 | ||
260 | 260 | ||
261 | 261 | func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", userAddress], SEP) | |
262 | 262 | ||
263 | 263 | ||
264 | 264 | func keyNum2UserMapping (num) = makeString(["%s%s%s__mapping__num2user", num], SEP) | |
265 | 265 | ||
266 | 266 | ||
267 | 267 | func keyLockParamTotalAmount () = "%s%s__stats__activeTotalLocked" | |
268 | 268 | ||
269 | 269 | ||
270 | 270 | func keyStatsLocksDurationSumInBlocks () = "%s%s__stats__locksDurationSumInBlocks" | |
271 | 271 | ||
272 | 272 | ||
273 | 273 | func keyStatsLocksCount () = "%s%s__stats__locksCount" | |
274 | 274 | ||
275 | 275 | ||
276 | 276 | func keyStatsUsersCount () = "%s%s__stats__activeUsersCount" | |
277 | 277 | ||
278 | 278 | ||
279 | 279 | func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastIntV2", toString(userNum)], SEP) | |
280 | 280 | ||
281 | 281 | ||
282 | 282 | func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__userBoostEmissionLastIntV2", toString(userNum), lpAssetId], SEP) | |
283 | 283 | ||
284 | 284 | ||
285 | 285 | func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", toString(userNum)], SEP) | |
286 | 286 | ||
287 | 287 | ||
288 | 288 | func keyTotalMaxBoostINTEGRAL () = "%s%s__maxBoostInt__total" | |
289 | 289 | ||
290 | 290 | ||
291 | 291 | func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", toString(userNum)], SEP) | |
292 | 292 | ||
293 | 293 | ||
294 | 294 | func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", toString(userNum)], SEP) | |
295 | 295 | ||
296 | 296 | ||
297 | 297 | func keyGwxTotal () = "%s%s__gwx__total" | |
298 | 298 | ||
299 | 299 | ||
300 | 300 | func keyVote (amountAssetId,priceAssetId,address,epoch) = makeString(["%s%s%s%s%d", "vote", amountAssetId, priceAssetId, toString(address), toString(epoch)], SEP) | |
301 | 301 | ||
302 | 302 | ||
303 | 303 | func keyStartHeightByEpoch (epoch) = makeString(["%s%d", "startHeight", toString(epoch)], SEP) | |
304 | 304 | ||
305 | 305 | ||
306 | 306 | func keyCurrentEpochUi () = makeString(["%s", "currentEpochUi"], SEP) | |
307 | 307 | ||
308 | 308 | ||
309 | 309 | func keyVotingResultStaked (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStaked", lpAssetIdStr, toString(epoch)], SEP) | |
310 | 310 | ||
311 | 311 | ||
312 | 312 | func keyVotingResultStakedIntegral (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegral", lpAssetIdStr, toString(epoch)], SEP) | |
313 | 313 | ||
314 | 314 | ||
315 | 315 | func keyVotingResultStakedLastUpdateHeight (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(epoch)], SEP) | |
316 | 316 | ||
317 | 317 | ||
318 | 318 | func keyVotingResultStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "votingResultStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
319 | 319 | ||
320 | 320 | ||
321 | 321 | func keyVoteStakedIntegral (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegral", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
322 | 322 | ||
323 | 323 | ||
324 | 324 | func keyVoteStakedLastUpdateHeight (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
325 | 325 | ||
326 | 326 | ||
327 | 327 | func keyVoteStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
328 | 328 | ||
329 | 329 | ||
330 | 330 | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s", "staked", userAddressStr, lpAssetIdStr], SEP) | |
331 | 331 | ||
332 | 332 | ||
333 | 333 | let factoryContract = readFactoryAddressOrFail() | |
334 | 334 | ||
335 | 335 | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
336 | 336 | ||
337 | 337 | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
338 | 338 | ||
339 | 339 | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
340 | 340 | ||
341 | 341 | let gwxRewardContract = getGwxRewardAddressOrFail(factoryCfg) | |
342 | 342 | ||
343 | 343 | let lpStakingPoolsContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(makeString(["%s", "lpStakingPoolsContract"], SEP)), wrapErr("lp_staking_pools contract address is undefined"))), wrapErr("invalid lp_staking_pools contract address")) | |
344 | 344 | ||
345 | 345 | let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], SEP) | |
346 | 346 | ||
347 | 347 | let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract)) | |
348 | 348 | ||
349 | 349 | let keyVotingEmissionRateContract = makeString(["%s", "votingEmissionRateContract"], SEP) | |
350 | 350 | ||
351 | 351 | let boostCoeff = { | |
352 | 352 | let @ = invoke(emissionContract, "getBoostCoeffREADONLY", nil, nil) | |
353 | 353 | if ($isInstanceOf(@, "Int")) | |
354 | 354 | then @ | |
355 | 355 | else throw(($getType(@) + " couldn't be cast to Int")) | |
356 | 356 | } | |
357 | 357 | ||
358 | 358 | func userNumberByAddressOrFail (userAddress) = match getString(this, keyUser2NumMapping(toString(userAddress))) { | |
359 | 359 | case s: String => | |
360 | 360 | valueOrErrorMessage(parseInt(s), wrapErr("invalid user number")) | |
361 | 361 | case _: Unit => | |
362 | 362 | throwErr("invalid user") | |
363 | 363 | case _ => | |
364 | 364 | throw("Match error") | |
365 | 365 | } | |
366 | 366 | ||
367 | 367 | ||
368 | 368 | func getGwxAmountTotal () = valueOrElse(getInteger(this, keyGwxTotal()), 0) | |
369 | 369 | ||
370 | 370 | ||
371 | 371 | func getLockedGwxAmount (userAddress) = { | |
372 | 372 | let functionName = "getLockedGwxAmount" | |
373 | 373 | let votingEmissionRateContract = valueOrErrorMessage( match getString(votingEmissionContract, keyVotingEmissionRateContract) { | |
374 | 374 | case _: Unit => | |
375 | 375 | unit | |
376 | 376 | case s: String => | |
377 | 377 | addressFromString(s) | |
378 | 378 | case _ => | |
379 | 379 | throw("Match error") | |
380 | 380 | }, wrapErr("invalid voting emission rate address")) | |
381 | 381 | let lockedVotingEmissionRate = { | |
382 | 382 | let @ = invoke(votingEmissionContract, functionName, [toString(userAddress)], nil) | |
383 | 383 | if ($isInstanceOf(@, "Int")) | |
384 | 384 | then @ | |
385 | 385 | else throw(($getType(@) + " couldn't be cast to Int")) | |
386 | 386 | } | |
387 | 387 | let lockedVotingEmission = { | |
388 | 388 | let @ = invoke(votingEmissionRateContract, functionName, [toString(userAddress)], nil) | |
389 | 389 | if ($isInstanceOf(@, "Int")) | |
390 | 390 | then @ | |
391 | 391 | else throw(($getType(@) + " couldn't be cast to Int")) | |
392 | 392 | } | |
393 | 393 | let locked = max([lockedVotingEmissionRate, lockedVotingEmission]) | |
394 | 394 | locked | |
395 | 395 | } | |
396 | 396 | ||
397 | 397 | ||
398 | 398 | func HistoryEntry (type,user,amount,lockStart,duration,gwxAmount,i) = { | |
399 | 399 | let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP) | |
400 | 400 | let historyDATA = makeString(["%d%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount), toString(lockStart), toString(duration), toString(gwxAmount)], SEP) | |
401 | 401 | StringEntry(historyKEY, historyDATA) | |
402 | 402 | } | |
403 | 403 | ||
404 | 404 | ||
405 | 405 | func StatsEntry (totalLockedInc,durationInc,lockCountInc,usersCountInc) = { | |
406 | 406 | let locksDurationSumInBlocksKEY = keyStatsLocksDurationSumInBlocks() | |
407 | 407 | let locksCountKEY = keyStatsLocksCount() | |
408 | 408 | let usersCountKEY = keyStatsUsersCount() | |
409 | 409 | let totalAmountKEY = keyLockParamTotalAmount() | |
410 | 410 | let locksDurationSumInBlocks = getIntOrZero(this, locksDurationSumInBlocksKEY) | |
411 | 411 | let locksCount = getIntOrZero(this, locksCountKEY) | |
412 | 412 | let usersCount = getIntOrZero(this, usersCountKEY) | |
413 | 413 | let totalAmount = getIntOrZero(this, totalAmountKEY) | |
414 | 414 | [IntegerEntry(locksDurationSumInBlocksKEY, (locksDurationSumInBlocks + durationInc)), IntegerEntry(locksCountKEY, (locksCount + lockCountInc)), IntegerEntry(usersCountKEY, (usersCount + usersCountInc)), IntegerEntry(totalAmountKEY, (totalAmount + totalLockedInc))] | |
415 | 415 | } | |
416 | 416 | ||
417 | 417 | ||
418 | 418 | func LockParamsEntry (userAddress,txId,amount,start,duration,gwxAmount,wxClaimed) = [StringEntry(keyLockParamsRecord(userAddress, txId), formatLockParamsRecord(amount, start, duration, gwxAmount, wxClaimed))] | |
419 | 419 | ||
420 | 420 | ||
421 | 421 | func extractOptionalPaymentAmountOrFail (i,expectedAssetId) = if ((size(i.payments) > 1)) | |
422 | 422 | then throwErr("only one payment is allowed") | |
423 | 423 | else if ((size(i.payments) == 0)) | |
424 | 424 | then 0 | |
425 | 425 | else { | |
426 | 426 | let pmt = i.payments[0] | |
427 | 427 | if ((value(pmt.assetId) != expectedAssetId)) | |
428 | 428 | then throwErr("invalid asset id in payment") | |
429 | 429 | else pmt.amount | |
430 | 430 | } | |
431 | 431 | ||
432 | 432 | ||
433 | 433 | func getUserGwxAmountTotal (userAddress) = valueOrElse(getInteger(this, keyUserGwxAmountTotal(userAddress)), 0) | |
434 | 434 | ||
435 | 435 | ||
436 | 436 | func getVotingEmissionEpochInfo () = { | |
437 | 437 | let $t01516415454 = { | |
438 | 438 | let currentEpochUi = value(getInteger(votingEmissionContract, keyCurrentEpochUi())) | |
439 | 439 | let lastFinalizedEpoch = (currentEpochUi - 1) | |
440 | 440 | if ((0 > lastFinalizedEpoch)) | |
441 | 441 | then throwErr("invalid epoch") | |
442 | 442 | else $Tuple2(currentEpochUi, lastFinalizedEpoch) | |
443 | 443 | } | |
444 | 444 | let currentEpochUi = $t01516415454._1 | |
445 | 445 | let lastFinalizedEpoch = $t01516415454._2 | |
446 | 446 | let currentEpochStartHeight = value(getInteger(votingEmissionContract, keyStartHeightByEpoch(currentEpochUi))) | |
447 | 447 | $Tuple2(lastFinalizedEpoch, currentEpochStartHeight) | |
448 | 448 | } | |
449 | 449 | ||
450 | 450 | ||
451 | 451 | func getPoolAssetsByLpAssetId (lpAssetIdStr) = { | |
452 | 452 | let idxAmountAssetId = 4 | |
453 | 453 | let idxPriceAssetId = 5 | |
454 | 454 | let poolCfg = { | |
455 | 455 | let @ = invoke(factoryContract, "getPoolConfigByLpAssetIdREADONLY", [lpAssetIdStr], nil) | |
456 | 456 | if ($isInstanceOf(@, "List[Any]")) | |
457 | 457 | then @ | |
458 | 458 | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
459 | 459 | } | |
460 | 460 | let amountAssetId = { | |
461 | 461 | let @ = poolCfg[idxAmountAssetId] | |
462 | 462 | if ($isInstanceOf(@, "String")) | |
463 | 463 | then @ | |
464 | 464 | else throw(($getType(@) + " couldn't be cast to String")) | |
465 | 465 | } | |
466 | 466 | let priceAssetId = { | |
467 | 467 | let @ = poolCfg[idxPriceAssetId] | |
468 | 468 | if ($isInstanceOf(@, "String")) | |
469 | 469 | then @ | |
470 | 470 | else throw(($getType(@) + " couldn't be cast to String")) | |
471 | 471 | } | |
472 | 472 | $Tuple2(amountAssetId, priceAssetId) | |
473 | 473 | } | |
474 | 474 | ||
475 | 475 | ||
476 | 476 | func getUserVoteFinalized (lpAssetIdStr,userAddressStr) = { | |
477 | 477 | let userAddress = addressFromStringValue(userAddressStr) | |
478 | 478 | let $t01614516225 = getVotingEmissionEpochInfo() | |
479 | 479 | let lastFinalizedEpoch = $t01614516225._1 | |
480 | 480 | let currentEpochStartHeight = $t01614516225._2 | |
481 | 481 | let $t01622816303 = getPoolAssetsByLpAssetId(lpAssetIdStr) | |
482 | 482 | let amountAssetId = $t01622816303._1 | |
483 | 483 | let priceAssetId = $t01622816303._2 | |
484 | 484 | let userVoteKey = keyVote(amountAssetId, priceAssetId, userAddress, lastFinalizedEpoch) | |
485 | 485 | let userVote = valueOrElse(getInteger(votingEmissionContract, userVoteKey), 0) | |
486 | 486 | userVote | |
487 | 487 | } | |
488 | 488 | ||
489 | 489 | ||
490 | 490 | func getUserVoteStaked (lpAssetIdStr,userAddressStr) = { | |
491 | 491 | let stakedByUser = valueOrElse(getInteger(stakingContract, keyStakedByUser(userAddressStr, lpAssetIdStr)), 0) | |
492 | 492 | let userVote = getUserVoteFinalized(lpAssetIdStr, userAddressStr) | |
493 | 493 | if ((stakedByUser == 0)) | |
494 | 494 | then 0 | |
495 | 495 | else userVote | |
496 | 496 | } | |
497 | 497 | ||
498 | 498 | ||
499 | 499 | func getVotingResultStaked (lpAssetIdStr) = { | |
500 | 500 | let $t01684716927 = getVotingEmissionEpochInfo() | |
501 | 501 | let lastFinalizedEpoch = $t01684716927._1 | |
502 | 502 | let currentEpochStartHeight = $t01684716927._2 | |
503 | 503 | let votingResultStakedStart = valueOrElse(getInteger(votingEmissionContract, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
504 | 504 | let votingResultStaked = valueOrElse(getInteger(this, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), votingResultStakedStart) | |
505 | 505 | votingResultStaked | |
506 | 506 | } | |
507 | 507 | ||
508 | 508 | ||
509 | 509 | func getVotingResultStakedIntegral (lpAssetIdStr) = { | |
510 | 510 | let $t01728917369 = getVotingEmissionEpochInfo() | |
511 | 511 | let lastFinalizedEpoch = $t01728917369._1 | |
512 | 512 | let currentEpochStartHeight = $t01728917369._2 | |
513 | 513 | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
514 | 514 | let votingResultStakedIntegralPrev = valueOrElse(getInteger(this, keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
515 | 515 | let votingResultStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch)), currentEpochStartHeight) | |
516 | 516 | let votingResultStakedIntegralDh = (height - votingResultStakedLastUpdateHeight) | |
517 | 517 | let votingResultStakedIntegral = ((votingResultStakedIntegralDh * votingResultStaked) + votingResultStakedIntegralPrev) | |
518 | 518 | votingResultStakedIntegral | |
519 | 519 | } | |
520 | 520 | ||
521 | 521 | ||
522 | 522 | func refreshVotingResultStakedIntegral (lpAssetIdStr,stakedVoteDelta) = { | |
523 | 523 | let $t01820618286 = getVotingEmissionEpochInfo() | |
524 | 524 | let lastFinalizedEpoch = $t01820618286._1 | |
525 | 525 | let currentEpochStartHeight = $t01820618286._2 | |
526 | 526 | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
527 | 527 | let votingResultStakedNew = (votingResultStaked + stakedVoteDelta) | |
528 | 528 | let votingResultStakedIntegral = getVotingResultStakedIntegral(lpAssetIdStr) | |
529 | 529 | [IntegerEntry(keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch), votingResultStakedNew), IntegerEntry(keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch), height), IntegerEntry(keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch), votingResultStakedIntegral)] | |
530 | 530 | } | |
531 | 531 | ||
532 | 532 | ||
533 | 533 | func getUserVoteStakedIntegral (lpAssetIdStr,userAddressStr) = { | |
534 | 534 | let $t01889718977 = getVotingEmissionEpochInfo() | |
535 | 535 | let lastFinalizedEpoch = $t01889718977._1 | |
536 | 536 | let currentEpochStartHeight = $t01889718977._2 | |
537 | 537 | let userAddress = addressFromStringValue(userAddressStr) | |
538 | 538 | let userVoteStaked = getUserVoteStaked(lpAssetIdStr, userAddressStr) | |
539 | 539 | let userVoteStakedIntegralPrev = valueOrElse(getInteger(this, keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch)), 0) | |
540 | 540 | let userVoteStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch)), currentEpochStartHeight) | |
541 | 541 | let userVoteStakedIntegralDh = (height - userVoteStakedLastUpdateHeight) | |
542 | 542 | let userVoteStakedIntegral = ((userVoteStakedIntegralDh * userVoteStaked) + userVoteStakedIntegralPrev) | |
543 | 543 | userVoteStakedIntegral | |
544 | 544 | } | |
545 | 545 | ||
546 | 546 | ||
547 | 547 | func refreshVoteStakedIntegral (lpAssetIdStr,userAddressStr,edge) = { | |
548 | 548 | let $t01976519845 = getVotingEmissionEpochInfo() | |
549 | 549 | let lastFinalizedEpoch = $t01976519845._1 | |
550 | 550 | let currentEpochStartHeight = $t01976519845._2 | |
551 | 551 | let userAddress = addressFromStringValue(userAddressStr) | |
552 | 552 | let userVoteFinalized = getUserVoteFinalized(lpAssetIdStr, userAddressStr) | |
553 | 553 | let actions = if ((userVoteFinalized == 0)) | |
554 | 554 | then nil | |
555 | 555 | else { | |
556 | 556 | let stakedVoteDelta = if (edge) | |
557 | 557 | then userVoteFinalized | |
558 | 558 | else -(userVoteFinalized) | |
559 | 559 | let votingResultActions = refreshVotingResultStakedIntegral(lpAssetIdStr, stakedVoteDelta) | |
560 | 560 | let userVoteStakedIntegral = getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr) | |
561 | 561 | let voteActions = [IntegerEntry(keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch), height), IntegerEntry(keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch), userVoteStakedIntegral)] | |
562 | 562 | (votingResultActions ++ voteActions) | |
563 | 563 | } | |
564 | 564 | actions | |
565 | 565 | } | |
566 | 566 | ||
567 | 567 | ||
568 | 568 | func getStakedVotesIntegralsDiff (lpAssetIdStr,userAddressStr) = { | |
569 | 569 | let $t02069920779 = getVotingEmissionEpochInfo() | |
570 | 570 | let lastFinalizedEpoch = $t02069920779._1 | |
571 | 571 | let currentEpochStartHeight = $t02069920779._2 | |
572 | 572 | let userAddress = addressFromStringValue(userAddressStr) | |
573 | 573 | let userVoteStakedIntegralLastKey = keyVoteStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
574 | 574 | let userVoteStakedIntegralLast = valueOrElse(getInteger(this, userVoteStakedIntegralLastKey), 0) | |
575 | 575 | let votingResultStakedIntegralLastKey = keyVotingResultStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
576 | 576 | let votingResultStakedIntegralLast = valueOrElse(getInteger(this, votingResultStakedIntegralLastKey), 0) | |
577 | 577 | let userVoteStakedIntegral = getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr) | |
578 | 578 | let votingResultStakedIntegral = getVotingResultStakedIntegral(lpAssetIdStr) | |
579 | 579 | let userVoteStakedIntegralDiff = (userVoteStakedIntegral - userVoteStakedIntegralLast) | |
580 | 580 | let votingResultStakedIntegralDiff = (votingResultStakedIntegral - votingResultStakedIntegralLast) | |
581 | 581 | $Tuple3([IntegerEntry(userVoteStakedIntegralLastKey, userVoteStakedIntegral), IntegerEntry(votingResultStakedIntegralLastKey, votingResultStakedIntegral)], userVoteStakedIntegralDiff, votingResultStakedIntegralDiff) | |
582 | 582 | } | |
583 | 583 | ||
584 | 584 | ||
585 | 585 | func refreshBoostEmissionIntegral () = { | |
586 | 586 | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
587 | 587 | let boostingV2LastUpdateHeightOption = getInteger(this, keyBoostingV2LastUpdateHeight()) | |
588 | 588 | let boostingV2IngergalOption = getInteger(this, keyBoostingV2Integral()) | |
589 | 589 | let emissionEnd = getIntOrFail(emissionContract, keyEmissionEndBlock()) | |
590 | 590 | let h = if ((height > emissionEnd)) | |
591 | 591 | then emissionEnd | |
592 | 592 | else height | |
593 | 593 | let dh = match boostingV2LastUpdateHeightOption { | |
594 | 594 | case lastUpdateHeight: Int => | |
595 | 595 | max([(h - lastUpdateHeight), 0]) | |
596 | 596 | case _: Unit => | |
597 | 597 | 0 | |
598 | 598 | case _ => | |
599 | 599 | throw("Match error") | |
600 | 600 | } | |
601 | 601 | let boostEmissionPerBlock = ((wxEmissionPerBlock * (boostCoeff - 1)) / boostCoeff) | |
602 | 602 | let boostEmissionIntegralPrev = valueOrElse(boostingV2IngergalOption, 0) | |
603 | 603 | let boostEmissionIntegral = ((boostEmissionPerBlock * dh) + boostEmissionIntegralPrev) | |
604 | 604 | $Tuple2([IntegerEntry(keyBoostingV2Integral(), boostEmissionIntegral), IntegerEntry(keyBoostingV2LastUpdateHeight(), height)], boostEmissionIntegral) | |
605 | 605 | } | |
606 | 606 | ||
607 | 607 | ||
608 | 608 | func internalClaimWxBoost (lpAssetIdStr,userAddressStr,readOnly) = { | |
609 | 609 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
610 | 610 | let userNum = userNumberByAddressOrFail(userAddress) | |
611 | 611 | if ((userNum == userNum)) | |
612 | 612 | then { | |
613 | 613 | let EMPTYSTR = "empty" | |
614 | 614 | let poolWeight = if ((lpAssetIdStr != EMPTYSTR)) | |
615 | 615 | then { | |
616 | 616 | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)), wrapErr(("unsupported lp asset " + lpAssetIdStr))) | |
617 | 617 | getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
618 | 618 | } | |
619 | 619 | else if (readOnly) | |
620 | 620 | then 0 | |
621 | 621 | else throwErr(("not readonly mode: unsupported lp asset " + lpAssetIdStr)) | |
622 | 622 | let userLpBoostEmissionLastIntegralKEY = keyUserLpBoostEmissionLastINTEGRAL(userNum, lpAssetIdStr) | |
623 | 623 | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum) | |
624 | 624 | let userBoostEmissionLastIntegral = valueOrElse(getInteger(this, userLpBoostEmissionLastIntegralKEY), getIntOrZero(this, userBoostEmissionLastIntegralKEY)) | |
625 | 625 | let boostEmissionIntegral = refreshBoostEmissionIntegral()._2 | |
626 | 626 | let userBoostEmissionIntegral = (boostEmissionIntegral - userBoostEmissionLastIntegral) | |
627 | 627 | if ((0 > userBoostEmissionIntegral)) | |
628 | 628 | then throwErr("wrong calculations") | |
629 | 629 | else { | |
630 | 630 | let $t02432124460 = getStakedVotesIntegralsDiff(lpAssetIdStr, userAddressStr) | |
631 | 631 | let stakedVotesIntegralsActions = $t02432124460._1 | |
632 | 632 | let userVoteIntegralDiff = $t02432124460._2 | |
633 | 633 | let totalVotesIntegralDiff = $t02432124460._3 | |
634 | 634 | let poolUserBoostEmissionIntegral = fraction(userBoostEmissionIntegral, poolWeight, POOLWEIGHTMULT) | |
635 | 635 | let userBoostAvaliableToClaimTotalNew = if ((totalVotesIntegralDiff == 0)) | |
636 | 636 | then 0 | |
637 | 637 | else fraction(poolUserBoostEmissionIntegral, userVoteIntegralDiff, totalVotesIntegralDiff) | |
638 | 638 | let dataState = ([IntegerEntry(userLpBoostEmissionLastIntegralKEY, boostEmissionIntegral)] ++ stakedVotesIntegralsActions) | |
639 | 639 | let debug = makeString([toString(userBoostEmissionLastIntegral), toString(userBoostEmissionIntegral), toString(poolWeight), toString(userVoteIntegralDiff), toString(totalVotesIntegralDiff)], ":") | |
640 | 640 | $Tuple3(userBoostAvaliableToClaimTotalNew, dataState, debug) | |
641 | 641 | } | |
642 | 642 | } | |
643 | 643 | else throw("Strict value is not equal to itself.") | |
644 | 644 | } | |
645 | 645 | ||
646 | 646 | ||
647 | 647 | func lockActions (i,durationMonths) = { | |
648 | 648 | let durationMonthsAllowed = [1, 3, 6, 12, 24, 48] | |
649 | 649 | if (!(containsElement(durationMonthsAllowed, durationMonths))) | |
650 | 650 | then throwErr("invalid duration") | |
651 | 651 | else { | |
652 | 652 | let duration = (durationMonths * blocksInMonth) | |
653 | 653 | let assetIdStr = toBase58String(assetId) | |
654 | 654 | if ((size(i.payments) != 1)) | |
655 | 655 | then throwErr("invalid payment - exact one payment must be attached") | |
656 | 656 | else { | |
657 | 657 | let pmt = i.payments[0] | |
658 | 658 | let pmtAmount = pmt.amount | |
659 | 659 | if ((assetId != value(pmt.assetId))) | |
660 | 660 | then throwErr((("invalid asset is in payment - " + assetIdStr) + " is expected")) | |
661 | 661 | else { | |
662 | 662 | let nextUserNumKEY = keyNextUserNum() | |
663 | 663 | let userAddress = i.caller | |
664 | 664 | let userAddressStr = toString(userAddress) | |
665 | 665 | let userIsExisting = isDefined(getString(keyUser2NumMapping(userAddressStr))) | |
666 | 666 | let userNumStr = if (userIsExisting) | |
667 | 667 | then value(getString(keyUser2NumMapping(userAddressStr))) | |
668 | 668 | else toString(getIntOrFail(this, nextUserNumKEY)) | |
669 | 669 | let userNum = parseIntValue(userNumStr) | |
670 | 670 | let lockStart = height | |
671 | 671 | if (if ((minLockAmount > pmtAmount)) | |
672 | 672 | then (userAddress != lpStakingPoolsContract) | |
673 | 673 | else false) | |
674 | 674 | then throwErr(("amount is less then minLockAmount=" + toString(minLockAmount))) | |
675 | 675 | else if ((minLockDuration > duration)) | |
676 | 676 | then throwErr(("passed duration is less then minLockDuration=" + toString(minLockDuration))) | |
677 | 677 | else if ((duration > maxLockDuration)) | |
678 | 678 | then throwErr(("passed duration is greater then maxLockDuration=" + toString(maxLockDuration))) | |
679 | 679 | else { | |
680 | 680 | let coeffX8 = fraction(duration, MULT8, maxLockDuration) | |
681 | 681 | let gWxAmountStart = fraction(pmtAmount, coeffX8, MULT8) | |
682 | 682 | let gwxAmountTotal = getGwxAmountTotal() | |
683 | 683 | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum) | |
684 | 684 | let boostEmissionIntegral = refreshBoostEmissionIntegral()._2 | |
685 | 685 | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
686 | 686 | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
687 | 687 | if ((gwxRewardInv == gwxRewardInv)) | |
688 | 688 | then { | |
689 | 689 | let arr = if (userIsExisting) | |
690 | 690 | then nil | |
691 | 691 | else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)] | |
692 | 692 | $Tuple2(((((arr ++ LockParamsEntry(userAddress, i.transactionId, pmtAmount, lockStart, duration, gWxAmountStart, 0)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting) | |
693 | 693 | then 0 | |
694 | 694 | else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, gWxAmountStart, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyGwxTotal(), (gwxAmountTotal + gWxAmountStart)), IntegerEntry(keyUserGwxAmountTotal(userAddress), (userGwxAmountTotal + gWxAmountStart))]), gWxAmountStart) | |
695 | 695 | } | |
696 | 696 | else throw("Strict value is not equal to itself.") | |
697 | 697 | } | |
698 | 698 | } | |
699 | 699 | } | |
700 | 700 | } | |
701 | 701 | } | |
702 | 702 | ||
703 | 703 | ||
704 | 704 | func getWxWithdrawable (userAddress,txIdOption) = { | |
705 | 705 | let userRecordArray = readLockParamsRecordOrFail(userAddress, txIdOption) | |
706 | 706 | let userAmount = parseIntValue(userRecordArray[IdxLockAmount]) | |
707 | 707 | let lockStart = parseIntValue(userRecordArray[IdxLockStart]) | |
708 | 708 | let lockDuration = parseIntValue(userRecordArray[IdxLockDuration]) | |
709 | 709 | let lockEnd = (lockStart + lockDuration) | |
710 | 710 | let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed]) | |
711 | 711 | let gwxAmount = parseIntValue(userRecordArray[IdxLockGwxAmount]) | |
712 | 712 | let t = ((height - lockStart) / blocksInPeriod) | |
713 | 713 | let exponent = fraction(toBigInt(t), (toBigInt((8 * blocksInPeriod)) * MULT18BI), toBigInt(lockDuration)) | |
714 | 714 | let wxWithdrawable = if ((height > lockEnd)) | |
715 | 715 | then userAmount | |
716 | 716 | else (toInt(fraction(toBigInt(userAmount), (MULT18BI - pow(toBigInt(5), 1, exponent, SCALE18, SCALE18, DOWN)), MULT18BI)) - wxClaimed) | |
717 | 717 | wxWithdrawable | |
718 | 718 | } | |
719 | 719 | ||
720 | 720 | ||
721 | 721 | @Callable(i) | |
722 | 722 | func constructor (factoryAddressStr,lockAssetIdStr,minLockAmount,minDuration,maxDuration,mathContract) = { | |
723 | 723 | let checkCaller = mustManager(i) | |
724 | 724 | if ((checkCaller == checkCaller)) | |
725 | 725 | then ([IntegerEntry(keyNextUserNum(), 0), StringEntry(keyConfig(), formatConfig(lockAssetIdStr, minLockAmount, minDuration, maxDuration, mathContract)), StringEntry(keyFactoryAddress(), factoryAddressStr)] ++ StatsEntry(0, 0, 0, 0)) | |
726 | 726 | else throw("Strict value is not equal to itself.") | |
727 | 727 | } | |
728 | 728 | ||
729 | 729 | ||
730 | 730 | ||
731 | 731 | @Callable(i) | |
732 | 732 | func lockRef (duration,referrerAddress,signature) = { | |
733 | 733 | let $t02942729492 = lockActions(i, duration) | |
734 | 734 | let lockActionsResult = $t02942729492._1 | |
735 | 735 | let gWxAmountStart = $t02942729492._2 | |
736 | 736 | let referralAddress = toString(i.caller) | |
737 | 737 | let refInv = if (if ((referrerAddress == "")) | |
738 | 738 | then true | |
739 | 739 | else (signature == base58'')) | |
740 | 740 | then unit | |
741 | 741 | else invoke(referralsContractAddressOrFail, "createPair", [referralProgramName, referrerAddress, referralAddress, signature], nil) | |
742 | 742 | if ((refInv == refInv)) | |
743 | 743 | then { | |
744 | 744 | let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil) | |
745 | 745 | if ((updateRefActivity == updateRefActivity)) | |
746 | 746 | then $Tuple2(lockActionsResult, unit) | |
747 | 747 | else throw("Strict value is not equal to itself.") | |
748 | 748 | } | |
749 | 749 | else throw("Strict value is not equal to itself.") | |
750 | 750 | } | |
751 | 751 | ||
752 | 752 | ||
753 | 753 | ||
754 | 754 | @Callable(i) | |
755 | 755 | func lock (duration) = { | |
756 | 756 | let $t02995030015 = lockActions(i, duration) | |
757 | 757 | let lockActionsResult = $t02995030015._1 | |
758 | 758 | let gWxAmountStart = $t02995030015._2 | |
759 | 759 | let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil) | |
760 | 760 | if ((updateRefActivity == updateRefActivity)) | |
761 | 761 | then $Tuple2(lockActionsResult, unit) | |
762 | 762 | else throw("Strict value is not equal to itself.") | |
763 | 763 | } | |
764 | 764 | ||
765 | 765 | ||
766 | 766 | ||
767 | 767 | @Callable(i) | |
768 | 768 | func claimWxBoost (lpAssetIdStr,userAddressStr) = if ((stakingContract != i.caller)) | |
769 | 769 | then throwErr("permissions denied") | |
770 | 770 | else { | |
771 | 771 | let $t03032530427 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, false) | |
772 | 772 | let userBoostAvailable = $t03032530427._1 | |
773 | 773 | let dataState = $t03032530427._2 | |
774 | 774 | let debug = $t03032530427._3 | |
775 | 775 | $Tuple2(dataState, [userBoostAvailable]) | |
776 | 776 | } | |
777 | 777 | ||
778 | 778 | ||
779 | 779 | ||
780 | 780 | @Callable(i) | |
781 | 781 | func claimWxBoostREADONLY (lpAssetIdStr,userAddressStr) = { | |
782 | 782 | let $t03055930660 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, true) | |
783 | 783 | let userBoostAvailable = $t03055930660._1 | |
784 | 784 | let dataState = $t03055930660._2 | |
785 | 785 | let debug = $t03055930660._3 | |
786 | 786 | $Tuple2(nil, [userBoostAvailable, debug]) | |
787 | 787 | } | |
788 | 788 | ||
789 | 789 | ||
790 | 790 | ||
791 | 791 | @Callable(i) | |
792 | 792 | func unlock (txIdStr,amount) = { | |
793 | 793 | let userAddress = i.caller | |
794 | 794 | let userAddressStr = toString(userAddress) | |
795 | 795 | let txId = fromBase58String(txIdStr) | |
796 | 796 | let userRecordArray = readLockParamsRecordOrFail(userAddress, if ((txIdStr == "")) | |
797 | 797 | then unit | |
798 | 798 | else txId) | |
799 | 799 | let userAmount = parseIntValue(userRecordArray[IdxLockAmount]) | |
800 | 800 | let lockStart = parseIntValue(userRecordArray[IdxLockStart]) | |
801 | 801 | let lockDuration = parseIntValue(userRecordArray[IdxLockDuration]) | |
802 | 802 | let lockEnd = (lockStart + lockDuration) | |
803 | 803 | let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed]) | |
804 | 804 | let gwxAmount = parseIntValue(userRecordArray[IdxLockGwxAmount]) | |
805 | 805 | let t = ((height - lockStart) / blocksInPeriod) | |
806 | 806 | let wxWithdrawable = getWxWithdrawable(userAddress, if ((txIdStr == "")) | |
807 | 807 | then unit | |
808 | 808 | else txId) | |
809 | 809 | if ((amount > wxWithdrawable)) | |
810 | 810 | then throwErr(("maximum amount to unlock: " + toString(wxWithdrawable))) | |
811 | 811 | else { | |
812 | 812 | let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration) | |
813 | 813 | let gWxAmountStart = fraction(userAmount, coeffX8, MULT8) | |
814 | 814 | let gwxBurned = fraction((t * blocksInPeriod), gWxAmountStart, maxLockDuration) | |
815 | 815 | let gwxRemaining = ensurePositive((gwxAmount - gwxBurned), "gwxRemaining") | |
816 | 816 | let lockedGwxAmount = getLockedGwxAmount(userAddress) | |
817 | - | if ((lockedGwxAmount > gwxRemaining)) | |
818 | - | then throwErr(("locked gwx amount: " + toString(lockedGwxAmount))) | |
819 | - | else if ((0 >= userAmount)) | |
820 | - | then throwErr("nothing to unlock") | |
821 | - | else { | |
822 | - | let gwxAmountTotal = getGwxAmountTotal() | |
823 | - | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
824 | - | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
825 | - | if ((gwxRewardInv == gwxRewardInv)) | |
826 | - | then ((((LockParamsEntry(userAddress, txId, userAmount, lockStart, lockDuration, gwxRemaining, (wxClaimed + amount)) ++ StatsEntry(-(amount), 0, 0, 0)) :+ HistoryEntry("unlock", userAddressStr, amount, lockStart, lockDuration, gwxBurned, i)) :+ ScriptTransfer(userAddress, amount, assetId)) ++ [IntegerEntry(keyGwxTotal(), ensurePositive((gwxAmountTotal - gwxBurned), "gwxTotal")), IntegerEntry(keyUserGwxAmountTotal(userAddress), ensurePositive((userGwxAmountTotal - gwxBurned), "userGwxAmountTotal"))]) | |
827 | - | else throw("Strict value is not equal to itself.") | |
828 | - | } | |
817 | + | if ((0 >= userAmount)) | |
818 | + | then throwErr("nothing to unlock") | |
819 | + | else { | |
820 | + | let gwxAmountTotal = getGwxAmountTotal() | |
821 | + | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
822 | + | let userGwxAmountTotalNew = ensurePositive((userGwxAmountTotal - gwxBurned), "userGwxAmountTotalNew") | |
823 | + | if ((lockedGwxAmount > userGwxAmountTotalNew)) | |
824 | + | then throwErr(("locked gwx amount: " + toString(lockedGwxAmount))) | |
825 | + | else { | |
826 | + | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
827 | + | if ((gwxRewardInv == gwxRewardInv)) | |
828 | + | then ((((LockParamsEntry(userAddress, txId, userAmount, lockStart, lockDuration, gwxRemaining, (wxClaimed + amount)) ++ StatsEntry(-(amount), 0, 0, 0)) :+ HistoryEntry("unlock", userAddressStr, amount, lockStart, lockDuration, gwxBurned, i)) :+ ScriptTransfer(userAddress, amount, assetId)) ++ [IntegerEntry(keyGwxTotal(), ensurePositive((gwxAmountTotal - gwxBurned), "gwxTotal")), IntegerEntry(keyUserGwxAmountTotal(userAddress), userGwxAmountTotalNew)]) | |
829 | + | else throw("Strict value is not equal to itself.") | |
830 | + | } | |
831 | + | } | |
829 | 832 | } | |
830 | 833 | } | |
831 | 834 | ||
832 | 835 | ||
833 | 836 | ||
834 | 837 | @Callable(i) | |
835 | 838 | func gwxUserInfoREADONLY (userAddressStr) = { | |
836 | 839 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
837 | 840 | let gwxAmount = getUserGwxAmountTotal(userAddress) | |
838 | 841 | $Tuple2(nil, [gwxAmount]) | |
839 | 842 | } | |
840 | 843 | ||
841 | 844 | ||
842 | 845 | ||
843 | 846 | @Callable(i) | |
844 | 847 | func userMaxDurationREADONLY (userAddressStr) = $Tuple2(nil, $Tuple2("increaseLock", maxLockDuration)) | |
845 | 848 | ||
846 | 849 | ||
847 | 850 | ||
848 | 851 | @Callable(i) | |
849 | 852 | func getUserGwxAmountAtHeightREADONLY (userAddressStr,targetHeight) = { | |
850 | 853 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
851 | 854 | let gwxAmount = getUserGwxAmountTotal(userAddress) | |
852 | 855 | $Tuple2(nil, gwxAmount) | |
853 | 856 | } | |
854 | 857 | ||
855 | 858 | ||
856 | 859 | ||
857 | 860 | @Callable(i) | |
858 | 861 | func getUserGwxAmount (userAddressStr) = { | |
859 | 862 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
860 | 863 | let gwxAmount = getUserGwxAmountTotal(userAddress) | |
861 | 864 | $Tuple2(nil, gwxAmount) | |
862 | 865 | } | |
863 | 866 | ||
864 | 867 | ||
865 | 868 | ||
866 | 869 | @Callable(i) | |
867 | 870 | func getGwxTotalREADONLY () = $Tuple2(nil, getGwxAmountTotal()) | |
868 | 871 | ||
869 | 872 | ||
870 | 873 | ||
871 | 874 | @Callable(i) | |
872 | 875 | func onBoostEmissionUpdate () = { | |
873 | 876 | let checkCaller = if ((i.caller == emissionContract)) | |
874 | 877 | then true | |
875 | 878 | else mustManager(i) | |
876 | 879 | if ((checkCaller == checkCaller)) | |
877 | 880 | then refreshBoostEmissionIntegral() | |
878 | 881 | else throw("Strict value is not equal to itself.") | |
879 | 882 | } | |
880 | 883 | ||
881 | 884 | ||
882 | 885 | ||
883 | 886 | @Callable(i) | |
884 | 887 | func onStakedVoteUpdate (lpAssetIdStr,userAddressStr,edge) = { | |
885 | 888 | let checkCaller = if ((i.caller == stakingContract)) | |
886 | 889 | then true | |
887 | 890 | else mustManager(i) | |
888 | 891 | if ((checkCaller == checkCaller)) | |
889 | 892 | then { | |
890 | 893 | let actions = refreshVoteStakedIntegral(lpAssetIdStr, userAddressStr, edge) | |
891 | 894 | $Tuple2(actions, unit) | |
892 | 895 | } | |
893 | 896 | else throw("Strict value is not equal to itself.") | |
894 | 897 | } | |
895 | 898 | ||
896 | 899 | ||
897 | 900 | ||
898 | 901 | @Callable(i) | |
899 | 902 | func getVotingResultStakedREADONLY (lpAssetIdStr) = $Tuple2(nil, getVotingResultStaked(lpAssetIdStr)) | |
900 | 903 | ||
901 | 904 | ||
902 | 905 | ||
903 | 906 | @Callable(i) | |
904 | 907 | func getVotingResultStakedIntegralREADONLY (lpAssetIdStr) = $Tuple2(nil, getVotingResultStakedIntegral(lpAssetIdStr)) | |
905 | 908 | ||
906 | 909 | ||
907 | 910 | ||
908 | 911 | @Callable(i) | |
909 | 912 | func getUserVoteFinalizedREADONLY (lpAssetIdStr,userAddressStr) = $Tuple2(nil, getUserVoteFinalized(lpAssetIdStr, userAddressStr)) | |
910 | 913 | ||
911 | 914 | ||
912 | 915 | ||
913 | 916 | @Callable(i) | |
914 | 917 | func getUserVoteStakedIntegralREADONLY (lpAssetIdStr,userAddressStr) = $Tuple2(nil, getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr)) | |
915 | 918 | ||
916 | 919 | ||
917 | 920 | @Verifier(tx) | |
918 | 921 | func verify () = { | |
919 | 922 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
920 | 923 | case pk: ByteVector => | |
921 | 924 | pk | |
922 | 925 | case _: Unit => | |
923 | 926 | tx.senderPublicKey | |
924 | 927 | case _ => | |
925 | 928 | throw("Match error") | |
926 | 929 | } | |
927 | 930 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
928 | 931 | } | |
929 | 932 |
github/deemru/w8io/026f985 149.40 ms ◑