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