tx · BN14Vfd9aoDBtQospVDznCoZboQsFZ5bmmSTPvtknHZD

3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h:  -0.05000000 Waves

2023.03.28 09:07 [2509419] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves

{ "type": 13, "id": "BN14Vfd9aoDBtQospVDznCoZboQsFZ5bmmSTPvtknHZD", "fee": 5000000, "feeAssetId": null, "timestamp": 1679983612490, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "5AWvRHscQr9hd83x7AszE5T56am9E6RdBjE96bsZKw7odnAW7caDPQG5whqXXwSJ2sAV4hd5RqrnHHCxNvPHnKa1" ], "script": "base64:BgIPCAISABIAEgASBQoDAQEBCwAMY29udHJhY3RGaWxlAglyZWJhbGFuY2UAD2tleXNUYXJnZXRSYXRpbwIPJXNfX3RhcmdldFJhdGlvABRrZXlBZGRpdGlvbmFsQmFsYW5jZQIaJXNfX2FkZGl0aW9uYWxXYXZlc0JhbGFuY2UAGmtleVNXYXZlc0FkZGl0aW9uYWxCYWxhbmNlAhElc19fc1dhdmVzQmFsYW5jZQAQa2V5U1dhdmVzQXNzZXRJZAIRJXNfX3NXYXZlc0Fzc2V0SWQAD2tleVByb3h5QWRkcmVzcwIQJXNfX3Byb3h5QWRkcmVzcwEQZ2V0SW50ZWdlck9yWmVybwEKaW50ZWdlcktleQQHJG1hdGNoMAkAmggCBQR0aGlzBQppbnRlZ2VyS2V5AwkAAQIFByRtYXRjaDACA0ludAQDdmFsBQckbWF0Y2gwBQN2YWwAAAEQZ2V0U3RyaW5nT3JUaHJvdwEJc3RyaW5nS2V5BAckbWF0Y2gwCQCdCAIFBHRoaXMFCXN0cmluZ0tleQMJAAECBQckbWF0Y2gwAgZTdHJpbmcEAXMFByRtYXRjaDAFAXMJAAI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ludGVnZXJPclplcm8BBRRrZXlBZGRpdGlvbmFsQmFsYW5jZQQFcmF0aW8JAGsDAGQFCmFkZGl0aW9uYWwJAGQCBQphZGRpdGlvbmFsBRNyZWd1bGFyV2F2ZXNCYWxhbmNlCQCUCgIFA25pbAUFcmF0aW8BaQENY2FsY1JhdGlvVGVzdAMOcmVndWxhckJhbGFuY2UKYWRkaXRpb25hbAt0YXJnZXRSYXRpbwQDc3VtCQBkAgUOcmVndWxhckJhbGFuY2UFCmFkZGl0aW9uYWwEF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlCQBrAwULdGFyZ2V0UmF0aW8FA3N1bQBkBAZjaGFuZ2UJAGUCBQphZGRpdGlvbmFsBRd0YXJnZXRBZGRpdGlvbmFsQmFsYW5jZQQGbmV3UmVnCQBkAgUOcmVndWxhckJhbGFuY2UFBmNoYW5nZQMJAGYCAAAFBmNoYW5nZQQKc2VuZEFtb3VudAkAaAIFBmNoYW5nZQD///////////8BCQCUCgIFA25pbAkAzAgCBQZuZXdSZWcJAMwIAgUXdGFyZ2V0QWRkaXRpb25hbEJhbGFuY2UJAMwIAgUGY2hhbmdlCQDMCAIJAKwCAgIJZGVwb3NpdDogCQCkAwEFCnNlbmRBbW91bnQFA25pbAQKc2VuZEFtb3VudAUGY2hhbmdlCQCUCgIFA25pbAkAzAgCBQZuZXdSZWcJAMwIAgUXdGFyZ2V0QWRkaXRpb25hbEJhbGFuY2UJAMwIAgUGY2hhbmdlCQDMCAIJAKwCAgIKd2l0aGRyYXc6IAkApAMBBQpzZW5kQW1vdW50BQNuaWwACqIZjw==", "height": 2509419, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6qZasWNEcJVm1eUmdNVzTegkBZVf4PBbf7BsRfchMfJB Next: FQR71EwWYET2D37rV9cyPQy9c57AsVrLSPBFetrAPMsk Diff:
OldNewDifferences
3737 let sWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
3838 if ((additionalBalance == 0))
3939 then 0
40- else fraction(10000000000, additionalBalance, sWavesBalance)
40+ else fraction(100000000000, additionalBalance, sWavesBalance)
4141 }
4242
4343
4444 func getRate () = {
4545 let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress))
46- invoke(proxy, "getRate", nil, nil)
46+ let inv = invoke(proxy, "getRate", nil, nil)
47+ if ((inv == inv))
48+ then match inv {
49+ case s: String =>
50+ parseIntValue(s)
51+ case _ =>
52+ 0
53+ }
54+ else throw("Strict value is not equal to itself.")
4755 }
4856
4957
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let contractFile = "rebalance"
55
66 let keysTargetRatio = "%s__targetRatio"
77
88 let keyAdditionalBalance = "%s__additionalWavesBalance"
99
1010 let keySWavesAdditionalBalance = "%s__sWavesBalance"
1111
1212 let keySWavesAssetId = "%s__sWavesAssetId"
1313
1414 let keyProxyAddress = "%s__proxyAddress"
1515
1616 func getIntegerOrZero (integerKey) = match getInteger(this, integerKey) {
1717 case val: Int =>
1818 val
1919 case _ =>
2020 0
2121 }
2222
2323
2424 func getStringOrThrow (stringKey) = match getString(this, stringKey) {
2525 case s: String =>
2626 s
2727 case _ =>
2828 throw((("[" + stringKey) + "] is empty"))
2929 }
3030
3131
3232 func internalWavesBalance () = (wavesBalance(this).regular + getIntegerOrZero(keyAdditionalBalance))
3333
3434
3535 func currentRate () = {
3636 let additionalBalance = getIntegerOrZero(keyAdditionalBalance)
3737 let sWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
3838 if ((additionalBalance == 0))
3939 then 0
40- else fraction(10000000000, additionalBalance, sWavesBalance)
40+ else fraction(100000000000, additionalBalance, sWavesBalance)
4141 }
4242
4343
4444 func getRate () = {
4545 let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress))
46- invoke(proxy, "getRate", nil, nil)
46+ let inv = invoke(proxy, "getRate", nil, nil)
47+ if ((inv == inv))
48+ then match inv {
49+ case s: String =>
50+ parseIntValue(s)
51+ case _ =>
52+ 0
53+ }
54+ else throw("Strict value is not equal to itself.")
4755 }
4856
4957
5058 @Callable(i)
5159 func returnWavesBalance () = $Tuple2(nil, internalWavesBalance())
5260
5361
5462
5563 @Callable(i)
5664 func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero(keySWavesAdditionalBalance))
5765
5866
5967
6068 @Callable(i)
6169 func calcRatio () = {
6270 let regularWavesBalance = wavesBalance(this).regular
6371 let additional = getIntegerOrZero(keyAdditionalBalance)
6472 let ratio = fraction(100, additional, (additional + regularWavesBalance))
6573 $Tuple2(nil, ratio)
6674 }
6775
6876
6977
7078 @Callable(i)
7179 func calcRatioTest (regularBalance,additional,targetRatio) = {
7280 let sum = (regularBalance + additional)
7381 let targetAdditionalBalance = fraction(targetRatio, sum, 100)
7482 let change = (additional - targetAdditionalBalance)
7583 let newReg = (regularBalance + change)
7684 if ((0 > change))
7785 then {
7886 let sendAmount = (change * -1)
7987 $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("deposit: " + toString(sendAmount))])
8088 }
8189 else {
8290 let sendAmount = change
8391 $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("withdraw: " + toString(sendAmount))])
8492 }
8593 }
8694
8795

github/deemru/w8io/026f985 
26.92 ms