tx · 3o1zMgN5rzALCFz58ngAbGpCFJCtVoRU1FzDdCCEjxWH

3N34x67KgytTnPx5erPmhz1FD8nwAChtAsb:  -0.01400000 Waves

2020.10.22 21:31 [1232146] smart account 3N34x67KgytTnPx5erPmhz1FD8nwAChtAsb > SELF 0.00000000 Waves

{ "type": 13, "id": "3o1zMgN5rzALCFz58ngAbGpCFJCtVoRU1FzDdCCEjxWH", "fee": 1400000, "feeAssetId": null, "timestamp": 1603391551192, "version": 1, "sender": "3N34x67KgytTnPx5erPmhz1FD8nwAChtAsb", "senderPublicKey": "Ak3LEdYk7Nk1Z88WXht4DxTQRZsK6dYL5kZ4CjrXSQBu", "proofs": [ "3hv8RLnE52x1Qv5RTftkGQQjfagwP1tJvu1NTGEw5YQx7nJH6Mpfe36PrvaNeKVJTZoVQVMLc7h64SHMffUg2d37" ], "script": "base64:AAIEAAAAAAAAABQIAhIAEgASBAoCAQESABIECgIBAQAAABsAAAAACElkVG9rZW5BCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzAgAAAA1hc3NldElkVG9rZW5BAAAAAAhJZFRva2VuQgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwIAAAANYXNzZXRJZFRva2VuQgAAAAAMSWRUb2tlblNoYXJlCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzAgAAAA5zaGFyZV90b2tlbl9pZAAAAAARZEFwcFRva2Vuc0Ftb3VudEEJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMCAAAADGFtb3VudFRva2VuQQAAAAARZEFwcFRva2Vuc0Ftb3VudEIJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMCAAAADGFtb3VudFRva2VuQgAAAAAQdG9rZW5TaGFyZVN1cHBseQkBAAAAEUBleHRyTmF0aXZlKDEwNTApAAAAAgUAAAAEdGhpcwIAAAASc2hhcmVfdG9rZW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hdGVIb3dNYW55U2VuZFRva2VuQgAAAAUFAAAAFWFtb3VudFRvU2VuZEVzdGltYXRlZAUAAAAVbWluVG9rZW5SZWNpZXZlQW1vdW50BQAAAAxhbW91bnRUb2tlbkEFAAAADGFtb3VudFRva2VuQgUAAAASdG9rZW5SZWNlaXZlQW1vdW50BAAAAAthc3NldElkU2VudAUAAAANYXNzZXRJZFRva2VuQgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAAMYW1vdW50VG9rZW5BCQAAZAAAAAIFAAAADGFtb3VudFRva2VuQQUAAAASdG9rZW5SZWNlaXZlQW1vdW50CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACAgAAAAxhbW91bnRUb2tlbkIJAABlAAAAAgUAAAAMYW1vdW50VG9rZW5CBQAAAA90b2tlblNlbmRBbW91bnQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAADmV4Y2hhbmdlX2NvdW50CQAAZAAAAAIFAAAABWNvdW50AAAAAAAAAAABCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACAgAAAAlpbnZhcmlhbnQJAQAAAA1pbnZhcmlhbnRDYWxjAAAAAgkAAGQAAAACBQAAAAxhbW91bnRUb2tlbkEFAAAAEnRva2VuUmVjZWl2ZUFtb3VudAkAAGUAAAACBQAAAAxhbW91bnRUb2tlbkIFAAAAD3Rva2VuU2VuZEFtb3VudAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIFAAAAD3Rva2VuU2VuZEFtb3VudAUAAAALYXNzZXRJZFNlbnQFAAAAA25pbAkAAAIAAAABAgAAABRBc3NldCBpcyBub3QgYWxsb3dlZAAAAAA/1FvN", "chainId": 84, "height": 1232146, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AaN9zgsmfWemEe6dVPmDQDeSnmJEokExE2o5PHn2uPBu Next: none Diff:
OldNewDifferences
55
66 let IdTokenB = getStringValue(this, "assetIdTokenB")
77
8-let amountTokenB = getIntegerValue(this, "amountTokenB")
8+let IdTokenShare = getStringValue(this, "share_token_id")
99
10-let amountTokenA = getIntegerValue(this, "amountTokenA")
10+let dAppTokensAmountA = getIntegerValue(this, "amountTokenA")
1111
12-let assetIdTokenShare = getBinaryValue(this, "share_token_id")
12+let dAppTokensAmountB = getIntegerValue(this, "amountTokenB")
1313
1414 let tokenShareSupply = getIntegerValue(this, "share_token_supply")
1515
16-let comission = 500
16+let comission = 0
1717
18-let comissionScaleDelimiter = 1000000
18+let comissionScaleDelimiter = 10000
1919
20-let version = "1.0.0"
20+let version = "2.0.0"
21+
22+let invariant = getIntegerValue(this, "invariant")
2123
2224 let scaleValue8 = 100000000
25+
26+let scaleValue8Digits = 8
27+
28+let scaleValue12 = 1000000000000
2329
2430 let ratioThresholdMax = 100000000
2531
2632 let ratioThresholdMin = 99999000
2733
28-let scaleValue8Digits = 8
34+let alpha = 50
35+
36+let alphaDigits = 2
37+
38+let betta = 46
39+
40+let bettaDigits = 2
41+
42+func skeweness (x,y) = ((fraction(scaleValue8, x, y) + fraction(scaleValue8, y, x)) / 2)
43+
44+
45+func invariantCalc (x,y) = {
46+ let sk = skeweness(x, y)
47+ (fraction((x + y), pow(sk, scaleValue8Digits, -(alpha), alphaDigits, 8, HALFDOWN), scaleValue8) + (2 * fraction(fraction(pow(x, 0, 5, 1, scaleValue8Digits, HALFDOWN), pow(y, 0, 5, 1, scaleValue8Digits, HALFDOWN), (scaleValue8 * scaleValue8)), pow((sk - ((betta * scaleValue8) / 100)), 0, alpha, alphaDigits, scaleValue8Digits, HALFDOWN), scaleValue12)))
48+ }
49+
2950
3051 func assetId (asset) = if ((asset == "WAVES"))
3152 then unit
3253 else fromBase58String(asset)
3354
3455
56+func calculateHowManySendTokenA (amountToSendEstimated,minTokenRecieveAmount,amountTokenA,amountTokenB,tokenReceiveAmount) = {
57+ let slippageValue = (scaleValue8 - ((scaleValue8 * 1) / 10000))
58+ let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantCalc((amountTokenA - amountToSendEstimated), (amountTokenB + tokenReceiveAmount)))
59+ if (if ((invariantEstimatedRatio > slippageValue))
60+ then (scaleValue8 > invariantEstimatedRatio)
61+ else false)
62+ then ((amountToSendEstimated * (comissionScaleDelimiter - comission)) / comissionScaleDelimiter)
63+ else throw("price has changed dramatically. err2")
64+ }
65+
66+
67+func calculateHowManySendTokenB (amountToSendEstimated,minTokenRecieveAmount,amountTokenA,amountTokenB,tokenReceiveAmount) = {
68+ let slippageValue = (scaleValue8 - ((scaleValue8 * 1) / 10000))
69+ let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantCalc((amountTokenA + tokenReceiveAmount), (amountTokenB - amountToSendEstimated)))
70+ if (if ((invariantEstimatedRatio > slippageValue))
71+ then (scaleValue8 > invariantEstimatedRatio)
72+ else false)
73+ then ((amountToSendEstimated * (comissionScaleDelimiter - comission)) / comissionScaleDelimiter)
74+ else throw("price has changed dramatically. err2")
75+ }
76+
77+
3578 let assetIdTokenA = assetId(IdTokenA)
3679
3780 let assetIdTokenB = assetId(IdTokenB)
81+
82+let assetIdTokenShare = fromBase58String(IdTokenShare)
3883
3984 @Callable(contextObj)
4085 func fund () = {
83128 case _ =>
84129 throw("Match error")
85130 }
86-[IntegerEntry("amountTokenA", tokenReceiveAmountA), IntegerEntry("amountTokenB", tokenReceiveAmountB), StringEntry("assetIdTokenA", assetIdTokenStringA), StringEntry("assetIdTokenB", assetIdTokenStringB), IntegerEntry("exchange_count", 0), BooleanEntry("status", true), IntegerEntry("comission", comission), IntegerEntry("comissionScaleDelimiter", comissionScaleDelimiter), StringEntry("version", version), Issue(shareTokenName, shareTokenName, shareTokenInitialAmount, digitsInShareToken, true), ScriptTransfer(contextObj.caller, shareTokenInitialAmount, shareTokenAssetId), BinaryEntry("share_token_id", shareTokenAssetId), IntegerEntry("share_token_supply", shareTokenInitialAmount)]
131+ let invariantCalcualated = invariantCalc(tokenReceiveAmountA, tokenReceiveAmountB)
132+[IntegerEntry("amountTokenA", tokenReceiveAmountA), IntegerEntry("amountTokenB", tokenReceiveAmountB), StringEntry("assetIdTokenA", assetIdTokenStringA), StringEntry("assetIdTokenB", assetIdTokenStringB), IntegerEntry("invariant", invariantCalcualated), IntegerEntry("exchange_count", 0), BooleanEntry("status", true), IntegerEntry("comission", comission), IntegerEntry("comissionScaleDelimiter", comissionScaleDelimiter), StringEntry("version", version), Issue(shareTokenName, shareTokenName, shareTokenInitialAmount, digitsInShareToken, true), ScriptTransfer(contextObj.caller, shareTokenInitialAmount, shareTokenAssetId), StringEntry("share_token_id", toBase58String(shareTokenAssetId)), IntegerEntry("share_token_supply", shareTokenInitialAmount)]
87133 }
88134 }
89135
90136
91137
92138 @Callable(contextObj)
93-func replenishment () = {
139+func replenishmentWithTwoToken () = {
94140 let paymentA = value(contextObj.payments[0])
95141 let paymentB = value(contextObj.payments[1])
96142 let assetIdReceivedA = paymentA.assetId
97143 let tokenReceiveAmountA = paymentA.amount
98144 let assetIdReceivedB = paymentB.assetId
99145 let tokenReceiveAmountB = paymentB.amount
100- let dAppTokensAmountA = getIntegerValue(this, "amountTokenA")
101- let dAppTokensAmountB = getIntegerValue(this, "amountTokenB")
146+ let invariantCalcualated = invariantCalc((dAppTokensAmountA + tokenReceiveAmountA), (dAppTokensAmountB + tokenReceiveAmountB))
102147 if (if ((assetIdReceivedA != assetIdTokenA))
103148 then true
104149 else (assetIdReceivedB != assetIdTokenB))
105150 then throw("incorrect assets")
106151 else {
107- let tokenRatio = (fraction(tokenReceiveAmountA, (1000000000000 * 100000), dAppTokensAmountA) / fraction(dAppTokensAmountB, 1000000000000, tokenReceiveAmountB))
108- if (!(if ((tokenRatio > 99990))
109- then (100010 > tokenRatio)
152+ let tokenRatio = (fraction(tokenReceiveAmountA, (1000000000000 * 1000), dAppTokensAmountA) / fraction(dAppTokensAmountB, 1000000000000, tokenReceiveAmountB))
153+ if (!(if ((tokenRatio > 990))
154+ then (1010 > tokenRatio)
110155 else false))
111156 then throw("incorrect assets amount")
112157 else {
113158 let shareTokenToPayAmount = fraction(tokenReceiveAmountA, tokenShareSupply, dAppTokensAmountA)
114159 if ((shareTokenToPayAmount == 0))
115160 then throw("you try replansish with very small amount")
116- else [Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenA", (dAppTokensAmountA + tokenReceiveAmountA)), IntegerEntry("amountTokenB", (dAppTokensAmountB + tokenReceiveAmountB))]
161+ else [Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenA", (dAppTokensAmountA + tokenReceiveAmountA)), IntegerEntry("amountTokenB", (dAppTokensAmountB + tokenReceiveAmountB)), IntegerEntry("invariant", invariantCalcualated)]
117162 }
118163 }
119164 }
121166
122167
123168 @Callable(contextObj)
124-func replanishmentWithOneToken () = {
169+func replanishmentWithOneToken (tokenAamountWithOldInvariantNewPrice,tokenBamountWithOldInvariantNewPrice) = {
125170 let payment = value(contextObj.payments[0])
126171 let assetIdReceived = payment.assetId
127172 let tokenReceiveAmount = payment.amount
128173 if ((assetIdReceived == assetIdTokenA))
129174 then {
130- let newAmountTokenA = (amountTokenA + tokenReceiveAmount)
131- let priceAtoBwith8digits = fraction(newAmountTokenA, scaleValue8, amountTokenB)
132- let tokenAmountBNewPriceOldInvariant = pow(fraction(amountTokenA, amountTokenB, priceAtoBwith8digits), 0, 5, 1, 0, HALFDOWN)
133- let newTokenShareSupply = fraction(amountTokenB, tokenShareSupply, tokenAmountBNewPriceOldInvariant)
134- let shareTokenToPayAmount = (newTokenShareSupply - tokenShareSupply)
135-[Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenA", newAmountTokenA)]
175+ let newAmountTokenA = (dAppTokensAmountA + tokenReceiveAmount)
176+ let newInvariant = invariantCalc(newAmountTokenA, dAppTokensAmountB)
177+ let priceAtoBwith8digits = fraction(newAmountTokenA, scaleValue8, dAppTokensAmountB)
178+ let isCorrectPriceRation = fraction(tokenBamountWithOldInvariantNewPrice, priceAtoBwith8digits, tokenAamountWithOldInvariantNewPrice)
179+ if (if ((isCorrectPriceRation > ratioThresholdMax))
180+ then true
181+ else (ratioThresholdMin > isCorrectPriceRation))
182+ then throw("incorrect function args: price")
183+ else {
184+ let calculatedInvariantWithNewPrice = invariantCalc(tokenAamountWithOldInvariantNewPrice, tokenBamountWithOldInvariantNewPrice)
185+ let isCorrectInvariantRation = fraction(calculatedInvariantWithNewPrice, scaleValue8, invariant)
186+ if (if ((isCorrectInvariantRation > ratioThresholdMax))
187+ then true
188+ else (ratioThresholdMin > isCorrectInvariantRation))
189+ then throw("incorrect function args: invariant")
190+ else {
191+ let newTokenShareSupply = fraction(tokenBamountWithOldInvariantNewPrice, tokenShareSupply, dAppTokensAmountB)
192+ let shareTokenToPayAmount = (newTokenShareSupply - tokenShareSupply)
193+[Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenA", newAmountTokenA), IntegerEntry("invariant", newInvariant)]
194+ }
195+ }
136196 }
137197 else if ((assetIdReceived == assetIdTokenB))
138198 then {
139- let newAmountTokenB = (amountTokenB + tokenReceiveAmount)
140- let priceAtoBwith8digits = fraction(amountTokenA, scaleValue8, newAmountTokenB)
141- let tokenAmountBNewPriceOldInvariant = pow(fraction(amountTokenA, amountTokenB, priceAtoBwith8digits), 0, 5, 1, 0, HALFDOWN)
142- let newTokenShareSupply = fraction(amountTokenB, tokenShareSupply, tokenAmountBNewPriceOldInvariant)
143- let shareTokenToPayAmount = (newTokenShareSupply - tokenShareSupply)
144-[Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenB", newAmountTokenB)]
199+ let newAmountTokenB = (dAppTokensAmountB + tokenReceiveAmount)
200+ let newInvariant = invariantCalc(dAppTokensAmountA, newAmountTokenB)
201+ let priceAtoBwith8digits = fraction(dAppTokensAmountA, scaleValue8, newAmountTokenB)
202+ let isCorrectPriceRation = fraction(tokenBamountWithOldInvariantNewPrice, priceAtoBwith8digits, tokenAamountWithOldInvariantNewPrice)
203+ if (if ((isCorrectPriceRation > ratioThresholdMax))
204+ then true
205+ else (ratioThresholdMin > isCorrectPriceRation))
206+ then throw("incorrect function args: price")
207+ else {
208+ let calculatedInvariantWithNewPrice = invariantCalc(tokenAamountWithOldInvariantNewPrice, tokenBamountWithOldInvariantNewPrice)
209+ let isCorrectInvariantRation = fraction(calculatedInvariantWithNewPrice, scaleValue8, invariant)
210+ if (if ((isCorrectInvariantRation > ratioThresholdMax))
211+ then true
212+ else (ratioThresholdMin > isCorrectInvariantRation))
213+ then throw("incorrect function args: invariant")
214+ else {
215+ let newTokenShareSupply = fraction(tokenBamountWithOldInvariantNewPrice, tokenShareSupply, dAppTokensAmountB)
216+ let shareTokenToPayAmount = (newTokenShareSupply - tokenShareSupply)
217+[Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenB", newAmountTokenB), IntegerEntry("invariant", newInvariant)]
218+ }
219+ }
145220 }
146221 else throw("incorrect assets in payment")
147222 }
150225
151226 @Callable(contextObj)
152227 func withdraw () = {
153- let dAppTokensAmountA = getIntegerValue(this, "amountTokenA")
154- let dAppTokensAmountB = getIntegerValue(this, "amountTokenB")
155228 let payment = value(contextObj.payments[0])
156229 let assetIdReceived = payment.assetId
157230 let tokenReceiveAmount = payment.amount
160233 else {
161234 let tokensToPayA = fraction(tokenReceiveAmount, dAppTokensAmountA, tokenShareSupply)
162235 let tokensToPayB = fraction(tokenReceiveAmount, dAppTokensAmountB, tokenShareSupply)
163-[ScriptTransfer(contextObj.caller, tokensToPayA, assetIdTokenA), ScriptTransfer(contextObj.caller, tokensToPayB, assetIdTokenB), IntegerEntry("amountTokenA", (dAppTokensAmountA - tokensToPayA)), IntegerEntry("amountTokenB", (dAppTokensAmountB - tokensToPayB)), IntegerEntry("share_token_supply", (tokenShareSupply - tokenReceiveAmount)), Burn(assetIdTokenShare, tokenReceiveAmount)]
236+ let invariantCalcualated = invariantCalc((dAppTokensAmountA - tokensToPayA), (dAppTokensAmountB - tokensToPayB))
237+[IntegerEntry("amountTokenA", (dAppTokensAmountA - tokensToPayA)), IntegerEntry("amountTokenB", (dAppTokensAmountB - tokensToPayB)), IntegerEntry("share_token_supply", (tokenShareSupply - tokenReceiveAmount)), ScriptTransfer(contextObj.caller, tokensToPayA, assetIdTokenA), ScriptTransfer(contextObj.caller, tokensToPayB, assetIdTokenB), Burn(assetIdTokenShare, tokenReceiveAmount), IntegerEntry("invariant", invariantCalcualated)]
164238 }
165239 }
166240
167241
168242
169243 @Callable(contextObj)
170-func exchanger (minTokenRecieve) = {
244+func exchanger (amountToSendEstimated,minTokenRecieveAmount) = {
245+ let amountTokenB = getIntegerValue(this, "amountTokenB")
246+ let amountTokenA = getIntegerValue(this, "amountTokenA")
171247 let payment = value(contextObj.payments[0])
172248 let assetIdReceived = payment.assetId
173249 let tokenReceiveAmount = payment.amount
174- let count = value(getInteger(this, "exchange_count"))
250+ let count = match getInteger(this, "exchange_count") {
251+ case i: Int =>
252+ (value(getInteger(this, "exchange_count")) + i)
253+ case _ =>
254+ 0
255+ }
175256 if ((assetIdReceived == assetIdTokenB))
176257 then {
177- let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (comissionScaleDelimiter - comission)) / comissionScaleDelimiter)
178- if ((minTokenRecieve > tokenSendAmount))
179- then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
180- else {
181- let assetIdSent = assetIdTokenA
182-[IntegerEntry("amountTokenA", (amountTokenA - tokenSendAmount)), IntegerEntry("amountTokenB", (amountTokenB + tokenReceiveAmount)), IntegerEntry("exchange_count", (count + 1)), ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]
183- }
258+ let tokenSendAmount = calculateHowManySendTokenA(amountToSendEstimated, minTokenRecieveAmount, amountTokenA, amountTokenB, tokenReceiveAmount)
259+ let assetIdSent = assetIdTokenA
260+[IntegerEntry("amountTokenA", (amountTokenA - tokenSendAmount)), IntegerEntry("amountTokenB", (amountTokenB + tokenReceiveAmount)), IntegerEntry("exchange_count", (count + 1)), IntegerEntry("invariant", invariantCalc((amountTokenA - tokenSendAmount), (amountTokenB + tokenReceiveAmount))), ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]
184261 }
185262 else if ((assetIdReceived == assetIdTokenA))
186263 then {
187- let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (comissionScaleDelimiter - comission)) / comissionScaleDelimiter)
188- if ((minTokenRecieve > tokenSendAmount))
189- then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
190- else {
191- let assetIdSent = assetIdTokenB
192-[IntegerEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), IntegerEntry("amountTokenB", (amountTokenB - tokenSendAmount)), IntegerEntry("exchange_count", (count + 1)), ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]
193- }
264+ let tokenSendAmount = calculateHowManySendTokenB(amountToSendEstimated, minTokenRecieveAmount, amountTokenA, amountTokenB, tokenReceiveAmount)
265+ let assetIdSent = assetIdTokenB
266+[IntegerEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), IntegerEntry("amountTokenB", (amountTokenB - tokenSendAmount)), IntegerEntry("exchange_count", (count + 1)), IntegerEntry("invariant", invariantCalc((amountTokenA + tokenReceiveAmount), (amountTokenB - tokenSendAmount))), ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]
194267 }
195268 else throw("Asset is not allowed")
196269 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let IdTokenA = getStringValue(this, "assetIdTokenA")
55
66 let IdTokenB = getStringValue(this, "assetIdTokenB")
77
8-let amountTokenB = getIntegerValue(this, "amountTokenB")
8+let IdTokenShare = getStringValue(this, "share_token_id")
99
10-let amountTokenA = getIntegerValue(this, "amountTokenA")
10+let dAppTokensAmountA = getIntegerValue(this, "amountTokenA")
1111
12-let assetIdTokenShare = getBinaryValue(this, "share_token_id")
12+let dAppTokensAmountB = getIntegerValue(this, "amountTokenB")
1313
1414 let tokenShareSupply = getIntegerValue(this, "share_token_supply")
1515
16-let comission = 500
16+let comission = 0
1717
18-let comissionScaleDelimiter = 1000000
18+let comissionScaleDelimiter = 10000
1919
20-let version = "1.0.0"
20+let version = "2.0.0"
21+
22+let invariant = getIntegerValue(this, "invariant")
2123
2224 let scaleValue8 = 100000000
25+
26+let scaleValue8Digits = 8
27+
28+let scaleValue12 = 1000000000000
2329
2430 let ratioThresholdMax = 100000000
2531
2632 let ratioThresholdMin = 99999000
2733
28-let scaleValue8Digits = 8
34+let alpha = 50
35+
36+let alphaDigits = 2
37+
38+let betta = 46
39+
40+let bettaDigits = 2
41+
42+func skeweness (x,y) = ((fraction(scaleValue8, x, y) + fraction(scaleValue8, y, x)) / 2)
43+
44+
45+func invariantCalc (x,y) = {
46+ let sk = skeweness(x, y)
47+ (fraction((x + y), pow(sk, scaleValue8Digits, -(alpha), alphaDigits, 8, HALFDOWN), scaleValue8) + (2 * fraction(fraction(pow(x, 0, 5, 1, scaleValue8Digits, HALFDOWN), pow(y, 0, 5, 1, scaleValue8Digits, HALFDOWN), (scaleValue8 * scaleValue8)), pow((sk - ((betta * scaleValue8) / 100)), 0, alpha, alphaDigits, scaleValue8Digits, HALFDOWN), scaleValue12)))
48+ }
49+
2950
3051 func assetId (asset) = if ((asset == "WAVES"))
3152 then unit
3253 else fromBase58String(asset)
3354
3455
56+func calculateHowManySendTokenA (amountToSendEstimated,minTokenRecieveAmount,amountTokenA,amountTokenB,tokenReceiveAmount) = {
57+ let slippageValue = (scaleValue8 - ((scaleValue8 * 1) / 10000))
58+ let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantCalc((amountTokenA - amountToSendEstimated), (amountTokenB + tokenReceiveAmount)))
59+ if (if ((invariantEstimatedRatio > slippageValue))
60+ then (scaleValue8 > invariantEstimatedRatio)
61+ else false)
62+ then ((amountToSendEstimated * (comissionScaleDelimiter - comission)) / comissionScaleDelimiter)
63+ else throw("price has changed dramatically. err2")
64+ }
65+
66+
67+func calculateHowManySendTokenB (amountToSendEstimated,minTokenRecieveAmount,amountTokenA,amountTokenB,tokenReceiveAmount) = {
68+ let slippageValue = (scaleValue8 - ((scaleValue8 * 1) / 10000))
69+ let invariantEstimatedRatio = fraction(invariant, scaleValue8, invariantCalc((amountTokenA + tokenReceiveAmount), (amountTokenB - amountToSendEstimated)))
70+ if (if ((invariantEstimatedRatio > slippageValue))
71+ then (scaleValue8 > invariantEstimatedRatio)
72+ else false)
73+ then ((amountToSendEstimated * (comissionScaleDelimiter - comission)) / comissionScaleDelimiter)
74+ else throw("price has changed dramatically. err2")
75+ }
76+
77+
3578 let assetIdTokenA = assetId(IdTokenA)
3679
3780 let assetIdTokenB = assetId(IdTokenB)
81+
82+let assetIdTokenShare = fromBase58String(IdTokenShare)
3883
3984 @Callable(contextObj)
4085 func fund () = {
4186 let paymentA = value(contextObj.payments[0])
4287 let paymentB = value(contextObj.payments[1])
4388 let assetIdReceivedA = paymentA.assetId
4489 let tokenReceiveAmountA = paymentA.amount
4590 let assetIdReceivedB = paymentB.assetId
4691 let tokenReceiveAmountB = paymentB.amount
4792 let digitTokenA = match assetIdReceivedA {
4893 case p: Unit =>
4994 8
5095 case p: ByteVector =>
5196 value(assetInfo(p)).decimals
5297 case _ =>
5398 throw("Match error")
5499 }
55100 let digitTokenB = match assetIdReceivedB {
56101 case p: Unit =>
57102 8
58103 case p: ByteVector =>
59104 value(assetInfo(p)).decimals
60105 case _ =>
61106 throw("Match error")
62107 }
63108 if (isDefined(getBoolean(this, "status")))
64109 then throw("already active")
65110 else {
66111 let shareTokenName = ("ShareT_" + takeRight(toString(this), 5))
67112 let digitsInShareToken = ((digitTokenA + digitTokenB) / 2)
68113 let shareTokenInitialAmount = fraction(pow(tokenReceiveAmountA, digitTokenA, 5, 1, digitTokenA, HALFDOWN), pow(tokenReceiveAmountB, digitTokenB, 5, 1, digitTokenB, HALFDOWN), pow(10, 0, digitsInShareToken, 0, 0, HALFDOWN))
69114 let shareTokenAssetId = calculateAssetId(Issue(shareTokenName, shareTokenName, shareTokenInitialAmount, digitsInShareToken, true))
70115 let assetIdTokenStringA = match assetIdReceivedA {
71116 case t: Unit =>
72117 "WAVES"
73118 case t: ByteVector =>
74119 toBase58String(value(assetIdReceivedA))
75120 case _ =>
76121 throw("Match error")
77122 }
78123 let assetIdTokenStringB = match assetIdReceivedB {
79124 case t: Unit =>
80125 "WAVES"
81126 case t: ByteVector =>
82127 toBase58String(value(assetIdReceivedB))
83128 case _ =>
84129 throw("Match error")
85130 }
86-[IntegerEntry("amountTokenA", tokenReceiveAmountA), IntegerEntry("amountTokenB", tokenReceiveAmountB), StringEntry("assetIdTokenA", assetIdTokenStringA), StringEntry("assetIdTokenB", assetIdTokenStringB), IntegerEntry("exchange_count", 0), BooleanEntry("status", true), IntegerEntry("comission", comission), IntegerEntry("comissionScaleDelimiter", comissionScaleDelimiter), StringEntry("version", version), Issue(shareTokenName, shareTokenName, shareTokenInitialAmount, digitsInShareToken, true), ScriptTransfer(contextObj.caller, shareTokenInitialAmount, shareTokenAssetId), BinaryEntry("share_token_id", shareTokenAssetId), IntegerEntry("share_token_supply", shareTokenInitialAmount)]
131+ let invariantCalcualated = invariantCalc(tokenReceiveAmountA, tokenReceiveAmountB)
132+[IntegerEntry("amountTokenA", tokenReceiveAmountA), IntegerEntry("amountTokenB", tokenReceiveAmountB), StringEntry("assetIdTokenA", assetIdTokenStringA), StringEntry("assetIdTokenB", assetIdTokenStringB), IntegerEntry("invariant", invariantCalcualated), IntegerEntry("exchange_count", 0), BooleanEntry("status", true), IntegerEntry("comission", comission), IntegerEntry("comissionScaleDelimiter", comissionScaleDelimiter), StringEntry("version", version), Issue(shareTokenName, shareTokenName, shareTokenInitialAmount, digitsInShareToken, true), ScriptTransfer(contextObj.caller, shareTokenInitialAmount, shareTokenAssetId), StringEntry("share_token_id", toBase58String(shareTokenAssetId)), IntegerEntry("share_token_supply", shareTokenInitialAmount)]
87133 }
88134 }
89135
90136
91137
92138 @Callable(contextObj)
93-func replenishment () = {
139+func replenishmentWithTwoToken () = {
94140 let paymentA = value(contextObj.payments[0])
95141 let paymentB = value(contextObj.payments[1])
96142 let assetIdReceivedA = paymentA.assetId
97143 let tokenReceiveAmountA = paymentA.amount
98144 let assetIdReceivedB = paymentB.assetId
99145 let tokenReceiveAmountB = paymentB.amount
100- let dAppTokensAmountA = getIntegerValue(this, "amountTokenA")
101- let dAppTokensAmountB = getIntegerValue(this, "amountTokenB")
146+ let invariantCalcualated = invariantCalc((dAppTokensAmountA + tokenReceiveAmountA), (dAppTokensAmountB + tokenReceiveAmountB))
102147 if (if ((assetIdReceivedA != assetIdTokenA))
103148 then true
104149 else (assetIdReceivedB != assetIdTokenB))
105150 then throw("incorrect assets")
106151 else {
107- let tokenRatio = (fraction(tokenReceiveAmountA, (1000000000000 * 100000), dAppTokensAmountA) / fraction(dAppTokensAmountB, 1000000000000, tokenReceiveAmountB))
108- if (!(if ((tokenRatio > 99990))
109- then (100010 > tokenRatio)
152+ let tokenRatio = (fraction(tokenReceiveAmountA, (1000000000000 * 1000), dAppTokensAmountA) / fraction(dAppTokensAmountB, 1000000000000, tokenReceiveAmountB))
153+ if (!(if ((tokenRatio > 990))
154+ then (1010 > tokenRatio)
110155 else false))
111156 then throw("incorrect assets amount")
112157 else {
113158 let shareTokenToPayAmount = fraction(tokenReceiveAmountA, tokenShareSupply, dAppTokensAmountA)
114159 if ((shareTokenToPayAmount == 0))
115160 then throw("you try replansish with very small amount")
116- else [Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenA", (dAppTokensAmountA + tokenReceiveAmountA)), IntegerEntry("amountTokenB", (dAppTokensAmountB + tokenReceiveAmountB))]
161+ else [Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenA", (dAppTokensAmountA + tokenReceiveAmountA)), IntegerEntry("amountTokenB", (dAppTokensAmountB + tokenReceiveAmountB)), IntegerEntry("invariant", invariantCalcualated)]
117162 }
118163 }
119164 }
120165
121166
122167
123168 @Callable(contextObj)
124-func replanishmentWithOneToken () = {
169+func replanishmentWithOneToken (tokenAamountWithOldInvariantNewPrice,tokenBamountWithOldInvariantNewPrice) = {
125170 let payment = value(contextObj.payments[0])
126171 let assetIdReceived = payment.assetId
127172 let tokenReceiveAmount = payment.amount
128173 if ((assetIdReceived == assetIdTokenA))
129174 then {
130- let newAmountTokenA = (amountTokenA + tokenReceiveAmount)
131- let priceAtoBwith8digits = fraction(newAmountTokenA, scaleValue8, amountTokenB)
132- let tokenAmountBNewPriceOldInvariant = pow(fraction(amountTokenA, amountTokenB, priceAtoBwith8digits), 0, 5, 1, 0, HALFDOWN)
133- let newTokenShareSupply = fraction(amountTokenB, tokenShareSupply, tokenAmountBNewPriceOldInvariant)
134- let shareTokenToPayAmount = (newTokenShareSupply - tokenShareSupply)
135-[Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenA", newAmountTokenA)]
175+ let newAmountTokenA = (dAppTokensAmountA + tokenReceiveAmount)
176+ let newInvariant = invariantCalc(newAmountTokenA, dAppTokensAmountB)
177+ let priceAtoBwith8digits = fraction(newAmountTokenA, scaleValue8, dAppTokensAmountB)
178+ let isCorrectPriceRation = fraction(tokenBamountWithOldInvariantNewPrice, priceAtoBwith8digits, tokenAamountWithOldInvariantNewPrice)
179+ if (if ((isCorrectPriceRation > ratioThresholdMax))
180+ then true
181+ else (ratioThresholdMin > isCorrectPriceRation))
182+ then throw("incorrect function args: price")
183+ else {
184+ let calculatedInvariantWithNewPrice = invariantCalc(tokenAamountWithOldInvariantNewPrice, tokenBamountWithOldInvariantNewPrice)
185+ let isCorrectInvariantRation = fraction(calculatedInvariantWithNewPrice, scaleValue8, invariant)
186+ if (if ((isCorrectInvariantRation > ratioThresholdMax))
187+ then true
188+ else (ratioThresholdMin > isCorrectInvariantRation))
189+ then throw("incorrect function args: invariant")
190+ else {
191+ let newTokenShareSupply = fraction(tokenBamountWithOldInvariantNewPrice, tokenShareSupply, dAppTokensAmountB)
192+ let shareTokenToPayAmount = (newTokenShareSupply - tokenShareSupply)
193+[Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenA", newAmountTokenA), IntegerEntry("invariant", newInvariant)]
194+ }
195+ }
136196 }
137197 else if ((assetIdReceived == assetIdTokenB))
138198 then {
139- let newAmountTokenB = (amountTokenB + tokenReceiveAmount)
140- let priceAtoBwith8digits = fraction(amountTokenA, scaleValue8, newAmountTokenB)
141- let tokenAmountBNewPriceOldInvariant = pow(fraction(amountTokenA, amountTokenB, priceAtoBwith8digits), 0, 5, 1, 0, HALFDOWN)
142- let newTokenShareSupply = fraction(amountTokenB, tokenShareSupply, tokenAmountBNewPriceOldInvariant)
143- let shareTokenToPayAmount = (newTokenShareSupply - tokenShareSupply)
144-[Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenB", newAmountTokenB)]
199+ let newAmountTokenB = (dAppTokensAmountB + tokenReceiveAmount)
200+ let newInvariant = invariantCalc(dAppTokensAmountA, newAmountTokenB)
201+ let priceAtoBwith8digits = fraction(dAppTokensAmountA, scaleValue8, newAmountTokenB)
202+ let isCorrectPriceRation = fraction(tokenBamountWithOldInvariantNewPrice, priceAtoBwith8digits, tokenAamountWithOldInvariantNewPrice)
203+ if (if ((isCorrectPriceRation > ratioThresholdMax))
204+ then true
205+ else (ratioThresholdMin > isCorrectPriceRation))
206+ then throw("incorrect function args: price")
207+ else {
208+ let calculatedInvariantWithNewPrice = invariantCalc(tokenAamountWithOldInvariantNewPrice, tokenBamountWithOldInvariantNewPrice)
209+ let isCorrectInvariantRation = fraction(calculatedInvariantWithNewPrice, scaleValue8, invariant)
210+ if (if ((isCorrectInvariantRation > ratioThresholdMax))
211+ then true
212+ else (ratioThresholdMin > isCorrectInvariantRation))
213+ then throw("incorrect function args: invariant")
214+ else {
215+ let newTokenShareSupply = fraction(tokenBamountWithOldInvariantNewPrice, tokenShareSupply, dAppTokensAmountB)
216+ let shareTokenToPayAmount = (newTokenShareSupply - tokenShareSupply)
217+[Reissue(assetIdTokenShare, shareTokenToPayAmount, true), ScriptTransfer(contextObj.caller, shareTokenToPayAmount, assetIdTokenShare), IntegerEntry("share_token_supply", (tokenShareSupply + shareTokenToPayAmount)), IntegerEntry("amountTokenB", newAmountTokenB), IntegerEntry("invariant", newInvariant)]
218+ }
219+ }
145220 }
146221 else throw("incorrect assets in payment")
147222 }
148223
149224
150225
151226 @Callable(contextObj)
152227 func withdraw () = {
153- let dAppTokensAmountA = getIntegerValue(this, "amountTokenA")
154- let dAppTokensAmountB = getIntegerValue(this, "amountTokenB")
155228 let payment = value(contextObj.payments[0])
156229 let assetIdReceived = payment.assetId
157230 let tokenReceiveAmount = payment.amount
158231 if ((assetIdTokenShare != assetIdReceived))
159232 then throw(("you need to attach share token for this dApp " + toBase58String(assetIdTokenShare)))
160233 else {
161234 let tokensToPayA = fraction(tokenReceiveAmount, dAppTokensAmountA, tokenShareSupply)
162235 let tokensToPayB = fraction(tokenReceiveAmount, dAppTokensAmountB, tokenShareSupply)
163-[ScriptTransfer(contextObj.caller, tokensToPayA, assetIdTokenA), ScriptTransfer(contextObj.caller, tokensToPayB, assetIdTokenB), IntegerEntry("amountTokenA", (dAppTokensAmountA - tokensToPayA)), IntegerEntry("amountTokenB", (dAppTokensAmountB - tokensToPayB)), IntegerEntry("share_token_supply", (tokenShareSupply - tokenReceiveAmount)), Burn(assetIdTokenShare, tokenReceiveAmount)]
236+ let invariantCalcualated = invariantCalc((dAppTokensAmountA - tokensToPayA), (dAppTokensAmountB - tokensToPayB))
237+[IntegerEntry("amountTokenA", (dAppTokensAmountA - tokensToPayA)), IntegerEntry("amountTokenB", (dAppTokensAmountB - tokensToPayB)), IntegerEntry("share_token_supply", (tokenShareSupply - tokenReceiveAmount)), ScriptTransfer(contextObj.caller, tokensToPayA, assetIdTokenA), ScriptTransfer(contextObj.caller, tokensToPayB, assetIdTokenB), Burn(assetIdTokenShare, tokenReceiveAmount), IntegerEntry("invariant", invariantCalcualated)]
164238 }
165239 }
166240
167241
168242
169243 @Callable(contextObj)
170-func exchanger (minTokenRecieve) = {
244+func exchanger (amountToSendEstimated,minTokenRecieveAmount) = {
245+ let amountTokenB = getIntegerValue(this, "amountTokenB")
246+ let amountTokenA = getIntegerValue(this, "amountTokenA")
171247 let payment = value(contextObj.payments[0])
172248 let assetIdReceived = payment.assetId
173249 let tokenReceiveAmount = payment.amount
174- let count = value(getInteger(this, "exchange_count"))
250+ let count = match getInteger(this, "exchange_count") {
251+ case i: Int =>
252+ (value(getInteger(this, "exchange_count")) + i)
253+ case _ =>
254+ 0
255+ }
175256 if ((assetIdReceived == assetIdTokenB))
176257 then {
177- let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (comissionScaleDelimiter - comission)) / comissionScaleDelimiter)
178- if ((minTokenRecieve > tokenSendAmount))
179- then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
180- else {
181- let assetIdSent = assetIdTokenA
182-[IntegerEntry("amountTokenA", (amountTokenA - tokenSendAmount)), IntegerEntry("amountTokenB", (amountTokenB + tokenReceiveAmount)), IntegerEntry("exchange_count", (count + 1)), ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]
183- }
258+ let tokenSendAmount = calculateHowManySendTokenA(amountToSendEstimated, minTokenRecieveAmount, amountTokenA, amountTokenB, tokenReceiveAmount)
259+ let assetIdSent = assetIdTokenA
260+[IntegerEntry("amountTokenA", (amountTokenA - tokenSendAmount)), IntegerEntry("amountTokenB", (amountTokenB + tokenReceiveAmount)), IntegerEntry("exchange_count", (count + 1)), IntegerEntry("invariant", invariantCalc((amountTokenA - tokenSendAmount), (amountTokenB + tokenReceiveAmount))), ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]
184261 }
185262 else if ((assetIdReceived == assetIdTokenA))
186263 then {
187- let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (comissionScaleDelimiter - comission)) / comissionScaleDelimiter)
188- if ((minTokenRecieve > tokenSendAmount))
189- then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
190- else {
191- let assetIdSent = assetIdTokenB
192-[IntegerEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), IntegerEntry("amountTokenB", (amountTokenB - tokenSendAmount)), IntegerEntry("exchange_count", (count + 1)), ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]
193- }
264+ let tokenSendAmount = calculateHowManySendTokenB(amountToSendEstimated, minTokenRecieveAmount, amountTokenA, amountTokenB, tokenReceiveAmount)
265+ let assetIdSent = assetIdTokenB
266+[IntegerEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), IntegerEntry("amountTokenB", (amountTokenB - tokenSendAmount)), IntegerEntry("exchange_count", (count + 1)), IntegerEntry("invariant", invariantCalc((amountTokenA + tokenReceiveAmount), (amountTokenB - tokenSendAmount))), ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]
194267 }
195268 else throw("Asset is not allowed")
196269 }
197270
198271

github/deemru/w8io/169f3d6 
62.99 ms