tx · Ge5EbvWYkiC6PsyTeFcgj3y8w9e7Cwe7JJRCbn4ws7cf 3N9eLqWNqb7jeF383m9qsXEBqpp8qfQmfbx: -0.04000000 Waves 2022.06.03 06:59 [2079646] smart account 3N9eLqWNqb7jeF383m9qsXEBqpp8qfQmfbx > SELF 0.00000000 Waves
{ "type": 13, "id": "Ge5EbvWYkiC6PsyTeFcgj3y8w9e7Cwe7JJRCbn4ws7cf", "fee": 4000000, "feeAssetId": null, "timestamp": 1654228883876, "version": 2, "chainId": 84, "sender": "3N9eLqWNqb7jeF383m9qsXEBqpp8qfQmfbx", "senderPublicKey": "5cWdpE4X7mfNkLmxJ389ws6qGZof4fwydqMcqPexhJ7w", "proofs": [ "5gWfUwiYwvzeQAg2XcMGXJJNk7fHdroADzmSDyekfZoeECbnxAdfxAxSYEPNTDvfk63KR3sjVNFc5oT9WF8r9hb4" ], "script": "base64:AAIFAAAAAAAAAEAIAhIHCgUICAgBARIDCgEIEgMKAQgSAwoBCBIDCgEIEgMKAQgSAwoBCBIECgIICRIDCgEIEgUKAwEIARIDCgEIAAAAIwAAAAAMbG9ja2luZ1N0b3JlBQAAAAR0aGlzAAAAAAxzdGFraW5nU3RvcmUCAAAACF9SZXNlcnZlAAAAABFtaW5pbXVtTG9ja0Ftb3VudAIAAAAOX01pbkxvY2tBbW91bnQAAAAAEW1heGltdW1Mb2NrQW1vdW50AgAAAA5fTWF4TG9ja0Ftb3VudAAAAAAJYXNzZXRMaXN0BQAAAANuaWwAAAAAEXVubG9ja0VsaWdpYmlsaXR5AgAAABxfRWxpZ2libGVfdG9fdW5sb2NrX2F0X2Jsb2NrAAAAAAxsb2NrZWRBbW91bnQCAAAADl9BbW91bnRfbG9ja2VkAAAAAAtsb2NrZWRBc3NldAIAAAANX0Fzc2V0X2xvY2tlZAAAAAAEdXNlcgIAAAAFX1VzZXIAAAAACkFQWV9BbW91bnQCAAAAC19BUFlfYW1vdW50AAAAABF0b3RhbExvY2tlZEFNb3VudAIAAAAUX1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AACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAZ1c2VySWQFAAAADXVMb2NrZWRBbW91bnQJAAGbAAAAAQUAAAAGdUFzc2V0CQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACBQAAABJ1QWxyZWFkeUNsYWltZWRLZXkGBQAAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAAAKpd5nQ==", "height": 2079646, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DvQ7JgcHRXHKQ1tqjeJNuo6kvF4ebxS1SHNsgeMF1Pc1 Next: 4Uj4ncgiqGfZhhkv3D1GSeyXxdomW7vYVmv4kwESQjCi Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lockingStore = this | |
5 | 5 | ||
6 | - | let stakingStore = "_ | |
6 | + | let stakingStore = "_Reserve" | |
7 | 7 | ||
8 | 8 | let minimumLockAmount = "_MinLockAmount" | |
9 | 9 | ||
21 | 21 | ||
22 | 22 | let APY_Amount = "_APY_amount" | |
23 | 23 | ||
24 | + | let totalLockedAMount = "_Total_Locked_Amount" | |
25 | + | ||
24 | 26 | let lockingPeriod = "_Days_locked" | |
27 | + | ||
28 | + | let entryIndex = "_Entry_Index" | |
29 | + | ||
30 | + | let alreadyClaimed = "_Already_Claimed" | |
25 | 31 | ||
26 | 32 | let admin = "admin_" | |
27 | 33 | ||
28 | 34 | let BlockPerDay = 1440 | |
29 | - | ||
30 | - | let RBase = 10000000000000000 | |
31 | - | ||
32 | - | let factorsBase = 1000 | |
33 | 35 | ||
34 | 36 | let thirtyDaysLockPeriod = 30 | |
35 | 37 | ||
127 | 129 | case _ => | |
128 | 130 | throw("unsupported config type") | |
129 | 131 | } | |
132 | + | ||
133 | + | ||
134 | + | func incrementEntryIndex (key) = { | |
135 | + | let uIndex = getI(key) | |
136 | + | if (isDefined(uIndex)) | |
137 | + | then (value(uIndex) + 1) | |
138 | + | else 0 | |
139 | + | } | |
130 | 140 | ||
131 | 141 | ||
132 | 142 | @Callable(i) | |
244 | 254 | ||
245 | 255 | ||
246 | 256 | @Callable(i) | |
257 | + | func getDaysLeftToClaim (userAddress) = { | |
258 | + | let check0 = adminOnly(i) | |
259 | + | if ((check0 == check0)) | |
260 | + | then { | |
261 | + | let check1 = valueOrErrorMessage(addressFromString(userAddress), "invalid address") | |
262 | + | if ((check1 == check1)) | |
263 | + | then { | |
264 | + | let uEntryIndex = ("_" + toString(throwOrReturnI(getI((userAddress + entryIndex)), ("no entry found for " + userAddress)))) | |
265 | + | let uUnlockEligibility = ((userAddress + uEntryIndex) + unlockEligibility) | |
266 | + | let uBlocks = throwOrReturnI(getI(uUnlockEligibility), "internal error") | |
267 | + | let uBlocksToDays = daysToBlocks((height - uBlocks)) | |
268 | + | $Tuple2(nil, uBlocksToDays) | |
269 | + | } | |
270 | + | else throw("Strict value is not equal to itself.") | |
271 | + | } | |
272 | + | else throw("Strict value is not equal to itself.") | |
273 | + | } | |
274 | + | ||
275 | + | ||
276 | + | ||
277 | + | @Callable(i) | |
247 | 278 | func Lock (LockPeriod,AssetTicker,APY) = { | |
248 | - | let check1 = throwIf((1 != size(i.payments)), " | |
279 | + | let check1 = throwIf((1 != size(i.payments)), "attach amount you want to lock") | |
249 | 280 | if ((check1 == check1)) | |
250 | 281 | then { | |
251 | 282 | let asset = toBase58String(value(i.payments[0].assetId)) | |
252 | - | let check2 = throwIf((getS(AssetTicker) != asset), " | |
283 | + | let check2 = throwIf((getS(AssetTicker) != asset), "asset not supported") | |
253 | 284 | if ((check2 == check2)) | |
254 | 285 | then { | |
255 | 286 | let lockPeriod = LockPeriod | |
262 | 293 | else (amountToStake > maxToStake), "staking amount is out of range") | |
263 | 294 | if ((check3 == check3)) | |
264 | 295 | then { | |
265 | - | let uUserId = (userId + user) | |
266 | - | let uAsset = (userId + lockedAsset) | |
267 | - | let uLockingPeriod = (userId + lockingPeriod) | |
268 | - | let uLockedAmount = (userId + lockedAmount) | |
269 | - | let uAPY = (userId + APY_Amount) | |
270 | - | let uUnlockEligibility = (userId + unlockEligibility) | |
271 | - | [writeStr(uUserId, userId), writeStr(uAsset, asset), writeInt(uLockingPeriod, lockPeriod), writeInt(uLockedAmount, i.payments[0].amount), writeInt(uUnlockEligibility, daysToBlocks(LockPeriod)), writeInt(uAPY, APY)] | |
296 | + | let uTotalLocked = (userId + totalLockedAMount) | |
297 | + | let uSumTotal = if (!(isDefined(getI(uTotalLocked)))) | |
298 | + | then 0 | |
299 | + | else (amountToStake + value(getI(uTotalLocked))) | |
300 | + | let check4 = throwIf((uSumTotal > maxToStake), "you have maxed out your quota") | |
301 | + | if ((check4 == check4)) | |
302 | + | then { | |
303 | + | let uEntryIndex = ((userId + AssetTicker) + entryIndex) | |
304 | + | let uIncrEntryIndex = incrementEntryIndex(uEntryIndex) | |
305 | + | let uEntryToString = ((("_" + AssetTicker) + "_") + toString(uIncrEntryIndex)) | |
306 | + | let uUserId = ((userId + uEntryToString) + user) | |
307 | + | let uAsset = ((userId + uEntryToString) + lockedAsset) | |
308 | + | let uLockingPeriod = ((userId + uEntryToString) + lockingPeriod) | |
309 | + | let uLockedAmount = ((userId + uEntryToString) + lockedAmount) | |
310 | + | let uAPY = ((userId + uEntryToString) + APY_Amount) | |
311 | + | let uUnlockEligibility = ((userId + uEntryToString) + unlockEligibility) | |
312 | + | let uAlreadyClaimed = ((userId + uEntryToString) + alreadyClaimed) | |
313 | + | [writeConstInteger(uEntryIndex, uIncrEntryIndex), writeConstString(uUserId, userId), writeConstString(uAsset, asset), writeConstInteger(uLockingPeriod, lockPeriod), writeConstInteger(uLockedAmount, i.payments[0].amount), writeConstInteger(uTotalLocked, uSumTotal), writeConstInteger(uUnlockEligibility, daysToBlocks(LockPeriod)), writeConstInteger(uAPY, APY), BooleanEntry(uAlreadyClaimed, false)] | |
314 | + | } | |
315 | + | else throw("Strict value is not equal to itself.") | |
272 | 316 | } | |
273 | 317 | else throw("Strict value is not equal to itself.") | |
274 | 318 | } | |
282 | 326 | @Callable(i) | |
283 | 327 | func Claim (AssetTicker) = { | |
284 | 328 | let userId = toString(i.caller) | |
285 | - | let uAsset = throwOrReturnS(getS((userId + lockedAsset)), ("there are no locked tokens for " + userId)) | |
286 | - | let uLockedAmount = throwOrReturnI(getI((userId + lockedAmount)), "internal error: could not retrieve locked amount") | |
287 | - | let stakingReserve = addressFromStringValue(throwOrReturnS(getS((AssetTicker + stakingStore)), "internal error: staking store not found for asset")) | |
288 | - | let APYAMount = throwOrReturnI(getI((userId + APY_Amount)), "internal error: failed to get APY") | |
289 | - | let period = throwOrReturnI(getI((userId + unlockEligibility)), "internal error: could not determine claim eligibility") | |
290 | - | let blocksLeft = if ((0 >= (period - height))) | |
291 | - | then 0 | |
292 | - | else (period - height) | |
293 | - | let daysLeft = blocksToDays(blocksLeft) | |
294 | - | let check1 = throwIf((period > height), (toString(daysLeft) + " days left to claim")) | |
295 | - | if ((check1 == check1)) | |
329 | + | let uEntryIndex = ((("_" + AssetTicker) + "_") + toString(throwOrReturnI(getI(((userId + AssetTicker) + entryIndex)), "no entry found for user"))) | |
330 | + | let uAlreadyClaimedKey = ((userId + uEntryIndex) + alreadyClaimed) | |
331 | + | let check0 = throwIf((valueOrErrorMessage(getBoolean(uAlreadyClaimedKey), "cannot ascertain claimability") == true), (("user + " + userId) + " already claimed")) | |
332 | + | if ((check0 == check0)) | |
296 | 333 | then { | |
297 | - | let transferAPYAmount = invoke(stakingReserve, "transferInterest", [userId, APYAMount, toBytes(uAsset)], nil) | |
298 | - | if ((transferAPYAmount == transferAPYAmount)) | |
299 | - | then [ScriptTransfer(addressFromStringValue(userId), uLockedAmount, toBytes(uAsset))] | |
334 | + | let uAsset = getSV(((userId + uEntryIndex) + lockedAsset)) | |
335 | + | let uLockedAmount = getIV(((userId + uEntryIndex) + lockedAmount)) | |
336 | + | let stakingReserve = addressFromStringValue(throwOrReturnS(getS((AssetTicker + stakingStore)), "internal error: no reserve found")) | |
337 | + | let APYAMount = getIV(((userId + uEntryIndex) + APY_Amount)) | |
338 | + | let period = getIV(((userId + uEntryIndex) + unlockEligibility)) | |
339 | + | let blocksLeft = if ((0 >= (period - height))) | |
340 | + | then 0 | |
341 | + | else (period - height) | |
342 | + | let daysLeft = blocksToDays(blocksLeft) | |
343 | + | let check1 = throwIf((period > height), (toString(daysLeft) + "/1000 days left to claim")) | |
344 | + | if ((check1 == check1)) | |
345 | + | then { | |
346 | + | let transferAPYAmount = invoke(stakingReserve, "transferInterest", [userId, APYAMount, toBytes(uAsset)], nil) | |
347 | + | if ((transferAPYAmount == transferAPYAmount)) | |
348 | + | then [ScriptTransfer(addressFromStringValue(userId), uLockedAmount, toBytes(uAsset)), BooleanEntry(uAlreadyClaimedKey, true)] | |
349 | + | else throw("Strict value is not equal to itself.") | |
350 | + | } | |
300 | 351 | else throw("Strict value is not equal to itself.") | |
301 | 352 | } | |
302 | 353 | else throw("Strict value is not equal to itself.") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lockingStore = this | |
5 | 5 | ||
6 | - | let stakingStore = "_ | |
6 | + | let stakingStore = "_Reserve" | |
7 | 7 | ||
8 | 8 | let minimumLockAmount = "_MinLockAmount" | |
9 | 9 | ||
10 | 10 | let maximumLockAmount = "_MaxLockAmount" | |
11 | 11 | ||
12 | 12 | let assetList = nil | |
13 | 13 | ||
14 | 14 | let unlockEligibility = "_Eligible_to_unlock_at_block" | |
15 | 15 | ||
16 | 16 | let lockedAmount = "_Amount_locked" | |
17 | 17 | ||
18 | 18 | let lockedAsset = "_Asset_locked" | |
19 | 19 | ||
20 | 20 | let user = "_User" | |
21 | 21 | ||
22 | 22 | let APY_Amount = "_APY_amount" | |
23 | 23 | ||
24 | + | let totalLockedAMount = "_Total_Locked_Amount" | |
25 | + | ||
24 | 26 | let lockingPeriod = "_Days_locked" | |
27 | + | ||
28 | + | let entryIndex = "_Entry_Index" | |
29 | + | ||
30 | + | let alreadyClaimed = "_Already_Claimed" | |
25 | 31 | ||
26 | 32 | let admin = "admin_" | |
27 | 33 | ||
28 | 34 | let BlockPerDay = 1440 | |
29 | - | ||
30 | - | let RBase = 10000000000000000 | |
31 | - | ||
32 | - | let factorsBase = 1000 | |
33 | 35 | ||
34 | 36 | let thirtyDaysLockPeriod = 30 | |
35 | 37 | ||
36 | 38 | let sixtyDaysLockPeriod = 60 | |
37 | 39 | ||
38 | 40 | let ninetyDaysLockPeriod = 90 | |
39 | 41 | ||
40 | 42 | func getI (key) = getInteger(this, key) | |
41 | 43 | ||
42 | 44 | ||
43 | 45 | func getS (key) = getString(this, key) | |
44 | 46 | ||
45 | 47 | ||
46 | 48 | func getIV (key) = value(getInteger(this, key)) | |
47 | 49 | ||
48 | 50 | ||
49 | 51 | func getSV (key) = value(getString(this, key)) | |
50 | 52 | ||
51 | 53 | ||
52 | 54 | func throwIf (condition,error) = if (condition) | |
53 | 55 | then throw(error) | |
54 | 56 | else true | |
55 | 57 | ||
56 | 58 | ||
57 | 59 | func throwOrReturnI (val,error) = match val { | |
58 | 60 | case val: Int => | |
59 | 61 | val | |
60 | 62 | case _ => | |
61 | 63 | throw(error) | |
62 | 64 | } | |
63 | 65 | ||
64 | 66 | ||
65 | 67 | func throwOrReturnS (val,error) = match val { | |
66 | 68 | case val: String => | |
67 | 69 | val | |
68 | 70 | case _ => | |
69 | 71 | throw(error) | |
70 | 72 | } | |
71 | 73 | ||
72 | 74 | ||
73 | 75 | func writeInt (key,value) = if ((0 > value)) | |
74 | 76 | then throw(((("writing negative value " + toString(value)) + " for key ") + key)) | |
75 | 77 | else IntegerEntry(key, value) | |
76 | 78 | ||
77 | 79 | ||
78 | 80 | func writeStr (key,value) = if ((" " == value)) | |
79 | 81 | then throw(("writing an empty string " + value)) | |
80 | 82 | else StringEntry(key, value) | |
81 | 83 | ||
82 | 84 | ||
83 | 85 | func daysToBlocks (days) = if (if (if ((days != thirtyDaysLockPeriod)) | |
84 | 86 | then true | |
85 | 87 | else (days != sixtyDaysLockPeriod)) | |
86 | 88 | then true | |
87 | 89 | else (days != ninetyDaysLockPeriod)) | |
88 | 90 | then throw("invalid Lock Period") | |
89 | 91 | else (((days + 1) * BlockPerDay) + height) | |
90 | 92 | ||
91 | 93 | ||
92 | 94 | func blocksToDays (blocksLeft) = if ((0 >= blocksLeft)) | |
93 | 95 | then 0 | |
94 | 96 | else { | |
95 | 97 | let multiplier = pow(10, 0, 3, 0, 0, CEILING) | |
96 | 98 | let daysleft = fraction(blocksLeft, multiplier, BlockPerDay) | |
97 | 99 | daysleft | |
98 | 100 | } | |
99 | 101 | ||
100 | 102 | ||
101 | 103 | func writeConstString (key,value) = if (!(isDefined(getS(key)))) | |
102 | 104 | then writeStr(key, value) | |
103 | 105 | else throw(("already initialized: " + key)) | |
104 | 106 | ||
105 | 107 | ||
106 | 108 | func writeConstInteger (key,value) = if (!(isDefined(getS(key)))) | |
107 | 109 | then writeInt(key, value) | |
108 | 110 | else throw(("already initialized: " + key)) | |
109 | 111 | ||
110 | 112 | ||
111 | 113 | func adminOnly (i) = { | |
112 | 114 | let AdminAddress = toString(i.caller) | |
113 | 115 | let otherAdminAddress = (admin + toString(i.caller)) | |
114 | 116 | if (if ((AdminAddress != valueOrElse(getS(admin), "not an admin"))) | |
115 | 117 | then true | |
116 | 118 | else (AdminAddress != valueOrElse(getS(otherAdminAddress), "not an admin"))) | |
117 | 119 | then throw("unauthorized") | |
118 | 120 | else true | |
119 | 121 | } | |
120 | 122 | ||
121 | 123 | ||
122 | 124 | func writeConfigValue (key,data) = match data { | |
123 | 125 | case data: String => | |
124 | 126 | writeConstString(key, data) | |
125 | 127 | case data: Int => | |
126 | 128 | writeConstInteger(key, data) | |
127 | 129 | case _ => | |
128 | 130 | throw("unsupported config type") | |
129 | 131 | } | |
132 | + | ||
133 | + | ||
134 | + | func incrementEntryIndex (key) = { | |
135 | + | let uIndex = getI(key) | |
136 | + | if (isDefined(uIndex)) | |
137 | + | then (value(uIndex) + 1) | |
138 | + | else 0 | |
139 | + | } | |
130 | 140 | ||
131 | 141 | ||
132 | 142 | @Callable(i) | |
133 | 143 | func addAsset (AssetTicker,AssetID,AssetStakingStore,AssetMinimumLockAmount,AssetMaximumLockAmount) = { | |
134 | 144 | let check = adminOnly(i) | |
135 | 145 | if ((check == check)) | |
136 | 146 | then { | |
137 | 147 | let aStakingStore = (AssetTicker + stakingStore) | |
138 | 148 | let aMinimumLockAmount = (AssetTicker + minimumLockAmount) | |
139 | 149 | let aMaximumLockAmount = (AssetTicker + maximumLockAmount) | |
140 | 150 | [writeConstString(AssetTicker, AssetID), writeConstString(aStakingStore, AssetStakingStore), writeConstInteger(aMinimumLockAmount, AssetMinimumLockAmount), writeConstInteger(aMaximumLockAmount, AssetMaximumLockAmount)] | |
141 | 151 | } | |
142 | 152 | else throw("Strict value is not equal to itself.") | |
143 | 153 | } | |
144 | 154 | ||
145 | 155 | ||
146 | 156 | ||
147 | 157 | @Callable(i) | |
148 | 158 | func getAssetIdByTicker (AssetTicker) = { | |
149 | 159 | let check = adminOnly(i) | |
150 | 160 | if ((check == check)) | |
151 | 161 | then { | |
152 | 162 | let a = throwOrReturnS(getS(AssetTicker), "asset not found") | |
153 | 163 | $Tuple2(nil, a) | |
154 | 164 | } | |
155 | 165 | else throw("Strict value is not equal to itself.") | |
156 | 166 | } | |
157 | 167 | ||
158 | 168 | ||
159 | 169 | ||
160 | 170 | @Callable(i) | |
161 | 171 | func init (AdminAddress) = [writeConstString(admin, toString(addressFromStringValue(AdminAddress)))] | |
162 | 172 | ||
163 | 173 | ||
164 | 174 | ||
165 | 175 | @Callable(i) | |
166 | 176 | func addAdmin (AdminAddress) = { | |
167 | 177 | let check = adminOnly(i) | |
168 | 178 | if ((check == check)) | |
169 | 179 | then { | |
170 | 180 | let newAdmin = (admin + AdminAddress) | |
171 | 181 | [writeConstString(newAdmin, AdminAddress)] | |
172 | 182 | } | |
173 | 183 | else throw("Strict value is not equal to itself.") | |
174 | 184 | } | |
175 | 185 | ||
176 | 186 | ||
177 | 187 | ||
178 | 188 | @Callable(i) | |
179 | 189 | func changeMainAdmin (address) = { | |
180 | 190 | let checks = adminOnly(i) | |
181 | 191 | if ((checks == checks)) | |
182 | 192 | then { | |
183 | 193 | let del = DeleteEntry(admin) | |
184 | 194 | if ((del == del)) | |
185 | 195 | then [writeConstString(admin, address)] | |
186 | 196 | else throw("Strict value is not equal to itself.") | |
187 | 197 | } | |
188 | 198 | else throw("Strict value is not equal to itself.") | |
189 | 199 | } | |
190 | 200 | ||
191 | 201 | ||
192 | 202 | ||
193 | 203 | @Callable(i) | |
194 | 204 | func updateOtherAdminAddress (address) = { | |
195 | 205 | let checks = adminOnly(i) | |
196 | 206 | if ((checks == checks)) | |
197 | 207 | then { | |
198 | 208 | let caller = toString(i.caller) | |
199 | 209 | let otherAdmin = (admin + caller) | |
200 | 210 | let checkOldAddress = throwOrReturnS(getS(otherAdmin), "no previous address found") | |
201 | 211 | if ((checkOldAddress == checkOldAddress)) | |
202 | 212 | then { | |
203 | 213 | let delAddress = DeleteEntry(otherAdmin) | |
204 | 214 | if ((delAddress == delAddress)) | |
205 | 215 | then [writeConstString(otherAdmin, address)] | |
206 | 216 | else throw("Strict value is not equal to itself.") | |
207 | 217 | } | |
208 | 218 | else throw("Strict value is not equal to itself.") | |
209 | 219 | } | |
210 | 220 | else throw("Strict value is not equal to itself.") | |
211 | 221 | } | |
212 | 222 | ||
213 | 223 | ||
214 | 224 | ||
215 | 225 | @Callable(i) | |
216 | 226 | func removeOtherAdmin (address) = { | |
217 | 227 | let checks = adminOnly(i) | |
218 | 228 | if ((checks == checks)) | |
219 | 229 | then { | |
220 | 230 | let otherAddress = (admin + address) | |
221 | 231 | let delAdmin = DeleteEntry(otherAddress) | |
222 | 232 | if ((delAdmin == delAdmin)) | |
223 | 233 | then nil | |
224 | 234 | else throw("Strict value is not equal to itself.") | |
225 | 235 | } | |
226 | 236 | else throw("Strict value is not equal to itself.") | |
227 | 237 | } | |
228 | 238 | ||
229 | 239 | ||
230 | 240 | ||
231 | 241 | @Callable(i) | |
232 | 242 | func updateConfigValue (key,data) = { | |
233 | 243 | let checks = adminOnly(i) | |
234 | 244 | if ((checks == checks)) | |
235 | 245 | then { | |
236 | 246 | let del = DeleteEntry(key) | |
237 | 247 | if ((del == del)) | |
238 | 248 | then [writeConfigValue(key, data)] | |
239 | 249 | else throw("Strict value is not equal to itself.") | |
240 | 250 | } | |
241 | 251 | else throw("Strict value is not equal to itself.") | |
242 | 252 | } | |
243 | 253 | ||
244 | 254 | ||
245 | 255 | ||
246 | 256 | @Callable(i) | |
257 | + | func getDaysLeftToClaim (userAddress) = { | |
258 | + | let check0 = adminOnly(i) | |
259 | + | if ((check0 == check0)) | |
260 | + | then { | |
261 | + | let check1 = valueOrErrorMessage(addressFromString(userAddress), "invalid address") | |
262 | + | if ((check1 == check1)) | |
263 | + | then { | |
264 | + | let uEntryIndex = ("_" + toString(throwOrReturnI(getI((userAddress + entryIndex)), ("no entry found for " + userAddress)))) | |
265 | + | let uUnlockEligibility = ((userAddress + uEntryIndex) + unlockEligibility) | |
266 | + | let uBlocks = throwOrReturnI(getI(uUnlockEligibility), "internal error") | |
267 | + | let uBlocksToDays = daysToBlocks((height - uBlocks)) | |
268 | + | $Tuple2(nil, uBlocksToDays) | |
269 | + | } | |
270 | + | else throw("Strict value is not equal to itself.") | |
271 | + | } | |
272 | + | else throw("Strict value is not equal to itself.") | |
273 | + | } | |
274 | + | ||
275 | + | ||
276 | + | ||
277 | + | @Callable(i) | |
247 | 278 | func Lock (LockPeriod,AssetTicker,APY) = { | |
248 | - | let check1 = throwIf((1 != size(i.payments)), " | |
279 | + | let check1 = throwIf((1 != size(i.payments)), "attach amount you want to lock") | |
249 | 280 | if ((check1 == check1)) | |
250 | 281 | then { | |
251 | 282 | let asset = toBase58String(value(i.payments[0].assetId)) | |
252 | - | let check2 = throwIf((getS(AssetTicker) != asset), " | |
283 | + | let check2 = throwIf((getS(AssetTicker) != asset), "asset not supported") | |
253 | 284 | if ((check2 == check2)) | |
254 | 285 | then { | |
255 | 286 | let lockPeriod = LockPeriod | |
256 | 287 | let userId = toString(i.caller) | |
257 | 288 | let amountToStake = i.payments[0].amount | |
258 | 289 | let minToStake = throwOrReturnI(getI((AssetTicker + minimumLockAmount)), "internal error: minimum stacking amount not specified") | |
259 | 290 | let maxToStake = throwOrReturnI(getI((AssetTicker + maximumLockAmount)), "internal error: maximum staking amount not specified") | |
260 | 291 | let check3 = throwIf(if ((minToStake > amountToStake)) | |
261 | 292 | then true | |
262 | 293 | else (amountToStake > maxToStake), "staking amount is out of range") | |
263 | 294 | if ((check3 == check3)) | |
264 | 295 | then { | |
265 | - | let uUserId = (userId + user) | |
266 | - | let uAsset = (userId + lockedAsset) | |
267 | - | let uLockingPeriod = (userId + lockingPeriod) | |
268 | - | let uLockedAmount = (userId + lockedAmount) | |
269 | - | let uAPY = (userId + APY_Amount) | |
270 | - | let uUnlockEligibility = (userId + unlockEligibility) | |
271 | - | [writeStr(uUserId, userId), writeStr(uAsset, asset), writeInt(uLockingPeriod, lockPeriod), writeInt(uLockedAmount, i.payments[0].amount), writeInt(uUnlockEligibility, daysToBlocks(LockPeriod)), writeInt(uAPY, APY)] | |
296 | + | let uTotalLocked = (userId + totalLockedAMount) | |
297 | + | let uSumTotal = if (!(isDefined(getI(uTotalLocked)))) | |
298 | + | then 0 | |
299 | + | else (amountToStake + value(getI(uTotalLocked))) | |
300 | + | let check4 = throwIf((uSumTotal > maxToStake), "you have maxed out your quota") | |
301 | + | if ((check4 == check4)) | |
302 | + | then { | |
303 | + | let uEntryIndex = ((userId + AssetTicker) + entryIndex) | |
304 | + | let uIncrEntryIndex = incrementEntryIndex(uEntryIndex) | |
305 | + | let uEntryToString = ((("_" + AssetTicker) + "_") + toString(uIncrEntryIndex)) | |
306 | + | let uUserId = ((userId + uEntryToString) + user) | |
307 | + | let uAsset = ((userId + uEntryToString) + lockedAsset) | |
308 | + | let uLockingPeriod = ((userId + uEntryToString) + lockingPeriod) | |
309 | + | let uLockedAmount = ((userId + uEntryToString) + lockedAmount) | |
310 | + | let uAPY = ((userId + uEntryToString) + APY_Amount) | |
311 | + | let uUnlockEligibility = ((userId + uEntryToString) + unlockEligibility) | |
312 | + | let uAlreadyClaimed = ((userId + uEntryToString) + alreadyClaimed) | |
313 | + | [writeConstInteger(uEntryIndex, uIncrEntryIndex), writeConstString(uUserId, userId), writeConstString(uAsset, asset), writeConstInteger(uLockingPeriod, lockPeriod), writeConstInteger(uLockedAmount, i.payments[0].amount), writeConstInteger(uTotalLocked, uSumTotal), writeConstInteger(uUnlockEligibility, daysToBlocks(LockPeriod)), writeConstInteger(uAPY, APY), BooleanEntry(uAlreadyClaimed, false)] | |
314 | + | } | |
315 | + | else throw("Strict value is not equal to itself.") | |
272 | 316 | } | |
273 | 317 | else throw("Strict value is not equal to itself.") | |
274 | 318 | } | |
275 | 319 | else throw("Strict value is not equal to itself.") | |
276 | 320 | } | |
277 | 321 | else throw("Strict value is not equal to itself.") | |
278 | 322 | } | |
279 | 323 | ||
280 | 324 | ||
281 | 325 | ||
282 | 326 | @Callable(i) | |
283 | 327 | func Claim (AssetTicker) = { | |
284 | 328 | let userId = toString(i.caller) | |
285 | - | let uAsset = throwOrReturnS(getS((userId + lockedAsset)), ("there are no locked tokens for " + userId)) | |
286 | - | let uLockedAmount = throwOrReturnI(getI((userId + lockedAmount)), "internal error: could not retrieve locked amount") | |
287 | - | let stakingReserve = addressFromStringValue(throwOrReturnS(getS((AssetTicker + stakingStore)), "internal error: staking store not found for asset")) | |
288 | - | let APYAMount = throwOrReturnI(getI((userId + APY_Amount)), "internal error: failed to get APY") | |
289 | - | let period = throwOrReturnI(getI((userId + unlockEligibility)), "internal error: could not determine claim eligibility") | |
290 | - | let blocksLeft = if ((0 >= (period - height))) | |
291 | - | then 0 | |
292 | - | else (period - height) | |
293 | - | let daysLeft = blocksToDays(blocksLeft) | |
294 | - | let check1 = throwIf((period > height), (toString(daysLeft) + " days left to claim")) | |
295 | - | if ((check1 == check1)) | |
329 | + | let uEntryIndex = ((("_" + AssetTicker) + "_") + toString(throwOrReturnI(getI(((userId + AssetTicker) + entryIndex)), "no entry found for user"))) | |
330 | + | let uAlreadyClaimedKey = ((userId + uEntryIndex) + alreadyClaimed) | |
331 | + | let check0 = throwIf((valueOrErrorMessage(getBoolean(uAlreadyClaimedKey), "cannot ascertain claimability") == true), (("user + " + userId) + " already claimed")) | |
332 | + | if ((check0 == check0)) | |
296 | 333 | then { | |
297 | - | let transferAPYAmount = invoke(stakingReserve, "transferInterest", [userId, APYAMount, toBytes(uAsset)], nil) | |
298 | - | if ((transferAPYAmount == transferAPYAmount)) | |
299 | - | then [ScriptTransfer(addressFromStringValue(userId), uLockedAmount, toBytes(uAsset))] | |
334 | + | let uAsset = getSV(((userId + uEntryIndex) + lockedAsset)) | |
335 | + | let uLockedAmount = getIV(((userId + uEntryIndex) + lockedAmount)) | |
336 | + | let stakingReserve = addressFromStringValue(throwOrReturnS(getS((AssetTicker + stakingStore)), "internal error: no reserve found")) | |
337 | + | let APYAMount = getIV(((userId + uEntryIndex) + APY_Amount)) | |
338 | + | let period = getIV(((userId + uEntryIndex) + unlockEligibility)) | |
339 | + | let blocksLeft = if ((0 >= (period - height))) | |
340 | + | then 0 | |
341 | + | else (period - height) | |
342 | + | let daysLeft = blocksToDays(blocksLeft) | |
343 | + | let check1 = throwIf((period > height), (toString(daysLeft) + "/1000 days left to claim")) | |
344 | + | if ((check1 == check1)) | |
345 | + | then { | |
346 | + | let transferAPYAmount = invoke(stakingReserve, "transferInterest", [userId, APYAMount, toBytes(uAsset)], nil) | |
347 | + | if ((transferAPYAmount == transferAPYAmount)) | |
348 | + | then [ScriptTransfer(addressFromStringValue(userId), uLockedAmount, toBytes(uAsset)), BooleanEntry(uAlreadyClaimedKey, true)] | |
349 | + | else throw("Strict value is not equal to itself.") | |
350 | + | } | |
300 | 351 | else throw("Strict value is not equal to itself.") | |
301 | 352 | } | |
302 | 353 | else throw("Strict value is not equal to itself.") | |
303 | 354 | } | |
304 | 355 | ||
305 | 356 |
github/deemru/w8io/169f3d6 55.29 ms ◑