tx · 8Gf6LecFJ8qt6Q17gNyF6mhyaXVzxDXETYvbGpEyvm2X 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h: -0.05000000 Waves 2023.03.27 11:46 [2508162] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves
{ "type": 13, "id": "8Gf6LecFJ8qt6Q17gNyF6mhyaXVzxDXETYvbGpEyvm2X", "fee": 5000000, "feeAssetId": null, "timestamp": 1679906877555, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "4ZLvTy97RiqByF1Qrw1rHWB138QHet4PR1LNeGakoazBqig2pauRQD9T4T5A2LYuQLY9mRf4bkAjLeQ7N6LG79Nd" ], "script": "base64:BgIPCAISABIAEgASBQoDAQEBCQAMY29udHJhY3RGaWxlAglyZWJhbGFuY2UAD2tleXNUYXJnZXRSYXRpbwIPJXNfX3RhcmdldFJhdGlvABRrZXlBZGRpdGlvbmFsQmFsYW5jZQIbJXNfX2FkZGl0dGlvbmFsV2F2ZXNCYWxhbmNlABhrZXlTV2F2ZXNBZGRpdGlvbkJhbGFuY2UCESVzX19zV2F2ZXNCYWxhbmNlABBrZXlTV2F2ZXNBc3NldElkAhElc19fc1dhdmVzQXNzZXRJZAAPa2V5UHJveHlBZGRyZXNzAhAlc19fcHJveHlBZGRyZXNzARBnZXRJbnRlZ2VyT3JaZXJvAQppbnRlZ2VyS2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFCmludGVnZXJLZXkDCQABAgUHJG1hdGNoMAIDSW50BAN2YWwFByRtYXRjaDAFA3ZhbAAAARBnZXRTdHJpbmdPclRocm93AQlzdHJpbmdLZXkEByRtYXRjaDAJAJ0IAgUEdGhpcwUJc3RyaW5nS2V5AwkAAQIFByRtYXRjaDACBlN0cmluZwQBcwUHJG1hdGNoMAUBcw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BmNoYW5nZQkAzAgCCQCsAgICCWRlcG9zaXQ6IAkApAMBBQpzZW5kQW1vdW50BQNuaWwECnNlbmRBbW91bnQFBmNoYW5nZQkAlAoCBQNuaWwJAMwIAgUGbmV3UmVnCQDMCAIFF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlCQDMCAIFBmNoYW5nZQkAzAgCCQCsAgICCndpdGhkcmF3OiAJAKQDAQUKc2VuZEFtb3VudAUDbmlsAC4sysI=", "height": 2508162, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: QKY7KPXGK5AjA7wPDp8y2fMxF2j5owy4bQXFUSaccdR Next: 7udwsQSXbHLwcqkw8Wt1byuy3hDwZmnBPDmTp27xMMy2 Diff:
Old | New | Differences | |
---|---|---|---|
55 | 55 | @Callable(i) | |
56 | 56 | func calcRatioTest (regularBalance,additional,targetRatio) = { | |
57 | 57 | let sum = (regularBalance + additional) | |
58 | - | let | |
59 | - | let change = (additional - | |
58 | + | let targetAdditionalBalance = fraction(targetRatio, sum, 100) | |
59 | + | let change = (additional - targetAdditionalBalance) | |
60 | 60 | let newReg = (regularBalance + change) | |
61 | - | $Tuple2(nil, [targetBalance, newReg, change]) | |
61 | + | if ((0 > change)) | |
62 | + | then { | |
63 | + | let sendAmount = (change * -1) | |
64 | + | $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("deposit: " + toString(sendAmount))]) | |
65 | + | } | |
66 | + | else { | |
67 | + | let sendAmount = change | |
68 | + | $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("withdraw: " + toString(sendAmount))]) | |
69 | + | } | |
62 | 70 | } | |
63 | 71 | ||
64 | 72 |
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__addittionalWavesBalance" | |
9 | 9 | ||
10 | 10 | let keySWavesAdditionBalance = "%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 | @Callable(i) | |
36 | 36 | func returnWavesBalance () = $Tuple2(nil, internalWavesBalance()) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | ||
40 | 40 | @Callable(i) | |
41 | 41 | func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero(keySWavesAdditionBalance)) | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | ||
45 | 45 | @Callable(i) | |
46 | 46 | func calcRatio () = { | |
47 | 47 | let regularWavesBalance = wavesBalance(this).regular | |
48 | 48 | let additional = getIntegerOrZero(keyAdditionalBalance) | |
49 | 49 | let ratio = fraction(100, additional, (additional + regularWavesBalance)) | |
50 | 50 | $Tuple2(nil, ratio) | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | 55 | @Callable(i) | |
56 | 56 | func calcRatioTest (regularBalance,additional,targetRatio) = { | |
57 | 57 | let sum = (regularBalance + additional) | |
58 | - | let | |
59 | - | let change = (additional - | |
58 | + | let targetAdditionalBalance = fraction(targetRatio, sum, 100) | |
59 | + | let change = (additional - targetAdditionalBalance) | |
60 | 60 | let newReg = (regularBalance + change) | |
61 | - | $Tuple2(nil, [targetBalance, newReg, change]) | |
61 | + | if ((0 > change)) | |
62 | + | then { | |
63 | + | let sendAmount = (change * -1) | |
64 | + | $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("deposit: " + toString(sendAmount))]) | |
65 | + | } | |
66 | + | else { | |
67 | + | let sendAmount = change | |
68 | + | $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("withdraw: " + toString(sendAmount))]) | |
69 | + | } | |
62 | 70 | } | |
63 | 71 | ||
64 | 72 |
github/deemru/w8io/169f3d6 25.49 ms ◑