tx · Ej5mXpi8bmLQ8jkfvvxwTSaZ9LkQi4nqSUtVocHjGMfE 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq: -0.16000000 Waves 2023.07.31 15:24 [2690055] smart account 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq > SELF 0.00000000 Waves
{ "type": 13, "id": "Ej5mXpi8bmLQ8jkfvvxwTSaZ9LkQi4nqSUtVocHjGMfE", "fee": 16000000, "feeAssetId": null, "timestamp": 1690806218192, "version": 2, "chainId": 84, "sender": "3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq", "senderPublicKey": "57SkjQUEwC1ayCqLbXLuzBqifK6B6SR6rfxtGsbAo3zW", "proofs": [ "4Etp4civJHTYPSdUykKSz2PM32GtAQHf9q65A6afM2ED8fNxkB9hainyEXxDaU5QspAY9o4BLz8xXSz54RqKxTKU" ], "script": "base64:BgIkCAISAwoBARIDCgEBEgASAwoBCBIDCgEBEgMKAQgSABIDCgEIMgAMY29udHJhY3RGaWxlAhFsMm1wX3N0YWtpbmcucmlkZQADU0VQAgJfXwAGc2NhbGU4AIDC1y8AB3NjYWxlMTgAgICQu7rWrfANAA1zY2FsZTE4QmlnSW50CQC2AgEFB3NjYWxlMTgAEkFERFJFU1NfQllURVNfU0laRQAaAA1CTE9DS1NfSU5fREFZAKALAQh0aHJvd0VycgEDbXNnCQACAQkArAICCQCsAgIFDGNvbnRyYWN0RmlsZQICOiAFA21zZwAKa2V5QXNzZXRJZAkAuQkCCQDMCAICAiVzCQDMCAICB2Fzc2V0SWQFA25pbAUDU0VQABNrZXlFbWlzc2lvblBlckJsb2NrCQC5CQIJAMwIAgICJXMJAMwIAgIQZW1pc3Npb25QZXJCbG9jawUDbmlsBQNTRVAAGWtleUVtaXNzaW9uUGVyaW9kSW5CbG9ja3MJALkJAgkAzAgCAgIlcwkAzAgCAhZlbWlzc2lvblBlcmlvZEluQmxvY2tzBQNuaWwFA1NFUAANa2V5U3RhcnRCbG9jawkAuQkCC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mLgECdHgBBnZlcmlmeQAECGJ5QWRtaW5zCQAAAggFAnR4AmlkCQDZBAEJAQt2YWx1ZU9yRWxzZQIJAJ0IAgUEdGhpcwkBDmtleUFsbG93ZWRUeElkAAIABAdieU93bmVyAwkAZwIJAJADAQkBDWdldEFkbWluc0xpc3QABQZRVU9SVU0HCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5AwUIYnlBZG1pbnMGBQdieU93bmVyRoGTgQ==", "height": 2690055, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GNgVpsstBv7bavKTgTETGZYsy6cQaeSpTNXBXTYkAZgf Next: 7vWYwan9jcdEdRYtSZsqJWFF7WB9HV4sY8WE5PbwmLuB Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let contractFile = " | |
4 | + | let contractFile = "l2mp_staking.ride" | |
5 | 5 | ||
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let scale8 = 100000000 | |
9 | + | ||
10 | + | let scale18 = 1000000000000000000 | |
11 | + | ||
12 | + | let scale18BigInt = toBigInt(scale18) | |
9 | 13 | ||
10 | 14 | let ADDRESS_BYTES_SIZE = 26 | |
11 | 15 | ||
35 | 39 | func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP) | |
36 | 40 | ||
37 | 41 | ||
42 | + | func keyHistory (type,userAddress,txId) = makeString(["%s%s%s", type, userAddress, toBase58String(txId)], SEP) | |
43 | + | ||
44 | + | ||
45 | + | func formatHistory (totalProfit,price,totalAssetAmount,totalLpAmount) = makeString(["%d%d", toString(totalProfit), toString(price), toString(totalAssetAmount), toString(totalLpAmount)], SEP) | |
46 | + | ||
47 | + | ||
38 | 48 | let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0) | |
39 | 49 | ||
40 | 50 | let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0) | |
48 | 58 | let emissionPeriodInBlocks = valueOrElse(getInteger(this, keyEmissionPeriodInBlocks), BLOCKS_IN_DAY) | |
49 | 59 | ||
50 | 60 | let emissionPerPeriod = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * emissionPeriodInBlocks) | |
51 | - | ||
52 | - | let heightInPeriods = fraction(height, 1, emissionPeriodInBlocks) | |
53 | 61 | ||
54 | 62 | let ADMIN_LIST_SIZE = 5 | |
55 | 63 | ||
87 | 95 | ||
88 | 96 | ||
89 | 97 | func genVotesKeysHelper (a,adminAddress) = { | |
90 | - | let $ | |
91 | - | let result = $ | |
92 | - | let prefix = $ | |
98 | + | let $t030453069 = a | |
99 | + | let result = $t030453069._1 | |
100 | + | let prefix = $t030453069._2 | |
93 | 101 | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
94 | 102 | } | |
95 | 103 | ||
96 | 104 | ||
97 | 105 | func genVotesKeys (keyPrefix) = { | |
98 | 106 | let adminList = keyAdminAddressList() | |
99 | - | let $ | |
107 | + | let $t032163300 = { | |
100 | 108 | let $l = getAdminsList() | |
101 | 109 | let $s = size($l) | |
102 | 110 | let $acc0 = $Tuple2(nil, keyPrefix) | |
110 | 118 | ||
111 | 119 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
112 | 120 | } | |
113 | - | let result = $ | |
114 | - | let prefix = $ | |
121 | + | let result = $t032163300._1 | |
122 | + | let prefix = $t032163300._2 | |
115 | 123 | result | |
116 | 124 | } | |
117 | 125 | ||
178 | 186 | } | |
179 | 187 | ||
180 | 188 | ||
181 | - | func | |
189 | + | func calcTotalProfitForHeight (h) = { | |
182 | 190 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
183 | 191 | let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks) | |
184 | - | let elapsedPeriods = ( | |
192 | + | let elapsedPeriods = ((h / emissionPeriodInBlocks) - startPeriod) | |
185 | 193 | max([0, (emissionPerPeriod * elapsedPeriods)]) | |
186 | 194 | } | |
195 | + | ||
196 | + | ||
197 | + | func calcTotalProfit () = calcTotalProfitForHeight(height) | |
187 | 198 | ||
188 | 199 | ||
189 | 200 | func getTotalAssetAmountWithProfitOrMaxAvailable () = { | |
203 | 214 | ||
204 | 215 | ||
205 | 216 | func getCurrentPrice () = if ((totalLpAmount != 0)) | |
206 | - | then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), | |
207 | - | else | |
217 | + | then fraction(toBigInt(getTotalAssetAmountWithProfitOrMaxAvailable()), scale18BigInt, toBigInt(totalLpAmount)) | |
218 | + | else scale18BigInt | |
208 | 219 | ||
209 | 220 | ||
210 | 221 | func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0) | |
212 | 223 | ||
213 | 224 | func getUserAvailableAssetsToWithdraw (userAddress) = { | |
214 | 225 | let userLpAmount = getUserLpAmount(userAddress) | |
215 | - | let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), | |
216 | - | | |
217 | - | | |
218 | - | | |
226 | + | let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt)) | |
227 | + | let roundedLpAmountFromAvailable = toInt(fraction(toBigInt(userAvailableAssetToWithdraw), scale18BigInt, getCurrentPrice())) | |
228 | + | let roundedAssetsAvailableToWithdraw = toInt(fraction(toBigInt(roundedLpAmountFromAvailable), getCurrentPrice(), scale18BigInt)) | |
229 | + | max([0, min([userAvailableAssetToWithdraw, roundedLpAmountFromAvailable])]) | |
219 | 230 | } | |
220 | 231 | ||
221 | 232 | ||
230 | 241 | if ((checks == checks)) | |
231 | 242 | then { | |
232 | 243 | let paymentAmount = i.payments[0].amount | |
233 | - | let paymentLpAmount = fraction(paymentAmount, | |
244 | + | let paymentLpAmount = toInt(fraction(toBigInt(paymentAmount), scale18BigInt, getCurrentPrice())) | |
234 | 245 | let userLpAmount = getUserLpAmount(userAddress) | |
235 | 246 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
236 | 247 | let newTotalLpAmount = (totalLpAmount + paymentLpAmount) | |
240 | 251 | let updateStartHeightAction = if ((totalLpAmount == 0)) | |
241 | 252 | then [IntegerEntry(keyStartBlock, height)] | |
242 | 253 | else nil | |
243 | - | ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction) | |
254 | + | ([StringEntry(keyHistory("stake", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalLpAmount, totalAssetAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction) | |
244 | 255 | } | |
245 | 256 | else throw("Strict value is not equal to itself.") | |
246 | 257 | } | |
257 | 268 | if ((check == check)) | |
258 | 269 | then { | |
259 | 270 | let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount) | |
260 | - | let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), | |
271 | + | let withdrawAssetAmount = toInt(fraction(toBigInt(lpAssetWithdrawAmount), getCurrentPrice(), scale18BigInt)) | |
261 | 272 | let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount) | |
262 | - | let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), | |
273 | + | let newTotalAssetAmount = toInt(fraction(toBigInt(newTotalLpAmount), getCurrentPrice(), scale18BigInt)) | |
263 | 274 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
264 | 275 | let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount) | |
265 | - | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
276 | + | [StringEntry(keyHistory("withdraw", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalLpAmount, totalAssetAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
266 | 277 | } | |
267 | 278 | else throw("Strict value is not equal to itself.") | |
268 | 279 | } | |
275 | 286 | else throwErr("permission denied")] | |
276 | 287 | if ((check == check)) | |
277 | 288 | then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))] | |
289 | + | else throw("Strict value is not equal to itself.") | |
290 | + | } | |
291 | + | ||
292 | + | ||
293 | + | ||
294 | + | @Callable(i) | |
295 | + | func setEmissionPeriodInBlocks (p) = { | |
296 | + | let check = [if ((p > 0)) | |
297 | + | then true | |
298 | + | else throwErr("emission period should be greater than 0"), if ((i.caller == this)) | |
299 | + | then true | |
300 | + | else throwErr("permission denied")] | |
301 | + | if ((check == check)) | |
302 | + | then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPeriodInBlocks, p)] | |
278 | 303 | else throw("Strict value is not equal to itself.") | |
279 | 304 | } | |
280 | 305 | ||
301 | 326 | func withdraw (withdrawAssetAmount) = { | |
302 | 327 | let userAddress = toString(i.caller) | |
303 | 328 | let userLpAmount = getUserLpAmount(userAddress) | |
304 | - | let lpAmountToWithdraw = fraction(withdrawAssetAmount, | |
329 | + | let lpAmountToWithdraw = toInt(fraction(toBigInt(withdrawAssetAmount), scale18BigInt, getCurrentPrice())) | |
305 | 330 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
306 | - | let minWithdrawAssetAmount = fraction(getCurrentPrice(), 1, | |
331 | + | let minWithdrawAssetAmount = toInt(fraction(getCurrentPrice(), toBigInt(1), scale18BigInt, CEILING)) | |
307 | 332 | let check = [if ((withdrawAssetAmount > 0)) | |
308 | 333 | then true | |
309 | 334 | else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let contractFile = " | |
4 | + | let contractFile = "l2mp_staking.ride" | |
5 | 5 | ||
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let scale8 = 100000000 | |
9 | + | ||
10 | + | let scale18 = 1000000000000000000 | |
11 | + | ||
12 | + | let scale18BigInt = toBigInt(scale18) | |
9 | 13 | ||
10 | 14 | let ADDRESS_BYTES_SIZE = 26 | |
11 | 15 | ||
12 | 16 | let BLOCKS_IN_DAY = 1440 | |
13 | 17 | ||
14 | 18 | func throwErr (msg) = throw(((contractFile + ": ") + msg)) | |
15 | 19 | ||
16 | 20 | ||
17 | 21 | let keyAssetId = makeString(["%s", "assetId"], SEP) | |
18 | 22 | ||
19 | 23 | let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP) | |
20 | 24 | ||
21 | 25 | let keyEmissionPeriodInBlocks = makeString(["%s", "emissionPeriodInBlocks"], SEP) | |
22 | 26 | ||
23 | 27 | let keyStartBlock = makeString(["%s", "startBlock"], SEP) | |
24 | 28 | ||
25 | 29 | let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP) | |
26 | 30 | ||
27 | 31 | let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP) | |
28 | 32 | ||
29 | 33 | func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP) | |
30 | 34 | ||
31 | 35 | ||
32 | 36 | func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP) | |
33 | 37 | ||
34 | 38 | ||
35 | 39 | func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP) | |
36 | 40 | ||
37 | 41 | ||
42 | + | func keyHistory (type,userAddress,txId) = makeString(["%s%s%s", type, userAddress, toBase58String(txId)], SEP) | |
43 | + | ||
44 | + | ||
45 | + | func formatHistory (totalProfit,price,totalAssetAmount,totalLpAmount) = makeString(["%d%d", toString(totalProfit), toString(price), toString(totalAssetAmount), toString(totalLpAmount)], SEP) | |
46 | + | ||
47 | + | ||
38 | 48 | let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0) | |
39 | 49 | ||
40 | 50 | let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0) | |
41 | 51 | ||
42 | 52 | let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES") | |
43 | 53 | ||
44 | 54 | let assetIdBytes = if ((assetIdString == "WAVES")) | |
45 | 55 | then unit | |
46 | 56 | else fromBase58String(assetIdString) | |
47 | 57 | ||
48 | 58 | let emissionPeriodInBlocks = valueOrElse(getInteger(this, keyEmissionPeriodInBlocks), BLOCKS_IN_DAY) | |
49 | 59 | ||
50 | 60 | let emissionPerPeriod = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * emissionPeriodInBlocks) | |
51 | - | ||
52 | - | let heightInPeriods = fraction(height, 1, emissionPeriodInBlocks) | |
53 | 61 | ||
54 | 62 | let ADMIN_LIST_SIZE = 5 | |
55 | 63 | ||
56 | 64 | let QUORUM = 3 | |
57 | 65 | ||
58 | 66 | let TXID_BYTES_LENGTH = 32 | |
59 | 67 | ||
60 | 68 | func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP) | |
61 | 69 | ||
62 | 70 | ||
63 | 71 | func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP) | |
64 | 72 | ||
65 | 73 | ||
66 | 74 | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
67 | 75 | ||
68 | 76 | ||
69 | 77 | func keyAllowedTxId () = makeString(["%s", "txId"], SEP) | |
70 | 78 | ||
71 | 79 | ||
72 | 80 | func getAdminVote (prefix,admin) = { | |
73 | 81 | let voteKey = keyFullAdminVote(prefix, admin) | |
74 | 82 | valueOrElse(getInteger(voteKey), 0) | |
75 | 83 | } | |
76 | 84 | ||
77 | 85 | ||
78 | 86 | func getAdminsList () = match getString(this, keyAdminAddressList()) { | |
79 | 87 | case s: String => | |
80 | 88 | split(s, SEP) | |
81 | 89 | case _ => | |
82 | 90 | nil | |
83 | 91 | } | |
84 | 92 | ||
85 | 93 | ||
86 | 94 | func isInAdminList (address) = containsElement(getAdminsList(), address) | |
87 | 95 | ||
88 | 96 | ||
89 | 97 | func genVotesKeysHelper (a,adminAddress) = { | |
90 | - | let $ | |
91 | - | let result = $ | |
92 | - | let prefix = $ | |
98 | + | let $t030453069 = a | |
99 | + | let result = $t030453069._1 | |
100 | + | let prefix = $t030453069._2 | |
93 | 101 | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
94 | 102 | } | |
95 | 103 | ||
96 | 104 | ||
97 | 105 | func genVotesKeys (keyPrefix) = { | |
98 | 106 | let adminList = keyAdminAddressList() | |
99 | - | let $ | |
107 | + | let $t032163300 = { | |
100 | 108 | let $l = getAdminsList() | |
101 | 109 | let $s = size($l) | |
102 | 110 | let $acc0 = $Tuple2(nil, keyPrefix) | |
103 | 111 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
104 | 112 | then $a | |
105 | 113 | else genVotesKeysHelper($a, $l[$i]) | |
106 | 114 | ||
107 | 115 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
108 | 116 | then $a | |
109 | 117 | else throw("List size exceeds 5") | |
110 | 118 | ||
111 | 119 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
112 | 120 | } | |
113 | - | let result = $ | |
114 | - | let prefix = $ | |
121 | + | let result = $t032163300._1 | |
122 | + | let prefix = $t032163300._2 | |
115 | 123 | result | |
116 | 124 | } | |
117 | 125 | ||
118 | 126 | ||
119 | 127 | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
120 | 128 | ||
121 | 129 | ||
122 | 130 | func countVotes (prefix) = { | |
123 | 131 | let votes = genVotesKeys(prefix) | |
124 | 132 | let $l = votes | |
125 | 133 | let $s = size($l) | |
126 | 134 | let $acc0 = 0 | |
127 | 135 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
128 | 136 | then $a | |
129 | 137 | else countVotesHelper($a, $l[$i]) | |
130 | 138 | ||
131 | 139 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
132 | 140 | then $a | |
133 | 141 | else throw("List size exceeds 5") | |
134 | 142 | ||
135 | 143 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
136 | 144 | } | |
137 | 145 | ||
138 | 146 | ||
139 | 147 | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
140 | 148 | ||
141 | 149 | ||
142 | 150 | func getClearVoteEntries (prefix) = { | |
143 | 151 | let votes = genVotesKeys(prefix) | |
144 | 152 | let $l = votes | |
145 | 153 | let $s = size($l) | |
146 | 154 | let $acc0 = nil | |
147 | 155 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
148 | 156 | then $a | |
149 | 157 | else clearVotesHelper($a, $l[$i]) | |
150 | 158 | ||
151 | 159 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
152 | 160 | then $a | |
153 | 161 | else throw("List size exceeds 5") | |
154 | 162 | ||
155 | 163 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
156 | 164 | } | |
157 | 165 | ||
158 | 166 | ||
159 | 167 | func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = { | |
160 | 168 | let voteKey = keyFullAdminVote(keyPrefix, callerAddressString) | |
161 | 169 | let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString) | |
162 | 170 | let err = if (!(isInAdminList(callerAddressString))) | |
163 | 171 | then throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
164 | 172 | else if ((adminCurrentVote == 1)) | |
165 | 173 | then throwErr((voteKey + " you already voted")) | |
166 | 174 | else unit | |
167 | 175 | if ((err == err)) | |
168 | 176 | then { | |
169 | 177 | let votes = countVotes(keyPrefix) | |
170 | 178 | if (((votes + 1) >= minVotes)) | |
171 | 179 | then { | |
172 | 180 | let clearVoteEntries = getClearVoteEntries(keyPrefix) | |
173 | 181 | (clearVoteEntries ++ voteResult) | |
174 | 182 | } | |
175 | 183 | else [IntegerEntry(voteKey, 1)] | |
176 | 184 | } | |
177 | 185 | else throw("Strict value is not equal to itself.") | |
178 | 186 | } | |
179 | 187 | ||
180 | 188 | ||
181 | - | func | |
189 | + | func calcTotalProfitForHeight (h) = { | |
182 | 190 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
183 | 191 | let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks) | |
184 | - | let elapsedPeriods = ( | |
192 | + | let elapsedPeriods = ((h / emissionPeriodInBlocks) - startPeriod) | |
185 | 193 | max([0, (emissionPerPeriod * elapsedPeriods)]) | |
186 | 194 | } | |
195 | + | ||
196 | + | ||
197 | + | func calcTotalProfit () = calcTotalProfitForHeight(height) | |
187 | 198 | ||
188 | 199 | ||
189 | 200 | func getTotalAssetAmountWithProfitOrMaxAvailable () = { | |
190 | 201 | let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit()) | |
191 | 202 | let totalAmount = match assetIdBytes { | |
192 | 203 | case u: Unit => | |
193 | 204 | min([totalAssetAmountWithProfit, wavesBalance(this).available]) | |
194 | 205 | case b: ByteVector => | |
195 | 206 | min([totalAssetAmountWithProfit, assetBalance(this, b)]) | |
196 | 207 | case _ => | |
197 | 208 | throw("Match error") | |
198 | 209 | } | |
199 | 210 | if ((totalLpAmount == 0)) | |
200 | 211 | then 0 | |
201 | 212 | else totalAmount | |
202 | 213 | } | |
203 | 214 | ||
204 | 215 | ||
205 | 216 | func getCurrentPrice () = if ((totalLpAmount != 0)) | |
206 | - | then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), | |
207 | - | else | |
217 | + | then fraction(toBigInt(getTotalAssetAmountWithProfitOrMaxAvailable()), scale18BigInt, toBigInt(totalLpAmount)) | |
218 | + | else scale18BigInt | |
208 | 219 | ||
209 | 220 | ||
210 | 221 | func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0) | |
211 | 222 | ||
212 | 223 | ||
213 | 224 | func getUserAvailableAssetsToWithdraw (userAddress) = { | |
214 | 225 | let userLpAmount = getUserLpAmount(userAddress) | |
215 | - | let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), | |
216 | - | | |
217 | - | | |
218 | - | | |
226 | + | let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt)) | |
227 | + | let roundedLpAmountFromAvailable = toInt(fraction(toBigInt(userAvailableAssetToWithdraw), scale18BigInt, getCurrentPrice())) | |
228 | + | let roundedAssetsAvailableToWithdraw = toInt(fraction(toBigInt(roundedLpAmountFromAvailable), getCurrentPrice(), scale18BigInt)) | |
229 | + | max([0, min([userAvailableAssetToWithdraw, roundedLpAmountFromAvailable])]) | |
219 | 230 | } | |
220 | 231 | ||
221 | 232 | ||
222 | 233 | func getStakeActions (i,userAddress) = { | |
223 | 234 | let checks = [if ((size(i.payments) == 1)) | |
224 | 235 | then true | |
225 | 236 | else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes)) | |
226 | 237 | then true | |
227 | 238 | else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0)) | |
228 | 239 | then true | |
229 | 240 | else "payment amount should be greater than 0"] | |
230 | 241 | if ((checks == checks)) | |
231 | 242 | then { | |
232 | 243 | let paymentAmount = i.payments[0].amount | |
233 | - | let paymentLpAmount = fraction(paymentAmount, | |
244 | + | let paymentLpAmount = toInt(fraction(toBigInt(paymentAmount), scale18BigInt, getCurrentPrice())) | |
234 | 245 | let userLpAmount = getUserLpAmount(userAddress) | |
235 | 246 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
236 | 247 | let newTotalLpAmount = (totalLpAmount + paymentLpAmount) | |
237 | 248 | let newTotalAssetAmount = (totalAssetAmount + paymentAmount) | |
238 | 249 | let newUserLpAmount = (userLpAmount + paymentLpAmount) | |
239 | 250 | let newUserTotalStakedAmount = (userTotalStakedAmount + paymentAmount) | |
240 | 251 | let updateStartHeightAction = if ((totalLpAmount == 0)) | |
241 | 252 | then [IntegerEntry(keyStartBlock, height)] | |
242 | 253 | else nil | |
243 | - | ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction) | |
254 | + | ([StringEntry(keyHistory("stake", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalLpAmount, totalAssetAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction) | |
244 | 255 | } | |
245 | 256 | else throw("Strict value is not equal to itself.") | |
246 | 257 | } | |
247 | 258 | ||
248 | 259 | ||
249 | 260 | func getWithdrawActions (i,lpAssetWithdrawAmount) = { | |
250 | 261 | let userAddress = toString(i.caller) | |
251 | 262 | let userLpAmount = getUserLpAmount(userAddress) | |
252 | 263 | let check = [if ((lpAssetWithdrawAmount > 0)) | |
253 | 264 | then true | |
254 | 265 | else throwErr("LP amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount)) | |
255 | 266 | then true | |
256 | 267 | else throwErr((("cannot withdraw more than available LP (" + toString(userLpAmount)) + ")"))] | |
257 | 268 | if ((check == check)) | |
258 | 269 | then { | |
259 | 270 | let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount) | |
260 | - | let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), | |
271 | + | let withdrawAssetAmount = toInt(fraction(toBigInt(lpAssetWithdrawAmount), getCurrentPrice(), scale18BigInt)) | |
261 | 272 | let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount) | |
262 | - | let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), | |
273 | + | let newTotalAssetAmount = toInt(fraction(toBigInt(newTotalLpAmount), getCurrentPrice(), scale18BigInt)) | |
263 | 274 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
264 | 275 | let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount) | |
265 | - | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
276 | + | [StringEntry(keyHistory("withdraw", userAddress, i.transactionId), formatHistory(calcTotalProfit(), getCurrentPrice(), totalLpAmount, totalAssetAmount)), IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
266 | 277 | } | |
267 | 278 | else throw("Strict value is not equal to itself.") | |
268 | 279 | } | |
269 | 280 | ||
270 | 281 | ||
271 | 282 | @Callable(i) | |
272 | 283 | func setEmissionPerBlock (emissionPerBlock) = { | |
273 | 284 | let check = [if ((i.caller == this)) | |
274 | 285 | then true | |
275 | 286 | else throwErr("permission denied")] | |
276 | 287 | if ((check == check)) | |
277 | 288 | then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))] | |
289 | + | else throw("Strict value is not equal to itself.") | |
290 | + | } | |
291 | + | ||
292 | + | ||
293 | + | ||
294 | + | @Callable(i) | |
295 | + | func setEmissionPeriodInBlocks (p) = { | |
296 | + | let check = [if ((p > 0)) | |
297 | + | then true | |
298 | + | else throwErr("emission period should be greater than 0"), if ((i.caller == this)) | |
299 | + | then true | |
300 | + | else throwErr("permission denied")] | |
301 | + | if ((check == check)) | |
302 | + | then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPeriodInBlocks, p)] | |
278 | 303 | else throw("Strict value is not equal to itself.") | |
279 | 304 | } | |
280 | 305 | ||
281 | 306 | ||
282 | 307 | ||
283 | 308 | @Callable(i) | |
284 | 309 | func stake () = getStakeActions(i, toString(i.caller)) | |
285 | 310 | ||
286 | 311 | ||
287 | 312 | ||
288 | 313 | @Callable(i) | |
289 | 314 | func stakeFor (userAddress) = { | |
290 | 315 | let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE)) | |
291 | 316 | then true | |
292 | 317 | else throwErr("address is not valid")] | |
293 | 318 | if ((check == check)) | |
294 | 319 | then getStakeActions(i, userAddress) | |
295 | 320 | else throw("Strict value is not equal to itself.") | |
296 | 321 | } | |
297 | 322 | ||
298 | 323 | ||
299 | 324 | ||
300 | 325 | @Callable(i) | |
301 | 326 | func withdraw (withdrawAssetAmount) = { | |
302 | 327 | let userAddress = toString(i.caller) | |
303 | 328 | let userLpAmount = getUserLpAmount(userAddress) | |
304 | - | let lpAmountToWithdraw = fraction(withdrawAssetAmount, | |
329 | + | let lpAmountToWithdraw = toInt(fraction(toBigInt(withdrawAssetAmount), scale18BigInt, getCurrentPrice())) | |
305 | 330 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
306 | - | let minWithdrawAssetAmount = fraction(getCurrentPrice(), 1, | |
331 | + | let minWithdrawAssetAmount = toInt(fraction(getCurrentPrice(), toBigInt(1), scale18BigInt, CEILING)) | |
307 | 332 | let check = [if ((withdrawAssetAmount > 0)) | |
308 | 333 | then true | |
309 | 334 | else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount)) | |
310 | 335 | then true | |
311 | 336 | else throwErr((("cannot withdraw more than available (" + toString(userAvailableAssetToWithdraw)) + ")")), if ((withdrawAssetAmount >= minWithdrawAssetAmount)) | |
312 | 337 | then true | |
313 | 338 | else throwErr((("withdraw amount is too small. Min: (" + toString(minWithdrawAssetAmount)) + ")"))] | |
314 | 339 | if ((check == check)) | |
315 | 340 | then getWithdrawActions(i, lpAmountToWithdraw) | |
316 | 341 | else throw("Strict value is not equal to itself.") | |
317 | 342 | } | |
318 | 343 | ||
319 | 344 | ||
320 | 345 | ||
321 | 346 | @Callable(i) | |
322 | 347 | func getUserAssetsREADONLY (userAddress) = { | |
323 | 348 | let userLpAmount = getUserLpAmount(userAddress) | |
324 | 349 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
325 | 350 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
326 | 351 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
327 | 352 | $Tuple2(nil, $Tuple5(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice(), userTotalStakedAmount, userTotalAssetWithdrawn)) | |
328 | 353 | } | |
329 | 354 | ||
330 | 355 | ||
331 | 356 | ||
332 | 357 | @Callable(i) | |
333 | 358 | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice())) | |
334 | 359 | ||
335 | 360 | ||
336 | 361 | ||
337 | 362 | @Callable(i) | |
338 | 363 | func voteForTxId (txId) = { | |
339 | 364 | let callerAddressString = toBase58String(i.caller.bytes) | |
340 | 365 | let keyPrefix = keyAllowedTxIdVotePrefix(txId) | |
341 | 366 | let result = [StringEntry(keyAllowedTxId(), txId)] | |
342 | 367 | let allowedTxIdOption = getString(this, keyAllowedTxId()) | |
343 | 368 | let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH)) | |
344 | 369 | then true | |
345 | 370 | else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit)) | |
346 | 371 | then true | |
347 | 372 | else (value(allowedTxIdOption) != txId)) | |
348 | 373 | then true | |
349 | 374 | else throwErr((txId + " is already allowed"))] | |
350 | 375 | if ((err == err)) | |
351 | 376 | then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result) | |
352 | 377 | else throw("Strict value is not equal to itself.") | |
353 | 378 | } | |
354 | 379 | ||
355 | 380 | ||
356 | 381 | @Verifier(tx) | |
357 | 382 | func verify () = { | |
358 | 383 | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), ""))) | |
359 | 384 | let byOwner = if ((size(getAdminsList()) >= QUORUM)) | |
360 | 385 | then false | |
361 | 386 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
362 | 387 | if (byAdmins) | |
363 | 388 | then true | |
364 | 389 | else byOwner | |
365 | 390 | } | |
366 | 391 |
github/deemru/w8io/169f3d6 82.87 ms ◑