tx · GntxmzcbzNf4b7cw9yqjGQpfYdaB35rwwASLFcGTaBx6 3NBqs2vfpyT5cMdUJ97mEJ1Ycp2y8GbAZDA: -0.01400000 Waves 2022.01.26 23:44 [1896401] smart account 3NBqs2vfpyT5cMdUJ97mEJ1Ycp2y8GbAZDA > SELF 0.00000000 Waves
{ "type": 13, "id": "GntxmzcbzNf4b7cw9yqjGQpfYdaB35rwwASLFcGTaBx6", "fee": 1400000, "feeAssetId": null, "timestamp": 1643229956059, "version": 1, "sender": "3NBqs2vfpyT5cMdUJ97mEJ1Ycp2y8GbAZDA", "senderPublicKey": "H19CeJVbUnfsK8EYs8K6fHxwBH7pLyxw8WCDFu7D4rGQ", "proofs": [ "TE68PomLwSNVwdRRjUxBbwRcbGfWA25ZbrFwkzyQnz34gTsX2SpuSzwy7nq5ve3uSj7wtBAb5ZC9a2THkrJZmuZ" ], "script": "base64:AAIFAAAAAAAAABcIAhIJCgcIAQEBAQEIEgMKAQgSAwoBAQAAACAAAAAAA1NFUAIAAAACX18BAAAAD2dldFN0cmluZ09yRmFpbAAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACAgAAAA9tYW5kYXRvcnkgdGhpcy4FAAAAA2tleQIAAAAPIGlzIG5vdCBkZWZpbmVkAQAAABFrZXlGYWN0b3J5QWRkcmVzcwAAAAACAAAAHCVzJXNfX2NvbmZpZ19fZmFjdG9yeUFkZHJlc3MBAAAAFGtleUd3eFJld2FyZHNBZGRyZXNzAAAAAAIAAAAfJXMlc19fY29uZmlnX19nd3hSZXdhcmRzQWRkcmVzcwAAAAAUZ3d4UmV3YXJkc0FkZHJlc3NTdHIJAQAAAA9nZXRTdHJpbmdPckZhaWwAAAACBQAAAAR0aGlzCQEAAAAUa2V5R3d4UmV3YXJkc0FkZHJlc3MAAAAAAAAAABJnd3hSZXd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AIFAAAACWNhbGxlclN0cgUAAAARc3Rha2luZ0FkZHJlc3NTdHIJAAACAAAAAQIAAAAScGVybWlzc2lvbnMgZGVuaWVkBAAAAAx3eEFzc2V0SWRTdHIJAAGRAAAAAgkABLUAAAACCQEAAAAPZ2V0U3RyaW5nT3JGYWlsAAAAAgUAAAAEdGhpcwkBAAAACWtleUNvbmZpZwAAAAAFAAAAA1NFUAAAAAAAAAAAAQQAAAAJd3hBc3NldElkCQACWQAAAAEFAAAADHd4QXNzZXRJZFN0cgQAAAAGcmVzdWx0CQAD/AAAAAQFAAAAEmd3eFJld2FyZHNDb250cmFjdAIAAAAXYXV4RW1pc3Npb25Gb3JHd3hSZXdhcmQJAARMAAAAAgUAAAAGYW1vdW50BQAAAANuaWwFAAAAA25pbAMJAAAAAAAAAgUAAAAGcmVzdWx0BQAAAAZyZXN1bHQEAAAACWF1eEFtb3VudAQAAAAHJG1hdGNoMAUAAAAGcmVzdWx0AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAXIFAAAAByRtYXRjaDAFAAAAAXIJAAACAAAAAQIAAAAXSW5jb3JyZWN0IGludm9rZSByZXN1bHQJAAUUAAAAAgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAA9zdGFraW5nQ29udHJhY3QJAABlAAAAAgUAAAAGYW1vdW50BQAAAAlhdXhBbW91bnQFAAAACXd4QXNzZXRJZAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAABJnd3hSZXdhcmRzQ29udHJhY3QFAAAACWF1eEFtb3VudAUAAAAJd3hBc3NldElkBQAAAANuaWwJAARMAAAAAgUAAAAJd3hBc3NldElkBQAAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAJhzmXI=", "chainId": 84, "height": 1896401, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5MALWhgbXED1pRVQcHeZFU41BrEJSzTWoGZekGVBWoCS Next: DwMYXzoHTS8ySHVgiXzVqStdDCzmZ2oSthwBCGEfQ59S Diff:
Old | New | Differences | |
---|---|---|---|
8 | 8 | ||
9 | 9 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
10 | 10 | ||
11 | + | ||
12 | + | func keyGwxRewardsAddress () = "%s%s__config__gwxRewardsAddress" | |
13 | + | ||
14 | + | ||
15 | + | let gwxRewardsAddressStr = getStringOrFail(this, keyGwxRewardsAddress()) | |
16 | + | ||
17 | + | let gwxRewardsContract = addressFromStringValue(gwxRewardsAddressStr) | |
11 | 18 | ||
12 | 19 | let IdxFactoryCfgStakingDapp = 1 | |
13 | 20 | ||
88 | 95 | ||
89 | 96 | ||
90 | 97 | @Callable(i) | |
91 | - | func emit (amount) = { | |
92 | - | let factoryContract = readFactoryAddressOrFail() | |
93 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
94 | - | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
95 | - | let stakingAddressStr = toString(stakingContract) | |
96 | - | let callerStr = toString(i.caller) | |
97 | - | if ((callerStr != stakingAddressStr)) | |
98 | - | then throw("permissions denied") | |
99 | - | else { | |
100 | - | let wxAssetIdStr = split(getStringOrFail(this, keyConfig()), SEP)[1] | |
101 | - | let wxAssetId = fromBase58String(wxAssetIdStr) | |
102 | - | $Tuple2([ScriptTransfer(stakingContract, amount, wxAssetId)], [wxAssetId]) | |
103 | - | } | |
104 | - | } | |
98 | + | func constructorV2 (gwxRewardsAddress) = if ((this != i.caller)) | |
99 | + | then throw("not authorized") | |
100 | + | else [StringEntry(keyGwxRewardsAddress(), gwxRewardsAddress)] | |
105 | 101 | ||
106 | 102 | ||
107 | 103 | ||
108 | 104 | @Callable(i) | |
109 | - | func burn () = { | |
110 | - | let factoryContract = readFactoryAddressOrFail() | |
111 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
112 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
113 | - | if ((size(i.payments) != 1)) | |
114 | - | then throw("exact one payment is allowed") | |
115 | - | else { | |
116 | - | let pmt = i.payments[0] | |
117 | - | let assetId = value(pmt.assetId) | |
118 | - | let pmtAmount = pmt.amount | |
119 | - | let wxAssetId = fromBase58String(split(getStringOrFail(this, keyConfig()), SEP)[1]) | |
120 | - | if ((assetId != wxAssetId)) | |
121 | - | then throw("invalid wxAssetId is passed") | |
122 | - | else if ((i.caller != boostingContract)) | |
123 | - | then throw("permissions denied") | |
124 | - | 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))] | |
125 | - | } | |
126 | - | } | |
105 | + | func emit (amount) = if ((0 >= amount)) | |
106 | + | then $Tuple2(nil, nil) | |
107 | + | else { | |
108 | + | let factoryContract = readFactoryAddressOrFail() | |
109 | + | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
110 | + | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
111 | + | let stakingAddressStr = toString(stakingContract) | |
112 | + | let callerStr = toString(i.caller) | |
113 | + | if ((callerStr != stakingAddressStr)) | |
114 | + | then throw("permissions denied") | |
115 | + | else { | |
116 | + | let wxAssetIdStr = split(getStringOrFail(this, keyConfig()), SEP)[1] | |
117 | + | let wxAssetId = fromBase58String(wxAssetIdStr) | |
118 | + | let result = invoke(gwxRewardsContract, "auxEmissionForGwxReward", [amount], nil) | |
119 | + | if ((result == result)) | |
120 | + | then { | |
121 | + | let auxAmount = match result { | |
122 | + | case r: Int => | |
123 | + | r | |
124 | + | case _ => | |
125 | + | throw("Incorrect invoke result") | |
126 | + | } | |
127 | + | $Tuple2([ScriptTransfer(stakingContract, (amount - auxAmount), wxAssetId), ScriptTransfer(gwxRewardsContract, auxAmount, wxAssetId)], [wxAssetId]) | |
128 | + | } | |
129 | + | else throw("Strict value is not equal to itself.") | |
130 | + | } | |
131 | + | } | |
127 | 132 | ||
128 | 133 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (("mandatory this." + key) + " is not defined")) | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
10 | 10 | ||
11 | + | ||
12 | + | func keyGwxRewardsAddress () = "%s%s__config__gwxRewardsAddress" | |
13 | + | ||
14 | + | ||
15 | + | let gwxRewardsAddressStr = getStringOrFail(this, keyGwxRewardsAddress()) | |
16 | + | ||
17 | + | let gwxRewardsContract = addressFromStringValue(gwxRewardsAddressStr) | |
11 | 18 | ||
12 | 19 | let IdxFactoryCfgStakingDapp = 1 | |
13 | 20 | ||
14 | 21 | let IdxFactoryCfgBoostingDapp = 2 | |
15 | 22 | ||
16 | 23 | let IdxFactoryCfgIdoDapp = 3 | |
17 | 24 | ||
18 | 25 | let IdxFactoryCfgTeamDapp = 4 | |
19 | 26 | ||
20 | 27 | let IdxFactoryCfgEmissionDapp = 5 | |
21 | 28 | ||
22 | 29 | let IdxFactoryCfgRestDapp = 6 | |
23 | 30 | ||
24 | 31 | let IdxFactoryCfgSlippageDapp = 7 | |
25 | 32 | ||
26 | 33 | func keyFactoryCfg () = "%s__factoryConfig" | |
27 | 34 | ||
28 | 35 | ||
29 | 36 | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
30 | 37 | ||
31 | 38 | ||
32 | 39 | func keyFactoryLpList () = "%s__lpTokensList" | |
33 | 40 | ||
34 | 41 | ||
35 | 42 | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
36 | 43 | ||
37 | 44 | ||
38 | 45 | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
39 | 46 | ||
40 | 47 | ||
41 | 48 | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(this, keyFactoryAddress())) | |
42 | 49 | ||
43 | 50 | ||
44 | 51 | func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP) | |
45 | 52 | ||
46 | 53 | ||
47 | 54 | func readFactoryCfgOrFail (factory) = split(getStringOrFail(factory, keyFactoryCfg()), SEP) | |
48 | 55 | ||
49 | 56 | ||
50 | 57 | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
51 | 58 | ||
52 | 59 | ||
53 | 60 | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
54 | 61 | ||
55 | 62 | ||
56 | 63 | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
57 | 64 | ||
58 | 65 | ||
59 | 66 | func keyConfig () = "%s__config" | |
60 | 67 | ||
61 | 68 | ||
62 | 69 | func keyRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
63 | 70 | ||
64 | 71 | ||
65 | 72 | func keyRatePerBlockMaxStartFrom (timestamp,block) = makeString(["%s%s%d%d__ratePerBlockMax__start", toString(timestamp), toString(block)], SEP) | |
66 | 73 | ||
67 | 74 | ||
68 | 75 | func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
69 | 76 | ||
70 | 77 | ||
71 | 78 | func keyRatePerBlockStartFrom (timestamp,block) = makeString(["%s%s%d%d__ratePerBlock__start", toString(timestamp), toString(block)], SEP) | |
72 | 79 | ||
73 | 80 | ||
74 | 81 | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
75 | 82 | ||
76 | 83 | ||
77 | 84 | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
78 | 85 | ||
79 | 86 | ||
80 | 87 | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
81 | 88 | ||
82 | 89 | ||
83 | 90 | @Callable(i) | |
84 | 91 | func constructor (factoryAddress,ratePerBlockMax,ratePerBlock,emissionStartBlock,emissionDuration,emissionStartTimestamp,wxAssetIdStr) = if ((i.caller != this)) | |
85 | 92 | then throw("permissions denied") | |
86 | 93 | else [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))] | |
87 | 94 | ||
88 | 95 | ||
89 | 96 | ||
90 | 97 | @Callable(i) | |
91 | - | func emit (amount) = { | |
92 | - | let factoryContract = readFactoryAddressOrFail() | |
93 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
94 | - | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
95 | - | let stakingAddressStr = toString(stakingContract) | |
96 | - | let callerStr = toString(i.caller) | |
97 | - | if ((callerStr != stakingAddressStr)) | |
98 | - | then throw("permissions denied") | |
99 | - | else { | |
100 | - | let wxAssetIdStr = split(getStringOrFail(this, keyConfig()), SEP)[1] | |
101 | - | let wxAssetId = fromBase58String(wxAssetIdStr) | |
102 | - | $Tuple2([ScriptTransfer(stakingContract, amount, wxAssetId)], [wxAssetId]) | |
103 | - | } | |
104 | - | } | |
98 | + | func constructorV2 (gwxRewardsAddress) = if ((this != i.caller)) | |
99 | + | then throw("not authorized") | |
100 | + | else [StringEntry(keyGwxRewardsAddress(), gwxRewardsAddress)] | |
105 | 101 | ||
106 | 102 | ||
107 | 103 | ||
108 | 104 | @Callable(i) | |
109 | - | func burn () = { | |
110 | - | let factoryContract = readFactoryAddressOrFail() | |
111 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
112 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
113 | - | if ((size(i.payments) != 1)) | |
114 | - | then throw("exact one payment is allowed") | |
115 | - | else { | |
116 | - | let pmt = i.payments[0] | |
117 | - | let assetId = value(pmt.assetId) | |
118 | - | let pmtAmount = pmt.amount | |
119 | - | let wxAssetId = fromBase58String(split(getStringOrFail(this, keyConfig()), SEP)[1]) | |
120 | - | if ((assetId != wxAssetId)) | |
121 | - | then throw("invalid wxAssetId is passed") | |
122 | - | else if ((i.caller != boostingContract)) | |
123 | - | then throw("permissions denied") | |
124 | - | 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))] | |
125 | - | } | |
126 | - | } | |
105 | + | func emit (amount) = if ((0 >= amount)) | |
106 | + | then $Tuple2(nil, nil) | |
107 | + | else { | |
108 | + | let factoryContract = readFactoryAddressOrFail() | |
109 | + | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
110 | + | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
111 | + | let stakingAddressStr = toString(stakingContract) | |
112 | + | let callerStr = toString(i.caller) | |
113 | + | if ((callerStr != stakingAddressStr)) | |
114 | + | then throw("permissions denied") | |
115 | + | else { | |
116 | + | let wxAssetIdStr = split(getStringOrFail(this, keyConfig()), SEP)[1] | |
117 | + | let wxAssetId = fromBase58String(wxAssetIdStr) | |
118 | + | let result = invoke(gwxRewardsContract, "auxEmissionForGwxReward", [amount], nil) | |
119 | + | if ((result == result)) | |
120 | + | then { | |
121 | + | let auxAmount = match result { | |
122 | + | case r: Int => | |
123 | + | r | |
124 | + | case _ => | |
125 | + | throw("Incorrect invoke result") | |
126 | + | } | |
127 | + | $Tuple2([ScriptTransfer(stakingContract, (amount - auxAmount), wxAssetId), ScriptTransfer(gwxRewardsContract, auxAmount, wxAssetId)], [wxAssetId]) | |
128 | + | } | |
129 | + | else throw("Strict value is not equal to itself.") | |
130 | + | } | |
131 | + | } | |
127 | 132 | ||
128 | 133 |
github/deemru/w8io/169f3d6 44.84 ms ◑