tx · 4uDHRyaYN55YQ2Cohjd94REj9PTdUmk4gzdGBVxd9be2

3NBGYJLwHsU6eJXLi74dB8cBbMfiTS2cTtu:  -0.01400000 Waves

2022.05.15 18:31 [2052974] smart account 3NBGYJLwHsU6eJXLi74dB8cBbMfiTS2cTtu > SELF 0.00000000 Waves

{ "type": 13, "id": "4uDHRyaYN55YQ2Cohjd94REj9PTdUmk4gzdGBVxd9be2", "fee": 1400000, "feeAssetId": null, "timestamp": 1652628752208, "version": 2, "chainId": 84, "sender": "3NBGYJLwHsU6eJXLi74dB8cBbMfiTS2cTtu", "senderPublicKey": "DqoxVw7QE15hy21jZuVxZXM9E7WXmheH1up4dwp57Yb8", "proofs": [ "osZ5CwBVPDUoGe8itR9rikAgn6K8XXBM4nABShpcdiVq3cbACy3iUH35W5RBfXhM9bJdh1YcKY7NdNE79mPQ4Er" ], "script": "base64:AAIFAAAAAAAAABQIAhIAEgMKAQgSABIDCgEBEgASAAAAAA0AAAAACW9yYWNsZUtleQIAAAAJb3JhY2xlS2V5AAAAAAVTY2FsZQAAAAAAAA9CQAEAAAANdHJ5R2V0SW50ZWdlcgAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAAAQAAAAx0cnlHZXRTdHJpbmcAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQIAAAAAAAAAAAZvcmFjbGUJAQAAAAx0cnlHZXRTdHJpbmcAAAABBQAAAAlvcmFjbGVLZXkAAAAACW9yYWNsZUZlZQkBAAAABXZhbHVlAAAAAQkABCYAAAABBQAAAAZvcmFjbGUBAAAAGWdldEludGVnZXJCeUtleUZ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xvYmFsX2xhc3RDaGVja19TQ09ORVhfaW50ZXJlc3QJAABkAAAAAgUAAAAPY3VycmVudEludGVyZXN0BQAAAA1pbnRlcmVzdERlbHRhBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleeC3920=", "height": 2052974, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5cN8KwRFrNKWV9PJax3f99SbTiDCUqmtGEobBiGBr6A1 Next: 5FQdBKvun9QA7cYwSGdEHKyT814iY5NaHsqaXx8SQ2NG Diff:
OldNewDifferences
2525
2626 let oracleFee = value(addressFromString(oracle))
2727
28+func getIntegerByKeyFromOracle (key) = valueOrErrorMessage(getInteger(oracleFee, key), "Integer undefine or 0 in oracle")
29+
30+
2831 let SconexAssetId = fromBase58String(getStringValue(oracleFee, "SconexAssetId"))
32+
33+let currentFeeSconex = getIntegerByKeyFromOracle(("fee_" + toBase58String(SconexAssetId)))
34+
35+let stakeDapp = addressFromString(valueOrErrorMessage(getString(oracleFee, "stakeDapp"), "sconexDapp not found"))
2936
3037 func claimResult (address) = {
3138 let addressStr = toString(address)
3946 }
4047
4148
49+func isPayment (i) = if ((size(i.payments) != 1))
50+ then throw("Wrong payments attached")
51+ else {
52+ let payment = value(i.payments[0])
53+ let amount = value(payment.amount)
54+ $Tuple2(payment, amount)
55+ }
56+
57+
58+func validatePayment (i) = {
59+ let t089829018 = isPayment(i)
60+ let payment = t089829018._1
61+ let amount = t089829018._2
62+ let assetId = if (if (isDefined(payment.assetId))
63+ then (payment.assetId == SconexAssetId)
64+ else false)
65+ then payment.assetId
66+ else throw((("Only " + toBase58String(SconexAssetId)) + " token accepted as transaction fee"))
67+ if ((amount != currentFeeSconex))
68+ then throw(((("Payment amount should be " + toString(currentFeeSconex)) + " but is: ") + toString(amount)))
69+ else $Tuple2(amount, assetId)
70+ }
71+
72+
73+@Callable(i)
74+func validateAndProcessPayment () = {
75+ let validP = validatePayment(i)
76+ let amountP = validP._1
77+ let assetIdP = validP._2
78+ if (!(isDefined(amountP)))
79+ then throw("Something went wrong")
80+ else {
81+ let invokeTeamFeeSplit = invoke(valueOrErrorMessage(stakeDapp, "stakeDapp not found"), "topUpReward", nil, [AttachedPayment(assetIdP, amountP)])
82+ if ((invokeTeamFeeSplit == invokeTeamFeeSplit))
83+ then nil
84+ else throw("Strict value is not equal to itself.")
85+ }
86+ }
87+
88+
89+
4290 @Callable(i)
4391 func initDapp (dappKey) = if ((i.caller != this))
4492 then throw("You cannot do this action")
5098
5199 @Callable(i)
52100 func stake () = {
53- let amount = i.payments[0].amount
54- let addressStr = toString(i.caller)
55- let totalStakedAmount = tryGetInteger("global_staked")
56- if ((i.payments[0].assetId != SconexAssetId))
57- then throw("wrong asset attached")
58- else (claimResult(i.caller) ++ [IntegerEntry("global_staked", (totalStakedAmount + amount)), IntegerEntry((addressStr + "_SCONEX_staked"), (tryGetInteger((addressStr + "_SCONEX_staked")) + amount))])
101+ let validateAndProcessPaymentInvoke = invoke(valueOrErrorMessage(this, "this not found"), "validateAndProcessPayment", nil, [i.payments[0]])
102+ if ((validateAndProcessPaymentInvoke == validateAndProcessPaymentInvoke))
103+ then {
104+ let amount = i.payments[1].amount
105+ let addressStr = toString(i.caller)
106+ let totalStakedAmount = tryGetInteger("global_staked")
107+ if ((i.payments[1].assetId != SconexAssetId))
108+ then throw("wrong asset attached")
109+ else (claimResult(i.caller) ++ [IntegerEntry("global_staked", (totalStakedAmount + amount)), IntegerEntry((addressStr + "_SCONEX_staked"), (tryGetInteger((addressStr + "_SCONEX_staked")) + amount))])
110+ }
111+ else throw("Strict value is not equal to itself.")
59112 }
60113
61114
62115
63116 @Callable(i)
64117 func unStake (amount) = {
65- let addressStr = toString(i.caller)
66- let stakedAmount = tryGetInteger((addressStr + "_SCONEX_staked"))
67- if ((amount > stakedAmount))
68- then throw("you don't have tokens available")
69- else (claimResult(i.caller) ++ [IntegerEntry((addressStr + "_SCONEX_staked"), (stakedAmount - amount)), IntegerEntry("global_staked", (tryGetInteger("global_staked") - amount)), ScriptTransfer(i.caller, amount, SconexAssetId)])
118+ let validateAndProcessPaymentInvoke = invoke(valueOrErrorMessage(this, "this not found"), "validateAndProcessPayment", nil, [i.payments[0]])
119+ if ((validateAndProcessPaymentInvoke == validateAndProcessPaymentInvoke))
120+ then {
121+ let addressStr = toString(i.caller)
122+ let stakedAmount = tryGetInteger((addressStr + "_SCONEX_staked"))
123+ if ((amount > stakedAmount))
124+ then throw("you don't have tokens available")
125+ else (claimResult(i.caller) ++ [IntegerEntry((addressStr + "_SCONEX_staked"), (stakedAmount - amount)), IntegerEntry("global_staked", (tryGetInteger("global_staked") - amount)), ScriptTransfer(i.caller, amount, SconexAssetId)])
126+ }
127+ else throw("Strict value is not equal to itself.")
70128 }
71129
72130
73131
74132 @Callable(i)
75-func claimReward () = claimResult(i.caller)
133+func claimReward () = {
134+ let validateAndProcessPaymentInvoke = invoke(valueOrErrorMessage(this, "this not found"), "validateAndProcessPayment", nil, [i.payments[0]])
135+ if ((validateAndProcessPaymentInvoke == validateAndProcessPaymentInvoke))
136+ then claimResult(i.caller)
137+ else throw("Strict value is not equal to itself.")
138+ }
76139
77140
78141
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let oracleKey = "oracleKey"
55
66 let Scale = 1000000
77
88 func tryGetInteger (key) = match getInteger(this, key) {
99 case b: Int =>
1010 b
1111 case _ =>
1212 0
1313 }
1414
1515
1616 func tryGetString (key) = match getString(this, key) {
1717 case a: String =>
1818 a
1919 case _ =>
2020 ""
2121 }
2222
2323
2424 let oracle = tryGetString(oracleKey)
2525
2626 let oracleFee = value(addressFromString(oracle))
2727
28+func getIntegerByKeyFromOracle (key) = valueOrErrorMessage(getInteger(oracleFee, key), "Integer undefine or 0 in oracle")
29+
30+
2831 let SconexAssetId = fromBase58String(getStringValue(oracleFee, "SconexAssetId"))
32+
33+let currentFeeSconex = getIntegerByKeyFromOracle(("fee_" + toBase58String(SconexAssetId)))
34+
35+let stakeDapp = addressFromString(valueOrErrorMessage(getString(oracleFee, "stakeDapp"), "sconexDapp not found"))
2936
3037 func claimResult (address) = {
3138 let addressStr = toString(address)
3239 let currentInterest = tryGetInteger("global_lastCheck_SCONEX_interest")
3340 let lastCheckInterest = tryGetInteger((addressStr + "_lastCheck_SCONEX_interest"))
3441 let stakedAmount = tryGetInteger((addressStr + "_SCONEX_staked"))
3542 let reward = if ((lastCheckInterest > 0))
3643 then fraction((currentInterest - lastCheckInterest), stakedAmount, Scale)
3744 else 0
3845 [IntegerEntry((addressStr + "_lastCheck_SCONEX_interest"), currentInterest), IntegerEntry((addressStr + "_SCONEX_claimed"), (tryGetInteger((addressStr + "_SCONEX_claimed")) + reward)), ScriptTransfer(address, reward, SconexAssetId)]
3946 }
4047
4148
49+func isPayment (i) = if ((size(i.payments) != 1))
50+ then throw("Wrong payments attached")
51+ else {
52+ let payment = value(i.payments[0])
53+ let amount = value(payment.amount)
54+ $Tuple2(payment, amount)
55+ }
56+
57+
58+func validatePayment (i) = {
59+ let t089829018 = isPayment(i)
60+ let payment = t089829018._1
61+ let amount = t089829018._2
62+ let assetId = if (if (isDefined(payment.assetId))
63+ then (payment.assetId == SconexAssetId)
64+ else false)
65+ then payment.assetId
66+ else throw((("Only " + toBase58String(SconexAssetId)) + " token accepted as transaction fee"))
67+ if ((amount != currentFeeSconex))
68+ then throw(((("Payment amount should be " + toString(currentFeeSconex)) + " but is: ") + toString(amount)))
69+ else $Tuple2(amount, assetId)
70+ }
71+
72+
73+@Callable(i)
74+func validateAndProcessPayment () = {
75+ let validP = validatePayment(i)
76+ let amountP = validP._1
77+ let assetIdP = validP._2
78+ if (!(isDefined(amountP)))
79+ then throw("Something went wrong")
80+ else {
81+ let invokeTeamFeeSplit = invoke(valueOrErrorMessage(stakeDapp, "stakeDapp not found"), "topUpReward", nil, [AttachedPayment(assetIdP, amountP)])
82+ if ((invokeTeamFeeSplit == invokeTeamFeeSplit))
83+ then nil
84+ else throw("Strict value is not equal to itself.")
85+ }
86+ }
87+
88+
89+
4290 @Callable(i)
4391 func initDapp (dappKey) = if ((i.caller != this))
4492 then throw("You cannot do this action")
4593 else if ((oracle != ""))
4694 then throw("oracle already set, you can't override!")
4795 else [StringEntry(oracleKey, dappKey)]
4896
4997
5098
5199 @Callable(i)
52100 func stake () = {
53- let amount = i.payments[0].amount
54- let addressStr = toString(i.caller)
55- let totalStakedAmount = tryGetInteger("global_staked")
56- if ((i.payments[0].assetId != SconexAssetId))
57- then throw("wrong asset attached")
58- else (claimResult(i.caller) ++ [IntegerEntry("global_staked", (totalStakedAmount + amount)), IntegerEntry((addressStr + "_SCONEX_staked"), (tryGetInteger((addressStr + "_SCONEX_staked")) + amount))])
101+ let validateAndProcessPaymentInvoke = invoke(valueOrErrorMessage(this, "this not found"), "validateAndProcessPayment", nil, [i.payments[0]])
102+ if ((validateAndProcessPaymentInvoke == validateAndProcessPaymentInvoke))
103+ then {
104+ let amount = i.payments[1].amount
105+ let addressStr = toString(i.caller)
106+ let totalStakedAmount = tryGetInteger("global_staked")
107+ if ((i.payments[1].assetId != SconexAssetId))
108+ then throw("wrong asset attached")
109+ else (claimResult(i.caller) ++ [IntegerEntry("global_staked", (totalStakedAmount + amount)), IntegerEntry((addressStr + "_SCONEX_staked"), (tryGetInteger((addressStr + "_SCONEX_staked")) + amount))])
110+ }
111+ else throw("Strict value is not equal to itself.")
59112 }
60113
61114
62115
63116 @Callable(i)
64117 func unStake (amount) = {
65- let addressStr = toString(i.caller)
66- let stakedAmount = tryGetInteger((addressStr + "_SCONEX_staked"))
67- if ((amount > stakedAmount))
68- then throw("you don't have tokens available")
69- else (claimResult(i.caller) ++ [IntegerEntry((addressStr + "_SCONEX_staked"), (stakedAmount - amount)), IntegerEntry("global_staked", (tryGetInteger("global_staked") - amount)), ScriptTransfer(i.caller, amount, SconexAssetId)])
118+ let validateAndProcessPaymentInvoke = invoke(valueOrErrorMessage(this, "this not found"), "validateAndProcessPayment", nil, [i.payments[0]])
119+ if ((validateAndProcessPaymentInvoke == validateAndProcessPaymentInvoke))
120+ then {
121+ let addressStr = toString(i.caller)
122+ let stakedAmount = tryGetInteger((addressStr + "_SCONEX_staked"))
123+ if ((amount > stakedAmount))
124+ then throw("you don't have tokens available")
125+ else (claimResult(i.caller) ++ [IntegerEntry((addressStr + "_SCONEX_staked"), (stakedAmount - amount)), IntegerEntry("global_staked", (tryGetInteger("global_staked") - amount)), ScriptTransfer(i.caller, amount, SconexAssetId)])
126+ }
127+ else throw("Strict value is not equal to itself.")
70128 }
71129
72130
73131
74132 @Callable(i)
75-func claimReward () = claimResult(i.caller)
133+func claimReward () = {
134+ let validateAndProcessPaymentInvoke = invoke(valueOrErrorMessage(this, "this not found"), "validateAndProcessPayment", nil, [i.payments[0]])
135+ if ((validateAndProcessPaymentInvoke == validateAndProcessPaymentInvoke))
136+ then claimResult(i.caller)
137+ else throw("Strict value is not equal to itself.")
138+ }
76139
77140
78141
79142 @Callable(i)
80143 func topUpReward () = {
81144 let amount = fraction(i.payments[0].amount, 9, 10)
82145 let currentInterest = tryGetInteger("global_lastCheck_SCONEX_interest")
83146 let totalStakedAmount = tryGetInteger("global_staked")
84147 let interestDelta = if ((totalStakedAmount > 0))
85148 then fraction(amount, Scale, totalStakedAmount)
86149 else 0
87150 if ((i.payments[0].assetId != SconexAssetId))
88151 then throw("wrong asset attached")
89152 else [IntegerEntry("global_SCONEX_earnings", (tryGetInteger("global_SCONEX_earnings") + amount)), IntegerEntry("global_lastCheck_SCONEX_interest", (currentInterest + interestDelta))]
90153 }
91154
92155
93156 @Verifier(tx)
94157 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
95158

github/deemru/w8io/026f985 
31.69 ms