tx · FtqdTuY78hYxmRQWRPJjHnuU1oewEVRUTiENKFKP5ALy

3MrWcipACLhYRJHpFXTZJThH65pnP9vCZow:  -0.01000000 Waves

2021.11.23 14:31 [1803611] smart account 3MrWcipACLhYRJHpFXTZJThH65pnP9vCZow > SELF 0.00000000 Waves

{ "type": 13, "id": "FtqdTuY78hYxmRQWRPJjHnuU1oewEVRUTiENKFKP5ALy", "fee": 1000000, "feeAssetId": null, "timestamp": 1637667097008, "version": 1, "sender": "3MrWcipACLhYRJHpFXTZJThH65pnP9vCZow", "senderPublicKey": "BCvAm7CyQwCK8SaiMMxYNL4sfMxyEHmSssYWaD9t4iUg", "proofs": [ "21BNaQsjFVGEkwPCrunGUKotSp51bHMZpG65w3hZcijJ1uswtFQWK7Gi3vzgsiEKQiVSNR5nfqPBTmJSbr8JQWCk" ], "script": "base64:AAIFAAAAAAAAABoIAhIDCgEIEgASBAoCCAESAwoBCBIECgIICAAAADgAAAAABlNDQUxFOAAAAAAAAAAACAAAAAAFTVVMVDgAAAAAAAX14QAAAAAAB1NDQUxFMTgAAAAAAAAAABIAAAAABk1VTFQxOAkAATYAAAABAA3gtrOnZAAAAAAAAANTRVACAAAAAl9fAAAAAA5QT09MV0VJR0hUTVVMVAUAAAAFTVVMVDgBAAAAD2dldFN0cmluZ09yRmFpbAAAAAEAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQiAAAAAQUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgIAAAAPbWFuZGF0b3J5IHRoaXMuBQAAAANrZXkCAAAADyBpcyBub3QgZGVmaW5lZAEAAAAYZ2V0U3RyaW5nQnlBZGRyZXNzT3JGYWlsAAAAAgAAAAdhZGRyZXNzAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAAB2FkZHJlc3MFAAAAA2tleQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAptYW5kYXRvcn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laWdodE5ldwUAAAAGaGVpZ2h0CQAFFAAAAAIFAAAAA25pbAkABLkAAAACCQAETAAAAAICAAAACCVzJXMlZCVkCQAETAAAAAIFAAAADGxwQXNzZXRJZFN0cgkABEwAAAACBQAAAA51c2VyQWRkcmVzc1N0cgkABEwAAAACCQABpAAAAAEFAAAADHVzZXJXeFJld2FyZAkABEwAAAACCQABpAAAAAEFAAAAEHd4VG9DbGFpbVVzZXJOZXcFAAAAA25pbAUAAAADU0VQAAAAAFbq95Q=", "chainId": 84, "height": 1803611, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2z3iUUBjCfajcUr7a3HRAqSEmYQsdyMAREh2uCKrLMMt Next: 5nyU8JwLdDHRxzuacYfsXcaDgjpq6igxWGETwdjid8CY Diff:
OldNewDifferences
1111
1212 let SEP = "__"
1313
14+let POOLWEIGHTMULT = MULT8
15+
1416 func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined"))
1517
1618
1820
1921
2022 func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0)
23+
24+
25+func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal)
2126
2227
2328 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined"))
97102 func readStaked (key) = valueOrElse(getInteger(this, key), 0)
98103
99104
105+func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP)
106+
107+
108+func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP)
109+
110+
111+func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP)
112+
113+
114+func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP)
115+
116+
117+func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP)
118+
119+
120+func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP)
121+
122+
123+func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP)
124+
125+
126+func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP)
127+
128+
129+func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP)
130+
131+
132+func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP)
133+
134+
135+func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP)
136+
137+
138+func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP)
139+
140+
100141 func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP)
101142
102143
106147 func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount))
107148
108149
150+let factoryContract = readFactoryAddressOrFail()
151+
152+let factoryCfg = readFactoryCfgOrFail(factoryContract)
153+
154+let emissionContract = getEmissionAddressOrFail(factoryCfg)
155+
109156 @Callable(i)
110157 func constructor (factoryAddressStr) = if ((i.caller != this))
111158 then throw("not authorized")
114161
115162
116163 @Callable(i)
117-func stake () = {
118- let factory = readFactoryAddressOrFail()
119- if ((size(i.payments) != 1))
120- then throw("invalid payment - exact one payment must be attached")
121- else {
122- let pmt = i.payments[0]
123- let lpAssetId = value(pmt.assetId)
124- let lpAssetIdStr = toBase58String(lpAssetId)
125- let amount = pmt.amount
126- let lpDappStr = valueOrErrorMessage(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
127- let callerStr = toString(i.caller)
128- let userAddressStr = if ((callerStr == lpDappStr))
129- then toString(i.originCaller)
130- else callerStr
131- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
132- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
133- let stakedByUser = readStaked(stakedByUserKEY)
134- let stakedTotal = readStaked(stakedTotalKEY)
135-[IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
136- }
164+func stake () = if ((size(i.payments) != 1))
165+ then throw("invalid payment - exact one payment must be attached")
166+ else {
167+ let pmt = i.payments[0]
168+ let lpAssetId = value(pmt.assetId)
169+ let lpAssetIdStr = toBase58String(lpAssetId)
170+ let amount = pmt.amount
171+ let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
172+ let callerStr = toString(i.caller)
173+ let userAddressStr = if ((callerStr == poolAddressStr))
174+ then toString(i.originCaller)
175+ else callerStr
176+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
177+ let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
178+ let stakedByUser = readStaked(stakedByUserKEY)
179+ let stakedTotal = readStaked(stakedTotalKEY)
180+ let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
181+ let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock())
182+ let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent())
183+ let poolWxEmissionPerBlock = fraction(wxEmissionPerBlock, poolWeight, (POOLWEIGHTMULT * 3))
184+ let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr)
185+ let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr)
186+ let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr)
187+ let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr)
188+ let wxPerLpKEY = keyWxPerLp(lpAssetIdStr)
189+ let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr)
190+ let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock)
191+ let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY)
192+ let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY)
193+ let wxPerLpIntegralUserLastUpdHeight = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY)
194+ let wxPerLpOrZero = getIntOrZero(this, wxPerLpKEY)
195+ let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0])
196+ let wxPerLp = if ((wxPerLpOrZero != 0))
197+ then wxPerLpOrZero
198+ else (poolWxEmissionPerBlock / stakedTotal)
199+ let stakedTotalNew = (stakedTotal + amount)
200+ let wxPerLpIntegralNew = (wxPerLpIntegral + (wxPerLp * dh))
201+ let wxPerLpIntegralUserLast = if (if ((wxPerLpIntegralUserLastUpdHeight == 0))
202+ then (stakedByUser > 0)
203+ else false)
204+ then 0
205+ else if ((stakedByUser == 0))
206+ then wxPerLpIntegralNew
207+ else if (if ((wxPerLpIntegralUserLastUpdHeight > 0))
208+ then (stakedByUser > 0)
209+ else false)
210+ then getIntOrFail(this, wxPerLpIntegralUserLastKEY)
211+ else throw("Invalid condition")
212+ let wxToClaimUserNew = (wxToClaimUser + ((wxPerLpIntegralNew - wxPerLpIntegralUserLast) * stakedByUser))
213+ let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew
214+ let wxPerLpNew = (poolWxEmissionPerBlock / stakedTotalNew)
215+ let wxPerLpIntegralLastUpdHeightNew = height
216+ let wxPerLpIntegralUserLastUpdHeightNew = height
217+[IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, stakedTotalNew), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
218+ }
219+
220+
221+
222+@Callable(i)
223+func unstake (lpAssetIdStr,amount) = {
224+ let userAddressStr = toString(i.caller)
225+ let lpAssetId = fromBase58String(lpAssetIdStr)
226+ if (!(isDefined(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)))))
227+ then throw(("unsupported lp asset " + lpAssetIdStr))
228+ else if ((userAddressStr == userAddressStr))
229+ then throw("Somthing went wrong")
230+ else {
231+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
232+ let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
233+ let stakedByUser = readStaked(stakedByUserKEY)
234+ let stakedTotal = readStaked(stakedTotalKEY)
235+ if ((amount > stakedByUser))
236+ then throw("passed amount is less then available")
237+ else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
238+ }
137239 }
138240
139241
140242
141243 @Callable(i)
142-func unstake (lpAssetIdStr,amount) = {
143- let factory = readFactoryAddressOrFail()
144- let userAddressStr = toString(i.caller)
145- let lpAssetId = fromBase58String(lpAssetIdStr)
146- if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)))))
147- then throw(("unsupported lp asset " + lpAssetIdStr))
148- else {
149- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
150- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
151- let stakedByUser = readStaked(stakedByUserKEY)
152- let stakedTotal = readStaked(stakedTotalKEY)
153- if ((amount > stakedByUser))
154- then throw("passed amount is less then available")
155- else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
156- }
157- }
244+func claimWx (lpAssetIdStr) = throw("temporary disabled")
158245
159246
160247
161248 @Callable(i)
162-func claimWx (lpAssetIdStr) = throw("temorary disabled")
163-
164-
165-
166-@Callable(i)
167-func claimWxREADONLY (lpAssetIdStr,userAddress) = {
168- let factoryContract = readFactoryAddressOrFail()
169- let factoryCfg = readFactoryCfgOrFail(factoryContract)
170- let emissionContract = getEmissionAddressOrFail(factoryCfg)
171- let stakedByUserKEY = keyStakedByUser(userAddress, lpAssetIdStr)
249+func claimWxREADONLY (lpAssetIdStr,userAddressStr) = {
250+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
172251 let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
173252 let stakedByUser = readStaked(stakedByUserKEY)
174253 let stakedTotal = readStaked(stakedTotalKEY)
182261 else (height - emissionStartBlock)
183262 let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, poolWeightMult)
184263 let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal)
185- $Tuple2(nil, makeString(["%s%s%d", lpAssetIdStr, userAddress, toString(userWxReward)], SEP))
264+ let poolWxEmissionPerBlock = fraction(wxEmissionPerBlock, poolWeight, POOLWEIGHTMULT)
265+ let amount = 0
266+ let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr)
267+ let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr)
268+ let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr)
269+ let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr)
270+ let wxPerLpKEY = keyWxPerLp(lpAssetIdStr)
271+ let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr)
272+ let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock)
273+ let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY)
274+ let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY)
275+ let wxPerLpIntegralUserLastUpdHeight = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY)
276+ let wxPerLpOrZero = getIntOrZero(this, wxPerLpKEY)
277+ let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0])
278+ let wxPerLp = if ((wxPerLpOrZero != 0))
279+ then wxPerLpOrZero
280+ else (poolWxEmissionPerBlock / stakedTotal)
281+ let stakedTotalNew = (stakedTotal + amount)
282+ let wxPerLpIntegralNew = (wxPerLpIntegral + (wxPerLp * dh))
283+ let wxPerLpIntegralUserLast = if (if ((wxPerLpIntegralUserLastUpdHeight == 0))
284+ then (stakedByUser > 0)
285+ else false)
286+ then 0
287+ else if ((stakedByUser == 0))
288+ then wxPerLpIntegralNew
289+ else if (if ((wxPerLpIntegralUserLastUpdHeight > 0))
290+ then (stakedByUser > 0)
291+ else false)
292+ then getIntOrFail(this, wxPerLpIntegralUserLastKEY)
293+ else throw("Invalid condition")
294+ let wxToClaimUserNew = (wxToClaimUser + ((wxPerLpIntegralNew - wxPerLpIntegralUserLast) * stakedByUser))
295+ let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew
296+ let wxPerLpNew = (poolWxEmissionPerBlock / stakedTotalNew)
297+ let wxPerLpIntegralLastUpdHeightNew = height
298+ let wxPerLpIntegralUserLastUpdHeightNew = height
299+ $Tuple2(nil, makeString(["%s%s%d%d", lpAssetIdStr, userAddressStr, toString(userWxReward), toString(wxToClaimUserNew)], SEP))
186300 }
187301
188302
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SCALE8 = 8
55
66 let MULT8 = 100000000
77
88 let SCALE18 = 18
99
1010 let MULT18 = toBigInt(1000000000000000000)
1111
1212 let SEP = "__"
1313
14+let POOLWEIGHTMULT = MULT8
15+
1416 func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined"))
1517
1618
1719 func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
1820
1921
2022 func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0)
23+
24+
25+func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal)
2126
2227
2328 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined"))
2429
2530
2631 func keyFactoryAddress () = "%s%s__config__factoryAddress"
2732
2833
2934 let IdxFactoryCfgStakingDapp = 1
3035
3136 let IdxFactoryCfgBoostingDapp = 2
3237
3338 let IdxFactoryCfgIdoDapp = 3
3439
3540 let IdxFactoryCfgTeamDapp = 4
3641
3742 let IdxFactoryCfgEmissionDapp = 5
3843
3944 let IdxFactoryCfgRestDapp = 6
4045
4146 let IdxFactoryCfgSlippageDapp = 7
4247
4348 func keyFactoryCfg () = "%s__factoryConfig"
4449
4550
4651 func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP)
4752
4853
4954 func keyFactoryLpList () = "%s__lpTokensList"
5055
5156
5257 func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP)
5358
5459
5560 func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP)
5661
5762
5863 func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(keyFactoryAddress()))
5964
6065
6166 func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP)
6267
6368
6469 func readFactoryCfgOrFail (factory) = split(getStringByAddressOrFail(factory, keyFactoryCfg()), SEP)
6570
6671
6772 func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp])
6873
6974
7075 func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp])
7176
7277
7378 func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp])
7479
7580
7681 func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current"
7782
7883
7984 func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current"
8085
8186
8287 func keyEmissionStartBlock () = "%s%s__emission__startBlock"
8388
8489
8590 func keyEmissionDurationInBlocks () = "%s%s__emission__duration"
8691
8792
8893 func keyEmissionEndBlock () = "%s%s__emission__endBlock"
8994
9095
9196 func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP)
9297
9398
9499 func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr)
95100
96101
97102 func readStaked (key) = valueOrElse(getInteger(this, key), 0)
98103
99104
105+func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP)
106+
107+
108+func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP)
109+
110+
111+func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP)
112+
113+
114+func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP)
115+
116+
117+func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP)
118+
119+
120+func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP)
121+
122+
123+func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP)
124+
125+
126+func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP)
127+
128+
129+func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP)
130+
131+
132+func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP)
133+
134+
135+func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP)
136+
137+
138+func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP)
139+
140+
100141 func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP)
101142
102143
103144 func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP)
104145
105146
106147 func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount))
107148
108149
150+let factoryContract = readFactoryAddressOrFail()
151+
152+let factoryCfg = readFactoryCfgOrFail(factoryContract)
153+
154+let emissionContract = getEmissionAddressOrFail(factoryCfg)
155+
109156 @Callable(i)
110157 func constructor (factoryAddressStr) = if ((i.caller != this))
111158 then throw("not authorized")
112159 else [StringEntry(keyFactoryAddress(), factoryAddressStr)]
113160
114161
115162
116163 @Callable(i)
117-func stake () = {
118- let factory = readFactoryAddressOrFail()
119- if ((size(i.payments) != 1))
120- then throw("invalid payment - exact one payment must be attached")
121- else {
122- let pmt = i.payments[0]
123- let lpAssetId = value(pmt.assetId)
124- let lpAssetIdStr = toBase58String(lpAssetId)
125- let amount = pmt.amount
126- let lpDappStr = valueOrErrorMessage(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
127- let callerStr = toString(i.caller)
128- let userAddressStr = if ((callerStr == lpDappStr))
129- then toString(i.originCaller)
130- else callerStr
131- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
132- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
133- let stakedByUser = readStaked(stakedByUserKEY)
134- let stakedTotal = readStaked(stakedTotalKEY)
135-[IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
136- }
164+func stake () = if ((size(i.payments) != 1))
165+ then throw("invalid payment - exact one payment must be attached")
166+ else {
167+ let pmt = i.payments[0]
168+ let lpAssetId = value(pmt.assetId)
169+ let lpAssetIdStr = toBase58String(lpAssetId)
170+ let amount = pmt.amount
171+ let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
172+ let callerStr = toString(i.caller)
173+ let userAddressStr = if ((callerStr == poolAddressStr))
174+ then toString(i.originCaller)
175+ else callerStr
176+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
177+ let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
178+ let stakedByUser = readStaked(stakedByUserKEY)
179+ let stakedTotal = readStaked(stakedTotalKEY)
180+ let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
181+ let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock())
182+ let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent())
183+ let poolWxEmissionPerBlock = fraction(wxEmissionPerBlock, poolWeight, (POOLWEIGHTMULT * 3))
184+ let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr)
185+ let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr)
186+ let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr)
187+ let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr)
188+ let wxPerLpKEY = keyWxPerLp(lpAssetIdStr)
189+ let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr)
190+ let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock)
191+ let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY)
192+ let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY)
193+ let wxPerLpIntegralUserLastUpdHeight = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY)
194+ let wxPerLpOrZero = getIntOrZero(this, wxPerLpKEY)
195+ let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0])
196+ let wxPerLp = if ((wxPerLpOrZero != 0))
197+ then wxPerLpOrZero
198+ else (poolWxEmissionPerBlock / stakedTotal)
199+ let stakedTotalNew = (stakedTotal + amount)
200+ let wxPerLpIntegralNew = (wxPerLpIntegral + (wxPerLp * dh))
201+ let wxPerLpIntegralUserLast = if (if ((wxPerLpIntegralUserLastUpdHeight == 0))
202+ then (stakedByUser > 0)
203+ else false)
204+ then 0
205+ else if ((stakedByUser == 0))
206+ then wxPerLpIntegralNew
207+ else if (if ((wxPerLpIntegralUserLastUpdHeight > 0))
208+ then (stakedByUser > 0)
209+ else false)
210+ then getIntOrFail(this, wxPerLpIntegralUserLastKEY)
211+ else throw("Invalid condition")
212+ let wxToClaimUserNew = (wxToClaimUser + ((wxPerLpIntegralNew - wxPerLpIntegralUserLast) * stakedByUser))
213+ let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew
214+ let wxPerLpNew = (poolWxEmissionPerBlock / stakedTotalNew)
215+ let wxPerLpIntegralLastUpdHeightNew = height
216+ let wxPerLpIntegralUserLastUpdHeightNew = height
217+[IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, stakedTotalNew), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
218+ }
219+
220+
221+
222+@Callable(i)
223+func unstake (lpAssetIdStr,amount) = {
224+ let userAddressStr = toString(i.caller)
225+ let lpAssetId = fromBase58String(lpAssetIdStr)
226+ if (!(isDefined(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)))))
227+ then throw(("unsupported lp asset " + lpAssetIdStr))
228+ else if ((userAddressStr == userAddressStr))
229+ then throw("Somthing went wrong")
230+ else {
231+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
232+ let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
233+ let stakedByUser = readStaked(stakedByUserKEY)
234+ let stakedTotal = readStaked(stakedTotalKEY)
235+ if ((amount > stakedByUser))
236+ then throw("passed amount is less then available")
237+ else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
238+ }
137239 }
138240
139241
140242
141243 @Callable(i)
142-func unstake (lpAssetIdStr,amount) = {
143- let factory = readFactoryAddressOrFail()
144- let userAddressStr = toString(i.caller)
145- let lpAssetId = fromBase58String(lpAssetIdStr)
146- if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)))))
147- then throw(("unsupported lp asset " + lpAssetIdStr))
148- else {
149- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
150- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
151- let stakedByUser = readStaked(stakedByUserKEY)
152- let stakedTotal = readStaked(stakedTotalKEY)
153- if ((amount > stakedByUser))
154- then throw("passed amount is less then available")
155- else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
156- }
157- }
244+func claimWx (lpAssetIdStr) = throw("temporary disabled")
158245
159246
160247
161248 @Callable(i)
162-func claimWx (lpAssetIdStr) = throw("temorary disabled")
163-
164-
165-
166-@Callable(i)
167-func claimWxREADONLY (lpAssetIdStr,userAddress) = {
168- let factoryContract = readFactoryAddressOrFail()
169- let factoryCfg = readFactoryCfgOrFail(factoryContract)
170- let emissionContract = getEmissionAddressOrFail(factoryCfg)
171- let stakedByUserKEY = keyStakedByUser(userAddress, lpAssetIdStr)
249+func claimWxREADONLY (lpAssetIdStr,userAddressStr) = {
250+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
172251 let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
173252 let stakedByUser = readStaked(stakedByUserKEY)
174253 let stakedTotal = readStaked(stakedTotalKEY)
175254 let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr))
176255 let poolWeightMult = MULT8
177256 let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
178257 let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent())
179258 let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock())
180259 let passedBlocks = if ((emissionStartBlock > height))
181260 then 0
182261 else (height - emissionStartBlock)
183262 let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, poolWeightMult)
184263 let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal)
185- $Tuple2(nil, makeString(["%s%s%d", lpAssetIdStr, userAddress, toString(userWxReward)], SEP))
264+ let poolWxEmissionPerBlock = fraction(wxEmissionPerBlock, poolWeight, POOLWEIGHTMULT)
265+ let amount = 0
266+ let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr)
267+ let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr)
268+ let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr)
269+ let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr)
270+ let wxPerLpKEY = keyWxPerLp(lpAssetIdStr)
271+ let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr)
272+ let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock)
273+ let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY)
274+ let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY)
275+ let wxPerLpIntegralUserLastUpdHeight = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY)
276+ let wxPerLpOrZero = getIntOrZero(this, wxPerLpKEY)
277+ let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0])
278+ let wxPerLp = if ((wxPerLpOrZero != 0))
279+ then wxPerLpOrZero
280+ else (poolWxEmissionPerBlock / stakedTotal)
281+ let stakedTotalNew = (stakedTotal + amount)
282+ let wxPerLpIntegralNew = (wxPerLpIntegral + (wxPerLp * dh))
283+ let wxPerLpIntegralUserLast = if (if ((wxPerLpIntegralUserLastUpdHeight == 0))
284+ then (stakedByUser > 0)
285+ else false)
286+ then 0
287+ else if ((stakedByUser == 0))
288+ then wxPerLpIntegralNew
289+ else if (if ((wxPerLpIntegralUserLastUpdHeight > 0))
290+ then (stakedByUser > 0)
291+ else false)
292+ then getIntOrFail(this, wxPerLpIntegralUserLastKEY)
293+ else throw("Invalid condition")
294+ let wxToClaimUserNew = (wxToClaimUser + ((wxPerLpIntegralNew - wxPerLpIntegralUserLast) * stakedByUser))
295+ let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew
296+ let wxPerLpNew = (poolWxEmissionPerBlock / stakedTotalNew)
297+ let wxPerLpIntegralLastUpdHeightNew = height
298+ let wxPerLpIntegralUserLastUpdHeightNew = height
299+ $Tuple2(nil, makeString(["%s%s%d%d", lpAssetIdStr, userAddressStr, toString(userWxReward), toString(wxToClaimUserNew)], SEP))
186300 }
187301
188302

github/deemru/w8io/026f985 
35.51 ms