tx · AWDnkZCp8uKMFFqTrCi2aaBWcdHFrCrbozUJjkekZen8 3N1Epwa6GQuTQr2K9WzeUcqSFCdERwuvL5T: -0.02800000 Waves 2022.06.14 18:41 [2096239] smart account 3N1Epwa6GQuTQr2K9WzeUcqSFCdERwuvL5T > SELF 0.00000000 Waves
{ "type": 13, "id": "AWDnkZCp8uKMFFqTrCi2aaBWcdHFrCrbozUJjkekZen8", "fee": 2800000, "feeAssetId": null, "timestamp": 1655221274664, "version": 1, "sender": "3N1Epwa6GQuTQr2K9WzeUcqSFCdERwuvL5T", "senderPublicKey": "7iXEgsFNsnbLZ3ca4tmz8jffnyxMu9keuBV6CuQPJLuA", "proofs": [ "5FLXhN6HJkkWbTjoRtEDi4xcpAYWqxsSK8mHUUBbdRzFPdiYvYXdia6xrYjyNu1bBbtZF5ZawpEZ86Vtn8mE3YnX" ], "script": "base64:AAIFAAAAAAAAACcIAhIDCgEIEgMKAQgSABIAEgQKAggBEgMKAQgSBAoCCAgSBAoCCAgAAABPAAAAAAZTQ0FMRTgAAAAAAAAAAAgAAAAABU1VTFQ4AAAAAAAF9eEAAAAAAAdTQ0FMRTE4AAAAAAAAAAASAAAAAAZNVUxUMTgJAAE2AAAAAQAN4Lazp2QAAAAAAAADU0VQAgAAAAJfXwAAAAAOUE9PTFdFSUdIVE1VTFQFAAAABU1VTFQ4AAAAAAp6ZXJvQmlnSW50CQABNgAAAAEAAAAAAAAAAAAAAAAACW9uZUJpZ0ludAkAATYAAAABAAAAAAAAAAABAQAAAAlhc0FueUxpc3QAAAABAAAAA3ZhbAQAAAAHJG1hdGNoMAUAAAADdmFsAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAlMaXN0W0FueV0EAAAACnZhbEFueUx5c3QFAAAAByRtYXRjaDAFAAAACnZhbEFueUx5c3QJAAACAAAAAQIAAAAbZmFpbCB0byBjYXN0IGludG8gTGlzdFtBbnldAQAAAAVhc0ludAAAAAEAAAADdmFsBAAAAAckbWF0Y2gwBQAAA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b25Nb2RpZnlXZWlnaHQAAAACAAAADGxwQXNzZXRJZFN0cgAAAA5wb29sQWRkcmVzc1N0cgMJAQAAAAIhPQAAAAIIBQAAAAFpAAAABmNhbGxlcgUAAAAPZmFjdG9yeUNvbnRyYWN0CQAAAgAAAAECAAAAEnBlcm1pc3Npb25zIGRlbmllZAQAAAANJHQwMjE3NDUyMTg1NQkBAAAAFHJlZnJlc2hQb29sSU5URUdSQUxTAAAAAwUAAAAMbHBBc3NldElkU3RyBQAAAA5wb29sQWRkcmVzc1N0cgAAAAAAAAAAAAQAAAASd3hQZXJMcEludGVncmFsTmV3CAUAAAANJHQwMjE3NDUyMTg1NQAAAAJfMQQAAAARcG9vbEludGVncmFsU1RBVEUIBQAAAA0kdDAyMTc0NTIxODU1AAAAAl8yBAAAAAlwb29sREVCVUcIBQAAAA0kdDAyMTc0NTIxODU1AAAAAl8zBQAAABFwb29sSW50ZWdyYWxTVEFURQAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAD3RhcmdldFB1YmxpY0tleQQAAAAHJG1hdGNoMAkBAAAAFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAJwawUAAAAHJG1hdGNoMAUAAAACcGsDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA90YXJnZXRQdWJsaWNLZXnKVxVe", "chainId": 84, "height": 2096239, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3AKn7adiUhyer32L4ETErbBL1nodvwsVk8QGF4sKEg27 Next: HLNGxu9TLaerUEpJcQtmogbk9NNM9ti9MR3q4pH2aa2A Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let SCALE8 = 8 | |
5 | 5 | ||
6 | - | let | |
6 | + | let MULT8 = 100000000 | |
7 | 7 | ||
8 | - | let | |
8 | + | let SCALE18 = 18 | |
9 | 9 | ||
10 | - | let | |
10 | + | let MULT18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | - | let | |
12 | + | let SEP = "__" | |
13 | 13 | ||
14 | - | let | |
14 | + | let POOLWEIGHTMULT = MULT8 | |
15 | 15 | ||
16 | - | let | |
16 | + | let zeroBigInt = toBigInt(0) | |
17 | 17 | ||
18 | - | let | |
18 | + | let oneBigInt = toBigInt(1) | |
19 | 19 | ||
20 | - | let keyEmissionContract = makeString(["%s", "emissionContract"], separator) | |
21 | - | ||
22 | - | let keyBoostingContract = makeString(["%s", "boostingContract"], separator) | |
23 | - | ||
24 | - | let keyFactoryContract = makeString(["%s", "factoryContract"], separator) | |
25 | - | ||
26 | - | let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], separator) | |
27 | - | ||
28 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (key + " is not defined")) | |
20 | + | func asAnyList (val) = match val { | |
21 | + | case valAnyLyst: List[Any] => | |
22 | + | valAnyLyst | |
23 | + | case _ => | |
24 | + | throw("fail to cast into List[Any]") | |
25 | + | } | |
29 | 26 | ||
30 | 27 | ||
31 | - | func keyInListAssetId (amountAssetId,priceAssetId) = makeString(["%s%s%s", "inList", amountAssetId, priceAssetId], separator) | |
28 | + | func asInt (val) = match val { | |
29 | + | case valInt: Int => | |
30 | + | valInt | |
31 | + | case _ => | |
32 | + | throw("fail to cast into Int") | |
33 | + | } | |
32 | 34 | ||
33 | 35 | ||
34 | - | func keySuggestIndex (amountAssetId,priceAssetId) = makeString(["%s%s%s", "suggestIndex", amountAssetId, priceAssetId], separator) | |
36 | + | func asString (val) = match val { | |
37 | + | case valStr: String => | |
38 | + | valStr | |
39 | + | case _ => | |
40 | + | throw("fail to cast into Int") | |
41 | + | } | |
35 | 42 | ||
36 | 43 | ||
37 | - | func keyStartHeight (amountAssetId,priceAssetId,suggestIndex) = makeString(["%s%s%s%d", "startHeight", amountAssetId, priceAssetId, toString(suggestIndex)], separator) | |
44 | + | func asByteVector (val) = match val { | |
45 | + | case valBin: ByteVector => | |
46 | + | valBin | |
47 | + | case _ => | |
48 | + | throw("fail to cast into Int") | |
49 | + | } | |
38 | 50 | ||
39 | 51 | ||
40 | - | func | |
52 | + | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (("mandatory this." + key) + " is not defined")) | |
41 | 53 | ||
42 | 54 | ||
43 | - | func | |
55 | + | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
44 | 56 | ||
45 | 57 | ||
46 | - | func | |
58 | + | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
47 | 59 | ||
48 | 60 | ||
49 | - | func keyVoteValue (gwxAmount,vote) = { | |
50 | - | let key = if (vote) | |
51 | - | then makeString(["%d%s", gwxAmount, "yes"], separator) | |
52 | - | else makeString(["%d%s", gwxAmount, "no"], separator) | |
53 | - | key | |
54 | - | } | |
61 | + | func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
62 | + | ||
63 | + | ||
64 | + | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) | |
65 | + | ||
66 | + | ||
67 | + | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), MULT18, toBigInt(origScaleMult)) | |
68 | + | ||
69 | + | ||
70 | + | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), MULT18)) | |
71 | + | ||
72 | + | ||
73 | + | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
74 | + | ||
75 | + | ||
76 | + | let IdxFactoryCfgStakingDapp = 1 | |
77 | + | ||
78 | + | let IdxFactoryCfgBoostingDapp = 2 | |
79 | + | ||
80 | + | let IdxFactoryCfgIdoDapp = 3 | |
81 | + | ||
82 | + | let IdxFactoryCfgTeamDapp = 4 | |
83 | + | ||
84 | + | let IdxFactoryCfgEmissionDapp = 5 | |
85 | + | ||
86 | + | let IdxFactoryCfgRestDapp = 6 | |
87 | + | ||
88 | + | let IdxFactoryCfgSlippageDapp = 7 | |
89 | + | ||
90 | + | func keyFactoryCfg () = "%s__factoryConfig" | |
55 | 91 | ||
56 | 92 | ||
57 | 93 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
60 | 96 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
61 | 97 | ||
62 | 98 | ||
63 | - | ||
99 | + | func keyStablePoolAddonAddr () = "%s__stablePoolAddonAddr" | |
64 | 100 | ||
65 | - | let boostingContract = addressFromStringValue(getStringOrFail(keyBoostingContract)) | |
66 | 101 | ||
67 | - | ||
102 | + | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
68 | 103 | ||
69 | - | let factoryContract = addressFromStringValue(getStringOrFail(keyFactoryContract)) | |
70 | 104 | ||
71 | - | ||
105 | + | func keyFactoryLpList () = "%s__lpTokensList" | |
72 | 106 | ||
73 | - | let votingEmissionContract = addressFromStringValue(getStringOrFail(keyVotingEmissionContract)) | |
107 | + | ||
108 | + | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
109 | + | ||
110 | + | ||
111 | + | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
112 | + | ||
113 | + | ||
114 | + | func readLpList (factory) = split(valueOrElse(getString(factory, keyFactoryLpList()), ""), SEP) | |
115 | + | ||
116 | + | ||
117 | + | func readFactoryCfgOrFail (factory) = split(getStringByAddressOrFail(factory, keyFactoryCfg()), SEP) | |
118 | + | ||
119 | + | ||
120 | + | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
121 | + | ||
122 | + | ||
123 | + | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
124 | + | ||
125 | + | ||
126 | + | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
127 | + | ||
128 | + | ||
129 | + | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
130 | + | ||
131 | + | ||
132 | + | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
133 | + | ||
134 | + | ||
135 | + | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
136 | + | ||
137 | + | ||
138 | + | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
139 | + | ||
140 | + | ||
141 | + | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
142 | + | ||
143 | + | ||
144 | + | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
145 | + | ||
146 | + | ||
147 | + | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
148 | + | ||
149 | + | ||
150 | + | func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) | |
151 | + | ||
152 | + | ||
153 | + | func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP) | |
154 | + | ||
155 | + | ||
156 | + | func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP) | |
157 | + | ||
158 | + | ||
159 | + | func keyClaimedTotal (lpAssetIdStr) = makeString(["%s%s%s__claimed", "total", lpAssetIdStr], SEP) | |
160 | + | ||
161 | + | ||
162 | + | func readStaked (key) = valueOrElse(getInteger(this, key), 0) | |
163 | + | ||
164 | + | ||
165 | + | func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP) | |
166 | + | ||
167 | + | ||
168 | + | func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP) | |
169 | + | ||
170 | + | ||
171 | + | func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP) | |
172 | + | ||
173 | + | ||
174 | + | func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP) | |
175 | + | ||
176 | + | ||
177 | + | func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP) | |
178 | + | ||
179 | + | ||
180 | + | func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP) | |
181 | + | ||
182 | + | ||
183 | + | func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP) | |
184 | + | ||
185 | + | ||
186 | + | func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP) | |
187 | + | ||
188 | + | ||
189 | + | func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP) | |
190 | + | ||
191 | + | ||
192 | + | func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP) | |
193 | + | ||
194 | + | ||
195 | + | func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP) | |
196 | + | ||
197 | + | ||
198 | + | func keyWxPerLpX18 (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLpX18"], SEP) | |
199 | + | ||
200 | + | ||
201 | + | func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP) | |
202 | + | ||
203 | + | ||
204 | + | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
205 | + | ||
206 | + | ||
207 | + | func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
208 | + | ||
209 | + | ||
210 | + | func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount)) | |
211 | + | ||
212 | + | ||
213 | + | let factoryAddress = getStringOrFail(this, keyFactoryAddress()) | |
214 | + | ||
215 | + | let factoryContract = addressFromStringValue(factoryAddress) | |
216 | + | ||
217 | + | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
218 | + | ||
219 | + | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
220 | + | ||
221 | + | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
222 | + | ||
223 | + | func calcWxPerLpIntegralUserLast (stakedByUser,wxPerLpIntegralUserLastUpdHeightOrZero,wxPerLpIntegralNew,wxPerLpIntegralUserLastKEY) = if (if ((wxPerLpIntegralUserLastUpdHeightOrZero == zeroBigInt)) | |
224 | + | then (stakedByUser > zeroBigInt) | |
225 | + | else false) | |
226 | + | then zeroBigInt | |
227 | + | else if ((stakedByUser == zeroBigInt)) | |
228 | + | then wxPerLpIntegralNew | |
229 | + | else if (if ((wxPerLpIntegralUserLastUpdHeightOrZero > zeroBigInt)) | |
230 | + | then (stakedByUser > zeroBigInt) | |
231 | + | else false) | |
232 | + | then value(parseBigInt(getStringOrFail(this, wxPerLpIntegralUserLastKEY))) | |
233 | + | else throw("calcWxPerLpIntegralUserLast: unexpected state") | |
234 | + | ||
235 | + | ||
236 | + | func refreshPoolINTEGRALS (lpAssetIdStr,poolAddressStr,lpDeltaAmount) = { | |
237 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
238 | + | let stakedTotal = toBigInt(readStaked(stakedTotalKEY)) | |
239 | + | let nonZeroStakedTotal = if ((stakedTotal == zeroBigInt)) | |
240 | + | then oneBigInt | |
241 | + | else stakedTotal | |
242 | + | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
243 | + | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
244 | + | let MULT3 = 1000 | |
245 | + | let wxEmissionPerBlockX3 = (getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) * MULT3) | |
246 | + | let poolWxEmissionPerBlockX3 = fraction(wxEmissionPerBlockX3, poolWeight, (POOLWEIGHTMULT * 3)) | |
247 | + | let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr) | |
248 | + | let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr) | |
249 | + | let wxPerLpKEY = keyWxPerLp(lpAssetIdStr) | |
250 | + | let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock) | |
251 | + | let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY) | |
252 | + | let wxPerLpOrZeroX3 = 0 | |
253 | + | let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0]) | |
254 | + | let wxPerLpX3 = if ((wxPerLpOrZeroX3 != 0)) | |
255 | + | then toBigInt(wxPerLpOrZeroX3) | |
256 | + | else fraction(toBigInt(poolWxEmissionPerBlockX3), toBigInt(MULT8), nonZeroStakedTotal) | |
257 | + | let stakedTotalNew = (stakedTotal + toBigInt(lpDeltaAmount)) | |
258 | + | let nonZeroStakedTotalNew = if ((stakedTotalNew == zeroBigInt)) | |
259 | + | then oneBigInt | |
260 | + | else stakedTotalNew | |
261 | + | let wxPerLpIntegralNew = (toBigInt(wxPerLpIntegral) + (wxPerLpX3 * toBigInt(dh))) | |
262 | + | let wxPerLpX3New = (toBigInt(poolWxEmissionPerBlockX3) / nonZeroStakedTotalNew) | |
263 | + | let wxPerLpIntegralLastUpdHeightNew = height | |
264 | + | let debug = makeString(["wxPerLpIntegralNew=", toString(wxPerLpIntegralNew), "dh=", toString(dh), "wxPerLpX3=", toString(wxPerLpX3), "stakedTotal=", toString(stakedTotal), "poolWxEmissionPerBlockX3=", toString(poolWxEmissionPerBlockX3), "wxEmissionPerBlockX3=", toString(wxEmissionPerBlockX3), "poolWeight=", toString(poolWeight)], "::") | |
265 | + | $Tuple3(wxPerLpIntegralNew, [StringEntry(wxPerLpIntegralKEY, toString(wxPerLpIntegralNew)), IntegerEntry(wxPerLpIntegralLastUpdHeightKEY, wxPerLpIntegralLastUpdHeightNew), StringEntry(wxPerLpKEY, toString(wxPerLpX3New))], debug) | |
266 | + | } | |
267 | + | ||
268 | + | ||
269 | + | func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = { | |
270 | + | let $t01119411316 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, lpDeltaAmount) | |
271 | + | let wxPerLpIntegralNew = $t01119411316._1 | |
272 | + | let poolIntegralSTATE = $t01119411316._2 | |
273 | + | let poolDEBUG = $t01119411316._3 | |
274 | + | let MULT3 = 1000 | |
275 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
276 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
277 | + | let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr) | |
278 | + | let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr) | |
279 | + | let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr) | |
280 | + | let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY) | |
281 | + | let wxPerLpIntegralUserLastUpdHeightOrZero = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY) | |
282 | + | let wxPerLpIntegralUserLast = calcWxPerLpIntegralUserLast(toBigInt(stakedByUser), toBigInt(wxPerLpIntegralUserLastUpdHeightOrZero), wxPerLpIntegralNew, wxPerLpIntegralUserLastKEY) | |
283 | + | let MULT11 = (MULT8 * MULT3) | |
284 | + | let wxToClaimUserNew = (toBigInt(wxToClaimUser) + fraction((wxPerLpIntegralNew - wxPerLpIntegralUserLast), toBigInt(stakedByUser), toBigInt(MULT11))) | |
285 | + | let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew | |
286 | + | let wxPerLpIntegralUserLastUpdHeightNew = height | |
287 | + | let debug = makeString(["wxToClaimUserNew=", toString(wxToClaimUserNew), "wxPerLpIntegralUserLast=", toString(wxPerLpIntegralUserLast), "stakedByUser=", toString(stakedByUser), "poolDEBUG=", poolDEBUG, "height=", toString(height)], "::") | |
288 | + | $Tuple3(wxToClaimUserNew, (poolIntegralSTATE ++ [StringEntry(wxToClaimUserKEY, toString(wxToClaimUserNew)), IntegerEntry(wxPerLpIntegralUserLastUpdHeightKEY, wxPerLpIntegralUserLastUpdHeightNew), StringEntry(wxPerLpIntegralUserLastKEY, toString(wxPerLpIntegralUserLastNew))]), debug) | |
289 | + | } | |
290 | + | ||
74 | 291 | ||
75 | 292 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
76 | 293 | case s: String => | |
93 | 310 | ||
94 | 311 | ||
95 | 312 | func mustManager (i) = { | |
96 | - | let pd = throw(" | |
313 | + | let pd = throw("Permission denied") | |
97 | 314 | match managerPublicKeyOrUnit() { | |
98 | 315 | case pk: ByteVector => | |
99 | 316 | if ((i.callerPublicKey == pk)) | |
109 | 326 | } | |
110 | 327 | ||
111 | 328 | ||
112 | - | func asInt (val) = match val { | |
113 | - | case valInt: Int => | |
114 | - | valInt | |
115 | - | case _ => | |
116 | - | throw("failed to cast into Integer") | |
117 | - | } | |
118 | - | ||
119 | - | ||
120 | 329 | @Callable(i) | |
121 | - | func constructor (assetsStoreContractPrm,boostingContractPrm,emissionContractPrm,factoryContractPrm,userPoolContractPrm,votingEmissionContractPrm,feeAmountPrm,wxAssetIdPrm,votingDurationPrm,usdnAssetIdPrm,finalizeRewardPrm) = { | |
122 | - | let checks = [mustManager(i), if (isDefined(addressFromString(assetsStoreContractPrm))) | |
123 | - | then true | |
124 | - | else throw("Invalid asset_store contract address"), if (isDefined(addressFromString(boostingContractPrm))) | |
125 | - | then true | |
126 | - | else throw("Invalid boosting contract address"), if (isDefined(addressFromString(userPoolContractPrm))) | |
127 | - | then true | |
128 | - | else throw("Invalid user_pools contract address"), if (isDefined(addressFromString(emissionContractPrm))) | |
129 | - | then true | |
130 | - | else throw("Invalid emission contract address"), if (isDefined(addressFromString(factoryContractPrm))) | |
131 | - | then true | |
132 | - | else throw("Invalid factory contract address"), if ((feeAmountPrm >= 0)) | |
133 | - | then true | |
134 | - | else throw("Invalid fee amount"), if ((votingDurationPrm > 0)) | |
135 | - | then true | |
136 | - | else throw("Invalid voting duration"), if ((finalizeRewardPrm > 0)) | |
137 | - | then true | |
138 | - | else throw("Invalid finalize reward"), if (isDefined(assetInfo(fromBase58String(wxAssetIdPrm)))) | |
139 | - | then true | |
140 | - | else throw("Invalid WX asset ID"), if (isDefined(assetInfo(fromBase58String(usdnAssetIdPrm)))) | |
141 | - | then true | |
142 | - | else throw("Invalid USDN asset ID")] | |
143 | - | if ((checks == checks)) | |
144 | - | then $Tuple2([StringEntry(keyAssetsStoreContract, assetsStoreContractPrm), StringEntry(keyBoostingContract, boostingContractPrm), StringEntry(keyEmissionContract, emissionContractPrm), StringEntry(keyFactoryContract, factoryContractPrm), StringEntry(keyUserPoolContract, userPoolContractPrm), StringEntry(keyVotingEmissionContract, votingEmissionContractPrm), IntegerEntry(keyFeeAmount, feeAmountPrm), IntegerEntry(keyEpochLength, votingDurationPrm), IntegerEntry(keyFinalizeReward, finalizeRewardPrm), StringEntry(keyWxAssetId, wxAssetIdPrm), StringEntry(keyUsdnAssetId, usdnAssetIdPrm)], unit) | |
145 | - | else throw("Strict value is not equal to itself.") | |
146 | - | } | |
147 | - | ||
148 | - | ||
149 | - | ||
150 | - | @Callable(i) | |
151 | - | func suggest (amountAssetId,priceAssetId) = { | |
152 | - | let payment = value(i.payments[0]) | |
153 | - | let info = valueOrErrorMessage(assetInfo(fromBase58String(amountAssetId)), "invalid amountAssetId ID") | |
154 | - | let checks = [if ((info.issuer == i.caller)) | |
155 | - | then true | |
156 | - | else throw("asset can only be suggested by its issuer"), if ((info.scripted == false)) | |
157 | - | then true | |
158 | - | else throw("asset is smart"), if ((toBase58String(value(payment.assetId)) == value(getString(keyWxAssetId)))) | |
159 | - | then true | |
160 | - | else throw("invalid fee asset"), if ((payment.amount == value(getInteger(keyFeeAmount)))) | |
161 | - | then true | |
162 | - | else throw("invalid fee amount"), if ((priceAssetId == value(getString(keyUsdnAssetId)))) | |
163 | - | then true | |
164 | - | else throw("priceAssetId is not USDN"), if ((getInteger(keyInListAssetId(amountAssetId, priceAssetId)) == unit)) | |
165 | - | then true | |
166 | - | else throw("already in voting list")] | |
167 | - | if ((checks == checks)) | |
168 | - | then { | |
169 | - | let ensureActive = match invoke(userPoolContract, "statusREADONLY", [amountAssetId, priceAssetId], nil) { | |
170 | - | case s: String => | |
171 | - | if ((s == "active")) | |
172 | - | then true | |
173 | - | else throw("user pool is not active") | |
174 | - | case _ => | |
175 | - | throw("user pool is not active") | |
176 | - | } | |
177 | - | if ((ensureActive == ensureActive)) | |
178 | - | then { | |
179 | - | let ensureAmountAssetVerified = match invoke(assetsStoreContract, "isVerifiedREADONLY", [amountAssetId], nil) { | |
180 | - | case b: Boolean => | |
181 | - | if (b) | |
182 | - | then true | |
183 | - | else throw("asset is not verified") | |
184 | - | case _ => | |
185 | - | throw("asset is not verified") | |
186 | - | } | |
187 | - | if ((ensureAmountAssetVerified == ensureAmountAssetVerified)) | |
188 | - | then { | |
189 | - | let burnFeeInv = invoke(emissionContract, "burn", nil, [AttachedPayment(payment.assetId, payment.amount)]) | |
190 | - | if ((burnFeeInv == burnFeeInv)) | |
191 | - | then { | |
192 | - | let newSuggestIndex = match getInteger(keySuggestIndex(amountAssetId, priceAssetId)) { | |
193 | - | case int: Int => | |
194 | - | (int + 1) | |
195 | - | case _ => | |
196 | - | 0 | |
197 | - | } | |
198 | - | $Tuple2([IntegerEntry(keyInListAssetId(amountAssetId, priceAssetId), newSuggestIndex), IntegerEntry(keyStartHeight(amountAssetId, priceAssetId, newSuggestIndex), height), StringEntry(keyVotingResult(amountAssetId, priceAssetId, newSuggestIndex), totalVotes("0", "0")), IntegerEntry(keySuggestIndex(amountAssetId, priceAssetId), newSuggestIndex)], unit) | |
199 | - | } | |
200 | - | else throw("Strict value is not equal to itself.") | |
201 | - | } | |
202 | - | else throw("Strict value is not equal to itself.") | |
203 | - | } | |
204 | - | else throw("Strict value is not equal to itself.") | |
205 | - | } | |
206 | - | else throw("Strict value is not equal to itself.") | |
207 | - | } | |
208 | - | ||
209 | - | ||
210 | - | ||
211 | - | @Callable(i) | |
212 | - | func vote (amountAssetId,priceAssetId,inFavor) = { | |
213 | - | let suggestIndex = value(getInteger(keyInListAssetId(amountAssetId, priceAssetId))) | |
214 | - | let votingFinishHeight = (value(getInteger(keyStartHeight(amountAssetId, priceAssetId, suggestIndex))) + value(getInteger(keyEpochLength))) | |
215 | - | let checks = [if (isDefined(getInteger(keyInListAssetId(amountAssetId, priceAssetId)))) | |
216 | - | then true | |
217 | - | else throw("the token isn't on the voting list"), if ((votingFinishHeight > height)) | |
218 | - | then true | |
219 | - | else throw("too late to vote")] | |
220 | - | if ((checks == checks)) | |
221 | - | then { | |
222 | - | let gwxAmount = invoke(boostingContract, "getUserGwxAmountAtHeightREADONLY", [toString(i.caller), votingFinishHeight], nil) | |
223 | - | let notZero = if ((asInt(gwxAmount) > 0)) | |
224 | - | then true | |
225 | - | else throw("you don't have gwx") | |
226 | - | if ((notZero == notZero)) | |
227 | - | then { | |
228 | - | let vote = match getString(keyVote(amountAssetId, priceAssetId, suggestIndex, toString(i.caller))) { | |
229 | - | case s: String => | |
230 | - | let vote = split(s, separator) | |
231 | - | let voteValue = vote[1] | |
232 | - | let voteType = vote[2] | |
233 | - | let isVoteTypeSimilar = if (if ((voteType == "yes")) | |
234 | - | then (inFavor == true) | |
235 | - | else false) | |
236 | - | then true | |
237 | - | else if ((voteType == "no")) | |
238 | - | then (inFavor == false) | |
239 | - | else false | |
240 | - | let isVoteValueSimilar = if (isVoteTypeSimilar) | |
241 | - | then (asInt(gwxAmount) == parseIntValue(voteValue)) | |
242 | - | else false | |
243 | - | let isNewVoteSimilar = if (if (isVoteTypeSimilar) | |
244 | - | then isVoteValueSimilar | |
245 | - | else false) | |
246 | - | then throw("you already voted") | |
247 | - | else invoke(this, "cancelVote", [amountAssetId, priceAssetId], nil) | |
248 | - | isNewVoteSimilar | |
249 | - | case u: Unit => | |
250 | - | u | |
251 | - | case _ => | |
252 | - | throw("Match error") | |
253 | - | } | |
254 | - | if ((vote == vote)) | |
255 | - | then { | |
256 | - | let votingResult = split(value(getString(keyVotingResult(amountAssetId, priceAssetId, suggestIndex))), separator) | |
257 | - | let positiveVotes = votingResult[1] | |
258 | - | let negativeVotes = votingResult[2] | |
259 | - | let newPositiveAndNegativeVotes = if (inFavor) | |
260 | - | then { | |
261 | - | let newPositiveVotes = (parseIntValue(positiveVotes) + asInt(gwxAmount)) | |
262 | - | [toString(newPositiveVotes), negativeVotes] | |
263 | - | } | |
264 | - | else { | |
265 | - | let newNegativeVotes = (parseIntValue(negativeVotes) + asInt(gwxAmount)) | |
266 | - | [positiveVotes, toString(newNegativeVotes)] | |
267 | - | } | |
268 | - | let voteKey = keyVote(amountAssetId, priceAssetId, suggestIndex, toString(i.caller)) | |
269 | - | let voteValue = keyVoteValue(toString(asInt(gwxAmount)), inFavor) | |
270 | - | $Tuple2([StringEntry(keyVotingResult(amountAssetId, priceAssetId, suggestIndex), totalVotes(newPositiveAndNegativeVotes[0], newPositiveAndNegativeVotes[1])), StringEntry(voteKey, voteValue)], unit) | |
271 | - | } | |
272 | - | else throw("Strict value is not equal to itself.") | |
273 | - | } | |
274 | - | else throw("Strict value is not equal to itself.") | |
275 | - | } | |
276 | - | else throw("Strict value is not equal to itself.") | |
277 | - | } | |
278 | - | ||
279 | - | ||
280 | - | ||
281 | - | @Callable(i) | |
282 | - | func cancelVote (amountAssetId,priceAssetId) = { | |
283 | - | let userAddress = if ((i.caller == this)) | |
284 | - | then toString(i.originCaller) | |
285 | - | else toString(i.caller) | |
286 | - | let suggestIndex = value(getInteger(keyInListAssetId(amountAssetId, priceAssetId))) | |
287 | - | let checks = [if (isDefined(getString(keyVotingResult(amountAssetId, priceAssetId, suggestIndex)))) | |
288 | - | then true | |
289 | - | else throw("no vote for assets pair")] | |
290 | - | if ((checks == checks)) | |
291 | - | then { | |
292 | - | let vote = split(value(getString(keyVote(amountAssetId, priceAssetId, suggestIndex, userAddress))), separator) | |
293 | - | let voteValue = vote[1] | |
294 | - | let voteType = vote[2] | |
295 | - | let votingResult = split(value(getString(keyVotingResult(amountAssetId, priceAssetId, suggestIndex))), separator) | |
296 | - | let positiveVotes = votingResult[1] | |
297 | - | let negativeVotes = votingResult[2] | |
298 | - | let actions = if ((voteType == "yes")) | |
299 | - | then { | |
300 | - | let newPositiveVotes = (parseIntValue(positiveVotes) - parseIntValue(voteValue)) | |
301 | - | $Tuple2([StringEntry(keyVotingResult(amountAssetId, priceAssetId, suggestIndex), totalVotes(toString(newPositiveVotes), negativeVotes)), DeleteEntry(keyVote(amountAssetId, priceAssetId, suggestIndex, userAddress))], unit) | |
302 | - | } | |
303 | - | else { | |
304 | - | let newNegativeVotes = (parseIntValue(negativeVotes) - parseIntValue(voteValue)) | |
305 | - | $Tuple2([StringEntry(keyVotingResult(amountAssetId, priceAssetId, suggestIndex), totalVotes(positiveVotes, toString(newNegativeVotes))), DeleteEntry(keyVote(amountAssetId, priceAssetId, suggestIndex, userAddress))], unit) | |
306 | - | } | |
307 | - | actions | |
308 | - | } | |
309 | - | else throw("Strict value is not equal to itself.") | |
310 | - | } | |
311 | - | ||
312 | - | ||
313 | - | ||
314 | - | @Callable(i) | |
315 | - | func setFee (newFee) = { | |
316 | - | let checks = [mustManager(i)] | |
317 | - | if ((checks == checks)) | |
318 | - | then [IntegerEntry(keyFeeAmount, newFee)] | |
319 | - | else throw("Strict value is not equal to itself.") | |
320 | - | } | |
321 | - | ||
322 | - | ||
323 | - | ||
324 | - | @Callable(i) | |
325 | - | func finalize (amountAssetId,priceAssetId) = { | |
326 | - | let suggestIndex = value(getInteger(keyInListAssetId(amountAssetId, priceAssetId))) | |
327 | - | let votingFinishHeight = (value(getInteger(keyStartHeight(amountAssetId, priceAssetId, suggestIndex))) + value(getInteger(keyEpochLength))) | |
328 | - | let checks = [if (isDefined(getInteger(keyInListAssetId(amountAssetId, priceAssetId)))) | |
329 | - | then true | |
330 | - | else throw("no assets pair"), if ((height >= votingFinishHeight)) | |
331 | - | then true | |
332 | - | else throw("insufficient height for completion")] | |
333 | - | if ((checks == checks)) | |
334 | - | then { | |
335 | - | let votingResult = split(value(getString(keyVotingResult(amountAssetId, priceAssetId, suggestIndex))), separator) | |
336 | - | let positiveVotes = parseIntValue(votingResult[1]) | |
337 | - | let negativeVotes = parseIntValue(votingResult[2]) | |
338 | - | let actions = if ((positiveVotes > negativeVotes)) | |
339 | - | then { | |
340 | - | let res = invoke(factoryContract, "setWxEmissionPoolLabel", [amountAssetId, priceAssetId], nil) | |
341 | - | if ((res == res)) | |
342 | - | then { | |
343 | - | let votingEmissionInv = invoke(votingEmissionContract, "create", [amountAssetId, priceAssetId], nil) | |
344 | - | if ((votingEmissionInv == votingEmissionInv)) | |
345 | - | then $Tuple2([DeleteEntry(keyInListAssetId(amountAssetId, priceAssetId))], unit) | |
346 | - | else throw("Strict value is not equal to itself.") | |
347 | - | } | |
348 | - | else throw("Strict value is not equal to itself.") | |
349 | - | } | |
350 | - | else $Tuple2([DeleteEntry(keyInListAssetId(amountAssetId, priceAssetId))], unit) | |
351 | - | actions | |
352 | - | } | |
330 | + | func constructor (factoryAddressStr) = { | |
331 | + | let checkCaller = mustManager(i) | |
332 | + | if ((checkCaller == checkCaller)) | |
333 | + | then [StringEntry(keyFactoryAddress(), factoryAddressStr)] | |
353 | 334 | else throw("Strict value is not equal to itself.") | |
354 | 335 | } | |
355 | 336 | ||
375 | 356 | let pm = pendingManagerPublicKeyOrUnit() | |
376 | 357 | let hasPM = if (isDefined(pm)) | |
377 | 358 | then true | |
378 | - | else throw(" | |
359 | + | else throw("No pending manager") | |
379 | 360 | if ((hasPM == hasPM)) | |
380 | 361 | then { | |
381 | 362 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
382 | 363 | then true | |
383 | - | else throw(" | |
364 | + | else throw("You are not pending manager") | |
384 | 365 | if ((checkPM == checkPM)) | |
385 | 366 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
386 | 367 | else throw("Strict value is not equal to itself.") | |
387 | 368 | } | |
388 | 369 | else throw("Strict value is not equal to itself.") | |
389 | 370 | } | |
371 | + | ||
372 | + | ||
373 | + | ||
374 | + | @Callable(i) | |
375 | + | func stake () = if ((size(i.payments) != 1)) | |
376 | + | then throw("invalid payment - exact one payment must be attached") | |
377 | + | else { | |
378 | + | let pmt = i.payments[0] | |
379 | + | let lpAssetId = value(pmt.assetId) | |
380 | + | let lpAssetIdStr = toBase58String(lpAssetId) | |
381 | + | let amount = pmt.amount | |
382 | + | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
383 | + | let callerStr = toString(i.caller) | |
384 | + | let userAddressStr = if ((callerStr == poolAddressStr)) | |
385 | + | then toString(i.originCaller) | |
386 | + | else callerStr | |
387 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
388 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
389 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
390 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
391 | + | let $t01541515532 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount) | |
392 | + | let wxToClaimUserNew = $t01541515532._1 | |
393 | + | let integralSTATE = $t01541515532._2 | |
394 | + | let debug = $t01541515532._3 | |
395 | + | ([IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
396 | + | } | |
397 | + | ||
398 | + | ||
399 | + | ||
400 | + | @Callable(i) | |
401 | + | func unstake (lpAssetIdStr,amount) = { | |
402 | + | let lpAssetId = fromBase58String(lpAssetIdStr) | |
403 | + | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
404 | + | let poolAddon = valueOrElse(getString(this, keyStablePoolAddonAddr()), poolAddressStr) | |
405 | + | let callerStr = toString(i.caller) | |
406 | + | let userAddressStr = if (if ((callerStr == poolAddressStr)) | |
407 | + | then true | |
408 | + | else (callerStr == poolAddon)) | |
409 | + | then toString(i.originCaller) | |
410 | + | else callerStr | |
411 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
412 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
413 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
414 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
415 | + | let $t01666916787 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount)) | |
416 | + | let wxToClaimUserNew = $t01666916787._1 | |
417 | + | let integralSTATE = $t01666916787._2 | |
418 | + | let debug = $t01666916787._3 | |
419 | + | if ((amount > stakedByUser)) | |
420 | + | then throw("passed amount is less then available") | |
421 | + | else ([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
422 | + | } | |
423 | + | ||
424 | + | ||
425 | + | ||
426 | + | @Callable(i) | |
427 | + | func claimWx (lpAssetIdStr) = { | |
428 | + | let userAddress = i.caller | |
429 | + | let userAddressStr = toString(i.caller) | |
430 | + | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
431 | + | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
432 | + | let claimedTotalKEY = keyClaimedTotal(lpAssetIdStr) | |
433 | + | let claimedByUserMinRewardKEY = keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr) | |
434 | + | let claimedByUserBoostRewardKEY = keyClaimedByUserBoostReward(lpAssetIdStr, userAddressStr) | |
435 | + | let claimedByUser = toBigInt(getIntOrZero(this, claimedByUserKEY)) | |
436 | + | let claimedByUserMinReward = toBigInt(getIntOrZero(this, claimedByUserMinRewardKEY)) | |
437 | + | let claimedByUserBoostReward = toBigInt(getIntOrZero(this, claimedByUserBoostRewardKEY)) | |
438 | + | let claimedTotal = toBigInt(getIntOrZero(this, claimedTotalKEY)) | |
439 | + | let $t01802318135 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
440 | + | let wxToClaimUserNew = $t01802318135._1 | |
441 | + | let integralSTATE = $t01802318135._2 | |
442 | + | let debug = $t01802318135._3 | |
443 | + | let availableToClaim = (wxToClaimUserNew - claimedByUser) | |
444 | + | if ((zeroBigInt >= availableToClaim)) | |
445 | + | then throw("nothing to claim") | |
446 | + | else { | |
447 | + | let wxAmountBoostTotal = asInt(asAnyList(invoke(boostingContract, "claimWxBoost", [lpAssetIdStr, userAddressStr], nil))[0]) | |
448 | + | let minRewardPart = availableToClaim | |
449 | + | let boostRewardPart = min([(minRewardPart * toBigInt(2)), toBigInt(wxAmountBoostTotal)]) | |
450 | + | let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [minRewardPart], nil))[0]) | |
451 | + | let emitBoost = asAnyList(invoke(emissionContract, "emit", [boostRewardPart], nil)) | |
452 | + | if ((emitBoost == emitBoost)) | |
453 | + | then { | |
454 | + | let claimedByUserValue = (claimedByUser + availableToClaim) | |
455 | + | let claimedByUserMinRewardPlusPart = (claimedByUserMinReward + minRewardPart) | |
456 | + | let claimedByUserBoostRewardPlusBoostRewardPart = (claimedByUserMinReward + minRewardPart) | |
457 | + | let claimedTotalPlusAvailableToClaim = (claimedByUserMinReward + minRewardPart) | |
458 | + | [StringEntry(claimedByUserKEY, toString(claimedByUserValue)), StringEntry(claimedByUserMinRewardKEY, toString(claimedByUserMinRewardPlusPart)), StringEntry(claimedByUserBoostRewardKEY, toString(claimedByUserBoostRewardPlusBoostRewardPart)), StringEntry(claimedTotalKEY, toString(claimedTotalPlusAvailableToClaim)), ScriptTransfer(userAddress, toInt(minRewardPart), wxAssetId), ScriptTransfer(userAddress, toInt(boostRewardPart), wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, toInt(availableToClaim), i.transactionId)] | |
459 | + | } | |
460 | + | else throw("Strict value is not equal to itself.") | |
461 | + | } | |
462 | + | } | |
463 | + | ||
464 | + | ||
465 | + | ||
466 | + | @Callable(i) | |
467 | + | func claimWxREADONLY (lpAssetIdStr,userAddressStr) = { | |
468 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
469 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
470 | + | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
471 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
472 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
473 | + | let claimedByUser = getIntOrZero(this, claimedByUserKEY) | |
474 | + | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
475 | + | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
476 | + | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
477 | + | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
478 | + | let passedBlocks = if ((emissionStartBlock > height)) | |
479 | + | then 0 | |
480 | + | else (height - emissionStartBlock) | |
481 | + | let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, POOLWEIGHTMULT) | |
482 | + | let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal) | |
483 | + | let $t02072020832 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
484 | + | let wxToClaimUserNew = $t02072020832._1 | |
485 | + | let integralSTATE = $t02072020832._2 | |
486 | + | let debug = $t02072020832._3 | |
487 | + | let availableToClaim = (wxToClaimUserNew - toBigInt(claimedByUser)) | |
488 | + | let boostInvResult = asAnyList(invoke(boostingContract, "claimWxBoostREADONLY", [lpAssetIdStr, userAddressStr], nil)) | |
489 | + | let wxAmountBoostTotal = asInt(boostInvResult[0]) | |
490 | + | let boostDebug = asString(boostInvResult[1]) | |
491 | + | let minRewardPart = availableToClaim | |
492 | + | let boostRewardPart = min([(minRewardPart * toBigInt(2)), toBigInt(wxAmountBoostTotal)]) | |
493 | + | let totalReward = (minRewardPart + boostRewardPart) | |
494 | + | $Tuple2(nil, makeString(["%s%s%d%d%d%d%s", lpAssetIdStr, userAddressStr, toString(totalReward), toString(claimedByUser), toString(minRewardPart), toString(boostRewardPart), ((((debug + "::") + toString(userWxReward)) + "::BOOSTDEBUG::") + boostDebug)], SEP)) | |
495 | + | } | |
496 | + | ||
497 | + | ||
498 | + | ||
499 | + | @Callable(i) | |
500 | + | func onModifyWeight (lpAssetIdStr,poolAddressStr) = if ((i.caller != factoryContract)) | |
501 | + | then throw("permissions denied") | |
502 | + | else { | |
503 | + | let $t02174521855 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, 0) | |
504 | + | let wxPerLpIntegralNew = $t02174521855._1 | |
505 | + | let poolIntegralSTATE = $t02174521855._2 | |
506 | + | let poolDEBUG = $t02174521855._3 | |
507 | + | poolIntegralSTATE | |
508 | + | } | |
390 | 509 | ||
391 | 510 | ||
392 | 511 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let SCALE8 = 8 | |
5 | 5 | ||
6 | - | let | |
6 | + | let MULT8 = 100000000 | |
7 | 7 | ||
8 | - | let | |
8 | + | let SCALE18 = 18 | |
9 | 9 | ||
10 | - | let | |
10 | + | let MULT18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | - | let | |
12 | + | let SEP = "__" | |
13 | 13 | ||
14 | - | let | |
14 | + | let POOLWEIGHTMULT = MULT8 | |
15 | 15 | ||
16 | - | let | |
16 | + | let zeroBigInt = toBigInt(0) | |
17 | 17 | ||
18 | - | let | |
18 | + | let oneBigInt = toBigInt(1) | |
19 | 19 | ||
20 | - | let keyEmissionContract = makeString(["%s", "emissionContract"], separator) | |
21 | - | ||
22 | - | let keyBoostingContract = makeString(["%s", "boostingContract"], separator) | |
23 | - | ||
24 | - | let keyFactoryContract = makeString(["%s", "factoryContract"], separator) | |
25 | - | ||
26 | - | let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], separator) | |
27 | - | ||
28 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (key + " is not defined")) | |
20 | + | func asAnyList (val) = match val { | |
21 | + | case valAnyLyst: List[Any] => | |
22 | + | valAnyLyst | |
23 | + | case _ => | |
24 | + | throw("fail to cast into List[Any]") | |
25 | + | } | |
29 | 26 | ||
30 | 27 | ||
31 | - | func keyInListAssetId (amountAssetId,priceAssetId) = makeString(["%s%s%s", "inList", amountAssetId, priceAssetId], separator) | |
28 | + | func asInt (val) = match val { | |
29 | + | case valInt: Int => | |
30 | + | valInt | |
31 | + | case _ => | |
32 | + | throw("fail to cast into Int") | |
33 | + | } | |
32 | 34 | ||
33 | 35 | ||
34 | - | func keySuggestIndex (amountAssetId,priceAssetId) = makeString(["%s%s%s", "suggestIndex", amountAssetId, priceAssetId], separator) | |
36 | + | func asString (val) = match val { | |
37 | + | case valStr: String => | |
38 | + | valStr | |
39 | + | case _ => | |
40 | + | throw("fail to cast into Int") | |
41 | + | } | |
35 | 42 | ||
36 | 43 | ||
37 | - | func keyStartHeight (amountAssetId,priceAssetId,suggestIndex) = makeString(["%s%s%s%d", "startHeight", amountAssetId, priceAssetId, toString(suggestIndex)], separator) | |
44 | + | func asByteVector (val) = match val { | |
45 | + | case valBin: ByteVector => | |
46 | + | valBin | |
47 | + | case _ => | |
48 | + | throw("fail to cast into Int") | |
49 | + | } | |
38 | 50 | ||
39 | 51 | ||
40 | - | func | |
52 | + | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (("mandatory this." + key) + " is not defined")) | |
41 | 53 | ||
42 | 54 | ||
43 | - | func | |
55 | + | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
44 | 56 | ||
45 | 57 | ||
46 | - | func | |
58 | + | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
47 | 59 | ||
48 | 60 | ||
49 | - | func keyVoteValue (gwxAmount,vote) = { | |
50 | - | let key = if (vote) | |
51 | - | then makeString(["%d%s", gwxAmount, "yes"], separator) | |
52 | - | else makeString(["%d%s", gwxAmount, "no"], separator) | |
53 | - | key | |
54 | - | } | |
61 | + | func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
62 | + | ||
63 | + | ||
64 | + | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) | |
65 | + | ||
66 | + | ||
67 | + | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), MULT18, toBigInt(origScaleMult)) | |
68 | + | ||
69 | + | ||
70 | + | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), MULT18)) | |
71 | + | ||
72 | + | ||
73 | + | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
74 | + | ||
75 | + | ||
76 | + | let IdxFactoryCfgStakingDapp = 1 | |
77 | + | ||
78 | + | let IdxFactoryCfgBoostingDapp = 2 | |
79 | + | ||
80 | + | let IdxFactoryCfgIdoDapp = 3 | |
81 | + | ||
82 | + | let IdxFactoryCfgTeamDapp = 4 | |
83 | + | ||
84 | + | let IdxFactoryCfgEmissionDapp = 5 | |
85 | + | ||
86 | + | let IdxFactoryCfgRestDapp = 6 | |
87 | + | ||
88 | + | let IdxFactoryCfgSlippageDapp = 7 | |
89 | + | ||
90 | + | func keyFactoryCfg () = "%s__factoryConfig" | |
55 | 91 | ||
56 | 92 | ||
57 | 93 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
58 | 94 | ||
59 | 95 | ||
60 | 96 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
61 | 97 | ||
62 | 98 | ||
63 | - | ||
99 | + | func keyStablePoolAddonAddr () = "%s__stablePoolAddonAddr" | |
64 | 100 | ||
65 | - | let boostingContract = addressFromStringValue(getStringOrFail(keyBoostingContract)) | |
66 | 101 | ||
67 | - | ||
102 | + | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
68 | 103 | ||
69 | - | let factoryContract = addressFromStringValue(getStringOrFail(keyFactoryContract)) | |
70 | 104 | ||
71 | - | ||
105 | + | func keyFactoryLpList () = "%s__lpTokensList" | |
72 | 106 | ||
73 | - | let votingEmissionContract = addressFromStringValue(getStringOrFail(keyVotingEmissionContract)) | |
107 | + | ||
108 | + | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
109 | + | ||
110 | + | ||
111 | + | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
112 | + | ||
113 | + | ||
114 | + | func readLpList (factory) = split(valueOrElse(getString(factory, keyFactoryLpList()), ""), SEP) | |
115 | + | ||
116 | + | ||
117 | + | func readFactoryCfgOrFail (factory) = split(getStringByAddressOrFail(factory, keyFactoryCfg()), SEP) | |
118 | + | ||
119 | + | ||
120 | + | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
121 | + | ||
122 | + | ||
123 | + | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
124 | + | ||
125 | + | ||
126 | + | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
127 | + | ||
128 | + | ||
129 | + | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
130 | + | ||
131 | + | ||
132 | + | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
133 | + | ||
134 | + | ||
135 | + | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
136 | + | ||
137 | + | ||
138 | + | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
139 | + | ||
140 | + | ||
141 | + | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
142 | + | ||
143 | + | ||
144 | + | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
145 | + | ||
146 | + | ||
147 | + | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
148 | + | ||
149 | + | ||
150 | + | func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) | |
151 | + | ||
152 | + | ||
153 | + | func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP) | |
154 | + | ||
155 | + | ||
156 | + | func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP) | |
157 | + | ||
158 | + | ||
159 | + | func keyClaimedTotal (lpAssetIdStr) = makeString(["%s%s%s__claimed", "total", lpAssetIdStr], SEP) | |
160 | + | ||
161 | + | ||
162 | + | func readStaked (key) = valueOrElse(getInteger(this, key), 0) | |
163 | + | ||
164 | + | ||
165 | + | func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP) | |
166 | + | ||
167 | + | ||
168 | + | func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP) | |
169 | + | ||
170 | + | ||
171 | + | func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP) | |
172 | + | ||
173 | + | ||
174 | + | func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP) | |
175 | + | ||
176 | + | ||
177 | + | func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP) | |
178 | + | ||
179 | + | ||
180 | + | func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP) | |
181 | + | ||
182 | + | ||
183 | + | func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP) | |
184 | + | ||
185 | + | ||
186 | + | func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP) | |
187 | + | ||
188 | + | ||
189 | + | func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP) | |
190 | + | ||
191 | + | ||
192 | + | func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP) | |
193 | + | ||
194 | + | ||
195 | + | func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP) | |
196 | + | ||
197 | + | ||
198 | + | func keyWxPerLpX18 (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLpX18"], SEP) | |
199 | + | ||
200 | + | ||
201 | + | func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP) | |
202 | + | ||
203 | + | ||
204 | + | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
205 | + | ||
206 | + | ||
207 | + | func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
208 | + | ||
209 | + | ||
210 | + | func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount)) | |
211 | + | ||
212 | + | ||
213 | + | let factoryAddress = getStringOrFail(this, keyFactoryAddress()) | |
214 | + | ||
215 | + | let factoryContract = addressFromStringValue(factoryAddress) | |
216 | + | ||
217 | + | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
218 | + | ||
219 | + | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
220 | + | ||
221 | + | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
222 | + | ||
223 | + | func calcWxPerLpIntegralUserLast (stakedByUser,wxPerLpIntegralUserLastUpdHeightOrZero,wxPerLpIntegralNew,wxPerLpIntegralUserLastKEY) = if (if ((wxPerLpIntegralUserLastUpdHeightOrZero == zeroBigInt)) | |
224 | + | then (stakedByUser > zeroBigInt) | |
225 | + | else false) | |
226 | + | then zeroBigInt | |
227 | + | else if ((stakedByUser == zeroBigInt)) | |
228 | + | then wxPerLpIntegralNew | |
229 | + | else if (if ((wxPerLpIntegralUserLastUpdHeightOrZero > zeroBigInt)) | |
230 | + | then (stakedByUser > zeroBigInt) | |
231 | + | else false) | |
232 | + | then value(parseBigInt(getStringOrFail(this, wxPerLpIntegralUserLastKEY))) | |
233 | + | else throw("calcWxPerLpIntegralUserLast: unexpected state") | |
234 | + | ||
235 | + | ||
236 | + | func refreshPoolINTEGRALS (lpAssetIdStr,poolAddressStr,lpDeltaAmount) = { | |
237 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
238 | + | let stakedTotal = toBigInt(readStaked(stakedTotalKEY)) | |
239 | + | let nonZeroStakedTotal = if ((stakedTotal == zeroBigInt)) | |
240 | + | then oneBigInt | |
241 | + | else stakedTotal | |
242 | + | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
243 | + | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
244 | + | let MULT3 = 1000 | |
245 | + | let wxEmissionPerBlockX3 = (getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) * MULT3) | |
246 | + | let poolWxEmissionPerBlockX3 = fraction(wxEmissionPerBlockX3, poolWeight, (POOLWEIGHTMULT * 3)) | |
247 | + | let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr) | |
248 | + | let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr) | |
249 | + | let wxPerLpKEY = keyWxPerLp(lpAssetIdStr) | |
250 | + | let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock) | |
251 | + | let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY) | |
252 | + | let wxPerLpOrZeroX3 = 0 | |
253 | + | let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0]) | |
254 | + | let wxPerLpX3 = if ((wxPerLpOrZeroX3 != 0)) | |
255 | + | then toBigInt(wxPerLpOrZeroX3) | |
256 | + | else fraction(toBigInt(poolWxEmissionPerBlockX3), toBigInt(MULT8), nonZeroStakedTotal) | |
257 | + | let stakedTotalNew = (stakedTotal + toBigInt(lpDeltaAmount)) | |
258 | + | let nonZeroStakedTotalNew = if ((stakedTotalNew == zeroBigInt)) | |
259 | + | then oneBigInt | |
260 | + | else stakedTotalNew | |
261 | + | let wxPerLpIntegralNew = (toBigInt(wxPerLpIntegral) + (wxPerLpX3 * toBigInt(dh))) | |
262 | + | let wxPerLpX3New = (toBigInt(poolWxEmissionPerBlockX3) / nonZeroStakedTotalNew) | |
263 | + | let wxPerLpIntegralLastUpdHeightNew = height | |
264 | + | let debug = makeString(["wxPerLpIntegralNew=", toString(wxPerLpIntegralNew), "dh=", toString(dh), "wxPerLpX3=", toString(wxPerLpX3), "stakedTotal=", toString(stakedTotal), "poolWxEmissionPerBlockX3=", toString(poolWxEmissionPerBlockX3), "wxEmissionPerBlockX3=", toString(wxEmissionPerBlockX3), "poolWeight=", toString(poolWeight)], "::") | |
265 | + | $Tuple3(wxPerLpIntegralNew, [StringEntry(wxPerLpIntegralKEY, toString(wxPerLpIntegralNew)), IntegerEntry(wxPerLpIntegralLastUpdHeightKEY, wxPerLpIntegralLastUpdHeightNew), StringEntry(wxPerLpKEY, toString(wxPerLpX3New))], debug) | |
266 | + | } | |
267 | + | ||
268 | + | ||
269 | + | func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = { | |
270 | + | let $t01119411316 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, lpDeltaAmount) | |
271 | + | let wxPerLpIntegralNew = $t01119411316._1 | |
272 | + | let poolIntegralSTATE = $t01119411316._2 | |
273 | + | let poolDEBUG = $t01119411316._3 | |
274 | + | let MULT3 = 1000 | |
275 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
276 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
277 | + | let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr) | |
278 | + | let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr) | |
279 | + | let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr) | |
280 | + | let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY) | |
281 | + | let wxPerLpIntegralUserLastUpdHeightOrZero = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY) | |
282 | + | let wxPerLpIntegralUserLast = calcWxPerLpIntegralUserLast(toBigInt(stakedByUser), toBigInt(wxPerLpIntegralUserLastUpdHeightOrZero), wxPerLpIntegralNew, wxPerLpIntegralUserLastKEY) | |
283 | + | let MULT11 = (MULT8 * MULT3) | |
284 | + | let wxToClaimUserNew = (toBigInt(wxToClaimUser) + fraction((wxPerLpIntegralNew - wxPerLpIntegralUserLast), toBigInt(stakedByUser), toBigInt(MULT11))) | |
285 | + | let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew | |
286 | + | let wxPerLpIntegralUserLastUpdHeightNew = height | |
287 | + | let debug = makeString(["wxToClaimUserNew=", toString(wxToClaimUserNew), "wxPerLpIntegralUserLast=", toString(wxPerLpIntegralUserLast), "stakedByUser=", toString(stakedByUser), "poolDEBUG=", poolDEBUG, "height=", toString(height)], "::") | |
288 | + | $Tuple3(wxToClaimUserNew, (poolIntegralSTATE ++ [StringEntry(wxToClaimUserKEY, toString(wxToClaimUserNew)), IntegerEntry(wxPerLpIntegralUserLastUpdHeightKEY, wxPerLpIntegralUserLastUpdHeightNew), StringEntry(wxPerLpIntegralUserLastKEY, toString(wxPerLpIntegralUserLastNew))]), debug) | |
289 | + | } | |
290 | + | ||
74 | 291 | ||
75 | 292 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
76 | 293 | case s: String => | |
77 | 294 | fromBase58String(s) | |
78 | 295 | case _: Unit => | |
79 | 296 | unit | |
80 | 297 | case _ => | |
81 | 298 | throw("Match error") | |
82 | 299 | } | |
83 | 300 | ||
84 | 301 | ||
85 | 302 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
86 | 303 | case s: String => | |
87 | 304 | fromBase58String(s) | |
88 | 305 | case _: Unit => | |
89 | 306 | unit | |
90 | 307 | case _ => | |
91 | 308 | throw("Match error") | |
92 | 309 | } | |
93 | 310 | ||
94 | 311 | ||
95 | 312 | func mustManager (i) = { | |
96 | - | let pd = throw(" | |
313 | + | let pd = throw("Permission denied") | |
97 | 314 | match managerPublicKeyOrUnit() { | |
98 | 315 | case pk: ByteVector => | |
99 | 316 | if ((i.callerPublicKey == pk)) | |
100 | 317 | then true | |
101 | 318 | else pd | |
102 | 319 | case _: Unit => | |
103 | 320 | if ((i.caller == this)) | |
104 | 321 | then true | |
105 | 322 | else pd | |
106 | 323 | case _ => | |
107 | 324 | throw("Match error") | |
108 | 325 | } | |
109 | 326 | } | |
110 | 327 | ||
111 | 328 | ||
112 | - | func asInt (val) = match val { | |
113 | - | case valInt: Int => | |
114 | - | valInt | |
115 | - | case _ => | |
116 | - | throw("failed to cast into Integer") | |
117 | - | } | |
118 | - | ||
119 | - | ||
120 | 329 | @Callable(i) | |
121 | - | func constructor (assetsStoreContractPrm,boostingContractPrm,emissionContractPrm,factoryContractPrm,userPoolContractPrm,votingEmissionContractPrm,feeAmountPrm,wxAssetIdPrm,votingDurationPrm,usdnAssetIdPrm,finalizeRewardPrm) = { | |
122 | - | let checks = [mustManager(i), if (isDefined(addressFromString(assetsStoreContractPrm))) | |
123 | - | then true | |
124 | - | else throw("Invalid asset_store contract address"), if (isDefined(addressFromString(boostingContractPrm))) | |
125 | - | then true | |
126 | - | else throw("Invalid boosting contract address"), if (isDefined(addressFromString(userPoolContractPrm))) | |
127 | - | then true | |
128 | - | else throw("Invalid user_pools contract address"), if (isDefined(addressFromString(emissionContractPrm))) | |
129 | - | then true | |
130 | - | else throw("Invalid emission contract address"), if (isDefined(addressFromString(factoryContractPrm))) | |
131 | - | then true | |
132 | - | else throw("Invalid factory contract address"), if ((feeAmountPrm >= 0)) | |
133 | - | then true | |
134 | - | else throw("Invalid fee amount"), if ((votingDurationPrm > 0)) | |
135 | - | then true | |
136 | - | else throw("Invalid voting duration"), if ((finalizeRewardPrm > 0)) | |
137 | - | then true | |
138 | - | else throw("Invalid finalize reward"), if (isDefined(assetInfo(fromBase58String(wxAssetIdPrm)))) | |
139 | - | then true | |
140 | - | else throw("Invalid WX asset ID"), if (isDefined(assetInfo(fromBase58String(usdnAssetIdPrm)))) | |
141 | - | then true | |
142 | - | else throw("Invalid USDN asset ID")] | |
143 | - | if ((checks == checks)) | |
144 | - | then $Tuple2([StringEntry(keyAssetsStoreContract, assetsStoreContractPrm), StringEntry(keyBoostingContract, boostingContractPrm), StringEntry(keyEmissionContract, emissionContractPrm), StringEntry(keyFactoryContract, factoryContractPrm), StringEntry(keyUserPoolContract, userPoolContractPrm), StringEntry(keyVotingEmissionContract, votingEmissionContractPrm), IntegerEntry(keyFeeAmount, feeAmountPrm), IntegerEntry(keyEpochLength, votingDurationPrm), IntegerEntry(keyFinalizeReward, finalizeRewardPrm), StringEntry(keyWxAssetId, wxAssetIdPrm), StringEntry(keyUsdnAssetId, usdnAssetIdPrm)], unit) | |
145 | - | else throw("Strict value is not equal to itself.") | |
146 | - | } | |
147 | - | ||
148 | - | ||
149 | - | ||
150 | - | @Callable(i) | |
151 | - | func suggest (amountAssetId,priceAssetId) = { | |
152 | - | let payment = value(i.payments[0]) | |
153 | - | let info = valueOrErrorMessage(assetInfo(fromBase58String(amountAssetId)), "invalid amountAssetId ID") | |
154 | - | let checks = [if ((info.issuer == i.caller)) | |
155 | - | then true | |
156 | - | else throw("asset can only be suggested by its issuer"), if ((info.scripted == false)) | |
157 | - | then true | |
158 | - | else throw("asset is smart"), if ((toBase58String(value(payment.assetId)) == value(getString(keyWxAssetId)))) | |
159 | - | then true | |
160 | - | else throw("invalid fee asset"), if ((payment.amount == value(getInteger(keyFeeAmount)))) | |
161 | - | then true | |
162 | - | else throw("invalid fee amount"), if ((priceAssetId == value(getString(keyUsdnAssetId)))) | |
163 | - | then true | |
164 | - | else throw("priceAssetId is not USDN"), if ((getInteger(keyInListAssetId(amountAssetId, priceAssetId)) == unit)) | |
165 | - | then true | |
166 | - | else throw("already in voting list")] | |
167 | - | if ((checks == checks)) | |
168 | - | then { | |
169 | - | let ensureActive = match invoke(userPoolContract, "statusREADONLY", [amountAssetId, priceAssetId], nil) { | |
170 | - | case s: String => | |
171 | - | if ((s == "active")) | |
172 | - | then true | |
173 | - | else throw("user pool is not active") | |
174 | - | case _ => | |
175 | - | throw("user pool is not active") | |
176 | - | } | |
177 | - | if ((ensureActive == ensureActive)) | |
178 | - | then { | |
179 | - | let ensureAmountAssetVerified = match invoke(assetsStoreContract, "isVerifiedREADONLY", [amountAssetId], nil) { | |
180 | - | case b: Boolean => | |
181 | - | if (b) | |
182 | - | then true | |
183 | - | else throw("asset is not verified") | |
184 | - | case _ => | |
185 | - | throw("asset is not verified") | |
186 | - | } | |
187 | - | if ((ensureAmountAssetVerified == ensureAmountAssetVerified)) | |
188 | - | then { | |
189 | - | let burnFeeInv = invoke(emissionContract, "burn", nil, [AttachedPayment(payment.assetId, payment.amount)]) | |
190 | - | if ((burnFeeInv == burnFeeInv)) | |
191 | - | then { | |
192 | - | let newSuggestIndex = match getInteger(keySuggestIndex(amountAssetId, priceAssetId)) { | |
193 | - | case int: Int => | |
194 | - | (int + 1) | |
195 | - | case _ => | |
196 | - | 0 | |
197 | - | } | |
198 | - | $Tuple2([IntegerEntry(keyInListAssetId(amountAssetId, priceAssetId), newSuggestIndex), IntegerEntry(keyStartHeight(amountAssetId, priceAssetId, newSuggestIndex), height), StringEntry(keyVotingResult(amountAssetId, priceAssetId, newSuggestIndex), totalVotes("0", "0")), IntegerEntry(keySuggestIndex(amountAssetId, priceAssetId), newSuggestIndex)], unit) | |
199 | - | } | |
200 | - | else throw("Strict value is not equal to itself.") | |
201 | - | } | |
202 | - | else throw("Strict value is not equal to itself.") | |
203 | - | } | |
204 | - | else throw("Strict value is not equal to itself.") | |
205 | - | } | |
206 | - | else throw("Strict value is not equal to itself.") | |
207 | - | } | |
208 | - | ||
209 | - | ||
210 | - | ||
211 | - | @Callable(i) | |
212 | - | func vote (amountAssetId,priceAssetId,inFavor) = { | |
213 | - | let suggestIndex = value(getInteger(keyInListAssetId(amountAssetId, priceAssetId))) | |
214 | - | let votingFinishHeight = (value(getInteger(keyStartHeight(amountAssetId, priceAssetId, suggestIndex))) + value(getInteger(keyEpochLength))) | |
215 | - | let checks = [if (isDefined(getInteger(keyInListAssetId(amountAssetId, priceAssetId)))) | |
216 | - | then true | |
217 | - | else throw("the token isn't on the voting list"), if ((votingFinishHeight > height)) | |
218 | - | then true | |
219 | - | else throw("too late to vote")] | |
220 | - | if ((checks == checks)) | |
221 | - | then { | |
222 | - | let gwxAmount = invoke(boostingContract, "getUserGwxAmountAtHeightREADONLY", [toString(i.caller), votingFinishHeight], nil) | |
223 | - | let notZero = if ((asInt(gwxAmount) > 0)) | |
224 | - | then true | |
225 | - | else throw("you don't have gwx") | |
226 | - | if ((notZero == notZero)) | |
227 | - | then { | |
228 | - | let vote = match getString(keyVote(amountAssetId, priceAssetId, suggestIndex, toString(i.caller))) { | |
229 | - | case s: String => | |
230 | - | let vote = split(s, separator) | |
231 | - | let voteValue = vote[1] | |
232 | - | let voteType = vote[2] | |
233 | - | let isVoteTypeSimilar = if (if ((voteType == "yes")) | |
234 | - | then (inFavor == true) | |
235 | - | else false) | |
236 | - | then true | |
237 | - | else if ((voteType == "no")) | |
238 | - | then (inFavor == false) | |
239 | - | else false | |
240 | - | let isVoteValueSimilar = if (isVoteTypeSimilar) | |
241 | - | then (asInt(gwxAmount) == parseIntValue(voteValue)) | |
242 | - | else false | |
243 | - | let isNewVoteSimilar = if (if (isVoteTypeSimilar) | |
244 | - | then isVoteValueSimilar | |
245 | - | else false) | |
246 | - | then throw("you already voted") | |
247 | - | else invoke(this, "cancelVote", [amountAssetId, priceAssetId], nil) | |
248 | - | isNewVoteSimilar | |
249 | - | case u: Unit => | |
250 | - | u | |
251 | - | case _ => | |
252 | - | throw("Match error") | |
253 | - | } | |
254 | - | if ((vote == vote)) | |
255 | - | then { | |
256 | - | let votingResult = split(value(getString(keyVotingResult(amountAssetId, priceAssetId, suggestIndex))), separator) | |
257 | - | let positiveVotes = votingResult[1] | |
258 | - | let negativeVotes = votingResult[2] | |
259 | - | let newPositiveAndNegativeVotes = if (inFavor) | |
260 | - | then { | |
261 | - | let newPositiveVotes = (parseIntValue(positiveVotes) + asInt(gwxAmount)) | |
262 | - | [toString(newPositiveVotes), negativeVotes] | |
263 | - | } | |
264 | - | else { | |
265 | - | let newNegativeVotes = (parseIntValue(negativeVotes) + asInt(gwxAmount)) | |
266 | - | [positiveVotes, toString(newNegativeVotes)] | |
267 | - | } | |
268 | - | let voteKey = keyVote(amountAssetId, priceAssetId, suggestIndex, toString(i.caller)) | |
269 | - | let voteValue = keyVoteValue(toString(asInt(gwxAmount)), inFavor) | |
270 | - | $Tuple2([StringEntry(keyVotingResult(amountAssetId, priceAssetId, suggestIndex), totalVotes(newPositiveAndNegativeVotes[0], newPositiveAndNegativeVotes[1])), StringEntry(voteKey, voteValue)], unit) | |
271 | - | } | |
272 | - | else throw("Strict value is not equal to itself.") | |
273 | - | } | |
274 | - | else throw("Strict value is not equal to itself.") | |
275 | - | } | |
276 | - | else throw("Strict value is not equal to itself.") | |
277 | - | } | |
278 | - | ||
279 | - | ||
280 | - | ||
281 | - | @Callable(i) | |
282 | - | func cancelVote (amountAssetId,priceAssetId) = { | |
283 | - | let userAddress = if ((i.caller == this)) | |
284 | - | then toString(i.originCaller) | |
285 | - | else toString(i.caller) | |
286 | - | let suggestIndex = value(getInteger(keyInListAssetId(amountAssetId, priceAssetId))) | |
287 | - | let checks = [if (isDefined(getString(keyVotingResult(amountAssetId, priceAssetId, suggestIndex)))) | |
288 | - | then true | |
289 | - | else throw("no vote for assets pair")] | |
290 | - | if ((checks == checks)) | |
291 | - | then { | |
292 | - | let vote = split(value(getString(keyVote(amountAssetId, priceAssetId, suggestIndex, userAddress))), separator) | |
293 | - | let voteValue = vote[1] | |
294 | - | let voteType = vote[2] | |
295 | - | let votingResult = split(value(getString(keyVotingResult(amountAssetId, priceAssetId, suggestIndex))), separator) | |
296 | - | let positiveVotes = votingResult[1] | |
297 | - | let negativeVotes = votingResult[2] | |
298 | - | let actions = if ((voteType == "yes")) | |
299 | - | then { | |
300 | - | let newPositiveVotes = (parseIntValue(positiveVotes) - parseIntValue(voteValue)) | |
301 | - | $Tuple2([StringEntry(keyVotingResult(amountAssetId, priceAssetId, suggestIndex), totalVotes(toString(newPositiveVotes), negativeVotes)), DeleteEntry(keyVote(amountAssetId, priceAssetId, suggestIndex, userAddress))], unit) | |
302 | - | } | |
303 | - | else { | |
304 | - | let newNegativeVotes = (parseIntValue(negativeVotes) - parseIntValue(voteValue)) | |
305 | - | $Tuple2([StringEntry(keyVotingResult(amountAssetId, priceAssetId, suggestIndex), totalVotes(positiveVotes, toString(newNegativeVotes))), DeleteEntry(keyVote(amountAssetId, priceAssetId, suggestIndex, userAddress))], unit) | |
306 | - | } | |
307 | - | actions | |
308 | - | } | |
309 | - | else throw("Strict value is not equal to itself.") | |
310 | - | } | |
311 | - | ||
312 | - | ||
313 | - | ||
314 | - | @Callable(i) | |
315 | - | func setFee (newFee) = { | |
316 | - | let checks = [mustManager(i)] | |
317 | - | if ((checks == checks)) | |
318 | - | then [IntegerEntry(keyFeeAmount, newFee)] | |
319 | - | else throw("Strict value is not equal to itself.") | |
320 | - | } | |
321 | - | ||
322 | - | ||
323 | - | ||
324 | - | @Callable(i) | |
325 | - | func finalize (amountAssetId,priceAssetId) = { | |
326 | - | let suggestIndex = value(getInteger(keyInListAssetId(amountAssetId, priceAssetId))) | |
327 | - | let votingFinishHeight = (value(getInteger(keyStartHeight(amountAssetId, priceAssetId, suggestIndex))) + value(getInteger(keyEpochLength))) | |
328 | - | let checks = [if (isDefined(getInteger(keyInListAssetId(amountAssetId, priceAssetId)))) | |
329 | - | then true | |
330 | - | else throw("no assets pair"), if ((height >= votingFinishHeight)) | |
331 | - | then true | |
332 | - | else throw("insufficient height for completion")] | |
333 | - | if ((checks == checks)) | |
334 | - | then { | |
335 | - | let votingResult = split(value(getString(keyVotingResult(amountAssetId, priceAssetId, suggestIndex))), separator) | |
336 | - | let positiveVotes = parseIntValue(votingResult[1]) | |
337 | - | let negativeVotes = parseIntValue(votingResult[2]) | |
338 | - | let actions = if ((positiveVotes > negativeVotes)) | |
339 | - | then { | |
340 | - | let res = invoke(factoryContract, "setWxEmissionPoolLabel", [amountAssetId, priceAssetId], nil) | |
341 | - | if ((res == res)) | |
342 | - | then { | |
343 | - | let votingEmissionInv = invoke(votingEmissionContract, "create", [amountAssetId, priceAssetId], nil) | |
344 | - | if ((votingEmissionInv == votingEmissionInv)) | |
345 | - | then $Tuple2([DeleteEntry(keyInListAssetId(amountAssetId, priceAssetId))], unit) | |
346 | - | else throw("Strict value is not equal to itself.") | |
347 | - | } | |
348 | - | else throw("Strict value is not equal to itself.") | |
349 | - | } | |
350 | - | else $Tuple2([DeleteEntry(keyInListAssetId(amountAssetId, priceAssetId))], unit) | |
351 | - | actions | |
352 | - | } | |
330 | + | func constructor (factoryAddressStr) = { | |
331 | + | let checkCaller = mustManager(i) | |
332 | + | if ((checkCaller == checkCaller)) | |
333 | + | then [StringEntry(keyFactoryAddress(), factoryAddressStr)] | |
353 | 334 | else throw("Strict value is not equal to itself.") | |
354 | 335 | } | |
355 | 336 | ||
356 | 337 | ||
357 | 338 | ||
358 | 339 | @Callable(i) | |
359 | 340 | func setManager (pendingManagerPublicKey) = { | |
360 | 341 | let checkCaller = mustManager(i) | |
361 | 342 | if ((checkCaller == checkCaller)) | |
362 | 343 | then { | |
363 | 344 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
364 | 345 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
365 | 346 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
366 | 347 | else throw("Strict value is not equal to itself.") | |
367 | 348 | } | |
368 | 349 | else throw("Strict value is not equal to itself.") | |
369 | 350 | } | |
370 | 351 | ||
371 | 352 | ||
372 | 353 | ||
373 | 354 | @Callable(i) | |
374 | 355 | func confirmManager () = { | |
375 | 356 | let pm = pendingManagerPublicKeyOrUnit() | |
376 | 357 | let hasPM = if (isDefined(pm)) | |
377 | 358 | then true | |
378 | - | else throw(" | |
359 | + | else throw("No pending manager") | |
379 | 360 | if ((hasPM == hasPM)) | |
380 | 361 | then { | |
381 | 362 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
382 | 363 | then true | |
383 | - | else throw(" | |
364 | + | else throw("You are not pending manager") | |
384 | 365 | if ((checkPM == checkPM)) | |
385 | 366 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
386 | 367 | else throw("Strict value is not equal to itself.") | |
387 | 368 | } | |
388 | 369 | else throw("Strict value is not equal to itself.") | |
389 | 370 | } | |
371 | + | ||
372 | + | ||
373 | + | ||
374 | + | @Callable(i) | |
375 | + | func stake () = if ((size(i.payments) != 1)) | |
376 | + | then throw("invalid payment - exact one payment must be attached") | |
377 | + | else { | |
378 | + | let pmt = i.payments[0] | |
379 | + | let lpAssetId = value(pmt.assetId) | |
380 | + | let lpAssetIdStr = toBase58String(lpAssetId) | |
381 | + | let amount = pmt.amount | |
382 | + | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
383 | + | let callerStr = toString(i.caller) | |
384 | + | let userAddressStr = if ((callerStr == poolAddressStr)) | |
385 | + | then toString(i.originCaller) | |
386 | + | else callerStr | |
387 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
388 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
389 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
390 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
391 | + | let $t01541515532 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount) | |
392 | + | let wxToClaimUserNew = $t01541515532._1 | |
393 | + | let integralSTATE = $t01541515532._2 | |
394 | + | let debug = $t01541515532._3 | |
395 | + | ([IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
396 | + | } | |
397 | + | ||
398 | + | ||
399 | + | ||
400 | + | @Callable(i) | |
401 | + | func unstake (lpAssetIdStr,amount) = { | |
402 | + | let lpAssetId = fromBase58String(lpAssetIdStr) | |
403 | + | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
404 | + | let poolAddon = valueOrElse(getString(this, keyStablePoolAddonAddr()), poolAddressStr) | |
405 | + | let callerStr = toString(i.caller) | |
406 | + | let userAddressStr = if (if ((callerStr == poolAddressStr)) | |
407 | + | then true | |
408 | + | else (callerStr == poolAddon)) | |
409 | + | then toString(i.originCaller) | |
410 | + | else callerStr | |
411 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
412 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
413 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
414 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
415 | + | let $t01666916787 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount)) | |
416 | + | let wxToClaimUserNew = $t01666916787._1 | |
417 | + | let integralSTATE = $t01666916787._2 | |
418 | + | let debug = $t01666916787._3 | |
419 | + | if ((amount > stakedByUser)) | |
420 | + | then throw("passed amount is less then available") | |
421 | + | else ([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
422 | + | } | |
423 | + | ||
424 | + | ||
425 | + | ||
426 | + | @Callable(i) | |
427 | + | func claimWx (lpAssetIdStr) = { | |
428 | + | let userAddress = i.caller | |
429 | + | let userAddressStr = toString(i.caller) | |
430 | + | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
431 | + | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
432 | + | let claimedTotalKEY = keyClaimedTotal(lpAssetIdStr) | |
433 | + | let claimedByUserMinRewardKEY = keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr) | |
434 | + | let claimedByUserBoostRewardKEY = keyClaimedByUserBoostReward(lpAssetIdStr, userAddressStr) | |
435 | + | let claimedByUser = toBigInt(getIntOrZero(this, claimedByUserKEY)) | |
436 | + | let claimedByUserMinReward = toBigInt(getIntOrZero(this, claimedByUserMinRewardKEY)) | |
437 | + | let claimedByUserBoostReward = toBigInt(getIntOrZero(this, claimedByUserBoostRewardKEY)) | |
438 | + | let claimedTotal = toBigInt(getIntOrZero(this, claimedTotalKEY)) | |
439 | + | let $t01802318135 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
440 | + | let wxToClaimUserNew = $t01802318135._1 | |
441 | + | let integralSTATE = $t01802318135._2 | |
442 | + | let debug = $t01802318135._3 | |
443 | + | let availableToClaim = (wxToClaimUserNew - claimedByUser) | |
444 | + | if ((zeroBigInt >= availableToClaim)) | |
445 | + | then throw("nothing to claim") | |
446 | + | else { | |
447 | + | let wxAmountBoostTotal = asInt(asAnyList(invoke(boostingContract, "claimWxBoost", [lpAssetIdStr, userAddressStr], nil))[0]) | |
448 | + | let minRewardPart = availableToClaim | |
449 | + | let boostRewardPart = min([(minRewardPart * toBigInt(2)), toBigInt(wxAmountBoostTotal)]) | |
450 | + | let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [minRewardPart], nil))[0]) | |
451 | + | let emitBoost = asAnyList(invoke(emissionContract, "emit", [boostRewardPart], nil)) | |
452 | + | if ((emitBoost == emitBoost)) | |
453 | + | then { | |
454 | + | let claimedByUserValue = (claimedByUser + availableToClaim) | |
455 | + | let claimedByUserMinRewardPlusPart = (claimedByUserMinReward + minRewardPart) | |
456 | + | let claimedByUserBoostRewardPlusBoostRewardPart = (claimedByUserMinReward + minRewardPart) | |
457 | + | let claimedTotalPlusAvailableToClaim = (claimedByUserMinReward + minRewardPart) | |
458 | + | [StringEntry(claimedByUserKEY, toString(claimedByUserValue)), StringEntry(claimedByUserMinRewardKEY, toString(claimedByUserMinRewardPlusPart)), StringEntry(claimedByUserBoostRewardKEY, toString(claimedByUserBoostRewardPlusBoostRewardPart)), StringEntry(claimedTotalKEY, toString(claimedTotalPlusAvailableToClaim)), ScriptTransfer(userAddress, toInt(minRewardPart), wxAssetId), ScriptTransfer(userAddress, toInt(boostRewardPart), wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, toInt(availableToClaim), i.transactionId)] | |
459 | + | } | |
460 | + | else throw("Strict value is not equal to itself.") | |
461 | + | } | |
462 | + | } | |
463 | + | ||
464 | + | ||
465 | + | ||
466 | + | @Callable(i) | |
467 | + | func claimWxREADONLY (lpAssetIdStr,userAddressStr) = { | |
468 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
469 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
470 | + | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
471 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
472 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
473 | + | let claimedByUser = getIntOrZero(this, claimedByUserKEY) | |
474 | + | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
475 | + | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
476 | + | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
477 | + | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
478 | + | let passedBlocks = if ((emissionStartBlock > height)) | |
479 | + | then 0 | |
480 | + | else (height - emissionStartBlock) | |
481 | + | let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, POOLWEIGHTMULT) | |
482 | + | let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal) | |
483 | + | let $t02072020832 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
484 | + | let wxToClaimUserNew = $t02072020832._1 | |
485 | + | let integralSTATE = $t02072020832._2 | |
486 | + | let debug = $t02072020832._3 | |
487 | + | let availableToClaim = (wxToClaimUserNew - toBigInt(claimedByUser)) | |
488 | + | let boostInvResult = asAnyList(invoke(boostingContract, "claimWxBoostREADONLY", [lpAssetIdStr, userAddressStr], nil)) | |
489 | + | let wxAmountBoostTotal = asInt(boostInvResult[0]) | |
490 | + | let boostDebug = asString(boostInvResult[1]) | |
491 | + | let minRewardPart = availableToClaim | |
492 | + | let boostRewardPart = min([(minRewardPart * toBigInt(2)), toBigInt(wxAmountBoostTotal)]) | |
493 | + | let totalReward = (minRewardPart + boostRewardPart) | |
494 | + | $Tuple2(nil, makeString(["%s%s%d%d%d%d%s", lpAssetIdStr, userAddressStr, toString(totalReward), toString(claimedByUser), toString(minRewardPart), toString(boostRewardPart), ((((debug + "::") + toString(userWxReward)) + "::BOOSTDEBUG::") + boostDebug)], SEP)) | |
495 | + | } | |
496 | + | ||
497 | + | ||
498 | + | ||
499 | + | @Callable(i) | |
500 | + | func onModifyWeight (lpAssetIdStr,poolAddressStr) = if ((i.caller != factoryContract)) | |
501 | + | then throw("permissions denied") | |
502 | + | else { | |
503 | + | let $t02174521855 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, 0) | |
504 | + | let wxPerLpIntegralNew = $t02174521855._1 | |
505 | + | let poolIntegralSTATE = $t02174521855._2 | |
506 | + | let poolDEBUG = $t02174521855._3 | |
507 | + | poolIntegralSTATE | |
508 | + | } | |
390 | 509 | ||
391 | 510 | ||
392 | 511 | @Verifier(tx) | |
393 | 512 | func verify () = { | |
394 | 513 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
395 | 514 | case pk: ByteVector => | |
396 | 515 | pk | |
397 | 516 | case _: Unit => | |
398 | 517 | tx.senderPublicKey | |
399 | 518 | case _ => | |
400 | 519 | throw("Match error") | |
401 | 520 | } | |
402 | 521 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
403 | 522 | } | |
404 | 523 |
github/deemru/w8io/169f3d6 75.30 ms ◑