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