tx · 4Ews9mKFeKby29MCBoA5fFBq59BR5b1LHauVe1AfYk4t

3MpVFGJWgiGyh5LmE1nxNLsjjtSL3Bgh9NV:  -0.01400000 Waves

2019.07.04 19:07 [570915] smart account 3MpVFGJWgiGyh5LmE1nxNLsjjtSL3Bgh9NV > SELF 0.00000000 Waves

{ "type": 13, "id": "4Ews9mKFeKby29MCBoA5fFBq59BR5b1LHauVe1AfYk4t", "fee": 1400000, "feeAssetId": null, "timestamp": 1562256447727, "version": 1, "sender": "3MpVFGJWgiGyh5LmE1nxNLsjjtSL3Bgh9NV", "senderPublicKey": "854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa", "proofs": [ "3ew4NhveAwtr65aMXMtVcoQTtAakFdg39sf2zttPJ8AcEX8oS5DUuzbV38mXA95MTD93fQRSnWYxnzhivB21gAt2" ], "script": "base64:AAIDAAAAAAAAAAAAAAADAAAAAAVvd25lcgEAAAAaAVTvvhtsl5a8uJsx9lmVjj72aCuw5r86MC8AAAAADUxpcXVpZEFzc2V0SWQBAAAAIOko/8ffrEF7C8jHeLG92rw5x2KlLkjVtarJvVMwnDvrAAAAAAdXQVZFU0lEBQAAAAR1bml0AAAAAgAAAApjb250ZXh0T2JqAQAAAAd1bmlzd2FwAAAAAgAAAAljb21pc3Npb24AAAANbWluUHJpY2VMZXZlbAMDCQAAZgAAAAIAAAAAAAAAAAAFAAAACWNvbWlzc2lvbgYJAABmAAAAAgUAAAAJY29taXNzaW9uAAAAAAAAAABkCQAAAgAAAAECAAAAGWluY29ycmVjdCBjb21pc3Npb24gdmFsdWUEAAAAC3dhdmVzQW1vdW50CQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAAAt3YXZlc0Ftb3VudAQAAAAMbGlxdWlkQW1vdW50CQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAAAxsaXF1aWRBbW91bnQEAAAAB3BheW1lbnQEAAAAByRtYXRja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uc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAAPdG9rZW5TZW5kQW1vdW50BQAAAAthc3NldElkU2VudAUAAAADbmlsCQAAAgAAAAECAAAAFEFzc2V0IGlzIG5vdCBhbGxvd2VkAAAACmNvbnRleHRPYmoBAAAACHdpdGhkcmF3AAAAAAQAAAANTGlxdWlkQmFsYW5jZQkAA+sAAAACBQAAAAR0aGlzBQAAAA1MaXF1aWRBc3NldElkBAAAAAxXYXZlc0JhbGFuY2UJAQAAAAx3YXZlc0JhbGFuY2UAAAABBQAAAAR0aGlzAwkAAAAAAAACCAgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyAAAABWJ5dGVzBQAAAAVvd25lcgkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAICAAAADGxpcXVpZEFtb3VudAIAAAAJd2l0aGRyYXduCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAAt3YXZlc0Ftb3VudAIAAAAJd2l0aGRyYXduBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyBQAAAA1MaXF1aWRCYWxhbmNlBQAAAA1MaXF1aWRBc3NldElkCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAAMV2F2ZXNCYWxhbmNlBQAAAAR1bml0BQAAAANuaWwJAAACAAAAAQIAAAAdWW91IGFyZSBub3QgZXhjaGFuZ2VyJ3Mgb3duZXIAAAABAAAACmNvbnRleHRPYmoBAAAABnZlcmlmeQAAAAAGEpJBfQ==", "chainId": 84, "height": 570915, "spentComplexity": 0 } View: original | compacted Prev: ANb2vzuxL1K4NQmSiAEirotyfUg4m7vM2XiCdCMgskXH Next: FraCVGDsA1iMrrESAmCnDXpWoNwB1RAAaAkFviFUJ5sH Diff:
OldNewDifferences
88 let WAVESID = unit
99
1010 @Callable(contextObj)
11-func uniswap (comission) = {
12- let wavesAmount = getIntegerValue(this, "wavesAmount")
13- let liquidAmount = getIntegerValue(this, "liquidAmount")
14- let payment = match contextObj.payment {
15- case p: AttachedPayment =>
16- p
17- case _ =>
18- throw("Payment not attached")
19- }
20- let assetIdReceived = payment.assetId
21- let tokenReceiveAmount = payment.amount
22- if ((assetIdReceived == unit))
23- then {
24- let tokenSendAmount = ((fraction(liquidAmount, tokenReceiveAmount, (tokenReceiveAmount + wavesAmount)) * (100 - comission)) / 100)
25- let assetIdSent = LiquidAssetId
26- ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount - tokenSendAmount)), DataEntry("wavesAmount", (wavesAmount + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
27- }
28- else if ((assetIdReceived == LiquidAssetId))
11+func uniswap (comission,minPriceLevel) = if (if ((0 > comission))
12+ then true
13+ else (comission > 100))
14+ then throw("incorrect comission value")
15+ else {
16+ let wavesAmount = getIntegerValue(this, "wavesAmount")
17+ let liquidAmount = getIntegerValue(this, "liquidAmount")
18+ let payment = match contextObj.payment {
19+ case p: AttachedPayment =>
20+ p
21+ case _ =>
22+ throw("Payment not attached")
23+ }
24+ let assetIdReceived = payment.assetId
25+ let tokenReceiveAmount = payment.amount
26+ if ((assetIdReceived == unit))
2927 then {
30- let tokenSendAmount = fraction(wavesAmount, tokenReceiveAmount, (tokenReceiveAmount + liquidAmount))
31- let assetIdSent = unit
32- ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount + tokenReceiveAmount)), DataEntry("wavesAmount", (wavesAmount - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
28+ let tokenSendAmount = ((fraction(liquidAmount, tokenReceiveAmount, (tokenReceiveAmount + wavesAmount)) * (100 - comission)) / 100)
29+ if ((minPriceLevel > tokenSendAmount))
30+ then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
31+ else {
32+ let assetIdSent = LiquidAssetId
33+ ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount - tokenSendAmount)), DataEntry("wavesAmount", (wavesAmount + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
34+ }
3335 }
34- else throw("Asset is not allowed")
35- }
36+ else if ((assetIdReceived == LiquidAssetId))
37+ then {
38+ let tokenSendAmount = ((fraction(wavesAmount, tokenReceiveAmount, (tokenReceiveAmount + liquidAmount)) * (100 - comission)) / 100)
39+ if ((minPriceLevel > tokenSendAmount))
40+ then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
41+ else {
42+ let assetIdSent = unit
43+ ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount + tokenReceiveAmount)), DataEntry("wavesAmount", (wavesAmount - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
44+ }
45+ }
46+ else throw("Asset is not allowed")
47+ }
3648
3749
3850
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let owner = base58'3NBmj1eEDJmrQ16GJkmVU1p31MTURgoV38r'
55
66 let LiquidAssetId = base58'GhAFhXzwCYfvcXQ3GHFaQFnCzAuYCT156qFqiYyzfkzv'
77
88 let WAVESID = unit
99
1010 @Callable(contextObj)
11-func uniswap (comission) = {
12- let wavesAmount = getIntegerValue(this, "wavesAmount")
13- let liquidAmount = getIntegerValue(this, "liquidAmount")
14- let payment = match contextObj.payment {
15- case p: AttachedPayment =>
16- p
17- case _ =>
18- throw("Payment not attached")
19- }
20- let assetIdReceived = payment.assetId
21- let tokenReceiveAmount = payment.amount
22- if ((assetIdReceived == unit))
23- then {
24- let tokenSendAmount = ((fraction(liquidAmount, tokenReceiveAmount, (tokenReceiveAmount + wavesAmount)) * (100 - comission)) / 100)
25- let assetIdSent = LiquidAssetId
26- ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount - tokenSendAmount)), DataEntry("wavesAmount", (wavesAmount + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
27- }
28- else if ((assetIdReceived == LiquidAssetId))
11+func uniswap (comission,minPriceLevel) = if (if ((0 > comission))
12+ then true
13+ else (comission > 100))
14+ then throw("incorrect comission value")
15+ else {
16+ let wavesAmount = getIntegerValue(this, "wavesAmount")
17+ let liquidAmount = getIntegerValue(this, "liquidAmount")
18+ let payment = match contextObj.payment {
19+ case p: AttachedPayment =>
20+ p
21+ case _ =>
22+ throw("Payment not attached")
23+ }
24+ let assetIdReceived = payment.assetId
25+ let tokenReceiveAmount = payment.amount
26+ if ((assetIdReceived == unit))
2927 then {
30- let tokenSendAmount = fraction(wavesAmount, tokenReceiveAmount, (tokenReceiveAmount + liquidAmount))
31- let assetIdSent = unit
32- ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount + tokenReceiveAmount)), DataEntry("wavesAmount", (wavesAmount - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
28+ let tokenSendAmount = ((fraction(liquidAmount, tokenReceiveAmount, (tokenReceiveAmount + wavesAmount)) * (100 - comission)) / 100)
29+ if ((minPriceLevel > tokenSendAmount))
30+ then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
31+ else {
32+ let assetIdSent = LiquidAssetId
33+ ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount - tokenSendAmount)), DataEntry("wavesAmount", (wavesAmount + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
34+ }
3335 }
34- else throw("Asset is not allowed")
35- }
36+ else if ((assetIdReceived == LiquidAssetId))
37+ then {
38+ let tokenSendAmount = ((fraction(wavesAmount, tokenReceiveAmount, (tokenReceiveAmount + liquidAmount)) * (100 - comission)) / 100)
39+ if ((minPriceLevel > tokenSendAmount))
40+ then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
41+ else {
42+ let assetIdSent = unit
43+ ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount + tokenReceiveAmount)), DataEntry("wavesAmount", (wavesAmount - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
44+ }
45+ }
46+ else throw("Asset is not allowed")
47+ }
3648
3749
3850
3951 @Callable(contextObj)
4052 func withdraw () = {
4153 let LiquidBalance = assetBalance(this, LiquidAssetId)
4254 let WavesBalance = wavesBalance(this)
4355 if ((contextObj.caller.bytes == owner))
4456 then ScriptResult(WriteSet([DataEntry("liquidAmount", "withdrawn"), DataEntry("wavesAmount", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, LiquidBalance, LiquidAssetId), ScriptTransfer(contextObj.caller, WavesBalance, unit)]))
4557 else throw("You are not exchanger's owner")
4658 }
4759
4860
4961 @Verifier(contextObj)
5062 func verify () = true
5163

github/deemru/w8io/169f3d6 
45.79 ms