tx · EuP2aX2tH2ZQYRYmZmHRg9P7PpKetkVW2xd3gDa6rgaF

3MyN19SDzDpXyEtabWvag2P5mkeFrdFVd4h:  -0.05000000 Waves

2023.01.02 15:48 [2387374] smart account 3MyN19SDzDpXyEtabWvag2P5mkeFrdFVd4h > SELF 0.00000000 Waves

{ "type": 13, "id": "EuP2aX2tH2ZQYRYmZmHRg9P7PpKetkVW2xd3gDa6rgaF", "fee": 5000000, "feeAssetId": null, "timestamp": 1672663687011, "version": 2, "chainId": 84, "sender": "3MyN19SDzDpXyEtabWvag2P5mkeFrdFVd4h", "senderPublicKey": "4HqqczFwZHAsxp1oNq8dQkRStfCKBL79X99icQ2B6FYn", "proofs": [ "4jvDseJU1tCZBsSLhyEFQCn4DWsvd4Nfs6Znm6Q4KUB6ZiUzefXtuqLcocFZJsiePVA51mLbjbpqwuLFgvs6c8nD" ], "script": "base64:AAIFAAAAAAAAACQIAhIECgIICBIECgIIARIDCgEIEgUKAwgBCBIDCgEIEgMKAQgAAAAZAAAAAANTRVACAAAAAl9fAAAAABlJZHhDb250cm9sQ2ZnTmV1dHJpbm9EYXBwAAAAAAAAAAABAAAAABhJZHhDb250cm9sQ2ZnQXVjdGlvbkRhcHAAAAAAAAAAAAIAAAAAFElkeENvbnRyb2xDZmdScGREYXBwAAAAAAAAAAADAAAAABVJZHhDb250cm9sQ2ZnTWF0aERhcHAAAAAAAAAAAAQAAAAAHElkeENvbnRyb2xDZmdMaXF1aWRhdGlvbkRhcHAAAAAAAAAAAAUAAAAAFUlkeENvbnRyb2xDZmdSZXN0RGFwcAAAAAAAAAAABgAAAAAdSWR4Q29udHJvbENmZ05vZGVSZWdpc3RyeURhcHAAAAAAAAAAAAcAAAAAHElkeENvbnRyb2xDZmdOc2J0U3Rha2luZ0RhcHAAAAAAAAAAAAgAAAAAGUlkeENvbnRyb2xDZmdNZWRpYXRvckRhcHAAAAAAAAAAAAkBAAAAD2dldFN0cmluZ09yRmFpbAAAAAIAAAAHYWRkcmVzcw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AAAEAAAAAAAAAAAFAAAAAAAAAAAGAAAAAAAAAAAHAAAAAAAAAAAIAAAAAAAAAAAJAAAAAAAAAAAKCQAFFAAAAAIFAAAAA25pbAkBAAAAC3Byb2R1Y2VKc29uAAAAAQUAAAAOaW52b2tlc1Jlc3VsdHMAAAAAR0aVow==", "height": 2387374, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CG7KVqCcnKv6x8HarFkyTrUWRkxG6c1CMjuJ9uw5zoNC Next: EVHRtR9ithvt9cUEiLLq6X42wwNh5nL3V4A4y7Vvezj8 Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let revisionNum = ""
5-
6-let separator = "__"
7-
84 let SEP = "__"
9-
10-let MULT6 = 1000000
11-
12-let MULT8 = 100000000
13-
14-let MULTX6 = toBigInt(MULT6)
15-
16-let MULTX8 = toBigInt(MULT8)
17-
18-let MULTX18 = toBigInt(1000000000000000000)
195
206 let IdxControlCfgNeutrinoDapp = 1
217
3420 let IdxControlCfgNsbtStakingDapp = 8
3521
3622 let IdxControlCfgMediatorDapp = 9
37-
38-let IdxControlCfgSurfStakingDapp = 10
39-
40-let IdxControlCfgGnsbtControllerDapp = 11
4123
4224 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
4325
5840
5941 let controlCfg = readControlCfgOrFail(controlContract)
6042
61-let mathContract = getContractAddressOrFail(controlCfg, IdxControlCfgMathDapp)
43+let restAcc = getContractAddressOrFail(controlCfg, IdxControlCfgRestDapp)
6244
63-let neutrinoContract = getContractAddressOrFail(controlCfg, IdxControlCfgNeutrinoDapp)
64-
65-let auctionContract = getContractAddressOrFail(controlCfg, IdxControlCfgAuctionDapp)
66-
67-func keyBondAsset () = "bond_asset_id"
45+func keyRestAddress () = "%s%s__config__restAddress"
6846
6947
70-func keyAuctionContractAddress () = "auction_contract"
48+func getStrOrFail (key) = valueOrErrorMessage(getString(this, key), (("Mandatory this." + key) + " is not defined"))
7149
7250
73-func keyMinLockAmount () = "%s__minLockAmount"
51+func getAddressOrFail (key) = valueOrErrorMessage(addressFromString(getStrOrFail(key)), ("fail to parse address for this." + key))
7452
7553
76-func keyStakedAssetId () = "%s__stakedAssetId"
77-
78-
79-func keyLockParamUserAmount (userAddress) = makeString(["%s%s%s", "paramByUser", toString(userAddress), "amount"], separator)
80-
81-
82-func keyLockParamStartBlock (userAddress) = makeString(["%s%s%s", "paramByUser", toString(userAddress), "start"], separator)
83-
84-
85-func keyLockParamVotingPowerEffectiveHeight (userAddress) = makeString(["%s%s%s", "paramByUser", toString(userAddress), "vpEffectiveHeight"], separator)
86-
87-
88-func keyHistoryRecord (type,userAddress,txId) = makeString(["%s%s%s%s", "history", type, toString(userAddress), toBase58String(txId)], separator)
89-
90-
91-func keyLockParamTotalAmount () = makeString(["%s%s", "stats", "activeTotalLocked"], separator)
92-
93-
94-func keyStatsLocksCount () = makeString(["%s%s", "stats", "locksCount"], separator)
95-
96-
97-func keyStatsUsersCount () = makeString(["%s%s", "stats", "activeUsersCount"], separator)
98-
99-
100-func keyNextPeriod () = "%s__nextPeriod"
101-
102-
103-func keySupportedRewardAssets () = "supportedRewardAssets"
104-
105-
106-func keyDepositNumLast () = makeString(["%s%s%s", "dep", "lastNum"], separator)
107-
108-
109-func keyUserRewardFromDepositNum (userAddress) = makeString(["%s%s%s", "userRwdFromDepNum", userAddress], separator)
110-
111-
112-func keyRewardPerNsbtSumAt (depositNum,tkn) = makeString(["%s%d", "rwdPerNsbtSumByDepNum", toString(depositNum), tkn], separator)
113-
114-
115-func keyReward (userAddress,tkn) = makeString(["%s%s%s", "rwd", userAddress, tkn], separator)
116-
117-
118-func keyClaimed (userAddress,tkn) = makeString(["%s%s%s", "clm", userAddress, tkn], separator)
119-
120-
121-func keyNotDistributedReward (tkn) = makeString(["%s%s", "notDistributed", tkn], separator)
122-
123-
124-func toX18 (origVal,origMult) = fraction(toBigInt(origVal), MULTX18, origMult)
125-
126-
127-func getIntOrZero (key) = valueOrElse(getInteger(this, key), 0)
128-
129-
130-func getIntOrElse (key,defaultVal) = valueOrElse(getInteger(this, key), defaultVal)
131-
132-
133-func getIntOrFail (key) = valueOrErrorMessage(getInteger(this, key), (("Mandatory this." + key) + " is not defined"))
134-
135-
136-func getStrOrElse (key,defaultVal) = valueOrElse(getString(this, key), defaultVal)
137-
138-
139-func toAddressOrFail (addressStr) = valueOrErrorMessage(addressFromString(addressStr), ("couldn't parse passed addressStr=" + addressStr))
140-
141-
142-func toAssetVect (assetStr) = fromBase58String(assetStr)
143-
144-
145-func asInt (val) = match val {
146- case valInt: Int =>
147- valInt
54+func asString (val) = match val {
55+ case valStr: String =>
56+ valStr
14857 case _ =>
149- throw("fail to cast into Int")
58+ throw("fail to cast into String")
15059 }
15160
15261
153-func asSwapParamsSTRUCT (v) = match v {
154- case struct: (Int, Int, Int, Int, Int, Int, Int) =>
155- struct
156- case _ =>
157- throw("fail to cast into Int")
158-}
62+func produceJson (strMap) = {
63+ let indexes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
64+ let length = size(strMap)
65+ if (((length % 2) != 0))
66+ then throw("only even args size is accepeted")
67+ else if ((length > size(indexes)))
68+ then throw(("strMap length is greater then " + toString(size(indexes))))
69+ else {
70+ func produceJson (jsonAccum,nextIdx) = if (if (((nextIdx % 2) == 0))
71+ then (length >= (nextIdx + 1))
72+ else false)
73+ then (((((jsonAccum + "
74+\"") + strMap[nextIdx]) + "\": \"") + strMap[(nextIdx + 1)]) + "\",")
75+ else jsonAccum
15976
77+ let preJsonResult = {
78+ let $l = indexes
79+ let $s = size($l)
80+ let $acc0 = ""
81+ func $f0_1 ($a,$i) = if (($i >= $s))
82+ then $a
83+ else produceJson($a, $l[$i])
16084
161-func formatHistoryRecord (oldAmount,oldStart,newAmount,newStart) = makeString(["%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(oldAmount), toString(oldStart), toString(newAmount), toString(newStart)], separator)
85+ func $f0_2 ($a,$i) = if (($i >= $s))
86+ then $a
87+ else throw("List size exceeds 20")
16288
163-
164-func formatClaimHistoryRecord (user,claimedRewards) = makeString(["%s%d%d%s", user, toString(lastBlock.height), toString(lastBlock.timestamp), claimedRewards], separator)
165-
166-
167-func HistoryRecordEntry (type,userAddress,txId,oldAmount,oldStart,newAmount,newStart) = StringEntry(keyHistoryRecord(type, userAddress, txId), formatHistoryRecord(oldAmount, oldStart, newAmount, newStart))
168-
169-
170-func ClaimHistoryEntry (userAddress,txId,claimedRewards) = StringEntry(keyHistoryRecord("claim", userAddress, txId), formatClaimHistoryRecord(toString(userAddress), claimedRewards))
171-
172-
173-func StatsResult (totalLockedInc,lockCountInc,usersCountInc) = {
174- let locksCount = getIntOrZero(keyStatsLocksCount())
175- let usersCount = getIntOrZero(keyStatsUsersCount())
176- let totalAmount = getIntOrZero(keyLockParamTotalAmount())
177- let totalAmountNew = (totalAmount + totalLockedInc)
178- $Tuple3([IntegerEntry(keyStatsLocksCount(), (locksCount + lockCountInc)), IntegerEntry(keyStatsUsersCount(), (usersCount + usersCountInc)), IntegerEntry(keyLockParamTotalAmount(), totalAmountNew)], totalAmount, totalAmountNew)
89+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20)
90+ }
91+ (("{" + dropRight(preJsonResult, 1)) + "}")
92+ }
17993 }
18094
18195
182-func LockParamsEntry (userAddress,amount,votingPowerEffectiveHeight) = [IntegerEntry(keyLockParamUserAmount(userAddress), amount), IntegerEntry(keyLockParamStartBlock(userAddress), votingPowerEffectiveHeight)]
96+func genericV2READONLY (x) = {
97+ func call (a,e) = (a :+ invoke(Address(fromBase58String(e._1)), e._2, e._3, nil))
18398
99+ let $l = x
100+ let $s = size($l)
101+ let $acc0 = nil
102+ func $f0_1 ($a,$i) = if (($i >= $s))
103+ then $a
104+ else call($a, $l[$i])
184105
185-func getParamsOrFail () = $Tuple2(fromBase58String(getStringOrFail(this, keyStakedAssetId())), getIntOrFail(keyMinLockAmount()))
106+ func $f0_2 ($a,$i) = if (($i >= $s))
107+ then $a
108+ else throw("List size exceeds 10")
186109
187-
188-func isActiveUser (userAddress) = (getIntOrElse(keyLockParamUserAmount(userAddress), 0) > 0)
189-
190-
191-func getUserParamsOrUnit (userAddress) = if (isActiveUser(userAddress))
192- then $Tuple3(false, getIntOrFail(keyLockParamUserAmount(userAddress)), getIntOrFail(keyLockParamStartBlock(userAddress)))
193- else unit
194-
195-
196-func getUserParamsOrFail (userAddress) = valueOrErrorMessage(getUserParamsOrUnit(userAddress), (("User " + toString(userAddress)) + " is not defined"))
197-
198-
199-let supportedAssetsStr = getStrOrElse(keySupportedRewardAssets(), "")
200-
201-let supportedAssetsList = split(supportedAssetsStr, "_")
202-
203-func calcReward (userAddress,assetId,stakedAmountX,depositNumUser,depositNumLast) = {
204- let rewardPerNsbtSumLastKEY = keyRewardPerNsbtSumAt(depositNumLast, assetId)
205- let sumLastX18 = parseBigIntValue(getStrOrElse(keyRewardPerNsbtSumAt(depositNumLast, assetId), "0"))
206- let sumUserX18 = parseBigIntValue(getStrOrElse(keyRewardPerNsbtSumAt(depositNumUser, assetId), "0"))
207- let rewardDynamicPart = toInt(fraction((sumLastX18 - sumUserX18), stakedAmountX, MULTX18))
208- let rewardCachedPartKEY = keyReward(userAddress, assetId)
209- let rewardCachedPart = getIntOrElse(rewardCachedPartKEY, 0)
210- $Tuple4((rewardCachedPart + rewardDynamicPart), rewardCachedPart, rewardDynamicPart, rewardCachedPartKEY)
110+ $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)
211111 }
212112
213113
214-func RewardEntries (isNewUser,userAddress,stakedAmount) = {
215- let stakedAmountX = toBigInt(stakedAmount)
216- let userRewardFromDepositNumKEY = keyUserRewardFromDepositNum(userAddress)
217- let depositNumUser = getIntOrElse(userRewardFromDepositNumKEY, -1)
218- let depositNumLast = getIntOrElse(keyDepositNumLast(), -1)
219- func forEachAssetCacheUserReward (accum,asset) = {
220- let $t087088843 = calcReward(userAddress, asset, stakedAmountX, depositNumUser, depositNumLast)
221- let rewardTotal = $t087088843._1
222- let cached = $t087088843._2
223- let dynamic = $t087088843._3
224- let rewardCachedPartKEY = $t087088843._4
225- (accum :+ IntegerEntry(rewardCachedPartKEY, rewardTotal))
114+func genericV3READONLY (x) = {
115+ func call (a,e) = {
116+ let dApp = Address(fromBase58String(e._1))
117+ let name = e._2
118+ let opType = e._3
119+ let params = e._4
120+ let res = if ((opType == "invoke"))
121+ then invoke(dApp, name, params, nil)
122+ else if ((opType == "binKey"))
123+ then getBinary(dApp, name)
124+ else if ((opType == "binValKey"))
125+ then getBinaryValue(dApp, name)
126+ else if ((opType == "boolKey"))
127+ then getBoolean(dApp, name)
128+ else if ((opType == "boolValKey"))
129+ then getBooleanValue(dApp, name)
130+ else if ((opType == "intKey"))
131+ then getInteger(dApp, name)
132+ else if ((opType == "intValKey"))
133+ then getIntegerValue(dApp, name)
134+ else if ((opType == "strKey"))
135+ then getString(dApp, name)
136+ else if ((opType == "strValKey"))
137+ then getStringValue(dApp, name)
138+ else if ((opType == "hasData"))
139+ then !(isDataStorageUntouched(dApp))
140+ else throw(("not supported operation type: " + opType))
141+ (a :+ res)
226142 }
227143
228- if (if ((depositNumLast == -1))
229- then (depositNumUser == -1)
230- else false)
231- then nil
232- else if (if ((depositNumLast == -1))
233- then (depositNumUser > -1)
234- else false)
235- then throw("invalid depositNumLast and depositNumUser state")
236- else if (if ((depositNumLast > -1))
237- then (depositNumUser >= -1)
238- else false)
239- then if (isNewUser)
240- then [IntegerEntry(userRewardFromDepositNumKEY, depositNumLast)]
241- else ({
242- let $l = supportedAssetsList
243- let $s = size($l)
244- let $acc0 = nil
245- func $f0_1 ($a,$i) = if (($i >= $s))
246- then $a
247- else forEachAssetCacheUserReward($a, $l[$i])
144+ let $l = x
145+ let $s = size($l)
146+ let $acc0 = nil
147+ func $f0_1 ($a,$i) = if (($i >= $s))
148+ then $a
149+ else call($a, $l[$i])
248150
249- func $f0_2 ($a,$i) = if (($i >= $s))
250- then $a
251- else throw("List size exceeds 10")
151+ func $f0_2 ($a,$i) = if (($i >= $s))
152+ then $a
153+ else throw("List size exceeds 10")
252154
253- $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)
254- } :+ IntegerEntry(userRewardFromDepositNumKEY, depositNumLast))
255- else throw(((("uncovered condition: depositNumLast=" + toString(depositNumLast)) + " depositNumUser=") + toString(depositNumUser)))
256- }
257-
258-
259-func IncrementNotDistributedRewardEntry (tkn,amountInc) = {
260- let notDistributedRewardKEY = keyNotDistributedReward(tkn)
261- let notDistributedReward = getIntOrElse(notDistributedRewardKEY, 0)
262-[IntegerEntry(notDistributedRewardKEY, (notDistributedReward + amountInc))]
263- }
264-
265-
266-func mergeVotingPowerEffectiveHeight (quarantinePeriod,vpEffectiveHeight,stakedAmt,stakedAmtNEW) = {
267- let remainingToWait = (vpEffectiveHeight - height)
268- if ((0 >= remainingToWait))
269- then (height + quarantinePeriod)
270- else {
271- let alreadyWaited = (quarantinePeriod - remainingToWait)
272- let kX8 = if ((stakedAmtNEW != 0))
273- then fraction(stakedAmt, MULT8, stakedAmtNEW)
274- else vpEffectiveHeight
275- ((quarantinePeriod + height) - fraction(alreadyWaited, kX8, MULT8))
276- }
277- }
278-
279-
280-func mergeStake (userAddress,amountToAdd) = {
281- let $t01065810768 = valueOrElse(getUserParamsOrUnit(userAddress), $Tuple3(true, 0, 0))
282- let isNewUser = $t01065810768._1
283- let stakedAmount = $t01065810768._2
284- let vpEffectiveHeight = $t01065810768._3
285- let stakedAmountNEW = if (isNewUser)
286- then amountToAdd
287- else (amountToAdd + stakedAmount)
288- let quarantinePeriod = (1440 * 14)
289- let vpEffectiveHeightNEW = if (isNewUser)
290- then (quarantinePeriod + height)
291- else mergeVotingPowerEffectiveHeight(quarantinePeriod, vpEffectiveHeight, stakedAmount, stakedAmountNEW)
292- $Tuple5(isNewUser, stakedAmount, vpEffectiveHeight, stakedAmountNEW, vpEffectiveHeightNEW)
293- }
294-
295-
296-func commonStake (userAddress,i) = {
297- let $t01125411308 = getParamsOrFail()
298- let stakedAssetId = $t01125411308._1
299- let minLockAmount = $t01125411308._2
300- if ((size(i.payments) != 1))
301- then throw("Invalid payments size")
302- else {
303- let payment = i.payments[0]
304- let amount = payment.amount
305- let invalidAssetMessage = (("Invalid asset. " + toBase58String(stakedAssetId)) + " is expected")
306- let assetId = valueOrErrorMessage(payment.assetId, invalidAssetMessage)
307- if ((assetId != stakedAssetId))
308- then throw(invalidAssetMessage)
309- else {
310- let userAddressStr = toString(userAddress)
311- let mergedData = mergeStake(userAddress, amount)
312- let isNewUser = mergedData._1
313- let stakedAmount = mergedData._2
314- let vpEffectiveHeight = mergedData._3
315- let stakedAmountNEW = mergedData._4
316- let vpEffectiveHeightNEW = mergedData._5
317- if ((minLockAmount > stakedAmountNEW))
318- then throw(("Min lock amount is " + toString(minLockAmount)))
319- else {
320- let $t01210712209 = StatsResult(amount, 1, if (isNewUser)
321- then 1
322- else 0)
323- let statsEntries = $t01210712209._1
324- let totalStaked = $t01210712209._2
325- let totalStakedNew = $t01210712209._3
326- ((([HistoryRecordEntry("stake", userAddress, i.transactionId, stakedAmount, vpEffectiveHeight, stakedAmountNEW, vpEffectiveHeightNEW)] ++ RewardEntries(isNewUser, userAddressStr, stakedAmount)) ++ LockParamsEntry(userAddress, stakedAmountNEW, vpEffectiveHeightNEW)) ++ statsEntries)
327- }
328- }
329- }
330- }
331-
332-
333-func commonClaim (userAddress,i) = {
334- let userAddressStr = toString(userAddress)
335- if ((size(i.payments) > 0))
336- then throw("payments are not accepted")
337- else {
338- let $t01268812793 = valueOrElse(getUserParamsOrUnit(userAddress), $Tuple3(true, 0, 0))
339- let isNewUser = $t01268812793._1
340- let stakedAmount = $t01268812793._2
341- let stakingStart = $t01268812793._3
342- let stakedAmountX = toBigInt(stakedAmount)
343- let userRewardFromDepositNumKEY = keyUserRewardFromDepositNum(userAddressStr)
344- let depositNumUser = getIntOrElse(userRewardFromDepositNumKEY, -1)
345- let depositNumLast = getIntOrElse(keyDepositNumLast(), -1)
346- func forEachAssetCalcUnclaimedReward (accum,asset) = {
347- let $t01316413302 = calcReward(userAddressStr, asset, stakedAmountX, depositNumUser, depositNumLast)
348- let rewardTotal = $t01316413302._1
349- let cached = $t01316413302._2
350- let dynamic = $t01316413302._3
351- let rewardCachedPartKEY = $t01316413302._4
352- let claimedKEY = keyClaimed(userAddressStr, asset)
353- let $t01336213399 = accum
354- let data = $t01336213399._1
355- let claimedAmtByAsset = $t01336213399._2
356- let newPart = makeString([asset, toString(rewardTotal)], ":")
357- let claimedAmtByAssetNew = makeString([claimedAmtByAsset, newPart], "_")
358- if ((0 >= rewardTotal))
359- then $Tuple2(data, claimedAmtByAssetNew)
360- else $Tuple2((((data :+ ScriptTransfer(userAddress, rewardTotal, toAssetVect(asset))) :+ IntegerEntry(claimedKEY, (valueOrElse(getInteger(claimedKEY), 0) + rewardTotal))) :+ IntegerEntry(rewardCachedPartKEY, 0)), claimedAmtByAssetNew)
361- }
362-
363- let $t01385913973 = {
364- let $l = supportedAssetsList
365- let $s = size($l)
366- let $acc0 = $Tuple2(nil, "")
367- func $f0_1 ($a,$i) = if (($i >= $s))
368- then $a
369- else forEachAssetCalcUnclaimedReward($a, $l[$i])
370-
371- func $f0_2 ($a,$i) = if (($i >= $s))
372- then $a
373- else throw("List size exceeds 10")
374-
375- $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)
376- }
377- let transfers = $t01385913973._1
378- let claimedAmtByAssetResult = $t01385913973._2
379- if ((0 >= size(transfers)))
380- then nil
381- else ((transfers :+ IntegerEntry(userRewardFromDepositNumKEY, depositNumLast)) :+ ClaimHistoryEntry(userAddress, i.transactionId, drop(claimedAmtByAssetResult, 1)))
382- }
155+ $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)
383156 }
384157
385158
386159 @Callable(i)
387-func constructor (minLockAmount,supportedRewardAssets,stakedAssetId) = if ((i.caller != this))
388- then throw("Permission denied")
389- else [IntegerEntry(keyMinLockAmount(), minLockAmount), StringEntry(keySupportedRewardAssets(), supportedRewardAssets), StringEntry(keyStakedAssetId(), stakedAssetId)]
160+func constructorV1 (controlAddress58,restAddress58) = if ((i.caller != this))
161+ then throw("not authorized")
162+ else [StringEntry(keyControlAddress(), controlAddress58), StringEntry(keyRestAddress(), restAddress58)]
390163
391164
392165
393166 @Callable(i)
394-func stake () = commonStake(i.caller, i)
395-
396-
397-
398-@Callable(i)
399-func stakeByOriginCaller () = commonStake(i.originCaller, i)
400-
401-
402-
403-@Callable(i)
404-func unstake (amount) = if ((size(i.payments) != 0))
405- then throw("unstake doesn't require any payment")
406- else {
407- let userAddress = i.caller
408- let userAddressStr = toString(userAddress)
409- let $t01488214936 = getParamsOrFail()
410- let stakedAssetId = $t01488214936._1
411- let minLockAmount = $t01488214936._2
412- let $t01493915023 = getUserParamsOrFail(userAddress)
413- let isNewUser = $t01493915023._1
414- let stakedAmount = $t01493915023._2
415- let vpEffectiveHeight = $t01493915023._3
416- let swapParamsSTRUCT = asSwapParamsSTRUCT(reentrantInvoke(neutrinoContract, "swapParamsByUserSYSREADONLY", [userAddressStr, 0], nil))
417- let swapLimitSpentInUsdn = swapParamsSTRUCT._2
418- let blcks2LmtReset = swapParamsSTRUCT._3
419- if ((swapLimitSpentInUsdn > 0))
420- then throw((("You have already made a swap operation. Wait " + toString((height + blcks2LmtReset))) + " height to unstake"))
421- else if ((0 >= stakedAmount))
422- then throw("Nothing to unstake")
423- else if ((amount > stakedAmount))
424- then throw(((("Requested " + toString(amount)) + ", but staked only ") + toString(stakedAmount)))
425- else {
426- let stakedAmountNEW = (stakedAmount - amount)
427- let $t01566115819 = StatsResult(-(amount), if ((amount == stakedAmount))
428- then -1
429- else 0, if ((amount == stakedAmount))
430- then -1
431- else 0)
432- let statsEntries = $t01566115819._1
433- let totalStaked = $t01566115819._2
434- let totalStakedNew = $t01566115819._3
435- ((([ScriptTransfer(userAddress, amount, stakedAssetId), HistoryRecordEntry("unstake", userAddress, i.transactionId, stakedAmount, vpEffectiveHeight, stakedAmountNEW, vpEffectiveHeight)] ++ RewardEntries(false, userAddressStr, stakedAmount)) ++ LockParamsEntry(userAddress, stakedAmountNEW, vpEffectiveHeight)) ++ statsEntries)
436- }
437- }
438-
439-
440-
441-@Callable(i)
442-func deposit () = if ((size(i.payments) != 1))
443- then throw("exact 1 payment is allowed only")
444- else {
445- let pmt = i.payments[0]
446- let amount = pmt.amount
447- let pmtAssetId = value(pmt.assetId)
448- let pmtAssetIdStr = toBase58String(pmtAssetId)
449- let pmtMultX = MULTX6
450- let amountX = toBigInt(amount)
451- let totalStaked = getIntOrElse(keyLockParamTotalAmount(), 0)
452- let totalStakedX = toBigInt(totalStaked)
453- if ((0 > totalStaked))
454- then throw("TODO: case is not supported")
455- else if ((totalStaked == 0))
456- then IncrementNotDistributedRewardEntry(pmtAssetIdStr, amount)
457- else {
458- let rewardPerNsbtX18 = fraction(amountX, MULTX18, totalStakedX)
459- let depositNumLastKEY = keyDepositNumLast()
460- let depositNumLast = getIntOrElse(depositNumLastKEY, -1)
461- let depositNumNew = (depositNumLast + 1)
462- if (!(contains(supportedAssetsStr, pmtAssetIdStr)))
463- then throw(((supportedAssetsStr + " doesn't contain ") + pmtAssetIdStr))
464- else {
465- func refreshRewardPerNsbtSUM (accum,nextAsset) = {
466- let rewardPerNsbtSumNewKEY = keyRewardPerNsbtSumAt(depositNumNew, nextAsset)
467- let sumLastStr = getStrOrElse(keyRewardPerNsbtSumAt(depositNumLast, nextAsset), "0")
468- (accum :+ (if ((nextAsset == pmtAssetIdStr))
469- then StringEntry(rewardPerNsbtSumNewKEY, toString((parseBigIntValue(sumLastStr) + rewardPerNsbtX18)))
470- else StringEntry(rewardPerNsbtSumNewKEY, sumLastStr)))
471- }
472-
473- ({
474- let $l = supportedAssetsList
475- let $s = size($l)
476- let $acc0 = nil
477- func $f0_1 ($a,$i) = if (($i >= $s))
478- then $a
479- else refreshRewardPerNsbtSUM($a, $l[$i])
480-
481- func $f0_2 ($a,$i) = if (($i >= $s))
482- then $a
483- else throw("List size exceeds 10")
484-
485- $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)
486- } :+ IntegerEntry(depositNumLastKEY, depositNumNew))
487- }
488- }
489- }
490-
491-
492-
493-@Callable(i)
494-func claimRewards () = commonClaim(i.caller, i)
495-
496-
497-
498-@Callable(i)
499-func claimRewardsByOriginCaller () = commonClaim(i.originCaller, i)
500-
501-
502-
503-@Callable(i)
504-func unclaimedRewardsREADONLY (userAddressStr) = {
505- func forEachAssetZeroReward (accum,asset) = ((accum + makeString([asset, "0", "0"], ":")) + "_")
506-
507- let unclaimedRewardStr = if ((userAddressStr == ""))
508- then {
509- let $l = supportedAssetsList
510- let $s = size($l)
511- let $acc0 = ""
512- func $f0_1 ($a,$i) = if (($i >= $s))
513- then $a
514- else forEachAssetZeroReward($a, $l[$i])
515-
516- func $f0_2 ($a,$i) = if (($i >= $s))
517- then $a
518- else throw("List size exceeds 10")
519-
520- $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)
521- }
522- else {
523- let userAddress = addressFromStringValue(userAddressStr)
524- let $t01833618441 = valueOrElse(getUserParamsOrUnit(userAddress), $Tuple3(true, 0, 0))
525- let isNewUser = $t01833618441._1
526- let stakedAmount = $t01833618441._2
527- let stakingStart = $t01833618441._3
528- let stakedAmountX = toBigInt(stakedAmount)
529- let userRewardFromDepositNumKEY = keyUserRewardFromDepositNum(userAddressStr)
530- let depositNumUser = getIntOrElse(userRewardFromDepositNumKEY, -1)
531- let depositNumLast = getIntOrElse(keyDepositNumLast(), -1)
532- func forEachAssetCalcUnclaimedReward (accum,asset) = {
533- let $t01878718925 = calcReward(userAddressStr, asset, stakedAmountX, depositNumUser, depositNumLast)
534- let rewardTotal = $t01878718925._1
535- let cached = $t01878718925._2
536- let dynamic = $t01878718925._3
537- let rewardCachedPartKEY = $t01878718925._4
538- let claimed = valueOrElse(getInteger(keyClaimed(userAddressStr, asset)), 0)
539- ((accum + makeString([asset, toString(rewardTotal), toString(claimed)], ":")) + "_")
540- }
541-
542- let $l = supportedAssetsList
543- let $s = size($l)
544- let $acc0 = ""
545- func $f0_1 ($a,$i) = if (($i >= $s))
546- then $a
547- else forEachAssetCalcUnclaimedReward($a, $l[$i])
548-
549- func $f0_2 ($a,$i) = if (($i >= $s))
550- then $a
551- else throw("List size exceeds 10")
552-
553- $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)
554- }
555- $Tuple2(nil, dropRight(unclaimedRewardStr, 1))
167+func stakeNsbtPageREADONLY (userAddressStrOpt,nsbtAmtDiff) = {
168+ let gnsbtInfo = asString(invoke(restAcc, "gnsbtInfoREADONLY", [userAddressStrOpt, nsbtAmtDiff], nil))
169+ let swapInfo = asString(invoke(restAcc, "swapInfoREADONLY", [userAddressStrOpt], nil))
170+ $Tuple2(nil, produceJson(["gnsbtInfoREADONLY", gnsbtInfo, "swapInfoREADONLY", swapInfo]))
556171 }
557172
558173
559174
560175 @Callable(i)
561-func usdnStakingSYSREADONLY (userAddressStrOrEmpty,usdnDiff) = {
562- let usdnTotal = getIntOrElse(keyLockParamTotalAmount(), 0)
563- if ((userAddressStrOrEmpty == ""))
564- then $Tuple2(nil, [0, usdnTotal, 0, 0, 0, height, height])
565- else {
566- let userAddress = toAddressOrFail(userAddressStrOrEmpty)
567- let mergedData = mergeStake(userAddress, usdnDiff)
568- let isNewUser = mergedData._1
569- let stakedAmount = mergedData._2
570- let vpEffectiveHeight = mergedData._3
571- let stakedAmountNEW = mergedData._4
572- let vpEffectiveHeightNEW = mergedData._5
573- let usdnUser = stakedAmount
574- $Tuple2(nil, [usdnUser, usdnTotal, 0, 0, vpEffectiveHeight, vpEffectiveHeightNEW])
575- }
176+func buyNsbtPageREADONLY (userAddressStrOpt) = {
177+ let gnsbtInfo = asString(invoke(restAcc, "gnsbtInfoREADONLY", [userAddressStrOpt, 0], nil))
178+ let neutrinoStats = asString(invoke(restAcc, "neutrinoStatsREADONLY", nil, nil))
179+ $Tuple2(nil, produceJson(["gnsbtInfoREADONLY", gnsbtInfo, "neutrinoStatsREADONLY", neutrinoStats]))
576180 }
577181
578182
579183
580184 @Callable(i)
581-func configSYSREADONLY () = {
582- let minLockAmt = getIntegerValue(keyMinLockAmount())
583- $Tuple2(nil, [minLockAmt])
185+func buySurfPageREADONLY (userAddressStrOpt,amount,assetIdStr) = {
186+ let neutrinoStats = asString(invoke(restAcc, "neutrinoStatsREADONLY", nil, nil))
187+ let surfBuy = asString(invoke(restAcc, "buySurfREADONLY", [userAddressStrOpt, amount, assetIdStr], nil))
188+ let neutrinoCfg = asString(invoke(restAcc, "neutrinoConfigREADONLY", nil, nil))
189+ $Tuple2(nil, produceJson(["neutrinoStatsREADONLY", neutrinoStats, "buySurfREADONLY", surfBuy, "neutrinoConfigREADONLY", neutrinoCfg]))
190+ }
191+
192+
193+
194+@Callable(i)
195+func walletPageREADONLY (userAddressStr) = {
196+ let walletInfo = asString(invoke(restAcc, "walletInfoREADONLY", [userAddressStr], nil))
197+ $Tuple2(nil, produceJson(["walletInfoREADONLY", walletInfo]))
198+ }
199+
200+
201+
202+@Callable(i)
203+func genericREADONLY (payload) = {
204+ let funcsIndexes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
205+ let paramIndexes = [1, 3, 5, 7, 9, 11]
206+ let payloadArr = split(payload, SEP)
207+ let payloadSize = size(payloadArr)
208+ func invokesAgregator (accum,funcIdx) = if ((funcIdx >= payloadSize))
209+ then accum
210+ else {
211+ let call = payloadArr[funcIdx]
212+ let callArr = split(call, "+")
213+ let address = addressFromStringValue(callArr[0])
214+ let funcName = callArr[1]
215+ let paramsArr = split(callArr[2], ":")
216+ let paramsSize = size(paramsArr)
217+ func paramsAgregator (paramsAcc,paramIdx) = if ((paramIdx >= paramsSize))
218+ then paramsAcc
219+ else {
220+ let p = if ((paramsArr[(paramIdx - 1)] == "s"))
221+ then paramsArr[paramIdx]
222+ else parseIntValue(paramsArr[paramIdx])
223+ (paramsAcc :+ p)
224+ }
225+
226+ let params = {
227+ let $l = paramIndexes
228+ let $s = size($l)
229+ let $acc0 = nil
230+ func $f0_1 ($a,$i) = if (($i >= $s))
231+ then $a
232+ else paramsAgregator($a, $l[$i])
233+
234+ func $f0_2 ($a,$i) = if (($i >= $s))
235+ then $a
236+ else throw("List size exceeds 6")
237+
238+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
239+ }
240+ let result = asString(invoke(address, funcName, params, nil))
241+ (accum ++ [funcName, result])
242+ }
243+
244+ let invokesResults = {
245+ let $l = funcsIndexes
246+ let $s = size($l)
247+ let $acc0 = nil
248+ func $f0_1 ($a,$i) = if (($i >= $s))
249+ then $a
250+ else invokesAgregator($a, $l[$i])
251+
252+ func $f0_2 ($a,$i) = if (($i >= $s))
253+ then $a
254+ else throw("List size exceeds 10")
255+
256+ $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)
257+ }
258+ $Tuple2(nil, produceJson(invokesResults))
584259 }
585260
586261
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let revisionNum = ""
5-
6-let separator = "__"
7-
84 let SEP = "__"
9-
10-let MULT6 = 1000000
11-
12-let MULT8 = 100000000
13-
14-let MULTX6 = toBigInt(MULT6)
15-
16-let MULTX8 = toBigInt(MULT8)
17-
18-let MULTX18 = toBigInt(1000000000000000000)
195
206 let IdxControlCfgNeutrinoDapp = 1
217
228 let IdxControlCfgAuctionDapp = 2
239
2410 let IdxControlCfgRpdDapp = 3
2511
2612 let IdxControlCfgMathDapp = 4
2713
2814 let IdxControlCfgLiquidationDapp = 5
2915
3016 let IdxControlCfgRestDapp = 6
3117
3218 let IdxControlCfgNodeRegistryDapp = 7
3319
3420 let IdxControlCfgNsbtStakingDapp = 8
3521
3622 let IdxControlCfgMediatorDapp = 9
37-
38-let IdxControlCfgSurfStakingDapp = 10
39-
40-let IdxControlCfgGnsbtControllerDapp = 11
4123
4224 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
4325
4426
4527 func keyControlAddress () = "%s%s__config__controlAddress"
4628
4729
4830 func keyControlCfg () = "%s__controlConfig"
4931
5032
5133 func readControlCfgOrFail (control) = split(getStringOrFail(control, keyControlCfg()), SEP)
5234
5335
5436 func getContractAddressOrFail (controlCfg,idx) = valueOrErrorMessage(addressFromString(controlCfg[idx]), ("Control cfg doesn't contain address at index " + toString(idx)))
5537
5638
5739 let controlContract = addressFromStringValue(valueOrElse(getString(this, keyControlAddress()), "3P5Bfd58PPfNvBM2Hy8QfbcDqMeNtzg7KfP"))
5840
5941 let controlCfg = readControlCfgOrFail(controlContract)
6042
61-let mathContract = getContractAddressOrFail(controlCfg, IdxControlCfgMathDapp)
43+let restAcc = getContractAddressOrFail(controlCfg, IdxControlCfgRestDapp)
6244
63-let neutrinoContract = getContractAddressOrFail(controlCfg, IdxControlCfgNeutrinoDapp)
64-
65-let auctionContract = getContractAddressOrFail(controlCfg, IdxControlCfgAuctionDapp)
66-
67-func keyBondAsset () = "bond_asset_id"
45+func keyRestAddress () = "%s%s__config__restAddress"
6846
6947
70-func keyAuctionContractAddress () = "auction_contract"
48+func getStrOrFail (key) = valueOrErrorMessage(getString(this, key), (("Mandatory this." + key) + " is not defined"))
7149
7250
73-func keyMinLockAmount () = "%s__minLockAmount"
51+func getAddressOrFail (key) = valueOrErrorMessage(addressFromString(getStrOrFail(key)), ("fail to parse address for this." + key))
7452
7553
76-func keyStakedAssetId () = "%s__stakedAssetId"
77-
78-
79-func keyLockParamUserAmount (userAddress) = makeString(["%s%s%s", "paramByUser", toString(userAddress), "amount"], separator)
80-
81-
82-func keyLockParamStartBlock (userAddress) = makeString(["%s%s%s", "paramByUser", toString(userAddress), "start"], separator)
83-
84-
85-func keyLockParamVotingPowerEffectiveHeight (userAddress) = makeString(["%s%s%s", "paramByUser", toString(userAddress), "vpEffectiveHeight"], separator)
86-
87-
88-func keyHistoryRecord (type,userAddress,txId) = makeString(["%s%s%s%s", "history", type, toString(userAddress), toBase58String(txId)], separator)
89-
90-
91-func keyLockParamTotalAmount () = makeString(["%s%s", "stats", "activeTotalLocked"], separator)
92-
93-
94-func keyStatsLocksCount () = makeString(["%s%s", "stats", "locksCount"], separator)
95-
96-
97-func keyStatsUsersCount () = makeString(["%s%s", "stats", "activeUsersCount"], separator)
98-
99-
100-func keyNextPeriod () = "%s__nextPeriod"
101-
102-
103-func keySupportedRewardAssets () = "supportedRewardAssets"
104-
105-
106-func keyDepositNumLast () = makeString(["%s%s%s", "dep", "lastNum"], separator)
107-
108-
109-func keyUserRewardFromDepositNum (userAddress) = makeString(["%s%s%s", "userRwdFromDepNum", userAddress], separator)
110-
111-
112-func keyRewardPerNsbtSumAt (depositNum,tkn) = makeString(["%s%d", "rwdPerNsbtSumByDepNum", toString(depositNum), tkn], separator)
113-
114-
115-func keyReward (userAddress,tkn) = makeString(["%s%s%s", "rwd", userAddress, tkn], separator)
116-
117-
118-func keyClaimed (userAddress,tkn) = makeString(["%s%s%s", "clm", userAddress, tkn], separator)
119-
120-
121-func keyNotDistributedReward (tkn) = makeString(["%s%s", "notDistributed", tkn], separator)
122-
123-
124-func toX18 (origVal,origMult) = fraction(toBigInt(origVal), MULTX18, origMult)
125-
126-
127-func getIntOrZero (key) = valueOrElse(getInteger(this, key), 0)
128-
129-
130-func getIntOrElse (key,defaultVal) = valueOrElse(getInteger(this, key), defaultVal)
131-
132-
133-func getIntOrFail (key) = valueOrErrorMessage(getInteger(this, key), (("Mandatory this." + key) + " is not defined"))
134-
135-
136-func getStrOrElse (key,defaultVal) = valueOrElse(getString(this, key), defaultVal)
137-
138-
139-func toAddressOrFail (addressStr) = valueOrErrorMessage(addressFromString(addressStr), ("couldn't parse passed addressStr=" + addressStr))
140-
141-
142-func toAssetVect (assetStr) = fromBase58String(assetStr)
143-
144-
145-func asInt (val) = match val {
146- case valInt: Int =>
147- valInt
54+func asString (val) = match val {
55+ case valStr: String =>
56+ valStr
14857 case _ =>
149- throw("fail to cast into Int")
58+ throw("fail to cast into String")
15059 }
15160
15261
153-func asSwapParamsSTRUCT (v) = match v {
154- case struct: (Int, Int, Int, Int, Int, Int, Int) =>
155- struct
156- case _ =>
157- throw("fail to cast into Int")
158-}
62+func produceJson (strMap) = {
63+ let indexes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
64+ let length = size(strMap)
65+ if (((length % 2) != 0))
66+ then throw("only even args size is accepeted")
67+ else if ((length > size(indexes)))
68+ then throw(("strMap length is greater then " + toString(size(indexes))))
69+ else {
70+ func produceJson (jsonAccum,nextIdx) = if (if (((nextIdx % 2) == 0))
71+ then (length >= (nextIdx + 1))
72+ else false)
73+ then (((((jsonAccum + "
74+\"") + strMap[nextIdx]) + "\": \"") + strMap[(nextIdx + 1)]) + "\",")
75+ else jsonAccum
15976
77+ let preJsonResult = {
78+ let $l = indexes
79+ let $s = size($l)
80+ let $acc0 = ""
81+ func $f0_1 ($a,$i) = if (($i >= $s))
82+ then $a
83+ else produceJson($a, $l[$i])
16084
161-func formatHistoryRecord (oldAmount,oldStart,newAmount,newStart) = makeString(["%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(oldAmount), toString(oldStart), toString(newAmount), toString(newStart)], separator)
85+ func $f0_2 ($a,$i) = if (($i >= $s))
86+ then $a
87+ else throw("List size exceeds 20")
16288
163-
164-func formatClaimHistoryRecord (user,claimedRewards) = makeString(["%s%d%d%s", user, toString(lastBlock.height), toString(lastBlock.timestamp), claimedRewards], separator)
165-
166-
167-func HistoryRecordEntry (type,userAddress,txId,oldAmount,oldStart,newAmount,newStart) = StringEntry(keyHistoryRecord(type, userAddress, txId), formatHistoryRecord(oldAmount, oldStart, newAmount, newStart))
168-
169-
170-func ClaimHistoryEntry (userAddress,txId,claimedRewards) = StringEntry(keyHistoryRecord("claim", userAddress, txId), formatClaimHistoryRecord(toString(userAddress), claimedRewards))
171-
172-
173-func StatsResult (totalLockedInc,lockCountInc,usersCountInc) = {
174- let locksCount = getIntOrZero(keyStatsLocksCount())
175- let usersCount = getIntOrZero(keyStatsUsersCount())
176- let totalAmount = getIntOrZero(keyLockParamTotalAmount())
177- let totalAmountNew = (totalAmount + totalLockedInc)
178- $Tuple3([IntegerEntry(keyStatsLocksCount(), (locksCount + lockCountInc)), IntegerEntry(keyStatsUsersCount(), (usersCount + usersCountInc)), IntegerEntry(keyLockParamTotalAmount(), totalAmountNew)], totalAmount, totalAmountNew)
89+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20)
90+ }
91+ (("{" + dropRight(preJsonResult, 1)) + "}")
92+ }
17993 }
18094
18195
182-func LockParamsEntry (userAddress,amount,votingPowerEffectiveHeight) = [IntegerEntry(keyLockParamUserAmount(userAddress), amount), IntegerEntry(keyLockParamStartBlock(userAddress), votingPowerEffectiveHeight)]
96+func genericV2READONLY (x) = {
97+ func call (a,e) = (a :+ invoke(Address(fromBase58String(e._1)), e._2, e._3, nil))
18398
99+ let $l = x
100+ let $s = size($l)
101+ let $acc0 = nil
102+ func $f0_1 ($a,$i) = if (($i >= $s))
103+ then $a
104+ else call($a, $l[$i])
184105
185-func getParamsOrFail () = $Tuple2(fromBase58String(getStringOrFail(this, keyStakedAssetId())), getIntOrFail(keyMinLockAmount()))
106+ func $f0_2 ($a,$i) = if (($i >= $s))
107+ then $a
108+ else throw("List size exceeds 10")
186109
187-
188-func isActiveUser (userAddress) = (getIntOrElse(keyLockParamUserAmount(userAddress), 0) > 0)
189-
190-
191-func getUserParamsOrUnit (userAddress) = if (isActiveUser(userAddress))
192- then $Tuple3(false, getIntOrFail(keyLockParamUserAmount(userAddress)), getIntOrFail(keyLockParamStartBlock(userAddress)))
193- else unit
194-
195-
196-func getUserParamsOrFail (userAddress) = valueOrErrorMessage(getUserParamsOrUnit(userAddress), (("User " + toString(userAddress)) + " is not defined"))
197-
198-
199-let supportedAssetsStr = getStrOrElse(keySupportedRewardAssets(), "")
200-
201-let supportedAssetsList = split(supportedAssetsStr, "_")
202-
203-func calcReward (userAddress,assetId,stakedAmountX,depositNumUser,depositNumLast) = {
204- let rewardPerNsbtSumLastKEY = keyRewardPerNsbtSumAt(depositNumLast, assetId)
205- let sumLastX18 = parseBigIntValue(getStrOrElse(keyRewardPerNsbtSumAt(depositNumLast, assetId), "0"))
206- let sumUserX18 = parseBigIntValue(getStrOrElse(keyRewardPerNsbtSumAt(depositNumUser, assetId), "0"))
207- let rewardDynamicPart = toInt(fraction((sumLastX18 - sumUserX18), stakedAmountX, MULTX18))
208- let rewardCachedPartKEY = keyReward(userAddress, assetId)
209- let rewardCachedPart = getIntOrElse(rewardCachedPartKEY, 0)
210- $Tuple4((rewardCachedPart + rewardDynamicPart), rewardCachedPart, rewardDynamicPart, rewardCachedPartKEY)
110+ $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)
211111 }
212112
213113
214-func RewardEntries (isNewUser,userAddress,stakedAmount) = {
215- let stakedAmountX = toBigInt(stakedAmount)
216- let userRewardFromDepositNumKEY = keyUserRewardFromDepositNum(userAddress)
217- let depositNumUser = getIntOrElse(userRewardFromDepositNumKEY, -1)
218- let depositNumLast = getIntOrElse(keyDepositNumLast(), -1)
219- func forEachAssetCacheUserReward (accum,asset) = {
220- let $t087088843 = calcReward(userAddress, asset, stakedAmountX, depositNumUser, depositNumLast)
221- let rewardTotal = $t087088843._1
222- let cached = $t087088843._2
223- let dynamic = $t087088843._3
224- let rewardCachedPartKEY = $t087088843._4
225- (accum :+ IntegerEntry(rewardCachedPartKEY, rewardTotal))
114+func genericV3READONLY (x) = {
115+ func call (a,e) = {
116+ let dApp = Address(fromBase58String(e._1))
117+ let name = e._2
118+ let opType = e._3
119+ let params = e._4
120+ let res = if ((opType == "invoke"))
121+ then invoke(dApp, name, params, nil)
122+ else if ((opType == "binKey"))
123+ then getBinary(dApp, name)
124+ else if ((opType == "binValKey"))
125+ then getBinaryValue(dApp, name)
126+ else if ((opType == "boolKey"))
127+ then getBoolean(dApp, name)
128+ else if ((opType == "boolValKey"))
129+ then getBooleanValue(dApp, name)
130+ else if ((opType == "intKey"))
131+ then getInteger(dApp, name)
132+ else if ((opType == "intValKey"))
133+ then getIntegerValue(dApp, name)
134+ else if ((opType == "strKey"))
135+ then getString(dApp, name)
136+ else if ((opType == "strValKey"))
137+ then getStringValue(dApp, name)
138+ else if ((opType == "hasData"))
139+ then !(isDataStorageUntouched(dApp))
140+ else throw(("not supported operation type: " + opType))
141+ (a :+ res)
226142 }
227143
228- if (if ((depositNumLast == -1))
229- then (depositNumUser == -1)
230- else false)
231- then nil
232- else if (if ((depositNumLast == -1))
233- then (depositNumUser > -1)
234- else false)
235- then throw("invalid depositNumLast and depositNumUser state")
236- else if (if ((depositNumLast > -1))
237- then (depositNumUser >= -1)
238- else false)
239- then if (isNewUser)
240- then [IntegerEntry(userRewardFromDepositNumKEY, depositNumLast)]
241- else ({
242- let $l = supportedAssetsList
243- let $s = size($l)
244- let $acc0 = nil
245- func $f0_1 ($a,$i) = if (($i >= $s))
246- then $a
247- else forEachAssetCacheUserReward($a, $l[$i])
144+ let $l = x
145+ let $s = size($l)
146+ let $acc0 = nil
147+ func $f0_1 ($a,$i) = if (($i >= $s))
148+ then $a
149+ else call($a, $l[$i])
248150
249- func $f0_2 ($a,$i) = if (($i >= $s))
250- then $a
251- else throw("List size exceeds 10")
151+ func $f0_2 ($a,$i) = if (($i >= $s))
152+ then $a
153+ else throw("List size exceeds 10")
252154
253- $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)
254- } :+ IntegerEntry(userRewardFromDepositNumKEY, depositNumLast))
255- else throw(((("uncovered condition: depositNumLast=" + toString(depositNumLast)) + " depositNumUser=") + toString(depositNumUser)))
256- }
257-
258-
259-func IncrementNotDistributedRewardEntry (tkn,amountInc) = {
260- let notDistributedRewardKEY = keyNotDistributedReward(tkn)
261- let notDistributedReward = getIntOrElse(notDistributedRewardKEY, 0)
262-[IntegerEntry(notDistributedRewardKEY, (notDistributedReward + amountInc))]
263- }
264-
265-
266-func mergeVotingPowerEffectiveHeight (quarantinePeriod,vpEffectiveHeight,stakedAmt,stakedAmtNEW) = {
267- let remainingToWait = (vpEffectiveHeight - height)
268- if ((0 >= remainingToWait))
269- then (height + quarantinePeriod)
270- else {
271- let alreadyWaited = (quarantinePeriod - remainingToWait)
272- let kX8 = if ((stakedAmtNEW != 0))
273- then fraction(stakedAmt, MULT8, stakedAmtNEW)
274- else vpEffectiveHeight
275- ((quarantinePeriod + height) - fraction(alreadyWaited, kX8, MULT8))
276- }
277- }
278-
279-
280-func mergeStake (userAddress,amountToAdd) = {
281- let $t01065810768 = valueOrElse(getUserParamsOrUnit(userAddress), $Tuple3(true, 0, 0))
282- let isNewUser = $t01065810768._1
283- let stakedAmount = $t01065810768._2
284- let vpEffectiveHeight = $t01065810768._3
285- let stakedAmountNEW = if (isNewUser)
286- then amountToAdd
287- else (amountToAdd + stakedAmount)
288- let quarantinePeriod = (1440 * 14)
289- let vpEffectiveHeightNEW = if (isNewUser)
290- then (quarantinePeriod + height)
291- else mergeVotingPowerEffectiveHeight(quarantinePeriod, vpEffectiveHeight, stakedAmount, stakedAmountNEW)
292- $Tuple5(isNewUser, stakedAmount, vpEffectiveHeight, stakedAmountNEW, vpEffectiveHeightNEW)
293- }
294-
295-
296-func commonStake (userAddress,i) = {
297- let $t01125411308 = getParamsOrFail()
298- let stakedAssetId = $t01125411308._1
299- let minLockAmount = $t01125411308._2
300- if ((size(i.payments) != 1))
301- then throw("Invalid payments size")
302- else {
303- let payment = i.payments[0]
304- let amount = payment.amount
305- let invalidAssetMessage = (("Invalid asset. " + toBase58String(stakedAssetId)) + " is expected")
306- let assetId = valueOrErrorMessage(payment.assetId, invalidAssetMessage)
307- if ((assetId != stakedAssetId))
308- then throw(invalidAssetMessage)
309- else {
310- let userAddressStr = toString(userAddress)
311- let mergedData = mergeStake(userAddress, amount)
312- let isNewUser = mergedData._1
313- let stakedAmount = mergedData._2
314- let vpEffectiveHeight = mergedData._3
315- let stakedAmountNEW = mergedData._4
316- let vpEffectiveHeightNEW = mergedData._5
317- if ((minLockAmount > stakedAmountNEW))
318- then throw(("Min lock amount is " + toString(minLockAmount)))
319- else {
320- let $t01210712209 = StatsResult(amount, 1, if (isNewUser)
321- then 1
322- else 0)
323- let statsEntries = $t01210712209._1
324- let totalStaked = $t01210712209._2
325- let totalStakedNew = $t01210712209._3
326- ((([HistoryRecordEntry("stake", userAddress, i.transactionId, stakedAmount, vpEffectiveHeight, stakedAmountNEW, vpEffectiveHeightNEW)] ++ RewardEntries(isNewUser, userAddressStr, stakedAmount)) ++ LockParamsEntry(userAddress, stakedAmountNEW, vpEffectiveHeightNEW)) ++ statsEntries)
327- }
328- }
329- }
330- }
331-
332-
333-func commonClaim (userAddress,i) = {
334- let userAddressStr = toString(userAddress)
335- if ((size(i.payments) > 0))
336- then throw("payments are not accepted")
337- else {
338- let $t01268812793 = valueOrElse(getUserParamsOrUnit(userAddress), $Tuple3(true, 0, 0))
339- let isNewUser = $t01268812793._1
340- let stakedAmount = $t01268812793._2
341- let stakingStart = $t01268812793._3
342- let stakedAmountX = toBigInt(stakedAmount)
343- let userRewardFromDepositNumKEY = keyUserRewardFromDepositNum(userAddressStr)
344- let depositNumUser = getIntOrElse(userRewardFromDepositNumKEY, -1)
345- let depositNumLast = getIntOrElse(keyDepositNumLast(), -1)
346- func forEachAssetCalcUnclaimedReward (accum,asset) = {
347- let $t01316413302 = calcReward(userAddressStr, asset, stakedAmountX, depositNumUser, depositNumLast)
348- let rewardTotal = $t01316413302._1
349- let cached = $t01316413302._2
350- let dynamic = $t01316413302._3
351- let rewardCachedPartKEY = $t01316413302._4
352- let claimedKEY = keyClaimed(userAddressStr, asset)
353- let $t01336213399 = accum
354- let data = $t01336213399._1
355- let claimedAmtByAsset = $t01336213399._2
356- let newPart = makeString([asset, toString(rewardTotal)], ":")
357- let claimedAmtByAssetNew = makeString([claimedAmtByAsset, newPart], "_")
358- if ((0 >= rewardTotal))
359- then $Tuple2(data, claimedAmtByAssetNew)
360- else $Tuple2((((data :+ ScriptTransfer(userAddress, rewardTotal, toAssetVect(asset))) :+ IntegerEntry(claimedKEY, (valueOrElse(getInteger(claimedKEY), 0) + rewardTotal))) :+ IntegerEntry(rewardCachedPartKEY, 0)), claimedAmtByAssetNew)
361- }
362-
363- let $t01385913973 = {
364- let $l = supportedAssetsList
365- let $s = size($l)
366- let $acc0 = $Tuple2(nil, "")
367- func $f0_1 ($a,$i) = if (($i >= $s))
368- then $a
369- else forEachAssetCalcUnclaimedReward($a, $l[$i])
370-
371- func $f0_2 ($a,$i) = if (($i >= $s))
372- then $a
373- else throw("List size exceeds 10")
374-
375- $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)
376- }
377- let transfers = $t01385913973._1
378- let claimedAmtByAssetResult = $t01385913973._2
379- if ((0 >= size(transfers)))
380- then nil
381- else ((transfers :+ IntegerEntry(userRewardFromDepositNumKEY, depositNumLast)) :+ ClaimHistoryEntry(userAddress, i.transactionId, drop(claimedAmtByAssetResult, 1)))
382- }
155+ $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)
383156 }
384157
385158
386159 @Callable(i)
387-func constructor (minLockAmount,supportedRewardAssets,stakedAssetId) = if ((i.caller != this))
388- then throw("Permission denied")
389- else [IntegerEntry(keyMinLockAmount(), minLockAmount), StringEntry(keySupportedRewardAssets(), supportedRewardAssets), StringEntry(keyStakedAssetId(), stakedAssetId)]
160+func constructorV1 (controlAddress58,restAddress58) = if ((i.caller != this))
161+ then throw("not authorized")
162+ else [StringEntry(keyControlAddress(), controlAddress58), StringEntry(keyRestAddress(), restAddress58)]
390163
391164
392165
393166 @Callable(i)
394-func stake () = commonStake(i.caller, i)
395-
396-
397-
398-@Callable(i)
399-func stakeByOriginCaller () = commonStake(i.originCaller, i)
400-
401-
402-
403-@Callable(i)
404-func unstake (amount) = if ((size(i.payments) != 0))
405- then throw("unstake doesn't require any payment")
406- else {
407- let userAddress = i.caller
408- let userAddressStr = toString(userAddress)
409- let $t01488214936 = getParamsOrFail()
410- let stakedAssetId = $t01488214936._1
411- let minLockAmount = $t01488214936._2
412- let $t01493915023 = getUserParamsOrFail(userAddress)
413- let isNewUser = $t01493915023._1
414- let stakedAmount = $t01493915023._2
415- let vpEffectiveHeight = $t01493915023._3
416- let swapParamsSTRUCT = asSwapParamsSTRUCT(reentrantInvoke(neutrinoContract, "swapParamsByUserSYSREADONLY", [userAddressStr, 0], nil))
417- let swapLimitSpentInUsdn = swapParamsSTRUCT._2
418- let blcks2LmtReset = swapParamsSTRUCT._3
419- if ((swapLimitSpentInUsdn > 0))
420- then throw((("You have already made a swap operation. Wait " + toString((height + blcks2LmtReset))) + " height to unstake"))
421- else if ((0 >= stakedAmount))
422- then throw("Nothing to unstake")
423- else if ((amount > stakedAmount))
424- then throw(((("Requested " + toString(amount)) + ", but staked only ") + toString(stakedAmount)))
425- else {
426- let stakedAmountNEW = (stakedAmount - amount)
427- let $t01566115819 = StatsResult(-(amount), if ((amount == stakedAmount))
428- then -1
429- else 0, if ((amount == stakedAmount))
430- then -1
431- else 0)
432- let statsEntries = $t01566115819._1
433- let totalStaked = $t01566115819._2
434- let totalStakedNew = $t01566115819._3
435- ((([ScriptTransfer(userAddress, amount, stakedAssetId), HistoryRecordEntry("unstake", userAddress, i.transactionId, stakedAmount, vpEffectiveHeight, stakedAmountNEW, vpEffectiveHeight)] ++ RewardEntries(false, userAddressStr, stakedAmount)) ++ LockParamsEntry(userAddress, stakedAmountNEW, vpEffectiveHeight)) ++ statsEntries)
436- }
437- }
438-
439-
440-
441-@Callable(i)
442-func deposit () = if ((size(i.payments) != 1))
443- then throw("exact 1 payment is allowed only")
444- else {
445- let pmt = i.payments[0]
446- let amount = pmt.amount
447- let pmtAssetId = value(pmt.assetId)
448- let pmtAssetIdStr = toBase58String(pmtAssetId)
449- let pmtMultX = MULTX6
450- let amountX = toBigInt(amount)
451- let totalStaked = getIntOrElse(keyLockParamTotalAmount(), 0)
452- let totalStakedX = toBigInt(totalStaked)
453- if ((0 > totalStaked))
454- then throw("TODO: case is not supported")
455- else if ((totalStaked == 0))
456- then IncrementNotDistributedRewardEntry(pmtAssetIdStr, amount)
457- else {
458- let rewardPerNsbtX18 = fraction(amountX, MULTX18, totalStakedX)
459- let depositNumLastKEY = keyDepositNumLast()
460- let depositNumLast = getIntOrElse(depositNumLastKEY, -1)
461- let depositNumNew = (depositNumLast + 1)
462- if (!(contains(supportedAssetsStr, pmtAssetIdStr)))
463- then throw(((supportedAssetsStr + " doesn't contain ") + pmtAssetIdStr))
464- else {
465- func refreshRewardPerNsbtSUM (accum,nextAsset) = {
466- let rewardPerNsbtSumNewKEY = keyRewardPerNsbtSumAt(depositNumNew, nextAsset)
467- let sumLastStr = getStrOrElse(keyRewardPerNsbtSumAt(depositNumLast, nextAsset), "0")
468- (accum :+ (if ((nextAsset == pmtAssetIdStr))
469- then StringEntry(rewardPerNsbtSumNewKEY, toString((parseBigIntValue(sumLastStr) + rewardPerNsbtX18)))
470- else StringEntry(rewardPerNsbtSumNewKEY, sumLastStr)))
471- }
472-
473- ({
474- let $l = supportedAssetsList
475- let $s = size($l)
476- let $acc0 = nil
477- func $f0_1 ($a,$i) = if (($i >= $s))
478- then $a
479- else refreshRewardPerNsbtSUM($a, $l[$i])
480-
481- func $f0_2 ($a,$i) = if (($i >= $s))
482- then $a
483- else throw("List size exceeds 10")
484-
485- $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)
486- } :+ IntegerEntry(depositNumLastKEY, depositNumNew))
487- }
488- }
489- }
490-
491-
492-
493-@Callable(i)
494-func claimRewards () = commonClaim(i.caller, i)
495-
496-
497-
498-@Callable(i)
499-func claimRewardsByOriginCaller () = commonClaim(i.originCaller, i)
500-
501-
502-
503-@Callable(i)
504-func unclaimedRewardsREADONLY (userAddressStr) = {
505- func forEachAssetZeroReward (accum,asset) = ((accum + makeString([asset, "0", "0"], ":")) + "_")
506-
507- let unclaimedRewardStr = if ((userAddressStr == ""))
508- then {
509- let $l = supportedAssetsList
510- let $s = size($l)
511- let $acc0 = ""
512- func $f0_1 ($a,$i) = if (($i >= $s))
513- then $a
514- else forEachAssetZeroReward($a, $l[$i])
515-
516- func $f0_2 ($a,$i) = if (($i >= $s))
517- then $a
518- else throw("List size exceeds 10")
519-
520- $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)
521- }
522- else {
523- let userAddress = addressFromStringValue(userAddressStr)
524- let $t01833618441 = valueOrElse(getUserParamsOrUnit(userAddress), $Tuple3(true, 0, 0))
525- let isNewUser = $t01833618441._1
526- let stakedAmount = $t01833618441._2
527- let stakingStart = $t01833618441._3
528- let stakedAmountX = toBigInt(stakedAmount)
529- let userRewardFromDepositNumKEY = keyUserRewardFromDepositNum(userAddressStr)
530- let depositNumUser = getIntOrElse(userRewardFromDepositNumKEY, -1)
531- let depositNumLast = getIntOrElse(keyDepositNumLast(), -1)
532- func forEachAssetCalcUnclaimedReward (accum,asset) = {
533- let $t01878718925 = calcReward(userAddressStr, asset, stakedAmountX, depositNumUser, depositNumLast)
534- let rewardTotal = $t01878718925._1
535- let cached = $t01878718925._2
536- let dynamic = $t01878718925._3
537- let rewardCachedPartKEY = $t01878718925._4
538- let claimed = valueOrElse(getInteger(keyClaimed(userAddressStr, asset)), 0)
539- ((accum + makeString([asset, toString(rewardTotal), toString(claimed)], ":")) + "_")
540- }
541-
542- let $l = supportedAssetsList
543- let $s = size($l)
544- let $acc0 = ""
545- func $f0_1 ($a,$i) = if (($i >= $s))
546- then $a
547- else forEachAssetCalcUnclaimedReward($a, $l[$i])
548-
549- func $f0_2 ($a,$i) = if (($i >= $s))
550- then $a
551- else throw("List size exceeds 10")
552-
553- $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)
554- }
555- $Tuple2(nil, dropRight(unclaimedRewardStr, 1))
167+func stakeNsbtPageREADONLY (userAddressStrOpt,nsbtAmtDiff) = {
168+ let gnsbtInfo = asString(invoke(restAcc, "gnsbtInfoREADONLY", [userAddressStrOpt, nsbtAmtDiff], nil))
169+ let swapInfo = asString(invoke(restAcc, "swapInfoREADONLY", [userAddressStrOpt], nil))
170+ $Tuple2(nil, produceJson(["gnsbtInfoREADONLY", gnsbtInfo, "swapInfoREADONLY", swapInfo]))
556171 }
557172
558173
559174
560175 @Callable(i)
561-func usdnStakingSYSREADONLY (userAddressStrOrEmpty,usdnDiff) = {
562- let usdnTotal = getIntOrElse(keyLockParamTotalAmount(), 0)
563- if ((userAddressStrOrEmpty == ""))
564- then $Tuple2(nil, [0, usdnTotal, 0, 0, 0, height, height])
565- else {
566- let userAddress = toAddressOrFail(userAddressStrOrEmpty)
567- let mergedData = mergeStake(userAddress, usdnDiff)
568- let isNewUser = mergedData._1
569- let stakedAmount = mergedData._2
570- let vpEffectiveHeight = mergedData._3
571- let stakedAmountNEW = mergedData._4
572- let vpEffectiveHeightNEW = mergedData._5
573- let usdnUser = stakedAmount
574- $Tuple2(nil, [usdnUser, usdnTotal, 0, 0, vpEffectiveHeight, vpEffectiveHeightNEW])
575- }
176+func buyNsbtPageREADONLY (userAddressStrOpt) = {
177+ let gnsbtInfo = asString(invoke(restAcc, "gnsbtInfoREADONLY", [userAddressStrOpt, 0], nil))
178+ let neutrinoStats = asString(invoke(restAcc, "neutrinoStatsREADONLY", nil, nil))
179+ $Tuple2(nil, produceJson(["gnsbtInfoREADONLY", gnsbtInfo, "neutrinoStatsREADONLY", neutrinoStats]))
576180 }
577181
578182
579183
580184 @Callable(i)
581-func configSYSREADONLY () = {
582- let minLockAmt = getIntegerValue(keyMinLockAmount())
583- $Tuple2(nil, [minLockAmt])
185+func buySurfPageREADONLY (userAddressStrOpt,amount,assetIdStr) = {
186+ let neutrinoStats = asString(invoke(restAcc, "neutrinoStatsREADONLY", nil, nil))
187+ let surfBuy = asString(invoke(restAcc, "buySurfREADONLY", [userAddressStrOpt, amount, assetIdStr], nil))
188+ let neutrinoCfg = asString(invoke(restAcc, "neutrinoConfigREADONLY", nil, nil))
189+ $Tuple2(nil, produceJson(["neutrinoStatsREADONLY", neutrinoStats, "buySurfREADONLY", surfBuy, "neutrinoConfigREADONLY", neutrinoCfg]))
190+ }
191+
192+
193+
194+@Callable(i)
195+func walletPageREADONLY (userAddressStr) = {
196+ let walletInfo = asString(invoke(restAcc, "walletInfoREADONLY", [userAddressStr], nil))
197+ $Tuple2(nil, produceJson(["walletInfoREADONLY", walletInfo]))
198+ }
199+
200+
201+
202+@Callable(i)
203+func genericREADONLY (payload) = {
204+ let funcsIndexes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
205+ let paramIndexes = [1, 3, 5, 7, 9, 11]
206+ let payloadArr = split(payload, SEP)
207+ let payloadSize = size(payloadArr)
208+ func invokesAgregator (accum,funcIdx) = if ((funcIdx >= payloadSize))
209+ then accum
210+ else {
211+ let call = payloadArr[funcIdx]
212+ let callArr = split(call, "+")
213+ let address = addressFromStringValue(callArr[0])
214+ let funcName = callArr[1]
215+ let paramsArr = split(callArr[2], ":")
216+ let paramsSize = size(paramsArr)
217+ func paramsAgregator (paramsAcc,paramIdx) = if ((paramIdx >= paramsSize))
218+ then paramsAcc
219+ else {
220+ let p = if ((paramsArr[(paramIdx - 1)] == "s"))
221+ then paramsArr[paramIdx]
222+ else parseIntValue(paramsArr[paramIdx])
223+ (paramsAcc :+ p)
224+ }
225+
226+ let params = {
227+ let $l = paramIndexes
228+ let $s = size($l)
229+ let $acc0 = nil
230+ func $f0_1 ($a,$i) = if (($i >= $s))
231+ then $a
232+ else paramsAgregator($a, $l[$i])
233+
234+ func $f0_2 ($a,$i) = if (($i >= $s))
235+ then $a
236+ else throw("List size exceeds 6")
237+
238+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
239+ }
240+ let result = asString(invoke(address, funcName, params, nil))
241+ (accum ++ [funcName, result])
242+ }
243+
244+ let invokesResults = {
245+ let $l = funcsIndexes
246+ let $s = size($l)
247+ let $acc0 = nil
248+ func $f0_1 ($a,$i) = if (($i >= $s))
249+ then $a
250+ else invokesAgregator($a, $l[$i])
251+
252+ func $f0_2 ($a,$i) = if (($i >= $s))
253+ then $a
254+ else throw("List size exceeds 10")
255+
256+ $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)
257+ }
258+ $Tuple2(nil, produceJson(invokesResults))
584259 }
585260
586261

github/deemru/w8io/169f3d6 
206.80 ms