tx · 7udwsQSXbHLwcqkw8Wt1byuy3hDwZmnBPDmTp27xMMy2 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h: -0.05000000 Waves 2023.03.27 13:15 [2508247] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves
{ "type": 13, "id": "7udwsQSXbHLwcqkw8Wt1byuy3hDwZmnBPDmTp27xMMy2", "fee": 5000000, "feeAssetId": null, "timestamp": 1679912141071, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "3a1ou3SgDBcD4acDyhptxBgmS7oEXba7btSKigCUQcATxd4n6Riqxi1BVzSj7usNgpx2zS7tpa289CsGWzjpABN3" ], "script": "base64:BgIPCAISABIAEgASBQoDAQEBCgAMY29udHJhY3RGaWxlAglyZWJhbGFuY2UAD2tleXNUYXJnZXRSYXRpbwIPJXNfX3RhcmdldFJhdGlvABRrZXlBZGRpdGlvbmFsQmFsYW5jZQIaJXNfX2FkZGl0aW9uYWxXYXZlc0JhbGFuY2UAGmtleVNXYXZlc0FkZGl0aW9uYWxCYWxhbmNlAhElc19fc1dhdmVzQmFsYW5jZQAQa2V5U1dhdmVzQXNzZXRJZAIRJXNfX3NXYXZlc0Fzc2V0SWQAD2tleVByb3h5QWRkcmVzcwIQJXNfX3Byb3h5QWRkcmVzcwEQZ2V0SW50ZWdlck9yWmVybwEKaW50ZWdlcktleQQHJG1hdGNoMAkAmggCBQR0aGlzBQppbnRlZ2VyS2V5AwkAAQIFByRtYXRjaDACA0ludAQDdmFsBQckbWF0Y2gwBQN2YWwAAAEQZ2V0U3RyaW5nT3JUaHJvdwEJc3RyaW5nS2V5BAckbWF0Y2gwCQCdCAIFBHRoaXMFCXN0cmluZ0tleQMJAAECBQckbWF0Y2gwAgZTdHJpbmcEAXMFByRtYXRjaDAFAXMJA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AawMFC3RhcmdldFJhdGlvBQNzdW0AZAQGY2hhbmdlCQBlAgUKYWRkaXRpb25hbAUXdGFyZ2V0QWRkaXRpb25hbEJhbGFuY2UEBm5ld1JlZwkAZAIFDnJlZ3VsYXJCYWxhbmNlBQZjaGFuZ2UDCQBmAgAABQZjaGFuZ2UECnNlbmRBbW91bnQJAGgCBQZjaGFuZ2UA////////////AQkAlAoCBQNuaWwJAMwIAgUGbmV3UmVnCQDMCAIFF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlCQDMCAIFBmNoYW5nZQkAzAgCCQCsAgICCWRlcG9zaXQ6IAkApAMBBQpzZW5kQW1vdW50BQNuaWwECnNlbmRBbW91bnQFBmNoYW5nZQkAlAoCBQNuaWwJAMwIAgUGbmV3UmVnCQDMCAIFF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlCQDMCAIFBmNoYW5nZQkAzAgCCQCsAgICCndpdGhkcmF3OiAJAKQDAQUKc2VuZEFtb3VudAUDbmlsACzYB8E=", "height": 2508247, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8Gf6LecFJ8qt6Q17gNyF6mhyaXVzxDXETYvbGpEyvm2X Next: ALSyjvDVKxkFhaACEuVFweozBT7CFNdrKEn7h1dDQboC Diff:
Old | New | Differences | |
---|---|---|---|
5 | 5 | ||
6 | 6 | let keysTargetRatio = "%s__targetRatio" | |
7 | 7 | ||
8 | - | let keyAdditionalBalance = "%s__ | |
8 | + | let keyAdditionalBalance = "%s__additionalWavesBalance" | |
9 | 9 | ||
10 | - | let | |
10 | + | let keySWavesAdditionalBalance = "%s__sWavesBalance" | |
11 | 11 | ||
12 | 12 | let keySWavesAssetId = "%s__sWavesAssetId" | |
13 | 13 | ||
32 | 32 | func internalWavesBalance () = (wavesBalance(this).regular + getIntegerOrZero(keyAdditionalBalance)) | |
33 | 33 | ||
34 | 34 | ||
35 | + | func currentRate () = { | |
36 | + | let additionalBalance = getIntegerOrZero(keyAdditionalBalance) | |
37 | + | let sWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance) | |
38 | + | if ((additionalBalance == 0)) | |
39 | + | then 0 | |
40 | + | else fraction(10000000000, additionalBalance, sWavesBalance) | |
41 | + | } | |
42 | + | ||
43 | + | ||
35 | 44 | @Callable(i) | |
36 | 45 | func returnWavesBalance () = $Tuple2(nil, internalWavesBalance()) | |
37 | 46 | ||
38 | 47 | ||
39 | 48 | ||
40 | 49 | @Callable(i) | |
41 | - | func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero( | |
50 | + | func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero(keySWavesAdditionalBalance)) | |
42 | 51 | ||
43 | 52 | ||
44 | 53 |
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 | - | let keyAdditionalBalance = "%s__ | |
8 | + | let keyAdditionalBalance = "%s__additionalWavesBalance" | |
9 | 9 | ||
10 | - | let | |
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 | + | func currentRate () = { | |
36 | + | let additionalBalance = getIntegerOrZero(keyAdditionalBalance) | |
37 | + | let sWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance) | |
38 | + | if ((additionalBalance == 0)) | |
39 | + | then 0 | |
40 | + | else fraction(10000000000, additionalBalance, sWavesBalance) | |
41 | + | } | |
42 | + | ||
43 | + | ||
35 | 44 | @Callable(i) | |
36 | 45 | func returnWavesBalance () = $Tuple2(nil, internalWavesBalance()) | |
37 | 46 | ||
38 | 47 | ||
39 | 48 | ||
40 | 49 | @Callable(i) | |
41 | - | func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero( | |
50 | + | func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero(keySWavesAdditionalBalance)) | |
42 | 51 | ||
43 | 52 | ||
44 | 53 | ||
45 | 54 | @Callable(i) | |
46 | 55 | func calcRatio () = { | |
47 | 56 | let regularWavesBalance = wavesBalance(this).regular | |
48 | 57 | let additional = getIntegerOrZero(keyAdditionalBalance) | |
49 | 58 | let ratio = fraction(100, additional, (additional + regularWavesBalance)) | |
50 | 59 | $Tuple2(nil, ratio) | |
51 | 60 | } | |
52 | 61 | ||
53 | 62 | ||
54 | 63 | ||
55 | 64 | @Callable(i) | |
56 | 65 | func calcRatioTest (regularBalance,additional,targetRatio) = { | |
57 | 66 | let sum = (regularBalance + additional) | |
58 | 67 | let targetAdditionalBalance = fraction(targetRatio, sum, 100) | |
59 | 68 | let change = (additional - targetAdditionalBalance) | |
60 | 69 | let newReg = (regularBalance + change) | |
61 | 70 | if ((0 > change)) | |
62 | 71 | then { | |
63 | 72 | let sendAmount = (change * -1) | |
64 | 73 | $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("deposit: " + toString(sendAmount))]) | |
65 | 74 | } | |
66 | 75 | else { | |
67 | 76 | let sendAmount = change | |
68 | 77 | $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("withdraw: " + toString(sendAmount))]) | |
69 | 78 | } | |
70 | 79 | } | |
71 | 80 | ||
72 | 81 |
github/deemru/w8io/026f985 27.77 ms ◑