tx · 9NGPmTFPthwHCjkDLXRhAyKqpmViiFms6PbshsNu1T7h 3NBFNzUQ8Y7FC2gkuLSr6yRrTLydGn1vcJw: -0.01000000 Waves 2021.11.24 14:45 [1805082] smart account 3NBFNzUQ8Y7FC2gkuLSr6yRrTLydGn1vcJw > SELF 0.00000000 Waves
{ "type": 13, "id": "9NGPmTFPthwHCjkDLXRhAyKqpmViiFms6PbshsNu1T7h", "fee": 1000000, "feeAssetId": null, "timestamp": 1637754357877, "version": 1, "sender": "3NBFNzUQ8Y7FC2gkuLSr6yRrTLydGn1vcJw", "senderPublicKey": "2h5WUYrDouLj41YkFTC8akD2W7ryFwpyqMMAKcn8KVsA", "proofs": [ "37BNWub7n2UZYSge98a149KeXVpnvfqU82d5JXhSvmNbpePrVPrSxG5F5jgaB8x8GFJzCa7aSv7yKhQjnZXxg5rG" ], "script": "base64:AAIFAAAAAAAAABoIAhIDCgEIEgASBAoCCAESAwoBCBIECgIICAAAAD4AAAAABlNDQUxFOAAAAAAAAAAACAAAAAAFTVVMVDgAAAAAAAX14QAAAAAAB1NDQUxFMTgAAAAAAAAAABIAAAAABk1VTFQxOAkAATYAAAABAA3gtrOnZAAAAAAAAANTRVACAAAAAl9fAAAAAA5QT09MV0VJR0hUTVVMVAUAAAAFTVVMVDgBAAAACWFzQW55TGlzdAAAAAEAAAADdmFsBAAAAAckbWF0Y2gwBQAAAAN2YWwDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACUxpc3RbQW55XQQAAAAKdmFsQW55THlzdAUAAAAHJG1hdGNoMAUAAAAKdmFsQW55THlzdAkAAAIAAAABAgAAABtmYWlsIHRvIGNhc3QgaW50byBMaXN0W0FueV0BAAAADGFzQnl0ZVZlY3RvcgAAAAEAAAADdmFsBAAAAAckbWF0Y2gwBQAAAAN2YWwDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACkJ5dGVWZWN0b3IEAAAABnZhbEJpbgUAAAAHJG1hdGNoMAUAAAAGdmFsQmluCQAAAgAAA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mxlVG9DbGFpbQkAAGUAAAACBQAAABB3eFRvQ2xhaW1Vc2VyTmV3BQAAAA1jbGFpbWVkQnlVc2VyCQAFFAAAAAIFAAAAA25pbAkABLkAAAACCQAETAAAAAICAAAACiVzJXMlZCVkJXMJAARMAAAAAgUAAAAMbHBBc3NldElkU3RyCQAETAAAAAIFAAAADnVzZXJBZGRyZXNzU3RyCQAETAAAAAIJAAGkAAAAAQUAAAAQYXZhaWxhYmxlVG9DbGFpbQkABEwAAAACCQABpAAAAAEFAAAADWNsYWltZWRCeVVzZXIJAARMAAAAAgkAASwAAAACCQABLAAAAAIFAAAABWRlYnVnAgAAAAI6OgkAAaQAAAABBQAAAAx1c2VyV3hSZXdhcmQFAAAAA25pbAUAAAADU0VQAAAAABsibq8=", "chainId": 84, "height": 1805082, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CQBnwLis6Smk2FbhDNHCBUCWC9z1Ao96qMjjiCYHhv12 Next: 5JFSmeG8TDDvJaRzviBgq84YqNaAef5fdRLxwmrGcLaS Diff:
Old | New | Differences | |
---|---|---|---|
11 | 11 | ||
12 | 12 | let SEP = "__" | |
13 | 13 | ||
14 | + | let POOLWEIGHTMULT = MULT8 | |
15 | + | ||
16 | + | func asAnyList (val) = match val { | |
17 | + | case valAnyLyst: List[Any] => | |
18 | + | valAnyLyst | |
19 | + | case _ => | |
20 | + | throw("fail to cast into List[Any]") | |
21 | + | } | |
22 | + | ||
23 | + | ||
24 | + | func asByteVector (val) = match val { | |
25 | + | case valBin: ByteVector => | |
26 | + | valBin | |
27 | + | case _ => | |
28 | + | throw("fail to cast into Int") | |
29 | + | } | |
30 | + | ||
31 | + | ||
14 | 32 | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
15 | 33 | ||
16 | 34 | ||
18 | 36 | ||
19 | 37 | ||
20 | 38 | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
39 | + | ||
40 | + | ||
41 | + | func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
21 | 42 | ||
22 | 43 | ||
23 | 44 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) | |
94 | 115 | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
95 | 116 | ||
96 | 117 | ||
118 | + | func keyClaimedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) | |
119 | + | ||
120 | + | ||
121 | + | func keyClaimedTotal (lpAssetIdStr) = makeString(["%s%s%s__claimed", "total", lpAssetIdStr], SEP) | |
122 | + | ||
123 | + | ||
97 | 124 | func readStaked (key) = valueOrElse(getInteger(this, key), 0) | |
125 | + | ||
126 | + | ||
127 | + | func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP) | |
128 | + | ||
129 | + | ||
130 | + | func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP) | |
131 | + | ||
132 | + | ||
133 | + | func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP) | |
134 | + | ||
135 | + | ||
136 | + | func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP) | |
137 | + | ||
138 | + | ||
139 | + | func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP) | |
140 | + | ||
141 | + | ||
142 | + | func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP) | |
143 | + | ||
144 | + | ||
145 | + | func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP) | |
146 | + | ||
147 | + | ||
148 | + | func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP) | |
149 | + | ||
150 | + | ||
151 | + | func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP) | |
152 | + | ||
153 | + | ||
154 | + | func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP) | |
155 | + | ||
156 | + | ||
157 | + | func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP) | |
158 | + | ||
159 | + | ||
160 | + | func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP) | |
98 | 161 | ||
99 | 162 | ||
100 | 163 | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
106 | 169 | func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount)) | |
107 | 170 | ||
108 | 171 | ||
172 | + | let factoryContract = readFactoryAddressOrFail() | |
173 | + | ||
174 | + | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
175 | + | ||
176 | + | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
177 | + | ||
178 | + | func calcWxPerLpIntegralUserLast (stakedByUser,wxPerLpIntegralUserLastUpdHeightOrZero,wxPerLpIntegralNew,wxPerLpIntegralUserLastKEY) = if (if ((wxPerLpIntegralUserLastUpdHeightOrZero == 0)) | |
179 | + | then (stakedByUser > 0) | |
180 | + | else false) | |
181 | + | then 0 | |
182 | + | else if ((stakedByUser == 0)) | |
183 | + | then wxPerLpIntegralNew | |
184 | + | else if (if ((wxPerLpIntegralUserLastUpdHeightOrZero > 0)) | |
185 | + | then (stakedByUser > 0) | |
186 | + | else false) | |
187 | + | then getIntOrFail(this, wxPerLpIntegralUserLastKEY) | |
188 | + | else throw("calcWxPerLpIntegralUserLast: unexpected state") | |
189 | + | ||
190 | + | ||
191 | + | func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = { | |
192 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
193 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
194 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
195 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
196 | + | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
197 | + | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
198 | + | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
199 | + | let poolWxEmissionPerBlock = fraction(wxEmissionPerBlock, poolWeight, POOLWEIGHTMULT) | |
200 | + | let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr) | |
201 | + | let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr) | |
202 | + | let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr) | |
203 | + | let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr) | |
204 | + | let wxPerLpKEY = keyWxPerLp(lpAssetIdStr) | |
205 | + | let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr) | |
206 | + | let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock) | |
207 | + | let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY) | |
208 | + | let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY) | |
209 | + | let wxPerLpIntegralUserLastUpdHeightOrZero = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY) | |
210 | + | let wxPerLpOrZero = getIntOrZero(this, wxPerLpKEY) | |
211 | + | let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0]) | |
212 | + | let wxPerLp = if ((wxPerLpOrZero != 0)) | |
213 | + | then wxPerLpOrZero | |
214 | + | else fraction(poolWxEmissionPerBlock, MULT8, stakedTotal) | |
215 | + | let stakedTotalNew = (stakedTotal + lpDeltaAmount) | |
216 | + | let wxPerLpIntegralNew = (wxPerLpIntegral + (wxPerLp * dh)) | |
217 | + | let wxPerLpIntegralUserLast = calcWxPerLpIntegralUserLast(stakedByUser, wxPerLpIntegralUserLastUpdHeightOrZero, wxPerLpIntegralNew, wxPerLpIntegralUserLastKEY) | |
218 | + | let wxToClaimUserNew = (wxToClaimUser + fraction((wxPerLpIntegralNew - wxPerLpIntegralUserLast), stakedByUser, MULT8)) | |
219 | + | let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew | |
220 | + | let wxPerLpNew = (poolWxEmissionPerBlock / stakedTotalNew) | |
221 | + | let wxPerLpIntegralLastUpdHeightNew = height | |
222 | + | let wxPerLpIntegralUserLastUpdHeightNew = height | |
223 | + | let debug = makeString([toString(wxToClaimUserNew), toString(wxPerLpIntegralNew), toString(wxPerLpIntegralUserLast), toString(stakedByUser), toString(dh), toString(wxPerLp), toString(stakedTotal), toString(poolWxEmissionPerBlock), toString(wxEmissionPerBlock), toString(poolWeight), toString(height)], "::") | |
224 | + | $Tuple3(wxToClaimUserNew, [IntegerEntry(wxPerLpIntegralKEY, wxPerLpIntegralNew), IntegerEntry(wxPerLpIntegralLastUpdHeightKEY, wxPerLpIntegralLastUpdHeightNew), IntegerEntry(wxToClaimUserKEY, wxToClaimUserNew), IntegerEntry(wxPerLpIntegralUserLastUpdHeightKEY, wxPerLpIntegralUserLastUpdHeightNew), IntegerEntry(wxPerLpKEY, wxPerLpNew), IntegerEntry(wxPerLpIntegralUserLastKEY, wxPerLpIntegralUserLastNew)], debug) | |
225 | + | } | |
226 | + | ||
227 | + | ||
109 | 228 | @Callable(i) | |
110 | 229 | func constructor (factoryAddressStr) = if ((i.caller != this)) | |
111 | 230 | then throw("not authorized") | |
114 | 233 | ||
115 | 234 | ||
116 | 235 | @Callable(i) | |
117 | - | func stake () = { | |
118 | - | let factory = readFactoryAddressOrFail() | |
119 | - | if ((size(i.payments) != 1)) | |
120 | - | then throw("invalid payment - exact one payment must be attached") | |
236 | + | func stake () = if ((size(i.payments) != 1)) | |
237 | + | then throw("invalid payment - exact one payment must be attached") | |
238 | + | else { | |
239 | + | let pmt = i.payments[0] | |
240 | + | let lpAssetId = value(pmt.assetId) | |
241 | + | let lpAssetIdStr = toBase58String(lpAssetId) | |
242 | + | let amount = pmt.amount | |
243 | + | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
244 | + | let callerStr = toString(i.caller) | |
245 | + | let userAddressStr = if ((callerStr == poolAddressStr)) | |
246 | + | then toString(i.originCaller) | |
247 | + | else callerStr | |
248 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
249 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
250 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
251 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
252 | + | let $t01155411671 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount) | |
253 | + | let wxToClaimUserNew = $t01155411671._1 | |
254 | + | let integralSTATE = $t01155411671._2 | |
255 | + | let debug = $t01155411671._3 | |
256 | + | ([IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
257 | + | } | |
258 | + | ||
259 | + | ||
260 | + | ||
261 | + | @Callable(i) | |
262 | + | func unstake (lpAssetIdStr,amount) = { | |
263 | + | let userAddressStr = toString(i.caller) | |
264 | + | let lpAssetId = fromBase58String(lpAssetIdStr) | |
265 | + | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
266 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
267 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
268 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
269 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
270 | + | let $t01248812606 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount)) | |
271 | + | let wxToClaimUserNew = $t01248812606._1 | |
272 | + | let integralSTATE = $t01248812606._2 | |
273 | + | let debug = $t01248812606._3 | |
274 | + | if ((amount > stakedByUser)) | |
275 | + | then throw("passed amount is less then available") | |
276 | + | else ([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
277 | + | } | |
278 | + | ||
279 | + | ||
280 | + | ||
281 | + | @Callable(i) | |
282 | + | func claimWx (lpAssetIdStr) = { | |
283 | + | let userAddress = i.caller | |
284 | + | let userAddressStr = toString(i.caller) | |
285 | + | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
286 | + | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
287 | + | let claimedTotalKEY = keyClaimedTotal(lpAssetIdStr) | |
288 | + | let claimedByUser = getIntOrZero(this, claimedByUserKEY) | |
289 | + | let claimedTotal = getIntOrZero(this, claimedTotalKEY) | |
290 | + | let $t01345813570 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
291 | + | let wxToClaimUserNew = $t01345813570._1 | |
292 | + | let integralSTATE = $t01345813570._2 | |
293 | + | let debug = $t01345813570._3 | |
294 | + | let availableToClaim = (wxToClaimUserNew - claimedByUser) | |
295 | + | if ((0 >= availableToClaim)) | |
296 | + | then throw("nothing to claim") | |
121 | 297 | else { | |
122 | - | let pmt = i.payments[0] | |
123 | - | let lpAssetId = value(pmt.assetId) | |
124 | - | let lpAssetIdStr = toBase58String(lpAssetId) | |
125 | - | let amount = pmt.amount | |
126 | - | let lpDappStr = valueOrErrorMessage(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
127 | - | let callerStr = toString(i.caller) | |
128 | - | let userAddressStr = if ((callerStr == lpDappStr)) | |
129 | - | then toString(i.originCaller) | |
130 | - | else callerStr | |
131 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
132 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
133 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
134 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
135 | - | [IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] | |
298 | + | let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [availableToClaim], nil))[0]) | |
299 | + | [IntegerEntry(claimedByUserKEY, (claimedByUser + availableToClaim)), IntegerEntry(claimedTotalKEY, (claimedTotal + availableToClaim)), ScriptTransfer(userAddress, availableToClaim, wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, availableToClaim, i.transactionId)] | |
136 | 300 | } | |
137 | 301 | } | |
138 | 302 | ||
139 | 303 | ||
140 | 304 | ||
141 | 305 | @Callable(i) | |
142 | - | func unstake (lpAssetIdStr,amount) = { | |
143 | - | let factory = readFactoryAddressOrFail() | |
144 | - | let userAddressStr = toString(i.caller) | |
145 | - | let lpAssetId = fromBase58String(lpAssetIdStr) | |
146 | - | if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr))))) | |
147 | - | then throw(("unsupported lp asset " + lpAssetIdStr)) | |
148 | - | else { | |
149 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
150 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
151 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
152 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
153 | - | if ((amount > stakedByUser)) | |
154 | - | then throw("passed amount is less then available") | |
155 | - | else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] | |
156 | - | } | |
157 | - | } | |
158 | - | ||
159 | - | ||
160 | - | ||
161 | - | @Callable(i) | |
162 | - | func claimWx (lpAssetIdStr) = throw("temorary disabled") | |
163 | - | ||
164 | - | ||
165 | - | ||
166 | - | @Callable(i) | |
167 | - | func claimWxREADONLY (lpAssetIdStr,userAddress) = { | |
168 | - | let factoryContract = readFactoryAddressOrFail() | |
169 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
170 | - | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
171 | - | let stakedByUserKEY = keyStakedByUser(userAddress, lpAssetIdStr) | |
306 | + | func claimWxREADONLY (lpAssetIdStr,userAddressStr) = { | |
307 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
172 | 308 | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
309 | + | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
173 | 310 | let stakedByUser = readStaked(stakedByUserKEY) | |
174 | 311 | let stakedTotal = readStaked(stakedTotalKEY) | |
312 | + | let claimedByUser = getIntOrZero(this, claimedByUserKEY) | |
175 | 313 | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
176 | 314 | let poolWeightMult = MULT8 | |
177 | 315 | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
182 | 320 | else (height - emissionStartBlock) | |
183 | 321 | let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, poolWeightMult) | |
184 | 322 | let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal) | |
185 | - | $Tuple2(nil, makeString(["%s%s%d", lpAssetIdStr, userAddress, toString(userWxReward)], SEP)) | |
323 | + | let $t01523915351 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
324 | + | let wxToClaimUserNew = $t01523915351._1 | |
325 | + | let integralSTATE = $t01523915351._2 | |
326 | + | let debug = $t01523915351._3 | |
327 | + | let availableToClaim = (wxToClaimUserNew - claimedByUser) | |
328 | + | $Tuple2(nil, makeString(["%s%s%d%d%s", lpAssetIdStr, userAddressStr, toString(availableToClaim), toString(claimedByUser), ((debug + "::") + toString(userWxReward))], SEP)) | |
186 | 329 | } | |
187 | 330 | ||
188 | 331 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SCALE8 = 8 | |
5 | 5 | ||
6 | 6 | let MULT8 = 100000000 | |
7 | 7 | ||
8 | 8 | let SCALE18 = 18 | |
9 | 9 | ||
10 | 10 | let MULT18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let SEP = "__" | |
13 | 13 | ||
14 | + | let POOLWEIGHTMULT = MULT8 | |
15 | + | ||
16 | + | func asAnyList (val) = match val { | |
17 | + | case valAnyLyst: List[Any] => | |
18 | + | valAnyLyst | |
19 | + | case _ => | |
20 | + | throw("fail to cast into List[Any]") | |
21 | + | } | |
22 | + | ||
23 | + | ||
24 | + | func asByteVector (val) = match val { | |
25 | + | case valBin: ByteVector => | |
26 | + | valBin | |
27 | + | case _ => | |
28 | + | throw("fail to cast into Int") | |
29 | + | } | |
30 | + | ||
31 | + | ||
14 | 32 | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
15 | 33 | ||
16 | 34 | ||
17 | 35 | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
18 | 36 | ||
19 | 37 | ||
20 | 38 | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
39 | + | ||
40 | + | ||
41 | + | func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
21 | 42 | ||
22 | 43 | ||
23 | 44 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) | |
24 | 45 | ||
25 | 46 | ||
26 | 47 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
27 | 48 | ||
28 | 49 | ||
29 | 50 | let IdxFactoryCfgStakingDapp = 1 | |
30 | 51 | ||
31 | 52 | let IdxFactoryCfgBoostingDapp = 2 | |
32 | 53 | ||
33 | 54 | let IdxFactoryCfgIdoDapp = 3 | |
34 | 55 | ||
35 | 56 | let IdxFactoryCfgTeamDapp = 4 | |
36 | 57 | ||
37 | 58 | let IdxFactoryCfgEmissionDapp = 5 | |
38 | 59 | ||
39 | 60 | let IdxFactoryCfgRestDapp = 6 | |
40 | 61 | ||
41 | 62 | let IdxFactoryCfgSlippageDapp = 7 | |
42 | 63 | ||
43 | 64 | func keyFactoryCfg () = "%s__factoryConfig" | |
44 | 65 | ||
45 | 66 | ||
46 | 67 | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
47 | 68 | ||
48 | 69 | ||
49 | 70 | func keyFactoryLpList () = "%s__lpTokensList" | |
50 | 71 | ||
51 | 72 | ||
52 | 73 | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
53 | 74 | ||
54 | 75 | ||
55 | 76 | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
56 | 77 | ||
57 | 78 | ||
58 | 79 | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(keyFactoryAddress())) | |
59 | 80 | ||
60 | 81 | ||
61 | 82 | func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP) | |
62 | 83 | ||
63 | 84 | ||
64 | 85 | func readFactoryCfgOrFail (factory) = split(getStringByAddressOrFail(factory, keyFactoryCfg()), SEP) | |
65 | 86 | ||
66 | 87 | ||
67 | 88 | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
68 | 89 | ||
69 | 90 | ||
70 | 91 | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
71 | 92 | ||
72 | 93 | ||
73 | 94 | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
74 | 95 | ||
75 | 96 | ||
76 | 97 | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
77 | 98 | ||
78 | 99 | ||
79 | 100 | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
80 | 101 | ||
81 | 102 | ||
82 | 103 | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
83 | 104 | ||
84 | 105 | ||
85 | 106 | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
86 | 107 | ||
87 | 108 | ||
88 | 109 | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
89 | 110 | ||
90 | 111 | ||
91 | 112 | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
92 | 113 | ||
93 | 114 | ||
94 | 115 | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
95 | 116 | ||
96 | 117 | ||
118 | + | func keyClaimedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) | |
119 | + | ||
120 | + | ||
121 | + | func keyClaimedTotal (lpAssetIdStr) = makeString(["%s%s%s__claimed", "total", lpAssetIdStr], SEP) | |
122 | + | ||
123 | + | ||
97 | 124 | func readStaked (key) = valueOrElse(getInteger(this, key), 0) | |
125 | + | ||
126 | + | ||
127 | + | func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP) | |
128 | + | ||
129 | + | ||
130 | + | func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP) | |
131 | + | ||
132 | + | ||
133 | + | func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP) | |
134 | + | ||
135 | + | ||
136 | + | func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP) | |
137 | + | ||
138 | + | ||
139 | + | func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP) | |
140 | + | ||
141 | + | ||
142 | + | func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP) | |
143 | + | ||
144 | + | ||
145 | + | func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP) | |
146 | + | ||
147 | + | ||
148 | + | func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP) | |
149 | + | ||
150 | + | ||
151 | + | func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP) | |
152 | + | ||
153 | + | ||
154 | + | func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP) | |
155 | + | ||
156 | + | ||
157 | + | func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP) | |
158 | + | ||
159 | + | ||
160 | + | func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP) | |
98 | 161 | ||
99 | 162 | ||
100 | 163 | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
101 | 164 | ||
102 | 165 | ||
103 | 166 | func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
104 | 167 | ||
105 | 168 | ||
106 | 169 | func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount)) | |
107 | 170 | ||
108 | 171 | ||
172 | + | let factoryContract = readFactoryAddressOrFail() | |
173 | + | ||
174 | + | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
175 | + | ||
176 | + | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
177 | + | ||
178 | + | func calcWxPerLpIntegralUserLast (stakedByUser,wxPerLpIntegralUserLastUpdHeightOrZero,wxPerLpIntegralNew,wxPerLpIntegralUserLastKEY) = if (if ((wxPerLpIntegralUserLastUpdHeightOrZero == 0)) | |
179 | + | then (stakedByUser > 0) | |
180 | + | else false) | |
181 | + | then 0 | |
182 | + | else if ((stakedByUser == 0)) | |
183 | + | then wxPerLpIntegralNew | |
184 | + | else if (if ((wxPerLpIntegralUserLastUpdHeightOrZero > 0)) | |
185 | + | then (stakedByUser > 0) | |
186 | + | else false) | |
187 | + | then getIntOrFail(this, wxPerLpIntegralUserLastKEY) | |
188 | + | else throw("calcWxPerLpIntegralUserLast: unexpected state") | |
189 | + | ||
190 | + | ||
191 | + | func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = { | |
192 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
193 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
194 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
195 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
196 | + | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
197 | + | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
198 | + | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
199 | + | let poolWxEmissionPerBlock = fraction(wxEmissionPerBlock, poolWeight, POOLWEIGHTMULT) | |
200 | + | let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr) | |
201 | + | let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr) | |
202 | + | let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr) | |
203 | + | let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr) | |
204 | + | let wxPerLpKEY = keyWxPerLp(lpAssetIdStr) | |
205 | + | let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr) | |
206 | + | let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock) | |
207 | + | let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY) | |
208 | + | let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY) | |
209 | + | let wxPerLpIntegralUserLastUpdHeightOrZero = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY) | |
210 | + | let wxPerLpOrZero = getIntOrZero(this, wxPerLpKEY) | |
211 | + | let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0]) | |
212 | + | let wxPerLp = if ((wxPerLpOrZero != 0)) | |
213 | + | then wxPerLpOrZero | |
214 | + | else fraction(poolWxEmissionPerBlock, MULT8, stakedTotal) | |
215 | + | let stakedTotalNew = (stakedTotal + lpDeltaAmount) | |
216 | + | let wxPerLpIntegralNew = (wxPerLpIntegral + (wxPerLp * dh)) | |
217 | + | let wxPerLpIntegralUserLast = calcWxPerLpIntegralUserLast(stakedByUser, wxPerLpIntegralUserLastUpdHeightOrZero, wxPerLpIntegralNew, wxPerLpIntegralUserLastKEY) | |
218 | + | let wxToClaimUserNew = (wxToClaimUser + fraction((wxPerLpIntegralNew - wxPerLpIntegralUserLast), stakedByUser, MULT8)) | |
219 | + | let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew | |
220 | + | let wxPerLpNew = (poolWxEmissionPerBlock / stakedTotalNew) | |
221 | + | let wxPerLpIntegralLastUpdHeightNew = height | |
222 | + | let wxPerLpIntegralUserLastUpdHeightNew = height | |
223 | + | let debug = makeString([toString(wxToClaimUserNew), toString(wxPerLpIntegralNew), toString(wxPerLpIntegralUserLast), toString(stakedByUser), toString(dh), toString(wxPerLp), toString(stakedTotal), toString(poolWxEmissionPerBlock), toString(wxEmissionPerBlock), toString(poolWeight), toString(height)], "::") | |
224 | + | $Tuple3(wxToClaimUserNew, [IntegerEntry(wxPerLpIntegralKEY, wxPerLpIntegralNew), IntegerEntry(wxPerLpIntegralLastUpdHeightKEY, wxPerLpIntegralLastUpdHeightNew), IntegerEntry(wxToClaimUserKEY, wxToClaimUserNew), IntegerEntry(wxPerLpIntegralUserLastUpdHeightKEY, wxPerLpIntegralUserLastUpdHeightNew), IntegerEntry(wxPerLpKEY, wxPerLpNew), IntegerEntry(wxPerLpIntegralUserLastKEY, wxPerLpIntegralUserLastNew)], debug) | |
225 | + | } | |
226 | + | ||
227 | + | ||
109 | 228 | @Callable(i) | |
110 | 229 | func constructor (factoryAddressStr) = if ((i.caller != this)) | |
111 | 230 | then throw("not authorized") | |
112 | 231 | else [StringEntry(keyFactoryAddress(), factoryAddressStr)] | |
113 | 232 | ||
114 | 233 | ||
115 | 234 | ||
116 | 235 | @Callable(i) | |
117 | - | func stake () = { | |
118 | - | let factory = readFactoryAddressOrFail() | |
119 | - | if ((size(i.payments) != 1)) | |
120 | - | then throw("invalid payment - exact one payment must be attached") | |
236 | + | func stake () = if ((size(i.payments) != 1)) | |
237 | + | then throw("invalid payment - exact one payment must be attached") | |
238 | + | else { | |
239 | + | let pmt = i.payments[0] | |
240 | + | let lpAssetId = value(pmt.assetId) | |
241 | + | let lpAssetIdStr = toBase58String(lpAssetId) | |
242 | + | let amount = pmt.amount | |
243 | + | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
244 | + | let callerStr = toString(i.caller) | |
245 | + | let userAddressStr = if ((callerStr == poolAddressStr)) | |
246 | + | then toString(i.originCaller) | |
247 | + | else callerStr | |
248 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
249 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
250 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
251 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
252 | + | let $t01155411671 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount) | |
253 | + | let wxToClaimUserNew = $t01155411671._1 | |
254 | + | let integralSTATE = $t01155411671._2 | |
255 | + | let debug = $t01155411671._3 | |
256 | + | ([IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
257 | + | } | |
258 | + | ||
259 | + | ||
260 | + | ||
261 | + | @Callable(i) | |
262 | + | func unstake (lpAssetIdStr,amount) = { | |
263 | + | let userAddressStr = toString(i.caller) | |
264 | + | let lpAssetId = fromBase58String(lpAssetIdStr) | |
265 | + | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
266 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
267 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
268 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
269 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
270 | + | let $t01248812606 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount)) | |
271 | + | let wxToClaimUserNew = $t01248812606._1 | |
272 | + | let integralSTATE = $t01248812606._2 | |
273 | + | let debug = $t01248812606._3 | |
274 | + | if ((amount > stakedByUser)) | |
275 | + | then throw("passed amount is less then available") | |
276 | + | else ([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
277 | + | } | |
278 | + | ||
279 | + | ||
280 | + | ||
281 | + | @Callable(i) | |
282 | + | func claimWx (lpAssetIdStr) = { | |
283 | + | let userAddress = i.caller | |
284 | + | let userAddressStr = toString(i.caller) | |
285 | + | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
286 | + | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
287 | + | let claimedTotalKEY = keyClaimedTotal(lpAssetIdStr) | |
288 | + | let claimedByUser = getIntOrZero(this, claimedByUserKEY) | |
289 | + | let claimedTotal = getIntOrZero(this, claimedTotalKEY) | |
290 | + | let $t01345813570 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
291 | + | let wxToClaimUserNew = $t01345813570._1 | |
292 | + | let integralSTATE = $t01345813570._2 | |
293 | + | let debug = $t01345813570._3 | |
294 | + | let availableToClaim = (wxToClaimUserNew - claimedByUser) | |
295 | + | if ((0 >= availableToClaim)) | |
296 | + | then throw("nothing to claim") | |
121 | 297 | else { | |
122 | - | let pmt = i.payments[0] | |
123 | - | let lpAssetId = value(pmt.assetId) | |
124 | - | let lpAssetIdStr = toBase58String(lpAssetId) | |
125 | - | let amount = pmt.amount | |
126 | - | let lpDappStr = valueOrErrorMessage(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
127 | - | let callerStr = toString(i.caller) | |
128 | - | let userAddressStr = if ((callerStr == lpDappStr)) | |
129 | - | then toString(i.originCaller) | |
130 | - | else callerStr | |
131 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
132 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
133 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
134 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
135 | - | [IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] | |
298 | + | let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [availableToClaim], nil))[0]) | |
299 | + | [IntegerEntry(claimedByUserKEY, (claimedByUser + availableToClaim)), IntegerEntry(claimedTotalKEY, (claimedTotal + availableToClaim)), ScriptTransfer(userAddress, availableToClaim, wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, availableToClaim, i.transactionId)] | |
136 | 300 | } | |
137 | 301 | } | |
138 | 302 | ||
139 | 303 | ||
140 | 304 | ||
141 | 305 | @Callable(i) | |
142 | - | func unstake (lpAssetIdStr,amount) = { | |
143 | - | let factory = readFactoryAddressOrFail() | |
144 | - | let userAddressStr = toString(i.caller) | |
145 | - | let lpAssetId = fromBase58String(lpAssetIdStr) | |
146 | - | if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr))))) | |
147 | - | then throw(("unsupported lp asset " + lpAssetIdStr)) | |
148 | - | else { | |
149 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
150 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
151 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
152 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
153 | - | if ((amount > stakedByUser)) | |
154 | - | then throw("passed amount is less then available") | |
155 | - | else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] | |
156 | - | } | |
157 | - | } | |
158 | - | ||
159 | - | ||
160 | - | ||
161 | - | @Callable(i) | |
162 | - | func claimWx (lpAssetIdStr) = throw("temorary disabled") | |
163 | - | ||
164 | - | ||
165 | - | ||
166 | - | @Callable(i) | |
167 | - | func claimWxREADONLY (lpAssetIdStr,userAddress) = { | |
168 | - | let factoryContract = readFactoryAddressOrFail() | |
169 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
170 | - | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
171 | - | let stakedByUserKEY = keyStakedByUser(userAddress, lpAssetIdStr) | |
306 | + | func claimWxREADONLY (lpAssetIdStr,userAddressStr) = { | |
307 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
172 | 308 | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
309 | + | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
173 | 310 | let stakedByUser = readStaked(stakedByUserKEY) | |
174 | 311 | let stakedTotal = readStaked(stakedTotalKEY) | |
312 | + | let claimedByUser = getIntOrZero(this, claimedByUserKEY) | |
175 | 313 | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
176 | 314 | let poolWeightMult = MULT8 | |
177 | 315 | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
178 | 316 | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
179 | 317 | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
180 | 318 | let passedBlocks = if ((emissionStartBlock > height)) | |
181 | 319 | then 0 | |
182 | 320 | else (height - emissionStartBlock) | |
183 | 321 | let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, poolWeightMult) | |
184 | 322 | let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal) | |
185 | - | $Tuple2(nil, makeString(["%s%s%d", lpAssetIdStr, userAddress, toString(userWxReward)], SEP)) | |
323 | + | let $t01523915351 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
324 | + | let wxToClaimUserNew = $t01523915351._1 | |
325 | + | let integralSTATE = $t01523915351._2 | |
326 | + | let debug = $t01523915351._3 | |
327 | + | let availableToClaim = (wxToClaimUserNew - claimedByUser) | |
328 | + | $Tuple2(nil, makeString(["%s%s%d%d%s", lpAssetIdStr, userAddressStr, toString(availableToClaim), toString(claimedByUser), ((debug + "::") + toString(userWxReward))], SEP)) | |
186 | 329 | } | |
187 | 330 | ||
188 | 331 |
github/deemru/w8io/169f3d6 50.77 ms ◑