tx · 9WzgvqcCxRSBPRa9QiZstfGGNY4MmkqsGYAD47KMPHMi

3Mzep1R5kHeC1ecKFkWjuhU3Gw4LAdCib9N:  -0.01300000 Waves

2024.02.02 12:44 [2958486] smart account 3Mzep1R5kHeC1ecKFkWjuhU3Gw4LAdCib9N > SELF 0.00000000 Waves

{ "type": 13, "id": "9WzgvqcCxRSBPRa9QiZstfGGNY4MmkqsGYAD47KMPHMi", "fee": 1300000, "feeAssetId": null, "timestamp": 1706867090670, "version": 2, "chainId": 84, "sender": "3Mzep1R5kHeC1ecKFkWjuhU3Gw4LAdCib9N", "senderPublicKey": "41THq9VrFxHEvVGJyz2oMpJQErnSkkqJXpBypSDxa5Mv", "proofs": [ "2PczNqpHQCyBgJaFkhwREEsj3EJ8UTtMMV62PjQZEtgNUWm7YbxHdQcfFCbvswDMNJckGoGZK11dig5PSx6LekWS" ], "script": "base64:BwIeCAISAwoBGBIDCgEYEgQKAgIYEgQKAgIYEgQKAgIYJgAHY2hhaW5JZAkAyQECCQDKAQIIBQR0aGlzBWJ5dGVzAAEAAQAIY2hhaW5JZFQBAVQACGNoYWluSWRXAQFXAANTRVACAl9fAAVXQVZFUwIFV0FWRVMAEGNvbnRyYWN0RmlsZW5hbWUCFXd4ZGFvX2NhbGN1bGF0b3IucmlkZQAFbXVsdDgAgMLXLwAGbXVsdDE4CQC2AgEAgICQu7rWrfANAA13YXZlc0RlY2ltYWxzAAgADHVzZHREZWNpbWFscwAGAQV0b1gxOAIHb3JpZ1ZhbA1vcmlnU2NhbGVNdWx0CQC8AgMJALYCAQUHb3JpZ1ZhbAUGbXVsdDE4CQC2AgEFDW9yaWdTY2FsZU11bHQBB2Zyb21YMTgCA3ZhbA9yZXN1bHRTY2FsZU11bHQJAKADAQkAvAIDBQN2YWwJALYCAQUPcmVzdWx0U2NhbGVNdWx0BQZtdWx0MTgBB3dyYXBFcnIBAXMJAKwCAgkArAICBRBjb250cmFjdEZpbGVuYW1lAgI6IAUBcwEIdGhyb3dFc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5QWRkcmVzcwkAbAYACgAABQx1c2R0RGVjaW1hbHMAAAAABQRET1dOCQCUCgIFA25pbAUNdHJlYXN1cnlWYWx1ZQECdHgBBnZlcmlmeQAJAAACBQdjaGFpbklkBQhjaGFpbklkVCknhE8=", "height": 2958486, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EgR72zW5AVazXcXRMMTG27dEZ3681ZKQazCoYHvThLPn Next: 8SzYkYqU1NM7wNRUa84T3d5jm4e4DuvJ9JW7QvQaV2NU Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 7 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let separator = "__"
5-
64 let chainId = take(drop(this.bytes, 1), 1)
75
86 let chainIdT = base58'2T'
97
108 let chainIdW = base58'2W'
11-
12-func mustAddress (i,address) = if ((i.caller == address))
13- then true
14- else throw("permission denied")
15-
16-
17-func mustThis (i) = mustAddress(i, this)
18-
199
2010 let SEP = "__"
2111
2515
2616 let mult8 = 100000000
2717
18+let mult18 = toBigInt(1000000000000000000)
19+
20+let wavesDecimals = 8
21+
22+let usdtDecimals = 6
23+
24+func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), mult18, toBigInt(origScaleMult))
25+
26+
27+func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), mult18))
28+
29+
2830 func wrapErr (s) = ((contractFilename + ": ") + s)
2931
3032
3133 func throwErr (s) = throw(wrapErr(s))
3234
35+
36+let wxAssetId = if ((chainId == chainIdW))
37+ then base58'Atqv59EYzjFGuitKVnMRk6H8FukjoV3ktPorbEys25on'
38+ else if ((chainId == chainIdT))
39+ then base58'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc'
40+ else throwErr("invalid chain id")
3341
3442 func keyCurrentPeriod () = makeString(["%s", "currentPeriod"], SEP)
3543
4149
4250
4351 func keyTreasuryValueByPeriod (period) = makeString(["%s%d", "treasuryValue", toString(period)], SEP)
52+
53+
54+func keySkinTotal (treasuryAddress) = ("skin_total_" + toString(treasuryAddress))
4455
4556
4657 func keyPowerConfigAddress () = "%s__powerConfigAddress"
113124 func getLpAssetId (factoryAddress) = fromBase58String(valueOrErrorMessage(getString(factoryAddress, keyLpAssetId()), wrapErr("invalid lp asset id")))
114125
115126
127+func getAssetInfoOrFail (assetId) = valueOrErrorMessage(assetInfo(assetId), wrapErr("invalid asset info"))
128+
129+
116130 func getAssetsBalances (targetAddress,assetIdList) = {
117131 func map (acc,nextAssetIdStr) = {
118132 let balance = if ((nextAssetIdStr == WAVES))
119- then wavesBalance(targetAddress)
120- else assetBalance(targetAddress, fromBase58String(nextAssetIdStr))
133+ then toX18(wavesBalance(targetAddress).available, pow(10, 0, wavesDecimals, 0, 0, DOWN))
134+ else {
135+ let assetId = fromBase58String(nextAssetIdStr)
136+ let assetDecimals = getAssetInfoOrFail(assetId).decimals
137+ toX18(assetBalance(targetAddress, assetId), pow(10, 0, assetDecimals, 0, 0, DOWN))
138+ }
121139 (acc :+ balance)
122140 }
123141
139157 func getAssetsPrices (poolsFactoryAddress,assetIdList) = if ((chainId == chainIdW))
140158 then {
141159 let wavesUsdtAddressStr = "3PKfrupEydU2nZAghVjZAfvCwMBkzuR1F52"
142- let wavesUsdtPrice = {
160+ let wavesUsdtPrice = parseBigIntValue({
143161 let @ = invoke(poolsFactoryAddress, "getPrice", [wavesUsdtAddressStr], nil)
144- if ($isInstanceOf(@, "Int"))
162+ if ($isInstanceOf(@, "String"))
145163 then @
146- else throw(($getType(@) + " couldn't be cast to Int"))
147- }
164+ else throw(($getType(@) + " couldn't be cast to String"))
165+ })
148166 let wavesXtnAddressStr = "3PPZWgFNRKHLvM51pwS934C8VZ7d2F4Z58g"
149- let wavesXtnPrice = {
167+ let wavesXtnPrice = parseBigIntValue({
150168 let @ = invoke(poolsFactoryAddress, "getPrice", [wavesXtnAddressStr], nil)
151- if ($isInstanceOf(@, "Int"))
169+ if ($isInstanceOf(@, "String"))
152170 then @
153- else throw(($getType(@) + " couldn't be cast to Int"))
154- }
155- let xtnUsdtPrice = fraction(wavesUsdtPrice, mult8, wavesXtnPrice)
171+ else throw(($getType(@) + " couldn't be cast to String"))
172+ })
173+ let xtnUsdtPrice = fraction(wavesUsdtPrice, mult18, wavesXtnPrice)
156174 func map (acc,nextAssetId) = {
157175 let price = match nextAssetId {
158176 case _ =>
159177 if (("2thsACuHmzDMuNezPM32wg9a3BwUzBWDeSKakgz3cw21" == $match0))
160178 then {
161179 let pwrWavesAddressStr = "3PDi7Qq8pLQYvtKyTfQuqqPUWyhoYbU957t"
162- let pwrWavesPrice = {
180+ let pwrWavesPrice = parseBigIntValue({
163181 let @ = invoke(poolsFactoryAddress, "getPrice", [pwrWavesAddressStr], nil)
164- if ($isInstanceOf(@, "Int"))
182+ if ($isInstanceOf(@, "String"))
165183 then @
166- else throw(($getType(@) + " couldn't be cast to Int"))
167- }
168- fraction(pwrWavesPrice, wavesUsdtPrice, mult8)
184+ else throw(($getType(@) + " couldn't be cast to String"))
185+ })
186+ fraction(pwrWavesPrice, wavesUsdtPrice, mult18)
169187 }
170188 else if (("Atqv59EYzjFGuitKVnMRk6H8FukjoV3ktPorbEys25on" == $match0))
171189 then {
172190 let wxWavesAddressStr = "3PFzaH2ghpwANHFgjeva83N1yxzErELx2eh"
173- let wxWavesPrice = {
191+ let wxWavesPrice = parseBigIntValue({
174192 let @ = invoke(poolsFactoryAddress, "getPrice", [wxWavesAddressStr], nil)
175- if ($isInstanceOf(@, "Int"))
193+ if ($isInstanceOf(@, "String"))
176194 then @
177- else throw(($getType(@) + " couldn't be cast to Int"))
178- }
179- fraction(wxWavesPrice, wavesUsdtPrice, mult8)
195+ else throw(($getType(@) + " couldn't be cast to String"))
196+ })
197+ fraction(wxWavesPrice, wavesUsdtPrice, mult18)
180198 }
181199 else if (("34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ" == $match0))
182200 then {
183- let usdtwxgXtnAddressStr = "3P8KMyAJCPWNcyedqrmymxaeWonvmkhGauz"
184- let usdtwxgXtnPrice = {
185- let @ = invoke(poolsFactoryAddress, "getPrice", [usdtwxgXtnAddressStr], nil)
186- if ($isInstanceOf(@, "Int"))
201+ let wavesUsdtwxgAddressStr = "3PKMVZ7kQeaREajYi8Yc25Ro6mcNw5D6QSa"
202+ let wavesUsdtwxgPrice = parseBigIntValue({
203+ let @ = invoke(poolsFactoryAddress, "getPrice", [wavesUsdtwxgAddressStr], nil)
204+ if ($isInstanceOf(@, "String"))
187205 then @
188- else throw(($getType(@) + " couldn't be cast to Int"))
189- }
190- fraction(usdtwxgXtnPrice, xtnUsdtPrice, mult8)
206+ else throw(($getType(@) + " couldn't be cast to String"))
207+ })
208+ fraction(wavesUsdtPrice, mult18, wavesUsdtwxgPrice)
191209 }
192210 else if (("6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" == $match0))
193211 then {
194212 let wavesUsdcwxgAddressStr = "3P3g3eipfG2NZKKQE8DZXt2E9tRJqii9jcX"
195- let usdcwxgXtnPrice = {
213+ let wavesUsdcwxgPrice = parseBigIntValue({
196214 let @ = invoke(poolsFactoryAddress, "getPrice", [wavesUsdcwxgAddressStr], nil)
197- if ($isInstanceOf(@, "Int"))
215+ if ($isInstanceOf(@, "String"))
198216 then @
199- else throw(($getType(@) + " couldn't be cast to Int"))
200- }
201- fraction(wavesUsdtPrice, mult8, usdcwxgXtnPrice)
217+ else throw(($getType(@) + " couldn't be cast to String"))
218+ })
219+ fraction(wavesUsdtPrice, mult18, wavesUsdcwxgPrice)
202220 }
203221 else if (("HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk" == $match0))
204222 then {
205223 let ltcwxgXtnAddressStr = "3P94wvu5gA7VhjPgAB3twaeqdwHCwNK2vsn"
206- let ltcwxgXtnPrice = {
224+ let ltcwxgXtnPrice = parseBigIntValue({
207225 let @ = invoke(poolsFactoryAddress, "getPrice", [ltcwxgXtnAddressStr], nil)
208- if ($isInstanceOf(@, "Int"))
226+ if ($isInstanceOf(@, "String"))
209227 then @
210- else throw(($getType(@) + " couldn't be cast to Int"))
228+ else throw(($getType(@) + " couldn't be cast to String"))
229+ })
230+ fraction(ltcwxgXtnPrice, xtnUsdtPrice, mult18)
231+ }
232+ else if (("474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu" == $match0))
233+ then {
234+ let ethwxgWavesAddressStr = "3P3XGTN6s292g9iwYhs3TEqJqHiffQYojuE"
235+ let ethwxgWavesPrice = parseBigIntValue({
236+ let @ = invoke(poolsFactoryAddress, "getPrice", [ethwxgWavesAddressStr], nil)
237+ if ($isInstanceOf(@, "String"))
238+ then @
239+ else throw(($getType(@) + " couldn't be cast to String"))
240+ })
241+ fraction(ethwxgWavesPrice, wavesUsdtPrice, mult18)
211242 }
212- fraction(ltcwxgXtnPrice, xtnUsdtPrice, mult8)
213- }
214- else if (("HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk" == $match0))
215- then {
216- let ethwxgXtnAddressStr = "3P3XGTN6s292g9iwYhs3TEqJqHiffQYojuE"
217- let ethwxgXtnPrice = {
218- let @ = invoke(poolsFactoryAddress, "getPrice", [ethwxgXtnAddressStr], nil)
219- if ($isInstanceOf(@, "Int"))
220- then @
221- else throw(($getType(@) + " couldn't be cast to Int"))
222- }
223- fraction(ethwxgXtnPrice, wavesUsdtPrice, mult8)
224- }
225- else if (("HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk" == $match0))
243+ else if (("8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS" == $match0))
226244 then {
227245 let btcwxgXtnAddressStr = "3PCBWDTA6jrFswd7gQgaE3Xk7gLM5RKofvp"
228- let btcwxgXtnPrice = {
246+ let btcwxgXtnPrice = parseBigIntValue({
229247 let @ = invoke(poolsFactoryAddress, "getPrice", [btcwxgXtnAddressStr], nil)
230- if ($isInstanceOf(@, "Int"))
248+ if ($isInstanceOf(@, "String"))
231249 then @
232- else throw(($getType(@) + " couldn't be cast to Int"))
233- }
234- fraction(btcwxgXtnPrice, wavesUsdtPrice, mult8)
250+ else throw(($getType(@) + " couldn't be cast to String"))
251+ })
252+ fraction(btcwxgXtnPrice, xtnUsdtPrice, mult18)
235253 }
236254 else throwErr("invalid asset id")
237255 }
259277 if (("EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc" == $match0))
260278 then {
261279 let wxUsdtAddressStr = "3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt"
262- let wxUsdtPrice = {
280+ let wxUsdtPrice = parseBigIntValue({
263281 let @ = invoke(poolsFactoryAddress, "getPrice", [wxUsdtAddressStr], nil)
264- if ($isInstanceOf(@, "Int"))
282+ if ($isInstanceOf(@, "String"))
265283 then @
266- else throw(($getType(@) + " couldn't be cast to Int"))
267- }
284+ else throw(($getType(@) + " couldn't be cast to String"))
285+ })
268286 wxUsdtPrice
269287 }
270288 else if (("A7Ksh7fXyqm1KhKAiK3bAB2aiPSitQQF6v1pyu9SS3FR" == $match0))
271289 then {
272290 let usdcUsdtAddressStr = "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA"
273- let usdcUsdtPrice = {
291+ let usdcUsdtPrice = parseBigIntValue({
274292 let @ = invoke(poolsFactoryAddress, "getPrice", [usdcUsdtAddressStr], nil)
275- if ($isInstanceOf(@, "Int"))
293+ if ($isInstanceOf(@, "String"))
276294 then @
277- else throw(($getType(@) + " couldn't be cast to Int"))
278- }
295+ else throw(($getType(@) + " couldn't be cast to String"))
296+ })
279297 usdcUsdtPrice
280298 }
281299 else if (("8Q6SE2ANebufw8JuPjJVRjZD6drD8ihjNjM8xaGUSfdR" == $match0))
315333 let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset id"))
316334 let balance = assetsBalances[index]
317335 let price = assetsPrices[index]
318- let assetValue = fraction(balance, price, mult8)
336+ let assetValue = fraction(balance, price, mult18)
319337 (acc + assetValue)
320338 }
321339
322340 let treasuryValue = {
323341 let $l = assetsStr
324342 let $s = size($l)
325- let $acc0 = 0
343+ let $acc0 = toBigInt(0)
326344 func $f0_1 ($a,$i) = if (($i >= $s))
327345 then $a
328346 else reduce($a, $l[$i])
374392 let pwrBalance = assetBalance(factoryAddress, getPowerAssetId(factoryAddress))
375393 if ((pwrBalance == pwrBalance))
376394 then {
377- let treasuryAddress = getTreasuryAddress(factoryAddress)
378- let assetsBalances = getAssetsBalances(treasuryAddress, assetsStr)
379- func map (acc,nextAssetIdStr) = {
380- let assetId = fromBase58String(nextAssetIdStr)
381- let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset balance"))
382- let balance = assetsBalances[index]
383- let amount = fraction(balance, pwrAmount, pwrBalance)
384- if ((amount > 0))
385- then $Tuple2((acc._1 :+ assetId), (acc._2 :+ amount))
386- else acc
387- }
395+ let wxdaoQuantity = getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity
396+ if ((wxdaoQuantity == wxdaoQuantity))
397+ then {
398+ let assetsBalances = getAssetsBalances(factoryAddress, assetsStr)
399+ func map (acc,nextAssetIdStr) = {
400+ let assetId = fromBase58String(nextAssetIdStr)
401+ let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset balance"))
402+ let assetDecimals = getAssetInfoOrFail(assetId).decimals
403+ let balance = fromX18(assetsBalances[index], pow(10, 0, assetDecimals, 0, 0, DOWN))
404+ let amount = fraction(balance, payment.amount, wxdaoQuantity)
405+ if ((amount > 0))
406+ then $Tuple2((acc._1 :+ assetId), (acc._2 :+ amount))
407+ else acc
408+ }
388409
389- let transfers = {
390- let $l = assetsStr
391- let $s = size($l)
392- let $acc0 = $Tuple2(nil, nil)
393- func $f0_1 ($a,$i) = if (($i >= $s))
394- then $a
395- else map($a, $l[$i])
410+ let transfers = {
411+ let $l = assetsStr
412+ let $s = size($l)
413+ let $acc0 = $Tuple2(nil, nil)
414+ func $f0_1 ($a,$i) = if (($i >= $s))
415+ then $a
416+ else map($a, $l[$i])
396417
397- func $f0_2 ($a,$i) = if (($i >= $s))
398- then $a
399- else throw("List size exceeds 6")
418+ func $f0_2 ($a,$i) = if (($i >= $s))
419+ then $a
420+ else throw("List size exceeds 6")
400421
401- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
402- }
403- if ((transfers == transfers))
404- then {
405- let additionalLockRounds = 0
406- let factoryActions = ([invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [toString(powerContractAddress(factoryAddress)), toString(factoryAddress), toString(userAddress), additionalLockRounds, getPowerAssetId(factoryAddress), pwrAmount], nil)] ++ (if ((size(transfers._1) == 0))
407- then nil
408- else [invoke(factoryAddress, "transferAssets", [userAddress.bytes, transfers._1, transfers._2], nil)]))
409- $Tuple2([Burn(paymentAssetId, payment.amount)], factoryActions)
422+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
423+ }
424+ if ((transfers == transfers))
425+ then {
426+ let additionalLockRounds = 0
427+ let factoryActions = ([invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [toString(powerContractAddress(factoryAddress)), toString(factoryAddress), toString(userAddress), additionalLockRounds, getPowerAssetId(factoryAddress), pwrAmount], nil)] ++ (if ((size(transfers._1) == 0))
428+ then nil
429+ else [invoke(factoryAddress, "transferAssets", [userAddress.bytes, transfers._1, transfers._2], nil)]))
430+ $Tuple2([Burn(paymentAssetId, payment.amount)], factoryActions)
431+ }
432+ else throw("Strict value is not equal to itself.")
410433 }
411434 else throw("Strict value is not equal to itself.")
412435 }
418441 @Callable(i)
419442 func price (callerPublicKey,args) = {
420443 let factoryAddress = i.caller
444+ let poolsFactoryAddress = getPoolsFactoryAddress(factoryAddress)
421445 let currentPeriod = valueOrErrorMessage(getInteger(factoryAddress, keyCurrentPeriod()), wrapErr("invalid current period"))
422446 let startTreasuryValue = valueOrErrorMessage(getInteger(factoryAddress, keyTreasuryValueByPeriod(currentPeriod)), wrapErr(("invalid treasury value for period " + toString(currentPeriod))))
423- let treasuryValue = calcTreasuryValue(factoryAddress)
447+ let treasuryValue = fromX18(calcTreasuryValue(factoryAddress), pow(10, 0, usdtDecimals, 0, 0, DOWN))
424448 let treasuryValueDiff = (treasuryValue - startTreasuryValue)
425- let pwrPriceRaw = getAssetsPrices(factoryAddress, [toBase58String(getPowerAssetId(factoryAddress))])[0]
426- let pwrPrice = if ((pwrPriceRaw > 0))
427- then pwrPriceRaw
449+ let pwrAssetId = getPowerAssetId(factoryAddress)
450+ let pwrPriceRaw = getAssetsPrices(poolsFactoryAddress, [toBase58String(pwrAssetId)])[0]
451+ let pwrPrice = if ((pwrPriceRaw > toBigInt(0)))
452+ then fromX18(pwrPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN))
428453 else throwErr("invalid PWR price")
429- let price = if ((0 > treasuryValueDiff))
430- then (pwrPrice / 100)
431- else ((fraction(treasuryValueDiff, 2, 10000) + pwrPrice) / 100)
454+ let treasuryAddress = getTreasuryAddress(factoryAddress)
455+ let skinTotal = valueOrElse(getInteger(powerContractAddress(factoryAddress), keySkinTotal(treasuryAddress)), 0)
456+ let pwrRemaining = (getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity / 100)
457+ let pwrAmount = (skinTotal + pwrRemaining)
458+ let factoryAddressWxBalanceRaw = getAssetsBalances(factoryAddress, [toBase58String(getLpAssetId(factoryAddress))])[0]
459+ let factoryAddressWxBalance = if ((factoryAddressWxBalanceRaw > toBigInt(0)))
460+ then fromX18(factoryAddressWxBalanceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN))
461+ else throwErr("invalid factory wx balance")
462+ let wxPriceRaw = getAssetsPrices(poolsFactoryAddress, [toBase58String(wxAssetId)])[0]
463+ let wxPrice = if ((wxPriceRaw > toBigInt(0)))
464+ then fromX18(wxPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN))
465+ else throwErr("invalid wx price")
466+ let wxdaoQuantity = getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity
467+ let price = (((pwrPrice / 100) + fraction(factoryAddressWxBalance, wxPrice, wxdaoQuantity)) + fraction(max([treasuryValueDiff, 0]), 2, (1000 * pwrAmount)))
432468 $Tuple2(nil, price)
433469 }
434470
437473 @Callable(i)
438474 func getTreasuryValue (callerPublicKey,args) = {
439475 let factoryAddress = i.caller
440- let treasuryValue = calcTreasuryValue(factoryAddress)
476+ let treasuryValue = fromX18(calcTreasuryValue(factoryAddress), pow(10, 0, usdtDecimals, 0, 0, DOWN))
441477 $Tuple2(nil, treasuryValue)
442478 }
443479
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 7 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let separator = "__"
5-
64 let chainId = take(drop(this.bytes, 1), 1)
75
86 let chainIdT = base58'2T'
97
108 let chainIdW = base58'2W'
11-
12-func mustAddress (i,address) = if ((i.caller == address))
13- then true
14- else throw("permission denied")
15-
16-
17-func mustThis (i) = mustAddress(i, this)
18-
199
2010 let SEP = "__"
2111
2212 let WAVES = "WAVES"
2313
2414 let contractFilename = "wxdao_calculator.ride"
2515
2616 let mult8 = 100000000
2717
18+let mult18 = toBigInt(1000000000000000000)
19+
20+let wavesDecimals = 8
21+
22+let usdtDecimals = 6
23+
24+func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), mult18, toBigInt(origScaleMult))
25+
26+
27+func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), mult18))
28+
29+
2830 func wrapErr (s) = ((contractFilename + ": ") + s)
2931
3032
3133 func throwErr (s) = throw(wrapErr(s))
3234
35+
36+let wxAssetId = if ((chainId == chainIdW))
37+ then base58'Atqv59EYzjFGuitKVnMRk6H8FukjoV3ktPorbEys25on'
38+ else if ((chainId == chainIdT))
39+ then base58'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc'
40+ else throwErr("invalid chain id")
3341
3442 func keyCurrentPeriod () = makeString(["%s", "currentPeriod"], SEP)
3543
3644
3745 func keyStartHeightByPeriod (period) = makeString(["%s%d", "startHeight", toString(period)], SEP)
3846
3947
4048 func keyPeriodLength () = makeString(["%s", "periodLength"], SEP)
4149
4250
4351 func keyTreasuryValueByPeriod (period) = makeString(["%s%d", "treasuryValue", toString(period)], SEP)
52+
53+
54+func keySkinTotal (treasuryAddress) = ("skin_total_" + toString(treasuryAddress))
4455
4556
4657 func keyPowerConfigAddress () = "%s__powerConfigAddress"
4758
4859
4960 func powerConfigAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyPowerConfigAddress()) {
5061 case s: String =>
5162 addressFromString(s)
5263 case _: Unit =>
5364 unit
5465 case _ =>
5566 throw("Match error")
5667 }, wrapErr("invalid power config address"))
5768
5869
5970 func keyPowerAssetId () = "powerAssetId"
6071
6172
6273 func getPowerAssetId (factoryAddress) = fromBase58String(valueOrErrorMessage(getString(powerConfigAddress(factoryAddress), keyPowerAssetId()), wrapErr("invalid power asset id")))
6374
6475
6576 func keyPowerContractAddress () = "%s__powerContractAddress"
6677
6778
6879 func powerContractAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyPowerContractAddress()) {
6980 case s: String =>
7081 addressFromString(s)
7182 case _: Unit =>
7283 unit
7384 case _ =>
7485 throw("Match error")
7586 }, wrapErr("invalid power contract address"))
7687
7788
7889 func keyPoolsFactoryAddress () = "%s__poolsFactoryAddress"
7990
8091
8192 func getPoolsFactoryAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyPoolsFactoryAddress()) {
8293 case s: String =>
8394 addressFromString(s)
8495 case _: Unit =>
8596 unit
8697 case _ =>
8798 throw("Match error")
8899 }, wrapErr("invalid pools factory address"))
89100
90101
91102 func keyTreasuryAddress () = "%s__treasuryAddress"
92103
93104
94105 func getTreasuryAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyTreasuryAddress()) {
95106 case s: String =>
96107 addressFromString(s)
97108 case _: Unit =>
98109 unit
99110 case _ =>
100111 throw("Match error")
101112 }, wrapErr("invalid treasury address"))
102113
103114
104115 func keyAssets () = "%s__assets"
105116
106117
107118 func getAssetsStr (factoryAddress) = valueOrErrorMessage(getString(factoryAddress, keyAssets()), wrapErr("invalid assets"))
108119
109120
110121 func keyLpAssetId () = "%s__lpAssetId"
111122
112123
113124 func getLpAssetId (factoryAddress) = fromBase58String(valueOrErrorMessage(getString(factoryAddress, keyLpAssetId()), wrapErr("invalid lp asset id")))
114125
115126
127+func getAssetInfoOrFail (assetId) = valueOrErrorMessage(assetInfo(assetId), wrapErr("invalid asset info"))
128+
129+
116130 func getAssetsBalances (targetAddress,assetIdList) = {
117131 func map (acc,nextAssetIdStr) = {
118132 let balance = if ((nextAssetIdStr == WAVES))
119- then wavesBalance(targetAddress)
120- else assetBalance(targetAddress, fromBase58String(nextAssetIdStr))
133+ then toX18(wavesBalance(targetAddress).available, pow(10, 0, wavesDecimals, 0, 0, DOWN))
134+ else {
135+ let assetId = fromBase58String(nextAssetIdStr)
136+ let assetDecimals = getAssetInfoOrFail(assetId).decimals
137+ toX18(assetBalance(targetAddress, assetId), pow(10, 0, assetDecimals, 0, 0, DOWN))
138+ }
121139 (acc :+ balance)
122140 }
123141
124142 let $l = assetIdList
125143 let $s = size($l)
126144 let $acc0 = nil
127145 func $f0_1 ($a,$i) = if (($i >= $s))
128146 then $a
129147 else map($a, $l[$i])
130148
131149 func $f0_2 ($a,$i) = if (($i >= $s))
132150 then $a
133151 else throw("List size exceeds 10")
134152
135153 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
136154 }
137155
138156
139157 func getAssetsPrices (poolsFactoryAddress,assetIdList) = if ((chainId == chainIdW))
140158 then {
141159 let wavesUsdtAddressStr = "3PKfrupEydU2nZAghVjZAfvCwMBkzuR1F52"
142- let wavesUsdtPrice = {
160+ let wavesUsdtPrice = parseBigIntValue({
143161 let @ = invoke(poolsFactoryAddress, "getPrice", [wavesUsdtAddressStr], nil)
144- if ($isInstanceOf(@, "Int"))
162+ if ($isInstanceOf(@, "String"))
145163 then @
146- else throw(($getType(@) + " couldn't be cast to Int"))
147- }
164+ else throw(($getType(@) + " couldn't be cast to String"))
165+ })
148166 let wavesXtnAddressStr = "3PPZWgFNRKHLvM51pwS934C8VZ7d2F4Z58g"
149- let wavesXtnPrice = {
167+ let wavesXtnPrice = parseBigIntValue({
150168 let @ = invoke(poolsFactoryAddress, "getPrice", [wavesXtnAddressStr], nil)
151- if ($isInstanceOf(@, "Int"))
169+ if ($isInstanceOf(@, "String"))
152170 then @
153- else throw(($getType(@) + " couldn't be cast to Int"))
154- }
155- let xtnUsdtPrice = fraction(wavesUsdtPrice, mult8, wavesXtnPrice)
171+ else throw(($getType(@) + " couldn't be cast to String"))
172+ })
173+ let xtnUsdtPrice = fraction(wavesUsdtPrice, mult18, wavesXtnPrice)
156174 func map (acc,nextAssetId) = {
157175 let price = match nextAssetId {
158176 case _ =>
159177 if (("2thsACuHmzDMuNezPM32wg9a3BwUzBWDeSKakgz3cw21" == $match0))
160178 then {
161179 let pwrWavesAddressStr = "3PDi7Qq8pLQYvtKyTfQuqqPUWyhoYbU957t"
162- let pwrWavesPrice = {
180+ let pwrWavesPrice = parseBigIntValue({
163181 let @ = invoke(poolsFactoryAddress, "getPrice", [pwrWavesAddressStr], nil)
164- if ($isInstanceOf(@, "Int"))
182+ if ($isInstanceOf(@, "String"))
165183 then @
166- else throw(($getType(@) + " couldn't be cast to Int"))
167- }
168- fraction(pwrWavesPrice, wavesUsdtPrice, mult8)
184+ else throw(($getType(@) + " couldn't be cast to String"))
185+ })
186+ fraction(pwrWavesPrice, wavesUsdtPrice, mult18)
169187 }
170188 else if (("Atqv59EYzjFGuitKVnMRk6H8FukjoV3ktPorbEys25on" == $match0))
171189 then {
172190 let wxWavesAddressStr = "3PFzaH2ghpwANHFgjeva83N1yxzErELx2eh"
173- let wxWavesPrice = {
191+ let wxWavesPrice = parseBigIntValue({
174192 let @ = invoke(poolsFactoryAddress, "getPrice", [wxWavesAddressStr], nil)
175- if ($isInstanceOf(@, "Int"))
193+ if ($isInstanceOf(@, "String"))
176194 then @
177- else throw(($getType(@) + " couldn't be cast to Int"))
178- }
179- fraction(wxWavesPrice, wavesUsdtPrice, mult8)
195+ else throw(($getType(@) + " couldn't be cast to String"))
196+ })
197+ fraction(wxWavesPrice, wavesUsdtPrice, mult18)
180198 }
181199 else if (("34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ" == $match0))
182200 then {
183- let usdtwxgXtnAddressStr = "3P8KMyAJCPWNcyedqrmymxaeWonvmkhGauz"
184- let usdtwxgXtnPrice = {
185- let @ = invoke(poolsFactoryAddress, "getPrice", [usdtwxgXtnAddressStr], nil)
186- if ($isInstanceOf(@, "Int"))
201+ let wavesUsdtwxgAddressStr = "3PKMVZ7kQeaREajYi8Yc25Ro6mcNw5D6QSa"
202+ let wavesUsdtwxgPrice = parseBigIntValue({
203+ let @ = invoke(poolsFactoryAddress, "getPrice", [wavesUsdtwxgAddressStr], nil)
204+ if ($isInstanceOf(@, "String"))
187205 then @
188- else throw(($getType(@) + " couldn't be cast to Int"))
189- }
190- fraction(usdtwxgXtnPrice, xtnUsdtPrice, mult8)
206+ else throw(($getType(@) + " couldn't be cast to String"))
207+ })
208+ fraction(wavesUsdtPrice, mult18, wavesUsdtwxgPrice)
191209 }
192210 else if (("6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" == $match0))
193211 then {
194212 let wavesUsdcwxgAddressStr = "3P3g3eipfG2NZKKQE8DZXt2E9tRJqii9jcX"
195- let usdcwxgXtnPrice = {
213+ let wavesUsdcwxgPrice = parseBigIntValue({
196214 let @ = invoke(poolsFactoryAddress, "getPrice", [wavesUsdcwxgAddressStr], nil)
197- if ($isInstanceOf(@, "Int"))
215+ if ($isInstanceOf(@, "String"))
198216 then @
199- else throw(($getType(@) + " couldn't be cast to Int"))
200- }
201- fraction(wavesUsdtPrice, mult8, usdcwxgXtnPrice)
217+ else throw(($getType(@) + " couldn't be cast to String"))
218+ })
219+ fraction(wavesUsdtPrice, mult18, wavesUsdcwxgPrice)
202220 }
203221 else if (("HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk" == $match0))
204222 then {
205223 let ltcwxgXtnAddressStr = "3P94wvu5gA7VhjPgAB3twaeqdwHCwNK2vsn"
206- let ltcwxgXtnPrice = {
224+ let ltcwxgXtnPrice = parseBigIntValue({
207225 let @ = invoke(poolsFactoryAddress, "getPrice", [ltcwxgXtnAddressStr], nil)
208- if ($isInstanceOf(@, "Int"))
226+ if ($isInstanceOf(@, "String"))
209227 then @
210- else throw(($getType(@) + " couldn't be cast to Int"))
228+ else throw(($getType(@) + " couldn't be cast to String"))
229+ })
230+ fraction(ltcwxgXtnPrice, xtnUsdtPrice, mult18)
231+ }
232+ else if (("474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu" == $match0))
233+ then {
234+ let ethwxgWavesAddressStr = "3P3XGTN6s292g9iwYhs3TEqJqHiffQYojuE"
235+ let ethwxgWavesPrice = parseBigIntValue({
236+ let @ = invoke(poolsFactoryAddress, "getPrice", [ethwxgWavesAddressStr], nil)
237+ if ($isInstanceOf(@, "String"))
238+ then @
239+ else throw(($getType(@) + " couldn't be cast to String"))
240+ })
241+ fraction(ethwxgWavesPrice, wavesUsdtPrice, mult18)
211242 }
212- fraction(ltcwxgXtnPrice, xtnUsdtPrice, mult8)
213- }
214- else if (("HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk" == $match0))
215- then {
216- let ethwxgXtnAddressStr = "3P3XGTN6s292g9iwYhs3TEqJqHiffQYojuE"
217- let ethwxgXtnPrice = {
218- let @ = invoke(poolsFactoryAddress, "getPrice", [ethwxgXtnAddressStr], nil)
219- if ($isInstanceOf(@, "Int"))
220- then @
221- else throw(($getType(@) + " couldn't be cast to Int"))
222- }
223- fraction(ethwxgXtnPrice, wavesUsdtPrice, mult8)
224- }
225- else if (("HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk" == $match0))
243+ else if (("8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS" == $match0))
226244 then {
227245 let btcwxgXtnAddressStr = "3PCBWDTA6jrFswd7gQgaE3Xk7gLM5RKofvp"
228- let btcwxgXtnPrice = {
246+ let btcwxgXtnPrice = parseBigIntValue({
229247 let @ = invoke(poolsFactoryAddress, "getPrice", [btcwxgXtnAddressStr], nil)
230- if ($isInstanceOf(@, "Int"))
248+ if ($isInstanceOf(@, "String"))
231249 then @
232- else throw(($getType(@) + " couldn't be cast to Int"))
233- }
234- fraction(btcwxgXtnPrice, wavesUsdtPrice, mult8)
250+ else throw(($getType(@) + " couldn't be cast to String"))
251+ })
252+ fraction(btcwxgXtnPrice, xtnUsdtPrice, mult18)
235253 }
236254 else throwErr("invalid asset id")
237255 }
238256 (acc :+ price)
239257 }
240258
241259 let $l = assetIdList
242260 let $s = size($l)
243261 let $acc0 = nil
244262 func $f0_1 ($a,$i) = if (($i >= $s))
245263 then $a
246264 else map($a, $l[$i])
247265
248266 func $f0_2 ($a,$i) = if (($i >= $s))
249267 then $a
250268 else throw("List size exceeds 10")
251269
252270 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
253271 }
254272 else if ((chainId == chainIdT))
255273 then {
256274 func map (acc,nextAssetId) = {
257275 let price = match nextAssetId {
258276 case _ =>
259277 if (("EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc" == $match0))
260278 then {
261279 let wxUsdtAddressStr = "3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt"
262- let wxUsdtPrice = {
280+ let wxUsdtPrice = parseBigIntValue({
263281 let @ = invoke(poolsFactoryAddress, "getPrice", [wxUsdtAddressStr], nil)
264- if ($isInstanceOf(@, "Int"))
282+ if ($isInstanceOf(@, "String"))
265283 then @
266- else throw(($getType(@) + " couldn't be cast to Int"))
267- }
284+ else throw(($getType(@) + " couldn't be cast to String"))
285+ })
268286 wxUsdtPrice
269287 }
270288 else if (("A7Ksh7fXyqm1KhKAiK3bAB2aiPSitQQF6v1pyu9SS3FR" == $match0))
271289 then {
272290 let usdcUsdtAddressStr = "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA"
273- let usdcUsdtPrice = {
291+ let usdcUsdtPrice = parseBigIntValue({
274292 let @ = invoke(poolsFactoryAddress, "getPrice", [usdcUsdtAddressStr], nil)
275- if ($isInstanceOf(@, "Int"))
293+ if ($isInstanceOf(@, "String"))
276294 then @
277- else throw(($getType(@) + " couldn't be cast to Int"))
278- }
295+ else throw(($getType(@) + " couldn't be cast to String"))
296+ })
279297 usdcUsdtPrice
280298 }
281299 else if (("8Q6SE2ANebufw8JuPjJVRjZD6drD8ihjNjM8xaGUSfdR" == $match0))
282300 then {
283301 let price = 100000000
284302 price
285303 }
286304 else throwErr("invalid asset id")
287305 }
288306 (acc :+ price)
289307 }
290308
291309 let $l = assetIdList
292310 let $s = size($l)
293311 let $acc0 = nil
294312 func $f0_1 ($a,$i) = if (($i >= $s))
295313 then $a
296314 else map($a, $l[$i])
297315
298316 func $f0_2 ($a,$i) = if (($i >= $s))
299317 then $a
300318 else throw("List size exceeds 10")
301319
302320 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
303321 }
304322 else throwErr("invalid chain id")
305323
306324
307325 func calcTreasuryValue (factoryAddress) = {
308326 let treasuryAddress = getTreasuryAddress(factoryAddress)
309327 let poolsFactoryAddress = getPoolsFactoryAddress(factoryAddress)
310328 let assetsStr = split(getAssetsStr(factoryAddress), SEP)
311329 let assetsBalances = getAssetsBalances(treasuryAddress, assetsStr)
312330 let assetsPrices = getAssetsPrices(poolsFactoryAddress, assetsStr)
313331 func reduce (acc,nextAssetIdStr) = {
314332 let assetId = fromBase58String(nextAssetIdStr)
315333 let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset id"))
316334 let balance = assetsBalances[index]
317335 let price = assetsPrices[index]
318- let assetValue = fraction(balance, price, mult8)
336+ let assetValue = fraction(balance, price, mult18)
319337 (acc + assetValue)
320338 }
321339
322340 let treasuryValue = {
323341 let $l = assetsStr
324342 let $s = size($l)
325- let $acc0 = 0
343+ let $acc0 = toBigInt(0)
326344 func $f0_1 ($a,$i) = if (($i >= $s))
327345 then $a
328346 else reduce($a, $l[$i])
329347
330348 func $f0_2 ($a,$i) = if (($i >= $s))
331349 then $a
332350 else throw("List size exceeds 10")
333351
334352 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
335353 }
336354 treasuryValue
337355 }
338356
339357
340358 @Callable(i)
341359 func withdraw (args) = {
342360 let recipient = addressFromStringValue(args[0])
343361 let amount = parseIntValue(args[1])
344362 let result = invoke(i.caller, "transferWaves", [recipient.bytes, amount], nil)
345363 $Tuple2(nil, result)
346364 }
347365
348366
349367
350368 @Callable(i)
351369 func setIntParam (args) = {
352370 let key = args[0]
353371 let val = parseIntValue(args[1])
354372 let result = invoke(i.caller, "integerEntry", [key, val], nil)
355373 $Tuple2(nil, result)
356374 }
357375
358376
359377
360378 @Callable(i)
361379 func swap (callerPublicKey,args) = {
362380 let factoryAddress = i.caller
363381 let userAddress = addressFromPublicKey(callerPublicKey)
364382 let payment = if ((size(i.payments) == 1))
365383 then i.payments[0]
366384 else throwErr("1 payment is required")
367385 let err = wrapErr("invalid payment asset id")
368386 let paymentAssetId = if ((valueOrErrorMessage(payment.assetId, err) == getLpAssetId(factoryAddress)))
369387 then value(payment.assetId)
370388 else throwErr(err)
371389 let pwrPrice = 100
372390 let pwrAmount = (payment.amount / pwrPrice)
373391 let assetsStr = split(getAssetsStr(factoryAddress), SEP)
374392 let pwrBalance = assetBalance(factoryAddress, getPowerAssetId(factoryAddress))
375393 if ((pwrBalance == pwrBalance))
376394 then {
377- let treasuryAddress = getTreasuryAddress(factoryAddress)
378- let assetsBalances = getAssetsBalances(treasuryAddress, assetsStr)
379- func map (acc,nextAssetIdStr) = {
380- let assetId = fromBase58String(nextAssetIdStr)
381- let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset balance"))
382- let balance = assetsBalances[index]
383- let amount = fraction(balance, pwrAmount, pwrBalance)
384- if ((amount > 0))
385- then $Tuple2((acc._1 :+ assetId), (acc._2 :+ amount))
386- else acc
387- }
395+ let wxdaoQuantity = getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity
396+ if ((wxdaoQuantity == wxdaoQuantity))
397+ then {
398+ let assetsBalances = getAssetsBalances(factoryAddress, assetsStr)
399+ func map (acc,nextAssetIdStr) = {
400+ let assetId = fromBase58String(nextAssetIdStr)
401+ let index = valueOrErrorMessage(indexOf(assetsStr, nextAssetIdStr), wrapErr("invalid asset balance"))
402+ let assetDecimals = getAssetInfoOrFail(assetId).decimals
403+ let balance = fromX18(assetsBalances[index], pow(10, 0, assetDecimals, 0, 0, DOWN))
404+ let amount = fraction(balance, payment.amount, wxdaoQuantity)
405+ if ((amount > 0))
406+ then $Tuple2((acc._1 :+ assetId), (acc._2 :+ amount))
407+ else acc
408+ }
388409
389- let transfers = {
390- let $l = assetsStr
391- let $s = size($l)
392- let $acc0 = $Tuple2(nil, nil)
393- func $f0_1 ($a,$i) = if (($i >= $s))
394- then $a
395- else map($a, $l[$i])
410+ let transfers = {
411+ let $l = assetsStr
412+ let $s = size($l)
413+ let $acc0 = $Tuple2(nil, nil)
414+ func $f0_1 ($a,$i) = if (($i >= $s))
415+ then $a
416+ else map($a, $l[$i])
396417
397- func $f0_2 ($a,$i) = if (($i >= $s))
398- then $a
399- else throw("List size exceeds 6")
418+ func $f0_2 ($a,$i) = if (($i >= $s))
419+ then $a
420+ else throw("List size exceeds 6")
400421
401- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
402- }
403- if ((transfers == transfers))
404- then {
405- let additionalLockRounds = 0
406- let factoryActions = ([invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [toString(powerContractAddress(factoryAddress)), toString(factoryAddress), toString(userAddress), additionalLockRounds, getPowerAssetId(factoryAddress), pwrAmount], nil)] ++ (if ((size(transfers._1) == 0))
407- then nil
408- else [invoke(factoryAddress, "transferAssets", [userAddress.bytes, transfers._1, transfers._2], nil)]))
409- $Tuple2([Burn(paymentAssetId, payment.amount)], factoryActions)
422+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
423+ }
424+ if ((transfers == transfers))
425+ then {
426+ let additionalLockRounds = 0
427+ let factoryActions = ([invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [toString(powerContractAddress(factoryAddress)), toString(factoryAddress), toString(userAddress), additionalLockRounds, getPowerAssetId(factoryAddress), pwrAmount], nil)] ++ (if ((size(transfers._1) == 0))
428+ then nil
429+ else [invoke(factoryAddress, "transferAssets", [userAddress.bytes, transfers._1, transfers._2], nil)]))
430+ $Tuple2([Burn(paymentAssetId, payment.amount)], factoryActions)
431+ }
432+ else throw("Strict value is not equal to itself.")
410433 }
411434 else throw("Strict value is not equal to itself.")
412435 }
413436 else throw("Strict value is not equal to itself.")
414437 }
415438
416439
417440
418441 @Callable(i)
419442 func price (callerPublicKey,args) = {
420443 let factoryAddress = i.caller
444+ let poolsFactoryAddress = getPoolsFactoryAddress(factoryAddress)
421445 let currentPeriod = valueOrErrorMessage(getInteger(factoryAddress, keyCurrentPeriod()), wrapErr("invalid current period"))
422446 let startTreasuryValue = valueOrErrorMessage(getInteger(factoryAddress, keyTreasuryValueByPeriod(currentPeriod)), wrapErr(("invalid treasury value for period " + toString(currentPeriod))))
423- let treasuryValue = calcTreasuryValue(factoryAddress)
447+ let treasuryValue = fromX18(calcTreasuryValue(factoryAddress), pow(10, 0, usdtDecimals, 0, 0, DOWN))
424448 let treasuryValueDiff = (treasuryValue - startTreasuryValue)
425- let pwrPriceRaw = getAssetsPrices(factoryAddress, [toBase58String(getPowerAssetId(factoryAddress))])[0]
426- let pwrPrice = if ((pwrPriceRaw > 0))
427- then pwrPriceRaw
449+ let pwrAssetId = getPowerAssetId(factoryAddress)
450+ let pwrPriceRaw = getAssetsPrices(poolsFactoryAddress, [toBase58String(pwrAssetId)])[0]
451+ let pwrPrice = if ((pwrPriceRaw > toBigInt(0)))
452+ then fromX18(pwrPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN))
428453 else throwErr("invalid PWR price")
429- let price = if ((0 > treasuryValueDiff))
430- then (pwrPrice / 100)
431- else ((fraction(treasuryValueDiff, 2, 10000) + pwrPrice) / 100)
454+ let treasuryAddress = getTreasuryAddress(factoryAddress)
455+ let skinTotal = valueOrElse(getInteger(powerContractAddress(factoryAddress), keySkinTotal(treasuryAddress)), 0)
456+ let pwrRemaining = (getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity / 100)
457+ let pwrAmount = (skinTotal + pwrRemaining)
458+ let factoryAddressWxBalanceRaw = getAssetsBalances(factoryAddress, [toBase58String(getLpAssetId(factoryAddress))])[0]
459+ let factoryAddressWxBalance = if ((factoryAddressWxBalanceRaw > toBigInt(0)))
460+ then fromX18(factoryAddressWxBalanceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN))
461+ else throwErr("invalid factory wx balance")
462+ let wxPriceRaw = getAssetsPrices(poolsFactoryAddress, [toBase58String(wxAssetId)])[0]
463+ let wxPrice = if ((wxPriceRaw > toBigInt(0)))
464+ then fromX18(wxPriceRaw, pow(10, 0, usdtDecimals, 0, 0, DOWN))
465+ else throwErr("invalid wx price")
466+ let wxdaoQuantity = getAssetInfoOrFail(getLpAssetId(factoryAddress)).quantity
467+ let price = (((pwrPrice / 100) + fraction(factoryAddressWxBalance, wxPrice, wxdaoQuantity)) + fraction(max([treasuryValueDiff, 0]), 2, (1000 * pwrAmount)))
432468 $Tuple2(nil, price)
433469 }
434470
435471
436472
437473 @Callable(i)
438474 func getTreasuryValue (callerPublicKey,args) = {
439475 let factoryAddress = i.caller
440- let treasuryValue = calcTreasuryValue(factoryAddress)
476+ let treasuryValue = fromX18(calcTreasuryValue(factoryAddress), pow(10, 0, usdtDecimals, 0, 0, DOWN))
441477 $Tuple2(nil, treasuryValue)
442478 }
443479
444480
445481 @Verifier(tx)
446482 func verify () = (chainId == chainIdT)
447483

github/deemru/w8io/026f985 
84.38 ms