tx · CncF2eq24FT7AgN7PvUyFwbWFpPZE5LS5tfpFXWinKn5 3N4UhavKsWv4dPmmhtaYT573ALxuvsAp6M4: -0.01400000 Waves 2022.06.07 14:48 [2085907] smart account 3N4UhavKsWv4dPmmhtaYT573ALxuvsAp6M4 > SELF 0.00000000 Waves
{ "type": 13, "id": "CncF2eq24FT7AgN7PvUyFwbWFpPZE5LS5tfpFXWinKn5", "fee": 1400000, "feeAssetId": null, "timestamp": 1654602499298, "version": 2, "chainId": 84, "sender": "3N4UhavKsWv4dPmmhtaYT573ALxuvsAp6M4", "senderPublicKey": "5nJ4v4Wx6sdXhiDZNrpW7m1aSDsTgTgFJVBgmPMPtbUM", "proofs": [ "3aEKWs9KcAken4Mj23JFcnzY7rMiXhbHxR6sFBn4qTpBQLDrL9ip9MNJfheTiY3Scn4Zb6dhCDjH55VXDMUfeKun" ], "script": "base64:AAIFAAAAAAAAACIIAhIFCgMICAESBgoECAgBARIFCgMICAESAwoBCBIDCgEIAAAAFwAAAAAGc3Rha2VyAgAAAAZzdGFrZXIAAAAABWFkbWluAgAAAAZhZG1pbl8AAAAAC2Fzc2V0SWRDYWxsAgAAAAhBc3NldCBJRAAAAAAKZW50cnlJbmRleAIAAAAMX0VudHJ5X0luZGV4AAAAAApBUFlfQW1vdW50AgAAAAtfQVBZX0Ftb3VudAEAAAAEZ2V0SQAAAAEAAAADa2V5CQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQEAAAAEZ2V0UwAAAAEAAAADa2V5CQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQEAAAAFZ2V0SVYAAAABAAAAA2tleQkBAAAABXZhbHVlAAAAAQkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkBAAAABWdldFNWAAAAAQAAAANrZXkJAQAAAAV2YWx1ZQAAAAEJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AQAAAAd0aHJvd0lmAAAAAgAAAAljb25kaXRpb24AAAAFZXJyb3IDBQAAAAljb25kaXRpb24JAA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AAA1zdGFrZXJBZGRyZXNzCQACWQAAAAEJAQAAAAVnZXRTVgAAAAECAAAABnN0YWtlcgQAAAADcnVuCQAD/AAAAAQJAQAAAAdBZGRyZXNzAAAAAQUAAAANc3Rha2VyQWRkcmVzcwIAAAATX2dldEFzc2V0SWRCeVRpY2tlcgkABEwAAAACBQAAAAtBc3NldFRpY2tlcgUAAAADbmlsBQAAAANuaWwEAAAAByRtYXRjaDAFAAAAA3J1bgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIFAAAAC2Fzc2V0SWRDYWxsBQAAAAFhBQAAAANuaWwFAAAAA25pbAkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAAADhv4hw==", "height": 2085907, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AhJ9gN3q52mB3XWGJZdgbYBTSocn5f8uHFzMUBXyX7wP Next: D3RrRxANwZrW9uB6F5xnbJWUVdVEz16ARpqu9ynspmbH Diff:
Old | New | Differences | |
---|---|---|---|
119 | 119 | ||
120 | 120 | ||
121 | 121 | @Callable(i) | |
122 | - | func getAPYAmount (user,AssetTicker, | |
122 | + | func getAPYAmount (user,AssetTicker,EntryIndex) = { | |
123 | 123 | let check = stakerOnly(i) | |
124 | 124 | if ((check == check)) | |
125 | 125 | then { | |
126 | - | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(uIndex)) | |
127 | - | let uIndexValue = valueOrErrorMessage(getS(uEntryToString), ("no entry for " + user)) | |
128 | - | let uUser = (uIndexValue + APY_Amount) | |
129 | - | let uAPYAmount = valueOrErrorMessage(getI(uUser), ("APY not computed for " + user)) | |
126 | + | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(EntryIndex)) | |
127 | + | let uAPY = (uEntryToString + APY_Amount) | |
128 | + | let uAPYAmount = valueOrErrorMessage(getI(uAPY), ("APY not computed for " + user)) | |
130 | 129 | $Tuple2(nil, uAPYAmount) | |
131 | 130 | } | |
132 | 131 | else throw("Strict value is not equal to itself.") | |
135 | 134 | ||
136 | 135 | ||
137 | 136 | @Callable(i) | |
138 | - | func storeAPYAmount (user,AssetTicker,APYAmount) = { | |
137 | + | func storeAPYAmount (user,AssetTicker,APYAmount,EntryIndex) = { | |
139 | 138 | let check = adminOnly(i) | |
140 | 139 | if ((check == check)) | |
141 | 140 | then { | |
142 | 141 | let uEntryIndex = (((user + "_") + AssetTicker) + entryIndex) | |
143 | - | let uIndex = incrementEntryIndex(uEntryIndex) | |
144 | - | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(uIndex)) | |
145 | - | let uAPY = (uEntryIndex + APY_Amount) | |
146 | - | [writeConstInteger(uEntryToString, uIndex), writeConstInteger(uAPY, value(APYAmount))] | |
142 | + | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(EntryIndex)) | |
143 | + | let uAPY = (uEntryToString + APY_Amount) | |
144 | + | [writeConstInteger(uEntryToString, EntryIndex), writeConstInteger(uAPY, value(APYAmount))] | |
147 | 145 | } | |
148 | 146 | else throw("Strict value is not equal to itself.") | |
149 | 147 | } | |
151 | 149 | ||
152 | 150 | ||
153 | 151 | @Callable(i) | |
154 | - | func deleteAPYAmount (user,AssetTicker, | |
152 | + | func deleteAPYAmount (user,AssetTicker,EntryIndex) = { | |
155 | 153 | let check = adminOnly(i) | |
156 | 154 | if ((check == check)) | |
157 | 155 | then { | |
158 | 156 | let uEntryIndex = ((((user + "_") + AssetTicker) + "_APY_") + entryIndex) | |
159 | - | let | |
160 | - | let uAPY = ( | |
157 | + | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(EntryIndex)) | |
158 | + | let uAPY = (uEntryToString + APY_Amount) | |
161 | 159 | [DeleteEntry(uAPY)] | |
162 | 160 | } | |
163 | 161 | 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 staker = "staker" | |
5 | 5 | ||
6 | 6 | let admin = "admin_" | |
7 | 7 | ||
8 | 8 | let assetIdCall = "Asset ID" | |
9 | 9 | ||
10 | 10 | let entryIndex = "_Entry_Index" | |
11 | 11 | ||
12 | 12 | let APY_Amount = "_APY_Amount" | |
13 | 13 | ||
14 | 14 | func getI (key) = getInteger(this, key) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getS (key) = getString(this, key) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getIV (key) = value(getInteger(this, key)) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func getSV (key) = value(getString(this, key)) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func throwIf (condition,error) = if (condition) | |
27 | 27 | then throw(error) | |
28 | 28 | else true | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | let thirtyDaysLockPeriod = 30 | |
32 | 32 | ||
33 | 33 | let sixtyDaysLockPeriod = 60 | |
34 | 34 | ||
35 | 35 | let ninetyDaysLockPeriod = 90 | |
36 | 36 | ||
37 | 37 | func throwOrReturnI (val,error) = match val { | |
38 | 38 | case val: Int => | |
39 | 39 | val | |
40 | 40 | case _ => | |
41 | 41 | throw(error) | |
42 | 42 | } | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func throwOrReturnS (val,error) = match val { | |
46 | 46 | case val: String => | |
47 | 47 | val | |
48 | 48 | case _ => | |
49 | 49 | throw(error) | |
50 | 50 | } | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | func writeInt (key,value) = if ((0 > value)) | |
54 | 54 | then throw(((("writing negative value " + toString(value)) + " for key ") + key)) | |
55 | 55 | else IntegerEntry(key, value) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func writeStr (key,value) = if ((" " == value)) | |
59 | 59 | then throw(("writing an empty string " + value)) | |
60 | 60 | else StringEntry(key, value) | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func writeConstString (key,value) = if (!(isDefined(getS(key)))) | |
64 | 64 | then writeStr(key, value) | |
65 | 65 | else throw(("already initialized: " + key)) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func writeConstInteger (key,value) = if (!(isDefined(getS(key)))) | |
69 | 69 | then writeInt(key, value) | |
70 | 70 | else throw(("already initialized: " + key)) | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func adminOnly (i) = { | |
74 | 74 | let inputAddress = toBase58String(i.caller.bytes) | |
75 | 75 | let otherAdmin = (admin + inputAddress) | |
76 | 76 | match getS(admin) { | |
77 | 77 | case a: String => | |
78 | 78 | if ((inputAddress != getS(admin))) | |
79 | 79 | then throw("unauthorized") | |
80 | 80 | else true | |
81 | 81 | case _ => | |
82 | 82 | match getS(otherAdmin) { | |
83 | 83 | case b: String => | |
84 | 84 | if ((inputAddress != getS(otherAdmin))) | |
85 | 85 | then throw("unauthorized") | |
86 | 86 | else true | |
87 | 87 | case _ => | |
88 | 88 | throw("unauthorizd") | |
89 | 89 | } | |
90 | 90 | } | |
91 | 91 | } | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func stakerOnly (i) = { | |
95 | 95 | let inputAddress = toBase58String(i.caller.bytes) | |
96 | 96 | let check = if ((inputAddress != getS(staker))) | |
97 | 97 | then throw("unauthorized") | |
98 | 98 | else true | |
99 | 99 | check | |
100 | 100 | } | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | func writeConfigValue (key,data) = match data { | |
104 | 104 | case data: String => | |
105 | 105 | writeConstString(key, data) | |
106 | 106 | case data: Int => | |
107 | 107 | writeConstInteger(key, data) | |
108 | 108 | case _ => | |
109 | 109 | throw("unsupported config type") | |
110 | 110 | } | |
111 | 111 | ||
112 | 112 | ||
113 | 113 | func incrementEntryIndex (key) = { | |
114 | 114 | let uIndex = getI(key) | |
115 | 115 | if (isDefined(uIndex)) | |
116 | 116 | then (value(uIndex) + 1) | |
117 | 117 | else 0 | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | @Callable(i) | |
122 | - | func getAPYAmount (user,AssetTicker, | |
122 | + | func getAPYAmount (user,AssetTicker,EntryIndex) = { | |
123 | 123 | let check = stakerOnly(i) | |
124 | 124 | if ((check == check)) | |
125 | 125 | then { | |
126 | - | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(uIndex)) | |
127 | - | let uIndexValue = valueOrErrorMessage(getS(uEntryToString), ("no entry for " + user)) | |
128 | - | let uUser = (uIndexValue + APY_Amount) | |
129 | - | let uAPYAmount = valueOrErrorMessage(getI(uUser), ("APY not computed for " + user)) | |
126 | + | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(EntryIndex)) | |
127 | + | let uAPY = (uEntryToString + APY_Amount) | |
128 | + | let uAPYAmount = valueOrErrorMessage(getI(uAPY), ("APY not computed for " + user)) | |
130 | 129 | $Tuple2(nil, uAPYAmount) | |
131 | 130 | } | |
132 | 131 | else throw("Strict value is not equal to itself.") | |
133 | 132 | } | |
134 | 133 | ||
135 | 134 | ||
136 | 135 | ||
137 | 136 | @Callable(i) | |
138 | - | func storeAPYAmount (user,AssetTicker,APYAmount) = { | |
137 | + | func storeAPYAmount (user,AssetTicker,APYAmount,EntryIndex) = { | |
139 | 138 | let check = adminOnly(i) | |
140 | 139 | if ((check == check)) | |
141 | 140 | then { | |
142 | 141 | let uEntryIndex = (((user + "_") + AssetTicker) + entryIndex) | |
143 | - | let uIndex = incrementEntryIndex(uEntryIndex) | |
144 | - | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(uIndex)) | |
145 | - | let uAPY = (uEntryIndex + APY_Amount) | |
146 | - | [writeConstInteger(uEntryToString, uIndex), writeConstInteger(uAPY, value(APYAmount))] | |
142 | + | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(EntryIndex)) | |
143 | + | let uAPY = (uEntryToString + APY_Amount) | |
144 | + | [writeConstInteger(uEntryToString, EntryIndex), writeConstInteger(uAPY, value(APYAmount))] | |
147 | 145 | } | |
148 | 146 | else throw("Strict value is not equal to itself.") | |
149 | 147 | } | |
150 | 148 | ||
151 | 149 | ||
152 | 150 | ||
153 | 151 | @Callable(i) | |
154 | - | func deleteAPYAmount (user,AssetTicker, | |
152 | + | func deleteAPYAmount (user,AssetTicker,EntryIndex) = { | |
155 | 153 | let check = adminOnly(i) | |
156 | 154 | if ((check == check)) | |
157 | 155 | then { | |
158 | 156 | let uEntryIndex = ((((user + "_") + AssetTicker) + "_APY_") + entryIndex) | |
159 | - | let | |
160 | - | let uAPY = ( | |
157 | + | let uEntryToString = ((((user + "_") + AssetTicker) + "_") + toString(EntryIndex)) | |
158 | + | let uAPY = (uEntryToString + APY_Amount) | |
161 | 159 | [DeleteEntry(uAPY)] | |
162 | 160 | } | |
163 | 161 | else throw("Strict value is not equal to itself.") | |
164 | 162 | } | |
165 | 163 | ||
166 | 164 | ||
167 | 165 | ||
168 | 166 | @Callable(i) | |
169 | 167 | func init (stakerAddress) = [writeConstString(staker, stakerAddress), writeConstString(admin, toBase58String(this.bytes))] | |
170 | 168 | ||
171 | 169 | ||
172 | 170 | ||
173 | 171 | @Callable(i) | |
174 | 172 | func getAssetIdByTicker (AssetTicker) = { | |
175 | 173 | let checks = adminOnly(i) | |
176 | 174 | if ((checks == checks)) | |
177 | 175 | then { | |
178 | 176 | let stakerAddress = fromBase58String(getSV("staker")) | |
179 | 177 | let run = invoke(Address(stakerAddress), "_getAssetIdByTicker", [AssetTicker], nil) | |
180 | 178 | match run { | |
181 | 179 | case a: String => | |
182 | 180 | [StringEntry(assetIdCall, a)] | |
183 | 181 | case _ => | |
184 | 182 | nil | |
185 | 183 | } | |
186 | 184 | } | |
187 | 185 | else throw("Strict value is not equal to itself.") | |
188 | 186 | } | |
189 | 187 | ||
190 | 188 |
github/deemru/w8io/026f985 44.91 ms ◑