tx · 5NChLH48U9yoomh6XV6XoE15GrHXjDydyGTeMn4QLBYR 3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz: -0.03500000 Waves 2022.06.08 16:48 [2087469] smart account 3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz > SELF 0.00000000 Waves
{ "type": 13, "id": "5NChLH48U9yoomh6XV6XoE15GrHXjDydyGTeMn4QLBYR", "fee": 3500000, "feeAssetId": null, "timestamp": 1654696121777, "version": 1, "sender": "3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz", "senderPublicKey": "D28XoueZWsMfm8Y5pa6C5ZFuYoWgre2Wm8tzJANJgMnq", "proofs": [ "53kNL3BYjKZxvaxNkB7oezgTHw6MUouZNCnqMMZPNVHNQFFoKM6HZeSmWZ8AQquj3AL8hcQsuS4ADnu2NYor3oAn" ], "script": "base64:AAIFAAAAAAAAACcIAhIDCgEIEgMKAQgSABIDCgEYEggKBgEBAQEIARIDCgEIEgMKAQgAAAAhAAAAAANTRVACAAAAAl9fAAAAAAVFTVBUWQIAAAAAAAAAAA5pZHhQb29sQWRkcmVzcwAAAAAAAAAAAQAAAAAJaWR4TFBBc0lkAAAAAAAAAAADAAAAAAlpZHhBbUFzSWQAAAAAAAAAAAQAAAAACWlkeFByQXNJZAAAAAAAAAAABQAAAAAPaWR4RmFjdFN0YWtDbnRyAAAAAAAAAAABAAAAAAVkZWxheQIAAAAJJXNfX2RlbGF5AQAAAAtrZXlGYWN0Q250cgAAAAACAAAAEyVzX19mYWN0b3J5Q29udHJhY3QBAAAAE2tleU1hbmFnZXJQdWJsaWNLZXkAAAAAAgAAABQlc19fbWFuYWdlclB1YmxpY0tleQEAAAAaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAAAAAgAAABslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBAAAAC2tleVBvb2xBZGRyAAAAAAIAAAAPJXNfX3Bvb2xBZGRyZXNzAQAAAAtrZXlBbXRB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eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAAPdGFyZ2V0UHVibGljS2V5pyjxuQ==", "chainId": 84, "height": 2087469, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8uMk9gcyqxTjm1s5RQa5WmmZnXwcQo1h8TbrHR3552Cc Next: AFS1mCWzWcF6e2753EkEzzhWHyvU1GVBGgf4WXFpQfxF Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let SCALE8 = 8 | |
5 | - | ||
6 | - | let MULT8 = 100000000 | |
7 | - | ||
8 | - | let SCALE18 = 18 | |
9 | - | ||
10 | - | let MULT18 = toBigInt(1000000000000000000) | |
11 | - | ||
12 | 4 | let SEP = "__" | |
13 | 5 | ||
14 | - | let | |
6 | + | let EMPTY = "" | |
15 | 7 | ||
16 | - | func asAnyList (val) = match val { | |
17 | - | case valAnyLyst: List[Any] => | |
18 | - | valAnyLyst | |
19 | - | case _ => | |
20 | - | throw("fail to cast into List[Any]") | |
21 | - | } | |
8 | + | let idxPoolAddress = 1 | |
22 | 9 | ||
10 | + | let idxLPAsId = 3 | |
23 | 11 | ||
24 | - | func asInt (val) = match val { | |
25 | - | case valInt: Int => | |
26 | - | valInt | |
27 | - | case _ => | |
28 | - | throw("fail to cast into Int") | |
29 | - | } | |
12 | + | let idxAmAsId = 4 | |
30 | 13 | ||
14 | + | let idxPrAsId = 5 | |
31 | 15 | ||
32 | - | func asString (val) = match val { | |
33 | - | case valStr: String => | |
34 | - | valStr | |
35 | - | case _ => | |
36 | - | throw("fail to cast into Int") | |
37 | - | } | |
16 | + | let idxFactStakCntr = 1 | |
38 | 17 | ||
18 | + | let delay = "%s__delay" | |
39 | 19 | ||
40 | - | func asByteVector (val) = match val { | |
41 | - | case valBin: ByteVector => | |
42 | - | valBin | |
43 | - | case _ => | |
44 | - | throw("fail to cast into Int") | |
45 | - | } | |
46 | - | ||
47 | - | ||
48 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
49 | - | ||
50 | - | ||
51 | - | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
52 | - | ||
53 | - | ||
54 | - | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
55 | - | ||
56 | - | ||
57 | - | func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
58 | - | ||
59 | - | ||
60 | - | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) | |
61 | - | ||
62 | - | ||
63 | - | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), MULT18, toBigInt(origScaleMult)) | |
64 | - | ||
65 | - | ||
66 | - | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), MULT18)) | |
67 | - | ||
68 | - | ||
69 | - | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
70 | - | ||
71 | - | ||
72 | - | let IdxFactoryCfgStakingDapp = 1 | |
73 | - | ||
74 | - | let IdxFactoryCfgBoostingDapp = 2 | |
75 | - | ||
76 | - | let IdxFactoryCfgIdoDapp = 3 | |
77 | - | ||
78 | - | let IdxFactoryCfgTeamDapp = 4 | |
79 | - | ||
80 | - | let IdxFactoryCfgEmissionDapp = 5 | |
81 | - | ||
82 | - | let IdxFactoryCfgRestDapp = 6 | |
83 | - | ||
84 | - | let IdxFactoryCfgSlippageDapp = 7 | |
85 | - | ||
86 | - | func keyFactoryCfg () = "%s__factoryConfig" | |
20 | + | func keyFactCntr () = "%s__factoryContract" | |
87 | 21 | ||
88 | 22 | ||
89 | 23 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
92 | 26 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
93 | 27 | ||
94 | 28 | ||
95 | - | func | |
29 | + | func keyPoolAddr () = "%s__poolAddress" | |
96 | 30 | ||
97 | 31 | ||
98 | - | func | |
32 | + | func keyAmtAsset () = "%s__amountAsset" | |
99 | 33 | ||
100 | 34 | ||
101 | - | func | |
35 | + | func keyPriceAsset () = "%s__priceAsset" | |
102 | 36 | ||
103 | 37 | ||
104 | - | func | |
38 | + | func keyAdminPubKeys () = "%s__adminPubKeys" | |
105 | 39 | ||
106 | 40 | ||
107 | - | func | |
41 | + | func keyAmp () = "%s__amp" | |
108 | 42 | ||
109 | 43 | ||
110 | - | func | |
44 | + | func keyAmpHistory (height) = ("%s%d__amp__" + toString(height)) | |
111 | 45 | ||
112 | 46 | ||
113 | - | func | |
47 | + | func lastGetOrPutOneTknCall (caller) = makeString(["%s%s__lastGetOrPutOneTknCall", caller], SEP) | |
114 | 48 | ||
115 | 49 | ||
116 | - | func | |
50 | + | func keyFactoryConfig () = "%s__factoryConfig" | |
117 | 51 | ||
118 | 52 | ||
119 | - | func | |
53 | + | func keyPoolConfig (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
120 | 54 | ||
121 | 55 | ||
122 | - | func | |
56 | + | func keyMappingsBaseAsset2internalId (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
123 | 57 | ||
124 | 58 | ||
125 | - | func | |
59 | + | func getStringOrFail (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
126 | 60 | ||
127 | 61 | ||
128 | - | func | |
62 | + | func getIntOrFail (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
129 | 63 | ||
130 | 64 | ||
131 | - | ||
65 | + | let poolContract = addressFromStringValue(getStringOrFail(this, keyPoolAddr())) | |
132 | 66 | ||
67 | + | let factoryContract = addressFromStringValue(getStringOrFail(poolContract, keyFactCntr())) | |
133 | 68 | ||
134 | - | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
135 | - | ||
136 | - | ||
137 | - | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
138 | - | ||
139 | - | ||
140 | - | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
141 | - | ||
142 | - | ||
143 | - | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
144 | - | ||
145 | - | ||
146 | - | func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) | |
147 | - | ||
148 | - | ||
149 | - | func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP) | |
150 | - | ||
151 | - | ||
152 | - | func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP) | |
153 | - | ||
154 | - | ||
155 | - | func keyClaimedTotal (lpAssetIdStr) = makeString(["%s%s%s__claimed", "total", lpAssetIdStr], SEP) | |
156 | - | ||
157 | - | ||
158 | - | func readStaked (key) = valueOrElse(getInteger(this, key), 0) | |
159 | - | ||
160 | - | ||
161 | - | func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP) | |
162 | - | ||
163 | - | ||
164 | - | func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP) | |
165 | - | ||
166 | - | ||
167 | - | func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP) | |
168 | - | ||
169 | - | ||
170 | - | func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP) | |
171 | - | ||
172 | - | ||
173 | - | func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP) | |
174 | - | ||
175 | - | ||
176 | - | func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP) | |
177 | - | ||
178 | - | ||
179 | - | func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP) | |
180 | - | ||
181 | - | ||
182 | - | func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP) | |
183 | - | ||
184 | - | ||
185 | - | func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP) | |
186 | - | ||
187 | - | ||
188 | - | func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP) | |
189 | - | ||
190 | - | ||
191 | - | func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP) | |
192 | - | ||
193 | - | ||
194 | - | func keyWxPerLpX18 (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLpX18"], SEP) | |
195 | - | ||
196 | - | ||
197 | - | func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP) | |
198 | - | ||
199 | - | ||
200 | - | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
201 | - | ||
202 | - | ||
203 | - | func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
204 | - | ||
205 | - | ||
206 | - | func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount)) | |
207 | - | ||
208 | - | ||
209 | - | let factoryAddress = getStringOrFail(keyFactoryAddress()) | |
210 | - | ||
211 | - | let factoryContract = addressFromStringValue(factoryAddress) | |
212 | - | ||
213 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
214 | - | ||
215 | - | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
216 | - | ||
217 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
218 | - | ||
219 | - | func calcWxPerLpIntegralUserLast (stakedByUser,wxPerLpIntegralUserLastUpdHeightOrZero,wxPerLpIntegralNew,wxPerLpIntegralUserLastKEY) = if (if ((wxPerLpIntegralUserLastUpdHeightOrZero == toBigInt(0))) | |
220 | - | then (stakedByUser > toBigInt(0)) | |
221 | - | else false) | |
222 | - | then toBigInt(0) | |
223 | - | else if ((stakedByUser == toBigInt(0))) | |
224 | - | then wxPerLpIntegralNew | |
225 | - | else if (if ((wxPerLpIntegralUserLastUpdHeightOrZero > toBigInt(0))) | |
226 | - | then (stakedByUser > toBigInt(0)) | |
227 | - | else false) | |
228 | - | then toBigInt(getIntOrFail(this, wxPerLpIntegralUserLastKEY)) | |
229 | - | else throw("calcWxPerLpIntegralUserLast: unexpected state") | |
230 | - | ||
231 | - | ||
232 | - | func refreshPoolINTEGRALS (lpAssetIdStr,poolAddressStr,lpDeltaAmount) = { | |
233 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
234 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
235 | - | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
236 | - | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
237 | - | let MULT3 = 1000 | |
238 | - | let wxEmissionPerBlockX3 = (getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) * MULT3) | |
239 | - | let poolWxEmissionPerBlockX3 = fraction(wxEmissionPerBlockX3, poolWeight, (POOLWEIGHTMULT * 3)) | |
240 | - | let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr) | |
241 | - | let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr) | |
242 | - | let wxPerLpKEY = keyWxPerLp(lpAssetIdStr) | |
243 | - | let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock) | |
244 | - | let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY) | |
245 | - | let wxPerLpOrZeroX3 = 0 | |
246 | - | let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0]) | |
247 | - | let wxPerLpX3 = if ((wxPerLpOrZeroX3 != 0)) | |
248 | - | then wxPerLpOrZeroX3 | |
249 | - | else fraction(poolWxEmissionPerBlockX3, MULT8, stakedTotal) | |
250 | - | let stakedTotalNew = (stakedTotal + lpDeltaAmount) | |
251 | - | let wxPerLpIntegralNew = (toBigInt(wxPerLpIntegral) + (toBigInt(wxPerLpX3) * toBigInt(dh))) | |
252 | - | let wxPerLpX3New = (poolWxEmissionPerBlockX3 / stakedTotalNew) | |
253 | - | let wxPerLpIntegralLastUpdHeightNew = height | |
254 | - | let debug = makeString([toString(wxPerLpIntegralNew), toString(dh), toString(wxPerLpX3), toString(stakedTotal), toString(poolWxEmissionPerBlockX3), toString(wxEmissionPerBlockX3), toString(poolWeight)], "::") | |
255 | - | $Tuple3(wxPerLpIntegralNew, [StringEntry(wxPerLpIntegralKEY, toString(wxPerLpIntegralNew)), IntegerEntry(wxPerLpIntegralLastUpdHeightKEY, wxPerLpIntegralLastUpdHeightNew), IntegerEntry(wxPerLpKEY, wxPerLpX3New)], debug) | |
69 | + | func getPoolConfig () = { | |
70 | + | let amtAs = getStringOrFail(poolContract, keyAmtAsset()) | |
71 | + | let priceAs = getStringOrFail(poolContract, keyPriceAsset()) | |
72 | + | let iPriceAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAs)) | |
73 | + | let iAmtAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAs)) | |
74 | + | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAs), toString(iPriceAs))), SEP) | |
256 | 75 | } | |
257 | 76 | ||
258 | 77 | ||
259 | - | func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = { | |
260 | - | let $t01110811230 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, lpDeltaAmount) | |
261 | - | let wxPerLpIntegralNew = $t01110811230._1 | |
262 | - | let poolIntegralSTATE = $t01110811230._2 | |
263 | - | let poolDEBUG = $t01110811230._3 | |
264 | - | let MULT3 = 1000 | |
265 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
266 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
267 | - | let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr) | |
268 | - | let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr) | |
269 | - | let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr) | |
270 | - | let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY) | |
271 | - | let wxPerLpIntegralUserLastUpdHeightOrZero = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY) | |
272 | - | let wxPerLpIntegralUserLast = calcWxPerLpIntegralUserLast(toBigInt(stakedByUser), toBigInt(wxPerLpIntegralUserLastUpdHeightOrZero), wxPerLpIntegralNew, wxPerLpIntegralUserLastKEY) | |
273 | - | let MULT11 = (MULT8 * MULT3) | |
274 | - | let wxToClaimUserNew = (toBigInt(wxToClaimUser) + fraction((wxPerLpIntegralNew - wxPerLpIntegralUserLast), toBigInt(stakedByUser), toBigInt(MULT11))) | |
275 | - | let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew | |
276 | - | let wxPerLpIntegralUserLastUpdHeightNew = height | |
277 | - | let debug = makeString([toString(wxToClaimUserNew), toString(wxPerLpIntegralUserLast), toString(stakedByUser), poolDEBUG, toString(height)], "::") | |
278 | - | $Tuple3(wxToClaimUserNew, (poolIntegralSTATE ++ [StringEntry(wxToClaimUserKEY, toString(wxToClaimUserNew)), IntegerEntry(wxPerLpIntegralUserLastUpdHeightKEY, wxPerLpIntegralUserLastUpdHeightNew), StringEntry(wxPerLpIntegralUserLastKEY, toString(wxPerLpIntegralUserLastNew))]), debug) | |
279 | - | } | |
78 | + | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
280 | 79 | ||
281 | 80 | ||
282 | 81 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
316 | 115 | } | |
317 | 116 | ||
318 | 117 | ||
118 | + | func getAdmins () = match getString(keyAdminPubKeys()) { | |
119 | + | case s: String => | |
120 | + | if ((size(s) == 0)) | |
121 | + | then nil | |
122 | + | else split(s, SEP) | |
123 | + | case _ => | |
124 | + | nil | |
125 | + | } | |
126 | + | ||
127 | + | ||
128 | + | func mustAdmin (i) = if (containsElement(getAdmins(), toBase58String(i.callerPublicKey))) | |
129 | + | then true | |
130 | + | else mustManager(i) | |
131 | + | ||
132 | + | ||
133 | + | func mustPool (i) = if ((i.caller == poolContract)) | |
134 | + | then true | |
135 | + | else throw("caller must be the pool") | |
136 | + | ||
137 | + | ||
319 | 138 | @Callable(i) | |
320 | - | func constructor ( | |
139 | + | func constructor (poolAddress) = { | |
321 | 140 | let checkCaller = mustManager(i) | |
322 | 141 | if ((checkCaller == checkCaller)) | |
323 | - | then [StringEntry( | |
142 | + | then [StringEntry(keyPoolAddr(), poolAddress)] | |
324 | 143 | else throw("Strict value is not equal to itself.") | |
325 | 144 | } | |
326 | 145 | ||
362 | 181 | ||
363 | 182 | ||
364 | 183 | @Callable(i) | |
365 | - | func stake () = if ((size(i.payments) != 1)) | |
366 | - | then throw("invalid payment - exact one payment must be attached") | |
367 | - | else { | |
368 | - | let pmt = i.payments[0] | |
369 | - | let lpAssetId = value(pmt.assetId) | |
370 | - | let lpAssetIdStr = toBase58String(lpAssetId) | |
371 | - | let amount = pmt.amount | |
372 | - | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
373 | - | let callerStr = toString(i.caller) | |
374 | - | let userAddressStr = if ((callerStr == poolAddressStr)) | |
375 | - | then toString(i.originCaller) | |
376 | - | else callerStr | |
377 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
378 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
379 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
380 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
381 | - | let $t01522115338 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount) | |
382 | - | let wxToClaimUserNew = $t01522115338._1 | |
383 | - | let integralSTATE = $t01522115338._2 | |
384 | - | let debug = $t01522115338._3 | |
385 | - | ([IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
386 | - | } | |
387 | - | ||
388 | - | ||
389 | - | ||
390 | - | @Callable(i) | |
391 | - | func unstake (lpAssetIdStr,amount) = { | |
392 | - | let lpAssetId = fromBase58String(lpAssetIdStr) | |
393 | - | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
394 | - | let poolAddon = valueOrElse(getString(this, keyStablePoolAddonAddr()), poolAddressStr) | |
395 | - | let callerStr = toString(i.caller) | |
396 | - | let userAddressStr = if (if ((callerStr == poolAddressStr)) | |
397 | - | then true | |
398 | - | else (callerStr == poolAddon)) | |
399 | - | then toString(i.originCaller) | |
400 | - | else callerStr | |
401 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
402 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
403 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
404 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
405 | - | let $t01647516593 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount)) | |
406 | - | let wxToClaimUserNew = $t01647516593._1 | |
407 | - | let integralSTATE = $t01647516593._2 | |
408 | - | let debug = $t01647516593._3 | |
409 | - | if ((amount > stakedByUser)) | |
410 | - | then throw("passed amount is less then available") | |
411 | - | else ([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
184 | + | func setAdmins (adminPubKeys) = { | |
185 | + | let checkCaller = mustManager(i) | |
186 | + | if ((checkCaller == checkCaller)) | |
187 | + | then [StringEntry(keyAdminPubKeys(), makeString(adminPubKeys, SEP))] | |
188 | + | else throw("Strict value is not equal to itself.") | |
412 | 189 | } | |
413 | 190 | ||
414 | 191 | ||
415 | 192 | ||
416 | 193 | @Callable(i) | |
417 | - | func claimWx (lpAssetIdStr) = { | |
418 | - | let userAddress = i.caller | |
419 | - | let userAddressStr = toString(i.caller) | |
420 | - | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
421 | - | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
422 | - | let claimedTotalKEY = keyClaimedTotal(lpAssetIdStr) | |
423 | - | let claimedByUserMinRewardKEY = keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr) | |
424 | - | let claimedByUserBoostRewardKEY = keyClaimedByUserBoostReward(lpAssetIdStr, userAddressStr) | |
425 | - | let claimedByUser = toBigInt(getIntOrZero(this, claimedByUserKEY)) | |
426 | - | let claimedByUserMinReward = toBigInt(getIntOrZero(this, claimedByUserMinRewardKEY)) | |
427 | - | let claimedByUserBoostReward = toBigInt(getIntOrZero(this, claimedByUserBoostRewardKEY)) | |
428 | - | let claimedTotal = toBigInt(getIntOrZero(this, claimedTotalKEY)) | |
429 | - | let $t01782917941 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
430 | - | let wxToClaimUserNew = $t01782917941._1 | |
431 | - | let integralSTATE = $t01782917941._2 | |
432 | - | let debug = $t01782917941._3 | |
433 | - | let availableToClaim = (wxToClaimUserNew - claimedByUser) | |
434 | - | if ((toBigInt(0) >= availableToClaim)) | |
435 | - | then throw("nothing to claim") | |
436 | - | else { | |
437 | - | let wxAmountBoostTotal = asInt(asAnyList(invoke(boostingContract, "claimWxBoost", [lpAssetIdStr, userAddressStr], nil))[0]) | |
438 | - | let minRewardPart = availableToClaim | |
439 | - | let boostRewardPart = min([(minRewardPart * toBigInt(2)), toBigInt(wxAmountBoostTotal)]) | |
440 | - | let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [minRewardPart], nil))[0]) | |
441 | - | let emitBoost = asAnyList(invoke(emissionContract, "emit", [boostRewardPart], nil)) | |
442 | - | if ((emitBoost == emitBoost)) | |
194 | + | func unstakeAndGetOneTkn (amount,exchResult,notUsed,outAmount,outAssetId,slippage) = { | |
195 | + | let checkPayments = if ((size(i.payments) != 0)) | |
196 | + | then throw("No pmnts expd") | |
197 | + | else true | |
198 | + | if ((checkPayments == checkPayments)) | |
199 | + | then { | |
200 | + | let cfg = getPoolConfig() | |
201 | + | let factoryCfg = getFactoryConfig() | |
202 | + | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
203 | + | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
204 | + | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
205 | + | if ((unstakeInv == unstakeInv)) | |
443 | 206 | then { | |
444 | - | let claimedByUserValue = (claimedByUser + availableToClaim) | |
445 | - | let claimedByUserMinRewardPlusPart = (claimedByUserMinReward + minRewardPart) | |
446 | - | let claimedByUserBoostRewardPlusBoostRewardPart = (claimedByUserMinReward + minRewardPart) | |
447 | - | let claimedTotalPlusAvailableToClaim = (claimedByUserMinReward + minRewardPart) | |
448 | - | [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)] | |
207 | + | let getOneTkn = reentrantInvoke(poolContract, "getOneTkn", [exchResult, notUsed, outAmount, outAssetId, slippage], [AttachedPayment(lpAssetId, amount)]) | |
208 | + | if ((getOneTkn == getOneTkn)) | |
209 | + | then nil | |
210 | + | else throw("Strict value is not equal to itself.") | |
449 | 211 | } | |
450 | 212 | else throw("Strict value is not equal to itself.") | |
451 | 213 | } | |
214 | + | else throw("Strict value is not equal to itself.") | |
452 | 215 | } | |
453 | 216 | ||
454 | 217 | ||
455 | 218 | ||
456 | 219 | @Callable(i) | |
457 | - | func claimWxREADONLY (lpAssetIdStr,userAddressStr) = { | |
458 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
459 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
460 | - | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
461 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
462 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
463 | - | let claimedByUser = getIntOrZero(this, claimedByUserKEY) | |
464 | - | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
465 | - | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
466 | - | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
467 | - | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
468 | - | let passedBlocks = if ((emissionStartBlock > height)) | |
469 | - | then 0 | |
470 | - | else (height - emissionStartBlock) | |
471 | - | let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, POOLWEIGHTMULT) | |
472 | - | let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal) | |
473 | - | let $t02052820640 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
474 | - | let wxToClaimUserNew = $t02052820640._1 | |
475 | - | let integralSTATE = $t02052820640._2 | |
476 | - | let debug = $t02052820640._3 | |
477 | - | let availableToClaim = (wxToClaimUserNew - toBigInt(claimedByUser)) | |
478 | - | let boostInvResult = asAnyList(invoke(boostingContract, "claimWxBoostREADONLY", [lpAssetIdStr, userAddressStr], nil)) | |
479 | - | let wxAmountBoostTotal = asInt(boostInvResult[0]) | |
480 | - | let boostDebug = asString(boostInvResult[1]) | |
481 | - | let minRewardPart = availableToClaim | |
482 | - | let boostRewardPart = min([(minRewardPart * toBigInt(2)), toBigInt(wxAmountBoostTotal)]) | |
483 | - | let totalReward = (minRewardPart + boostRewardPart) | |
484 | - | $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)) | |
220 | + | func setAmp (amp) = { | |
221 | + | let checkCaller = mustAdmin(i) | |
222 | + | if ((checkCaller == checkCaller)) | |
223 | + | then { | |
224 | + | let res1 = invoke(poolContract, "setS", [keyAmp(), amp], nil) | |
225 | + | let res2 = invoke(poolContract, "setS", [keyAmpHistory(height), amp], nil) | |
226 | + | $Tuple2(nil, $Tuple2(res1, res2)) | |
227 | + | } | |
228 | + | else throw("Strict value is not equal to itself.") | |
485 | 229 | } | |
486 | 230 | ||
487 | 231 | ||
488 | 232 | ||
489 | 233 | @Callable(i) | |
490 | - | func onModifyWeight (lpAssetIdStr,poolAddressStr) = if ((i.caller != factoryContract)) | |
491 | - | then throw("permissions denied") | |
492 | - | else { | |
493 | - | let $t02155321663 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, 0) | |
494 | - | let wxPerLpIntegralNew = $t02155321663._1 | |
495 | - | let poolIntegralSTATE = $t02155321663._2 | |
496 | - | let poolDEBUG = $t02155321663._3 | |
497 | - | poolIntegralSTATE | |
498 | - | } | |
234 | + | func ensureCanGetOrPutOneTkn (caller) = { | |
235 | + | let checkCaller = mustPool(i) | |
236 | + | if ((checkCaller == checkCaller)) | |
237 | + | then { | |
238 | + | let ensureCanPut = match getInteger(poolContract, lastGetOrPutOneTknCall(caller)) { | |
239 | + | case int: Int => | |
240 | + | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
241 | + | let isReadyforPutOneTkn = (height >= permittedHeight) | |
242 | + | let needBlocks = (permittedHeight - height) | |
243 | + | if (isReadyforPutOneTkn) | |
244 | + | then true | |
245 | + | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
246 | + | case _ => | |
247 | + | true | |
248 | + | } | |
249 | + | if ((ensureCanPut == ensureCanPut)) | |
250 | + | then { | |
251 | + | let setI = invoke(poolContract, "setI", [lastGetOrPutOneTknCall(caller), height], nil) | |
252 | + | if ((setI == setI)) | |
253 | + | then nil | |
254 | + | else throw("Strict value is not equal to itself.") | |
255 | + | } | |
256 | + | else throw("Strict value is not equal to itself.") | |
257 | + | } | |
258 | + | else throw("Strict value is not equal to itself.") | |
259 | + | } | |
499 | 260 | ||
500 | 261 | ||
501 | 262 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let SCALE8 = 8 | |
5 | - | ||
6 | - | let MULT8 = 100000000 | |
7 | - | ||
8 | - | let SCALE18 = 18 | |
9 | - | ||
10 | - | let MULT18 = toBigInt(1000000000000000000) | |
11 | - | ||
12 | 4 | let SEP = "__" | |
13 | 5 | ||
14 | - | let | |
6 | + | let EMPTY = "" | |
15 | 7 | ||
16 | - | func asAnyList (val) = match val { | |
17 | - | case valAnyLyst: List[Any] => | |
18 | - | valAnyLyst | |
19 | - | case _ => | |
20 | - | throw("fail to cast into List[Any]") | |
21 | - | } | |
8 | + | let idxPoolAddress = 1 | |
22 | 9 | ||
10 | + | let idxLPAsId = 3 | |
23 | 11 | ||
24 | - | func asInt (val) = match val { | |
25 | - | case valInt: Int => | |
26 | - | valInt | |
27 | - | case _ => | |
28 | - | throw("fail to cast into Int") | |
29 | - | } | |
12 | + | let idxAmAsId = 4 | |
30 | 13 | ||
14 | + | let idxPrAsId = 5 | |
31 | 15 | ||
32 | - | func asString (val) = match val { | |
33 | - | case valStr: String => | |
34 | - | valStr | |
35 | - | case _ => | |
36 | - | throw("fail to cast into Int") | |
37 | - | } | |
16 | + | let idxFactStakCntr = 1 | |
38 | 17 | ||
18 | + | let delay = "%s__delay" | |
39 | 19 | ||
40 | - | func asByteVector (val) = match val { | |
41 | - | case valBin: ByteVector => | |
42 | - | valBin | |
43 | - | case _ => | |
44 | - | throw("fail to cast into Int") | |
45 | - | } | |
46 | - | ||
47 | - | ||
48 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
49 | - | ||
50 | - | ||
51 | - | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
52 | - | ||
53 | - | ||
54 | - | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
55 | - | ||
56 | - | ||
57 | - | func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
58 | - | ||
59 | - | ||
60 | - | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) | |
61 | - | ||
62 | - | ||
63 | - | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), MULT18, toBigInt(origScaleMult)) | |
64 | - | ||
65 | - | ||
66 | - | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), MULT18)) | |
67 | - | ||
68 | - | ||
69 | - | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
70 | - | ||
71 | - | ||
72 | - | let IdxFactoryCfgStakingDapp = 1 | |
73 | - | ||
74 | - | let IdxFactoryCfgBoostingDapp = 2 | |
75 | - | ||
76 | - | let IdxFactoryCfgIdoDapp = 3 | |
77 | - | ||
78 | - | let IdxFactoryCfgTeamDapp = 4 | |
79 | - | ||
80 | - | let IdxFactoryCfgEmissionDapp = 5 | |
81 | - | ||
82 | - | let IdxFactoryCfgRestDapp = 6 | |
83 | - | ||
84 | - | let IdxFactoryCfgSlippageDapp = 7 | |
85 | - | ||
86 | - | func keyFactoryCfg () = "%s__factoryConfig" | |
20 | + | func keyFactCntr () = "%s__factoryContract" | |
87 | 21 | ||
88 | 22 | ||
89 | 23 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
90 | 24 | ||
91 | 25 | ||
92 | 26 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
93 | 27 | ||
94 | 28 | ||
95 | - | func | |
29 | + | func keyPoolAddr () = "%s__poolAddress" | |
96 | 30 | ||
97 | 31 | ||
98 | - | func | |
32 | + | func keyAmtAsset () = "%s__amountAsset" | |
99 | 33 | ||
100 | 34 | ||
101 | - | func | |
35 | + | func keyPriceAsset () = "%s__priceAsset" | |
102 | 36 | ||
103 | 37 | ||
104 | - | func | |
38 | + | func keyAdminPubKeys () = "%s__adminPubKeys" | |
105 | 39 | ||
106 | 40 | ||
107 | - | func | |
41 | + | func keyAmp () = "%s__amp" | |
108 | 42 | ||
109 | 43 | ||
110 | - | func | |
44 | + | func keyAmpHistory (height) = ("%s%d__amp__" + toString(height)) | |
111 | 45 | ||
112 | 46 | ||
113 | - | func | |
47 | + | func lastGetOrPutOneTknCall (caller) = makeString(["%s%s__lastGetOrPutOneTknCall", caller], SEP) | |
114 | 48 | ||
115 | 49 | ||
116 | - | func | |
50 | + | func keyFactoryConfig () = "%s__factoryConfig" | |
117 | 51 | ||
118 | 52 | ||
119 | - | func | |
53 | + | func keyPoolConfig (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
120 | 54 | ||
121 | 55 | ||
122 | - | func | |
56 | + | func keyMappingsBaseAsset2internalId (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
123 | 57 | ||
124 | 58 | ||
125 | - | func | |
59 | + | func getStringOrFail (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
126 | 60 | ||
127 | 61 | ||
128 | - | func | |
62 | + | func getIntOrFail (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
129 | 63 | ||
130 | 64 | ||
131 | - | ||
65 | + | let poolContract = addressFromStringValue(getStringOrFail(this, keyPoolAddr())) | |
132 | 66 | ||
67 | + | let factoryContract = addressFromStringValue(getStringOrFail(poolContract, keyFactCntr())) | |
133 | 68 | ||
134 | - | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
135 | - | ||
136 | - | ||
137 | - | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
138 | - | ||
139 | - | ||
140 | - | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
141 | - | ||
142 | - | ||
143 | - | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
144 | - | ||
145 | - | ||
146 | - | func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) | |
147 | - | ||
148 | - | ||
149 | - | func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP) | |
150 | - | ||
151 | - | ||
152 | - | func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP) | |
153 | - | ||
154 | - | ||
155 | - | func keyClaimedTotal (lpAssetIdStr) = makeString(["%s%s%s__claimed", "total", lpAssetIdStr], SEP) | |
156 | - | ||
157 | - | ||
158 | - | func readStaked (key) = valueOrElse(getInteger(this, key), 0) | |
159 | - | ||
160 | - | ||
161 | - | func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP) | |
162 | - | ||
163 | - | ||
164 | - | func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP) | |
165 | - | ||
166 | - | ||
167 | - | func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP) | |
168 | - | ||
169 | - | ||
170 | - | func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP) | |
171 | - | ||
172 | - | ||
173 | - | func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP) | |
174 | - | ||
175 | - | ||
176 | - | func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP) | |
177 | - | ||
178 | - | ||
179 | - | func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP) | |
180 | - | ||
181 | - | ||
182 | - | func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP) | |
183 | - | ||
184 | - | ||
185 | - | func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP) | |
186 | - | ||
187 | - | ||
188 | - | func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP) | |
189 | - | ||
190 | - | ||
191 | - | func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP) | |
192 | - | ||
193 | - | ||
194 | - | func keyWxPerLpX18 (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLpX18"], SEP) | |
195 | - | ||
196 | - | ||
197 | - | func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP) | |
198 | - | ||
199 | - | ||
200 | - | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
201 | - | ||
202 | - | ||
203 | - | func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
204 | - | ||
205 | - | ||
206 | - | func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount)) | |
207 | - | ||
208 | - | ||
209 | - | let factoryAddress = getStringOrFail(keyFactoryAddress()) | |
210 | - | ||
211 | - | let factoryContract = addressFromStringValue(factoryAddress) | |
212 | - | ||
213 | - | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
214 | - | ||
215 | - | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
216 | - | ||
217 | - | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
218 | - | ||
219 | - | func calcWxPerLpIntegralUserLast (stakedByUser,wxPerLpIntegralUserLastUpdHeightOrZero,wxPerLpIntegralNew,wxPerLpIntegralUserLastKEY) = if (if ((wxPerLpIntegralUserLastUpdHeightOrZero == toBigInt(0))) | |
220 | - | then (stakedByUser > toBigInt(0)) | |
221 | - | else false) | |
222 | - | then toBigInt(0) | |
223 | - | else if ((stakedByUser == toBigInt(0))) | |
224 | - | then wxPerLpIntegralNew | |
225 | - | else if (if ((wxPerLpIntegralUserLastUpdHeightOrZero > toBigInt(0))) | |
226 | - | then (stakedByUser > toBigInt(0)) | |
227 | - | else false) | |
228 | - | then toBigInt(getIntOrFail(this, wxPerLpIntegralUserLastKEY)) | |
229 | - | else throw("calcWxPerLpIntegralUserLast: unexpected state") | |
230 | - | ||
231 | - | ||
232 | - | func refreshPoolINTEGRALS (lpAssetIdStr,poolAddressStr,lpDeltaAmount) = { | |
233 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
234 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
235 | - | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
236 | - | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
237 | - | let MULT3 = 1000 | |
238 | - | let wxEmissionPerBlockX3 = (getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) * MULT3) | |
239 | - | let poolWxEmissionPerBlockX3 = fraction(wxEmissionPerBlockX3, poolWeight, (POOLWEIGHTMULT * 3)) | |
240 | - | let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr) | |
241 | - | let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr) | |
242 | - | let wxPerLpKEY = keyWxPerLp(lpAssetIdStr) | |
243 | - | let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock) | |
244 | - | let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY) | |
245 | - | let wxPerLpOrZeroX3 = 0 | |
246 | - | let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0]) | |
247 | - | let wxPerLpX3 = if ((wxPerLpOrZeroX3 != 0)) | |
248 | - | then wxPerLpOrZeroX3 | |
249 | - | else fraction(poolWxEmissionPerBlockX3, MULT8, stakedTotal) | |
250 | - | let stakedTotalNew = (stakedTotal + lpDeltaAmount) | |
251 | - | let wxPerLpIntegralNew = (toBigInt(wxPerLpIntegral) + (toBigInt(wxPerLpX3) * toBigInt(dh))) | |
252 | - | let wxPerLpX3New = (poolWxEmissionPerBlockX3 / stakedTotalNew) | |
253 | - | let wxPerLpIntegralLastUpdHeightNew = height | |
254 | - | let debug = makeString([toString(wxPerLpIntegralNew), toString(dh), toString(wxPerLpX3), toString(stakedTotal), toString(poolWxEmissionPerBlockX3), toString(wxEmissionPerBlockX3), toString(poolWeight)], "::") | |
255 | - | $Tuple3(wxPerLpIntegralNew, [StringEntry(wxPerLpIntegralKEY, toString(wxPerLpIntegralNew)), IntegerEntry(wxPerLpIntegralLastUpdHeightKEY, wxPerLpIntegralLastUpdHeightNew), IntegerEntry(wxPerLpKEY, wxPerLpX3New)], debug) | |
69 | + | func getPoolConfig () = { | |
70 | + | let amtAs = getStringOrFail(poolContract, keyAmtAsset()) | |
71 | + | let priceAs = getStringOrFail(poolContract, keyPriceAsset()) | |
72 | + | let iPriceAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAs)) | |
73 | + | let iAmtAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAs)) | |
74 | + | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAs), toString(iPriceAs))), SEP) | |
256 | 75 | } | |
257 | 76 | ||
258 | 77 | ||
259 | - | func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = { | |
260 | - | let $t01110811230 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, lpDeltaAmount) | |
261 | - | let wxPerLpIntegralNew = $t01110811230._1 | |
262 | - | let poolIntegralSTATE = $t01110811230._2 | |
263 | - | let poolDEBUG = $t01110811230._3 | |
264 | - | let MULT3 = 1000 | |
265 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
266 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
267 | - | let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr) | |
268 | - | let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr) | |
269 | - | let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr) | |
270 | - | let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY) | |
271 | - | let wxPerLpIntegralUserLastUpdHeightOrZero = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY) | |
272 | - | let wxPerLpIntegralUserLast = calcWxPerLpIntegralUserLast(toBigInt(stakedByUser), toBigInt(wxPerLpIntegralUserLastUpdHeightOrZero), wxPerLpIntegralNew, wxPerLpIntegralUserLastKEY) | |
273 | - | let MULT11 = (MULT8 * MULT3) | |
274 | - | let wxToClaimUserNew = (toBigInt(wxToClaimUser) + fraction((wxPerLpIntegralNew - wxPerLpIntegralUserLast), toBigInt(stakedByUser), toBigInt(MULT11))) | |
275 | - | let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew | |
276 | - | let wxPerLpIntegralUserLastUpdHeightNew = height | |
277 | - | let debug = makeString([toString(wxToClaimUserNew), toString(wxPerLpIntegralUserLast), toString(stakedByUser), poolDEBUG, toString(height)], "::") | |
278 | - | $Tuple3(wxToClaimUserNew, (poolIntegralSTATE ++ [StringEntry(wxToClaimUserKEY, toString(wxToClaimUserNew)), IntegerEntry(wxPerLpIntegralUserLastUpdHeightKEY, wxPerLpIntegralUserLastUpdHeightNew), StringEntry(wxPerLpIntegralUserLastKEY, toString(wxPerLpIntegralUserLastNew))]), debug) | |
279 | - | } | |
78 | + | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
280 | 79 | ||
281 | 80 | ||
282 | 81 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
283 | 82 | case s: String => | |
284 | 83 | fromBase58String(s) | |
285 | 84 | case _: Unit => | |
286 | 85 | unit | |
287 | 86 | case _ => | |
288 | 87 | throw("Match error") | |
289 | 88 | } | |
290 | 89 | ||
291 | 90 | ||
292 | 91 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
293 | 92 | case s: String => | |
294 | 93 | fromBase58String(s) | |
295 | 94 | case _: Unit => | |
296 | 95 | unit | |
297 | 96 | case _ => | |
298 | 97 | throw("Match error") | |
299 | 98 | } | |
300 | 99 | ||
301 | 100 | ||
302 | 101 | func mustManager (i) = { | |
303 | 102 | let pd = throw("Permission denied") | |
304 | 103 | match managerPublicKeyOrUnit() { | |
305 | 104 | case pk: ByteVector => | |
306 | 105 | if ((i.callerPublicKey == pk)) | |
307 | 106 | then true | |
308 | 107 | else pd | |
309 | 108 | case _: Unit => | |
310 | 109 | if ((i.caller == this)) | |
311 | 110 | then true | |
312 | 111 | else pd | |
313 | 112 | case _ => | |
314 | 113 | throw("Match error") | |
315 | 114 | } | |
316 | 115 | } | |
317 | 116 | ||
318 | 117 | ||
118 | + | func getAdmins () = match getString(keyAdminPubKeys()) { | |
119 | + | case s: String => | |
120 | + | if ((size(s) == 0)) | |
121 | + | then nil | |
122 | + | else split(s, SEP) | |
123 | + | case _ => | |
124 | + | nil | |
125 | + | } | |
126 | + | ||
127 | + | ||
128 | + | func mustAdmin (i) = if (containsElement(getAdmins(), toBase58String(i.callerPublicKey))) | |
129 | + | then true | |
130 | + | else mustManager(i) | |
131 | + | ||
132 | + | ||
133 | + | func mustPool (i) = if ((i.caller == poolContract)) | |
134 | + | then true | |
135 | + | else throw("caller must be the pool") | |
136 | + | ||
137 | + | ||
319 | 138 | @Callable(i) | |
320 | - | func constructor ( | |
139 | + | func constructor (poolAddress) = { | |
321 | 140 | let checkCaller = mustManager(i) | |
322 | 141 | if ((checkCaller == checkCaller)) | |
323 | - | then [StringEntry( | |
142 | + | then [StringEntry(keyPoolAddr(), poolAddress)] | |
324 | 143 | else throw("Strict value is not equal to itself.") | |
325 | 144 | } | |
326 | 145 | ||
327 | 146 | ||
328 | 147 | ||
329 | 148 | @Callable(i) | |
330 | 149 | func setManager (pendingManagerPublicKey) = { | |
331 | 150 | let checkCaller = mustManager(i) | |
332 | 151 | if ((checkCaller == checkCaller)) | |
333 | 152 | then { | |
334 | 153 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
335 | 154 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
336 | 155 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
337 | 156 | else throw("Strict value is not equal to itself.") | |
338 | 157 | } | |
339 | 158 | else throw("Strict value is not equal to itself.") | |
340 | 159 | } | |
341 | 160 | ||
342 | 161 | ||
343 | 162 | ||
344 | 163 | @Callable(i) | |
345 | 164 | func confirmManager () = { | |
346 | 165 | let pm = pendingManagerPublicKeyOrUnit() | |
347 | 166 | let hasPM = if (isDefined(pm)) | |
348 | 167 | then true | |
349 | 168 | else throw("No pending manager") | |
350 | 169 | if ((hasPM == hasPM)) | |
351 | 170 | then { | |
352 | 171 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
353 | 172 | then true | |
354 | 173 | else throw("You are not pending manager") | |
355 | 174 | if ((checkPM == checkPM)) | |
356 | 175 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
357 | 176 | else throw("Strict value is not equal to itself.") | |
358 | 177 | } | |
359 | 178 | else throw("Strict value is not equal to itself.") | |
360 | 179 | } | |
361 | 180 | ||
362 | 181 | ||
363 | 182 | ||
364 | 183 | @Callable(i) | |
365 | - | func stake () = if ((size(i.payments) != 1)) | |
366 | - | then throw("invalid payment - exact one payment must be attached") | |
367 | - | else { | |
368 | - | let pmt = i.payments[0] | |
369 | - | let lpAssetId = value(pmt.assetId) | |
370 | - | let lpAssetIdStr = toBase58String(lpAssetId) | |
371 | - | let amount = pmt.amount | |
372 | - | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
373 | - | let callerStr = toString(i.caller) | |
374 | - | let userAddressStr = if ((callerStr == poolAddressStr)) | |
375 | - | then toString(i.originCaller) | |
376 | - | else callerStr | |
377 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
378 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
379 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
380 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
381 | - | let $t01522115338 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount) | |
382 | - | let wxToClaimUserNew = $t01522115338._1 | |
383 | - | let integralSTATE = $t01522115338._2 | |
384 | - | let debug = $t01522115338._3 | |
385 | - | ([IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
386 | - | } | |
387 | - | ||
388 | - | ||
389 | - | ||
390 | - | @Callable(i) | |
391 | - | func unstake (lpAssetIdStr,amount) = { | |
392 | - | let lpAssetId = fromBase58String(lpAssetIdStr) | |
393 | - | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
394 | - | let poolAddon = valueOrElse(getString(this, keyStablePoolAddonAddr()), poolAddressStr) | |
395 | - | let callerStr = toString(i.caller) | |
396 | - | let userAddressStr = if (if ((callerStr == poolAddressStr)) | |
397 | - | then true | |
398 | - | else (callerStr == poolAddon)) | |
399 | - | then toString(i.originCaller) | |
400 | - | else callerStr | |
401 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
402 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
403 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
404 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
405 | - | let $t01647516593 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount)) | |
406 | - | let wxToClaimUserNew = $t01647516593._1 | |
407 | - | let integralSTATE = $t01647516593._2 | |
408 | - | let debug = $t01647516593._3 | |
409 | - | if ((amount > stakedByUser)) | |
410 | - | then throw("passed amount is less then available") | |
411 | - | else ([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) | |
184 | + | func setAdmins (adminPubKeys) = { | |
185 | + | let checkCaller = mustManager(i) | |
186 | + | if ((checkCaller == checkCaller)) | |
187 | + | then [StringEntry(keyAdminPubKeys(), makeString(adminPubKeys, SEP))] | |
188 | + | else throw("Strict value is not equal to itself.") | |
412 | 189 | } | |
413 | 190 | ||
414 | 191 | ||
415 | 192 | ||
416 | 193 | @Callable(i) | |
417 | - | func claimWx (lpAssetIdStr) = { | |
418 | - | let userAddress = i.caller | |
419 | - | let userAddressStr = toString(i.caller) | |
420 | - | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
421 | - | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
422 | - | let claimedTotalKEY = keyClaimedTotal(lpAssetIdStr) | |
423 | - | let claimedByUserMinRewardKEY = keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr) | |
424 | - | let claimedByUserBoostRewardKEY = keyClaimedByUserBoostReward(lpAssetIdStr, userAddressStr) | |
425 | - | let claimedByUser = toBigInt(getIntOrZero(this, claimedByUserKEY)) | |
426 | - | let claimedByUserMinReward = toBigInt(getIntOrZero(this, claimedByUserMinRewardKEY)) | |
427 | - | let claimedByUserBoostReward = toBigInt(getIntOrZero(this, claimedByUserBoostRewardKEY)) | |
428 | - | let claimedTotal = toBigInt(getIntOrZero(this, claimedTotalKEY)) | |
429 | - | let $t01782917941 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
430 | - | let wxToClaimUserNew = $t01782917941._1 | |
431 | - | let integralSTATE = $t01782917941._2 | |
432 | - | let debug = $t01782917941._3 | |
433 | - | let availableToClaim = (wxToClaimUserNew - claimedByUser) | |
434 | - | if ((toBigInt(0) >= availableToClaim)) | |
435 | - | then throw("nothing to claim") | |
436 | - | else { | |
437 | - | let wxAmountBoostTotal = asInt(asAnyList(invoke(boostingContract, "claimWxBoost", [lpAssetIdStr, userAddressStr], nil))[0]) | |
438 | - | let minRewardPart = availableToClaim | |
439 | - | let boostRewardPart = min([(minRewardPart * toBigInt(2)), toBigInt(wxAmountBoostTotal)]) | |
440 | - | let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [minRewardPart], nil))[0]) | |
441 | - | let emitBoost = asAnyList(invoke(emissionContract, "emit", [boostRewardPart], nil)) | |
442 | - | if ((emitBoost == emitBoost)) | |
194 | + | func unstakeAndGetOneTkn (amount,exchResult,notUsed,outAmount,outAssetId,slippage) = { | |
195 | + | let checkPayments = if ((size(i.payments) != 0)) | |
196 | + | then throw("No pmnts expd") | |
197 | + | else true | |
198 | + | if ((checkPayments == checkPayments)) | |
199 | + | then { | |
200 | + | let cfg = getPoolConfig() | |
201 | + | let factoryCfg = getFactoryConfig() | |
202 | + | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
203 | + | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
204 | + | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
205 | + | if ((unstakeInv == unstakeInv)) | |
443 | 206 | then { | |
444 | - | let claimedByUserValue = (claimedByUser + availableToClaim) | |
445 | - | let claimedByUserMinRewardPlusPart = (claimedByUserMinReward + minRewardPart) | |
446 | - | let claimedByUserBoostRewardPlusBoostRewardPart = (claimedByUserMinReward + minRewardPart) | |
447 | - | let claimedTotalPlusAvailableToClaim = (claimedByUserMinReward + minRewardPart) | |
448 | - | [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)] | |
207 | + | let getOneTkn = reentrantInvoke(poolContract, "getOneTkn", [exchResult, notUsed, outAmount, outAssetId, slippage], [AttachedPayment(lpAssetId, amount)]) | |
208 | + | if ((getOneTkn == getOneTkn)) | |
209 | + | then nil | |
210 | + | else throw("Strict value is not equal to itself.") | |
449 | 211 | } | |
450 | 212 | else throw("Strict value is not equal to itself.") | |
451 | 213 | } | |
214 | + | else throw("Strict value is not equal to itself.") | |
452 | 215 | } | |
453 | 216 | ||
454 | 217 | ||
455 | 218 | ||
456 | 219 | @Callable(i) | |
457 | - | func claimWxREADONLY (lpAssetIdStr,userAddressStr) = { | |
458 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
459 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
460 | - | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
461 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
462 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
463 | - | let claimedByUser = getIntOrZero(this, claimedByUserKEY) | |
464 | - | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
465 | - | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
466 | - | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
467 | - | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
468 | - | let passedBlocks = if ((emissionStartBlock > height)) | |
469 | - | then 0 | |
470 | - | else (height - emissionStartBlock) | |
471 | - | let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, POOLWEIGHTMULT) | |
472 | - | let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal) | |
473 | - | let $t02052820640 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
474 | - | let wxToClaimUserNew = $t02052820640._1 | |
475 | - | let integralSTATE = $t02052820640._2 | |
476 | - | let debug = $t02052820640._3 | |
477 | - | let availableToClaim = (wxToClaimUserNew - toBigInt(claimedByUser)) | |
478 | - | let boostInvResult = asAnyList(invoke(boostingContract, "claimWxBoostREADONLY", [lpAssetIdStr, userAddressStr], nil)) | |
479 | - | let wxAmountBoostTotal = asInt(boostInvResult[0]) | |
480 | - | let boostDebug = asString(boostInvResult[1]) | |
481 | - | let minRewardPart = availableToClaim | |
482 | - | let boostRewardPart = min([(minRewardPart * toBigInt(2)), toBigInt(wxAmountBoostTotal)]) | |
483 | - | let totalReward = (minRewardPart + boostRewardPart) | |
484 | - | $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)) | |
220 | + | func setAmp (amp) = { | |
221 | + | let checkCaller = mustAdmin(i) | |
222 | + | if ((checkCaller == checkCaller)) | |
223 | + | then { | |
224 | + | let res1 = invoke(poolContract, "setS", [keyAmp(), amp], nil) | |
225 | + | let res2 = invoke(poolContract, "setS", [keyAmpHistory(height), amp], nil) | |
226 | + | $Tuple2(nil, $Tuple2(res1, res2)) | |
227 | + | } | |
228 | + | else throw("Strict value is not equal to itself.") | |
485 | 229 | } | |
486 | 230 | ||
487 | 231 | ||
488 | 232 | ||
489 | 233 | @Callable(i) | |
490 | - | func onModifyWeight (lpAssetIdStr,poolAddressStr) = if ((i.caller != factoryContract)) | |
491 | - | then throw("permissions denied") | |
492 | - | else { | |
493 | - | let $t02155321663 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, 0) | |
494 | - | let wxPerLpIntegralNew = $t02155321663._1 | |
495 | - | let poolIntegralSTATE = $t02155321663._2 | |
496 | - | let poolDEBUG = $t02155321663._3 | |
497 | - | poolIntegralSTATE | |
498 | - | } | |
234 | + | func ensureCanGetOrPutOneTkn (caller) = { | |
235 | + | let checkCaller = mustPool(i) | |
236 | + | if ((checkCaller == checkCaller)) | |
237 | + | then { | |
238 | + | let ensureCanPut = match getInteger(poolContract, lastGetOrPutOneTknCall(caller)) { | |
239 | + | case int: Int => | |
240 | + | let permittedHeight = (int + value(getInteger(poolContract, delay))) | |
241 | + | let isReadyforPutOneTkn = (height >= permittedHeight) | |
242 | + | let needBlocks = (permittedHeight - height) | |
243 | + | if (isReadyforPutOneTkn) | |
244 | + | then true | |
245 | + | else throw(makeString(["you should wait", toString(needBlocks), "blocks more to perform the action"], " ")) | |
246 | + | case _ => | |
247 | + | true | |
248 | + | } | |
249 | + | if ((ensureCanPut == ensureCanPut)) | |
250 | + | then { | |
251 | + | let setI = invoke(poolContract, "setI", [lastGetOrPutOneTknCall(caller), height], nil) | |
252 | + | if ((setI == setI)) | |
253 | + | then nil | |
254 | + | else throw("Strict value is not equal to itself.") | |
255 | + | } | |
256 | + | else throw("Strict value is not equal to itself.") | |
257 | + | } | |
258 | + | else throw("Strict value is not equal to itself.") | |
259 | + | } | |
499 | 260 | ||
500 | 261 | ||
501 | 262 | @Verifier(tx) | |
502 | 263 | func verify () = { | |
503 | 264 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
504 | 265 | case pk: ByteVector => | |
505 | 266 | pk | |
506 | 267 | case _: Unit => | |
507 | 268 | tx.senderPublicKey | |
508 | 269 | case _ => | |
509 | 270 | throw("Match error") | |
510 | 271 | } | |
511 | 272 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
512 | 273 | } | |
513 | 274 |
github/deemru/w8io/169f3d6 77.79 ms ◑