tx · HLNGxu9TLaerUEpJcQtmogbk9NNM9ti9MR3q4pH2aa2A 3N1Epwa6GQuTQr2K9WzeUcqSFCdERwuvL5T: -0.02800000 Waves 2022.06.14 19:34 [2096298] smart account 3N1Epwa6GQuTQr2K9WzeUcqSFCdERwuvL5T > SELF 0.00000000 Waves
{ "type": 13, "id": "HLNGxu9TLaerUEpJcQtmogbk9NNM9ti9MR3q4pH2aa2A", "fee": 2800000, "feeAssetId": null, "timestamp": 1655224507770, "version": 1, "sender": "3N1Epwa6GQuTQr2K9WzeUcqSFCdERwuvL5T", "senderPublicKey": "7iXEgsFNsnbLZ3ca4tmz8jffnyxMu9keuBV6CuQPJLuA", "proofs": [ "pfBCom4PU6mMRApZT3zbzkp3JYziivjbpGuEGCzomyPLVBDPzyW6GXr6BkJH4528aUeYSGjbyMjeDB5cuV3NXDx" ], "script": "base64:AAIFAAAAAAAAADYIAhINCgsICAgICAgBCAEIARIECgIICBIFCgMICAQSBAoCCAgSAwoBARIECgIICBIDCgEIEgAAAAAgAAAAAAlzZXBhcmF0b3ICAAAAAl9fAAAAAAxrZXlGZWVBbW91bnQJAAS5AAAAAgkABEwAAAACAgAAAAIlcwkABEwAAAACAgAAAANmZWUFAAAAA25pbAUAAAAJc2VwYXJhdG9yAAAAAA5rZXlVc2RuQXNzZXRJZAkABLkAAAACCQAETAAAAAICAAAAAiVzCQAETAAAAAICAAAAC3VzZG5Bc3NldElkBQAAAANuaWwFAAAACXNlcGFyYXRvcgAAAAAOa2V5RXBvY2hMZW5ndGgJAAS5AAAAAgkABEwAAAACAgAAAAIlcwkABEwAAAACAgAAAAtlcG9jaExlbmd0aAUAAAADbmlsBQAAAAlzZXBhcmF0b3IAAAAAEWtleUZpbmFsaXplUmV3YXJkCQAEuQAAAAIJAARMAAAAAgIAAAACJXMJAARMAAAAAgIAAAAOZmluYWxpemVSZXdhcmQFAAAAA25pbAUAAAAJc2VwYXJhdG9yAAAAAAxrZXlXeEFzc2V0SWQJAAS5AAAAAgk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CQEAAAAaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAAAABQAAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAD3RhcmdldFB1YmxpY0tleQQAAAAHJG1hdGNoMAkBAAAAFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAJwawUAAAAHJG1hdGNoMAUAAAACcGsDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA90YXJnZXRQdWJsaWNLZXlleeBJ", "chainId": 84, "height": 2096298, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AWDnkZCp8uKMFFqTrCi2aaBWcdHFrCrbozUJjkekZen8 Next: 8gaRocQYr2GYogxYRLUVwJdYCQy12wjjgWee8HoUifki Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let separator = "__" | |
5 | 5 | ||
6 | - | let | |
6 | + | let keyFeeAmount = makeString(["%s", "fee"], separator) | |
7 | 7 | ||
8 | - | let | |
8 | + | let keyUsdnAssetId = makeString(["%s", "usdnAssetId"], separator) | |
9 | 9 | ||
10 | - | let | |
10 | + | let keyEpochLength = makeString(["%s", "epochLength"], separator) | |
11 | 11 | ||
12 | - | let | |
12 | + | let keyFinalizeReward = makeString(["%s", "finalizeReward"], separator) | |
13 | 13 | ||
14 | - | let | |
14 | + | let keyWxAssetId = makeString(["%s", "wxAssetId"], separator) | |
15 | 15 | ||
16 | - | let | |
16 | + | let keyAssetsStoreContract = makeString(["%s", "assetsStoreContract"], separator) | |
17 | 17 | ||
18 | - | let | |
18 | + | let keyUserPoolContract = makeString(["%s", "userPoolContract"], separator) | |
19 | 19 | ||
20 | - | func asAnyList (val) = match val { | |
21 | - | case valAnyLyst: List[Any] => | |
22 | - | valAnyLyst | |
23 | - | case _ => | |
24 | - | throw("fail to cast into List[Any]") | |
25 | - | } | |
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")) | |
26 | 29 | ||
27 | 30 | ||
28 | - | func asInt (val) = match val { | |
29 | - | case valInt: Int => | |
30 | - | valInt | |
31 | - | case _ => | |
32 | - | throw("fail to cast into Int") | |
33 | - | } | |
31 | + | func keyInListAssetId (amountAssetId,priceAssetId) = makeString(["%s%s%s", "inList", amountAssetId, priceAssetId], separator) | |
34 | 32 | ||
35 | 33 | ||
36 | - | func asString (val) = match val { | |
37 | - | case valStr: String => | |
38 | - | valStr | |
39 | - | case _ => | |
40 | - | throw("fail to cast into Int") | |
41 | - | } | |
34 | + | func keySuggestIndex (amountAssetId,priceAssetId) = makeString(["%s%s%s", "suggestIndex", amountAssetId, priceAssetId], separator) | |
42 | 35 | ||
43 | 36 | ||
44 | - | func asByteVector (val) = match val { | |
45 | - | case valBin: ByteVector => | |
46 | - | valBin | |
47 | - | case _ => | |
48 | - | throw("fail to cast into Int") | |
49 | - | } | |
37 | + | func keyStartHeight (amountAssetId,priceAssetId,suggestIndex) = makeString(["%s%s%s%d", "startHeight", amountAssetId, priceAssetId, toString(suggestIndex)], separator) | |
50 | 38 | ||
51 | 39 | ||
52 | - | func | |
40 | + | func keyVotingResult (amountAssetId,priceAssetId,suggestIndex) = makeString(["%s%s%s%d", "votingResult", amountAssetId, priceAssetId, toString(suggestIndex)], separator) | |
53 | 41 | ||
54 | 42 | ||
55 | - | func | |
43 | + | func totalVotes (totalYes,totalNo) = makeString(["%d%d", totalYes, totalNo], separator) | |
56 | 44 | ||
57 | 45 | ||
58 | - | func | |
46 | + | func keyVote (amountAssetId,priceAssetId,suggestIndex,voterAddress) = makeString(["%s%s%s%d%s", "vote", amountAssetId, priceAssetId, toString(suggestIndex), voterAddress], separator) | |
59 | 47 | ||
60 | 48 | ||
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" | |
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 | + | } | |
91 | 55 | ||
92 | 56 | ||
93 | 57 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
96 | 60 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
97 | 61 | ||
98 | 62 | ||
99 | - | ||
63 | + | let assetsStoreContract = addressFromStringValue(getStringOrFail(keyAssetsStoreContract)) | |
100 | 64 | ||
65 | + | let boostingContract = addressFromStringValue(getStringOrFail(keyBoostingContract)) | |
101 | 66 | ||
102 | - | ||
67 | + | let emissionContract = addressFromStringValue(getStringOrFail(keyEmissionContract)) | |
103 | 68 | ||
69 | + | let factoryContract = addressFromStringValue(getStringOrFail(keyFactoryContract)) | |
104 | 70 | ||
105 | - | ||
71 | + | let userPoolContract = addressFromStringValue(getStringOrFail(keyUserPoolContract)) | |
106 | 72 | ||
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 | - | ||
73 | + | let votingEmissionContract = addressFromStringValue(getStringOrFail(keyVotingEmissionContract)) | |
291 | 74 | ||
292 | 75 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
293 | 76 | case s: String => | |
310 | 93 | ||
311 | 94 | ||
312 | 95 | func mustManager (i) = { | |
313 | - | let pd = throw(" | |
96 | + | let pd = throw("permission denied") | |
314 | 97 | match managerPublicKeyOrUnit() { | |
315 | 98 | case pk: ByteVector => | |
316 | 99 | if ((i.callerPublicKey == pk)) | |
326 | 109 | } | |
327 | 110 | ||
328 | 111 | ||
112 | + | func asInt (val) = match val { | |
113 | + | case valInt: Int => | |
114 | + | valInt | |
115 | + | case _ => | |
116 | + | throw("failed to cast into Integer") | |
117 | + | } | |
118 | + | ||
119 | + | ||
329 | 120 | @Callable(i) | |
330 | - | func constructor (factoryAddressStr) = { | |
331 | - | let checkCaller = mustManager(i) | |
332 | - | if ((checkCaller == checkCaller)) | |
333 | - | then [StringEntry(keyFactoryAddress(), factoryAddressStr)] | |
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 $Tuple2([DeleteEntry(keyInListAssetId(amountAssetId, priceAssetId))], unit) | |
343 | + | else throw("Strict value is not equal to itself.") | |
344 | + | } | |
345 | + | else $Tuple2([DeleteEntry(keyInListAssetId(amountAssetId, priceAssetId))], unit) | |
346 | + | actions | |
347 | + | } | |
334 | 348 | else throw("Strict value is not equal to itself.") | |
335 | 349 | } | |
336 | 350 | ||
356 | 370 | let pm = pendingManagerPublicKeyOrUnit() | |
357 | 371 | let hasPM = if (isDefined(pm)) | |
358 | 372 | then true | |
359 | - | else throw(" | |
373 | + | else throw("no pending manager") | |
360 | 374 | if ((hasPM == hasPM)) | |
361 | 375 | then { | |
362 | 376 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
363 | 377 | then true | |
364 | - | else throw(" | |
378 | + | else throw("you are not pending manager") | |
365 | 379 | if ((checkPM == checkPM)) | |
366 | 380 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
367 | 381 | else throw("Strict value is not equal to itself.") | |
368 | 382 | } | |
369 | 383 | else throw("Strict value is not equal to itself.") | |
370 | 384 | } | |
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 | - | } | |
509 | 385 | ||
510 | 386 | ||
511 | 387 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let separator = "__" | |
5 | 5 | ||
6 | - | let | |
6 | + | let keyFeeAmount = makeString(["%s", "fee"], separator) | |
7 | 7 | ||
8 | - | let | |
8 | + | let keyUsdnAssetId = makeString(["%s", "usdnAssetId"], separator) | |
9 | 9 | ||
10 | - | let | |
10 | + | let keyEpochLength = makeString(["%s", "epochLength"], separator) | |
11 | 11 | ||
12 | - | let | |
12 | + | let keyFinalizeReward = makeString(["%s", "finalizeReward"], separator) | |
13 | 13 | ||
14 | - | let | |
14 | + | let keyWxAssetId = makeString(["%s", "wxAssetId"], separator) | |
15 | 15 | ||
16 | - | let | |
16 | + | let keyAssetsStoreContract = makeString(["%s", "assetsStoreContract"], separator) | |
17 | 17 | ||
18 | - | let | |
18 | + | let keyUserPoolContract = makeString(["%s", "userPoolContract"], separator) | |
19 | 19 | ||
20 | - | func asAnyList (val) = match val { | |
21 | - | case valAnyLyst: List[Any] => | |
22 | - | valAnyLyst | |
23 | - | case _ => | |
24 | - | throw("fail to cast into List[Any]") | |
25 | - | } | |
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")) | |
26 | 29 | ||
27 | 30 | ||
28 | - | func asInt (val) = match val { | |
29 | - | case valInt: Int => | |
30 | - | valInt | |
31 | - | case _ => | |
32 | - | throw("fail to cast into Int") | |
33 | - | } | |
31 | + | func keyInListAssetId (amountAssetId,priceAssetId) = makeString(["%s%s%s", "inList", amountAssetId, priceAssetId], separator) | |
34 | 32 | ||
35 | 33 | ||
36 | - | func asString (val) = match val { | |
37 | - | case valStr: String => | |
38 | - | valStr | |
39 | - | case _ => | |
40 | - | throw("fail to cast into Int") | |
41 | - | } | |
34 | + | func keySuggestIndex (amountAssetId,priceAssetId) = makeString(["%s%s%s", "suggestIndex", amountAssetId, priceAssetId], separator) | |
42 | 35 | ||
43 | 36 | ||
44 | - | func asByteVector (val) = match val { | |
45 | - | case valBin: ByteVector => | |
46 | - | valBin | |
47 | - | case _ => | |
48 | - | throw("fail to cast into Int") | |
49 | - | } | |
37 | + | func keyStartHeight (amountAssetId,priceAssetId,suggestIndex) = makeString(["%s%s%s%d", "startHeight", amountAssetId, priceAssetId, toString(suggestIndex)], separator) | |
50 | 38 | ||
51 | 39 | ||
52 | - | func | |
40 | + | func keyVotingResult (amountAssetId,priceAssetId,suggestIndex) = makeString(["%s%s%s%d", "votingResult", amountAssetId, priceAssetId, toString(suggestIndex)], separator) | |
53 | 41 | ||
54 | 42 | ||
55 | - | func | |
43 | + | func totalVotes (totalYes,totalNo) = makeString(["%d%d", totalYes, totalNo], separator) | |
56 | 44 | ||
57 | 45 | ||
58 | - | func | |
46 | + | func keyVote (amountAssetId,priceAssetId,suggestIndex,voterAddress) = makeString(["%s%s%s%d%s", "vote", amountAssetId, priceAssetId, toString(suggestIndex), voterAddress], separator) | |
59 | 47 | ||
60 | 48 | ||
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" | |
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 | + | } | |
91 | 55 | ||
92 | 56 | ||
93 | 57 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
94 | 58 | ||
95 | 59 | ||
96 | 60 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
97 | 61 | ||
98 | 62 | ||
99 | - | ||
63 | + | let assetsStoreContract = addressFromStringValue(getStringOrFail(keyAssetsStoreContract)) | |
100 | 64 | ||
65 | + | let boostingContract = addressFromStringValue(getStringOrFail(keyBoostingContract)) | |
101 | 66 | ||
102 | - | ||
67 | + | let emissionContract = addressFromStringValue(getStringOrFail(keyEmissionContract)) | |
103 | 68 | ||
69 | + | let factoryContract = addressFromStringValue(getStringOrFail(keyFactoryContract)) | |
104 | 70 | ||
105 | - | ||
71 | + | let userPoolContract = addressFromStringValue(getStringOrFail(keyUserPoolContract)) | |
106 | 72 | ||
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 | - | ||
73 | + | let votingEmissionContract = addressFromStringValue(getStringOrFail(keyVotingEmissionContract)) | |
291 | 74 | ||
292 | 75 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
293 | 76 | case s: String => | |
294 | 77 | fromBase58String(s) | |
295 | 78 | case _: Unit => | |
296 | 79 | unit | |
297 | 80 | case _ => | |
298 | 81 | throw("Match error") | |
299 | 82 | } | |
300 | 83 | ||
301 | 84 | ||
302 | 85 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
303 | 86 | case s: String => | |
304 | 87 | fromBase58String(s) | |
305 | 88 | case _: Unit => | |
306 | 89 | unit | |
307 | 90 | case _ => | |
308 | 91 | throw("Match error") | |
309 | 92 | } | |
310 | 93 | ||
311 | 94 | ||
312 | 95 | func mustManager (i) = { | |
313 | - | let pd = throw(" | |
96 | + | let pd = throw("permission denied") | |
314 | 97 | match managerPublicKeyOrUnit() { | |
315 | 98 | case pk: ByteVector => | |
316 | 99 | if ((i.callerPublicKey == pk)) | |
317 | 100 | then true | |
318 | 101 | else pd | |
319 | 102 | case _: Unit => | |
320 | 103 | if ((i.caller == this)) | |
321 | 104 | then true | |
322 | 105 | else pd | |
323 | 106 | case _ => | |
324 | 107 | throw("Match error") | |
325 | 108 | } | |
326 | 109 | } | |
327 | 110 | ||
328 | 111 | ||
112 | + | func asInt (val) = match val { | |
113 | + | case valInt: Int => | |
114 | + | valInt | |
115 | + | case _ => | |
116 | + | throw("failed to cast into Integer") | |
117 | + | } | |
118 | + | ||
119 | + | ||
329 | 120 | @Callable(i) | |
330 | - | func constructor (factoryAddressStr) = { | |
331 | - | let checkCaller = mustManager(i) | |
332 | - | if ((checkCaller == checkCaller)) | |
333 | - | then [StringEntry(keyFactoryAddress(), factoryAddressStr)] | |
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 $Tuple2([DeleteEntry(keyInListAssetId(amountAssetId, priceAssetId))], unit) | |
343 | + | else throw("Strict value is not equal to itself.") | |
344 | + | } | |
345 | + | else $Tuple2([DeleteEntry(keyInListAssetId(amountAssetId, priceAssetId))], unit) | |
346 | + | actions | |
347 | + | } | |
334 | 348 | else throw("Strict value is not equal to itself.") | |
335 | 349 | } | |
336 | 350 | ||
337 | 351 | ||
338 | 352 | ||
339 | 353 | @Callable(i) | |
340 | 354 | func setManager (pendingManagerPublicKey) = { | |
341 | 355 | let checkCaller = mustManager(i) | |
342 | 356 | if ((checkCaller == checkCaller)) | |
343 | 357 | then { | |
344 | 358 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
345 | 359 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
346 | 360 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
347 | 361 | else throw("Strict value is not equal to itself.") | |
348 | 362 | } | |
349 | 363 | else throw("Strict value is not equal to itself.") | |
350 | 364 | } | |
351 | 365 | ||
352 | 366 | ||
353 | 367 | ||
354 | 368 | @Callable(i) | |
355 | 369 | func confirmManager () = { | |
356 | 370 | let pm = pendingManagerPublicKeyOrUnit() | |
357 | 371 | let hasPM = if (isDefined(pm)) | |
358 | 372 | then true | |
359 | - | else throw(" | |
373 | + | else throw("no pending manager") | |
360 | 374 | if ((hasPM == hasPM)) | |
361 | 375 | then { | |
362 | 376 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
363 | 377 | then true | |
364 | - | else throw(" | |
378 | + | else throw("you are not pending manager") | |
365 | 379 | if ((checkPM == checkPM)) | |
366 | 380 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
367 | 381 | else throw("Strict value is not equal to itself.") | |
368 | 382 | } | |
369 | 383 | else throw("Strict value is not equal to itself.") | |
370 | 384 | } | |
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 | - | } | |
509 | 385 | ||
510 | 386 | ||
511 | 387 | @Verifier(tx) | |
512 | 388 | func verify () = { | |
513 | 389 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
514 | 390 | case pk: ByteVector => | |
515 | 391 | pk | |
516 | 392 | case _: Unit => | |
517 | 393 | tx.senderPublicKey | |
518 | 394 | case _ => | |
519 | 395 | throw("Match error") | |
520 | 396 | } | |
521 | 397 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
522 | 398 | } | |
523 | 399 |
github/deemru/w8io/169f3d6 73.53 ms ◑