tx · 6qZasWNEcJVm1eUmdNVzTegkBZVf4PBbf7BsRfchMfJB 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h: -0.05000000 Waves 2023.03.27 13:19 [2508251] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves
{ "type": 13, "id": "6qZasWNEcJVm1eUmdNVzTegkBZVf4PBbf7BsRfchMfJB", "fee": 5000000, "feeAssetId": null, "timestamp": 1679912414245, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "3jjziTe9zpeZA3P88Bxggca2Jy252tD8T8XtxrvV5sSHHqwqVj6UVS6EfFg1rgaJ7kUQkgoS2yUhWVGfn3zzPkpo" ], "script": "base64:BgIPCAISABIAEgASBQoDAQEBCwAMY29udHJhY3RGaWxlAglyZWJhbGFuY2UAD2tleXNUYXJnZXRSYXRpbwIPJXNfX3RhcmdldFJhdGlvABRrZXlBZGRpdGlvbmFsQmFsYW5jZQIaJXNfX2FkZGl0aW9uYWxXYXZlc0JhbGFuY2UAGmtleVNXYXZlc0FkZGl0aW9uYWxCYWxhbmNlAhElc19fc1dhdmVzQmFsYW5jZQAQa2V5U1dhdmVzQXNzZXRJZAIRJXNfX3NXYXZlc0Fzc2V0SWQAD2tleVByb3h5QWRkcmVzcwIQJXNfX3Byb3h5QWRkcmVzcwEQZ2V0SW50ZWdlck9yWmVybwEKaW50ZWdlcktleQQHJG1hdGNoMAkAmggCBQR0aGlzBQppbnRlZ2VyS2V5AwkAAQIFByRtYXRjaDACA0ludAQDdmFsBQckbWF0Y2gwBQN2YWwAAAEQZ2V0U3RyaW5nT3JUaHJvdwEJc3RyaW5nS2V5BAckbWF0Y2gwCQCdCAIFBHRoaXMFCXN0cmluZ0tleQMJAAECBQckbWF0Y2gwAgZTdHJpbmcEAXMFByRtYXRjaDAF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ZXN0Aw5yZWd1bGFyQmFsYW5jZQphZGRpdGlvbmFsC3RhcmdldFJhdGlvBANzdW0JAGQCBQ5yZWd1bGFyQmFsYW5jZQUKYWRkaXRpb25hbAQXdGFyZ2V0QWRkaXRpb25hbEJhbGFuY2UJAGsDBQt0YXJnZXRSYXRpbwUDc3VtAGQEBmNoYW5nZQkAZQIFCmFkZGl0aW9uYWwFF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlBAZuZXdSZWcJAGQCBQ5yZWd1bGFyQmFsYW5jZQUGY2hhbmdlAwkAZgIAAAUGY2hhbmdlBApzZW5kQW1vdW50CQBoAgUGY2hhbmdlAP///////////wEJAJQKAgUDbmlsCQDMCAIFBm5ld1JlZwkAzAgCBRd0YXJnZXRBZGRpdGlvbmFsQmFsYW5jZQkAzAgCBQZjaGFuZ2UJAMwIAgkArAICAglkZXBvc2l0OiAJAKQDAQUKc2VuZEFtb3VudAUDbmlsBApzZW5kQW1vdW50BQZjaGFuZ2UJAJQKAgUDbmlsCQDMCAIFBm5ld1JlZwkAzAgCBRd0YXJnZXRBZGRpdGlvbmFsQmFsYW5jZQkAzAgCBQZjaGFuZ2UJAMwIAgkArAICAgp3aXRoZHJhdzogCQCkAwEFCnNlbmRBbW91bnQFA25pbAC9w18n", "height": 2508251, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ALSyjvDVKxkFhaACEuVFweozBT7CFNdrKEn7h1dDQboC Next: BN14Vfd9aoDBtQospVDznCoZboQsFZ5bmmSTPvtknHZD Diff:
Old | New | Differences | |
---|---|---|---|
43 | 43 | ||
44 | 44 | func getRate () = { | |
45 | 45 | let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress)) | |
46 | - | invoke(proxy, " | |
46 | + | invoke(proxy, "getRate", nil, nil) | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFile = "rebalance" | |
5 | 5 | ||
6 | 6 | let keysTargetRatio = "%s__targetRatio" | |
7 | 7 | ||
8 | 8 | let keyAdditionalBalance = "%s__additionalWavesBalance" | |
9 | 9 | ||
10 | 10 | let keySWavesAdditionalBalance = "%s__sWavesBalance" | |
11 | 11 | ||
12 | 12 | let keySWavesAssetId = "%s__sWavesAssetId" | |
13 | 13 | ||
14 | 14 | let keyProxyAddress = "%s__proxyAddress" | |
15 | 15 | ||
16 | 16 | func getIntegerOrZero (integerKey) = match getInteger(this, integerKey) { | |
17 | 17 | case val: Int => | |
18 | 18 | val | |
19 | 19 | case _ => | |
20 | 20 | 0 | |
21 | 21 | } | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getStringOrThrow (stringKey) = match getString(this, stringKey) { | |
25 | 25 | case s: String => | |
26 | 26 | s | |
27 | 27 | case _ => | |
28 | 28 | throw((("[" + stringKey) + "] is empty")) | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func internalWavesBalance () = (wavesBalance(this).regular + getIntegerOrZero(keyAdditionalBalance)) | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func currentRate () = { | |
36 | 36 | let additionalBalance = getIntegerOrZero(keyAdditionalBalance) | |
37 | 37 | let sWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance) | |
38 | 38 | if ((additionalBalance == 0)) | |
39 | 39 | then 0 | |
40 | 40 | else fraction(10000000000, additionalBalance, sWavesBalance) | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func getRate () = { | |
45 | 45 | let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress)) | |
46 | - | invoke(proxy, " | |
46 | + | invoke(proxy, "getRate", nil, nil) | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | @Callable(i) | |
51 | 51 | func returnWavesBalance () = $Tuple2(nil, internalWavesBalance()) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | 55 | @Callable(i) | |
56 | 56 | func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero(keySWavesAdditionalBalance)) | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | ||
60 | 60 | @Callable(i) | |
61 | 61 | func calcRatio () = { | |
62 | 62 | let regularWavesBalance = wavesBalance(this).regular | |
63 | 63 | let additional = getIntegerOrZero(keyAdditionalBalance) | |
64 | 64 | let ratio = fraction(100, additional, (additional + regularWavesBalance)) | |
65 | 65 | $Tuple2(nil, ratio) | |
66 | 66 | } | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | ||
70 | 70 | @Callable(i) | |
71 | 71 | func calcRatioTest (regularBalance,additional,targetRatio) = { | |
72 | 72 | let sum = (regularBalance + additional) | |
73 | 73 | let targetAdditionalBalance = fraction(targetRatio, sum, 100) | |
74 | 74 | let change = (additional - targetAdditionalBalance) | |
75 | 75 | let newReg = (regularBalance + change) | |
76 | 76 | if ((0 > change)) | |
77 | 77 | then { | |
78 | 78 | let sendAmount = (change * -1) | |
79 | 79 | $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("deposit: " + toString(sendAmount))]) | |
80 | 80 | } | |
81 | 81 | else { | |
82 | 82 | let sendAmount = change | |
83 | 83 | $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("withdraw: " + toString(sendAmount))]) | |
84 | 84 | } | |
85 | 85 | } | |
86 | 86 | ||
87 | 87 |
github/deemru/w8io/026f985 25.30 ms ◑