tx · CYPhwj3imUdgjDn3DnXuLt3WcMxuJjbfKFbBQJV8yrFK 3MxpZZ46oGH5idG2rXfcUDwFotSELDEtyQu: -0.01000000 Waves 2021.10.27 20:49 [1765023] smart account 3MxpZZ46oGH5idG2rXfcUDwFotSELDEtyQu > SELF 0.00000000 Waves
{ "type": 13, "id": "CYPhwj3imUdgjDn3DnXuLt3WcMxuJjbfKFbBQJV8yrFK", "fee": 1000000, "feeAssetId": null, "timestamp": 1635356983827, "version": 1, "sender": "3MxpZZ46oGH5idG2rXfcUDwFotSELDEtyQu", "senderPublicKey": "HLjebBrq1Pdi1gabeao41GqBhEf9kyjY2P4k6dbNW8XC", "proofs": [ "2MJ6DewHX2oydVY7ebC5MoaxScYH9MmBhfbHe1TbKoTmD4hWgphjXHsMYKAApjsWFfdTxcPp9tYLkWQZUmnCXgee" ], "script": "base64:AAIFAAAAAAAAACIIAhIDCgEIEgMKAQgSBAoCCAgSAwoBCBIHCgUBAQEICBIAAAAAFAAAAAAGU0NBTEU4AAAAAAAAAAAIAAAAAAVNVUxUOAAAAAAABfXhAAAAAAAHU0NBTEUxOAAAAAAAAAAAEgAAAAAGTVVMVDE4CQABNgAAAAEADeC2s6dkAAAAAAAAA1NFUAIAAAACX18BAAAAD2dldFN0cmluZ09yRmFpbAAAAAEAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQiAAAAAQUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgIAAAAPbWFuZGF0b3J5IHRoaXMuBQAAAANrZXkCAAAADyBpcyBub3QgZGVmaW5lZAEAAAAYZ2V0U3RyaW5nQnlBZGRyZXNzT3JGYWlsAAAAAgAAAAdhZGRyZXNzAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAAB2FkZHJlc3MFAAAAA2tleQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAptYW5kYXRvcnkgCQAEJQAAAA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UGVyaW9kSW5CbG9ja3MFAAAABk1VTFQxOAkAATYAAAABCQAAaAAAAAIAAAAAAAAAAB4AAAAAAAAABaAEAAAAB2NvZWZmMTgJAAE6AAAAAgkAAHYAAAAGBQAAAAltb250aGVzMTgFAAAAB1NDQUxFMTgJAAE2AAAAAQAAAAAAAAAAAgAAAAAAAAAAAAUAAAAHU0NBTEUxOAUAAAAGSEFMRlVQCQABNgAAAAEAAAAAAAAAA+gEAAAACWdXeEFtb3VudAkAATwAAAADCQABNgAAAAEFAAAADWRlbHRhV3hBbW91bnQFAAAAB2NvZWZmMTgFAAAABk1VTFQxOAkABRQAAAACBQAAAANuaWwJAAS5AAAAAgkABEwAAAACAgAAAAQlZCVkCQAETAAAAAIJAAGkAAAAAQkAAaAAAAABBQAAAAlnV3hBbW91bnQJAARMAAAAAgkAAaQAAAABBQAAAAVib29zdAUAAAADbmlsBQAAAANTRVAAAAABaQEAAAAXd3hFbWlzc2lvblN0YXRzUkVBRE9OTFkAAAAABAAAAAdPTkVNVUxUCQABpAAAAAEFAAAABU1VTFQ4BAAAAANPTkUCAAAAATEEAAAAD3RvdGFsV3hSZWxlYXNlZAAAAAAAAAAAAAQAAAANdG90YWxXeExvY2tlZAAAAAAAAAAAAAQAAAAYbG9ja3NEdXJhdGlvblN1bUluQmxvY2tzAAAAAAAAAAAABAAAAApsb2Nrc0NvdW50AAAAAAAAAAAACQAFFAAAAAIFAAAAA25pbAkABLkAAAACCQAETAAAAAICAAAACCVkJWQlZCVkCQAETAAAAAIJAAGkAAAAAQUAAAAPdG90YWxXeFJlbGVhc2VkCQAETAAAAAIJAAGkAAAAAQUAAAANdG90YWxXeExvY2tlZAkABEwAAAACCQABpAAAAAEFAAAAGGxvY2tzRHVyYXRpb25TdW1JbkJsb2NrcwkABEwAAAACCQABpAAAAAEFAAAACmxvY2tzQ291bnQFAAAAA25pbAUAAAADU0VQAAAAANuA50M=", "chainId": 84, "height": 1765023, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: FTsegQgfsrr57qLagsc6t8DsPuCDH4RA2yU6TEK3Z8Nm Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SCALE8 = 8 | |
5 | + | ||
6 | + | let MULT8 = 100000000 | |
7 | + | ||
8 | + | let SCALE18 = 18 | |
9 | + | ||
10 | + | let MULT18 = toBigInt(1000000000000000000) | |
11 | + | ||
12 | + | let SEP = "__" | |
13 | + | ||
14 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
15 | + | ||
16 | + | ||
17 | + | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
18 | + | ||
19 | + | ||
20 | + | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
21 | + | ||
22 | + | ||
23 | + | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) | |
24 | + | ||
25 | + | ||
26 | + | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
27 | + | ||
28 | + | ||
29 | + | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
30 | + | ||
31 | + | ||
32 | + | func keyFactoryLpList () = "%s__lpTokensList" | |
33 | + | ||
34 | + | ||
35 | + | func keyFactoryCfg () = "%s__factoryConfig" | |
36 | + | ||
37 | + | ||
38 | + | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(keyFactoryAddress())) | |
39 | + | ||
40 | + | ||
41 | + | func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP) | |
42 | + | ||
43 | + | ||
44 | + | func readFactoryCfgOrFail () = split(getStringByAddressOrFail(readFactoryAddressOrFail(), keyFactoryCfg()), SEP) | |
45 | + | ||
46 | + | ||
47 | + | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
48 | + | ||
49 | + | ||
50 | + | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
51 | + | ||
52 | + | ||
53 | + | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[1]) | |
54 | + | ||
55 | + | ||
56 | + | func internalCurrentRewardRate (stakingContract,lpAssetId) = { | |
57 | + | let wxEmissionPerBlock = 0 | |
58 | + | let maxFactor = (1 * MULT8) | |
59 | + | let totalLpStaked = getIntOrZero(stakingContract, keyStakedTotal(lpAssetId)) | |
60 | + | [wxEmissionPerBlock, maxFactor, totalLpStaked] | |
61 | + | } | |
62 | + | ||
63 | + | ||
64 | + | @Callable(i) | |
65 | + | func constructor (factoryAddress) = if ((i.caller != this)) | |
66 | + | then throw("not authorized") | |
67 | + | else [StringEntry(keyFactoryAddress(), factoryAddress)] | |
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | @Callable(i) | |
72 | + | func currentRewardRateREADONLY (lpAssetId) = { | |
73 | + | let factoryCfgArray = readFactoryCfgOrFail() | |
74 | + | let stakingContract = getStakingAddressOrFail(factoryCfgArray) | |
75 | + | let rewardData = internalCurrentRewardRate(stakingContract, lpAssetId) | |
76 | + | let wxEmissionPerBlock = rewardData[0] | |
77 | + | let maxFactor = rewardData[1] | |
78 | + | let totalLpStaked = rewardData[2] | |
79 | + | $Tuple2(nil, makeString(["%d%d%d", toString(wxEmissionPerBlock), toString(maxFactor), toString(totalLpStaked)], SEP)) | |
80 | + | } | |
81 | + | ||
82 | + | ||
83 | + | ||
84 | + | @Callable(i) | |
85 | + | func currentUserRewardRateREADONLY (lpAssetId,userAddress) = { | |
86 | + | let factoryCfgArray = readFactoryCfgOrFail() | |
87 | + | let stakingContract = getStakingAddressOrFail(factoryCfgArray) | |
88 | + | let rewardData = internalCurrentRewardRate(stakingContract, lpAssetId) | |
89 | + | let wxEmissionPerBlock = rewardData[0] | |
90 | + | let maxFactor = rewardData[1] | |
91 | + | let totalLpStaked = rewardData[2] | |
92 | + | let lpStakedByUser = getIntOrZero(stakingContract, keyStakedByUser(userAddress, lpAssetId)) | |
93 | + | let boostingPower = (1 * MULT8) | |
94 | + | $Tuple2(nil, makeString(["%d%d%d", toString(wxEmissionPerBlock), toString(maxFactor), toString(totalLpStaked), toString(lpStakedByUser), toString(boostingPower)], SEP)) | |
95 | + | } | |
96 | + | ||
97 | + | ||
98 | + | ||
99 | + | @Callable(i) | |
100 | + | func claimedRewardREADONLY (userAddress) = { | |
101 | + | let lpList = readLpList() | |
102 | + | let prefix = "%s%d%d%d%s" | |
103 | + | func claimedRewardByLpAggregator (resultStr,nextLp) = { | |
104 | + | let rand = ((toInt(fromBase58String(nextLp)) % 100000) + (toInt(toBytes(userAddress)) % 100000)) | |
105 | + | let absRand = if ((0 > rand)) | |
106 | + | then -(rand) | |
107 | + | else rand | |
108 | + | let val = (((absRand % 100) * MULT8) + (absRand * (MULT8 / 100000))) | |
109 | + | let minRewardClaimed = 0 | |
110 | + | let boostRewardClaimed = 0 | |
111 | + | let gFeeClaimed = 0 | |
112 | + | makeString([(prefix + resultStr), nextLp, toString(minRewardClaimed), toString(boostRewardClaimed), toString(gFeeClaimed), "end"], SEP) | |
113 | + | } | |
114 | + | ||
115 | + | let result = { | |
116 | + | let $l = lpList | |
117 | + | let $s = size($l) | |
118 | + | let $acc0 = "%s" | |
119 | + | func 1 ($a,$i) = if (($i >= $s)) | |
120 | + | then $a | |
121 | + | else claimedRewardByLpAggregator($a, $l[$i]) | |
122 | + | ||
123 | + | func 2 ($a,$i) = if (($i >= $s)) | |
124 | + | then $a | |
125 | + | else throw("List size exceeds 10") | |
126 | + | ||
127 | + | 2(1(1(1(1(1(1(1(1(1(1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
128 | + | } | |
129 | + | $Tuple2(nil, ((result + SEP) + userAddress)) | |
130 | + | } | |
131 | + | ||
132 | + | ||
133 | + | ||
134 | + | @Callable(i) | |
135 | + | func calcBoostREADONLY (deltaWxAmount,deltaLockPeriodInBlocks,deltaLpAmount,lpAssetIdOpt,userAddressOpt) = { | |
136 | + | let boost = if ((userAddressOpt != "")) | |
137 | + | then (3 * MULT8) | |
138 | + | else (1 * MULT8) | |
139 | + | let monthes18 = fraction(toBigInt(deltaLockPeriodInBlocks), MULT18, toBigInt((30 * 1440))) | |
140 | + | let coeff18 = (pow(monthes18, SCALE18, toBigInt(2), 0, SCALE18, HALFUP) / toBigInt(1000)) | |
141 | + | let gWxAmount = fraction(toBigInt(deltaWxAmount), coeff18, MULT18) | |
142 | + | $Tuple2(nil, makeString(["%d%d", toString(toInt(gWxAmount)), toString(boost)], SEP)) | |
143 | + | } | |
144 | + | ||
145 | + | ||
146 | + | ||
147 | + | @Callable(i) | |
148 | + | func wxEmissionStatsREADONLY () = { | |
149 | + | let ONEMULT = toString(MULT8) | |
150 | + | let ONE = "1" | |
151 | + | let totalWxReleased = 0 | |
152 | + | let totalWxLocked = 0 | |
153 | + | let locksDurationSumInBlocks = 0 | |
154 | + | let locksCount = 0 | |
155 | + | $Tuple2(nil, makeString(["%d%d%d%d", toString(totalWxReleased), toString(totalWxLocked), toString(locksDurationSumInBlocks), toString(locksCount)], SEP)) | |
156 | + | } | |
157 | + | ||
158 | + |
github/deemru/w8io/026f985 17.81 ms ◑