tx · EWbphkhY6NbbuezqiPaYC3aVbUXB9C94t2kLetQdLB8R 3MrMbQwr3cpCvWMWCFjqUZzqRgxg8En6Jd5: -0.03700000 Waves 2022.11.17 00:39 [2320226] smart account 3MrMbQwr3cpCvWMWCFjqUZzqRgxg8En6Jd5 > SELF 0.00000000 Waves
{ "type": 13, "id": "EWbphkhY6NbbuezqiPaYC3aVbUXB9C94t2kLetQdLB8R", "fee": 3700000, "feeAssetId": null, "timestamp": 1668634849052, "version": 2, "chainId": 84, "sender": "3MrMbQwr3cpCvWMWCFjqUZzqRgxg8En6Jd5", "senderPublicKey": "8WTLBzi1s9cZm76TPZ9czV6poaHGWvpZ7sCBeTBaa7uh", "proofs": [ "657KrNmcitumekg7z3SGmTzN3a2eYraKMAKSwgrfxEL4ZLXUXTpocqoMeSD22vzNyAYZjniYudcz2XMJeNprMLj5" ], "script": "base64:BgJhCAISBAoCCAgSAwoBCBIAEgUKAwgIARIFCgMICAESBgoECAgIARIFCgMICAgSBQoDCAgBEgQKAggIEgMKAQgSBAoCCAESBQoDCAgBEgQKAggBEgQKAggBEgMKAQgSAwoBCGAAE2tfdG90YWxGZWVzSW5QZXJpb2QCE2tfdG90YWxGZWVzSW5QZXJpb2QAGGtfdG90YWxBc3NldEZlZXNJblBlcmlvZAIYa190b3RhbEFzc2V0RmVlc0luUGVyaW9kABRrX3RyYWRlckZlZXNJblBlcmlvZAIUa190cmFkZXJGZWVzSW5QZXJpb2QADmtfdHJhZGVyVm9sdW1lAg5rX3RyYWRlclZvbHVtZQAYa190cmFkZXJDdW11bGF0aXZlVm9sdW1lAhhrX3RyYWRlckN1bXVsYXRpdmVWb2x1bWUACmtfZmVlVGllcnMCCmtfZmVlVGllcnMADmtfbGFzdE5vdGlvbmFsAg5rX2xhc3ROb3Rpb25hbAAUa190b3RhbFNjb3JlSW5QZXJpb2QCFGtfdG90YWxTY29yZUluUGVyaW9kABVrX3RyYWRlclNjb3JlSW5QZXJpb2QCFWtfdHJhZGVyU2Nvc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G5ld1RvdGFsQW1tU2NvcmVJblBlcmlvZAkAZAIJAGUCBRBvbGRUb3RhbEFtbVNjb3JlBRFvbGRUcmFkZXJBbW1TY29yZQURbmV3VHJhZGVyQW1tU2NvcmUJAM4IAgkBDXVwZGF0ZUFtbURhdGEHBQNhbW0FB190cmFkZXIFBndlZWtJZAURbmV3UnVubmluZ0F2ZXJhZ2UFDmFjdHVhbE5vdGlvbmFsBRFuZXdUcmFkZXJBbW1TY29yZQUYbmV3VG90YWxBbW1TY29yZUluUGVyaW9kCQESdXBkYXRlVHJhZGVyVm9sdW1lAwUHX3RyYWRlcgUFZGF5SWQJAQNhYnMBCQBlAgUMbGFzdE5vdGlvbmFsBQ5hY3R1YWxOb3Rpb25hbAFpARJjb21wdXRlRmVlRGlzY291bnQBB190cmFkZXIEBnJlc3VsdAkBDmdldEZlZURpc2NvdW50AQUHX3RyYWRlcgkAlAoCBQNuaWwFBnJlc3VsdAFpARd2aWV3X2NvbXB1dGVGZWVEaXNjb3VudAEHX3RyYWRlcgQGcmVzdWx0CQEOZ2V0RmVlRGlzY291bnQBBQdfdHJhZGVyCQACAQkApAMBBQZyZXN1bHQBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACQEOYWRtaW5QdWJsaWNLZXkA3++/jg==", "height": 2320226, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EDrsrCohnbqjcYv1twZd3muUK2gx5Mm9sA5ifkbWPa1e Next: DXj6csFNKmpdJqa7tq74Av6XU1rjhv83vKH4USbxesXU Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | let k_totalAssetFeesInPeriod = "k_totalAssetFeesInPeriod" | |
7 | 7 | ||
8 | 8 | let k_traderFeesInPeriod = "k_traderFeesInPeriod" | |
9 | + | ||
10 | + | let k_traderVolume = "k_traderVolume" | |
11 | + | ||
12 | + | let k_traderCumulativeVolume = "k_traderCumulativeVolume" | |
13 | + | ||
14 | + | let k_feeTiers = "k_feeTiers" | |
9 | 15 | ||
10 | 16 | let k_lastNotional = "k_lastNotional" | |
11 | 17 | ||
52 | 58 | let A = 70000000 | |
53 | 59 | ||
54 | 60 | let MS_IN_WEEK = (1000 * 604800) | |
61 | + | ||
62 | + | let MS_IN_DAY = (1000 * 86400) | |
63 | + | ||
64 | + | let NO_DISCOUNT = (DECIMAL_UNIT / 100) | |
55 | 65 | ||
56 | 66 | func listToStr (_list) = { | |
57 | 67 | func _join (accumulator,val) = ((accumulator + val) + ",") | |
133 | 143 | ||
134 | 144 | let TIME = lastBlock.timestamp | |
135 | 145 | ||
146 | + | func getTraderVolumeKey (_trader,_dayId) = ((((k_traderVolume + "_") + _trader) + "_") + toString(_dayId)) | |
147 | + | ||
148 | + | ||
149 | + | func getTraderCumulativeVolumeKey (_trader) = ((k_traderCumulativeVolume + "_") + _trader) | |
150 | + | ||
151 | + | ||
136 | 152 | func getTraderFeesInPeriodKey (_amm,_trader,_weekId) = ((((((k_traderFeesInPeriod + "_") + _amm) + "_") + _trader) + "_") + toString(_weekId)) | |
137 | 153 | ||
138 | 154 | ||
182 | 198 | ||
183 | 199 | ||
184 | 200 | func getWeekId (_ts) = (_ts / MS_IN_WEEK) | |
201 | + | ||
202 | + | ||
203 | + | func getDayId (_ts) = (_ts / MS_IN_DAY) | |
204 | + | ||
205 | + | ||
206 | + | func getFeeTiers () = { | |
207 | + | let storedTiers = valueOrElse(getString(this, k_feeTiers), "") | |
208 | + | if ((storedTiers == "")) | |
209 | + | then nil | |
210 | + | else { | |
211 | + | let tiers = split(valueOrElse(getString(this, k_feeTiers), ""), ",") | |
212 | + | func toFeeTier (_acc,_tier) = { | |
213 | + | let tierSplit = split(_tier, ":") | |
214 | + | let minCumulativeVolume = parseIntValue(tierSplit[0]) | |
215 | + | let discount = parseIntValue(tierSplit[1]) | |
216 | + | (_acc :+ $Tuple2(minCumulativeVolume, discount)) | |
217 | + | } | |
218 | + | ||
219 | + | let $l = tiers | |
220 | + | let $s = size($l) | |
221 | + | let $acc0 = nil | |
222 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
223 | + | then $a | |
224 | + | else toFeeTier($a, $l[$i]) | |
225 | + | ||
226 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
227 | + | then $a | |
228 | + | else throw("List size exceeds 10") | |
229 | + | ||
230 | + | $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) | |
231 | + | } | |
232 | + | } | |
233 | + | ||
234 | + | ||
235 | + | func getTraderVolume (_trader,_dayId) = { | |
236 | + | let key = getTraderVolumeKey(_trader, _dayId) | |
237 | + | valueOrElse(getInteger(this, key), 0) | |
238 | + | } | |
239 | + | ||
240 | + | ||
241 | + | func getTraderCumulativeVolume (_trader) = { | |
242 | + | let key = getTraderCumulativeVolumeKey(_trader) | |
243 | + | valueOrElse(getInteger(this, key), 0) | |
244 | + | } | |
185 | 245 | ||
186 | 246 | ||
187 | 247 | func getFeesInPeriod (_amm,_trader,_weekId) = { | |
283 | 343 | let traderShareInRewards = divd(muld(actualTotalAssetToDistribute, traderScore), totalTraderScore) | |
284 | 344 | traderShareInRewards | |
285 | 345 | } | |
346 | + | } | |
347 | + | } | |
348 | + | ||
349 | + | ||
350 | + | func rewardForAmmInAssetInPeriod (_amm,_assetId,_weekId) = { | |
351 | + | let rewardAssetRate = getAmmRewardRate(_amm, _assetId) | |
352 | + | if ((rewardAssetRate == 0)) | |
353 | + | then 0 | |
354 | + | else { | |
355 | + | let totalFeesInPeriod = getTotalFeesInPeriod(_amm, _weekId) | |
356 | + | let rewardAssetPrice = getRewardAssetPrice(_assetId, _weekId) | |
357 | + | let maxAmountOfAssetToDistribute = getMaxAmountOfAssetToDistribute(_amm, _assetId, _weekId) | |
358 | + | let totalAssetToDistribute = divd(muld(totalFeesInPeriod, rewardAssetRate), rewardAssetPrice) | |
359 | + | let actualTotalAssetToDistribute = minv(totalAssetToDistribute, maxAmountOfAssetToDistribute) | |
360 | + | actualTotalAssetToDistribute | |
286 | 361 | } | |
287 | 362 | } | |
288 | 363 | ||
391 | 466 | } | |
392 | 467 | ||
393 | 468 | ||
469 | + | func updateTraderVolume (_trader,_dayId,_generatedVolume) = { | |
470 | + | let actualDayVolume = (getTraderVolume(_trader, _dayId) + _generatedVolume) | |
471 | + | let daysBefore = [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] | |
472 | + | func updateCumulativeVolume (_acc,_minusDay) = (_acc + getTraderVolume(_trader, (_dayId - _minusDay))) | |
473 | + | ||
474 | + | let cumulativeVolume = { | |
475 | + | let $l = daysBefore | |
476 | + | let $s = size($l) | |
477 | + | let $acc0 = 0 | |
478 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
479 | + | then $a | |
480 | + | else updateCumulativeVolume($a, $l[$i]) | |
481 | + | ||
482 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
483 | + | then $a | |
484 | + | else throw("List size exceeds 30") | |
485 | + | ||
486 | + | $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($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) | |
487 | + | } | |
488 | + | [IntegerEntry(getTraderVolumeKey(_trader, _dayId), actualDayVolume), IntegerEntry(getTraderCumulativeVolumeKey(_trader), (cumulativeVolume + actualDayVolume))] | |
489 | + | } | |
490 | + | ||
491 | + | ||
394 | 492 | func updateAmmFees (_amm,_trader,_weekId,_actualFee) = { | |
395 | 493 | let traderFeesKey = getTraderFeesInPeriodKey(_amm, _trader, _weekId) | |
396 | 494 | let totalFeesKey = getTotalAmmFeesInPeriodKey(_amm, _weekId) | |
433 | 531 | let lastNotionalKey = getLastNotionalKey(_amm, _trader) | |
434 | 532 | let traderAverageNotionalInPeriodKey = getTraderAverageNotionalInPeriodKey(_amm, _trader, _weekId) | |
435 | 533 | [IntegerEntry(totalScoreInPeriodKey, _totalScore), IntegerEntry(traderScoreInPeriodKey, _traderScore), IntegerEntry(lastNotionalKey, _traderLastNotional), IntegerEntry(traderAverageNotionalInPeriodKey, _traderAverage)] | |
534 | + | } | |
535 | + | ||
536 | + | ||
537 | + | func getFeeDiscount (_trader) = { | |
538 | + | let tiers = getFeeTiers() | |
539 | + | let cumulativeVolume = getTraderCumulativeVolume(_trader) | |
540 | + | func findFee (_acc,_tier) = { | |
541 | + | let $t01644516488 = _tier | |
542 | + | let minCumulativeVolume = $t01644516488._1 | |
543 | + | let discount = $t01644516488._2 | |
544 | + | if ((cumulativeVolume >= minCumulativeVolume)) | |
545 | + | then [discount] | |
546 | + | else _acc | |
547 | + | } | |
548 | + | ||
549 | + | let resultList = { | |
550 | + | let $l = tiers | |
551 | + | let $s = size($l) | |
552 | + | let $acc0 = [NO_DISCOUNT] | |
553 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
554 | + | then $a | |
555 | + | else findFee($a, $l[$i]) | |
556 | + | ||
557 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
558 | + | then $a | |
559 | + | else throw("List size exceeds 5") | |
560 | + | ||
561 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
562 | + | } | |
563 | + | resultList[0] | |
436 | 564 | } | |
437 | 565 | ||
438 | 566 | ||
486 | 614 | ||
487 | 615 | ||
488 | 616 | @Callable(i) | |
617 | + | func view_earnedRewards (_amm,_assetId,_period) = { | |
618 | + | let result = rewardForAmmInAssetInPeriod(_amm, _assetId, _period) | |
619 | + | throw(toString(result)) | |
620 | + | } | |
621 | + | ||
622 | + | ||
623 | + | ||
624 | + | @Callable(i) | |
489 | 625 | func claimAllRewards (_assetId,_periods) = { | |
490 | 626 | let trader = toString(i.caller) | |
491 | 627 | if (contains(_periods, toString(getWeekId(TIME)))) | |
492 | 628 | then throw("Can not claim rewards for current week") | |
493 | 629 | else { | |
494 | - | let $ | |
495 | - | let amount = $ | |
496 | - | let result = $ | |
630 | + | let $t01890718990 = claimAllRewardForPeriodForTrader(trader, _assetId, _periods) | |
631 | + | let amount = $t01890718990._1 | |
632 | + | let result = $t01890718990._2 | |
497 | 633 | if ((amount == 0)) | |
498 | 634 | then throw("Nothing to claim") | |
499 | 635 | else result | |
500 | 636 | } | |
501 | 637 | } | |
638 | + | ||
639 | + | ||
640 | + | ||
641 | + | @Callable(i) | |
642 | + | func setFeeDiscountTiers (_discounts) = if (if (!(initialized())) | |
643 | + | then true | |
644 | + | else (i.caller != adminAddress())) | |
645 | + | then throw("Invalid setFeeDiscountTiers params") | |
646 | + | else [StringEntry(k_feeTiers, _discounts)] | |
502 | 647 | ||
503 | 648 | ||
504 | 649 | ||
566 | 711 | let actualNotional = usdnToDecimals(_notional) | |
567 | 712 | let lastNotional = getLastNotional(amm, _trader) | |
568 | 713 | let weekId = getWeekId(TIME) | |
714 | + | let dayId = getDayId(TIME) | |
569 | 715 | let weekStart = getWeekStart(weekId) | |
570 | 716 | let weekEnd = getWeekEnd(weekId) | |
571 | 717 | let t = (weekEnd - weekStart) | |
577 | 723 | let newRunningAverage = ((oldRunningAverage + muld(actualNotional, w)) - muld(lastNotional, w)) | |
578 | 724 | let newTraderAmmScore = muld(powd(fees, A), powd(newRunningAverage, (DECIMAL_UNIT - A))) | |
579 | 725 | let newTotalAmmScoreInPeriod = ((oldTotalAmmScore - oldTraderAmmScore) + newTraderAmmScore) | |
580 | - | updateAmmData(amm, _trader, weekId, newRunningAverage, actualNotional, newTraderAmmScore, newTotalAmmScoreInPeriod) | |
726 | + | (updateAmmData(amm, _trader, weekId, newRunningAverage, actualNotional, newTraderAmmScore, newTotalAmmScoreInPeriod) ++ updateTraderVolume(_trader, dayId, abs((lastNotional - actualNotional)))) | |
581 | 727 | } | |
728 | + | } | |
729 | + | ||
730 | + | ||
731 | + | ||
732 | + | @Callable(i) | |
733 | + | func computeFeeDiscount (_trader) = { | |
734 | + | let result = getFeeDiscount(_trader) | |
735 | + | $Tuple2(nil, result) | |
736 | + | } | |
737 | + | ||
738 | + | ||
739 | + | ||
740 | + | @Callable(i) | |
741 | + | func view_computeFeeDiscount (_trader) = { | |
742 | + | let result = getFeeDiscount(_trader) | |
743 | + | throw(toString(result)) | |
582 | 744 | } | |
583 | 745 | ||
584 | 746 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_totalFeesInPeriod = "k_totalFeesInPeriod" | |
5 | 5 | ||
6 | 6 | let k_totalAssetFeesInPeriod = "k_totalAssetFeesInPeriod" | |
7 | 7 | ||
8 | 8 | let k_traderFeesInPeriod = "k_traderFeesInPeriod" | |
9 | + | ||
10 | + | let k_traderVolume = "k_traderVolume" | |
11 | + | ||
12 | + | let k_traderCumulativeVolume = "k_traderCumulativeVolume" | |
13 | + | ||
14 | + | let k_feeTiers = "k_feeTiers" | |
9 | 15 | ||
10 | 16 | let k_lastNotional = "k_lastNotional" | |
11 | 17 | ||
12 | 18 | let k_totalScoreInPeriod = "k_totalScoreInPeriod" | |
13 | 19 | ||
14 | 20 | let k_traderScoreInPeriod = "k_traderScoreInPeriod" | |
15 | 21 | ||
16 | 22 | let k_traderAverageNotionalInPeriod = "k_traderAverageNotionalInPeriod" | |
17 | 23 | ||
18 | 24 | let k_ammRewardRate = "k_ammRewardRate" | |
19 | 25 | ||
20 | 26 | let k_assetMaxAmountPerPeriod = "k_assetMaxAmountPerPeriod" | |
21 | 27 | ||
22 | 28 | let k_rewardAssetIds = "k_rewardAssetIds" | |
23 | 29 | ||
24 | 30 | let k_amms = "k_amms" | |
25 | 31 | ||
26 | 32 | let k_claimedAssetAndPeriod = "k_claimedAssetAndPeriod" | |
27 | 33 | ||
28 | 34 | let k_oracleAddress = "k_oracleAddress" | |
29 | 35 | ||
30 | 36 | let k_oraclePrice = "price" | |
31 | 37 | ||
32 | 38 | let k_totalClaimedForTraderAndAsset = "k_totalClaimedForTraderAndAsset" | |
33 | 39 | ||
34 | 40 | let k_ammMaxAmountPerPeriod = "k_ammMaxAmountPerPeriod" | |
35 | 41 | ||
36 | 42 | let k_initialized = "k_initialized" | |
37 | 43 | ||
38 | 44 | let k_coordinatorAddress = "k_coordinatorAddress" | |
39 | 45 | ||
40 | 46 | let k_governance_asset = "k_gov_asset" | |
41 | 47 | ||
42 | 48 | let k_quote_asset = "k_quote_asset" | |
43 | 49 | ||
44 | 50 | let k_admin_public_key = "k_admin_public_key" | |
45 | 51 | ||
46 | 52 | let k_admin_address = "k_admin_address" | |
47 | 53 | ||
48 | 54 | let k_amm = "k_amm" | |
49 | 55 | ||
50 | 56 | let DECIMAL_UNIT = (1 * (((((((10 * 10) * 10) * 10) * 10) * 10) * 10) * 10)) | |
51 | 57 | ||
52 | 58 | let A = 70000000 | |
53 | 59 | ||
54 | 60 | let MS_IN_WEEK = (1000 * 604800) | |
61 | + | ||
62 | + | let MS_IN_DAY = (1000 * 86400) | |
63 | + | ||
64 | + | let NO_DISCOUNT = (DECIMAL_UNIT / 100) | |
55 | 65 | ||
56 | 66 | func listToStr (_list) = { | |
57 | 67 | func _join (accumulator,val) = ((accumulator + val) + ",") | |
58 | 68 | ||
59 | 69 | let newListStr = { | |
60 | 70 | let $l = _list | |
61 | 71 | let $s = size($l) | |
62 | 72 | let $acc0 = "" | |
63 | 73 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
64 | 74 | then $a | |
65 | 75 | else _join($a, $l[$i]) | |
66 | 76 | ||
67 | 77 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
68 | 78 | then $a | |
69 | 79 | else throw("List size exceeds 100") | |
70 | 80 | ||
71 | 81 | $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) | |
72 | 82 | } | |
73 | 83 | let newListStrU = dropRight(newListStr, 1) | |
74 | 84 | let newListStrR = if ((take(newListStrU, 1) == ",")) | |
75 | 85 | then drop(newListStrU, 1) | |
76 | 86 | else newListStrU | |
77 | 87 | newListStrR | |
78 | 88 | } | |
79 | 89 | ||
80 | 90 | ||
81 | 91 | func strToList (_str) = if ((_str == "")) | |
82 | 92 | then nil | |
83 | 93 | else split(_str, ",") | |
84 | 94 | ||
85 | 95 | ||
86 | 96 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
87 | 97 | ||
88 | 98 | ||
89 | 99 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
90 | 100 | ||
91 | 101 | ||
92 | 102 | func powd (_x,_y) = pow(_x, 8, _y, 8, 8, HALFEVEN) | |
93 | 103 | ||
94 | 104 | ||
95 | 105 | func abs (_x) = if ((_x > 0)) | |
96 | 106 | then _x | |
97 | 107 | else -(_x) | |
98 | 108 | ||
99 | 109 | ||
100 | 110 | func minv (_x,_y) = if ((_x > _y)) | |
101 | 111 | then _y | |
102 | 112 | else _x | |
103 | 113 | ||
104 | 114 | ||
105 | 115 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
106 | 116 | ||
107 | 117 | ||
108 | 118 | let that = this | |
109 | 119 | ||
110 | 120 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(that, k_coordinatorAddress)), "Coordinator not set") | |
111 | 121 | ||
112 | 122 | ||
113 | 123 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
114 | 124 | ||
115 | 125 | ||
116 | 126 | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
117 | 127 | ||
118 | 128 | ||
119 | 129 | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
120 | 130 | ||
121 | 131 | ||
122 | 132 | func int (k) = valueOrErrorMessage(getInteger(that, k), ("no value for " + k)) | |
123 | 133 | ||
124 | 134 | ||
125 | 135 | func int0 (k) = valueOrElse(getInteger(that, k), 0) | |
126 | 136 | ||
127 | 137 | ||
128 | 138 | func initialized () = valueOrElse(getBoolean(that, k_initialized), false) | |
129 | 139 | ||
130 | 140 | ||
131 | 141 | func getRewardAssetIds () = strToList(valueOrElse(getString(that, k_rewardAssetIds), "")) | |
132 | 142 | ||
133 | 143 | ||
134 | 144 | let TIME = lastBlock.timestamp | |
135 | 145 | ||
146 | + | func getTraderVolumeKey (_trader,_dayId) = ((((k_traderVolume + "_") + _trader) + "_") + toString(_dayId)) | |
147 | + | ||
148 | + | ||
149 | + | func getTraderCumulativeVolumeKey (_trader) = ((k_traderCumulativeVolume + "_") + _trader) | |
150 | + | ||
151 | + | ||
136 | 152 | func getTraderFeesInPeriodKey (_amm,_trader,_weekId) = ((((((k_traderFeesInPeriod + "_") + _amm) + "_") + _trader) + "_") + toString(_weekId)) | |
137 | 153 | ||
138 | 154 | ||
139 | 155 | func getTotalAmmFeesInPeriodKey (_amm,_weekId) = ((((k_totalFeesInPeriod + "_") + _amm) + "_") + toString(_weekId)) | |
140 | 156 | ||
141 | 157 | ||
142 | 158 | func getTotalAssetFeesInPeriodKey (_assetId,_weekId) = ((((k_totalAssetFeesInPeriod + "_") + _assetId) + "_") + toString(_weekId)) | |
143 | 159 | ||
144 | 160 | ||
145 | 161 | func getLastNotionalKey (_amm,_trader) = ((((k_lastNotional + "_") + _amm) + "_") + _trader) | |
146 | 162 | ||
147 | 163 | ||
148 | 164 | func getTraderScoreInPeriodKey (_amm,_trader,_weekId) = ((((((k_traderScoreInPeriod + "_") + _amm) + "_") + _trader) + "_") + toString(_weekId)) | |
149 | 165 | ||
150 | 166 | ||
151 | 167 | func getTotalScoreInPeriodKey (_amm,_weekId) = ((((k_totalScoreInPeriod + "_") + _amm) + "_") + toString(_weekId)) | |
152 | 168 | ||
153 | 169 | ||
154 | 170 | func getTraderAverageNotionalInPeriodKey (_amm,_trader,_weekId) = ((((((k_traderAverageNotionalInPeriod + "_") + _amm) + "_") + _trader) + "_") + toString(_weekId)) | |
155 | 171 | ||
156 | 172 | ||
157 | 173 | func getAmmRewardRateKey (_amm,_assetId) = ((((k_ammRewardRate + "_") + _amm) + "_") + _assetId) | |
158 | 174 | ||
159 | 175 | ||
160 | 176 | func getAssetMaxAmountPerPeriodKey (_assetId) = ((k_assetMaxAmountPerPeriod + "_") + _assetId) | |
161 | 177 | ||
162 | 178 | ||
163 | 179 | func getClaimedTraderAssetPeriodKey (_trader,_assetId,_period) = ((((((k_claimedAssetAndPeriod + "_") + _trader) + "_") + _assetId) + "_") + toString(_period)) | |
164 | 180 | ||
165 | 181 | ||
166 | 182 | func getOraclePriceKey (_assetId,_period) = ((((k_oraclePrice + "_") + toString(_period)) + "_") + _assetId) | |
167 | 183 | ||
168 | 184 | ||
169 | 185 | func getTotalClaimedForTraderAndAssetKey (_trader,_assetId) = ((((k_totalClaimedForTraderAndAsset + "_") + _trader) + "_") + _assetId) | |
170 | 186 | ||
171 | 187 | ||
172 | 188 | func getAmmMaxAmountPerPeriodKey (_amm,_assetId) = ((((k_ammMaxAmountPerPeriod + "_") + _amm) + "_") + _assetId) | |
173 | 189 | ||
174 | 190 | ||
175 | 191 | func usdnToDecimals (_amount) = (_amount * 100) | |
176 | 192 | ||
177 | 193 | ||
178 | 194 | func getWeekStart (_weekId) = (_weekId * MS_IN_WEEK) | |
179 | 195 | ||
180 | 196 | ||
181 | 197 | func getWeekEnd (_weekId) = ((_weekId + 1) * MS_IN_WEEK) | |
182 | 198 | ||
183 | 199 | ||
184 | 200 | func getWeekId (_ts) = (_ts / MS_IN_WEEK) | |
201 | + | ||
202 | + | ||
203 | + | func getDayId (_ts) = (_ts / MS_IN_DAY) | |
204 | + | ||
205 | + | ||
206 | + | func getFeeTiers () = { | |
207 | + | let storedTiers = valueOrElse(getString(this, k_feeTiers), "") | |
208 | + | if ((storedTiers == "")) | |
209 | + | then nil | |
210 | + | else { | |
211 | + | let tiers = split(valueOrElse(getString(this, k_feeTiers), ""), ",") | |
212 | + | func toFeeTier (_acc,_tier) = { | |
213 | + | let tierSplit = split(_tier, ":") | |
214 | + | let minCumulativeVolume = parseIntValue(tierSplit[0]) | |
215 | + | let discount = parseIntValue(tierSplit[1]) | |
216 | + | (_acc :+ $Tuple2(minCumulativeVolume, discount)) | |
217 | + | } | |
218 | + | ||
219 | + | let $l = tiers | |
220 | + | let $s = size($l) | |
221 | + | let $acc0 = nil | |
222 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
223 | + | then $a | |
224 | + | else toFeeTier($a, $l[$i]) | |
225 | + | ||
226 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
227 | + | then $a | |
228 | + | else throw("List size exceeds 10") | |
229 | + | ||
230 | + | $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) | |
231 | + | } | |
232 | + | } | |
233 | + | ||
234 | + | ||
235 | + | func getTraderVolume (_trader,_dayId) = { | |
236 | + | let key = getTraderVolumeKey(_trader, _dayId) | |
237 | + | valueOrElse(getInteger(this, key), 0) | |
238 | + | } | |
239 | + | ||
240 | + | ||
241 | + | func getTraderCumulativeVolume (_trader) = { | |
242 | + | let key = getTraderCumulativeVolumeKey(_trader) | |
243 | + | valueOrElse(getInteger(this, key), 0) | |
244 | + | } | |
185 | 245 | ||
186 | 246 | ||
187 | 247 | func getFeesInPeriod (_amm,_trader,_weekId) = { | |
188 | 248 | let key = getTraderFeesInPeriodKey(_amm, _trader, _weekId) | |
189 | 249 | int0(key) | |
190 | 250 | } | |
191 | 251 | ||
192 | 252 | ||
193 | 253 | func getTotalFeesInPeriod (_amm,_weekId) = { | |
194 | 254 | let key = getTotalAmmFeesInPeriodKey(_amm, _weekId) | |
195 | 255 | int0(key) | |
196 | 256 | } | |
197 | 257 | ||
198 | 258 | ||
199 | 259 | func getTotalAssetFeesInPeriod (_assetId,_weekId) = { | |
200 | 260 | let key = getTotalAssetFeesInPeriodKey(_assetId, _weekId) | |
201 | 261 | int0(key) | |
202 | 262 | } | |
203 | 263 | ||
204 | 264 | ||
205 | 265 | func getLastNotional (_amm,_trader) = { | |
206 | 266 | let key = getLastNotionalKey(_amm, _trader) | |
207 | 267 | int0(key) | |
208 | 268 | } | |
209 | 269 | ||
210 | 270 | ||
211 | 271 | func getTraderScoreInPeriod (_amm,_trader,_weekId) = { | |
212 | 272 | let key = getTraderScoreInPeriodKey(_amm, _trader, _weekId) | |
213 | 273 | int0(key) | |
214 | 274 | } | |
215 | 275 | ||
216 | 276 | ||
217 | 277 | func getTotalScoreInPeriod (_amm,_weekId) = { | |
218 | 278 | let key = getTotalScoreInPeriodKey(_amm, _weekId) | |
219 | 279 | int0(key) | |
220 | 280 | } | |
221 | 281 | ||
222 | 282 | ||
223 | 283 | func getAmms () = strToList(valueOrElse(getString(that, k_amms), "")) | |
224 | 284 | ||
225 | 285 | ||
226 | 286 | func getAmmRewardRate (_amm,_assetId) = { | |
227 | 287 | let key = getAmmRewardRateKey(_amm, _assetId) | |
228 | 288 | int0(key) | |
229 | 289 | } | |
230 | 290 | ||
231 | 291 | ||
232 | 292 | func getAssetMaxAmountPerPeriod (_assetId) = { | |
233 | 293 | let key = getAssetMaxAmountPerPeriodKey(_assetId) | |
234 | 294 | int0(key) | |
235 | 295 | } | |
236 | 296 | ||
237 | 297 | ||
238 | 298 | func getTotalClaimedForTraderAndAsset (_trader,_assetId) = { | |
239 | 299 | let key = getTotalClaimedForTraderAndAssetKey(_trader, _assetId) | |
240 | 300 | int0(key) | |
241 | 301 | } | |
242 | 302 | ||
243 | 303 | ||
244 | 304 | func getRewardAssetPrice (_assetId,_weekId) = { | |
245 | 305 | let oracleAddressStr = valueOrErrorMessage(getString(that, k_oracleAddress), "Oracle not set") | |
246 | 306 | let oracleAddress = valueOrErrorMessage(addressFromString(oracleAddressStr), "Invalid oracle address") | |
247 | 307 | let priceKey = getOraclePriceKey(_assetId, _weekId) | |
248 | 308 | usdnToDecimals(valueOrErrorMessage(getInteger(oracleAddress, priceKey), ((("No oracle price for asset " + _assetId) + " period ") + toString(_weekId)))) | |
249 | 309 | } | |
250 | 310 | ||
251 | 311 | ||
252 | 312 | func getMaxAmountOfAssetToDistribute (_amm,_assetId,_weekId) = { | |
253 | 313 | let totalFeesInPeriod = getTotalFeesInPeriod(_amm, _weekId) | |
254 | 314 | let totalAssetFeesInPeriod = getTotalAssetFeesInPeriod(_assetId, _weekId) | |
255 | 315 | if ((totalAssetFeesInPeriod == 0)) | |
256 | 316 | then { | |
257 | 317 | let key = getAmmMaxAmountPerPeriodKey(_amm, _assetId) | |
258 | 318 | int0(key) | |
259 | 319 | } | |
260 | 320 | else { | |
261 | 321 | let maxAmountOfAsset = getAssetMaxAmountPerPeriod(_assetId) | |
262 | 322 | let maxAmountOfAssetToDistribute = muld(divd(totalFeesInPeriod, totalAssetFeesInPeriod), maxAmountOfAsset) | |
263 | 323 | maxAmountOfAssetToDistribute | |
264 | 324 | } | |
265 | 325 | } | |
266 | 326 | ||
267 | 327 | ||
268 | 328 | func rewardForTraderInAssetInPeriod (_amm,_trader,_assetId,_weekId) = { | |
269 | 329 | let rewardAssetRate = getAmmRewardRate(_amm, _assetId) | |
270 | 330 | if ((rewardAssetRate == 0)) | |
271 | 331 | then 0 | |
272 | 332 | else { | |
273 | 333 | let totalFeesInPeriod = getTotalFeesInPeriod(_amm, _weekId) | |
274 | 334 | let rewardAssetPrice = getRewardAssetPrice(_assetId, _weekId) | |
275 | 335 | let maxAmountOfAssetToDistribute = getMaxAmountOfAssetToDistribute(_amm, _assetId, _weekId) | |
276 | 336 | let traderScore = getTraderScoreInPeriod(_amm, _trader, _weekId) | |
277 | 337 | let totalTraderScore = getTotalScoreInPeriod(_amm, _weekId) | |
278 | 338 | if ((totalTraderScore == 0)) | |
279 | 339 | then 0 | |
280 | 340 | else { | |
281 | 341 | let totalAssetToDistribute = divd(muld(totalFeesInPeriod, rewardAssetRate), rewardAssetPrice) | |
282 | 342 | let actualTotalAssetToDistribute = minv(totalAssetToDistribute, maxAmountOfAssetToDistribute) | |
283 | 343 | let traderShareInRewards = divd(muld(actualTotalAssetToDistribute, traderScore), totalTraderScore) | |
284 | 344 | traderShareInRewards | |
285 | 345 | } | |
346 | + | } | |
347 | + | } | |
348 | + | ||
349 | + | ||
350 | + | func rewardForAmmInAssetInPeriod (_amm,_assetId,_weekId) = { | |
351 | + | let rewardAssetRate = getAmmRewardRate(_amm, _assetId) | |
352 | + | if ((rewardAssetRate == 0)) | |
353 | + | then 0 | |
354 | + | else { | |
355 | + | let totalFeesInPeriod = getTotalFeesInPeriod(_amm, _weekId) | |
356 | + | let rewardAssetPrice = getRewardAssetPrice(_assetId, _weekId) | |
357 | + | let maxAmountOfAssetToDistribute = getMaxAmountOfAssetToDistribute(_amm, _assetId, _weekId) | |
358 | + | let totalAssetToDistribute = divd(muld(totalFeesInPeriod, rewardAssetRate), rewardAssetPrice) | |
359 | + | let actualTotalAssetToDistribute = minv(totalAssetToDistribute, maxAmountOfAssetToDistribute) | |
360 | + | actualTotalAssetToDistribute | |
286 | 361 | } | |
287 | 362 | } | |
288 | 363 | ||
289 | 364 | ||
290 | 365 | func totalRewardForTraderInAssetInPeriod (_trader,_assetId,_weekId) = { | |
291 | 366 | let amms = getAmms() | |
292 | 367 | func compute (_acc,_amm) = (_acc + rewardForTraderInAssetInPeriod(_amm, _trader, _assetId, _weekId)) | |
293 | 368 | ||
294 | 369 | let $l = amms | |
295 | 370 | let $s = size($l) | |
296 | 371 | let $acc0 = 0 | |
297 | 372 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
298 | 373 | then $a | |
299 | 374 | else compute($a, $l[$i]) | |
300 | 375 | ||
301 | 376 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
302 | 377 | then $a | |
303 | 378 | else throw("List size exceeds 20") | |
304 | 379 | ||
305 | 380 | $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) | |
306 | 381 | } | |
307 | 382 | ||
308 | 383 | ||
309 | 384 | func totalRewardForTraderInAsset (_trader,_assetId,_periods) = { | |
310 | 385 | func compute (_acc,_weekId) = (_acc + totalRewardForTraderInAssetInPeriod(_trader, _assetId, _weekId)) | |
311 | 386 | ||
312 | 387 | let $l = _periods | |
313 | 388 | let $s = size($l) | |
314 | 389 | let $acc0 = 0 | |
315 | 390 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
316 | 391 | then $a | |
317 | 392 | else compute($a, $l[$i]) | |
318 | 393 | ||
319 | 394 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
320 | 395 | then $a | |
321 | 396 | else throw("List size exceeds 12") | |
322 | 397 | ||
323 | 398 | $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($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12) | |
324 | 399 | } | |
325 | 400 | ||
326 | 401 | ||
327 | 402 | func getTraderAverageNotionalInPeriod (_amm,_trader,_weekId,_defaultValue) = { | |
328 | 403 | let key = getTraderAverageNotionalInPeriodKey(_amm, _trader, _weekId) | |
329 | 404 | valueOrElse(getInteger(that, key), _defaultValue) | |
330 | 405 | } | |
331 | 406 | ||
332 | 407 | ||
333 | 408 | func isClaimed (_trader,_assetId,_period) = { | |
334 | 409 | let key = getClaimedTraderAssetPeriodKey(_trader, _assetId, _period) | |
335 | 410 | valueOrElse(getBoolean(that, key), false) | |
336 | 411 | } | |
337 | 412 | ||
338 | 413 | ||
339 | 414 | func adjust (_amount,_assetId) = { | |
340 | 415 | let asset = valueOrErrorMessage(assetInfo(fromBase58String(_assetId)), "Invalid asset id") | |
341 | 416 | let decimals = asset.decimals | |
342 | 417 | if ((decimals == 6)) | |
343 | 418 | then (_amount / 100) | |
344 | 419 | else _amount | |
345 | 420 | } | |
346 | 421 | ||
347 | 422 | ||
348 | 423 | func claimAllRewardForPeriodForTrader (_trader,_assetId,_periods) = { | |
349 | 424 | let periods = strToList(_periods) | |
350 | 425 | func checkAndFilterFn (_acc,_next) = { | |
351 | 426 | let period = valueOrErrorMessage(parseInt(_next), ("Invalid period: " + _next)) | |
352 | 427 | if (if (containsElement(_acc, period)) | |
353 | 428 | then true | |
354 | 429 | else isClaimed(_trader, _assetId, period)) | |
355 | 430 | then _acc | |
356 | 431 | else (_acc :+ period) | |
357 | 432 | } | |
358 | 433 | ||
359 | 434 | let validPeriods = { | |
360 | 435 | let $l = periods | |
361 | 436 | let $s = size($l) | |
362 | 437 | let $acc0 = nil | |
363 | 438 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
364 | 439 | then $a | |
365 | 440 | else checkAndFilterFn($a, $l[$i]) | |
366 | 441 | ||
367 | 442 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
368 | 443 | then $a | |
369 | 444 | else throw("List size exceeds 12") | |
370 | 445 | ||
371 | 446 | $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($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12) | |
372 | 447 | } | |
373 | 448 | func markPeriodAsDoneFn (_acc,_period) = (_acc :+ BooleanEntry(getClaimedTraderAssetPeriodKey(_trader, _assetId, _period), true)) | |
374 | 449 | ||
375 | 450 | let markPeriodsAsClaimed = { | |
376 | 451 | let $l = validPeriods | |
377 | 452 | let $s = size($l) | |
378 | 453 | let $acc0 = nil | |
379 | 454 | func $f1_1 ($a,$i) = if (($i >= $s)) | |
380 | 455 | then $a | |
381 | 456 | else markPeriodAsDoneFn($a, $l[$i]) | |
382 | 457 | ||
383 | 458 | func $f1_2 ($a,$i) = if (($i >= $s)) | |
384 | 459 | then $a | |
385 | 460 | else throw("List size exceeds 16") | |
386 | 461 | ||
387 | 462 | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16) | |
388 | 463 | } | |
389 | 464 | let amount = totalRewardForTraderInAsset(_trader, _assetId, validPeriods) | |
390 | 465 | $Tuple2(amount, ([ScriptTransfer(addressFromStringValue(_trader), adjust(amount, _assetId), fromBase58String(_assetId)), IntegerEntry(getTotalClaimedForTraderAndAssetKey(_trader, _assetId), (getTotalClaimedForTraderAndAsset(_trader, _assetId) + amount))] ++ markPeriodsAsClaimed)) | |
391 | 466 | } | |
392 | 467 | ||
393 | 468 | ||
469 | + | func updateTraderVolume (_trader,_dayId,_generatedVolume) = { | |
470 | + | let actualDayVolume = (getTraderVolume(_trader, _dayId) + _generatedVolume) | |
471 | + | let daysBefore = [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] | |
472 | + | func updateCumulativeVolume (_acc,_minusDay) = (_acc + getTraderVolume(_trader, (_dayId - _minusDay))) | |
473 | + | ||
474 | + | let cumulativeVolume = { | |
475 | + | let $l = daysBefore | |
476 | + | let $s = size($l) | |
477 | + | let $acc0 = 0 | |
478 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
479 | + | then $a | |
480 | + | else updateCumulativeVolume($a, $l[$i]) | |
481 | + | ||
482 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
483 | + | then $a | |
484 | + | else throw("List size exceeds 30") | |
485 | + | ||
486 | + | $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($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) | |
487 | + | } | |
488 | + | [IntegerEntry(getTraderVolumeKey(_trader, _dayId), actualDayVolume), IntegerEntry(getTraderCumulativeVolumeKey(_trader), (cumulativeVolume + actualDayVolume))] | |
489 | + | } | |
490 | + | ||
491 | + | ||
394 | 492 | func updateAmmFees (_amm,_trader,_weekId,_actualFee) = { | |
395 | 493 | let traderFeesKey = getTraderFeesInPeriodKey(_amm, _trader, _weekId) | |
396 | 494 | let totalFeesKey = getTotalAmmFeesInPeriodKey(_amm, _weekId) | |
397 | 495 | let rewardAssets = getRewardAssetIds() | |
398 | 496 | let feesInPeriod = getFeesInPeriod(_amm, _trader, _weekId) | |
399 | 497 | let totalFeesInPeriod = getTotalFeesInPeriod(_amm, _weekId) | |
400 | 498 | let newFeesInPeriod = (feesInPeriod + _actualFee) | |
401 | 499 | let newTotalFeesInPeriod = (totalFeesInPeriod + _actualFee) | |
402 | 500 | func doHandleRewardAssetId (_acc,_assetId) = { | |
403 | 501 | let key = getAmmRewardRateKey(_amm, _assetId) | |
404 | 502 | if ((int0(key) > 0)) | |
405 | 503 | then { | |
406 | 504 | let totalAssetFeesKey = getTotalAssetFeesInPeriodKey(_assetId, _weekId) | |
407 | 505 | (_acc :+ IntegerEntry(totalAssetFeesKey, (getTotalAssetFeesInPeriod(_assetId, _weekId) + _actualFee))) | |
408 | 506 | } | |
409 | 507 | else _acc | |
410 | 508 | } | |
411 | 509 | ||
412 | 510 | let updateAssetFees = { | |
413 | 511 | let $l = rewardAssets | |
414 | 512 | let $s = size($l) | |
415 | 513 | let $acc0 = nil | |
416 | 514 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
417 | 515 | then $a | |
418 | 516 | else doHandleRewardAssetId($a, $l[$i]) | |
419 | 517 | ||
420 | 518 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
421 | 519 | then $a | |
422 | 520 | else throw("List size exceeds 10") | |
423 | 521 | ||
424 | 522 | $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) | |
425 | 523 | } | |
426 | 524 | ([IntegerEntry(traderFeesKey, newFeesInPeriod), IntegerEntry(totalFeesKey, newTotalFeesInPeriod)] ++ updateAssetFees) | |
427 | 525 | } | |
428 | 526 | ||
429 | 527 | ||
430 | 528 | func updateAmmData (_amm,_trader,_weekId,_traderAverage,_traderLastNotional,_traderScore,_totalScore) = { | |
431 | 529 | let totalScoreInPeriodKey = getTotalScoreInPeriodKey(_amm, _weekId) | |
432 | 530 | let traderScoreInPeriodKey = getTraderScoreInPeriodKey(_amm, _trader, _weekId) | |
433 | 531 | let lastNotionalKey = getLastNotionalKey(_amm, _trader) | |
434 | 532 | let traderAverageNotionalInPeriodKey = getTraderAverageNotionalInPeriodKey(_amm, _trader, _weekId) | |
435 | 533 | [IntegerEntry(totalScoreInPeriodKey, _totalScore), IntegerEntry(traderScoreInPeriodKey, _traderScore), IntegerEntry(lastNotionalKey, _traderLastNotional), IntegerEntry(traderAverageNotionalInPeriodKey, _traderAverage)] | |
534 | + | } | |
535 | + | ||
536 | + | ||
537 | + | func getFeeDiscount (_trader) = { | |
538 | + | let tiers = getFeeTiers() | |
539 | + | let cumulativeVolume = getTraderCumulativeVolume(_trader) | |
540 | + | func findFee (_acc,_tier) = { | |
541 | + | let $t01644516488 = _tier | |
542 | + | let minCumulativeVolume = $t01644516488._1 | |
543 | + | let discount = $t01644516488._2 | |
544 | + | if ((cumulativeVolume >= minCumulativeVolume)) | |
545 | + | then [discount] | |
546 | + | else _acc | |
547 | + | } | |
548 | + | ||
549 | + | let resultList = { | |
550 | + | let $l = tiers | |
551 | + | let $s = size($l) | |
552 | + | let $acc0 = [NO_DISCOUNT] | |
553 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
554 | + | then $a | |
555 | + | else findFee($a, $l[$i]) | |
556 | + | ||
557 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
558 | + | then $a | |
559 | + | else throw("List size exceeds 5") | |
560 | + | ||
561 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
562 | + | } | |
563 | + | resultList[0] | |
436 | 564 | } | |
437 | 565 | ||
438 | 566 | ||
439 | 567 | @Callable(i) | |
440 | 568 | func initialize (_coordinator,_oracle) = if (initialized()) | |
441 | 569 | then throw("Already initialized") | |
442 | 570 | else [StringEntry(k_coordinatorAddress, _coordinator), StringEntry(k_oracleAddress, _oracle), BooleanEntry(k_initialized, true)] | |
443 | 571 | ||
444 | 572 | ||
445 | 573 | ||
446 | 574 | @Callable(i) | |
447 | 575 | func setOracleAddress (_oracle) = if (if (!(initialized())) | |
448 | 576 | then true | |
449 | 577 | else (i.caller != adminAddress())) | |
450 | 578 | then throw("Invalid setOracleAddress parameters") | |
451 | 579 | else [StringEntry(k_oracleAddress, _oracle)] | |
452 | 580 | ||
453 | 581 | ||
454 | 582 | ||
455 | 583 | @Callable(i) | |
456 | 584 | func view_getPeriod () = { | |
457 | 585 | let weekId = getWeekId(TIME) | |
458 | 586 | let weekStart = getWeekStart(weekId) | |
459 | 587 | let weekEnd = getWeekEnd(weekId) | |
460 | 588 | throw(((((toString(weekStart) + ",") + toString(weekEnd)) + ",") + toString(TIME))) | |
461 | 589 | } | |
462 | 590 | ||
463 | 591 | ||
464 | 592 | ||
465 | 593 | @Callable(i) | |
466 | 594 | func view_getMaxAmountOfAssetToDistribute (_amm,_assetId,_weekId) = throw(toString(getMaxAmountOfAssetToDistribute(_amm, _assetId, _weekId))) | |
467 | 595 | ||
468 | 596 | ||
469 | 597 | ||
470 | 598 | @Callable(i) | |
471 | 599 | func view_claimRewards (_trader,_assetId,_period) = throw(toString(totalRewardForTraderInAsset(_trader, _assetId, [_period]))) | |
472 | 600 | ||
473 | 601 | ||
474 | 602 | ||
475 | 603 | @Callable(i) | |
476 | 604 | func view_calcReward (_trader,_amm,_assetId,_period) = throw(toString(rewardForTraderInAssetInPeriod(_amm, _assetId, _trader, _period))) | |
477 | 605 | ||
478 | 606 | ||
479 | 607 | ||
480 | 608 | @Callable(i) | |
481 | 609 | func view_claimAllRewards (_trader,_assetId,_periods) = { | |
482 | 610 | let result = claimAllRewardForPeriodForTrader(_trader, _assetId, _periods) | |
483 | 611 | throw(((toString(result._1) + ",") + toString(getTotalClaimedForTraderAndAsset(_trader, _assetId)))) | |
484 | 612 | } | |
485 | 613 | ||
486 | 614 | ||
487 | 615 | ||
488 | 616 | @Callable(i) | |
617 | + | func view_earnedRewards (_amm,_assetId,_period) = { | |
618 | + | let result = rewardForAmmInAssetInPeriod(_amm, _assetId, _period) | |
619 | + | throw(toString(result)) | |
620 | + | } | |
621 | + | ||
622 | + | ||
623 | + | ||
624 | + | @Callable(i) | |
489 | 625 | func claimAllRewards (_assetId,_periods) = { | |
490 | 626 | let trader = toString(i.caller) | |
491 | 627 | if (contains(_periods, toString(getWeekId(TIME)))) | |
492 | 628 | then throw("Can not claim rewards for current week") | |
493 | 629 | else { | |
494 | - | let $ | |
495 | - | let amount = $ | |
496 | - | let result = $ | |
630 | + | let $t01890718990 = claimAllRewardForPeriodForTrader(trader, _assetId, _periods) | |
631 | + | let amount = $t01890718990._1 | |
632 | + | let result = $t01890718990._2 | |
497 | 633 | if ((amount == 0)) | |
498 | 634 | then throw("Nothing to claim") | |
499 | 635 | else result | |
500 | 636 | } | |
501 | 637 | } | |
638 | + | ||
639 | + | ||
640 | + | ||
641 | + | @Callable(i) | |
642 | + | func setFeeDiscountTiers (_discounts) = if (if (!(initialized())) | |
643 | + | then true | |
644 | + | else (i.caller != adminAddress())) | |
645 | + | then throw("Invalid setFeeDiscountTiers params") | |
646 | + | else [StringEntry(k_feeTiers, _discounts)] | |
502 | 647 | ||
503 | 648 | ||
504 | 649 | ||
505 | 650 | @Callable(i) | |
506 | 651 | func attachRewardAsset (_assetId,_maxAmountPerPeriod) = if (if (!(initialized())) | |
507 | 652 | then true | |
508 | 653 | else (i.caller != adminAddress())) | |
509 | 654 | then throw("Invalid attachRewardAsset params") | |
510 | 655 | else { | |
511 | 656 | let amms = getAmms() | |
512 | 657 | let rewardAssetIds = getRewardAssetIds() | |
513 | 658 | let newRewardAssetIds = if (containsElement(rewardAssetIds, _assetId)) | |
514 | 659 | then rewardAssetIds | |
515 | 660 | else (rewardAssetIds :+ _assetId) | |
516 | 661 | [IntegerEntry(getAssetMaxAmountPerPeriodKey(_assetId), _maxAmountPerPeriod), StringEntry(k_rewardAssetIds, listToStr(newRewardAssetIds))] | |
517 | 662 | } | |
518 | 663 | ||
519 | 664 | ||
520 | 665 | ||
521 | 666 | @Callable(i) | |
522 | 667 | func attachRewards (_amm,_assetId,_rewardRate) = if (if (if (!(initialized())) | |
523 | 668 | then true | |
524 | 669 | else (i.caller != adminAddress())) | |
525 | 670 | then true | |
526 | 671 | else !(isWhitelist(_amm))) | |
527 | 672 | then throw("Invalid attachRewards params") | |
528 | 673 | else { | |
529 | 674 | let amms = getAmms() | |
530 | 675 | let rewardAssetIds = getRewardAssetIds() | |
531 | 676 | let newAmms = if (containsElement(amms, _amm)) | |
532 | 677 | then amms | |
533 | 678 | else (amms :+ _amm) | |
534 | 679 | let newRewardAssetIds = if (containsElement(rewardAssetIds, _assetId)) | |
535 | 680 | then rewardAssetIds | |
536 | 681 | else (rewardAssetIds :+ _assetId) | |
537 | 682 | [IntegerEntry(getAmmRewardRateKey(_amm, _assetId), _rewardRate), StringEntry(k_amms, listToStr(newAmms)), StringEntry(k_rewardAssetIds, listToStr(newRewardAssetIds))] | |
538 | 683 | } | |
539 | 684 | ||
540 | 685 | ||
541 | 686 | ||
542 | 687 | @Callable(i) | |
543 | 688 | func notifyFees (_trader,_fee) = { | |
544 | 689 | let amm = toString(i.caller) | |
545 | 690 | if (if (!(isWhitelist(amm))) | |
546 | 691 | then true | |
547 | 692 | else !(initialized())) | |
548 | 693 | then throw("Invalid notifyFees params") | |
549 | 694 | else { | |
550 | 695 | let actualFee = usdnToDecimals(_fee) | |
551 | 696 | let weekId = getWeekId(TIME) | |
552 | 697 | updateAmmFees(amm, _trader, weekId, actualFee) | |
553 | 698 | } | |
554 | 699 | } | |
555 | 700 | ||
556 | 701 | ||
557 | 702 | ||
558 | 703 | @Callable(i) | |
559 | 704 | func notifyNotional (_trader,_notional) = { | |
560 | 705 | let amm = toString(i.caller) | |
561 | 706 | if (if (!(isWhitelist(amm))) | |
562 | 707 | then true | |
563 | 708 | else !(initialized())) | |
564 | 709 | then throw("Invalid notifyNotional params") | |
565 | 710 | else { | |
566 | 711 | let actualNotional = usdnToDecimals(_notional) | |
567 | 712 | let lastNotional = getLastNotional(amm, _trader) | |
568 | 713 | let weekId = getWeekId(TIME) | |
714 | + | let dayId = getDayId(TIME) | |
569 | 715 | let weekStart = getWeekStart(weekId) | |
570 | 716 | let weekEnd = getWeekEnd(weekId) | |
571 | 717 | let t = (weekEnd - weekStart) | |
572 | 718 | let oldRunningAverage = getTraderAverageNotionalInPeriod(amm, _trader, weekId, lastNotional) | |
573 | 719 | let w = divd((weekEnd - TIME), t) | |
574 | 720 | let oldTraderAmmScore = getTraderScoreInPeriod(amm, _trader, weekId) | |
575 | 721 | let oldTotalAmmScore = getTotalScoreInPeriod(amm, weekId) | |
576 | 722 | let fees = getFeesInPeriod(amm, _trader, weekId) | |
577 | 723 | let newRunningAverage = ((oldRunningAverage + muld(actualNotional, w)) - muld(lastNotional, w)) | |
578 | 724 | let newTraderAmmScore = muld(powd(fees, A), powd(newRunningAverage, (DECIMAL_UNIT - A))) | |
579 | 725 | let newTotalAmmScoreInPeriod = ((oldTotalAmmScore - oldTraderAmmScore) + newTraderAmmScore) | |
580 | - | updateAmmData(amm, _trader, weekId, newRunningAverage, actualNotional, newTraderAmmScore, newTotalAmmScoreInPeriod) | |
726 | + | (updateAmmData(amm, _trader, weekId, newRunningAverage, actualNotional, newTraderAmmScore, newTotalAmmScoreInPeriod) ++ updateTraderVolume(_trader, dayId, abs((lastNotional - actualNotional)))) | |
581 | 727 | } | |
728 | + | } | |
729 | + | ||
730 | + | ||
731 | + | ||
732 | + | @Callable(i) | |
733 | + | func computeFeeDiscount (_trader) = { | |
734 | + | let result = getFeeDiscount(_trader) | |
735 | + | $Tuple2(nil, result) | |
736 | + | } | |
737 | + | ||
738 | + | ||
739 | + | ||
740 | + | @Callable(i) | |
741 | + | func view_computeFeeDiscount (_trader) = { | |
742 | + | let result = getFeeDiscount(_trader) | |
743 | + | throw(toString(result)) | |
582 | 744 | } | |
583 | 745 | ||
584 | 746 | ||
585 | 747 | @Verifier(tx) | |
586 | 748 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
587 | 749 |
github/deemru/w8io/169f3d6 103.56 ms ◑