tx · 8cTTKCu9mNNEmPMnZGfWW83a2WK5TKZ8N7RrBh3rjAcS 3Mu5kasZ85VY5xUCpPYoWr6fBzh6eGZwcnt: -0.01000000 Waves 2023.05.22 10:46 [2588893] smart account 3Mu5kasZ85VY5xUCpPYoWr6fBzh6eGZwcnt > SELF 0.00000000 Waves
{ "type": 13, "id": "8cTTKCu9mNNEmPMnZGfWW83a2WK5TKZ8N7RrBh3rjAcS", "fee": 1000000, "feeAssetId": null, "timestamp": 1684741609755, "version": 2, "chainId": 84, "sender": "3Mu5kasZ85VY5xUCpPYoWr6fBzh6eGZwcnt", "senderPublicKey": "6VehQ4nhpSn9EW76xuyThbHcUFYhjEbb4sJDrys5ZEx5", "proofs": [ "5tr6x1uYZr7wmkfKhvRh83vfSZdRutLRBxPZqUAjzWRYmAEjKHMXrSgsPsctjgTrZSoxS65eAQmRwsHncqPCkQ5w" ], "script": "base64:BgIOCAISABIDCgEBEgMKAQEAAwFpAQZnZXROdW0ACQCUCgIFA25pbAAHAWkBDnNldHRlcklOVEVSTkFMAQFuBAVjaGVjawMJAAACCAUBaQZjYWxsZXIFBHRoaXMGCQACAQIHRVJST1IgMQMJAAACBQVjaGVjawUFY2hlY2sEBnRpbWVzdAQHJG1hdGNoMAkA7QcBBQZoZWlnaHQDCQABAgUHJG1hdGNoMAIJQmxvY2tJbmZvBAJiaQUHJG1hdGNoMAgFAmJpCXRpbWVzdGFtcAkAAgECB0VSUk9SIDIJAMwIAgkBDEludGVnZXJFbnRyeQICCG51bVZhbHVlBQFuCQDMCAIJAQxJbnRlZ2VyRW50cnkCAgFoBQZoZWlnaHQJAMwIAgkBDEludGVnZXJFbnRyeQICAXQFBnRpbWVzdAUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAWkBBnNldHRlcgEBbgQNb3RoZXJDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQIjM01wTXVHTjhyVzlFcFB3ekVUQVF6ODhQZTlUUWhTd2lyaXEEAnRjCQD8BwQFBHRoaXMCDnNldHRlcklOVEVSTkFMCQDMCAIFAW4FA25pbAUDbmlsAwkAAAIFAnRjBQJ0YwQCb2MJAP0HBAUNb3RoZXJDb250cmFjdAIGdXBkYXRlBQNuaWwFA25pbAkAlAoCBQNuaWwFAm9jCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAIuQk5g=", "height": 2588893, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: B7Wf966y9YKVJPyzFPmxaWQ7GA2uqrLCF5G7fmpicnMY Next: FJm2mXh7QqjoWrWwb63FbPXYWxTdpkX2uUyt4ug4WnMn Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let SEP = "__" | |
5 | - | ||
6 | - | func wrapErr (msg) = makeString(["emission.ride:", toString(this), msg], " ") | |
7 | - | ||
8 | - | ||
9 | - | func throwErr (msg) = throw(wrapErr(msg)) | |
10 | - | ||
11 | - | ||
12 | - | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
13 | - | ||
14 | - | ||
15 | - | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
16 | - | ||
17 | - | ||
18 | - | let keyVotingVerifiedContract = "%s%s__config__votingVerifiedContract" | |
19 | - | ||
20 | - | let keyVotingEmissionCandidateContract = "%s%s__config__votingEmissionCandidateContract" | |
21 | - | ||
22 | - | let keyUserPoolsContract = "%s%s__config__userPoolsContract" | |
23 | - | ||
24 | - | let keyVotingEmissionRateContract = "%s%s__config__votingEmissionRateContract" | |
25 | - | ||
26 | - | let votingVerifiedContract = addressFromStringValue(getStringOrFail(this, keyVotingVerifiedContract)) | |
27 | - | ||
28 | - | let votingEmissionCandidateContract = addressFromStringValue(getStringOrFail(this, keyVotingEmissionCandidateContract)) | |
29 | - | ||
30 | - | let userPoolsContract = addressFromStringValue(getStringOrFail(this, keyUserPoolsContract)) | |
31 | - | ||
32 | - | let votingEmissionRateContract = addressFromStringValue(getStringOrFail(this, keyVotingEmissionRateContract)) | |
33 | - | ||
34 | - | let IdxFactoryCfgStakingDapp = 1 | |
35 | - | ||
36 | - | let IdxFactoryCfgBoostingDapp = 2 | |
37 | - | ||
38 | - | let IdxFactoryCfgIdoDapp = 3 | |
39 | - | ||
40 | - | let IdxFactoryCfgTeamDapp = 4 | |
41 | - | ||
42 | - | let IdxFactoryCfgEmissionDapp = 5 | |
43 | - | ||
44 | - | let IdxFactoryCfgRestDapp = 6 | |
45 | - | ||
46 | - | let IdxFactoryCfgSlippageDapp = 7 | |
47 | - | ||
48 | - | let IdxFactoryCfgGwxRewardDapp = 10 | |
49 | - | ||
50 | - | func keyFactoryCfg () = "%s__factoryConfig" | |
51 | - | ||
52 | - | ||
53 | - | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
54 | - | ||
55 | - | ||
56 | - | func keyFactoryLpList () = "%s__lpTokensList" | |
57 | - | ||
58 | - | ||
59 | - | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
60 | - | ||
61 | - | ||
62 | - | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
63 | - | ||
64 | - | ||
65 | - | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(this, keyFactoryAddress())) | |
66 | - | ||
67 | - | ||
68 | - | func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP) | |
69 | - | ||
70 | - | ||
71 | - | func readFactoryCfgOrFail (factory) = split(getStringOrFail(factory, keyFactoryCfg()), SEP) | |
72 | - | ||
73 | - | ||
74 | - | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
75 | - | ||
76 | - | ||
77 | - | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
78 | - | ||
79 | - | ||
80 | - | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
81 | - | ||
82 | - | ||
83 | - | func getGwxRewardAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgGwxRewardDapp]) | |
84 | - | ||
85 | - | ||
86 | - | func keyConfig () = "%s__config" | |
87 | - | ||
88 | - | ||
89 | - | func keyRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
90 | - | ||
91 | - | ||
92 | - | func keyRatePerBlockMaxStartFrom (timestamp,block) = makeString(["%s%s%d%d__ratePerBlockMax__start", toString(timestamp), toString(block)], SEP) | |
93 | - | ||
94 | - | ||
95 | - | func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
96 | - | ||
97 | - | ||
98 | - | func keyRatePerBlockStartFrom (timestamp,block) = makeString(["%s%s%d%d__ratePerBlock__start", toString(timestamp), toString(block)], SEP) | |
99 | - | ||
100 | - | ||
101 | - | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
102 | - | ||
103 | - | ||
104 | - | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
105 | - | ||
106 | - | ||
107 | - | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
108 | - | ||
109 | - | ||
110 | - | func keyBoostCoeff () = "%s__boostCoeff" | |
111 | - | ||
112 | - | ||
113 | - | let boostCoeffDefault = 3 | |
114 | - | ||
115 | - | let boostCoeff = valueOrElse(getInteger(this, keyBoostCoeff()), boostCoeffDefault) | |
116 | - | ||
117 | - | func keyGwxHoldersRewardCurrent () = "%s%s__gwxHoldersReward__current" | |
118 | - | ||
119 | - | ||
120 | - | func keyGwxHoldersRewardNext () = "%s%s__gwxHoldersReward__next" | |
121 | - | ||
122 | - | ||
123 | - | func keyManagerPublicKey () = "%s__managerPublicKey" | |
124 | - | ||
125 | - | ||
126 | - | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
127 | - | ||
128 | - | ||
129 | - | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
130 | - | case s: String => | |
131 | - | addressFromStringValue(s) | |
132 | - | case _ => | |
133 | - | this | |
134 | - | } | |
135 | - | ||
136 | - | ||
137 | - | func managerPublicKeyOrUnit () = { | |
138 | - | let managerVaultAddress = getManagerVaultAddressOrThis() | |
139 | - | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
140 | - | case s: String => | |
141 | - | fromBase58String(s) | |
142 | - | case _: Unit => | |
143 | - | unit | |
144 | - | case _ => | |
145 | - | throw("Match error") | |
146 | - | } | |
147 | - | } | |
148 | - | ||
149 | - | ||
150 | - | func mustManager (i) = { | |
151 | - | let pd = throwErr("Permission denied") | |
152 | - | match managerPublicKeyOrUnit() { | |
153 | - | case pk: ByteVector => | |
154 | - | if ((i.callerPublicKey == pk)) | |
155 | - | then true | |
156 | - | else pd | |
157 | - | case _: Unit => | |
158 | - | if ((i.caller == this)) | |
159 | - | then true | |
160 | - | else pd | |
161 | - | case _ => | |
162 | - | throw("Match error") | |
163 | - | } | |
164 | - | } | |
165 | 4 | ||
166 | 5 | ||
167 | 6 | @Callable(i) | |
168 | - | func constructor (factoryAddress,ratePerBlockMax,ratePerBlock,emissionStartBlock,emissionDuration,emissionStartTimestamp,wxAssetIdStr) = { | |
169 | - | let checkCaller = mustManager(i) | |
170 | - | if ((checkCaller == checkCaller)) | |
171 | - | then [IntegerEntry(keyRatePerBlockMaxStartFrom(emissionStartTimestamp, emissionStartBlock), ratePerBlockMax), IntegerEntry(keyRatePerBlockMaxCurrent(), ratePerBlockMax), IntegerEntry(keyRatePerBlockStartFrom(emissionStartTimestamp, emissionStartBlock), ratePerBlock), IntegerEntry(keyRatePerBlockCurrent(), ratePerBlock), IntegerEntry(keyEmissionStartBlock(), emissionStartBlock), IntegerEntry(keyEmissionDurationInBlocks(), emissionDuration), IntegerEntry(keyEmissionEndBlock(), (emissionStartBlock + emissionDuration)), StringEntry(keyFactoryAddress(), factoryAddress), StringEntry(keyConfig(), ("%s__" + wxAssetIdStr))] | |
172 | - | else throw("Strict value is not equal to itself.") | |
173 | - | } | |
7 | + | func getNum () = $Tuple2(nil, 7) | |
174 | 8 | ||
175 | 9 | ||
176 | 10 | ||
177 | 11 | @Callable(i) | |
178 | - | func constructorV2 (votingVerifiedContractPrm) = { | |
179 | - | let checkCaller = mustManager(i) | |
180 | - | if ((checkCaller == checkCaller)) | |
181 | - | then $Tuple2([StringEntry(keyVotingVerifiedContract, votingVerifiedContractPrm)], unit) | |
182 | - | else throw("Strict value is not equal to itself.") | |
183 | - | } | |
184 | - | ||
185 | - | ||
186 | - | ||
187 | - | @Callable(i) | |
188 | - | func emit (amount) = if ((0 >= amount)) | |
189 | - | then $Tuple2(nil, nil) | |
190 | - | else { | |
191 | - | let factoryContract = readFactoryAddressOrFail() | |
192 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
193 | - | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
194 | - | let gwxRewardsContract = getGwxRewardAddressOrFail(factoryCfg) | |
195 | - | let caller = i.caller | |
196 | - | if (if ((caller != stakingContract)) | |
197 | - | then (caller != gwxRewardsContract) | |
198 | - | else false) | |
199 | - | then throwErr("permissions denied") | |
200 | - | else { | |
201 | - | let wxAssetIdStr = split(getStringOrFail(this, keyConfig()), SEP)[1] | |
202 | - | let wxAssetId = fromBase58String(wxAssetIdStr) | |
203 | - | $Tuple2([ScriptTransfer(caller, amount, wxAssetId)], [wxAssetId]) | |
204 | - | } | |
205 | - | } | |
206 | - | ||
207 | - | ||
208 | - | ||
209 | - | @Callable(i) | |
210 | - | func burn () = { | |
211 | - | let factoryContract = readFactoryAddressOrFail() | |
212 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
213 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
214 | - | if ((size(i.payments) != 1)) | |
215 | - | then throwErr("exact one payment is allowed") | |
216 | - | else { | |
217 | - | let pmt = i.payments[0] | |
218 | - | let assetId = value(pmt.assetId) | |
219 | - | let pmtAmount = pmt.amount | |
220 | - | let wxAssetId = fromBase58String(split(getStringOrFail(this, keyConfig()), SEP)[1]) | |
221 | - | if ((assetId != wxAssetId)) | |
222 | - | then throwErr("invalid wxAssetId is passed") | |
223 | - | else if (!(containsElement([boostingContract, votingVerifiedContract, votingEmissionCandidateContract, userPoolsContract], i.caller))) | |
224 | - | then throwErr("permissions denied") | |
225 | - | else [Burn(assetId, pmtAmount), StringEntry(("%s%s%s__history__burn__" + toBase58String(i.transactionId)), makeString(["%d%d%d", toString(height), toString(lastBlock.timestamp), toString(pmtAmount)], SEP))] | |
12 | + | func setterINTERNAL (n) = { | |
13 | + | let check = if ((i.caller == this)) | |
14 | + | then true | |
15 | + | else throw("ERROR 1") | |
16 | + | if ((check == check)) | |
17 | + | then { | |
18 | + | let timest = match blockInfoByHeight(height) { | |
19 | + | case bi: BlockInfo => | |
20 | + | bi.timestamp | |
21 | + | case _ => | |
22 | + | throw("ERROR 2") | |
226 | 23 | } | |
227 | - | } | |
228 | - | ||
229 | - | ||
230 | - | ||
231 | - | @Callable(i) | |
232 | - | func gwxHoldersRewardUpdate () = { | |
233 | - | let factoryContract = readFactoryAddressOrFail() | |
234 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
235 | - | let gwxRewardsContract = getGwxRewardAddressOrFail(factoryCfg) | |
236 | - | let checkCaller = if ((i.caller == gwxRewardsContract)) | |
237 | - | then true | |
238 | - | else mustManager(i) | |
239 | - | if ((checkCaller == checkCaller)) | |
240 | - | then { | |
241 | - | let gwxHolderRewardCurrent = valueOrElse(getInteger(keyGwxHoldersRewardCurrent()), 0) | |
242 | - | let gwxHolderRewardNext = valueOrElse(getInteger(keyGwxHoldersRewardNext()), gwxHolderRewardCurrent) | |
243 | - | let shouldBeUpdated = (gwxHolderRewardCurrent != gwxHolderRewardNext) | |
244 | - | let actions = if (shouldBeUpdated) | |
245 | - | then [IntegerEntry(keyGwxHoldersRewardCurrent(), gwxHolderRewardNext), DeleteEntry(keyGwxHoldersRewardNext())] | |
246 | - | else nil | |
247 | - | $Tuple2(actions, shouldBeUpdated) | |
24 | + | [IntegerEntry("numValue", n), IntegerEntry("h", height), IntegerEntry("t", timest)] | |
248 | 25 | } | |
249 | 26 | else throw("Strict value is not equal to itself.") | |
250 | 27 | } | |
252 | 29 | ||
253 | 30 | ||
254 | 31 | @Callable(i) | |
255 | - | func getBoostCoeffREADONLY () = $Tuple2(nil, boostCoeff) | |
256 | - | ||
257 | - | ||
258 | - | ||
259 | - | @Callable(i) | |
260 | - | func changeRatePerBlockINTERNAL (newRatePerBlock) = { | |
261 | - | let check = if ((i.caller == this)) | |
262 | - | then true | |
263 | - | else throwErr("should be invoked internally") | |
264 | - | if ((check == check)) | |
32 | + | func setter (n) = { | |
33 | + | let otherContract = addressFromStringValue("3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq") | |
34 | + | let tc = invoke(this, "setterINTERNAL", [n], nil) | |
35 | + | if ((tc == tc)) | |
265 | 36 | then { | |
266 | - | let blockTimestamp = match blockInfoByHeight(height) { | |
267 | - | case bi: BlockInfo => | |
268 | - | bi.timestamp | |
269 | - | case _ => | |
270 | - | throwErr("BlockInfo.timestamp error") | |
271 | - | } | |
272 | - | [IntegerEntry(keyRatePerBlockStartFrom(blockTimestamp, height), newRatePerBlock), IntegerEntry(keyRatePerBlockCurrent(), newRatePerBlock)] | |
37 | + | let oc = reentrantInvoke(otherContract, "update", nil, nil) | |
38 | + | $Tuple2(nil, oc) | |
273 | 39 | } | |
274 | 40 | else throw("Strict value is not equal to itself.") | |
275 | 41 | } | |
276 | 42 | ||
277 | 43 | ||
278 | - | ||
279 | - | @Callable(i) | |
280 | - | func changeRatePerBlock (newRatePerBlock) = { | |
281 | - | let check = if ((i.caller == votingEmissionRateContract)) | |
282 | - | then true | |
283 | - | else throwErr("should be invoked by votingEmissionRateContract") | |
284 | - | if ((check == check)) | |
285 | - | then { | |
286 | - | let factoryContract = readFactoryAddressOrFail() | |
287 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
288 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
289 | - | let internalInv = invoke(this, "changeRatePerBlockINTERNAL", [newRatePerBlock], nil) | |
290 | - | if ((internalInv == internalInv)) | |
291 | - | then { | |
292 | - | let boostingInvoke = reentrantInvoke(boostingContract, "onBoostEmissionUpdate", nil, nil) | |
293 | - | $Tuple2(nil, boostingInvoke) | |
294 | - | } | |
295 | - | else throw("Strict value is not equal to itself.") | |
296 | - | } | |
297 | - | else throw("Strict value is not equal to itself.") | |
298 | - | } | |
299 | - | ||
300 | - | ||
301 | - | @Verifier(tx) | |
302 | - | func verify () = { | |
303 | - | let targetPublicKey = match managerPublicKeyOrUnit() { | |
304 | - | case pk: ByteVector => | |
305 | - | pk | |
306 | - | case _: Unit => | |
307 | - | tx.senderPublicKey | |
308 | - | case _ => | |
309 | - | throw("Match error") | |
310 | - | } | |
311 | - | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
312 | - | } | |
313 | - |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let SEP = "__" | |
5 | - | ||
6 | - | func wrapErr (msg) = makeString(["emission.ride:", toString(this), msg], " ") | |
7 | - | ||
8 | - | ||
9 | - | func throwErr (msg) = throw(wrapErr(msg)) | |
10 | - | ||
11 | - | ||
12 | - | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
13 | - | ||
14 | - | ||
15 | - | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
16 | - | ||
17 | - | ||
18 | - | let keyVotingVerifiedContract = "%s%s__config__votingVerifiedContract" | |
19 | - | ||
20 | - | let keyVotingEmissionCandidateContract = "%s%s__config__votingEmissionCandidateContract" | |
21 | - | ||
22 | - | let keyUserPoolsContract = "%s%s__config__userPoolsContract" | |
23 | - | ||
24 | - | let keyVotingEmissionRateContract = "%s%s__config__votingEmissionRateContract" | |
25 | - | ||
26 | - | let votingVerifiedContract = addressFromStringValue(getStringOrFail(this, keyVotingVerifiedContract)) | |
27 | - | ||
28 | - | let votingEmissionCandidateContract = addressFromStringValue(getStringOrFail(this, keyVotingEmissionCandidateContract)) | |
29 | - | ||
30 | - | let userPoolsContract = addressFromStringValue(getStringOrFail(this, keyUserPoolsContract)) | |
31 | - | ||
32 | - | let votingEmissionRateContract = addressFromStringValue(getStringOrFail(this, keyVotingEmissionRateContract)) | |
33 | - | ||
34 | - | let IdxFactoryCfgStakingDapp = 1 | |
35 | - | ||
36 | - | let IdxFactoryCfgBoostingDapp = 2 | |
37 | - | ||
38 | - | let IdxFactoryCfgIdoDapp = 3 | |
39 | - | ||
40 | - | let IdxFactoryCfgTeamDapp = 4 | |
41 | - | ||
42 | - | let IdxFactoryCfgEmissionDapp = 5 | |
43 | - | ||
44 | - | let IdxFactoryCfgRestDapp = 6 | |
45 | - | ||
46 | - | let IdxFactoryCfgSlippageDapp = 7 | |
47 | - | ||
48 | - | let IdxFactoryCfgGwxRewardDapp = 10 | |
49 | - | ||
50 | - | func keyFactoryCfg () = "%s__factoryConfig" | |
51 | - | ||
52 | - | ||
53 | - | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
54 | - | ||
55 | - | ||
56 | - | func keyFactoryLpList () = "%s__lpTokensList" | |
57 | - | ||
58 | - | ||
59 | - | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
60 | - | ||
61 | - | ||
62 | - | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
63 | - | ||
64 | - | ||
65 | - | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(this, keyFactoryAddress())) | |
66 | - | ||
67 | - | ||
68 | - | func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP) | |
69 | - | ||
70 | - | ||
71 | - | func readFactoryCfgOrFail (factory) = split(getStringOrFail(factory, keyFactoryCfg()), SEP) | |
72 | - | ||
73 | - | ||
74 | - | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
75 | - | ||
76 | - | ||
77 | - | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
78 | - | ||
79 | - | ||
80 | - | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
81 | - | ||
82 | - | ||
83 | - | func getGwxRewardAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgGwxRewardDapp]) | |
84 | - | ||
85 | - | ||
86 | - | func keyConfig () = "%s__config" | |
87 | - | ||
88 | - | ||
89 | - | func keyRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
90 | - | ||
91 | - | ||
92 | - | func keyRatePerBlockMaxStartFrom (timestamp,block) = makeString(["%s%s%d%d__ratePerBlockMax__start", toString(timestamp), toString(block)], SEP) | |
93 | - | ||
94 | - | ||
95 | - | func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
96 | - | ||
97 | - | ||
98 | - | func keyRatePerBlockStartFrom (timestamp,block) = makeString(["%s%s%d%d__ratePerBlock__start", toString(timestamp), toString(block)], SEP) | |
99 | - | ||
100 | - | ||
101 | - | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
102 | - | ||
103 | - | ||
104 | - | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
105 | - | ||
106 | - | ||
107 | - | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
108 | - | ||
109 | - | ||
110 | - | func keyBoostCoeff () = "%s__boostCoeff" | |
111 | - | ||
112 | - | ||
113 | - | let boostCoeffDefault = 3 | |
114 | - | ||
115 | - | let boostCoeff = valueOrElse(getInteger(this, keyBoostCoeff()), boostCoeffDefault) | |
116 | - | ||
117 | - | func keyGwxHoldersRewardCurrent () = "%s%s__gwxHoldersReward__current" | |
118 | - | ||
119 | - | ||
120 | - | func keyGwxHoldersRewardNext () = "%s%s__gwxHoldersReward__next" | |
121 | - | ||
122 | - | ||
123 | - | func keyManagerPublicKey () = "%s__managerPublicKey" | |
124 | - | ||
125 | - | ||
126 | - | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
127 | - | ||
128 | - | ||
129 | - | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
130 | - | case s: String => | |
131 | - | addressFromStringValue(s) | |
132 | - | case _ => | |
133 | - | this | |
134 | - | } | |
135 | - | ||
136 | - | ||
137 | - | func managerPublicKeyOrUnit () = { | |
138 | - | let managerVaultAddress = getManagerVaultAddressOrThis() | |
139 | - | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
140 | - | case s: String => | |
141 | - | fromBase58String(s) | |
142 | - | case _: Unit => | |
143 | - | unit | |
144 | - | case _ => | |
145 | - | throw("Match error") | |
146 | - | } | |
147 | - | } | |
148 | - | ||
149 | - | ||
150 | - | func mustManager (i) = { | |
151 | - | let pd = throwErr("Permission denied") | |
152 | - | match managerPublicKeyOrUnit() { | |
153 | - | case pk: ByteVector => | |
154 | - | if ((i.callerPublicKey == pk)) | |
155 | - | then true | |
156 | - | else pd | |
157 | - | case _: Unit => | |
158 | - | if ((i.caller == this)) | |
159 | - | then true | |
160 | - | else pd | |
161 | - | case _ => | |
162 | - | throw("Match error") | |
163 | - | } | |
164 | - | } | |
165 | 4 | ||
166 | 5 | ||
167 | 6 | @Callable(i) | |
168 | - | func constructor (factoryAddress,ratePerBlockMax,ratePerBlock,emissionStartBlock,emissionDuration,emissionStartTimestamp,wxAssetIdStr) = { | |
169 | - | let checkCaller = mustManager(i) | |
170 | - | if ((checkCaller == checkCaller)) | |
171 | - | then [IntegerEntry(keyRatePerBlockMaxStartFrom(emissionStartTimestamp, emissionStartBlock), ratePerBlockMax), IntegerEntry(keyRatePerBlockMaxCurrent(), ratePerBlockMax), IntegerEntry(keyRatePerBlockStartFrom(emissionStartTimestamp, emissionStartBlock), ratePerBlock), IntegerEntry(keyRatePerBlockCurrent(), ratePerBlock), IntegerEntry(keyEmissionStartBlock(), emissionStartBlock), IntegerEntry(keyEmissionDurationInBlocks(), emissionDuration), IntegerEntry(keyEmissionEndBlock(), (emissionStartBlock + emissionDuration)), StringEntry(keyFactoryAddress(), factoryAddress), StringEntry(keyConfig(), ("%s__" + wxAssetIdStr))] | |
172 | - | else throw("Strict value is not equal to itself.") | |
173 | - | } | |
7 | + | func getNum () = $Tuple2(nil, 7) | |
174 | 8 | ||
175 | 9 | ||
176 | 10 | ||
177 | 11 | @Callable(i) | |
178 | - | func constructorV2 (votingVerifiedContractPrm) = { | |
179 | - | let checkCaller = mustManager(i) | |
180 | - | if ((checkCaller == checkCaller)) | |
181 | - | then $Tuple2([StringEntry(keyVotingVerifiedContract, votingVerifiedContractPrm)], unit) | |
182 | - | else throw("Strict value is not equal to itself.") | |
183 | - | } | |
184 | - | ||
185 | - | ||
186 | - | ||
187 | - | @Callable(i) | |
188 | - | func emit (amount) = if ((0 >= amount)) | |
189 | - | then $Tuple2(nil, nil) | |
190 | - | else { | |
191 | - | let factoryContract = readFactoryAddressOrFail() | |
192 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
193 | - | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
194 | - | let gwxRewardsContract = getGwxRewardAddressOrFail(factoryCfg) | |
195 | - | let caller = i.caller | |
196 | - | if (if ((caller != stakingContract)) | |
197 | - | then (caller != gwxRewardsContract) | |
198 | - | else false) | |
199 | - | then throwErr("permissions denied") | |
200 | - | else { | |
201 | - | let wxAssetIdStr = split(getStringOrFail(this, keyConfig()), SEP)[1] | |
202 | - | let wxAssetId = fromBase58String(wxAssetIdStr) | |
203 | - | $Tuple2([ScriptTransfer(caller, amount, wxAssetId)], [wxAssetId]) | |
204 | - | } | |
205 | - | } | |
206 | - | ||
207 | - | ||
208 | - | ||
209 | - | @Callable(i) | |
210 | - | func burn () = { | |
211 | - | let factoryContract = readFactoryAddressOrFail() | |
212 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
213 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
214 | - | if ((size(i.payments) != 1)) | |
215 | - | then throwErr("exact one payment is allowed") | |
216 | - | else { | |
217 | - | let pmt = i.payments[0] | |
218 | - | let assetId = value(pmt.assetId) | |
219 | - | let pmtAmount = pmt.amount | |
220 | - | let wxAssetId = fromBase58String(split(getStringOrFail(this, keyConfig()), SEP)[1]) | |
221 | - | if ((assetId != wxAssetId)) | |
222 | - | then throwErr("invalid wxAssetId is passed") | |
223 | - | else if (!(containsElement([boostingContract, votingVerifiedContract, votingEmissionCandidateContract, userPoolsContract], i.caller))) | |
224 | - | then throwErr("permissions denied") | |
225 | - | else [Burn(assetId, pmtAmount), StringEntry(("%s%s%s__history__burn__" + toBase58String(i.transactionId)), makeString(["%d%d%d", toString(height), toString(lastBlock.timestamp), toString(pmtAmount)], SEP))] | |
12 | + | func setterINTERNAL (n) = { | |
13 | + | let check = if ((i.caller == this)) | |
14 | + | then true | |
15 | + | else throw("ERROR 1") | |
16 | + | if ((check == check)) | |
17 | + | then { | |
18 | + | let timest = match blockInfoByHeight(height) { | |
19 | + | case bi: BlockInfo => | |
20 | + | bi.timestamp | |
21 | + | case _ => | |
22 | + | throw("ERROR 2") | |
226 | 23 | } | |
227 | - | } | |
228 | - | ||
229 | - | ||
230 | - | ||
231 | - | @Callable(i) | |
232 | - | func gwxHoldersRewardUpdate () = { | |
233 | - | let factoryContract = readFactoryAddressOrFail() | |
234 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
235 | - | let gwxRewardsContract = getGwxRewardAddressOrFail(factoryCfg) | |
236 | - | let checkCaller = if ((i.caller == gwxRewardsContract)) | |
237 | - | then true | |
238 | - | else mustManager(i) | |
239 | - | if ((checkCaller == checkCaller)) | |
240 | - | then { | |
241 | - | let gwxHolderRewardCurrent = valueOrElse(getInteger(keyGwxHoldersRewardCurrent()), 0) | |
242 | - | let gwxHolderRewardNext = valueOrElse(getInteger(keyGwxHoldersRewardNext()), gwxHolderRewardCurrent) | |
243 | - | let shouldBeUpdated = (gwxHolderRewardCurrent != gwxHolderRewardNext) | |
244 | - | let actions = if (shouldBeUpdated) | |
245 | - | then [IntegerEntry(keyGwxHoldersRewardCurrent(), gwxHolderRewardNext), DeleteEntry(keyGwxHoldersRewardNext())] | |
246 | - | else nil | |
247 | - | $Tuple2(actions, shouldBeUpdated) | |
24 | + | [IntegerEntry("numValue", n), IntegerEntry("h", height), IntegerEntry("t", timest)] | |
248 | 25 | } | |
249 | 26 | else throw("Strict value is not equal to itself.") | |
250 | 27 | } | |
251 | 28 | ||
252 | 29 | ||
253 | 30 | ||
254 | 31 | @Callable(i) | |
255 | - | func getBoostCoeffREADONLY () = $Tuple2(nil, boostCoeff) | |
256 | - | ||
257 | - | ||
258 | - | ||
259 | - | @Callable(i) | |
260 | - | func changeRatePerBlockINTERNAL (newRatePerBlock) = { | |
261 | - | let check = if ((i.caller == this)) | |
262 | - | then true | |
263 | - | else throwErr("should be invoked internally") | |
264 | - | if ((check == check)) | |
32 | + | func setter (n) = { | |
33 | + | let otherContract = addressFromStringValue("3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq") | |
34 | + | let tc = invoke(this, "setterINTERNAL", [n], nil) | |
35 | + | if ((tc == tc)) | |
265 | 36 | then { | |
266 | - | let blockTimestamp = match blockInfoByHeight(height) { | |
267 | - | case bi: BlockInfo => | |
268 | - | bi.timestamp | |
269 | - | case _ => | |
270 | - | throwErr("BlockInfo.timestamp error") | |
271 | - | } | |
272 | - | [IntegerEntry(keyRatePerBlockStartFrom(blockTimestamp, height), newRatePerBlock), IntegerEntry(keyRatePerBlockCurrent(), newRatePerBlock)] | |
37 | + | let oc = reentrantInvoke(otherContract, "update", nil, nil) | |
38 | + | $Tuple2(nil, oc) | |
273 | 39 | } | |
274 | 40 | else throw("Strict value is not equal to itself.") | |
275 | 41 | } | |
276 | 42 | ||
277 | 43 | ||
278 | - | ||
279 | - | @Callable(i) | |
280 | - | func changeRatePerBlock (newRatePerBlock) = { | |
281 | - | let check = if ((i.caller == votingEmissionRateContract)) | |
282 | - | then true | |
283 | - | else throwErr("should be invoked by votingEmissionRateContract") | |
284 | - | if ((check == check)) | |
285 | - | then { | |
286 | - | let factoryContract = readFactoryAddressOrFail() | |
287 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
288 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
289 | - | let internalInv = invoke(this, "changeRatePerBlockINTERNAL", [newRatePerBlock], nil) | |
290 | - | if ((internalInv == internalInv)) | |
291 | - | then { | |
292 | - | let boostingInvoke = reentrantInvoke(boostingContract, "onBoostEmissionUpdate", nil, nil) | |
293 | - | $Tuple2(nil, boostingInvoke) | |
294 | - | } | |
295 | - | else throw("Strict value is not equal to itself.") | |
296 | - | } | |
297 | - | else throw("Strict value is not equal to itself.") | |
298 | - | } | |
299 | - | ||
300 | - | ||
301 | - | @Verifier(tx) | |
302 | - | func verify () = { | |
303 | - | let targetPublicKey = match managerPublicKeyOrUnit() { | |
304 | - | case pk: ByteVector => | |
305 | - | pk | |
306 | - | case _: Unit => | |
307 | - | tx.senderPublicKey | |
308 | - | case _ => | |
309 | - | throw("Match error") | |
310 | - | } | |
311 | - | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
312 | - | } | |
313 | - |
github/deemru/w8io/169f3d6 30.78 ms ◑![]()