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