tx · 6HQdUQoyT8irZdogvakgS6twP8dkNaQzRc6nw1jPHD4f 3N18bq33YEjzWkoTDhZvc7zd7eRAyv6x4aZ: -0.01400000 Waves 2021.03.07 17:46 [1427409] smart account 3N18bq33YEjzWkoTDhZvc7zd7eRAyv6x4aZ > SELF 0.00000000 Waves
{ "type": 13, "id": "6HQdUQoyT8irZdogvakgS6twP8dkNaQzRc6nw1jPHD4f", "fee": 1400000, "feeAssetId": null, "timestamp": 1615128376428, "version": 1, "sender": "3N18bq33YEjzWkoTDhZvc7zd7eRAyv6x4aZ", "senderPublicKey": "71DfVUys2KXcuEivd6kRxABvVQKB5k5c48qobMB1DzKN", "proofs": [ "Y4CaxaXAa69wsNBkHGwUfBJe38oNyVGrT2LJqV7U8ANLFWVjdynvTaQ1k75XJhKUjZ5HZ1YKa7LW3z3MitaBUJT" ], "script": "base64:AAIEAAAAAAAAACAIAhIAEgMKAQESBAoCAQESABIECgIBARIAEgASAwoBAQAAAEYAAAAAB3ZlcnNpb24CAAAABTIuMC4wAAAAAAhrVmVyc2lvbgIAAAAHdmVyc2lvbgAAAAAHa0FjdGl2ZQIAAAAGYWN0aXZlAAAAAAlrQXNzZXRJZEECAAAACkFfYXNzZXRfaWQAAAAACWtBc3NldElkQgIAAAAKQl9hc3NldF9pZAAAAAAJa0JhbGFuY2VBAgAAAA9BX2Fzc2V0X2JhbGFuY2UAAAAACWtCYWxhbmNlQgIAAAAPQl9hc3NldF9iYWxhbmNlAAAAAA1rU2hhcmVBc3NldElkAgAAAA5zaGFyZV9hc3NldF9pZAAAAAARa1NoYXJlQXNzZXRTdXBwbHkCAAAAEnNoYXJlX2Fzc2V0X3N1cHBseQAAAAAEa0ZlZQIAAAAKY29tbWlzc2lvbgAAAAASa0ZlZVNjYWxlRGVsaW1pdGVyAgAAABpjb21taXNzaW9uX3NjYWxlX2RlbGltaXRlcgAAAAAKa0ludmFyaWFudAIAAAAJaW52YXJpYW50AAAAAAZrQ2F1c2UCAAAADnNodXRkb3du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vbGxCCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQABLAAAAAICAAAADGxhc3RfaW5jb21lXwUAAAALc3RyQXNzZXRJZEEFAAAADWFtb3VudEVucm9sbEEJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgIAAAAMbGFzdF9pbmNvbWVfBQAAAAtzdHJBc3NldElkQgUAAAANYW1vdW50RW5yb2xsQgUAAAADbmlsAAAAAKMJbAc=", "chainId": 84, "height": 1427409, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HFjqkfFk9wzLDSfysw5LF7PnrGbxWh6DDV2U3YLSLRV9 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
23 | 23 | ||
24 | 24 | let kFeeScaleDelimiter = "commission_scale_delimiter" | |
25 | 25 | ||
26 | - | let kFeeGovernance = "commission_governance" | |
27 | - | ||
28 | 26 | let kInvariant = "invariant" | |
29 | 27 | ||
30 | 28 | let kCause = "shutdown_cause" | |
37 | 35 | ||
38 | 36 | let admStartStop = base58'7FhFLst7Htn4uYxGH7xYMTAmbydLVoiZef3eFghi7CG4' | |
39 | 37 | ||
40 | - | let | |
38 | + | let admStaking = base58'7FhFLst7Htn4uYxGH7xYMTAmbydLVoiZef3eFghi7CG4' | |
41 | 39 | ||
42 | 40 | let govAddr = Address(base58'3MqhxbxHEMtp2Rwy1gUb6cPSJHQepdap1Yp') | |
43 | 41 | ||
93 | 91 | ||
94 | 92 | let feeGovernance = 200 | |
95 | 93 | ||
96 | - | let | |
94 | + | let feeScale6 = 1000000 | |
97 | 95 | ||
98 | - | let | |
96 | + | let scale3 = 1000 | |
99 | 97 | ||
100 | - | let | |
98 | + | let scale8 = 100000000 | |
101 | 99 | ||
102 | - | let | |
100 | + | let scale12 = 1000000000000 | |
103 | 101 | ||
104 | - | let | |
102 | + | let slippageScale3 = 1000 | |
105 | 103 | ||
106 | - | let scaleValue8Digits = 8 | |
107 | - | ||
108 | - | let scaleValue12Digits = 12 | |
104 | + | let digits8 = 8 | |
109 | 105 | ||
110 | 106 | let dAppThreshold = 50 | |
111 | 107 | ||
112 | - | let dAppThresholdDelimiter = 100 | |
113 | - | ||
114 | - | let ratioThresholdMax = 100000000 | |
115 | - | ||
116 | - | let ratioThresholdMin = 99999000 | |
108 | + | let dAppThresholdScale2 = 100 | |
117 | 109 | ||
118 | 110 | let exchangeRatioLimitMin = 90000000 | |
119 | 111 | ||
124 | 116 | let alphaDigits = 2 | |
125 | 117 | ||
126 | 118 | let beta = 46000000 | |
127 | - | ||
128 | - | let betaDigits = 8 | |
129 | 119 | ||
130 | 120 | func accountBalance (assetId) = match assetId { | |
131 | 121 | case id: ByteVector => | |
166 | 156 | then (accountBalanceWithStakedB >= balanceB) | |
167 | 157 | else false | |
168 | 158 | ||
169 | - | func skewness (x,y) = (((fraction( | |
159 | + | func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000) | |
170 | 160 | ||
171 | 161 | ||
172 | 162 | func invariantCalc (x,y) = { | |
173 | 163 | let sk = skewness(x, y) | |
174 | - | (fraction((x + y), | |
164 | + | (fraction((x + y), scale8, pow(sk, digits8, alpha, alphaDigits, digits8, UP)) + (2 * fraction(pow(fraction(x, y, scale8), 0, 5, 1, (digits8 / 2), DOWN), pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN), scale8))) | |
175 | 165 | } | |
176 | 166 | ||
177 | 167 | ||
178 | - | func calculateHowManySendA (amountToSendEstimated,minTokenReceiveAmount,amountA,amountB,tokenReceiveAmount) = { | |
179 | - | let slippageValue = (scaleValue8 - ((scaleValue8 * 1) / 10000000)) | |
180 | - | let deltaMaxAndMinSendValue = (amountToSendEstimated - minTokenReceiveAmount) | |
181 | - | let amountToSendStep1 = (amountToSendEstimated - ((1 * deltaMaxAndMinSendValue) / 5)) | |
182 | - | let amountToSendStep2 = (amountToSendEstimated - ((2 * deltaMaxAndMinSendValue) / 5)) | |
183 | - | let amountToSendStep3 = (amountToSendEstimated - ((3 * deltaMaxAndMinSendValue) / 5)) | |
184 | - | let amountToSendStep4 = (amountToSendEstimated - ((4 * deltaMaxAndMinSendValue) / 5)) | |
185 | - | let amountToSendStep5 = (amountToSendEstimated - ((5 * deltaMaxAndMinSendValue) / 5)) | |
186 | - | let y = (amountB + tokenReceiveAmount) | |
187 | - | let invariantNew = invariantCalc((amountA - amountToSendEstimated), y) | |
188 | - | let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantNew) | |
189 | - | if ((0 >= (invariantCalc((amountA - amountToSendStep5), y) - invariant))) | |
190 | - | then throw("err1") | |
168 | + | func calculateSendAmount (amountToSendEstimated,minTokenReceiveAmount,tokenReceiveAmount,tokenId) = { | |
169 | + | let slippageValue = (scale8 - ((scale8 * 1) / 10000000)) | |
170 | + | let deltaBetweenMaxAndMinSendValue = (amountToSendEstimated - minTokenReceiveAmount) | |
171 | + | let x = (balanceA + tokenReceiveAmount) | |
172 | + | let y = (balanceB + tokenReceiveAmount) | |
173 | + | let invariantNew = if ((tokenId == assetIdA)) | |
174 | + | then invariantCalc(x, (balanceB - amountToSendEstimated)) | |
175 | + | else if ((tokenId == assetIdB)) | |
176 | + | then invariantCalc((balanceA - amountToSendEstimated), y) | |
177 | + | else throw("Wrong asset in payment") | |
178 | + | let invariantEstimatedRatio = fraction(scale8, invariant, invariantNew) | |
179 | + | func getStepAmount (acc,step) = if (true) | |
180 | + | then throw(((toString(acc) + " ") + toString(step))) | |
181 | + | else { | |
182 | + | let amountToSend = (amountToSendEstimated - ((step * deltaBetweenMaxAndMinSendValue) / 5)) | |
183 | + | let stepInvariant = if ((tokenId == assetIdA)) | |
184 | + | then invariantCalc(x, (balanceB - amountToSend)) | |
185 | + | else invariantCalc((balanceA - amountToSend), y) | |
186 | + | if (true) | |
187 | + | then amountToSend | |
188 | + | else acc | |
189 | + | } | |
190 | + | ||
191 | + | let stepAmount = { | |
192 | + | let $list58655908 = [1, 2, 3, 4, 5] | |
193 | + | let $size58655908 = size($list58655908) | |
194 | + | let $acc058655908 = -1 | |
195 | + | if (($size58655908 == 0)) | |
196 | + | then $acc058655908 | |
197 | + | else { | |
198 | + | let $acc158655908 = getStepAmount($acc058655908, $list58655908[0]) | |
199 | + | if (($size58655908 == 1)) | |
200 | + | then $acc158655908 | |
201 | + | else { | |
202 | + | let $acc258655908 = getStepAmount($acc158655908, $list58655908[1]) | |
203 | + | if (($size58655908 == 2)) | |
204 | + | then $acc258655908 | |
205 | + | else { | |
206 | + | let $acc358655908 = getStepAmount($acc258655908, $list58655908[2]) | |
207 | + | if (($size58655908 == 3)) | |
208 | + | then $acc358655908 | |
209 | + | else { | |
210 | + | let $acc458655908 = getStepAmount($acc358655908, $list58655908[3]) | |
211 | + | if (($size58655908 == 4)) | |
212 | + | then $acc458655908 | |
213 | + | else { | |
214 | + | let $acc558655908 = getStepAmount($acc458655908, $list58655908[4]) | |
215 | + | if (($size58655908 == 5)) | |
216 | + | then $acc558655908 | |
217 | + | else { | |
218 | + | let $acc658655908 = getStepAmount($acc558655908, $list58655908[5]) | |
219 | + | throw("List size exceed 5") | |
220 | + | } | |
221 | + | } | |
222 | + | } | |
223 | + | } | |
224 | + | } | |
225 | + | } | |
226 | + | } | |
227 | + | if ((0 > stepAmount)) | |
228 | + | then throw("something went wrong while working with amountToSend") | |
191 | 229 | else if (if ((invariantEstimatedRatio > slippageValue)) | |
192 | - | then ( | |
230 | + | then (invariantNew > invariant) | |
193 | 231 | else false) | |
194 | 232 | then amountToSendEstimated | |
195 | - | else if (((invariantCalc((amountA - amountToSendStep1), y) - invariant) > 0)) | |
196 | - | then ((amountToSendStep1 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
197 | - | else if (((invariantCalc((amountA - amountToSendStep2), y) - invariant) > 0)) | |
198 | - | then ((amountToSendStep2 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
199 | - | else if (((invariantCalc((amountA - amountToSendStep3), y) - invariant) > 0)) | |
200 | - | then ((amountToSendStep3 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
201 | - | else if (((invariantCalc((amountA - amountToSendStep4), y) - invariant) > 0)) | |
202 | - | then ((amountToSendStep4 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
203 | - | else if (((invariantCalc((amountA - amountToSendStep5), y) - invariant) > 0)) | |
204 | - | then ((amountToSendStep5 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
205 | - | else throw("err2") | |
206 | - | } | |
207 | - | ||
208 | - | ||
209 | - | func calculateHowManySendB (amountToSendEstimated,minTokenReceiveAmount,amountA,amountB,tokenReceiveAmount) = { | |
210 | - | let slippageValue = (scaleValue8 - ((scaleValue8 * 1) / 10000000)) | |
211 | - | let deltaMaxAndMinSendValue = (amountToSendEstimated - minTokenReceiveAmount) | |
212 | - | let amountToSendStep1 = (amountToSendEstimated - ((1 * deltaMaxAndMinSendValue) / 5)) | |
213 | - | let amountToSendStep2 = (amountToSendEstimated - ((2 * deltaMaxAndMinSendValue) / 5)) | |
214 | - | let amountToSendStep3 = (amountToSendEstimated - ((3 * deltaMaxAndMinSendValue) / 5)) | |
215 | - | let amountToSendStep4 = (amountToSendEstimated - ((4 * deltaMaxAndMinSendValue) / 5)) | |
216 | - | let amountToSendStep5 = (amountToSendEstimated - ((5 * deltaMaxAndMinSendValue) / 5)) | |
217 | - | let x = (amountA + tokenReceiveAmount) | |
218 | - | let invariantNew = invariantCalc(x, (amountB - amountToSendEstimated)) | |
219 | - | let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantNew) | |
220 | - | if ((0 >= (invariantCalc(x, (amountB - amountToSendStep5)) - invariant))) | |
221 | - | then throw("err1") | |
222 | - | else if (if ((invariantEstimatedRatio > slippageValue)) | |
223 | - | then ((invariantNew - invariant) > 0) | |
224 | - | else false) | |
225 | - | then amountToSendEstimated | |
226 | - | else if (((invariantCalc(x, (amountB - amountToSendStep1)) - invariant) > 0)) | |
227 | - | then ((amountToSendStep1 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
228 | - | else if (((invariantCalc(x, (amountB - amountToSendStep2)) - invariant) > 0)) | |
229 | - | then ((amountToSendStep2 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
230 | - | else if (((invariantCalc(x, (amountB - amountToSendStep3)) - invariant) > 0)) | |
231 | - | then ((amountToSendStep3 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
232 | - | else if (((invariantCalc(x, (amountB - amountToSendStep4)) - invariant) > 0)) | |
233 | - | then ((amountToSendStep4 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
234 | - | else if (((invariantCalc(x, (amountB - amountToSendStep5)) - invariant) > 0)) | |
235 | - | then ((amountToSendStep5 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
236 | - | else throw("err2") | |
233 | + | else ((stepAmount * (feeScale6 - fee)) / feeScale6) | |
237 | 234 | } | |
238 | 235 | ||
239 | 236 | ||
288 | 285 | ||
289 | 286 | @Callable(i) | |
290 | 287 | func init () = { | |
291 | - | let $ | |
292 | - | let pmtAmountA = $ | |
293 | - | let pmtAssetIdA = $ | |
294 | - | let $ | |
295 | - | let pmtAmountB = $ | |
296 | - | let pmtAssetIdB = $ | |
297 | - | let $ | |
298 | - | let pmtStrAssetIdA = $ | |
299 | - | let pmtAssetNameA = $ | |
300 | - | let pmtDecimalsA = $ | |
301 | - | let $ | |
302 | - | let pmtStrAssetIdB = $ | |
303 | - | let pmtAssetNameB = $ | |
304 | - | let pmtDecimalsB = $ | |
288 | + | let $t086198696 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
289 | + | let pmtAmountA = $t086198696._1 | |
290 | + | let pmtAssetIdA = $t086198696._2 | |
291 | + | let $t087018778 = $Tuple2(i.payments[1].amount, i.payments[1].assetId) | |
292 | + | let pmtAmountB = $t087018778._1 | |
293 | + | let pmtAssetIdB = $t087018778._2 | |
294 | + | let $t087838860 = getAssetInfo(pmtAssetIdA) | |
295 | + | let pmtStrAssetIdA = $t087838860._1 | |
296 | + | let pmtAssetNameA = $t087838860._2 | |
297 | + | let pmtDecimalsA = $t087838860._3 | |
298 | + | let $t088658942 = getAssetInfo(pmtAssetIdB) | |
299 | + | let pmtStrAssetIdB = $t088658942._1 | |
300 | + | let pmtAssetNameB = $t088658942._2 | |
301 | + | let pmtDecimalsB = $t088658942._3 | |
305 | 302 | if (isDefined(getBoolean(this, kActive))) | |
306 | 303 | then throwIsActive() | |
307 | 304 | else if ((pmtAssetIdA == pmtAssetIdB)) | |
314 | 311 | let shareIssue = Issue(shareName, shareDescription, shareInitialSupply, shareDecimals, true) | |
315 | 312 | let shareIssueId = calculateAssetId(shareIssue) | |
316 | 313 | let invariantCalculated = invariantCalc(pmtAmountA, pmtAmountB) | |
317 | - | [StringEntry(kVersion, version), BooleanEntry(kActive, true), StringEntry(kAssetIdA, pmtStrAssetIdA), StringEntry(kAssetIdB, pmtStrAssetIdB), IntegerEntry(kBalanceA, pmtAmountA), IntegerEntry(kBalanceB, pmtAmountB), IntegerEntry(kInvariant, invariantCalculated), IntegerEntry(kFee, fee), IntegerEntry(kFeeScaleDelimiter, | |
314 | + | [StringEntry(kVersion, version), BooleanEntry(kActive, true), StringEntry(kAssetIdA, pmtStrAssetIdA), StringEntry(kAssetIdB, pmtStrAssetIdB), IntegerEntry(kBalanceA, pmtAmountA), IntegerEntry(kBalanceB, pmtAmountB), IntegerEntry(kInvariant, invariantCalculated), IntegerEntry(kFee, fee), IntegerEntry(kFeeScaleDelimiter, feeScale6), shareIssue, StringEntry(kShareAssetId, toBase58String(shareIssueId)), IntegerEntry(kShareAssetSupply, shareInitialSupply), ScriptTransfer(i.caller, shareInitialSupply, shareIssueId)] | |
318 | 315 | } | |
319 | 316 | } | |
320 | 317 | ||
321 | 318 | ||
322 | 319 | ||
323 | 320 | @Callable(i) | |
324 | - | func replenishWithTwoTokens (slippageTolerance) = if ((slippageTolerance > 10)) | |
325 | - | then throw("slippage tolerance must be <= 1%") | |
326 | - | else { | |
327 | - | let pmtAssetIdA = i.payments[0].assetId | |
328 | - | let pmtAssetIdB = i.payments[1].assetId | |
329 | - | let pmtAmountA = deductStakingFee(i.payments[0].amount, pmtAssetIdA) | |
330 | - | let pmtAmountB = deductStakingFee(i.payments[1].amount, pmtAssetIdB) | |
331 | - | let tokenRatio = fraction(fraction(balanceA, scaleValue8, pmtAmountA), scaleValue3, fraction(balanceB, scaleValue8, pmtAmountB)) | |
332 | - | let ratioShareTokensInA = fraction(pmtAmountA, scaleValue8, balanceA) | |
333 | - | let ratioShareTokensInB = fraction(pmtAmountB, scaleValue8, balanceB) | |
334 | - | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
335 | - | let invariantCalculated = invariantCalc((balanceA + pmtAmountA), (balanceB + pmtAmountB)) | |
336 | - | if (!(isActive)) | |
337 | - | then throwIsInactive() | |
338 | - | else if (if ((0 > slippageTolerance)) | |
339 | - | then true | |
340 | - | else (slippageTolerance > slippageToleranceDelimiter)) | |
341 | - | then throw(((("Slippage tolerance must be between 0 and " + toString(slippageToleranceDelimiter)) + " inclusively. Actual: ") + toString(slippageTolerance))) | |
342 | - | else if ((size(i.payments) != 2)) | |
343 | - | then throw("Two attached assets expected") | |
344 | - | else if (if ((pmtAssetIdA != assetIdA)) | |
321 | + | func replenishWithTwoTokens (slippageTolerance) = { | |
322 | + | let pmtAssetIdA = i.payments[0].assetId | |
323 | + | let pmtAssetIdB = i.payments[1].assetId | |
324 | + | let pmtAmountA = deductStakingFee(i.payments[0].amount, pmtAssetIdA) | |
325 | + | let pmtAmountB = deductStakingFee(i.payments[1].amount, pmtAssetIdB) | |
326 | + | let tokenRatio = fraction(fraction(scale8, balanceA, pmtAmountA), scale3, fraction(scale8, balanceB, pmtAmountB)) | |
327 | + | let ratioShareTokensInA = fraction(scale8, pmtAmountA, balanceA) | |
328 | + | let ratioShareTokensInB = fraction(scale8, pmtAmountB, balanceB) | |
329 | + | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scale8) | |
330 | + | let invariantCalculated = invariantCalc((balanceA + pmtAmountA), (balanceB + pmtAmountB)) | |
331 | + | if (!(isActive)) | |
332 | + | then throwIsInactive() | |
333 | + | else if (if ((0 > slippageTolerance)) | |
334 | + | then true | |
335 | + | else (slippageTolerance > 10)) | |
336 | + | then throw("Slippage tolerance must be <= 1%") | |
337 | + | else if ((size(i.payments) != 2)) | |
338 | + | then throw("Two attached assets expected") | |
339 | + | else if (if ((pmtAssetIdA != assetIdA)) | |
340 | + | then true | |
341 | + | else (pmtAssetIdB != assetIdB)) | |
342 | + | then throwAssets() | |
343 | + | else if (if ((((scale3 * (slippageScale3 - slippageTolerance)) / slippageScale3) > tokenRatio)) | |
345 | 344 | then true | |
346 | - | else (pmtAssetIdB != assetIdB)) | |
347 | - | then throwAssets() | |
348 | - | else if (if ((((scaleValue3 * (slippageToleranceDelimiter - slippageTolerance)) / slippageToleranceDelimiter) > tokenRatio)) | |
349 | - | then true | |
350 | - | else (tokenRatio > ((scaleValue3 * (slippageToleranceDelimiter + slippageTolerance)) / slippageToleranceDelimiter))) | |
351 | - | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
352 | - | else if ((shareTokenToPayAmount == 0)) | |
353 | - | then throw("Too small amount to replenish") | |
354 | - | else if (!(hasEnoughBalance)) | |
355 | - | then suspendSuspicious() | |
356 | - | else [IntegerEntry(kBalanceA, (balanceA + pmtAmountA)), IntegerEntry(kBalanceB, (balanceB + pmtAmountB)), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), IntegerEntry(kInvariant, invariantCalculated), Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId)] | |
357 | - | } | |
345 | + | else (tokenRatio > ((scale3 * (slippageScale3 + slippageTolerance)) / slippageScale3))) | |
346 | + | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
347 | + | else if ((shareTokenToPayAmount == 0)) | |
348 | + | then throw("Too small amount to replenish") | |
349 | + | else if (!(hasEnoughBalance)) | |
350 | + | then suspendSuspicious() | |
351 | + | else [IntegerEntry(kBalanceA, (balanceA + pmtAmountA)), IntegerEntry(kBalanceB, (balanceB + pmtAmountB)), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), IntegerEntry(kInvariant, invariantCalculated), Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId)] | |
352 | + | } | |
358 | 353 | ||
359 | 354 | ||
360 | 355 | ||
361 | 356 | @Callable(i) | |
362 | 357 | func replenishWithOneToken (virtualSwapTokenPay,virtualSwapTokenGet) = { | |
363 | - | let $ | |
364 | - | let pmtAmount = $ | |
365 | - | let pmtAssetId = $ | |
358 | + | let $t01315713232 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
359 | + | let pmtAmount = $t01315713232._1 | |
360 | + | let pmtAssetId = $t01315713232._2 | |
366 | 361 | let pmtMinThreshold = 5000000 | |
367 | 362 | let thresholdValueForMinTolerance = 50000000 | |
368 | 363 | let tolerance = if ((thresholdValueForMinTolerance > pmtAmount)) | |
369 | 364 | then 100000 | |
370 | 365 | else 1 | |
371 | - | let slippageValueMinForReplenish = ( | |
372 | - | let slippageValueMaxForReplenish = ( | |
373 | - | let slippageValueMinForSwap = ( | |
374 | - | let slippageValueMaxForSwap = ( | |
366 | + | let slippageValueMinForReplenish = (scale8 - ((scale8 * tolerance) / 10000000)) | |
367 | + | let slippageValueMaxForReplenish = (scale8 + ((scale8 * tolerance) / 10000000)) | |
368 | + | let slippageValueMinForSwap = (scale8 - ((scale8 * 1) / 10000000)) | |
369 | + | let slippageValueMaxForSwap = (scale8 + ((scale8 * 1) / 10000000)) | |
375 | 370 | if (!(isActive)) | |
376 | 371 | then throwIsInactive() | |
377 | 372 | else if ((pmtMinThreshold > pmtAmount)) | |
380 | 375 | then throw("One attached payment expected") | |
381 | 376 | else if (!(hasEnoughBalance)) | |
382 | 377 | then suspendSuspicious() | |
383 | - | else if ((pmtAssetId == assetIdA)) | |
384 | - | then { | |
385 | - | let virtReplA = (pmtAmount - virtualSwapTokenPay) | |
386 | - | let virtReplB = virtualSwapTokenGet | |
387 | - | let balanceAfterSwapA = (balanceA + virtualSwapTokenPay) | |
388 | - | let balanceAfterSwapB = (balanceB - virtualSwapTokenGet) | |
378 | + | else if (if ((pmtAssetId != assetIdA)) | |
379 | + | then (pmtAssetId != assetIdB) | |
380 | + | else false) | |
381 | + | then throwAssets() | |
382 | + | else { | |
383 | + | let $t01423414999 = if ((pmtAssetId == assetIdA)) | |
384 | + | then $Tuple7((pmtAmount - virtualSwapTokenPay), virtualSwapTokenGet, (balanceA + virtualSwapTokenPay), (balanceB - virtualSwapTokenGet), invariantCalc((balanceA + pmtAmount), balanceB), (balanceA + pmtAmount), balanceB) | |
385 | + | else $Tuple7(virtualSwapTokenGet, (pmtAmount - virtualSwapTokenPay), (balanceA - virtualSwapTokenGet), (balanceB + virtualSwapTokenPay), invariantCalc(balanceA, (balanceB + pmtAmount)), balanceA, (balanceB + pmtAmount)) | |
386 | + | let virtualReplenishA = $t01423414999._1 | |
387 | + | let virtualReplenishB = $t01423414999._2 | |
388 | + | let balanceAfterSwapA = $t01423414999._3 | |
389 | + | let balanceAfterSwapB = $t01423414999._4 | |
390 | + | let invariantCalculated = $t01423414999._5 | |
391 | + | let newBalanceA = $t01423414999._6 | |
392 | + | let newBalanceB = $t01423414999._7 | |
393 | + | let newBalanceEntry = if ((pmtAssetId == assetIdA)) | |
394 | + | then IntegerEntry(kBalanceA, newBalanceA) | |
395 | + | else IntegerEntry(kBalanceB, newBalanceB) | |
389 | 396 | let invariantNew = invariantCalc(balanceAfterSwapA, balanceAfterSwapB) | |
390 | - | let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantNew) | |
391 | - | if (if ((invariantEstimatedRatio > slippageValueMinForSwap)) | |
392 | - | then ((invariantNew - invariant) >= 0) | |
393 | - | else false) | |
394 | - | then { | |
395 | - | let ratioVirtualBalanceToVirtualReplenish = (fraction(balanceAfterSwapA, (scaleValue8 * scaleValue8), balanceAfterSwapB) / fraction(virtReplA, scaleValue8, virtReplB)) | |
396 | - | if (if ((slippageValueMinForReplenish > ratioVirtualBalanceToVirtualReplenish)) | |
397 | + | let invariantEstimatedRatio = fraction(scale8, invariant, invariantNew) | |
398 | + | let ratioVirtualBalanceToVirtualReplenish = (fraction((scale8 * scale8), balanceAfterSwapA, balanceAfterSwapB) / fraction(scale8, virtualReplenishA, virtualReplenishB)) | |
399 | + | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdScale2)) | |
400 | + | if (if ((slippageValueMinForSwap >= invariantEstimatedRatio)) | |
401 | + | then true | |
402 | + | else (invariant > invariantNew)) | |
403 | + | then throw("Incorrect virtualSwapTokenPay or virtualSwapTokenGet value") | |
404 | + | else if (if ((slippageValueMinForReplenish > ratioVirtualBalanceToVirtualReplenish)) | |
405 | + | then true | |
406 | + | else (ratioVirtualBalanceToVirtualReplenish > slippageValueMaxForReplenish)) | |
407 | + | then throw("Swap with virtualSwapTokenPay and virtualSwapTokenGet is possible, but ratio after virtual swap is incorrect") | |
408 | + | else if (if ((dAppThresholdAmount > newBalanceA)) | |
397 | 409 | then true | |
398 | - | else ( | |
399 | - | then | |
410 | + | else (dAppThresholdAmount > newBalanceB)) | |
411 | + | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
400 | 412 | else { | |
401 | - | let ratioShareTokensInA = fraction(deductStakingFee(virtReplA, assetIdA), scaleValue8, balanceAfterSwapA) | |
402 | - | let ratioShareTokensInB = fraction(deductStakingFee(virtReplB, assetIdB), scaleValue8, balanceAfterSwapB) | |
403 | - | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
404 | - | let invariantCalculated = invariantCalc((balanceA + pmtAmount), balanceB) | |
405 | - | let newBalanceA = (balanceA + pmtAmount) | |
406 | - | let newBalanceB = balanceB | |
407 | - | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdDelimiter)) | |
408 | - | if (if ((dAppThresholdAmount > newBalanceA)) | |
409 | - | then true | |
410 | - | else (dAppThresholdAmount > newBalanceB)) | |
411 | - | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
412 | - | else [Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), IntegerEntry(kBalanceA, newBalanceA), IntegerEntry(kInvariant, invariantCalculated)] | |
413 | + | let ratioShareTokensInA = fraction(deductStakingFee(virtualReplenishA, assetIdA), scale8, balanceAfterSwapA) | |
414 | + | let ratioShareTokensInB = fraction(deductStakingFee(virtualReplenishB, assetIdB), scale8, balanceAfterSwapB) | |
415 | + | if (true) | |
416 | + | then throw(toString(value(value(assetInfo(USDN)).minSponsoredFee))) | |
417 | + | else { | |
418 | + | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scale8) | |
419 | + | if (true) | |
420 | + | then throw(toString(shareTokenToPayAmount)) | |
421 | + | else [Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), newBalanceEntry, IntegerEntry(kInvariant, invariantCalculated)] | |
422 | + | } | |
413 | 423 | } | |
414 | - | } | |
415 | - | else throw("Incorrect virtualSwapTokenPay or virtualSwapTokenGet value") | |
416 | 424 | } | |
417 | - | else if ((pmtAssetId == assetIdB)) | |
418 | - | then { | |
419 | - | let virtReplB = (pmtAmount - virtualSwapTokenPay) | |
420 | - | let virtReplA = virtualSwapTokenGet | |
421 | - | let balanceAfterSwapA = (balanceA - virtualSwapTokenGet) | |
422 | - | let balanceAfterSwapB = (balanceB + virtualSwapTokenPay) | |
423 | - | let invariantNew = invariantCalc(balanceAfterSwapA, balanceAfterSwapB) | |
424 | - | let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantNew) | |
425 | - | if (if ((invariantEstimatedRatio > slippageValueMinForSwap)) | |
426 | - | then ((invariantNew - invariant) >= 0) | |
427 | - | else false) | |
428 | - | then { | |
429 | - | let ratioVirtualBalanceToVirtualReplenish = (fraction(balanceAfterSwapA, (scaleValue8 * scaleValue8), balanceAfterSwapB) / fraction(virtReplA, scaleValue8, virtReplB)) | |
430 | - | if (if ((slippageValueMinForReplenish > ratioVirtualBalanceToVirtualReplenish)) | |
431 | - | then true | |
432 | - | else (ratioVirtualBalanceToVirtualReplenish > slippageValueMaxForReplenish)) | |
433 | - | then throw("Ratio after virtual swap incorrect") | |
434 | - | else { | |
435 | - | let ratioShareTokensInA = fraction(deductStakingFee(virtReplA, assetIdA), scaleValue8, balanceAfterSwapA) | |
436 | - | let ratioShareTokensInB = fraction(deductStakingFee(virtReplB, assetIdB), scaleValue8, balanceAfterSwapB) | |
437 | - | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
438 | - | let invariantCalculated = invariantCalc(balanceA, (balanceB + pmtAmount)) | |
439 | - | let newBalanceA = balanceA | |
440 | - | let newBalanceB = (balanceB + pmtAmount) | |
441 | - | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdDelimiter)) | |
442 | - | if (if ((dAppThresholdAmount > newBalanceA)) | |
443 | - | then true | |
444 | - | else (dAppThresholdAmount > newBalanceB)) | |
445 | - | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
446 | - | else [Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), IntegerEntry(kBalanceB, newBalanceB), IntegerEntry(kInvariant, invariantCalculated)] | |
447 | - | } | |
448 | - | } | |
449 | - | else throw("Incorrect virtualSwapTokenPay or virtualSwapTokenGet value") | |
450 | - | } | |
451 | - | else throwAssets() | |
452 | 425 | } | |
453 | 426 | ||
454 | 427 | ||
455 | 428 | ||
456 | 429 | @Callable(i) | |
457 | 430 | func withdraw () = { | |
458 | - | let $ | |
459 | - | let pmtAmount = $ | |
460 | - | let pmtAssetId = $ | |
431 | + | let $t01770817851 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
432 | + | let pmtAmount = $t01770817851._1 | |
433 | + | let pmtAssetId = $t01770817851._2 | |
461 | 434 | let amountToPayA = deductStakingFee(fraction(pmtAmount, balanceA, shareAssetSupply), assetIdA) | |
462 | 435 | let amountToPayB = deductStakingFee(fraction(pmtAmount, balanceB, shareAssetSupply), assetIdB) | |
463 | 436 | let invariantCalculated = invariantCalc((balanceA - amountToPayA), (balanceB - amountToPayB)) | |
480 | 453 | ||
481 | 454 | @Callable(i) | |
482 | 455 | func exchange (estimatedAmountToReceive,minAmountToReceive) = { | |
483 | - | let $ | |
484 | - | let pmtAmount = $ | |
485 | - | let pmtAssetId = $ | |
486 | - | if ( | |
487 | - | then | |
488 | - | else ( | |
489 | - | then throw(" | |
490 | - | else if ( | |
491 | - | then | |
492 | - | else if (( | |
493 | - | then throw( | |
494 | - | else if (( | |
495 | - | then | |
496 | - | else if (( | |
497 | - | then | |
498 | - | else | |
499 | - | then | |
456 | + | let $t01913419209 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
457 | + | let pmtAmount = $t01913419209._1 | |
458 | + | let pmtAssetId = $t01913419209._2 | |
459 | + | if (!(isActive)) | |
460 | + | then throwIsInactive() | |
461 | + | else if ((0 >= estimatedAmountToReceive)) | |
462 | + | then throw(("Estimated amount must be positive. Actual: " + toString(estimatedAmountToReceive))) | |
463 | + | else if ((minAmountToReceive > estimatedAmountToReceive)) | |
464 | + | then throw(((("Minimal amount can't be greater than estimated. Estimated: " + toString(estimatedAmountToReceive)) + ". Minimal: ") + toString(minAmountToReceive))) | |
465 | + | else if ((size(i.payments) != 1)) | |
466 | + | then throw("One attached payment expected") | |
467 | + | else if (!(hasEnoughBalance)) | |
468 | + | then suspendSuspicious() | |
469 | + | else if (if ((pmtAssetId != assetIdA)) | |
470 | + | then (pmtAssetId != assetIdB) | |
471 | + | else false) | |
472 | + | then throwAssets() | |
500 | 473 | else if ((10000000 > pmtAmount)) | |
501 | 474 | then throw("Only swap of 10.000000 or more tokens is allowed") | |
502 | - | else if ((pmtAssetId == assetIdA)) | |
503 | - | then { | |
504 | - | let assetIdSend = assetIdB | |
505 | - | let amountWithoutFee = calculateHowManySendB(estimatedAmountToReceive, minAmountToReceive, balanceA, balanceB, pmtAmount) | |
506 | - | let amountWithFee = fraction(amountWithoutFee, (feeScaleDelimiter - fee), feeScaleDelimiter) | |
507 | - | let governanceReward = fraction(amountWithoutFee, feeGovernance, feeScaleDelimiter) | |
508 | - | let newBalanceA = (balanceA + pmtAmount) | |
509 | - | let newBalanceB = ((balanceB - amountWithFee) - governanceReward) | |
510 | - | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdDelimiter)) | |
475 | + | else if (if ((exchangeRatioLimitMin > fraction(scale8, minAmountToReceive, pmtAmount))) | |
476 | + | then true | |
477 | + | else (fraction(scale8, estimatedAmountToReceive, pmtAmount) > exchangeRatioLimitMax)) | |
478 | + | then throw("Incorrect args and pmt ratio") | |
479 | + | else { | |
480 | + | let sendAssetId = if ((pmtAssetId == assetIdA)) | |
481 | + | then assetIdB | |
482 | + | else assetIdA | |
483 | + | let amountWithoutFee = calculateSendAmount(estimatedAmountToReceive, minAmountToReceive, pmtAmount, pmtAssetId) | |
484 | + | let amountWithFee = fraction(amountWithoutFee, (feeScale6 - fee), feeScale6) | |
485 | + | let governanceReward = fraction(amountWithoutFee, feeGovernance, feeScale6) | |
486 | + | let $t02058920850 = if ((pmtAssetId == assetIdA)) | |
487 | + | then $Tuple2((balanceA + pmtAmount), ((balanceB - amountWithFee) - governanceReward)) | |
488 | + | else $Tuple2(((balanceA - amountWithFee) - governanceReward), (balanceB + pmtAmount)) | |
489 | + | let newBalanceA = $t02058920850._1 | |
490 | + | let newBalanceB = $t02058920850._2 | |
491 | + | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdScale2)) | |
511 | 492 | if (if ((dAppThresholdAmount > newBalanceA)) | |
512 | 493 | then true | |
513 | 494 | else (dAppThresholdAmount > newBalanceB)) | |
514 | 495 | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
515 | 496 | else if (if (if ((assetIdA == USDN)) | |
497 | + | then (sendAssetId == assetIdA) | |
498 | + | else false) | |
516 | 499 | then (stakedAmountUSDN >= newBalanceA) | |
517 | 500 | else false) | |
518 | - | then true | |
519 | - | else if ((assetIdB == USDN)) | |
501 | + | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceA, assetNameA) | |
502 | + | else if (if (if ((assetIdB == USDN)) | |
503 | + | then (sendAssetId == assetIdB) | |
504 | + | else false) | |
520 | 505 | then (stakedAmountUSDN >= newBalanceB) | |
521 | 506 | else false) | |
522 | - | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceB, assetNameB) | |
523 | - | else [IntegerEntry(kBalanceA, newBalanceA), IntegerEntry(kBalanceB, newBalanceB), IntegerEntry(kInvariant, invariantCalc( | |
507 | + | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceB, assetNameB) | |
508 | + | else [IntegerEntry(kBalanceA, newBalanceA), IntegerEntry(kBalanceB, newBalanceB), IntegerEntry(kInvariant, invariantCalc(newBalanceA, newBalanceB)), ScriptTransfer(i.caller, amountWithFee, sendAssetId), ScriptTransfer(govAddr, governanceReward, sendAssetId)] | |
524 | 509 | } | |
525 | - | else if ((pmtAssetId == assetIdB)) | |
526 | - | then { | |
527 | - | let assetIdSend = assetIdA | |
528 | - | let amountWithoutFee = calculateHowManySendA(estimatedAmountToReceive, minAmountToReceive, balanceA, balanceB, pmtAmount) | |
529 | - | let amountWithFee = fraction(amountWithoutFee, (feeScaleDelimiter - fee), feeScaleDelimiter) | |
530 | - | let governanceReward = fraction(amountWithoutFee, feeGovernance, feeScaleDelimiter) | |
531 | - | let newBalanceA = ((balanceA - amountWithFee) - governanceReward) | |
532 | - | let newBalanceB = (balanceB + pmtAmount) | |
533 | - | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdDelimiter)) | |
534 | - | if (if ((dAppThresholdAmount > newBalanceA)) | |
535 | - | then true | |
536 | - | else (dAppThresholdAmount > newBalanceB)) | |
537 | - | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
538 | - | else if (if (if ((assetIdA == USDN)) | |
539 | - | then (stakedAmountUSDN >= newBalanceA) | |
540 | - | else false) | |
541 | - | then true | |
542 | - | else if ((assetIdB == USDN)) | |
543 | - | then (stakedAmountUSDN >= newBalanceB) | |
544 | - | else false) | |
545 | - | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceA, assetNameA) | |
546 | - | else [IntegerEntry(kBalanceA, newBalanceA), IntegerEntry(kBalanceB, newBalanceB), IntegerEntry(kInvariant, invariantCalc(((balanceA - amountWithFee) - governanceReward), (balanceB + pmtAmount))), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(govAddr, governanceReward, assetIdSend)] | |
547 | - | } | |
548 | - | else throwAssets() | |
549 | 510 | } | |
550 | 511 | ||
551 | 512 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let version = "2.0.0" | |
5 | 5 | ||
6 | 6 | let kVersion = "version" | |
7 | 7 | ||
8 | 8 | let kActive = "active" | |
9 | 9 | ||
10 | 10 | let kAssetIdA = "A_asset_id" | |
11 | 11 | ||
12 | 12 | let kAssetIdB = "B_asset_id" | |
13 | 13 | ||
14 | 14 | let kBalanceA = "A_asset_balance" | |
15 | 15 | ||
16 | 16 | let kBalanceB = "B_asset_balance" | |
17 | 17 | ||
18 | 18 | let kShareAssetId = "share_asset_id" | |
19 | 19 | ||
20 | 20 | let kShareAssetSupply = "share_asset_supply" | |
21 | 21 | ||
22 | 22 | let kFee = "commission" | |
23 | 23 | ||
24 | 24 | let kFeeScaleDelimiter = "commission_scale_delimiter" | |
25 | 25 | ||
26 | - | let kFeeGovernance = "commission_governance" | |
27 | - | ||
28 | 26 | let kInvariant = "invariant" | |
29 | 27 | ||
30 | 28 | let kCause = "shutdown_cause" | |
31 | 29 | ||
32 | 30 | let adm1 = base58'7FhFLst7Htn4uYxGH7xYMTAmbydLVoiZef3eFghi7CG4' | |
33 | 31 | ||
34 | 32 | let adm2 = base58'7FhFLst7Htn4uYxGH7xYMTAmbydLVoiZef3eFghi7CG4' | |
35 | 33 | ||
36 | 34 | let adm3 = base58'7FhFLst7Htn4uYxGH7xYMTAmbydLVoiZef3eFghi7CG4' | |
37 | 35 | ||
38 | 36 | let admStartStop = base58'7FhFLst7Htn4uYxGH7xYMTAmbydLVoiZef3eFghi7CG4' | |
39 | 37 | ||
40 | - | let | |
38 | + | let admStaking = base58'7FhFLst7Htn4uYxGH7xYMTAmbydLVoiZef3eFghi7CG4' | |
41 | 39 | ||
42 | 40 | let govAddr = Address(base58'3MqhxbxHEMtp2Rwy1gUb6cPSJHQepdap1Yp') | |
43 | 41 | ||
44 | 42 | let stakingAddress = Address(base58'3MqhxbxHEMtp2Rwy1gUb6cPSJHQepdap1Yp') | |
45 | 43 | ||
46 | 44 | let USDN = base58'3FUNGbzfNsQ1AZfvumCUqARXvpjjLQrvCzorYuDryQAq' | |
47 | 45 | ||
48 | 46 | let stakingFeeInUSDN = (9 * value(value(assetInfo(USDN)).minSponsoredFee)) | |
49 | 47 | ||
50 | 48 | let isActive = getBooleanValue(this, kActive) | |
51 | 49 | ||
52 | 50 | let strAssetIdA = getStringValue(this, kAssetIdA) | |
53 | 51 | ||
54 | 52 | let strAssetIdB = getStringValue(this, kAssetIdB) | |
55 | 53 | ||
56 | 54 | let assetIdA = if ((strAssetIdA == "WAVES")) | |
57 | 55 | then unit | |
58 | 56 | else fromBase58String(strAssetIdA) | |
59 | 57 | ||
60 | 58 | let assetIdB = if ((strAssetIdB == "WAVES")) | |
61 | 59 | then unit | |
62 | 60 | else fromBase58String(strAssetIdB) | |
63 | 61 | ||
64 | 62 | let assetNameA = match assetIdA { | |
65 | 63 | case id: ByteVector => | |
66 | 64 | value(assetInfo(id)).name | |
67 | 65 | case waves: Unit => | |
68 | 66 | "WAVES" | |
69 | 67 | case _ => | |
70 | 68 | throw("Match error") | |
71 | 69 | } | |
72 | 70 | ||
73 | 71 | let assetNameB = match assetIdB { | |
74 | 72 | case id: ByteVector => | |
75 | 73 | value(assetInfo(id)).name | |
76 | 74 | case waves: Unit => | |
77 | 75 | "WAVES" | |
78 | 76 | case _ => | |
79 | 77 | throw("Match error") | |
80 | 78 | } | |
81 | 79 | ||
82 | 80 | let balanceA = getIntegerValue(this, kBalanceA) | |
83 | 81 | ||
84 | 82 | let balanceB = getIntegerValue(this, kBalanceB) | |
85 | 83 | ||
86 | 84 | let shareAssetId = fromBase58String(getStringValue(this, kShareAssetId)) | |
87 | 85 | ||
88 | 86 | let shareAssetSupply = getIntegerValue(this, kShareAssetSupply) | |
89 | 87 | ||
90 | 88 | let invariant = getIntegerValue(this, kInvariant) | |
91 | 89 | ||
92 | 90 | let fee = 500 | |
93 | 91 | ||
94 | 92 | let feeGovernance = 200 | |
95 | 93 | ||
96 | - | let | |
94 | + | let feeScale6 = 1000000 | |
97 | 95 | ||
98 | - | let | |
96 | + | let scale3 = 1000 | |
99 | 97 | ||
100 | - | let | |
98 | + | let scale8 = 100000000 | |
101 | 99 | ||
102 | - | let | |
100 | + | let scale12 = 1000000000000 | |
103 | 101 | ||
104 | - | let | |
102 | + | let slippageScale3 = 1000 | |
105 | 103 | ||
106 | - | let scaleValue8Digits = 8 | |
107 | - | ||
108 | - | let scaleValue12Digits = 12 | |
104 | + | let digits8 = 8 | |
109 | 105 | ||
110 | 106 | let dAppThreshold = 50 | |
111 | 107 | ||
112 | - | let dAppThresholdDelimiter = 100 | |
113 | - | ||
114 | - | let ratioThresholdMax = 100000000 | |
115 | - | ||
116 | - | let ratioThresholdMin = 99999000 | |
108 | + | let dAppThresholdScale2 = 100 | |
117 | 109 | ||
118 | 110 | let exchangeRatioLimitMin = 90000000 | |
119 | 111 | ||
120 | 112 | let exchangeRatioLimitMax = 110000000 | |
121 | 113 | ||
122 | 114 | let alpha = 50 | |
123 | 115 | ||
124 | 116 | let alphaDigits = 2 | |
125 | 117 | ||
126 | 118 | let beta = 46000000 | |
127 | - | ||
128 | - | let betaDigits = 8 | |
129 | 119 | ||
130 | 120 | func accountBalance (assetId) = match assetId { | |
131 | 121 | case id: ByteVector => | |
132 | 122 | assetBalance(this, id) | |
133 | 123 | case waves: Unit => | |
134 | 124 | wavesBalance(this).available | |
135 | 125 | case _ => | |
136 | 126 | throw("Match error") | |
137 | 127 | } | |
138 | 128 | ||
139 | 129 | ||
140 | 130 | let stakedAmountUSDN = match getInteger(stakingAddress, ((("rpd_balance_" + toBase58String(USDN)) + "_") + toString(this))) { | |
141 | 131 | case staked: Int => | |
142 | 132 | staked | |
143 | 133 | case nothing: Unit => | |
144 | 134 | 0 | |
145 | 135 | case _ => | |
146 | 136 | throw("Match error") | |
147 | 137 | } | |
148 | 138 | ||
149 | 139 | let availableBalanceA = (balanceA - (if ((assetIdA == USDN)) | |
150 | 140 | then stakedAmountUSDN | |
151 | 141 | else 0)) | |
152 | 142 | ||
153 | 143 | let availableBalanceB = (balanceB - (if ((assetIdB == USDN)) | |
154 | 144 | then stakedAmountUSDN | |
155 | 145 | else 0)) | |
156 | 146 | ||
157 | 147 | let accountBalanceWithStakedA = (accountBalance(assetIdA) + (if ((assetIdA == USDN)) | |
158 | 148 | then stakedAmountUSDN | |
159 | 149 | else 0)) | |
160 | 150 | ||
161 | 151 | let accountBalanceWithStakedB = (accountBalance(assetIdB) + (if ((assetIdB == USDN)) | |
162 | 152 | then stakedAmountUSDN | |
163 | 153 | else 0)) | |
164 | 154 | ||
165 | 155 | let hasEnoughBalance = if ((accountBalanceWithStakedA >= balanceA)) | |
166 | 156 | then (accountBalanceWithStakedB >= balanceB) | |
167 | 157 | else false | |
168 | 158 | ||
169 | - | func skewness (x,y) = (((fraction( | |
159 | + | func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000) | |
170 | 160 | ||
171 | 161 | ||
172 | 162 | func invariantCalc (x,y) = { | |
173 | 163 | let sk = skewness(x, y) | |
174 | - | (fraction((x + y), | |
164 | + | (fraction((x + y), scale8, pow(sk, digits8, alpha, alphaDigits, digits8, UP)) + (2 * fraction(pow(fraction(x, y, scale8), 0, 5, 1, (digits8 / 2), DOWN), pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN), scale8))) | |
175 | 165 | } | |
176 | 166 | ||
177 | 167 | ||
178 | - | func calculateHowManySendA (amountToSendEstimated,minTokenReceiveAmount,amountA,amountB,tokenReceiveAmount) = { | |
179 | - | let slippageValue = (scaleValue8 - ((scaleValue8 * 1) / 10000000)) | |
180 | - | let deltaMaxAndMinSendValue = (amountToSendEstimated - minTokenReceiveAmount) | |
181 | - | let amountToSendStep1 = (amountToSendEstimated - ((1 * deltaMaxAndMinSendValue) / 5)) | |
182 | - | let amountToSendStep2 = (amountToSendEstimated - ((2 * deltaMaxAndMinSendValue) / 5)) | |
183 | - | let amountToSendStep3 = (amountToSendEstimated - ((3 * deltaMaxAndMinSendValue) / 5)) | |
184 | - | let amountToSendStep4 = (amountToSendEstimated - ((4 * deltaMaxAndMinSendValue) / 5)) | |
185 | - | let amountToSendStep5 = (amountToSendEstimated - ((5 * deltaMaxAndMinSendValue) / 5)) | |
186 | - | let y = (amountB + tokenReceiveAmount) | |
187 | - | let invariantNew = invariantCalc((amountA - amountToSendEstimated), y) | |
188 | - | let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantNew) | |
189 | - | if ((0 >= (invariantCalc((amountA - amountToSendStep5), y) - invariant))) | |
190 | - | then throw("err1") | |
168 | + | func calculateSendAmount (amountToSendEstimated,minTokenReceiveAmount,tokenReceiveAmount,tokenId) = { | |
169 | + | let slippageValue = (scale8 - ((scale8 * 1) / 10000000)) | |
170 | + | let deltaBetweenMaxAndMinSendValue = (amountToSendEstimated - minTokenReceiveAmount) | |
171 | + | let x = (balanceA + tokenReceiveAmount) | |
172 | + | let y = (balanceB + tokenReceiveAmount) | |
173 | + | let invariantNew = if ((tokenId == assetIdA)) | |
174 | + | then invariantCalc(x, (balanceB - amountToSendEstimated)) | |
175 | + | else if ((tokenId == assetIdB)) | |
176 | + | then invariantCalc((balanceA - amountToSendEstimated), y) | |
177 | + | else throw("Wrong asset in payment") | |
178 | + | let invariantEstimatedRatio = fraction(scale8, invariant, invariantNew) | |
179 | + | func getStepAmount (acc,step) = if (true) | |
180 | + | then throw(((toString(acc) + " ") + toString(step))) | |
181 | + | else { | |
182 | + | let amountToSend = (amountToSendEstimated - ((step * deltaBetweenMaxAndMinSendValue) / 5)) | |
183 | + | let stepInvariant = if ((tokenId == assetIdA)) | |
184 | + | then invariantCalc(x, (balanceB - amountToSend)) | |
185 | + | else invariantCalc((balanceA - amountToSend), y) | |
186 | + | if (true) | |
187 | + | then amountToSend | |
188 | + | else acc | |
189 | + | } | |
190 | + | ||
191 | + | let stepAmount = { | |
192 | + | let $list58655908 = [1, 2, 3, 4, 5] | |
193 | + | let $size58655908 = size($list58655908) | |
194 | + | let $acc058655908 = -1 | |
195 | + | if (($size58655908 == 0)) | |
196 | + | then $acc058655908 | |
197 | + | else { | |
198 | + | let $acc158655908 = getStepAmount($acc058655908, $list58655908[0]) | |
199 | + | if (($size58655908 == 1)) | |
200 | + | then $acc158655908 | |
201 | + | else { | |
202 | + | let $acc258655908 = getStepAmount($acc158655908, $list58655908[1]) | |
203 | + | if (($size58655908 == 2)) | |
204 | + | then $acc258655908 | |
205 | + | else { | |
206 | + | let $acc358655908 = getStepAmount($acc258655908, $list58655908[2]) | |
207 | + | if (($size58655908 == 3)) | |
208 | + | then $acc358655908 | |
209 | + | else { | |
210 | + | let $acc458655908 = getStepAmount($acc358655908, $list58655908[3]) | |
211 | + | if (($size58655908 == 4)) | |
212 | + | then $acc458655908 | |
213 | + | else { | |
214 | + | let $acc558655908 = getStepAmount($acc458655908, $list58655908[4]) | |
215 | + | if (($size58655908 == 5)) | |
216 | + | then $acc558655908 | |
217 | + | else { | |
218 | + | let $acc658655908 = getStepAmount($acc558655908, $list58655908[5]) | |
219 | + | throw("List size exceed 5") | |
220 | + | } | |
221 | + | } | |
222 | + | } | |
223 | + | } | |
224 | + | } | |
225 | + | } | |
226 | + | } | |
227 | + | if ((0 > stepAmount)) | |
228 | + | then throw("something went wrong while working with amountToSend") | |
191 | 229 | else if (if ((invariantEstimatedRatio > slippageValue)) | |
192 | - | then ( | |
230 | + | then (invariantNew > invariant) | |
193 | 231 | else false) | |
194 | 232 | then amountToSendEstimated | |
195 | - | else if (((invariantCalc((amountA - amountToSendStep1), y) - invariant) > 0)) | |
196 | - | then ((amountToSendStep1 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
197 | - | else if (((invariantCalc((amountA - amountToSendStep2), y) - invariant) > 0)) | |
198 | - | then ((amountToSendStep2 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
199 | - | else if (((invariantCalc((amountA - amountToSendStep3), y) - invariant) > 0)) | |
200 | - | then ((amountToSendStep3 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
201 | - | else if (((invariantCalc((amountA - amountToSendStep4), y) - invariant) > 0)) | |
202 | - | then ((amountToSendStep4 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
203 | - | else if (((invariantCalc((amountA - amountToSendStep5), y) - invariant) > 0)) | |
204 | - | then ((amountToSendStep5 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
205 | - | else throw("err2") | |
206 | - | } | |
207 | - | ||
208 | - | ||
209 | - | func calculateHowManySendB (amountToSendEstimated,minTokenReceiveAmount,amountA,amountB,tokenReceiveAmount) = { | |
210 | - | let slippageValue = (scaleValue8 - ((scaleValue8 * 1) / 10000000)) | |
211 | - | let deltaMaxAndMinSendValue = (amountToSendEstimated - minTokenReceiveAmount) | |
212 | - | let amountToSendStep1 = (amountToSendEstimated - ((1 * deltaMaxAndMinSendValue) / 5)) | |
213 | - | let amountToSendStep2 = (amountToSendEstimated - ((2 * deltaMaxAndMinSendValue) / 5)) | |
214 | - | let amountToSendStep3 = (amountToSendEstimated - ((3 * deltaMaxAndMinSendValue) / 5)) | |
215 | - | let amountToSendStep4 = (amountToSendEstimated - ((4 * deltaMaxAndMinSendValue) / 5)) | |
216 | - | let amountToSendStep5 = (amountToSendEstimated - ((5 * deltaMaxAndMinSendValue) / 5)) | |
217 | - | let x = (amountA + tokenReceiveAmount) | |
218 | - | let invariantNew = invariantCalc(x, (amountB - amountToSendEstimated)) | |
219 | - | let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantNew) | |
220 | - | if ((0 >= (invariantCalc(x, (amountB - amountToSendStep5)) - invariant))) | |
221 | - | then throw("err1") | |
222 | - | else if (if ((invariantEstimatedRatio > slippageValue)) | |
223 | - | then ((invariantNew - invariant) > 0) | |
224 | - | else false) | |
225 | - | then amountToSendEstimated | |
226 | - | else if (((invariantCalc(x, (amountB - amountToSendStep1)) - invariant) > 0)) | |
227 | - | then ((amountToSendStep1 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
228 | - | else if (((invariantCalc(x, (amountB - amountToSendStep2)) - invariant) > 0)) | |
229 | - | then ((amountToSendStep2 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
230 | - | else if (((invariantCalc(x, (amountB - amountToSendStep3)) - invariant) > 0)) | |
231 | - | then ((amountToSendStep3 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
232 | - | else if (((invariantCalc(x, (amountB - amountToSendStep4)) - invariant) > 0)) | |
233 | - | then ((amountToSendStep4 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
234 | - | else if (((invariantCalc(x, (amountB - amountToSendStep5)) - invariant) > 0)) | |
235 | - | then ((amountToSendStep5 * (feeScaleDelimiter - fee)) / feeScaleDelimiter) | |
236 | - | else throw("err2") | |
233 | + | else ((stepAmount * (feeScale6 - fee)) / feeScale6) | |
237 | 234 | } | |
238 | 235 | ||
239 | 236 | ||
240 | 237 | func getAssetInfo (assetId) = match assetId { | |
241 | 238 | case id: ByteVector => | |
242 | 239 | let stringId = toBase58String(id) | |
243 | 240 | let info = valueOrErrorMessage(assetInfo(id), (("Asset " + stringId) + " doesn't exist")) | |
244 | 241 | $Tuple3(stringId, info.name, info.decimals) | |
245 | 242 | case waves: Unit => | |
246 | 243 | $Tuple3("WAVES", "WAVES", 8) | |
247 | 244 | case _ => | |
248 | 245 | throw("Match error") | |
249 | 246 | } | |
250 | 247 | ||
251 | 248 | ||
252 | 249 | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
253 | 250 | ||
254 | 251 | ||
255 | 252 | func deductStakingFee (amount,assetId) = if ((assetId == USDN)) | |
256 | 253 | then { | |
257 | 254 | let result = (amount - stakingFeeInUSDN) | |
258 | 255 | if ((0 >= result)) | |
259 | 256 | then throw((((("Insufficient amount " + toString(amount)) + " to deduct staking fee ") + toString(stakingFeeInUSDN)) + " USD-N")) | |
260 | 257 | else result | |
261 | 258 | } | |
262 | 259 | else amount | |
263 | 260 | ||
264 | 261 | ||
265 | 262 | func throwIsActive () = throw("DApp is already active") | |
266 | 263 | ||
267 | 264 | ||
268 | 265 | func throwIsInactive () = throw("DApp is inactive at this moment") | |
269 | 266 | ||
270 | 267 | ||
271 | 268 | func throwOnlyAdmin () = throw("Only admin can call this function") | |
272 | 269 | ||
273 | 270 | ||
274 | 271 | func throwAssets () = throw(((("Incorrect assets attached. Expected: " + strAssetIdA) + " and ") + strAssetIdB)) | |
275 | 272 | ||
276 | 273 | ||
277 | 274 | func throwThreshold (threshold,amountA,amountB) = throw(((((((((("New balance in assets of the DApp is less than threshold " + toString(threshold)) + ": ") + toString(amountA)) + " ") + assetNameA) + ", ") + toString(amountB)) + " ") + assetNameB)) | |
278 | 275 | ||
279 | 276 | ||
280 | 277 | func throwInsufficientAvailableBalance (amount,available,assetName) = throw((((((((("Insufficient DApp balance to pay " + toString(amount)) + " ") + assetName) + " due to staking. Available: ") + toString(available)) + " ") + assetName) + ". Please contact support in Telegram: https://t.me/swopfisupport")) | |
281 | 278 | ||
282 | 279 | ||
283 | 280 | func throwInsufficientAvailableBalances (amountA,amountB) = throw((((((((((((((((("Insufficient DApp balance to pay " + toString(amountA)) + " ") + assetNameA) + " and ") + toString(amountB)) + " ") + assetNameB) + " due to staking. Available: ") + toString(availableBalanceA)) + " ") + assetNameA) + " and ") + toString(availableBalanceB)) + " ") + assetNameB) + ". Please contact support in Telegram: https://t.me/swopfisupport")) | |
284 | 281 | ||
285 | 282 | ||
286 | 283 | func suspendSuspicious () = suspend(((((((((((((((("Suspicious state. Actual balances: " + toString(balanceA)) + " ") + assetNameA) + ", ") + toString(balanceB)) + " ") + assetNameB) + ". State: ") + toString(accountBalance(assetIdA))) + " ") + assetNameA) + ", ") + toString(accountBalance(assetIdB))) + " ") + assetNameB)) | |
287 | 284 | ||
288 | 285 | ||
289 | 286 | @Callable(i) | |
290 | 287 | func init () = { | |
291 | - | let $ | |
292 | - | let pmtAmountA = $ | |
293 | - | let pmtAssetIdA = $ | |
294 | - | let $ | |
295 | - | let pmtAmountB = $ | |
296 | - | let pmtAssetIdB = $ | |
297 | - | let $ | |
298 | - | let pmtStrAssetIdA = $ | |
299 | - | let pmtAssetNameA = $ | |
300 | - | let pmtDecimalsA = $ | |
301 | - | let $ | |
302 | - | let pmtStrAssetIdB = $ | |
303 | - | let pmtAssetNameB = $ | |
304 | - | let pmtDecimalsB = $ | |
288 | + | let $t086198696 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
289 | + | let pmtAmountA = $t086198696._1 | |
290 | + | let pmtAssetIdA = $t086198696._2 | |
291 | + | let $t087018778 = $Tuple2(i.payments[1].amount, i.payments[1].assetId) | |
292 | + | let pmtAmountB = $t087018778._1 | |
293 | + | let pmtAssetIdB = $t087018778._2 | |
294 | + | let $t087838860 = getAssetInfo(pmtAssetIdA) | |
295 | + | let pmtStrAssetIdA = $t087838860._1 | |
296 | + | let pmtAssetNameA = $t087838860._2 | |
297 | + | let pmtDecimalsA = $t087838860._3 | |
298 | + | let $t088658942 = getAssetInfo(pmtAssetIdB) | |
299 | + | let pmtStrAssetIdB = $t088658942._1 | |
300 | + | let pmtAssetNameB = $t088658942._2 | |
301 | + | let pmtDecimalsB = $t088658942._3 | |
305 | 302 | if (isDefined(getBoolean(this, kActive))) | |
306 | 303 | then throwIsActive() | |
307 | 304 | else if ((pmtAssetIdA == pmtAssetIdB)) | |
308 | 305 | then throw("Assets must be different") | |
309 | 306 | else { | |
310 | 307 | let shareName = ((("s" + take(pmtAssetNameA, 7)) + "_") + take(pmtAssetNameB, 7)) | |
311 | 308 | let shareDescription = ((((("ShareToken of SwopFi protocol for " + pmtAssetNameA) + " and ") + pmtAssetNameB) + " at address ") + toString(this)) | |
312 | 309 | let shareDecimals = ((pmtDecimalsA + pmtDecimalsB) / 2) | |
313 | 310 | let shareInitialSupply = fraction(pow(pmtAmountA, pmtDecimalsA, 5, 1, pmtDecimalsA, HALFDOWN), pow(pmtAmountB, pmtDecimalsB, 5, 1, pmtDecimalsB, HALFDOWN), pow(10, 0, shareDecimals, 0, 0, HALFDOWN)) | |
314 | 311 | let shareIssue = Issue(shareName, shareDescription, shareInitialSupply, shareDecimals, true) | |
315 | 312 | let shareIssueId = calculateAssetId(shareIssue) | |
316 | 313 | let invariantCalculated = invariantCalc(pmtAmountA, pmtAmountB) | |
317 | - | [StringEntry(kVersion, version), BooleanEntry(kActive, true), StringEntry(kAssetIdA, pmtStrAssetIdA), StringEntry(kAssetIdB, pmtStrAssetIdB), IntegerEntry(kBalanceA, pmtAmountA), IntegerEntry(kBalanceB, pmtAmountB), IntegerEntry(kInvariant, invariantCalculated), IntegerEntry(kFee, fee), IntegerEntry(kFeeScaleDelimiter, | |
314 | + | [StringEntry(kVersion, version), BooleanEntry(kActive, true), StringEntry(kAssetIdA, pmtStrAssetIdA), StringEntry(kAssetIdB, pmtStrAssetIdB), IntegerEntry(kBalanceA, pmtAmountA), IntegerEntry(kBalanceB, pmtAmountB), IntegerEntry(kInvariant, invariantCalculated), IntegerEntry(kFee, fee), IntegerEntry(kFeeScaleDelimiter, feeScale6), shareIssue, StringEntry(kShareAssetId, toBase58String(shareIssueId)), IntegerEntry(kShareAssetSupply, shareInitialSupply), ScriptTransfer(i.caller, shareInitialSupply, shareIssueId)] | |
318 | 315 | } | |
319 | 316 | } | |
320 | 317 | ||
321 | 318 | ||
322 | 319 | ||
323 | 320 | @Callable(i) | |
324 | - | func replenishWithTwoTokens (slippageTolerance) = if ((slippageTolerance > 10)) | |
325 | - | then throw("slippage tolerance must be <= 1%") | |
326 | - | else { | |
327 | - | let pmtAssetIdA = i.payments[0].assetId | |
328 | - | let pmtAssetIdB = i.payments[1].assetId | |
329 | - | let pmtAmountA = deductStakingFee(i.payments[0].amount, pmtAssetIdA) | |
330 | - | let pmtAmountB = deductStakingFee(i.payments[1].amount, pmtAssetIdB) | |
331 | - | let tokenRatio = fraction(fraction(balanceA, scaleValue8, pmtAmountA), scaleValue3, fraction(balanceB, scaleValue8, pmtAmountB)) | |
332 | - | let ratioShareTokensInA = fraction(pmtAmountA, scaleValue8, balanceA) | |
333 | - | let ratioShareTokensInB = fraction(pmtAmountB, scaleValue8, balanceB) | |
334 | - | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
335 | - | let invariantCalculated = invariantCalc((balanceA + pmtAmountA), (balanceB + pmtAmountB)) | |
336 | - | if (!(isActive)) | |
337 | - | then throwIsInactive() | |
338 | - | else if (if ((0 > slippageTolerance)) | |
339 | - | then true | |
340 | - | else (slippageTolerance > slippageToleranceDelimiter)) | |
341 | - | then throw(((("Slippage tolerance must be between 0 and " + toString(slippageToleranceDelimiter)) + " inclusively. Actual: ") + toString(slippageTolerance))) | |
342 | - | else if ((size(i.payments) != 2)) | |
343 | - | then throw("Two attached assets expected") | |
344 | - | else if (if ((pmtAssetIdA != assetIdA)) | |
321 | + | func replenishWithTwoTokens (slippageTolerance) = { | |
322 | + | let pmtAssetIdA = i.payments[0].assetId | |
323 | + | let pmtAssetIdB = i.payments[1].assetId | |
324 | + | let pmtAmountA = deductStakingFee(i.payments[0].amount, pmtAssetIdA) | |
325 | + | let pmtAmountB = deductStakingFee(i.payments[1].amount, pmtAssetIdB) | |
326 | + | let tokenRatio = fraction(fraction(scale8, balanceA, pmtAmountA), scale3, fraction(scale8, balanceB, pmtAmountB)) | |
327 | + | let ratioShareTokensInA = fraction(scale8, pmtAmountA, balanceA) | |
328 | + | let ratioShareTokensInB = fraction(scale8, pmtAmountB, balanceB) | |
329 | + | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scale8) | |
330 | + | let invariantCalculated = invariantCalc((balanceA + pmtAmountA), (balanceB + pmtAmountB)) | |
331 | + | if (!(isActive)) | |
332 | + | then throwIsInactive() | |
333 | + | else if (if ((0 > slippageTolerance)) | |
334 | + | then true | |
335 | + | else (slippageTolerance > 10)) | |
336 | + | then throw("Slippage tolerance must be <= 1%") | |
337 | + | else if ((size(i.payments) != 2)) | |
338 | + | then throw("Two attached assets expected") | |
339 | + | else if (if ((pmtAssetIdA != assetIdA)) | |
340 | + | then true | |
341 | + | else (pmtAssetIdB != assetIdB)) | |
342 | + | then throwAssets() | |
343 | + | else if (if ((((scale3 * (slippageScale3 - slippageTolerance)) / slippageScale3) > tokenRatio)) | |
345 | 344 | then true | |
346 | - | else (pmtAssetIdB != assetIdB)) | |
347 | - | then throwAssets() | |
348 | - | else if (if ((((scaleValue3 * (slippageToleranceDelimiter - slippageTolerance)) / slippageToleranceDelimiter) > tokenRatio)) | |
349 | - | then true | |
350 | - | else (tokenRatio > ((scaleValue3 * (slippageToleranceDelimiter + slippageTolerance)) / slippageToleranceDelimiter))) | |
351 | - | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
352 | - | else if ((shareTokenToPayAmount == 0)) | |
353 | - | then throw("Too small amount to replenish") | |
354 | - | else if (!(hasEnoughBalance)) | |
355 | - | then suspendSuspicious() | |
356 | - | else [IntegerEntry(kBalanceA, (balanceA + pmtAmountA)), IntegerEntry(kBalanceB, (balanceB + pmtAmountB)), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), IntegerEntry(kInvariant, invariantCalculated), Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId)] | |
357 | - | } | |
345 | + | else (tokenRatio > ((scale3 * (slippageScale3 + slippageTolerance)) / slippageScale3))) | |
346 | + | then throw("Incorrect assets amount: amounts must have the contract ratio") | |
347 | + | else if ((shareTokenToPayAmount == 0)) | |
348 | + | then throw("Too small amount to replenish") | |
349 | + | else if (!(hasEnoughBalance)) | |
350 | + | then suspendSuspicious() | |
351 | + | else [IntegerEntry(kBalanceA, (balanceA + pmtAmountA)), IntegerEntry(kBalanceB, (balanceB + pmtAmountB)), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), IntegerEntry(kInvariant, invariantCalculated), Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId)] | |
352 | + | } | |
358 | 353 | ||
359 | 354 | ||
360 | 355 | ||
361 | 356 | @Callable(i) | |
362 | 357 | func replenishWithOneToken (virtualSwapTokenPay,virtualSwapTokenGet) = { | |
363 | - | let $ | |
364 | - | let pmtAmount = $ | |
365 | - | let pmtAssetId = $ | |
358 | + | let $t01315713232 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
359 | + | let pmtAmount = $t01315713232._1 | |
360 | + | let pmtAssetId = $t01315713232._2 | |
366 | 361 | let pmtMinThreshold = 5000000 | |
367 | 362 | let thresholdValueForMinTolerance = 50000000 | |
368 | 363 | let tolerance = if ((thresholdValueForMinTolerance > pmtAmount)) | |
369 | 364 | then 100000 | |
370 | 365 | else 1 | |
371 | - | let slippageValueMinForReplenish = ( | |
372 | - | let slippageValueMaxForReplenish = ( | |
373 | - | let slippageValueMinForSwap = ( | |
374 | - | let slippageValueMaxForSwap = ( | |
366 | + | let slippageValueMinForReplenish = (scale8 - ((scale8 * tolerance) / 10000000)) | |
367 | + | let slippageValueMaxForReplenish = (scale8 + ((scale8 * tolerance) / 10000000)) | |
368 | + | let slippageValueMinForSwap = (scale8 - ((scale8 * 1) / 10000000)) | |
369 | + | let slippageValueMaxForSwap = (scale8 + ((scale8 * 1) / 10000000)) | |
375 | 370 | if (!(isActive)) | |
376 | 371 | then throwIsInactive() | |
377 | 372 | else if ((pmtMinThreshold > pmtAmount)) | |
378 | 373 | then throw((((("Payment amount " + toString(pmtAmount)) + " does not exceed the minimum amount of ") + toString(pmtMinThreshold)) + " tokens")) | |
379 | 374 | else if ((size(i.payments) != 1)) | |
380 | 375 | then throw("One attached payment expected") | |
381 | 376 | else if (!(hasEnoughBalance)) | |
382 | 377 | then suspendSuspicious() | |
383 | - | else if ((pmtAssetId == assetIdA)) | |
384 | - | then { | |
385 | - | let virtReplA = (pmtAmount - virtualSwapTokenPay) | |
386 | - | let virtReplB = virtualSwapTokenGet | |
387 | - | let balanceAfterSwapA = (balanceA + virtualSwapTokenPay) | |
388 | - | let balanceAfterSwapB = (balanceB - virtualSwapTokenGet) | |
378 | + | else if (if ((pmtAssetId != assetIdA)) | |
379 | + | then (pmtAssetId != assetIdB) | |
380 | + | else false) | |
381 | + | then throwAssets() | |
382 | + | else { | |
383 | + | let $t01423414999 = if ((pmtAssetId == assetIdA)) | |
384 | + | then $Tuple7((pmtAmount - virtualSwapTokenPay), virtualSwapTokenGet, (balanceA + virtualSwapTokenPay), (balanceB - virtualSwapTokenGet), invariantCalc((balanceA + pmtAmount), balanceB), (balanceA + pmtAmount), balanceB) | |
385 | + | else $Tuple7(virtualSwapTokenGet, (pmtAmount - virtualSwapTokenPay), (balanceA - virtualSwapTokenGet), (balanceB + virtualSwapTokenPay), invariantCalc(balanceA, (balanceB + pmtAmount)), balanceA, (balanceB + pmtAmount)) | |
386 | + | let virtualReplenishA = $t01423414999._1 | |
387 | + | let virtualReplenishB = $t01423414999._2 | |
388 | + | let balanceAfterSwapA = $t01423414999._3 | |
389 | + | let balanceAfterSwapB = $t01423414999._4 | |
390 | + | let invariantCalculated = $t01423414999._5 | |
391 | + | let newBalanceA = $t01423414999._6 | |
392 | + | let newBalanceB = $t01423414999._7 | |
393 | + | let newBalanceEntry = if ((pmtAssetId == assetIdA)) | |
394 | + | then IntegerEntry(kBalanceA, newBalanceA) | |
395 | + | else IntegerEntry(kBalanceB, newBalanceB) | |
389 | 396 | let invariantNew = invariantCalc(balanceAfterSwapA, balanceAfterSwapB) | |
390 | - | let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantNew) | |
391 | - | if (if ((invariantEstimatedRatio > slippageValueMinForSwap)) | |
392 | - | then ((invariantNew - invariant) >= 0) | |
393 | - | else false) | |
394 | - | then { | |
395 | - | let ratioVirtualBalanceToVirtualReplenish = (fraction(balanceAfterSwapA, (scaleValue8 * scaleValue8), balanceAfterSwapB) / fraction(virtReplA, scaleValue8, virtReplB)) | |
396 | - | if (if ((slippageValueMinForReplenish > ratioVirtualBalanceToVirtualReplenish)) | |
397 | + | let invariantEstimatedRatio = fraction(scale8, invariant, invariantNew) | |
398 | + | let ratioVirtualBalanceToVirtualReplenish = (fraction((scale8 * scale8), balanceAfterSwapA, balanceAfterSwapB) / fraction(scale8, virtualReplenishA, virtualReplenishB)) | |
399 | + | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdScale2)) | |
400 | + | if (if ((slippageValueMinForSwap >= invariantEstimatedRatio)) | |
401 | + | then true | |
402 | + | else (invariant > invariantNew)) | |
403 | + | then throw("Incorrect virtualSwapTokenPay or virtualSwapTokenGet value") | |
404 | + | else if (if ((slippageValueMinForReplenish > ratioVirtualBalanceToVirtualReplenish)) | |
405 | + | then true | |
406 | + | else (ratioVirtualBalanceToVirtualReplenish > slippageValueMaxForReplenish)) | |
407 | + | then throw("Swap with virtualSwapTokenPay and virtualSwapTokenGet is possible, but ratio after virtual swap is incorrect") | |
408 | + | else if (if ((dAppThresholdAmount > newBalanceA)) | |
397 | 409 | then true | |
398 | - | else ( | |
399 | - | then | |
410 | + | else (dAppThresholdAmount > newBalanceB)) | |
411 | + | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
400 | 412 | else { | |
401 | - | let ratioShareTokensInA = fraction(deductStakingFee(virtReplA, assetIdA), scaleValue8, balanceAfterSwapA) | |
402 | - | let ratioShareTokensInB = fraction(deductStakingFee(virtReplB, assetIdB), scaleValue8, balanceAfterSwapB) | |
403 | - | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
404 | - | let invariantCalculated = invariantCalc((balanceA + pmtAmount), balanceB) | |
405 | - | let newBalanceA = (balanceA + pmtAmount) | |
406 | - | let newBalanceB = balanceB | |
407 | - | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdDelimiter)) | |
408 | - | if (if ((dAppThresholdAmount > newBalanceA)) | |
409 | - | then true | |
410 | - | else (dAppThresholdAmount > newBalanceB)) | |
411 | - | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
412 | - | else [Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), IntegerEntry(kBalanceA, newBalanceA), IntegerEntry(kInvariant, invariantCalculated)] | |
413 | + | let ratioShareTokensInA = fraction(deductStakingFee(virtualReplenishA, assetIdA), scale8, balanceAfterSwapA) | |
414 | + | let ratioShareTokensInB = fraction(deductStakingFee(virtualReplenishB, assetIdB), scale8, balanceAfterSwapB) | |
415 | + | if (true) | |
416 | + | then throw(toString(value(value(assetInfo(USDN)).minSponsoredFee))) | |
417 | + | else { | |
418 | + | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scale8) | |
419 | + | if (true) | |
420 | + | then throw(toString(shareTokenToPayAmount)) | |
421 | + | else [Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), newBalanceEntry, IntegerEntry(kInvariant, invariantCalculated)] | |
422 | + | } | |
413 | 423 | } | |
414 | - | } | |
415 | - | else throw("Incorrect virtualSwapTokenPay or virtualSwapTokenGet value") | |
416 | 424 | } | |
417 | - | else if ((pmtAssetId == assetIdB)) | |
418 | - | then { | |
419 | - | let virtReplB = (pmtAmount - virtualSwapTokenPay) | |
420 | - | let virtReplA = virtualSwapTokenGet | |
421 | - | let balanceAfterSwapA = (balanceA - virtualSwapTokenGet) | |
422 | - | let balanceAfterSwapB = (balanceB + virtualSwapTokenPay) | |
423 | - | let invariantNew = invariantCalc(balanceAfterSwapA, balanceAfterSwapB) | |
424 | - | let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantNew) | |
425 | - | if (if ((invariantEstimatedRatio > slippageValueMinForSwap)) | |
426 | - | then ((invariantNew - invariant) >= 0) | |
427 | - | else false) | |
428 | - | then { | |
429 | - | let ratioVirtualBalanceToVirtualReplenish = (fraction(balanceAfterSwapA, (scaleValue8 * scaleValue8), balanceAfterSwapB) / fraction(virtReplA, scaleValue8, virtReplB)) | |
430 | - | if (if ((slippageValueMinForReplenish > ratioVirtualBalanceToVirtualReplenish)) | |
431 | - | then true | |
432 | - | else (ratioVirtualBalanceToVirtualReplenish > slippageValueMaxForReplenish)) | |
433 | - | then throw("Ratio after virtual swap incorrect") | |
434 | - | else { | |
435 | - | let ratioShareTokensInA = fraction(deductStakingFee(virtReplA, assetIdA), scaleValue8, balanceAfterSwapA) | |
436 | - | let ratioShareTokensInB = fraction(deductStakingFee(virtReplB, assetIdB), scaleValue8, balanceAfterSwapB) | |
437 | - | let shareTokenToPayAmount = fraction(min([ratioShareTokensInA, ratioShareTokensInB]), shareAssetSupply, scaleValue8) | |
438 | - | let invariantCalculated = invariantCalc(balanceA, (balanceB + pmtAmount)) | |
439 | - | let newBalanceA = balanceA | |
440 | - | let newBalanceB = (balanceB + pmtAmount) | |
441 | - | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdDelimiter)) | |
442 | - | if (if ((dAppThresholdAmount > newBalanceA)) | |
443 | - | then true | |
444 | - | else (dAppThresholdAmount > newBalanceB)) | |
445 | - | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
446 | - | else [Reissue(shareAssetId, shareTokenToPayAmount, true), ScriptTransfer(i.caller, shareTokenToPayAmount, shareAssetId), IntegerEntry(kShareAssetSupply, (shareAssetSupply + shareTokenToPayAmount)), IntegerEntry(kBalanceB, newBalanceB), IntegerEntry(kInvariant, invariantCalculated)] | |
447 | - | } | |
448 | - | } | |
449 | - | else throw("Incorrect virtualSwapTokenPay or virtualSwapTokenGet value") | |
450 | - | } | |
451 | - | else throwAssets() | |
452 | 425 | } | |
453 | 426 | ||
454 | 427 | ||
455 | 428 | ||
456 | 429 | @Callable(i) | |
457 | 430 | func withdraw () = { | |
458 | - | let $ | |
459 | - | let pmtAmount = $ | |
460 | - | let pmtAssetId = $ | |
431 | + | let $t01770817851 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
432 | + | let pmtAmount = $t01770817851._1 | |
433 | + | let pmtAssetId = $t01770817851._2 | |
461 | 434 | let amountToPayA = deductStakingFee(fraction(pmtAmount, balanceA, shareAssetSupply), assetIdA) | |
462 | 435 | let amountToPayB = deductStakingFee(fraction(pmtAmount, balanceB, shareAssetSupply), assetIdB) | |
463 | 436 | let invariantCalculated = invariantCalc((balanceA - amountToPayA), (balanceB - amountToPayB)) | |
464 | 437 | if (!(isActive)) | |
465 | 438 | then throwIsInactive() | |
466 | 439 | else if ((size(i.payments) != 1)) | |
467 | 440 | then throw("One attached payment expected") | |
468 | 441 | else if ((pmtAssetId != shareAssetId)) | |
469 | 442 | then throw(("Incorrect asset attached. Expected: " + toBase58String(shareAssetId))) | |
470 | 443 | else if (!(hasEnoughBalance)) | |
471 | 444 | then suspendSuspicious() | |
472 | 445 | else if (if ((amountToPayA > availableBalanceA)) | |
473 | 446 | then true | |
474 | 447 | else (amountToPayB > availableBalanceB)) | |
475 | 448 | then throwInsufficientAvailableBalances(amountToPayA, amountToPayB) | |
476 | 449 | else [IntegerEntry(kBalanceA, (balanceA - amountToPayA)), IntegerEntry(kBalanceB, (balanceB - amountToPayB)), IntegerEntry(kShareAssetSupply, (shareAssetSupply - pmtAmount)), IntegerEntry(kInvariant, invariantCalculated), Burn(shareAssetId, pmtAmount), ScriptTransfer(i.caller, amountToPayA, assetIdA), ScriptTransfer(i.caller, amountToPayB, assetIdB)] | |
477 | 450 | } | |
478 | 451 | ||
479 | 452 | ||
480 | 453 | ||
481 | 454 | @Callable(i) | |
482 | 455 | func exchange (estimatedAmountToReceive,minAmountToReceive) = { | |
483 | - | let $ | |
484 | - | let pmtAmount = $ | |
485 | - | let pmtAssetId = $ | |
486 | - | if ( | |
487 | - | then | |
488 | - | else ( | |
489 | - | then throw(" | |
490 | - | else if ( | |
491 | - | then | |
492 | - | else if (( | |
493 | - | then throw( | |
494 | - | else if (( | |
495 | - | then | |
496 | - | else if (( | |
497 | - | then | |
498 | - | else | |
499 | - | then | |
456 | + | let $t01913419209 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
457 | + | let pmtAmount = $t01913419209._1 | |
458 | + | let pmtAssetId = $t01913419209._2 | |
459 | + | if (!(isActive)) | |
460 | + | then throwIsInactive() | |
461 | + | else if ((0 >= estimatedAmountToReceive)) | |
462 | + | then throw(("Estimated amount must be positive. Actual: " + toString(estimatedAmountToReceive))) | |
463 | + | else if ((minAmountToReceive > estimatedAmountToReceive)) | |
464 | + | then throw(((("Minimal amount can't be greater than estimated. Estimated: " + toString(estimatedAmountToReceive)) + ". Minimal: ") + toString(minAmountToReceive))) | |
465 | + | else if ((size(i.payments) != 1)) | |
466 | + | then throw("One attached payment expected") | |
467 | + | else if (!(hasEnoughBalance)) | |
468 | + | then suspendSuspicious() | |
469 | + | else if (if ((pmtAssetId != assetIdA)) | |
470 | + | then (pmtAssetId != assetIdB) | |
471 | + | else false) | |
472 | + | then throwAssets() | |
500 | 473 | else if ((10000000 > pmtAmount)) | |
501 | 474 | then throw("Only swap of 10.000000 or more tokens is allowed") | |
502 | - | else if ((pmtAssetId == assetIdA)) | |
503 | - | then { | |
504 | - | let assetIdSend = assetIdB | |
505 | - | let amountWithoutFee = calculateHowManySendB(estimatedAmountToReceive, minAmountToReceive, balanceA, balanceB, pmtAmount) | |
506 | - | let amountWithFee = fraction(amountWithoutFee, (feeScaleDelimiter - fee), feeScaleDelimiter) | |
507 | - | let governanceReward = fraction(amountWithoutFee, feeGovernance, feeScaleDelimiter) | |
508 | - | let newBalanceA = (balanceA + pmtAmount) | |
509 | - | let newBalanceB = ((balanceB - amountWithFee) - governanceReward) | |
510 | - | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdDelimiter)) | |
475 | + | else if (if ((exchangeRatioLimitMin > fraction(scale8, minAmountToReceive, pmtAmount))) | |
476 | + | then true | |
477 | + | else (fraction(scale8, estimatedAmountToReceive, pmtAmount) > exchangeRatioLimitMax)) | |
478 | + | then throw("Incorrect args and pmt ratio") | |
479 | + | else { | |
480 | + | let sendAssetId = if ((pmtAssetId == assetIdA)) | |
481 | + | then assetIdB | |
482 | + | else assetIdA | |
483 | + | let amountWithoutFee = calculateSendAmount(estimatedAmountToReceive, minAmountToReceive, pmtAmount, pmtAssetId) | |
484 | + | let amountWithFee = fraction(amountWithoutFee, (feeScale6 - fee), feeScale6) | |
485 | + | let governanceReward = fraction(amountWithoutFee, feeGovernance, feeScale6) | |
486 | + | let $t02058920850 = if ((pmtAssetId == assetIdA)) | |
487 | + | then $Tuple2((balanceA + pmtAmount), ((balanceB - amountWithFee) - governanceReward)) | |
488 | + | else $Tuple2(((balanceA - amountWithFee) - governanceReward), (balanceB + pmtAmount)) | |
489 | + | let newBalanceA = $t02058920850._1 | |
490 | + | let newBalanceB = $t02058920850._2 | |
491 | + | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdScale2)) | |
511 | 492 | if (if ((dAppThresholdAmount > newBalanceA)) | |
512 | 493 | then true | |
513 | 494 | else (dAppThresholdAmount > newBalanceB)) | |
514 | 495 | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
515 | 496 | else if (if (if ((assetIdA == USDN)) | |
497 | + | then (sendAssetId == assetIdA) | |
498 | + | else false) | |
516 | 499 | then (stakedAmountUSDN >= newBalanceA) | |
517 | 500 | else false) | |
518 | - | then true | |
519 | - | else if ((assetIdB == USDN)) | |
501 | + | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceA, assetNameA) | |
502 | + | else if (if (if ((assetIdB == USDN)) | |
503 | + | then (sendAssetId == assetIdB) | |
504 | + | else false) | |
520 | 505 | then (stakedAmountUSDN >= newBalanceB) | |
521 | 506 | else false) | |
522 | - | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceB, assetNameB) | |
523 | - | else [IntegerEntry(kBalanceA, newBalanceA), IntegerEntry(kBalanceB, newBalanceB), IntegerEntry(kInvariant, invariantCalc( | |
507 | + | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceB, assetNameB) | |
508 | + | else [IntegerEntry(kBalanceA, newBalanceA), IntegerEntry(kBalanceB, newBalanceB), IntegerEntry(kInvariant, invariantCalc(newBalanceA, newBalanceB)), ScriptTransfer(i.caller, amountWithFee, sendAssetId), ScriptTransfer(govAddr, governanceReward, sendAssetId)] | |
524 | 509 | } | |
525 | - | else if ((pmtAssetId == assetIdB)) | |
526 | - | then { | |
527 | - | let assetIdSend = assetIdA | |
528 | - | let amountWithoutFee = calculateHowManySendA(estimatedAmountToReceive, minAmountToReceive, balanceA, balanceB, pmtAmount) | |
529 | - | let amountWithFee = fraction(amountWithoutFee, (feeScaleDelimiter - fee), feeScaleDelimiter) | |
530 | - | let governanceReward = fraction(amountWithoutFee, feeGovernance, feeScaleDelimiter) | |
531 | - | let newBalanceA = ((balanceA - amountWithFee) - governanceReward) | |
532 | - | let newBalanceB = (balanceB + pmtAmount) | |
533 | - | let dAppThresholdAmount = fraction((newBalanceA + newBalanceB), dAppThreshold, (2 * dAppThresholdDelimiter)) | |
534 | - | if (if ((dAppThresholdAmount > newBalanceA)) | |
535 | - | then true | |
536 | - | else (dAppThresholdAmount > newBalanceB)) | |
537 | - | then throwThreshold(dAppThresholdAmount, newBalanceA, newBalanceB) | |
538 | - | else if (if (if ((assetIdA == USDN)) | |
539 | - | then (stakedAmountUSDN >= newBalanceA) | |
540 | - | else false) | |
541 | - | then true | |
542 | - | else if ((assetIdB == USDN)) | |
543 | - | then (stakedAmountUSDN >= newBalanceB) | |
544 | - | else false) | |
545 | - | then throwInsufficientAvailableBalance(amountWithFee, availableBalanceA, assetNameA) | |
546 | - | else [IntegerEntry(kBalanceA, newBalanceA), IntegerEntry(kBalanceB, newBalanceB), IntegerEntry(kInvariant, invariantCalc(((balanceA - amountWithFee) - governanceReward), (balanceB + pmtAmount))), ScriptTransfer(i.caller, amountWithFee, assetIdSend), ScriptTransfer(govAddr, governanceReward, assetIdSend)] | |
547 | - | } | |
548 | - | else throwAssets() | |
549 | 510 | } | |
550 | 511 | ||
551 | 512 | ||
552 | 513 | ||
553 | 514 | @Callable(i) | |
554 | 515 | func shutdown () = if (!(isActive)) | |
555 | 516 | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
556 | 517 | else if (!(containsElement([adm1, adm2, adm3, admStartStop], i.callerPublicKey))) | |
557 | 518 | then throwOnlyAdmin() | |
558 | 519 | else suspend("Paused by admin") | |
559 | 520 | ||
560 | 521 | ||
561 | 522 | ||
562 | 523 | @Callable(i) | |
563 | 524 | func activate () = if (isActive) | |
564 | 525 | then throwIsActive() | |
565 | 526 | else if (!(containsElement([adm1, adm2, adm3, admStartStop], i.callerPublicKey))) | |
566 | 527 | then throwOnlyAdmin() | |
567 | 528 | else [BooleanEntry(kActive, true), DeleteEntry(kCause)] | |
568 | 529 | ||
569 | 530 | ||
570 | 531 | ||
571 | 532 | @Callable(i) | |
572 | 533 | func takeIntoAccountExtraFunds (amountLeave) = { | |
573 | 534 | let uncountableA = (accountBalanceWithStakedA - balanceA) | |
574 | 535 | let uncountableB = (accountBalanceWithStakedB - balanceB) | |
575 | 536 | let amountEnrollA = (uncountableA - (if ((assetIdA == USDN)) | |
576 | 537 | then amountLeave | |
577 | 538 | else 0)) | |
578 | 539 | let amountEnrollB = (uncountableB - (if ((assetIdB == USDN)) | |
579 | 540 | then amountLeave | |
580 | 541 | else 0)) | |
581 | 542 | if (!(isActive)) | |
582 | 543 | then throwIsInactive() | |
583 | 544 | else if ((i.caller != this)) | |
584 | 545 | then throwOnlyAdmin() | |
585 | 546 | else if ((0 > amountLeave)) | |
586 | 547 | then throw(("Argument 'amountLeave' cannot be negative. Actual: " + toString(amountLeave))) | |
587 | 548 | else if (if ((0 > uncountableA)) | |
588 | 549 | then true | |
589 | 550 | else (0 > uncountableB)) | |
590 | 551 | then suspend("Enroll amount negative") | |
591 | 552 | else if (if ((0 > amountEnrollA)) | |
592 | 553 | then true | |
593 | 554 | else (0 > amountEnrollB)) | |
594 | 555 | then throw("Too large amountLeave") | |
595 | 556 | else [IntegerEntry(kBalanceA, (balanceA + amountEnrollA)), IntegerEntry(kBalanceB, (balanceB + amountEnrollB)), IntegerEntry(("last_income_" + strAssetIdA), amountEnrollA), IntegerEntry(("last_income_" + strAssetIdB), amountEnrollB)] | |
596 | 557 | } | |
597 | 558 | ||
598 | 559 |
github/deemru/w8io/169f3d6 98.60 ms ◑