tx · 8DAztdbjEvV3BwbPK7C8WLDhxbG1ssBQMFJTdXBv9JK4

3N2hq7Nm7cSu4TXtVQ5Mj96vjavhv1134o1:  -0.03400000 Waves

2022.08.04 14:29 [2169689] smart account 3N2hq7Nm7cSu4TXtVQ5Mj96vjavhv1134o1 > SELF 0.00000000 Waves

{ "type": 13, "id": "8DAztdbjEvV3BwbPK7C8WLDhxbG1ssBQMFJTdXBv9JK4", "fee": 3400000, "feeAssetId": null, "timestamp": 1659612615272, "version": 2, "chainId": 84, "sender": "3N2hq7Nm7cSu4TXtVQ5Mj96vjavhv1134o1", "senderPublicKey": "2xBJ1sGKs6eWt91XZbMaa48ucFzNiqRcFCx9t9kM7Mh7", "proofs": [ "5kts2cTP4q8m3REJGJvHC6zYG12QnEyxiKBj8vtTS31g9ey1F34AcStS4mW47HMQmtyLH85tNcmojFhCvXkQtfTB" ], "script": "base64:BgIpCAISBAoCCAgSBQoDCAgBEgQKAggBEgYKBAgIAQESBAoCCAESBAoCCAFHABNrX3RvdGFsRmVlc0luUGVyaW9kAhNrX3RvdGFsRmVlc0luUGVyaW9kABRrX3RyYWRlckZlZXNJblBlcmlvZAIUa190cmFkZXJGZWVzSW5QZXJpb2QADmtfbGFzdE5vdGlvbmFsAg5rX2xhc3ROb3Rpb25hbAASa19sYXN0RGF0ZUluUGVyaW9kAhJrX2xhc3REYXRlSW5QZXJpb2QAFGtfdG90YWxTY29yZUluUGVyaW9kAhRrX3RvdGFsU2NvcmVJblBlcmlvZAAVa190cmFkZXJTY29yZUluUGVyaW9kAhVrX3RyYWRlclNjb3JlSW5QZXJpb2QAH2tfdHJhZGVyQXZlcmFnZU5vdGlvbmFsSW5QZXJpb2QCH2tfdHJhZGVyQXZlcmFnZU5vdGlvbmFsSW5QZXJpb2QAD2tfYW1tUmV3YXJkUmF0ZQIPa19hbW1SZXdhcmRSYXRlABdrX2FtbU1heEFtb3VudFBlclBlcmlvZAIXa19hbW1NYXhBbW91bnRQZXJQZXJpb2QAEGtf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W1tU2NvcmUFGG5ld1RvdGFsQW1tU2NvcmVJblBlcmlvZAECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAJAQ5hZG1pblB1YmxpY0tleQCMeLMy", "height": 2169689, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let k_totalFeesInPeriod = "k_totalFeesInPeriod"
5+
6+let k_traderFeesInPeriod = "k_traderFeesInPeriod"
7+
8+let k_lastNotional = "k_lastNotional"
9+
10+let k_lastDateInPeriod = "k_lastDateInPeriod"
11+
12+let k_totalScoreInPeriod = "k_totalScoreInPeriod"
13+
14+let k_traderScoreInPeriod = "k_traderScoreInPeriod"
15+
16+let k_traderAverageNotionalInPeriod = "k_traderAverageNotionalInPeriod"
17+
18+let k_ammRewardRate = "k_ammRewardRate"
19+
20+let k_ammMaxAmountPerPeriod = "k_ammMaxAmountPerPeriod"
21+
22+let k_rewardAssetIds = "k_rewardAssetIds"
23+
24+let k_amms = "k_amms"
25+
26+let k_claimedAssetAndPeriod = "k_claimedAssetAndPeriod"
27+
28+let k_oracleAddress = "k_oracleAddress"
29+
30+let k_oraclePrice = "price"
31+
32+let k_initialized = "k_initialized"
33+
34+let k_coordinatorAddress = "k_coordinatorAddress"
35+
36+let k_governance_asset = "k_gov_asset"
37+
38+let k_quote_asset = "k_quote_asset"
39+
40+let k_admin_public_key = "k_admin_public_key"
41+
42+let k_admin_address = "k_admin_address"
43+
44+let k_amm = "k_amm"
45+
46+let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10))
47+
48+let A = 70000000
49+
50+let MS_IN_WEEK = (1000 * 604800)
51+
52+func listToStr (_list) = {
53+ func _join (accumulator,val) = ((accumulator + val) + ",")
54+
55+ let newListStr = {
56+ let $l = _list
57+ let $s = size($l)
58+ let $acc0 = ""
59+ func $f0_1 ($a,$i) = if (($i >= $s))
60+ then $a
61+ else _join($a, $l[$i])
62+
63+ func $f0_2 ($a,$i) = if (($i >= $s))
64+ then $a
65+ else throw("List size exceeds 100")
66+
67+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99), 100)
68+ }
69+ let newListStrU = dropRight(newListStr, 1)
70+ let newListStrR = if ((take(newListStrU, 1) == ","))
71+ then drop(newListStrU, 1)
72+ else newListStrU
73+ newListStrR
74+ }
75+
76+
77+func strToList (_str) = if ((_str == ""))
78+ then nil
79+ else split(_str, ",")
80+
81+
82+func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
83+
84+
85+func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
86+
87+
88+func powd (_x,_y) = pow(_x, 8, _y, 8, 8, HALFEVEN)
89+
90+
91+func abs (_x) = if ((_x > 0))
92+ then _x
93+ else -(_x)
94+
95+
96+func minv (_x,_y) = if ((_x > _y))
97+ then _y
98+ else _x
99+
100+
101+func toCompositeKey (_key,_address) = ((_key + "_") + _address)
102+
103+
104+func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
105+
106+
107+func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
108+
109+
110+func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
111+
112+
113+func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false)
114+
115+
116+func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
117+
118+
119+func int0 (k) = valueOrElse(getInteger(this, k), 0)
120+
121+
122+func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
123+
124+
125+func getFeesInPeriodKey (_amm,_trader,_weekId) = ((((((k_traderFeesInPeriod + "_") + _amm) + "_") + _trader) + "_") + toString(_weekId))
126+
127+
128+func getTotalFeesInPeriodKey (_amm,_weekId) = ((((k_totalFeesInPeriod + "_") + _amm) + "_") + toString(_weekId))
129+
130+
131+func getLastNotionalKey (_amm,_trader) = ((((k_lastNotional + "_") + _amm) + "_") + _trader)
132+
133+
134+func getLastDateInPeriodKey (_amm,_trader,_weekId) = ((((((k_lastDateInPeriod + "_") + _amm) + "_") + _trader) + "_") + toString(_weekId))
135+
136+
137+func getTraderScoreInPeriodKey (_amm,_trader,_weekId) = ((((((k_traderScoreInPeriod + "_") + _amm) + "_") + _trader) + "_") + toString(_weekId))
138+
139+
140+func getTotalScoreInPeriodKey (_amm,_weekId) = ((((k_totalScoreInPeriod + "_") + _amm) + "_") + toString(_weekId))
141+
142+
143+func getTraderAverageNotionalInPeriodKey (_amm,_trader,_weekId) = ((((((k_traderAverageNotionalInPeriod + "_") + _amm) + "_") + _trader) + "_") + toString(_weekId))
144+
145+
146+func getAmmRewardRateKey (_amm,_assetId) = ((((k_ammRewardRate + "_") + _amm) + "_") + _assetId)
147+
148+
149+func getAmmMaxAmountPerPeriodKey (_amm,_assetId) = ((((k_ammMaxAmountPerPeriod + "_") + _amm) + "_") + _assetId)
150+
151+
152+func getClaimedTraderAssetPeriodKey (_trader,_assetId,_period) = ((((((k_claimedAssetAndPeriod + "_") + _trader) + "_") + _assetId) + "_") + toString(_period))
153+
154+
155+func getOraclePriceKey (_assetId,_period) = ((((k_oraclePrice + "_") + toString(_period)) + "_") + _assetId)
156+
157+
158+func updateAmmFees (_amm,_trader,_weekId,_traderFees,_totalFees) = {
159+ let traderFeesKey = getFeesInPeriodKey(_amm, _trader, _weekId)
160+ let totalFeesKey = getTotalFeesInPeriodKey(_amm, _weekId)
161+[IntegerEntry(traderFeesKey, _traderFees), IntegerEntry(totalFeesKey, _totalFees)]
162+ }
163+
164+
165+func updateAmmData (_amm,_trader,_weekId,_traderLastDateInPeriod,_traderAverage,_traderLastNotional,_traderScore,_totalScore) = {
166+ let totalScoreInPeriodKey = getTotalScoreInPeriodKey(_amm, _weekId)
167+ let traderScoreInPeriodKey = getTraderScoreInPeriodKey(_amm, _trader, _weekId)
168+ let lastDateInPeriodKey = getLastDateInPeriodKey(_amm, _trader, _weekId)
169+ let lastNotionalKey = getLastNotionalKey(_amm, _trader)
170+ let traderAverageNotionalInPeriodKey = getTraderAverageNotionalInPeriodKey(_amm, _trader, _weekId)
171+[IntegerEntry(totalScoreInPeriodKey, _totalScore), IntegerEntry(traderScoreInPeriodKey, _traderScore), IntegerEntry(lastDateInPeriodKey, _traderLastDateInPeriod), IntegerEntry(lastNotionalKey, _traderLastNotional), IntegerEntry(traderAverageNotionalInPeriodKey, _traderAverage)]
172+ }
173+
174+
175+func usdnToDecimals (_amount) = (_amount * 100)
176+
177+
178+func getWeekStart (_weekId) = (_weekId * MS_IN_WEEK)
179+
180+
181+func getWeekEnd (_weekId) = ((_weekId + 1) * MS_IN_WEEK)
182+
183+
184+func getWeekId (_ts) = (_ts / MS_IN_WEEK)
185+
186+
187+func getFeesInPeriod (_amm,_trader,_weekId) = {
188+ let key = getFeesInPeriodKey(_amm, _trader, _weekId)
189+ valueOrElse(getInteger(this, key), 0)
190+ }
191+
192+
193+func getTotalFeesInPeriod (_amm,_weekId) = {
194+ let key = getTotalFeesInPeriodKey(_amm, _weekId)
195+ valueOrElse(getInteger(this, key), 0)
196+ }
197+
198+
199+func getLastNotional (_amm,_trader) = {
200+ let key = getLastNotionalKey(_amm, _trader)
201+ valueOrElse(getInteger(this, key), 0)
202+ }
203+
204+
205+func getLastDateInPeriod (_amm,_trader,_weekId,_weekStart) = {
206+ let key = getLastDateInPeriodKey(_amm, _trader, _weekId)
207+ valueOrElse(getInteger(this, key), _weekStart)
208+ }
209+
210+
211+func getTraderScoreInPeriod (_amm,_trader,_weekId) = {
212+ let key = getTraderScoreInPeriodKey(_amm, _trader, _weekId)
213+ valueOrElse(getInteger(this, key), 0)
214+ }
215+
216+
217+func getTotalScoreInPeriod (_amm,_weekId) = {
218+ let key = getTotalScoreInPeriodKey(_amm, _weekId)
219+ valueOrElse(getInteger(this, key), 0)
220+ }
221+
222+
223+func getAmms () = strToList(valueOrElse(getString(this, k_amms), ""))
224+
225+
226+func getRewardAssetIds () = strToList(valueOrElse(getString(this, k_rewardAssetIds), ""))
227+
228+
229+func getAmmRewardRate (_amm,_assetId) = {
230+ let key = getAmmRewardRateKey(_amm, _assetId)
231+ valueOrElse(getInteger(this, key), 0)
232+ }
233+
234+
235+func getAmmMaxAmountPerPeriod (_amm,_assetId) = {
236+ let key = getAmmMaxAmountPerPeriodKey(_amm, _assetId)
237+ valueOrElse(getInteger(this, key), 0)
238+ }
239+
240+
241+func getRewardAssetPrice (_assetId,_weekId) = {
242+ let oracleAddressStr = valueOrErrorMessage(getString(this, k_oracleAddress), "Oracle not set")
243+ let oracleAddress = valueOrErrorMessage(addressFromString(oracleAddressStr), "Invalid oracle address")
244+ let priceKey = getOraclePriceKey(_assetId, _weekId)
245+ usdnToDecimals(valueOrErrorMessage(getInteger(oracleAddress, priceKey), ((("No oracle price for asset " + _assetId) + " period ") + toString(_weekId))))
246+ }
247+
248+
249+func rewardForTraderInAssetInPeriod (_amm,_trader,_assetId,_weekId) = {
250+ let rewardAssetRate = getAmmRewardRate(_amm, _assetId)
251+ if ((rewardAssetRate == 0))
252+ then 0
253+ else {
254+ let totalFeesInPeriod = getTotalFeesInPeriod(_amm, _weekId)
255+ let rewardAssetPrice = getRewardAssetPrice(_assetId, _weekId)
256+ let maxAmountOfAssetToDistribute = getAmmMaxAmountPerPeriod(_amm, _assetId)
257+ let traderScore = getTraderScoreInPeriod(_amm, _trader, _weekId)
258+ let totalTraderScore = getTotalScoreInPeriod(_amm, _weekId)
259+ if ((totalTraderScore == 0))
260+ then 0
261+ else {
262+ let totalAssetToDistribute = muld(divd(totalFeesInPeriod, rewardAssetPrice), rewardAssetRate)
263+ let actualTotalAssetToDistribute = minv(totalAssetToDistribute, maxAmountOfAssetToDistribute)
264+ let traderShareInRewards = divd(muld(actualTotalAssetToDistribute, traderScore), totalTraderScore)
265+ traderShareInRewards
266+ }
267+ }
268+ }
269+
270+
271+func totalRewardForTraderInAssetInPeriod (_trader,_assetId,_weekId) = {
272+ let amms = getAmms()
273+ func compute (_acc,_amm) = (_acc + rewardForTraderInAssetInPeriod(_amm, _trader, _assetId, _weekId))
274+
275+ let $l = amms
276+ let $s = size($l)
277+ let $acc0 = 0
278+ func $f0_1 ($a,$i) = if (($i >= $s))
279+ then $a
280+ else compute($a, $l[$i])
281+
282+ func $f0_2 ($a,$i) = if (($i >= $s))
283+ then $a
284+ else throw("List size exceeds 20")
285+
286+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20)
287+ }
288+
289+
290+func totalRewardForTraderInAsset (_trader,_assetId,_periods) = {
291+ func compute (_acc,_weekId) = (_acc + totalRewardForTraderInAssetInPeriod(_trader, _assetId, _weekId))
292+
293+ let $l = _periods
294+ let $s = size($l)
295+ let $acc0 = 0
296+ func $f0_1 ($a,$i) = if (($i >= $s))
297+ then $a
298+ else compute($a, $l[$i])
299+
300+ func $f0_2 ($a,$i) = if (($i >= $s))
301+ then $a
302+ else throw("List size exceeds 10")
303+
304+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
305+ }
306+
307+
308+func isClaimed (_trader,_assetId,_period) = {
309+ let key = getClaimedTraderAssetPeriodKey(_trader, _assetId, _period)
310+ valueOrElse(getBoolean(this, key), false)
311+ }
312+
313+
314+@Callable(i)
315+func initialize (_coordinator,_oracle) = if (initialized())
316+ then throw("Already initialized")
317+ else [StringEntry(k_coordinatorAddress, _coordinator), StringEntry(k_oracleAddress, _oracle), BooleanEntry(k_initialized, true)]
318+
319+
320+
321+@Callable(i)
322+func view_claimRewards (_trader,_assetId,_period) = throw(toString(totalRewardForTraderInAsset(_trader, _assetId, [_period])))
323+
324+
325+
326+@Callable(i)
327+func claimRewards (_assetId,_period) = {
328+ let trader = toString(i.caller)
329+ if (isClaimed(trader, _assetId, _period))
330+ then throw("Already claimed")
331+ else {
332+ let currentWeekId = getWeekId(lastBlock.timestamp)
333+ if ((_period >= currentWeekId))
334+ then throw(("Unable to claim rewards in future periods, current period is " + toString(currentWeekId)))
335+ else {
336+ let amount = totalRewardForTraderInAsset(trader, _assetId, [_period])
337+ if ((amount == 0))
338+ then throw("Nothing to claim")
339+ else [ScriptTransfer(i.caller, amount, fromBase58String(_assetId)), BooleanEntry(getClaimedTraderAssetPeriodKey(trader, _assetId, _period), true)]
340+ }
341+ }
342+ }
343+
344+
345+
346+@Callable(i)
347+func attachRewards (_amm,_assetId,_maxAmountPerPeriod,_rewardRate) = if (if (!(initialized()))
348+ then true
349+ else (i.caller != adminAddress()))
350+ then throw("Invalid attachRewards params")
351+ else {
352+ let amms = getAmms()
353+ let rewardAssetIds = getRewardAssetIds()
354+ let newAmms = if (containsElement(amms, _amm))
355+ then amms
356+ else (amms :+ _amm)
357+ let newRewardAssetIds = if (containsElement(rewardAssetIds, _assetId))
358+ then rewardAssetIds
359+ else (rewardAssetIds :+ _assetId)
360+[IntegerEntry(getAmmRewardRateKey(_amm, _assetId), _rewardRate), IntegerEntry(getAmmMaxAmountPerPeriodKey(_amm, _assetId), _maxAmountPerPeriod), StringEntry(k_amms, listToStr(newAmms)), StringEntry(k_rewardAssetIds, listToStr(newRewardAssetIds))]
361+ }
362+
363+
364+
365+@Callable(i)
366+func notifyFees (_trader,_fee) = {
367+ let amm = toString(i.caller)
368+ if (if (!(isWhitelist(amm)))
369+ then true
370+ else !(initialized()))
371+ then throw("Invalid notifyFees params")
372+ else {
373+ let actualFee = usdnToDecimals(_fee)
374+ let ts = lastBlock.timestamp
375+ let weekId = getWeekId(ts)
376+ let feesInPeriod = getFeesInPeriod(amm, _trader, weekId)
377+ let totalFeesInPeriod = getTotalFeesInPeriod(amm, weekId)
378+ let newFeesInPeriod = (feesInPeriod + actualFee)
379+ let newTotalFeesInPeriod = (totalFeesInPeriod + actualFee)
380+ updateAmmFees(amm, _trader, weekId, newFeesInPeriod, newTotalFeesInPeriod)
381+ }
382+ }
383+
384+
385+
386+@Callable(i)
387+func notifyNotional (_trader,_notional) = {
388+ let amm = toString(i.caller)
389+ if (if (!(isWhitelist(amm)))
390+ then true
391+ else !(initialized()))
392+ then throw("Invalid notifyNotional params")
393+ else {
394+ let actualNotional = usdnToDecimals(_notional)
395+ let ts = lastBlock.timestamp
396+ let lastNotional = getLastNotional(amm, _trader)
397+ let weekId = getWeekId(ts)
398+ let weekStart = getWeekStart(weekId)
399+ let weekEnd = getWeekEnd(weekId)
400+ let t = (weekEnd - weekStart)
401+ let lastDateInPeriod = getLastDateInPeriod(amm, _trader, weekId, weekStart)
402+ let dt = (ts - lastDateInPeriod)
403+ let oldTraderAmmScore = getTraderScoreInPeriod(amm, _trader, weekId)
404+ let oldTotalAmmScore = getTotalScoreInPeriod(amm, weekId)
405+ let fees = getFeesInPeriod(amm, _trader, weekId)
406+ let newRunningAverage = (muld(lastNotional, divd(dt, t)) + muld(actualNotional, divd((t - dt), t)))
407+ let newTraderAmmScore = muld(powd(fees, A), powd(newRunningAverage, (DECIMAL_UNIT - A)))
408+ let newTotalAmmScoreInPeriod = ((oldTotalAmmScore - oldTraderAmmScore) + newTraderAmmScore)
409+ updateAmmData(amm, _trader, weekId, ts, newRunningAverage, actualNotional, newTraderAmmScore, newTotalAmmScoreInPeriod)
410+ }
411+ }
412+
413+
414+@Verifier(tx)
415+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
416+

github/deemru/w8io/03bedc9 
27.17 ms