tx · FQcKGnKCWEoDER6GCXaZjUchpyqSwfjdQgibexChkgaN 3NAfzeA3URU6oCV6HvtAiNwqGXsTs87ZpHh: -0.04000000 Waves 2022.08.24 13:01 [2198414] smart account 3NAfzeA3URU6oCV6HvtAiNwqGXsTs87ZpHh > SELF 0.00000000 Waves
{ "type": 13, "id": "FQcKGnKCWEoDER6GCXaZjUchpyqSwfjdQgibexChkgaN", "fee": 4000000, "feeAssetId": null, "timestamp": 1661335296964, "version": 1, "sender": "3NAfzeA3URU6oCV6HvtAiNwqGXsTs87ZpHh", "senderPublicKey": "HiTi1JT7GQRqLNxg4yZhD1mV42y1Mv2AYvRx92JQRbwX", "proofs": [ "2RWmrGCvReXxXcTo2d7CyYAfrZj4EX7PiNjK5h4bCH7MXTuEWmHMNLQkYvnfyJB1tzQ8xZAw3SAk2o5nAhp18yS7" ], "script": "base64:BgIvCAISBAoCAQQSBQoDCAEBEgUKAwgBARIDCgEIEgQKAggBEgUKAwgBCBIFCgMIAQhqAAZFVUxFUjgA1onPgQEABU1VTFQ2AMCEPQAGTVVMVFg2CQC2AgEAwIQ9AAVNVUxUOACAwtcvAAZNVUxUWDgJALYCAQCAwtcvAAdNVUxUWDEwCQC2AgEAgMivoCUABk1VTFQxMgCAoJSljR0AB01VTFRYMTYJALYCAQCAgIT+pt7hEQAGTVVMVDE4CQC2AgEAgICQu7rWrfANAANTRVACAl9fABFERUZBVUxUU1dBUEZFRU4yVwCIJwARREVGQVVMVFNXQVBGRUVXMk4AoJwBAAtCUlBST1RFQ1RFRACgjQYAB1dBVkVTSUQJANkEAQIFV0FWRVMBEmtleU5ldXRyaW5vQXNzZXRJZAACEW5ldXRyaW5vX2Fzc2V0X2lkAQ5rZXlOc2J0QXNzZXRJZAACDWJvbmRfYXNzZXRfaWQBDmtleVN1cmZBc3NldElkAAINc3VyZl9hc3NldF9pZAEQa2V5QmFsYW5jZUxvY2tlZAACDWJhbGFuY2VfbG9ja18BFWtleVdhdmVzTG9ja2VkQmFsYW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UMb3V0TmV0QW1vdW50CQDMCAIJAKQDAQUKb3V0U3VyZkFtdAkAzAgCCQCkAwEFDG91dEZlZUFtb3VudAkAzAgCCQCkAwEFBXByaWNlCQDMCAIJAKQDAQUOYmxja3MyTG10UmVzZXQJAMwIAgkApAMBBQ1saW1pdE1heFdhdmVzCQDMCAIJAKQDAQUMbGltaXRNYXhVc2RuCQDMCAIJAKQDAQUPaW5BbXRUb1N1cmZQYXJ0BQNuaWwFA1NFUABrA/Ah", "chainId": 84, "height": 2198414, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8g2WnbZT4qL8h1oL7rvXrsJ7pgHgRSFUzQnf5KZZ8SiQ Next: 62SckJcH7hagXSmBJLcjz7ucac7xwYwkadsKCMPmzsiB Diff:
Old | New | Differences | |
---|---|---|---|
63 | 63 | ||
64 | 64 | ||
65 | 65 | func keySwapAmountBParam () = "%s%s__config__swapBParam" | |
66 | + | ||
67 | + | ||
68 | + | func keyUsdnSwapAmountAParam () = "%s%s__config__usdnSwapAParam" | |
69 | + | ||
70 | + | ||
71 | + | func keyUsdnSwapAmountBParam () = "%s%s__config__usdnSwapBParam" | |
66 | 72 | ||
67 | 73 | ||
68 | 74 | func keyNsbtLockContract () = "%s__nsbtLockContract" | |
287 | 293 | let surfAssetId = fromBase58String(surfAssetIdStr) | |
288 | 294 | ||
289 | 295 | @Callable(i) | |
290 | - | func reverseSwapLimitREADONLY (lim) = { | |
296 | + | func reverseSwapLimitREADONLY (lim,isWavesSwap) = { | |
297 | + | let BR = asInt(asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil))[nMetricIdxBR]) | |
291 | 298 | let gNsbt = if ((0 >= lim)) | |
292 | 299 | then 0 | |
293 | 300 | else { | |
294 | - | let aParamX8 = toBigInt(getIntOrFail(mathContract, keySwapAmountAParam())) | |
295 | - | let bParamX16 = toBigInt(getIntOrFail(mathContract, keySwapAmountBParam())) | |
296 | - | let limDivAX8 = fraction(toBigInt(lim), MULTX10, aParamX8) | |
301 | + | let aParamX8 = toBigInt(getIntOrFail(mathContract, if (isWavesSwap) | |
302 | + | then keySwapAmountAParam() | |
303 | + | else keyUsdnSwapAmountAParam())) | |
304 | + | let bParamX16 = toBigInt(getIntOrFail(mathContract, if (isWavesSwap) | |
305 | + | then keySwapAmountBParam() | |
306 | + | else keyUsdnSwapAmountBParam())) | |
307 | + | let limDivAX8 = if (isWavesSwap) | |
308 | + | then fraction(toBigInt(lim), MULTX10, aParamX8) | |
309 | + | else fraction(fraction(toBigInt(lim), MULTX10, aParamX8), MULTX6, toBigInt(BR)) | |
297 | 310 | let revBX16 = fraction(MULTX16, MULTX16, bParamX16) | |
298 | 311 | toInt(pow(limDivAX8, 8, revBX16, 16, 6, CEILING)) | |
299 | 312 | } | |
416 | 429 | let limitWantedUsdn = if ((assetIdStr == "WAVES")) | |
417 | 430 | then convertWavesToNeutrino(limitWanted, getIntegerValue(controlContract, keyPrice())) | |
418 | 431 | else limitWanted | |
419 | - | let gNsbtNeeded = asInt(invoke(this, "reverseSwapLimitREADONLY", [limitWantedUsdn], nil)) | |
432 | + | let gNsbtNeeded = asInt(invoke(this, "reverseSwapLimitREADONLY", [limitWantedUsdn, (assetIdStr == "WAVES")], nil)) | |
420 | 433 | let gNsbtDelta = (gNsbtNeeded - gNsbtCurrent) | |
421 | 434 | $Tuple2(nil, makeString(["%s%s", toString(gNsbtCurrent), toString(gNsbtDelta)], SEP)) | |
422 | 435 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let EULER8 = 271828182 | |
5 | 5 | ||
6 | 6 | let MULT6 = 1000000 | |
7 | 7 | ||
8 | 8 | let MULTX6 = toBigInt(1000000) | |
9 | 9 | ||
10 | 10 | let MULT8 = 100000000 | |
11 | 11 | ||
12 | 12 | let MULTX8 = toBigInt(100000000) | |
13 | 13 | ||
14 | 14 | let MULTX10 = toBigInt(10000000000) | |
15 | 15 | ||
16 | 16 | let MULT12 = 1000000000000 | |
17 | 17 | ||
18 | 18 | let MULTX16 = toBigInt(10000000000000000) | |
19 | 19 | ||
20 | 20 | let MULT18 = toBigInt(1000000000000000000) | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let DEFAULTSWAPFEEN2W = 5000 | |
25 | 25 | ||
26 | 26 | let DEFAULTSWAPFEEW2N = 20000 | |
27 | 27 | ||
28 | 28 | let BRPROTECTED = 100000 | |
29 | 29 | ||
30 | 30 | let WAVESID = fromBase58String("WAVES") | |
31 | 31 | ||
32 | 32 | func keyNeutrinoAssetId () = "neutrino_asset_id" | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func keyNsbtAssetId () = "bond_asset_id" | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func keySurfAssetId () = "surf_asset_id" | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func keyBalanceLocked () = "balance_lock_" | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func keyWavesLockedBalance () = (keyBalanceLocked() + "waves") | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func keyNeutrinoLockedBalance () = (keyBalanceLocked() + "neutrino") | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | func keyMinWavesSwapAmount () = "min_waves_swap_amount" | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | func keyMinNeutrinoSwapAmount () = "min_neutrino_swap_amount" | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | func keyWavesOutFeePart () = "wavesOut_swap_feePart" | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | func keyNeutrinoOutFeePart () = "neutrinoOut_swap_feePart" | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func keySwapAmountAParam () = "%s%s__config__swapAParam" | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func keySwapAmountBParam () = "%s%s__config__swapBParam" | |
66 | + | ||
67 | + | ||
68 | + | func keyUsdnSwapAmountAParam () = "%s%s__config__usdnSwapAParam" | |
69 | + | ||
70 | + | ||
71 | + | func keyUsdnSwapAmountBParam () = "%s%s__config__usdnSwapBParam" | |
66 | 72 | ||
67 | 73 | ||
68 | 74 | func keyNsbtLockContract () = "%s__nsbtLockContract" | |
69 | 75 | ||
70 | 76 | ||
71 | 77 | func keyMathContract () = "%s__mathContract" | |
72 | 78 | ||
73 | 79 | ||
74 | 80 | func keyBalanceWavesLockInterval () = "balance_waves_lock_interval" | |
75 | 81 | ||
76 | 82 | ||
77 | 83 | func keyBalanceNeutrinoLockInterval () = "balance_neutrino_lock_interval" | |
78 | 84 | ||
79 | 85 | ||
80 | 86 | func keyPrice () = "price" | |
81 | 87 | ||
82 | 88 | ||
83 | 89 | func keyLockParamStartBlock (userAddress) = makeString(["%s%s%s", "paramByUser", userAddress, "start"], SEP) | |
84 | 90 | ||
85 | 91 | ||
86 | 92 | func keyHalfLife () = "%s__halfLife" | |
87 | 93 | ||
88 | 94 | ||
89 | 95 | func keyMinLockAmount () = "%s__minLockAmount" | |
90 | 96 | ||
91 | 97 | ||
92 | 98 | func keyMinWavesForNsbtBuy () = "min_waves_nsbt_buy" | |
93 | 99 | ||
94 | 100 | ||
95 | 101 | func keyMinNsbtSell () = "min_nsbt_sell" | |
96 | 102 | ||
97 | 103 | ||
98 | 104 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
99 | 105 | ||
100 | 106 | ||
101 | 107 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
102 | 108 | ||
103 | 109 | ||
104 | 110 | func getBoolOrFail (address,key) = valueOrErrorMessage(getBoolean(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
105 | 111 | ||
106 | 112 | ||
107 | 113 | func convertNeutrinoToWaves (amount,price) = fraction(amount, MULT8, price) | |
108 | 114 | ||
109 | 115 | ||
110 | 116 | func convertWavesToNeutrino (amount,price) = fraction(amount, price, MULT8) | |
111 | 117 | ||
112 | 118 | ||
113 | 119 | func asAnyList (val) = match val { | |
114 | 120 | case valAnyList: List[Any] => | |
115 | 121 | valAnyList | |
116 | 122 | case _ => | |
117 | 123 | throw("fail to cast into List[Any]") | |
118 | 124 | } | |
119 | 125 | ||
120 | 126 | ||
121 | 127 | func asInt (val) = match val { | |
122 | 128 | case valInt: Int => | |
123 | 129 | valInt | |
124 | 130 | case _ => | |
125 | 131 | throw("fail to cast into Int") | |
126 | 132 | } | |
127 | 133 | ||
128 | 134 | ||
129 | 135 | func asString (val) = match val { | |
130 | 136 | case valStr: String => | |
131 | 137 | valStr | |
132 | 138 | case _ => | |
133 | 139 | throw("fail to cast into String") | |
134 | 140 | } | |
135 | 141 | ||
136 | 142 | ||
137 | 143 | func asTuple2Ints (val) = match val { | |
138 | 144 | case v: (Int, Int) => | |
139 | 145 | v | |
140 | 146 | case _ => | |
141 | 147 | throw("fail to cast into Tuple2 ints") | |
142 | 148 | } | |
143 | 149 | ||
144 | 150 | ||
145 | 151 | func asSwapParamsSTRUCT (val) = match val { | |
146 | 152 | case struct: (Int, Int, Int, Int, Int, Int, Int) => | |
147 | 153 | struct | |
148 | 154 | case _ => | |
149 | 155 | throw("fail to cast into SwapParamsSTRUCT") | |
150 | 156 | } | |
151 | 157 | ||
152 | 158 | ||
153 | 159 | func asWithdrawResultSTRUCT (val) = match val { | |
154 | 160 | case struct: (Int, Unit, Int, Int, Int, Int, Int)|(Int, ByteVector, Int, Int, Int, Int, Int) => | |
155 | 161 | struct | |
156 | 162 | case _ => | |
157 | 163 | throw("fail to cast into WithdrawResult") | |
158 | 164 | } | |
159 | 165 | ||
160 | 166 | ||
161 | 167 | func toTimestamp (start) = if ((0 > start)) | |
162 | 168 | then -1 | |
163 | 169 | else match blockInfoByHeight(start) { | |
164 | 170 | case block: BlockInfo => | |
165 | 171 | block.timestamp | |
166 | 172 | case _ => | |
167 | 173 | -1 | |
168 | 174 | } | |
169 | 175 | ||
170 | 176 | ||
171 | 177 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), MULT18, toBigInt(origScaleMult)) | |
172 | 178 | ||
173 | 179 | ||
174 | 180 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), MULT18)) | |
175 | 181 | ||
176 | 182 | ||
177 | 183 | let nMetricIdxPrice = 0 | |
178 | 184 | ||
179 | 185 | let nMetricIdxUsdnLockedBalance = 1 | |
180 | 186 | ||
181 | 187 | let nMetricIdxWavesLockedBalance = 2 | |
182 | 188 | ||
183 | 189 | let nMetricIdxReserve = 3 | |
184 | 190 | ||
185 | 191 | let nMetricIdxReserveInUsdn = 4 | |
186 | 192 | ||
187 | 193 | let nMetricIdxUsdnSupply = 5 | |
188 | 194 | ||
189 | 195 | let nMetricIdxSurplus = 6 | |
190 | 196 | ||
191 | 197 | let nMetricIdxSurplusPercent = 7 | |
192 | 198 | ||
193 | 199 | let nMetricIdxBR = 8 | |
194 | 200 | ||
195 | 201 | let nMetricIdxNsbtSupply = 9 | |
196 | 202 | ||
197 | 203 | let nMetricIdxMaxNsbtSupply = 10 | |
198 | 204 | ||
199 | 205 | let nMetricIdxSurfSupply = 11 | |
200 | 206 | ||
201 | 207 | let IdxControlCfgNeutrinoDapp = 1 | |
202 | 208 | ||
203 | 209 | let IdxControlCfgAuctionDapp = 2 | |
204 | 210 | ||
205 | 211 | let IdxControlCfgRpdDapp = 3 | |
206 | 212 | ||
207 | 213 | let IdxControlCfgMathDapp = 4 | |
208 | 214 | ||
209 | 215 | let IdxControlCfgLiquidationDapp = 5 | |
210 | 216 | ||
211 | 217 | let IdxControlCfgRestDapp = 6 | |
212 | 218 | ||
213 | 219 | let IdxControlCfgNodeRegistryDapp = 7 | |
214 | 220 | ||
215 | 221 | let IdxControlCfgNsbtStakingDapp = 8 | |
216 | 222 | ||
217 | 223 | let IdxControlCfgMediatorDapp = 9 | |
218 | 224 | ||
219 | 225 | let IdxControlCfgSurfStakingDapp = 10 | |
220 | 226 | ||
221 | 227 | let IdxControlCfgGnsbtControllerDapp = 11 | |
222 | 228 | ||
223 | 229 | let bFuncIdxSurf = 0 | |
224 | 230 | ||
225 | 231 | let bFuncIdxWaves = 1 | |
226 | 232 | ||
227 | 233 | let bFuncIdxUsdn = 2 | |
228 | 234 | ||
229 | 235 | let bFuncIdxReserveStart = 3 | |
230 | 236 | ||
231 | 237 | let bFuncIdxSupplyStart = 4 | |
232 | 238 | ||
233 | 239 | let bFuncIdxBRStart = 5 | |
234 | 240 | ||
235 | 241 | let bFuncIdxReserveEnd = 6 | |
236 | 242 | ||
237 | 243 | let bFuncIdxSupplyEnd = 7 | |
238 | 244 | ||
239 | 245 | let bFuncIdxBREnd = 8 | |
240 | 246 | ||
241 | 247 | let bFuncIdxRest = 9 | |
242 | 248 | ||
243 | 249 | let bFuncIdxWavesPrice = 10 | |
244 | 250 | ||
245 | 251 | func keyControlAddress () = "%s%s__config__controlAddress" | |
246 | 252 | ||
247 | 253 | ||
248 | 254 | func keyControlCfg () = "%s__controlConfig" | |
249 | 255 | ||
250 | 256 | ||
251 | 257 | func readControlCfgOrFail (control) = split(getStringOrFail(control, keyControlCfg()), SEP) | |
252 | 258 | ||
253 | 259 | ||
254 | 260 | func getContractAddressOrFail (controlCfg,idx) = valueOrErrorMessage(addressFromString(controlCfg[idx]), ("Control cfg doesn't contain address at index " + toString(idx))) | |
255 | 261 | ||
256 | 262 | ||
257 | 263 | let controlContract = addressFromStringValue(valueOrElse(getString(this, keyControlAddress()), "3N4NS7d4Jo9a6F14LiFUKKYVdUkkf2eP4Zx")) | |
258 | 264 | ||
259 | 265 | let controlCfg = readControlCfgOrFail(controlContract) | |
260 | 266 | ||
261 | 267 | let mathContract = getContractAddressOrFail(controlCfg, IdxControlCfgMathDapp) | |
262 | 268 | ||
263 | 269 | let neutrinoContract = getContractAddressOrFail(controlCfg, IdxControlCfgNeutrinoDapp) | |
264 | 270 | ||
265 | 271 | let auctionContract = getContractAddressOrFail(controlCfg, IdxControlCfgAuctionDapp) | |
266 | 272 | ||
267 | 273 | let liquidationContract = getContractAddressOrFail(controlCfg, IdxControlCfgLiquidationDapp) | |
268 | 274 | ||
269 | 275 | let rpdContract = getContractAddressOrFail(controlCfg, IdxControlCfgRpdDapp) | |
270 | 276 | ||
271 | 277 | let nsbtStakingContract = getContractAddressOrFail(controlCfg, IdxControlCfgNsbtStakingDapp) | |
272 | 278 | ||
273 | 279 | let surfStakingContract = getContractAddressOrFail(controlCfg, IdxControlCfgSurfStakingDapp) | |
274 | 280 | ||
275 | 281 | let gnsbtControllerContract = getContractAddressOrFail(controlCfg, IdxControlCfgGnsbtControllerDapp) | |
276 | 282 | ||
277 | 283 | let neutrinoAssetIdString = getStringOrFail(neutrinoContract, keyNeutrinoAssetId()) | |
278 | 284 | ||
279 | 285 | let neutrinoAssetId = fromBase58String(neutrinoAssetIdString) | |
280 | 286 | ||
281 | 287 | let nsbtAssetIdStr = getStringValue(neutrinoContract, keyNsbtAssetId()) | |
282 | 288 | ||
283 | 289 | let nsbtAssetId = fromBase58String(nsbtAssetIdStr) | |
284 | 290 | ||
285 | 291 | let surfAssetIdStr = getStringValue(auctionContract, keySurfAssetId()) | |
286 | 292 | ||
287 | 293 | let surfAssetId = fromBase58String(surfAssetIdStr) | |
288 | 294 | ||
289 | 295 | @Callable(i) | |
290 | - | func reverseSwapLimitREADONLY (lim) = { | |
296 | + | func reverseSwapLimitREADONLY (lim,isWavesSwap) = { | |
297 | + | let BR = asInt(asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil))[nMetricIdxBR]) | |
291 | 298 | let gNsbt = if ((0 >= lim)) | |
292 | 299 | then 0 | |
293 | 300 | else { | |
294 | - | let aParamX8 = toBigInt(getIntOrFail(mathContract, keySwapAmountAParam())) | |
295 | - | let bParamX16 = toBigInt(getIntOrFail(mathContract, keySwapAmountBParam())) | |
296 | - | let limDivAX8 = fraction(toBigInt(lim), MULTX10, aParamX8) | |
301 | + | let aParamX8 = toBigInt(getIntOrFail(mathContract, if (isWavesSwap) | |
302 | + | then keySwapAmountAParam() | |
303 | + | else keyUsdnSwapAmountAParam())) | |
304 | + | let bParamX16 = toBigInt(getIntOrFail(mathContract, if (isWavesSwap) | |
305 | + | then keySwapAmountBParam() | |
306 | + | else keyUsdnSwapAmountBParam())) | |
307 | + | let limDivAX8 = if (isWavesSwap) | |
308 | + | then fraction(toBigInt(lim), MULTX10, aParamX8) | |
309 | + | else fraction(fraction(toBigInt(lim), MULTX10, aParamX8), MULTX6, toBigInt(BR)) | |
297 | 310 | let revBX16 = fraction(MULTX16, MULTX16, bParamX16) | |
298 | 311 | toInt(pow(limDivAX8, 8, revBX16, 16, 6, CEILING)) | |
299 | 312 | } | |
300 | 313 | $Tuple2(nil, gNsbt) | |
301 | 314 | } | |
302 | 315 | ||
303 | 316 | ||
304 | 317 | ||
305 | 318 | @Callable(i) | |
306 | 319 | func gnsbtInfoINTERNAL (userAddressStrOrEmpty,additionalNsbtToStakeOrZero,additionalSurfToStakeOrZero) = { | |
307 | 320 | let userAddressOrThis = if ((userAddressStrOrEmpty != "")) | |
308 | 321 | then addressFromStringValue(userAddressStrOrEmpty) | |
309 | 322 | else this | |
310 | 323 | let currentPrice = getIntegerValue(controlContract, keyPrice()) | |
311 | 324 | let gnsbtFromNsbtDiff = additionalNsbtToStakeOrZero | |
312 | 325 | let gnsbtFromSurfDiff = asInt(invoke(surfStakingContract, "gnsbtFromSurfSYSREADONLY", [additionalSurfToStakeOrZero], nil)) | |
313 | 326 | let gNsbtDiff = (gnsbtFromNsbtDiff + gnsbtFromSurfDiff) | |
314 | 327 | let swapParamsTuple = asSwapParamsSTRUCT(invoke(neutrinoContract, "swapParamsByUserSYSREADONLY", [userAddressStrOrEmpty, 0], nil)) | |
315 | 328 | let blcks2LmtReset = swapParamsTuple._3 | |
316 | 329 | let gnsbtAmt = swapParamsTuple._4 | |
317 | 330 | let gnsbtAmtTotal = swapParamsTuple._5 | |
318 | 331 | let limitMaxWaves = swapParamsTuple._6 | |
319 | 332 | let limitMaxUsdn = swapParamsTuple._7 | |
320 | 333 | let swapParamsTupleNEW = asSwapParamsSTRUCT(invoke(neutrinoContract, "swapParamsByUserSYSREADONLY", [userAddressStrOrEmpty, gNsbtDiff], nil)) | |
321 | 334 | let blcks2LmtResetNEW = swapParamsTupleNEW._3 | |
322 | 335 | let gnsbtAmtNEW = swapParamsTupleNEW._4 | |
323 | 336 | let gnsbtAmtTotalNEW = swapParamsTupleNEW._5 | |
324 | 337 | let limitMaxWavesNEW = swapParamsTupleNEW._6 | |
325 | 338 | let limitMaxUsdnNEW = swapParamsTupleNEW._7 | |
326 | 339 | let nsbtBalance = if ((userAddressStrOrEmpty != "")) | |
327 | 340 | then assetBalance(userAddressOrThis, nsbtAssetId) | |
328 | 341 | else 0 | |
329 | 342 | let surfBalance = if ((userAddressStrOrEmpty != "")) | |
330 | 343 | then assetBalance(userAddressOrThis, surfAssetId) | |
331 | 344 | else 0 | |
332 | 345 | let nsbtBalanceDiff = if ((additionalNsbtToStakeOrZero >= 0)) | |
333 | 346 | then additionalNsbtToStakeOrZero | |
334 | 347 | else { | |
335 | 348 | let nsbtUnstakingData = asAnyList(invoke(nsbtStakingContract, "nsbtUnstakingSYSREADONLY", [userAddressStrOrEmpty, (-1 * additionalNsbtToStakeOrZero)], nil)) | |
336 | 349 | let nsbtReceiveAmount = asInt(nsbtUnstakingData[2]) | |
337 | 350 | let result = -(nsbtReceiveAmount) | |
338 | 351 | result | |
339 | 352 | } | |
340 | 353 | let nsbtBalanceNew = (nsbtBalance - nsbtBalanceDiff) | |
341 | 354 | let surfBalanceNew = (surfBalance - additionalSurfToStakeOrZero) | |
342 | 355 | let gnsbtData = asAnyList(invoke(gnsbtControllerContract, "gnsbtInfoSYSREADONLY", [userAddressStrOrEmpty, additionalNsbtToStakeOrZero, additionalSurfToStakeOrZero], nil)) | |
343 | 356 | let gnsbtUser = asInt(gnsbtData[0]) | |
344 | 357 | let gnsbtTotal = asInt(gnsbtData[1]) | |
345 | 358 | let nsbtData = asAnyList(gnsbtData[2]) | |
346 | 359 | let surfData = asAnyList(gnsbtData[3]) | |
347 | 360 | let vpEffectiveHeight = asInt(gnsbtData[4]) | |
348 | 361 | let vpEffectiveHeightNEW = asInt(gnsbtData[5]) | |
349 | 362 | let gnsbtAmtFromNsbt = asInt(nsbtData[2]) | |
350 | 363 | let gnsbtAmtFromSurf = asInt(surfData[2]) | |
351 | 364 | let gnsbtAmtFromNsbtNEW = (gnsbtAmtFromNsbt + gnsbtFromNsbtDiff) | |
352 | 365 | let gnsbtAmtFromSurfNEW = (gnsbtAmtFromSurf + gnsbtFromSurfDiff) | |
353 | 366 | let gnsbtFromNsbtTotal = asInt(nsbtData[3]) | |
354 | 367 | let gnsbtFromSurfTotal = asInt(surfData[3]) | |
355 | 368 | let gnsbtFromSurfActiveTotal = 0 | |
356 | 369 | let gnsbtFromSurfFrozenTotal = gnsbtFromSurfTotal | |
357 | 370 | let gnsbtFromNsbtTotalNEW = (gnsbtFromNsbtTotal + gnsbtFromNsbtDiff) | |
358 | 371 | let gnsbtFromSurfTotalNEW = (gnsbtFromSurfTotal + gnsbtFromSurfDiff) | |
359 | 372 | let gnsbtFromSurfFrozenTotalNEW = gnsbtFromSurfTotalNEW | |
360 | 373 | let votingPower = fraction(gnsbtAmtFromNsbt, MULT8, (gnsbtFromNsbtTotal + gnsbtFromSurfActiveTotal)) | |
361 | 374 | let votingPowerNew = fraction(gnsbtAmtFromNsbtNEW, MULT8, (gnsbtFromNsbtTotalNEW + gnsbtFromSurfActiveTotal)) | |
362 | 375 | let votingPowerMax = fraction((gnsbtAmtFromNsbt + gnsbtAmtFromSurf), MULT8, ((gnsbtFromNsbtTotal + gnsbtFromSurfActiveTotal) + gnsbtFromSurfFrozenTotal)) | |
363 | 376 | let votingPowerMaxNew = fraction((gnsbtAmtFromNsbtNEW + gnsbtAmtFromSurfNEW), MULT8, ((gnsbtFromNsbtTotalNEW + gnsbtFromSurfActiveTotal) + gnsbtFromSurfFrozenTotalNEW)) | |
364 | 377 | let votingPowerEta = if ((vpEffectiveHeight == 0)) | |
365 | 378 | then height | |
366 | 379 | else vpEffectiveHeight | |
367 | 380 | let votingPowerEtaNew = if ((vpEffectiveHeightNEW == 0)) | |
368 | 381 | then height | |
369 | 382 | else vpEffectiveHeightNEW | |
370 | 383 | $Tuple2(nil, [0, nsbtBalance, surfBalance, nsbtBalanceNew, surfBalanceNew, gnsbtAmtFromNsbt, gnsbtAmtFromSurf, gnsbtAmtFromNsbtNEW, gnsbtAmtFromSurfNEW, gnsbtFromNsbtTotal, gnsbtFromSurfTotal, gnsbtFromNsbtTotalNEW, gnsbtFromSurfTotalNEW, limitMaxUsdn, limitMaxWaves, limitMaxUsdnNEW, limitMaxWavesNEW, blcks2LmtReset, blcks2LmtResetNEW, votingPower, votingPowerNew, votingPowerMax, votingPowerMaxNew, votingPowerEta, votingPowerEtaNew]) | |
371 | 384 | } | |
372 | 385 | ||
373 | 386 | ||
374 | 387 | ||
375 | 388 | @Callable(i) | |
376 | 389 | func gnsbtInfoREADONLY (userAddressStrOrEmpty,additionalNsbtToStakeOrZero,additionalSurfToStakeOrZero) = { | |
377 | 390 | let gnsbtInfoDATA = asAnyList(invoke(this, "gnsbtInfoINTERNAL", [userAddressStrOrEmpty, additionalNsbtToStakeOrZero, additionalSurfToStakeOrZero], nil)) | |
378 | 391 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", toString(asInt(gnsbtInfoDATA[1])), toString(asInt(gnsbtInfoDATA[2])), toString(asInt(gnsbtInfoDATA[3])), toString(asInt(gnsbtInfoDATA[4])), toString(asInt(gnsbtInfoDATA[5])), toString(asInt(gnsbtInfoDATA[6])), toString(asInt(gnsbtInfoDATA[7])), toString(asInt(gnsbtInfoDATA[8])), toString(asInt(gnsbtInfoDATA[9])), toString(asInt(gnsbtInfoDATA[10])), toString(asInt(gnsbtInfoDATA[11])), toString(asInt(gnsbtInfoDATA[12])), toString(asInt(gnsbtInfoDATA[13])), toString(asInt(gnsbtInfoDATA[14])), toString(asInt(gnsbtInfoDATA[15])), toString(asInt(gnsbtInfoDATA[16])), toString(asInt(gnsbtInfoDATA[17])), toString(asInt(gnsbtInfoDATA[18])), toString(asInt(gnsbtInfoDATA[19])), toString(asInt(gnsbtInfoDATA[20])), toString(asInt(gnsbtInfoDATA[21])), toString(asInt(gnsbtInfoDATA[22])), toString(asInt(gnsbtInfoDATA[23])), toString(asInt(gnsbtInfoDATA[24]))], SEP)) | |
379 | 392 | } | |
380 | 393 | ||
381 | 394 | ||
382 | 395 | ||
383 | 396 | @Callable(i) | |
384 | 397 | func rewardInfoREADONLY (userAddressStrOrEmpty) = { | |
385 | 398 | let rewardsData = asAnyList(invoke(gnsbtControllerContract, "gnsbtRewardsSYSREADONLY", [userAddressStrOrEmpty], nil)) | |
386 | 399 | $Tuple2(nil, makeString(["%s%s", asString(rewardsData[0]), asString(rewardsData[1])], SEP)) | |
387 | 400 | } | |
388 | 401 | ||
389 | 402 | ||
390 | 403 | ||
391 | 404 | @Callable(i) | |
392 | 405 | func mergeNsbtREADONLY (userAddressMandatory,newAmount) = { | |
393 | 406 | let nsbtData = asAnyList(invoke(nsbtStakingContract, "nsbtStakingSYSREADONLY", [userAddressMandatory, newAmount], nil)) | |
394 | 407 | let amount0 = asInt(nsbtData[0]) | |
395 | 408 | let startHeight = if ((0 >= amount0)) | |
396 | 409 | then -1 | |
397 | 410 | else asInt(nsbtData[2]) | |
398 | 411 | let startTimestamp = toTimestamp(startHeight) | |
399 | 412 | let startHeightNew = if ((0 >= newAmount)) | |
400 | 413 | then startHeight | |
401 | 414 | else { | |
402 | 415 | let halfLife = getIntOrFail(nsbtStakingContract, keyHalfLife()) | |
403 | 416 | asInt(invoke(mathContract, "mergeStakesREADONLY", [amount0, startHeight, newAmount, height, halfLife], nil)) | |
404 | 417 | } | |
405 | 418 | let startTimestampNew = toTimestamp(startHeightNew) | |
406 | 419 | $Tuple2(nil, makeString(["%d%d%d%d", toString(startHeight), toString(startTimestamp), toString(startHeightNew), toString(startTimestampNew)], SEP)) | |
407 | 420 | } | |
408 | 421 | ||
409 | 422 | ||
410 | 423 | ||
411 | 424 | @Callable(i) | |
412 | 425 | func swapLimitCalculatorREADONLY (userAddressStrOpt,limitWanted,assetIdStr) = { | |
413 | 426 | let gNsbtCurrent = if ((userAddressStrOpt == "")) | |
414 | 427 | then 0 | |
415 | 428 | else asInt(asSwapParamsSTRUCT(invoke(neutrinoContract, "swapParamsByUserSYSREADONLY", [userAddressStrOpt, 0], nil))._4) | |
416 | 429 | let limitWantedUsdn = if ((assetIdStr == "WAVES")) | |
417 | 430 | then convertWavesToNeutrino(limitWanted, getIntegerValue(controlContract, keyPrice())) | |
418 | 431 | else limitWanted | |
419 | - | let gNsbtNeeded = asInt(invoke(this, "reverseSwapLimitREADONLY", [limitWantedUsdn], nil)) | |
432 | + | let gNsbtNeeded = asInt(invoke(this, "reverseSwapLimitREADONLY", [limitWantedUsdn, (assetIdStr == "WAVES")], nil)) | |
420 | 433 | let gNsbtDelta = (gNsbtNeeded - gNsbtCurrent) | |
421 | 434 | $Tuple2(nil, makeString(["%s%s", toString(gNsbtCurrent), toString(gNsbtDelta)], SEP)) | |
422 | 435 | } | |
423 | 436 | ||
424 | 437 | ||
425 | 438 | ||
426 | 439 | @Callable(i) | |
427 | 440 | func swapInfoREADONLY (userAddressStrOrEmpty,amount,assetIdStr) = { | |
428 | 441 | let neutrinoMetrics = asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil)) | |
429 | 442 | let price = asInt(neutrinoMetrics[nMetricIdxPrice]) | |
430 | 443 | let swapParamsTuple = asSwapParamsSTRUCT(invoke(neutrinoContract, "swapParamsByUserSYSREADONLY", [userAddressStrOrEmpty, 0], nil)) | |
431 | 444 | let blcks2LmtReset = swapParamsTuple._3 | |
432 | 445 | let limitMaxWaves = swapParamsTuple._6 | |
433 | 446 | let limitMaxUsdn = swapParamsTuple._7 | |
434 | 447 | let assetId = fromBase58String(assetIdStr) | |
435 | 448 | let swapType = if ((assetId == WAVESID)) | |
436 | 449 | then "waves" | |
437 | 450 | else if ((assetId == neutrinoAssetId)) | |
438 | 451 | then "neutrino" | |
439 | 452 | else throw(("Can't swap assetId=" + assetIdStr)) | |
440 | 453 | let withdrawTuple = asWithdrawResultSTRUCT(invoke(neutrinoContract, "calcWithdrawResultSYSREADONLY", [swapType, amount, price], nil)) | |
441 | 454 | let outNetAmount = withdrawTuple._1 | |
442 | 455 | let outAssetId = withdrawTuple._2 | |
443 | 456 | let outSurfAmt = withdrawTuple._3 | |
444 | 457 | let inAmtToSurfPart = withdrawTuple._4 | |
445 | 458 | let unleaseAmt = withdrawTuple._5 | |
446 | 459 | let outFeeAmount = withdrawTuple._6 | |
447 | 460 | let outAmtGross = withdrawTuple._7 | |
448 | 461 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(outNetAmount), toString(outSurfAmt), toString(outFeeAmount), toString(price), toString(blcks2LmtReset), toString(limitMaxWaves), toString(limitMaxUsdn), toString(inAmtToSurfPart)], SEP)) | |
449 | 462 | } | |
450 | 463 | ||
451 | 464 |
github/deemru/w8io/026f985 57.33 ms ◑