tx · 34zHoGHvjSXGZvqWXDCh9bsrgQVah1DfVqgKrW1ZYwzM

3MuAPY3jP4q2AoNYX27B5BU9EoLU77mr7pS:  -0.02000000 Waves

2022.02.24 15:41 [1937740] smart account 3MuAPY3jP4q2AoNYX27B5BU9EoLU77mr7pS > SELF 0.00000000 Waves

{ "type": 13, "id": "34zHoGHvjSXGZvqWXDCh9bsrgQVah1DfVqgKrW1ZYwzM", "fee": 2000000, "feeAssetId": null, "timestamp": 1645706574899, "version": 1, "sender": "3MuAPY3jP4q2AoNYX27B5BU9EoLU77mr7pS", "senderPublicKey": "rqCnkHfz5ix6HNKiVvYE3URUtLs6f2nWzt4hpdGGQdm", "proofs": [ "3hW9VX9Ex3M9BuDTVDbWbw1qtHYn8YE1JEfSa3s5Wu1BjY2bMwZjt2gRWzrAat2gKbbkN8RpBApKVbADorqCpyZW" ], "script": "base64:AAIFAAAAAAAAADgIAhIFCgMICAESAwoBARIHCgUBAQEBARIICgYBAQEBAQESABIDCgEIEgASBAoCAQESBgoEAQEBAQAAADcAAAAAB1dBVkVMRVQAAAAAAAX14QAAAAAABVBBVUxJAAAAAAAAD0JAAAAAAAhCSUdQQVVMSQkAATYAAAABAAAAAAAAD0JAAAAAAAhQUklDRUxFVAAAAAAAAA9CQAAAAAAETVVMVAAAAAAABfXhAAAAAAAJQklHTVVMVDE2CQABNgAAAAEAACOG8m/BAAAAAAAACU1VTFRTQ0FMRQAAAAAAAAAACAAAAAAHU0NBTEUxNgAAAAAAAAAAEAAAAAADU0VQAgAAAAJfXwAAAAAFSEFMRjgAAAAAAAL68IAAAAAAC0VVTEVSTlVNQkVSAAAAAAAQM8TWAAAAAAZzY2FsZTYAAAAAAAAPQkAAAAAADHNjYWxlNkJpZ0ludAkAATYAAAABAAAAAAAAD0JAAQAAABJrZXlOZXV0cmlub0FkZHJlc3MAAAAAAgAAAB0lcyVzX19jb25maWdfX25ldXRyaW5vQWRkcmVzcwEAAAATa2V5U3dhcEFtb3VudEFQYXJhbQA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xUBQAAAAhoYWxmTGlmZQAAAAAAAAAACAAAAAAAAAAACAUAAAAGSEFMRlVQBQAAAARNVUxUBAAAAAF2CQAAawAAAAMJAABkAAAAAgUAAAAHYW1vdW50MQUAAAAHYW1vdW50MgUAAAAETVVMVAkAAGQAAAACBQAAAAdhbW91bnQxBQAAAAF3CQAFFAAAAAIFAAAAA25pbAkAAGQAAAACBQAAAAdoZWlnaHQxCQAAaQAAAAIJAABlAAAAAgUAAAAFSEFMRjgJAABoAAAAAgUAAAAIaGFsZkxpZmUJAABtAAAABgUAAAABdgAAAAAAAAAACAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAACAUAAAAGSEFMRlVQBQAAAARNVUxUAAAAAAXNCyo=", "chainId": 84, "height": 1937740, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Aa5vrUS7PeT22UnfNs7jkUM23C2vz7SuCvdo67S8pTuA Next: BjQC1wRfmE3xTrYs2ZdEMVZJCUXqpeiBRqVKZ9AHgoVU Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let neutrinoContract = addressFromStringValue("3Mzbx34Ex5rRbn39vUHx9kiwh3nneF8S5we")
5-
6-func getNumberByKey (key) = valueOrElse(getInteger(neutrinoContract, key), 0)
7-
8-
9-func getStringByKey (key) = valueOrElse(getString(neutrinoContract, key), "")
10-
11-
12-func getBoolByKey (key) = valueOrElse(getBoolean(neutrinoContract, key), false)
13-
14-
15-func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(addressFromStringValue(address), key), 0)
16-
17-
18-func getStringByAddressAndKey (address,key) = valueOrElse(getString(addressFromStringValue(address), key), "")
19-
20-
21-func getBoolByAddressAndKey (address,key) = valueOrElse(getBoolean(addressFromStringValue(address), key), false)
22-
23-
24-let SENDTXEXPIRE = 30
25-
26-let LISTSPLITSYMBOL = "_"
27-
28-let LISTDATASYMBOL = "+"
29-
304 let WAVELET = 100000000
315
326 let PAULI = 1000000
7+
8+let BIGPAULI = toBigInt(1000000)
339
3410 let PRICELET = 1000000
3511
3612 let MULT = 100000000
3713
14+let BIGMULT16 = toBigInt(10000000000000000)
15+
3816 let MULTSCALE = 8
3917
40-let NeutrinoAssetIdKey = "neutrino_asset_id"
18+let SCALE16 = 16
4119
42-let BondAssetIdKey = "bond_asset_id"
20+let SEP = "__"
4321
44-let AuctionContractKey = "auction_contract"
22+let HALF8 = 50000000
4523
46-let LiquidationContractKey = "liquidation_contract"
24+let EULERNUMBER = 271828182
4725
48-let RPDContractKey = "rpd_contract"
26+let scale6 = 1000000
4927
50-let ContolContractKey = "control_contract"
28+let scale6BigInt = toBigInt(1000000)
5129
52-let BalanceWavesLockIntervalKey = "balance_waves_lock_interval"
53-
54-let BalanceNeutrinoLockIntervalKey = "balance_neutrino_lock_interval"
55-
56-let MinWavesSwapAmountKey = "min_waves_swap_amount"
57-
58-let MinNeutrinoSwapAmountKey = "min_neutrino_swap_amount"
59-
60-let NodeOracleProviderPubKeyKey = "node_oracle_provider"
61-
62-let RPDBalanceKey = "rpd_balance"
63-
64-func getRPDContractBalanceKey (assetId) = ((RPDBalanceKey + "_") + toBase58String(assetId))
30+func keyNeutrinoAddress () = "%s%s__config__neutrinoAddress"
6531
6632
67-let PriceKey = "price"
68-
69-let PriceIndexKey = "price_index"
70-
71-let IsBlockedKey = "is_blocked"
72-
73-func getPriceHistoryKey (block) = ((PriceKey + "_") + toString(block))
33+func keySwapAmountAParam () = "%s%s__config__swapAParam"
7434
7535
76-func getHeightPriceByIndexKey (index) = ((PriceIndexKey + "_") + toString(index))
36+func keyNeutrinoAssetId () = "neutrino_asset_id"
7737
7838
79-let BalanceLockedkKey = "balance_lock_"
80-
81-let WavesLockedBalanceKey = (BalanceLockedkKey + "waves")
82-
83-let NeutrinoLockedBalanceKey = (BalanceLockedkKey + "neutrino")
84-
85-func getRPDSnapshotContractBalanceKey (count,assetId) = ((((RPDBalanceKey + "_") + toBase58String(assetId)) + "_") + toString(count))
39+func keyLiquidationContractAddress () = "liquidation_contract"
8640
8741
88-func getCancelLeaseTxReserveFeeKey (hash) = (("cancel_lease_tx_reserve_fee" + "_") + hash)
42+func keyRPDContract () = "rpd_contract"
8943
9044
91-func getWavesLockedBalanceKey (owner) = ((WavesLockedBalanceKey + "_") + owner)
45+func keyAuctionContract () = "auction_contract"
9246
9347
94-func getNeutrinoLockedBalanceKey (owner) = ((NeutrinoLockedBalanceKey + "_") + owner)
48+func keyContolContract () = "control_contract"
9549
9650
97-func getBalanceUnlockBlockKey (owner) = ("balance_unlock_block_" + owner)
51+func keyBondAssetId () = "bond_asset_id"
9852
9953
100-func getRPDProfitKey (count) = (("rpd_profit" + "_") + toString(count))
54+func keyBalanceLocked () = "balance_lock_"
55+
56+
57+func keyWavesLockedBalance () = (keyBalanceLocked() + "waves")
58+
59+
60+func keyNeutrinoLockedBalance () = (keyBalanceLocked() + "neutrino")
61+
62+
63+func keyMinWavesSwapAmount () = "min_waves_swap_amount"
64+
65+
66+func keyMinNeutrinoSwapAmount () = "min_neutrino_swap_amount"
67+
68+
69+func keyWavesOutFeePart () = "wavesOut_swap_feePart"
70+
71+
72+func keyNeutrinoOutFeePart () = "neutrinoOut_swap_feePart"
73+
74+
75+func keyNsbtLockContract () = "%s__nsbtLockContract"
76+
77+
78+func keyQuickSwapLimitDuration () = "%s__quickSwapLimitDuration"
79+
80+
81+func keyUserLastQuickSwapHeight (userAddress) = makeString(["%s%s", "userLastQuickSwapHeight", userAddress], SEP)
82+
83+
84+func keyQuickSwapUserSpentInPeriod (userAddress) = makeString(["%s%s", "quickSwapUserSpentInPeriod", userAddress], SEP)
85+
86+
87+func keyPrice () = "price"
88+
89+
90+func keyHalfLife () = "%s__halfLife"
91+
92+
93+func keyLockParamUserAmount (userAddress) = makeString(["%s%s%s", "paramByUser", userAddress, "amount"], SEP)
94+
95+
96+func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
97+
98+
99+func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
100+
101+
102+func getBoolOrFail (address,key) = valueOrErrorMessage(getBoolean(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
101103
102104
103105 func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, PRICELET, price), WAVELET, PAULI)
106108 func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, PRICELET), PAULI, WAVELET)
107109
108110
109-func convertWavesToBond (amount,price) = convertWavesToNeutrino(amount, price)
111+func toX16 (origVal,origScaleMult) = fraction(toBigInt(origVal), BIGMULT16, toBigInt(origScaleMult))
110112
111113
112-func convertJsonArrayToList (jsonArray) = split(jsonArray, ",")
114+func fromX16 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), BIGMULT16))
113115
114116
115-let liquidationContract = getStringByKey(LiquidationContractKey)
117+func asAnyList (val) = match val {
118+ case valAnyLyst: List[Any] =>
119+ valAnyLyst
120+ case _ =>
121+ throw("fail to cast into List[Any]")
122+}
116123
117-let neutrinoAssetIdString = getStringByKey(NeutrinoAssetIdKey)
124+
125+func asInt (val) = match val {
126+ case valInt: Int =>
127+ valInt
128+ case _ =>
129+ throw("fail to cast into Int")
130+}
131+
132+
133+func asString (val) = match val {
134+ case valStr: String =>
135+ valStr
136+ case _ =>
137+ throw("fail to cast into String")
138+}
139+
140+
141+let neutrinoContract = addressFromStringValue(getStringOrFail(this, keyNeutrinoAddress()))
142+
143+let controlContract = addressFromStringValue(getStringOrFail(neutrinoContract, keyContolContract()))
144+
145+let auctionContract = addressFromStringValue(getStringOrFail(neutrinoContract, keyAuctionContract()))
146+
147+let liquidationContract = getStringOrFail(neutrinoContract, keyLiquidationContractAddress())
148+
149+let rpdContract = getStringOrFail(neutrinoContract, keyRPDContract())
150+
151+let nsbtStakingContract = addressFromStringValue(getStringOrFail(this, keyNsbtLockContract()))
152+
153+let neutrinoAssetIdString = getStringOrFail(neutrinoContract, keyNeutrinoAssetId())
118154
119155 let neutrinoAssetId = fromBase58String(neutrinoAssetIdString)
120156
121-let auctionContract = getStringByKey(AuctionContractKey)
122-
123-let rpdContract = getStringByKey(RPDContractKey)
124-
125-let controlContract = getStringByKey(ContolContractKey)
126-
127-let priceIndex = getNumberByAddressAndKey(controlContract, PriceIndexKey)
128-
129-let isBlocked = getBoolByAddressAndKey(controlContract, IsBlockedKey)
130-
131-let nodeOracleProviderPubKey = fromBase58String(getStringByKey(NodeOracleProviderPubKeyKey))
132-
133-let balanceWavesLockInterval = getNumberByKey(BalanceWavesLockIntervalKey)
134-
135-let balanceNeutrinoLockInterval = getNumberByKey(BalanceNeutrinoLockIntervalKey)
136-
137-let minWavesSwapAmount = getNumberByKey(MinWavesSwapAmountKey)
138-
139-let minNeutrinoSwapAmount = getNumberByKey(MinNeutrinoSwapAmountKey)
140-
141-let nsbtAssetIdStr = getStringValue(neutrinoContract, BondAssetIdKey)
157+let nsbtAssetIdStr = getStringValue(neutrinoContract, keyBondAssetId())
142158
143159 let nsbtAssetId = fromBase58String(nsbtAssetIdStr)
144160
145-let deprecatedBondAssetId = fromBase58String("975akZBfnMj513U7MZaHKzQrmsEx5aE3wdWKTrHBhbjF")
146-
147-let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey)
148-
149-let neutrinoLockedBalance = getNumberByKey(NeutrinoLockedBalanceKey)
150-
151-let wavesLockedBalance = getNumberByKey(WavesLockedBalanceKey)
152-
153-let reservesInWaves = (wavesBalance(neutrinoContract).regular - wavesLockedBalance)
154-
155-let reservesInUsdn = convertWavesToNeutrino(reservesInWaves, currentPrice)
156-
157-let neutrinoSupply = (((neutrinoLockedBalance + value(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(addressFromStringValue(liquidationContract), neutrinoAssetId))
158-
159-let surplus = (reservesInUsdn - neutrinoSupply)
160-
161-let surplusPercent = (fraction(surplus, PAULI, neutrinoSupply) * 100)
162-
163-let BR = fraction(reservesInUsdn, PAULI, neutrinoSupply)
164-
165-let auctionAddress = addressFromStringValue(auctionContract)
166-
167-let nsbtSupplyMAX = value(assetInfo(nsbtAssetId)).quantity
168-
169-let nsbtSupply = (nsbtSupplyMAX - assetBalance(auctionAddress, nsbtAssetId))
170-
171-let IdxA = 0
172-
173-let IdxPaulB = 1
174-
175-let IdxWResAsUsdn = 2
176-
177-let IdxMultBR = 3
178-
179-let IdxMultPower = 4
180-
181-let IdxMultExpInPower = 5
182-
183-let IdxMultK = 6
184-
185-func calculateK (wRaw,uRaw,price,mRaw,sRaw) = {
186- let EXP = 271828100
187- let a = valueOrElse(getInteger(this, "nsbtCurveParam_a"), 3)
188- let paulB = valueOrElse(getInteger(this, "nsbtCurveParam_b"), ((3 * PAULI) / 10))
189- let wReservesInUsdn = convertWavesToNeutrino(wRaw, price)
190- let multBR = fraction(wReservesInUsdn, MULT, uRaw)
191- let multPower = (a * (multBR - (1 * MULT)))
192- let multExpInPower = pow(EXP, MULTSCALE, multPower, MULTSCALE, MULTSCALE, DOWN)
193- let multK = fraction(paulB, multExpInPower, PAULI)
194-[a, paulB, wReservesInUsdn, multBR, multPower, multExpInPower, multK]
195- }
196-
197-
198-func privateNsbtPriceREST () = {
199- let kCalcArray = calculateK(reservesInWaves, neutrinoSupply, currentPrice, nsbtSupplyMAX, nsbtSupply)
200- let multK = kCalcArray[IdxMultK]
201- let multStep1 = fraction(nsbtSupplyMAX, MULT, (nsbtSupplyMAX - nsbtSupply))
202- let multStep2 = fraction(multStep1, multStep1, MULT)
203- let multNsbt2usdnPrice = fraction(multK, multStep2, MULT)
204- let nsbt2usdnPrice = fraction(multNsbt2usdnPrice, PAULI, MULT)
205- let nsbt2wavesPrice = fraction(nsbt2usdnPrice, PAULI, currentPrice)
206- $Tuple2(IntegerEntry("nsbt2usdnPrice", nsbt2usdnPrice), IntegerEntry("nsbt2wavesPrice", nsbt2wavesPrice))
207- }
208-
209-
210-func privateNeutrinoStateREADONLY () = makeString(["resultNeutrinoStateREST", toString(currentPrice), toString(neutrinoLockedBalance), toString(wavesLockedBalance), toString(reservesInWaves), toString(reservesInUsdn), toString(neutrinoSupply), toString(surplus), toString(surplusPercent), toString(BR), toString(nsbtSupply)], "__")
211-
212-
213161 @Callable(i)
214-func neutrinoStateREST () = throw(privateNeutrinoStateREADONLY())
162+func constructor (neutrinoAddress,nsbtLockAddress,swapAmountAParam) = if ((i.caller != this))
163+ then throw("not authorized")
164+ else [StringEntry(keyNeutrinoAddress(), neutrinoAddress), StringEntry(keyNsbtLockContract(), nsbtLockAddress), IntegerEntry(keySwapAmountAParam(), swapAmountAParam)]
215165
216166
217167
218168 @Callable(i)
219-func neutrinoStateREADONLY () = $Tuple2(nil, ("%s%d%d%d%d%d%d%d%d%d%d__" + privateNeutrinoStateREADONLY()))
169+func calcSwapLimitMATH (gNsbtAmount) = {
170+ let usdnSwapDelayDuration = valueOrErrorMessage(getIntegerValue(this, keySwapAmountAParam()), "Swap parameter A missed.")
171+ let gNsbtAmountBigInt = toBigInt(gNsbtAmount)
172+ let limitPowPart = pow(gNsbtAmountBigInt, 0, toBigInt(EULERNUMBER), 8, 0, DOWN)
173+ let limit = fraction(toBigInt(usdnSwapDelayDuration), limitPowPart, scale6BigInt)
174+ $Tuple2(nil, limit)
175+ }
220176
221177
222178
223179 @Callable(i)
224-func nsbtPriceREST () = {
225- let nsbtPriceTuple = privateNsbtPriceREST()
226- let nsbt2usdnPrice = nsbtPriceTuple._1.value
227- let nsbt2wavesPrice = nsbtPriceTuple._2.value
228- let restData = makeString(["startNsbtPriceREST", toString(nsbt2usdnPrice), toString(nsbt2wavesPrice), "endNsbtPriceREST"], "__")
229- throw(restData)
180+func calculateKMATH (wRaw,uRaw,price,mRaw,sRaw) = {
181+ let EXP = toBigInt(2718281)
182+ let EXPSCALE = 6
183+ let a = valueOrElse(getInteger(auctionContract, "nsbtCurveParam_a"), 3)
184+ let paulB = valueOrElse(getInteger(auctionContract, "nsbtCurveParam_b"), ((3 * PAULI) / 10))
185+ let wReservesInUsdn = convertWavesToNeutrino(wRaw, price)
186+ let multBR = fraction(wReservesInUsdn, MULT, uRaw)
187+ if ((multBR > 10678564816))
188+ then throw("BR > 10678.564816% will overflow exponent")
189+ else {
190+ let multPower = (a * (multBR - MULT))
191+ let multExpInPower = pow(EXP, EXPSCALE, toBigInt(multPower), MULTSCALE, SCALE16, DOWN)
192+ let multK = fraction(toBigInt(paulB), multExpInPower, BIGPAULI)
193+ $Tuple2(nil, $Tuple7(a, paulB, wReservesInUsdn, multBR, multPower, toString(multExpInPower), toString(multK)))
194+ }
195+ }
196+
197+
198+
199+@Callable(i)
200+func curveFunctionMATH (wRaw,uRaw,price,mRaw,sRaw,wavesPayRaw) = {
201+ let kCalcArray = asAnyList(invoke(this, "calculateKMATH", [wRaw, uRaw, price, mRaw, sRaw], nil))
202+ if ((kCalcArray == kCalcArray))
203+ then {
204+ let multK = parseBigIntValue(asString(kCalcArray[7]))
205+ let usdnPay = convertWavesToNeutrino(wavesPayRaw, price)
206+ let bigMaxNsbtSupply = toBigInt(mRaw)
207+ let bigNsbtSupply = toBigInt((mRaw - sRaw))
208+ let step1 = fraction(toBigInt(usdnPay), BIGMULT16, multK)
209+ let step2 = fraction(step1, bigNsbtSupply, bigMaxNsbtSupply)
210+ let step3 = toInt(fraction(bigNsbtSupply, bigMaxNsbtSupply, (step2 + bigMaxNsbtSupply)))
211+ let nsbtAmountRaw = ((mRaw - sRaw) - step3)
212+ $Tuple2(nil, $Tuple17(nsbtAmountRaw, usdnPay, wRaw, uRaw, mRaw, sRaw, asInt(kCalcArray[1]), asInt(kCalcArray[2]), asInt(kCalcArray[3]), asInt(price), asInt(kCalcArray[4]), asInt(kCalcArray[5]), kCalcArray[6], kCalcArray[7], toString(step1), toString(step2), toString(step3)))
213+ }
214+ else throw("Strict value is not equal to itself.")
215+ }
216+
217+
218+
219+@Callable(i)
220+func calcContractNsbtPriceMATH () = {
221+ let nsbtSupplyMAX = value(assetInfo(nsbtAssetId)).quantity
222+ let neutrinoMetrics = asAnyList(invoke(this, "calcNeutinoMetricsMATH", nil, nil))
223+ if ((neutrinoMetrics == neutrinoMetrics))
224+ then {
225+ let nsbtSupply = asInt(neutrinoMetrics[10])
226+ let currentPrice = asInt(neutrinoMetrics[1])
227+ let kCalcArray = asAnyList(invoke(this, "calculateKMATH", [asInt(neutrinoMetrics[4]), asInt(neutrinoMetrics[6]), currentPrice, nsbtSupplyMAX, nsbtSupply], nil))
228+ if ((kCalcArray == kCalcArray))
229+ then {
230+ let multK = parseBigIntValue(asString(kCalcArray[7]))
231+ let mK = fromX16(multK, MULT)
232+ let multStep1 = fraction(nsbtSupplyMAX, MULT, (nsbtSupplyMAX - nsbtSupply))
233+ let multStep2 = fraction(multStep1, multStep1, MULT)
234+ let multNsbt2usdnPrice = fraction(mK, multStep2, MULT)
235+ let nsbt2usdnPrice = fraction(multNsbt2usdnPrice, PAULI, MULT)
236+ let nsbt2wavesPrice = fraction(nsbt2usdnPrice, PAULI, currentPrice)
237+ $Tuple2(nil, $Tuple2(nsbt2usdnPrice, nsbt2wavesPrice))
238+ }
239+ else throw("Strict value is not equal to itself.")
240+ }
241+ else throw("Strict value is not equal to itself.")
242+ }
243+
244+
245+
246+@Callable(i)
247+func calcUserSwapLimitsMATH (userAddressStr) = {
248+ let userGNsbtAmount = valueOrElse(getInteger(nsbtStakingContract, keyLockParamUserAmount(userAddressStr)), 0)
249+ let usdnLmtMax = asInt(invoke(this, "calcSwapLimitMATH", [userGNsbtAmount], nil))
250+ if ((usdnLmtMax == usdnLmtMax))
251+ then {
252+ let quickSwapResetBlocks = getIntegerValue(neutrinoContract, keyQuickSwapLimitDuration())
253+ let lastQuickSwapBlock = valueOrElse(getInteger(neutrinoContract, keyUserLastQuickSwapHeight(userAddressStr)), 0)
254+ let isNewQuickSwapPeriod = ((height - lastQuickSwapBlock) > quickSwapResetBlocks)
255+ let quickSwapUserSpent = if (isNewQuickSwapPeriod)
256+ then 0
257+ else valueOrElse(getInteger(neutrinoContract, keyQuickSwapUserSpentInPeriod(userAddressStr)), 0)
258+ $Tuple2(nil, $Tuple2(usdnLmtMax, quickSwapUserSpent))
259+ }
260+ else throw("Strict value is not equal to itself.")
261+ }
262+
263+
264+
265+@Callable(i)
266+func calcNeutinoMetricsMATH () = {
267+ let currentPrice = getIntegerValue(controlContract, keyPrice())
268+ let neutrinoLockedBalance = valueOrElse(getInteger(neutrinoContract, keyNeutrinoLockedBalance()), 0)
269+ let wavesLockedBalance = valueOrElse(getInteger(neutrinoContract, keyWavesLockedBalance()), 0)
270+ let reserve = (wavesBalance(neutrinoContract).regular - wavesLockedBalance)
271+ let reservesInUsdn = convertWavesToNeutrino(reserve, currentPrice)
272+ let neutrinoSupply = (((neutrinoLockedBalance + value(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(addressFromStringValue(liquidationContract), neutrinoAssetId))
273+ let surplus = (reservesInUsdn - neutrinoSupply)
274+ let deficit = (neutrinoSupply - reservesInUsdn)
275+ let surplusPercent = (fraction(surplus, PAULI, neutrinoSupply) * 100)
276+ let BR = fraction(reservesInUsdn, PAULI, neutrinoSupply)
277+ let nsbtSupplyMAX = value(assetInfo(nsbtAssetId)).quantity
278+ let nsbtSupply = (nsbtSupplyMAX - assetBalance(auctionContract, nsbtAssetId))
279+ $Tuple2(nil, $Tuple11(currentPrice, neutrinoLockedBalance, wavesLockedBalance, reserve, reservesInUsdn, neutrinoSupply, surplus, surplusPercent, BR, nsbtSupply, nsbtSupplyMAX))
280+ }
281+
282+
283+
284+@Callable(i)
285+func getUnstakeComissionAmountMATH (amount,startHeight) = {
286+ let halfLife = getIntOrFail(nsbtStakingContract, keyHalfLife())
287+ $Tuple2(nil, fraction(amount, pow(2, 0, fraction(-((height - startHeight)), MULT, halfLife), 8, 8, HALFUP), MULT))
288+ }
289+
290+
291+
292+@Callable(i)
293+func mergeStakesMATH (amount1,height1,amount2,height2) = {
294+ let halfLife = getIntOrFail(nsbtStakingContract, keyHalfLife())
295+ let w = fraction(amount2, pow(2, 0, fraction((height2 - height1), MULT, halfLife), 8, 8, HALFUP), MULT)
296+ let v = fraction((amount1 + amount2), MULT, (amount1 + w))
297+ $Tuple2(nil, (height1 + ((HALF8 - (halfLife * log(v, 8, 2, 0, 8, HALFUP))) / MULT)))
230298 }
231299
232300
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let neutrinoContract = addressFromStringValue("3Mzbx34Ex5rRbn39vUHx9kiwh3nneF8S5we")
5-
6-func getNumberByKey (key) = valueOrElse(getInteger(neutrinoContract, key), 0)
7-
8-
9-func getStringByKey (key) = valueOrElse(getString(neutrinoContract, key), "")
10-
11-
12-func getBoolByKey (key) = valueOrElse(getBoolean(neutrinoContract, key), false)
13-
14-
15-func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(addressFromStringValue(address), key), 0)
16-
17-
18-func getStringByAddressAndKey (address,key) = valueOrElse(getString(addressFromStringValue(address), key), "")
19-
20-
21-func getBoolByAddressAndKey (address,key) = valueOrElse(getBoolean(addressFromStringValue(address), key), false)
22-
23-
24-let SENDTXEXPIRE = 30
25-
26-let LISTSPLITSYMBOL = "_"
27-
28-let LISTDATASYMBOL = "+"
29-
304 let WAVELET = 100000000
315
326 let PAULI = 1000000
7+
8+let BIGPAULI = toBigInt(1000000)
339
3410 let PRICELET = 1000000
3511
3612 let MULT = 100000000
3713
14+let BIGMULT16 = toBigInt(10000000000000000)
15+
3816 let MULTSCALE = 8
3917
40-let NeutrinoAssetIdKey = "neutrino_asset_id"
18+let SCALE16 = 16
4119
42-let BondAssetIdKey = "bond_asset_id"
20+let SEP = "__"
4321
44-let AuctionContractKey = "auction_contract"
22+let HALF8 = 50000000
4523
46-let LiquidationContractKey = "liquidation_contract"
24+let EULERNUMBER = 271828182
4725
48-let RPDContractKey = "rpd_contract"
26+let scale6 = 1000000
4927
50-let ContolContractKey = "control_contract"
28+let scale6BigInt = toBigInt(1000000)
5129
52-let BalanceWavesLockIntervalKey = "balance_waves_lock_interval"
53-
54-let BalanceNeutrinoLockIntervalKey = "balance_neutrino_lock_interval"
55-
56-let MinWavesSwapAmountKey = "min_waves_swap_amount"
57-
58-let MinNeutrinoSwapAmountKey = "min_neutrino_swap_amount"
59-
60-let NodeOracleProviderPubKeyKey = "node_oracle_provider"
61-
62-let RPDBalanceKey = "rpd_balance"
63-
64-func getRPDContractBalanceKey (assetId) = ((RPDBalanceKey + "_") + toBase58String(assetId))
30+func keyNeutrinoAddress () = "%s%s__config__neutrinoAddress"
6531
6632
67-let PriceKey = "price"
68-
69-let PriceIndexKey = "price_index"
70-
71-let IsBlockedKey = "is_blocked"
72-
73-func getPriceHistoryKey (block) = ((PriceKey + "_") + toString(block))
33+func keySwapAmountAParam () = "%s%s__config__swapAParam"
7434
7535
76-func getHeightPriceByIndexKey (index) = ((PriceIndexKey + "_") + toString(index))
36+func keyNeutrinoAssetId () = "neutrino_asset_id"
7737
7838
79-let BalanceLockedkKey = "balance_lock_"
80-
81-let WavesLockedBalanceKey = (BalanceLockedkKey + "waves")
82-
83-let NeutrinoLockedBalanceKey = (BalanceLockedkKey + "neutrino")
84-
85-func getRPDSnapshotContractBalanceKey (count,assetId) = ((((RPDBalanceKey + "_") + toBase58String(assetId)) + "_") + toString(count))
39+func keyLiquidationContractAddress () = "liquidation_contract"
8640
8741
88-func getCancelLeaseTxReserveFeeKey (hash) = (("cancel_lease_tx_reserve_fee" + "_") + hash)
42+func keyRPDContract () = "rpd_contract"
8943
9044
91-func getWavesLockedBalanceKey (owner) = ((WavesLockedBalanceKey + "_") + owner)
45+func keyAuctionContract () = "auction_contract"
9246
9347
94-func getNeutrinoLockedBalanceKey (owner) = ((NeutrinoLockedBalanceKey + "_") + owner)
48+func keyContolContract () = "control_contract"
9549
9650
97-func getBalanceUnlockBlockKey (owner) = ("balance_unlock_block_" + owner)
51+func keyBondAssetId () = "bond_asset_id"
9852
9953
100-func getRPDProfitKey (count) = (("rpd_profit" + "_") + toString(count))
54+func keyBalanceLocked () = "balance_lock_"
55+
56+
57+func keyWavesLockedBalance () = (keyBalanceLocked() + "waves")
58+
59+
60+func keyNeutrinoLockedBalance () = (keyBalanceLocked() + "neutrino")
61+
62+
63+func keyMinWavesSwapAmount () = "min_waves_swap_amount"
64+
65+
66+func keyMinNeutrinoSwapAmount () = "min_neutrino_swap_amount"
67+
68+
69+func keyWavesOutFeePart () = "wavesOut_swap_feePart"
70+
71+
72+func keyNeutrinoOutFeePart () = "neutrinoOut_swap_feePart"
73+
74+
75+func keyNsbtLockContract () = "%s__nsbtLockContract"
76+
77+
78+func keyQuickSwapLimitDuration () = "%s__quickSwapLimitDuration"
79+
80+
81+func keyUserLastQuickSwapHeight (userAddress) = makeString(["%s%s", "userLastQuickSwapHeight", userAddress], SEP)
82+
83+
84+func keyQuickSwapUserSpentInPeriod (userAddress) = makeString(["%s%s", "quickSwapUserSpentInPeriod", userAddress], SEP)
85+
86+
87+func keyPrice () = "price"
88+
89+
90+func keyHalfLife () = "%s__halfLife"
91+
92+
93+func keyLockParamUserAmount (userAddress) = makeString(["%s%s%s", "paramByUser", userAddress, "amount"], SEP)
94+
95+
96+func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
97+
98+
99+func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
100+
101+
102+func getBoolOrFail (address,key) = valueOrErrorMessage(getBoolean(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
101103
102104
103105 func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, PRICELET, price), WAVELET, PAULI)
104106
105107
106108 func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, PRICELET), PAULI, WAVELET)
107109
108110
109-func convertWavesToBond (amount,price) = convertWavesToNeutrino(amount, price)
111+func toX16 (origVal,origScaleMult) = fraction(toBigInt(origVal), BIGMULT16, toBigInt(origScaleMult))
110112
111113
112-func convertJsonArrayToList (jsonArray) = split(jsonArray, ",")
114+func fromX16 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), BIGMULT16))
113115
114116
115-let liquidationContract = getStringByKey(LiquidationContractKey)
117+func asAnyList (val) = match val {
118+ case valAnyLyst: List[Any] =>
119+ valAnyLyst
120+ case _ =>
121+ throw("fail to cast into List[Any]")
122+}
116123
117-let neutrinoAssetIdString = getStringByKey(NeutrinoAssetIdKey)
124+
125+func asInt (val) = match val {
126+ case valInt: Int =>
127+ valInt
128+ case _ =>
129+ throw("fail to cast into Int")
130+}
131+
132+
133+func asString (val) = match val {
134+ case valStr: String =>
135+ valStr
136+ case _ =>
137+ throw("fail to cast into String")
138+}
139+
140+
141+let neutrinoContract = addressFromStringValue(getStringOrFail(this, keyNeutrinoAddress()))
142+
143+let controlContract = addressFromStringValue(getStringOrFail(neutrinoContract, keyContolContract()))
144+
145+let auctionContract = addressFromStringValue(getStringOrFail(neutrinoContract, keyAuctionContract()))
146+
147+let liquidationContract = getStringOrFail(neutrinoContract, keyLiquidationContractAddress())
148+
149+let rpdContract = getStringOrFail(neutrinoContract, keyRPDContract())
150+
151+let nsbtStakingContract = addressFromStringValue(getStringOrFail(this, keyNsbtLockContract()))
152+
153+let neutrinoAssetIdString = getStringOrFail(neutrinoContract, keyNeutrinoAssetId())
118154
119155 let neutrinoAssetId = fromBase58String(neutrinoAssetIdString)
120156
121-let auctionContract = getStringByKey(AuctionContractKey)
122-
123-let rpdContract = getStringByKey(RPDContractKey)
124-
125-let controlContract = getStringByKey(ContolContractKey)
126-
127-let priceIndex = getNumberByAddressAndKey(controlContract, PriceIndexKey)
128-
129-let isBlocked = getBoolByAddressAndKey(controlContract, IsBlockedKey)
130-
131-let nodeOracleProviderPubKey = fromBase58String(getStringByKey(NodeOracleProviderPubKeyKey))
132-
133-let balanceWavesLockInterval = getNumberByKey(BalanceWavesLockIntervalKey)
134-
135-let balanceNeutrinoLockInterval = getNumberByKey(BalanceNeutrinoLockIntervalKey)
136-
137-let minWavesSwapAmount = getNumberByKey(MinWavesSwapAmountKey)
138-
139-let minNeutrinoSwapAmount = getNumberByKey(MinNeutrinoSwapAmountKey)
140-
141-let nsbtAssetIdStr = getStringValue(neutrinoContract, BondAssetIdKey)
157+let nsbtAssetIdStr = getStringValue(neutrinoContract, keyBondAssetId())
142158
143159 let nsbtAssetId = fromBase58String(nsbtAssetIdStr)
144160
145-let deprecatedBondAssetId = fromBase58String("975akZBfnMj513U7MZaHKzQrmsEx5aE3wdWKTrHBhbjF")
146-
147-let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey)
148-
149-let neutrinoLockedBalance = getNumberByKey(NeutrinoLockedBalanceKey)
150-
151-let wavesLockedBalance = getNumberByKey(WavesLockedBalanceKey)
152-
153-let reservesInWaves = (wavesBalance(neutrinoContract).regular - wavesLockedBalance)
154-
155-let reservesInUsdn = convertWavesToNeutrino(reservesInWaves, currentPrice)
156-
157-let neutrinoSupply = (((neutrinoLockedBalance + value(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(addressFromStringValue(liquidationContract), neutrinoAssetId))
158-
159-let surplus = (reservesInUsdn - neutrinoSupply)
160-
161-let surplusPercent = (fraction(surplus, PAULI, neutrinoSupply) * 100)
162-
163-let BR = fraction(reservesInUsdn, PAULI, neutrinoSupply)
164-
165-let auctionAddress = addressFromStringValue(auctionContract)
166-
167-let nsbtSupplyMAX = value(assetInfo(nsbtAssetId)).quantity
168-
169-let nsbtSupply = (nsbtSupplyMAX - assetBalance(auctionAddress, nsbtAssetId))
170-
171-let IdxA = 0
172-
173-let IdxPaulB = 1
174-
175-let IdxWResAsUsdn = 2
176-
177-let IdxMultBR = 3
178-
179-let IdxMultPower = 4
180-
181-let IdxMultExpInPower = 5
182-
183-let IdxMultK = 6
184-
185-func calculateK (wRaw,uRaw,price,mRaw,sRaw) = {
186- let EXP = 271828100
187- let a = valueOrElse(getInteger(this, "nsbtCurveParam_a"), 3)
188- let paulB = valueOrElse(getInteger(this, "nsbtCurveParam_b"), ((3 * PAULI) / 10))
189- let wReservesInUsdn = convertWavesToNeutrino(wRaw, price)
190- let multBR = fraction(wReservesInUsdn, MULT, uRaw)
191- let multPower = (a * (multBR - (1 * MULT)))
192- let multExpInPower = pow(EXP, MULTSCALE, multPower, MULTSCALE, MULTSCALE, DOWN)
193- let multK = fraction(paulB, multExpInPower, PAULI)
194-[a, paulB, wReservesInUsdn, multBR, multPower, multExpInPower, multK]
195- }
196-
197-
198-func privateNsbtPriceREST () = {
199- let kCalcArray = calculateK(reservesInWaves, neutrinoSupply, currentPrice, nsbtSupplyMAX, nsbtSupply)
200- let multK = kCalcArray[IdxMultK]
201- let multStep1 = fraction(nsbtSupplyMAX, MULT, (nsbtSupplyMAX - nsbtSupply))
202- let multStep2 = fraction(multStep1, multStep1, MULT)
203- let multNsbt2usdnPrice = fraction(multK, multStep2, MULT)
204- let nsbt2usdnPrice = fraction(multNsbt2usdnPrice, PAULI, MULT)
205- let nsbt2wavesPrice = fraction(nsbt2usdnPrice, PAULI, currentPrice)
206- $Tuple2(IntegerEntry("nsbt2usdnPrice", nsbt2usdnPrice), IntegerEntry("nsbt2wavesPrice", nsbt2wavesPrice))
207- }
208-
209-
210-func privateNeutrinoStateREADONLY () = makeString(["resultNeutrinoStateREST", toString(currentPrice), toString(neutrinoLockedBalance), toString(wavesLockedBalance), toString(reservesInWaves), toString(reservesInUsdn), toString(neutrinoSupply), toString(surplus), toString(surplusPercent), toString(BR), toString(nsbtSupply)], "__")
211-
212-
213161 @Callable(i)
214-func neutrinoStateREST () = throw(privateNeutrinoStateREADONLY())
162+func constructor (neutrinoAddress,nsbtLockAddress,swapAmountAParam) = if ((i.caller != this))
163+ then throw("not authorized")
164+ else [StringEntry(keyNeutrinoAddress(), neutrinoAddress), StringEntry(keyNsbtLockContract(), nsbtLockAddress), IntegerEntry(keySwapAmountAParam(), swapAmountAParam)]
215165
216166
217167
218168 @Callable(i)
219-func neutrinoStateREADONLY () = $Tuple2(nil, ("%s%d%d%d%d%d%d%d%d%d%d__" + privateNeutrinoStateREADONLY()))
169+func calcSwapLimitMATH (gNsbtAmount) = {
170+ let usdnSwapDelayDuration = valueOrErrorMessage(getIntegerValue(this, keySwapAmountAParam()), "Swap parameter A missed.")
171+ let gNsbtAmountBigInt = toBigInt(gNsbtAmount)
172+ let limitPowPart = pow(gNsbtAmountBigInt, 0, toBigInt(EULERNUMBER), 8, 0, DOWN)
173+ let limit = fraction(toBigInt(usdnSwapDelayDuration), limitPowPart, scale6BigInt)
174+ $Tuple2(nil, limit)
175+ }
220176
221177
222178
223179 @Callable(i)
224-func nsbtPriceREST () = {
225- let nsbtPriceTuple = privateNsbtPriceREST()
226- let nsbt2usdnPrice = nsbtPriceTuple._1.value
227- let nsbt2wavesPrice = nsbtPriceTuple._2.value
228- let restData = makeString(["startNsbtPriceREST", toString(nsbt2usdnPrice), toString(nsbt2wavesPrice), "endNsbtPriceREST"], "__")
229- throw(restData)
180+func calculateKMATH (wRaw,uRaw,price,mRaw,sRaw) = {
181+ let EXP = toBigInt(2718281)
182+ let EXPSCALE = 6
183+ let a = valueOrElse(getInteger(auctionContract, "nsbtCurveParam_a"), 3)
184+ let paulB = valueOrElse(getInteger(auctionContract, "nsbtCurveParam_b"), ((3 * PAULI) / 10))
185+ let wReservesInUsdn = convertWavesToNeutrino(wRaw, price)
186+ let multBR = fraction(wReservesInUsdn, MULT, uRaw)
187+ if ((multBR > 10678564816))
188+ then throw("BR > 10678.564816% will overflow exponent")
189+ else {
190+ let multPower = (a * (multBR - MULT))
191+ let multExpInPower = pow(EXP, EXPSCALE, toBigInt(multPower), MULTSCALE, SCALE16, DOWN)
192+ let multK = fraction(toBigInt(paulB), multExpInPower, BIGPAULI)
193+ $Tuple2(nil, $Tuple7(a, paulB, wReservesInUsdn, multBR, multPower, toString(multExpInPower), toString(multK)))
194+ }
195+ }
196+
197+
198+
199+@Callable(i)
200+func curveFunctionMATH (wRaw,uRaw,price,mRaw,sRaw,wavesPayRaw) = {
201+ let kCalcArray = asAnyList(invoke(this, "calculateKMATH", [wRaw, uRaw, price, mRaw, sRaw], nil))
202+ if ((kCalcArray == kCalcArray))
203+ then {
204+ let multK = parseBigIntValue(asString(kCalcArray[7]))
205+ let usdnPay = convertWavesToNeutrino(wavesPayRaw, price)
206+ let bigMaxNsbtSupply = toBigInt(mRaw)
207+ let bigNsbtSupply = toBigInt((mRaw - sRaw))
208+ let step1 = fraction(toBigInt(usdnPay), BIGMULT16, multK)
209+ let step2 = fraction(step1, bigNsbtSupply, bigMaxNsbtSupply)
210+ let step3 = toInt(fraction(bigNsbtSupply, bigMaxNsbtSupply, (step2 + bigMaxNsbtSupply)))
211+ let nsbtAmountRaw = ((mRaw - sRaw) - step3)
212+ $Tuple2(nil, $Tuple17(nsbtAmountRaw, usdnPay, wRaw, uRaw, mRaw, sRaw, asInt(kCalcArray[1]), asInt(kCalcArray[2]), asInt(kCalcArray[3]), asInt(price), asInt(kCalcArray[4]), asInt(kCalcArray[5]), kCalcArray[6], kCalcArray[7], toString(step1), toString(step2), toString(step3)))
213+ }
214+ else throw("Strict value is not equal to itself.")
215+ }
216+
217+
218+
219+@Callable(i)
220+func calcContractNsbtPriceMATH () = {
221+ let nsbtSupplyMAX = value(assetInfo(nsbtAssetId)).quantity
222+ let neutrinoMetrics = asAnyList(invoke(this, "calcNeutinoMetricsMATH", nil, nil))
223+ if ((neutrinoMetrics == neutrinoMetrics))
224+ then {
225+ let nsbtSupply = asInt(neutrinoMetrics[10])
226+ let currentPrice = asInt(neutrinoMetrics[1])
227+ let kCalcArray = asAnyList(invoke(this, "calculateKMATH", [asInt(neutrinoMetrics[4]), asInt(neutrinoMetrics[6]), currentPrice, nsbtSupplyMAX, nsbtSupply], nil))
228+ if ((kCalcArray == kCalcArray))
229+ then {
230+ let multK = parseBigIntValue(asString(kCalcArray[7]))
231+ let mK = fromX16(multK, MULT)
232+ let multStep1 = fraction(nsbtSupplyMAX, MULT, (nsbtSupplyMAX - nsbtSupply))
233+ let multStep2 = fraction(multStep1, multStep1, MULT)
234+ let multNsbt2usdnPrice = fraction(mK, multStep2, MULT)
235+ let nsbt2usdnPrice = fraction(multNsbt2usdnPrice, PAULI, MULT)
236+ let nsbt2wavesPrice = fraction(nsbt2usdnPrice, PAULI, currentPrice)
237+ $Tuple2(nil, $Tuple2(nsbt2usdnPrice, nsbt2wavesPrice))
238+ }
239+ else throw("Strict value is not equal to itself.")
240+ }
241+ else throw("Strict value is not equal to itself.")
242+ }
243+
244+
245+
246+@Callable(i)
247+func calcUserSwapLimitsMATH (userAddressStr) = {
248+ let userGNsbtAmount = valueOrElse(getInteger(nsbtStakingContract, keyLockParamUserAmount(userAddressStr)), 0)
249+ let usdnLmtMax = asInt(invoke(this, "calcSwapLimitMATH", [userGNsbtAmount], nil))
250+ if ((usdnLmtMax == usdnLmtMax))
251+ then {
252+ let quickSwapResetBlocks = getIntegerValue(neutrinoContract, keyQuickSwapLimitDuration())
253+ let lastQuickSwapBlock = valueOrElse(getInteger(neutrinoContract, keyUserLastQuickSwapHeight(userAddressStr)), 0)
254+ let isNewQuickSwapPeriod = ((height - lastQuickSwapBlock) > quickSwapResetBlocks)
255+ let quickSwapUserSpent = if (isNewQuickSwapPeriod)
256+ then 0
257+ else valueOrElse(getInteger(neutrinoContract, keyQuickSwapUserSpentInPeriod(userAddressStr)), 0)
258+ $Tuple2(nil, $Tuple2(usdnLmtMax, quickSwapUserSpent))
259+ }
260+ else throw("Strict value is not equal to itself.")
261+ }
262+
263+
264+
265+@Callable(i)
266+func calcNeutinoMetricsMATH () = {
267+ let currentPrice = getIntegerValue(controlContract, keyPrice())
268+ let neutrinoLockedBalance = valueOrElse(getInteger(neutrinoContract, keyNeutrinoLockedBalance()), 0)
269+ let wavesLockedBalance = valueOrElse(getInteger(neutrinoContract, keyWavesLockedBalance()), 0)
270+ let reserve = (wavesBalance(neutrinoContract).regular - wavesLockedBalance)
271+ let reservesInUsdn = convertWavesToNeutrino(reserve, currentPrice)
272+ let neutrinoSupply = (((neutrinoLockedBalance + value(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(addressFromStringValue(liquidationContract), neutrinoAssetId))
273+ let surplus = (reservesInUsdn - neutrinoSupply)
274+ let deficit = (neutrinoSupply - reservesInUsdn)
275+ let surplusPercent = (fraction(surplus, PAULI, neutrinoSupply) * 100)
276+ let BR = fraction(reservesInUsdn, PAULI, neutrinoSupply)
277+ let nsbtSupplyMAX = value(assetInfo(nsbtAssetId)).quantity
278+ let nsbtSupply = (nsbtSupplyMAX - assetBalance(auctionContract, nsbtAssetId))
279+ $Tuple2(nil, $Tuple11(currentPrice, neutrinoLockedBalance, wavesLockedBalance, reserve, reservesInUsdn, neutrinoSupply, surplus, surplusPercent, BR, nsbtSupply, nsbtSupplyMAX))
280+ }
281+
282+
283+
284+@Callable(i)
285+func getUnstakeComissionAmountMATH (amount,startHeight) = {
286+ let halfLife = getIntOrFail(nsbtStakingContract, keyHalfLife())
287+ $Tuple2(nil, fraction(amount, pow(2, 0, fraction(-((height - startHeight)), MULT, halfLife), 8, 8, HALFUP), MULT))
288+ }
289+
290+
291+
292+@Callable(i)
293+func mergeStakesMATH (amount1,height1,amount2,height2) = {
294+ let halfLife = getIntOrFail(nsbtStakingContract, keyHalfLife())
295+ let w = fraction(amount2, pow(2, 0, fraction((height2 - height1), MULT, halfLife), 8, 8, HALFUP), MULT)
296+ let v = fraction((amount1 + amount2), MULT, (amount1 + w))
297+ $Tuple2(nil, (height1 + ((HALF8 - (halfLife * log(v, 8, 2, 0, 8, HALFUP))) / MULT)))
230298 }
231299
232300

github/deemru/w8io/026f985 
48.15 ms