tx · GuWtKs3nYMdz2tUqzSF3Xmi9nZzLLUmXVtpq8jcdRpEn 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h: -0.05000000 Waves 2023.03.29 14:45 [2511188] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves
{ "type": 13, "id": "GuWtKs3nYMdz2tUqzSF3Xmi9nZzLLUmXVtpq8jcdRpEn", "fee": 5000000, "feeAssetId": null, "timestamp": 1680090396813, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "5Jxs8ZaNV1bQLe1AT1emJc6UKoacfQrVYqLRr58W5TGXF2e6oL84kMdaGjNFjofvnhJ5fK6u9VBH9kTdYwa3Cqs3" ], "script": "base64:BgIJCAISAwoBARIAFAAMY29udHJhY3RGaWxlAglyZWJhbGFuY2UAD2tleXNUYXJnZXRSYXRpbwIPJXNfX3RhcmdldFJhdGlvABRrZXlBZGRpdGlvbmFsQmFsYW5jZQIaJXNfX2FkZGl0aW9uYWxXYXZlc0JhbGFuY2UAGmtleVNXYXZlc0FkZGl0aW9uYWxCYWxhbmNlAhElc19fc1dhdmVzQmFsYW5jZQAQa2V5U1dhdmVzQXNzZXRJZAIRJXNfX3NXYXZlc0Fzc2V0SWQAD2tleVByb3h5QWRkcmVzcwIQJXNfX3Byb3h5QWRkcmVzcwANa2V5TWluQmFsYW5jZQITJXNfX21pbldhdmVzQmFsYW5jZQARa2V5RmFjdG9yeUFkZHJlc3MCCyVzX19mYWN0b3J5AAZNVUxUMTIAgKCUpY0dARBnZXRJbnRlZ2VyT3JaZXJvAQppbnRlZ2VyS2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFCmludGVnZXJLZXkDCQABAgUHJG1hdGNoMAIDSW50BAN2YWwFByRtYXRjaDAFA3ZhbAAAARBnZXRTdHJpbmdPcl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GFuY2UJAJYDAQkAzAgCAAAJAMwIAgkAZQIJAGQCBRBhdmFpbGFibGVCYWxhbmNlBRFhZGRpdGlvbmFsQmFsYW5jZQkBDWdldE1pbkJhbGFuY2UABQNuaWwEF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlCQBrAwULdGFyZ2V0UmF0aW8FDHdob2xlQmFsYW5jZQBkBARkaWZmCQBlAgURYWRkaXRpb25hbEJhbGFuY2UFF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlAwkAAAIFBGRpZmYAAAUDbmlsAwkAZgIAAAUEZGlmZgQPc2VuZFdhdmVzQW1vdW50CQEBLQEFBGRpZmYJAQdkZXBvc2l0AQUPc2VuZFdhdmVzQW1vdW50BA5nZXRXYXZlc0Ftb3VudAUEZGlmZgkBCHdpdGhkcmF3AQUOZ2V0V2F2ZXNBbW91bnQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4CAWkBDnJlYmFsYW5jZVJhdGlvAQt0YXJnZXRSYXRpbwkBEXJlYmFsYW5jZUludGVybmFsAQULdGFyZ2V0UmF0aW8BaQEJcmViYWxhbmNlAAkBEXJlYmFsYW5jZUludGVybmFsAQkBDmdldFRhcmdldFJhdGlvAABOjxUe", "height": 2511188, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9B5o6xrQxZesRAhzUguYrZiAsQDiEBE8rwd8j9ahfLaN Next: AMUwG36YQv66tpSkTNkVUyUeaCsDCK5rdczmaWj9tJvc Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | let keyProxyAddress = "%s__proxyAddress" | |
15 | 15 | ||
16 | 16 | let keyMinBalance = "%s__minWavesBalance" | |
17 | + | ||
18 | + | let keyFactoryAddress = "%s__factory" | |
17 | 19 | ||
18 | 20 | let MULT12 = 1000000000000 | |
19 | 21 | ||
67 | 69 | ||
68 | 70 | ||
69 | 71 | func getSWavesId () = fromBase58String(getStringOrThrow(keySWavesAssetId)) | |
72 | + | ||
73 | + | ||
74 | + | func getLeaseProxyConfig () = { | |
75 | + | let factory = addressFromStringValue(valueOrElse(getString(keyFactoryAddress), "")) | |
76 | + | let myAddressString = toString(this) | |
77 | + | $Tuple2(invoke(factory, "", [myAddressString, "WAVES"], nil), myAddressString) | |
78 | + | } | |
70 | 79 | ||
71 | 80 | ||
72 | 81 | func deposit (wavesAmount) = { | |
134 | 143 | ||
135 | 144 | ||
136 | 145 | func rebalanceInternal (targetRatio) = { | |
137 | - | let | |
138 | - | if (( | |
146 | + | let availableBalance = wavesBalance(this).available | |
147 | + | if ((availableBalance == availableBalance)) | |
139 | 148 | then { | |
140 | 149 | let additionalBalance = getIntegerOrZero(keyAdditionalBalance) | |
141 | 150 | if ((additionalBalance == additionalBalance)) | |
142 | 151 | then { | |
143 | - | let wholeBalance = max([0, (( | |
152 | + | let wholeBalance = max([0, ((availableBalance + additionalBalance) - getMinBalance())]) | |
144 | 153 | let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100) | |
145 | 154 | let diff = (additionalBalance - targetAdditionalBalance) | |
146 | 155 | if ((diff == 0)) |
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 | let keyMinBalance = "%s__minWavesBalance" | |
17 | + | ||
18 | + | let keyFactoryAddress = "%s__factory" | |
17 | 19 | ||
18 | 20 | let MULT12 = 1000000000000 | |
19 | 21 | ||
20 | 22 | func getIntegerOrZero (integerKey) = match getInteger(this, integerKey) { | |
21 | 23 | case val: Int => | |
22 | 24 | val | |
23 | 25 | case _ => | |
24 | 26 | 0 | |
25 | 27 | } | |
26 | 28 | ||
27 | 29 | ||
28 | 30 | func getStringOrThrow (stringKey) = match getString(this, stringKey) { | |
29 | 31 | case s: String => | |
30 | 32 | s | |
31 | 33 | case _ => | |
32 | 34 | throw((("[" + stringKey) + "] is empty")) | |
33 | 35 | } | |
34 | 36 | ||
35 | 37 | ||
36 | 38 | func getTargetRatio () = match getInteger(keysTargetRatio) { | |
37 | 39 | case ratio: Int => | |
38 | 40 | min([100, max([0, ratio])]) | |
39 | 41 | case _ => | |
40 | 42 | 0 | |
41 | 43 | } | |
42 | 44 | ||
43 | 45 | ||
44 | 46 | func getMinBalance () = match getInteger(keyMinBalance) { | |
45 | 47 | case i: Int => | |
46 | 48 | max([0, i]) | |
47 | 49 | case _ => | |
48 | 50 | 0 | |
49 | 51 | } | |
50 | 52 | ||
51 | 53 | ||
52 | 54 | func getRate () = { | |
53 | 55 | let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress)) | |
54 | 56 | let inv = invoke(proxy, "getRate", nil, nil) | |
55 | 57 | if ((inv == inv)) | |
56 | 58 | then match inv { | |
57 | 59 | case s: String => | |
58 | 60 | parseIntValue(s) | |
59 | 61 | case _ => | |
60 | 62 | throw("Rate is zero (0)") | |
61 | 63 | } | |
62 | 64 | else throw("Strict value is not equal to itself.") | |
63 | 65 | } | |
64 | 66 | ||
65 | 67 | ||
66 | 68 | func getProxyAddress () = addressFromStringValue(getStringOrThrow(keyProxyAddress)) | |
67 | 69 | ||
68 | 70 | ||
69 | 71 | func getSWavesId () = fromBase58String(getStringOrThrow(keySWavesAssetId)) | |
72 | + | ||
73 | + | ||
74 | + | func getLeaseProxyConfig () = { | |
75 | + | let factory = addressFromStringValue(valueOrElse(getString(keyFactoryAddress), "")) | |
76 | + | let myAddressString = toString(this) | |
77 | + | $Tuple2(invoke(factory, "", [myAddressString, "WAVES"], nil), myAddressString) | |
78 | + | } | |
70 | 79 | ||
71 | 80 | ||
72 | 81 | func deposit (wavesAmount) = { | |
73 | 82 | let proxy = getProxyAddress() | |
74 | 83 | let currentAdditionalBalance = getIntegerOrZero(keyAdditionalBalance) | |
75 | 84 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
76 | 85 | then { | |
77 | 86 | let currentSWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance) | |
78 | 87 | if ((currentSWavesBalance == currentSWavesBalance)) | |
79 | 88 | then if ((wavesAmount > 0)) | |
80 | 89 | then { | |
81 | 90 | let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(unit, wavesAmount)]) | |
82 | 91 | if ((depositInvoke == depositInvoke)) | |
83 | 92 | then match depositInvoke { | |
84 | 93 | case receivedSWaves: Int => | |
85 | 94 | let newAdditionalBalance = (currentAdditionalBalance + wavesAmount) | |
86 | 95 | let newSWavesBalance = (currentSWavesBalance + receivedSWaves) | |
87 | 96 | [IntegerEntry(keyAdditionalBalance, newAdditionalBalance), IntegerEntry(keySWavesAdditionalBalance, newSWavesBalance)] | |
88 | 97 | case _ => | |
89 | 98 | nil | |
90 | 99 | } | |
91 | 100 | else throw("Strict value is not equal to itself.") | |
92 | 101 | } | |
93 | 102 | else nil | |
94 | 103 | else throw("Strict value is not equal to itself.") | |
95 | 104 | } | |
96 | 105 | else throw("Strict value is not equal to itself.") | |
97 | 106 | } | |
98 | 107 | ||
99 | 108 | ||
100 | 109 | func withdraw (wavesAmount) = { | |
101 | 110 | let proxy = getProxyAddress() | |
102 | 111 | let currentAdditionalBalance = getIntegerOrZero(keyAdditionalBalance) | |
103 | 112 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
104 | 113 | then { | |
105 | 114 | let currentSWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance) | |
106 | 115 | if ((currentSWavesBalance == currentSWavesBalance)) | |
107 | 116 | then { | |
108 | 117 | let currentProxyRate = getRate() | |
109 | 118 | if ((currentProxyRate == currentProxyRate)) | |
110 | 119 | then { | |
111 | 120 | let sendSWavesAmount = fraction(MULT12, wavesAmount, currentProxyRate) | |
112 | 121 | if ((sendSWavesAmount > 0)) | |
113 | 122 | then { | |
114 | 123 | let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(getSWavesId(), sendSWavesAmount)]) | |
115 | 124 | if ((withdrawInvoke == withdrawInvoke)) | |
116 | 125 | then match withdrawInvoke { | |
117 | 126 | case receivedWaves: Int => | |
118 | 127 | let newAdditionalBalance = (currentAdditionalBalance - receivedWaves) | |
119 | 128 | let newSWavesBalance = (currentSWavesBalance - sendSWavesAmount) | |
120 | 129 | [IntegerEntry(keyAdditionalBalance, newAdditionalBalance), IntegerEntry(keySWavesAdditionalBalance, newSWavesBalance)] | |
121 | 130 | case _ => | |
122 | 131 | nil | |
123 | 132 | } | |
124 | 133 | else throw("Strict value is not equal to itself.") | |
125 | 134 | } | |
126 | 135 | else nil | |
127 | 136 | } | |
128 | 137 | else throw("Strict value is not equal to itself.") | |
129 | 138 | } | |
130 | 139 | else throw("Strict value is not equal to itself.") | |
131 | 140 | } | |
132 | 141 | else throw("Strict value is not equal to itself.") | |
133 | 142 | } | |
134 | 143 | ||
135 | 144 | ||
136 | 145 | func rebalanceInternal (targetRatio) = { | |
137 | - | let | |
138 | - | if (( | |
146 | + | let availableBalance = wavesBalance(this).available | |
147 | + | if ((availableBalance == availableBalance)) | |
139 | 148 | then { | |
140 | 149 | let additionalBalance = getIntegerOrZero(keyAdditionalBalance) | |
141 | 150 | if ((additionalBalance == additionalBalance)) | |
142 | 151 | then { | |
143 | - | let wholeBalance = max([0, (( | |
152 | + | let wholeBalance = max([0, ((availableBalance + additionalBalance) - getMinBalance())]) | |
144 | 153 | let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100) | |
145 | 154 | let diff = (additionalBalance - targetAdditionalBalance) | |
146 | 155 | if ((diff == 0)) | |
147 | 156 | then nil | |
148 | 157 | else if ((0 > diff)) | |
149 | 158 | then { | |
150 | 159 | let sendWavesAmount = -(diff) | |
151 | 160 | deposit(sendWavesAmount) | |
152 | 161 | } | |
153 | 162 | else { | |
154 | 163 | let getWavesAmount = diff | |
155 | 164 | withdraw(getWavesAmount) | |
156 | 165 | } | |
157 | 166 | } | |
158 | 167 | else throw("Strict value is not equal to itself.") | |
159 | 168 | } | |
160 | 169 | else throw("Strict value is not equal to itself.") | |
161 | 170 | } | |
162 | 171 | ||
163 | 172 | ||
164 | 173 | @Callable(i) | |
165 | 174 | func rebalanceRatio (targetRatio) = rebalanceInternal(targetRatio) | |
166 | 175 | ||
167 | 176 | ||
168 | 177 | ||
169 | 178 | @Callable(i) | |
170 | 179 | func rebalance () = rebalanceInternal(getTargetRatio()) | |
171 | 180 | ||
172 | 181 |
github/deemru/w8io/026f985 37.90 ms ◑