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