tx · BMXPWUrZNuz1rf9srKZvyfhnD3ShTL7cREM2DvXSpgCU 3N4w7wVkViML11XdFL5xNkPofVVg1nLWEmX: -0.01400000 Waves 2019.07.04 19:06 [570914] smart account 3N4w7wVkViML11XdFL5xNkPofVVg1nLWEmX > SELF 0.00000000 Waves
{ "type": 13, "id": "BMXPWUrZNuz1rf9srKZvyfhnD3ShTL7cREM2DvXSpgCU", "fee": 1400000, "feeAssetId": null, "timestamp": 1562256391903, "version": 1, "sender": "3N4w7wVkViML11XdFL5xNkPofVVg1nLWEmX", "senderPublicKey": "EKGwbPjcrwuWgDm8Ed9HAGmxMviCRgqTkQDVt4rYbyre", "proofs": [ "F1SjtAjvJ1ZWAkFgY1JrZAaHBn4q3xvzVmL9REHXpbi6ft64R7FQsQiADPmnUFNRwquWstHpnBo6vZ7eCDZf2FC" ], "script": "base64:AAIDAAAAAAAAAAAAAAADAAAAAAVvd25lcgEAAAAaAVTvvhtsl5a8uJsx9lmVjj72aCuw5r86MC8AAAAADUxpcXVpZEFzc2V0SWQBAAAAIOko/8ffrEF7C8jHeLG92rw5x2KlLkjVtarJvVMwnDvrAAAAAAdXQVZFU0lEBQAAAAR1bml0AAAAAgAAAApjb250ZXh0T2JqAQAAAAd1bmlzd2FwAAAAAgAAAAljb21pc3Npb24AAAANbWluUHJpY2VMZXZlbAMDCQAAZgAAAAIAAAAAAAAAAAAFAAAACWNvbWlzc2lvbgYJAABmAAAAAgUAAAAJY29taXNzaW9uAAAAAAAAAABkCQAAAgAAAAECAAAAGWluY29ycmVjdCBjb21pc3Npb24gdmFsdWUEAAAAC3dhdmVzQW1vdW50CQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAAAt3YXZlc0Ftb3VudAQAAAAMbGlxdWlkQW1vdW50CQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAAAxsaXF1aWRBbW91bnQEAAAAB3BheW1lbnQEAAAAByRtYXRjaDAIBQ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lcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAAPdG9rZW5TZW5kQW1vdW50BQAAAAthc3NldElkU2VudAUAAAADbmlsCQAAAgAAAAECAAAAFEFzc2V0IGlzIG5vdCBhbGxvd2VkAAAACmNvbnRleHRPYmoBAAAACHdpdGhkcmF3AAAAAAQAAAANTGlxdWlkQmFsYW5jZQkAA+sAAAACBQAAAAR0aGlzBQAAAA1MaXF1aWRBc3NldElkBAAAAAxXYXZlc0JhbGFuY2UJAQAAAAx3YXZlc0JhbGFuY2UAAAABBQAAAAR0aGlzAwkAAAAAAAACCAgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyAAAABWJ5dGVzBQAAAAVvd25lcgkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAICAAAADGxpcXVpZEFtb3VudAIAAAAJd2l0aGRyYXduCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAAt3YXZlc0Ftb3VudAIAAAAJd2l0aGRyYXduBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyBQAAAA1MaXF1aWRCYWxhbmNlBQAAAA1MaXF1aWRBc3NldElkCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAAMV2F2ZXNCYWxhbmNlBQAAAAR1bml0BQAAAANuaWwJAAACAAAAAQIAAAAdWW91IGFyZSBub3QgZXhjaGFuZ2VyJ3Mgb3duZXIAAAABAAAACmNvbnRleHRPYmoBAAAABnZlcmlmeQAAAAAGEpJBfQ==", "chainId": 84, "height": 570914, "spentComplexity": 0 } View: original | compacted Prev: D3kvAU2yc7xAoovQEq4iZd6FMgHBRMWjsPDbzo6REskx Next: C6BfHa54RubtNkmR6dyt5DTofdEp34i7eBQ2nDi2tWvY Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let owner = base58'3NBmj1eEDJmrQ16GJkmVU1p31MTURgoV38r' | |
5 | + | ||
6 | + | let LiquidAssetId = base58'GhAFhXzwCYfvcXQ3GHFaQFnCzAuYCT156qFqiYyzfkzv' | |
7 | + | ||
8 | + | let WAVESID = unit | |
9 | + | ||
10 | + | @Callable(contextObj) | |
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)) | |
27 | + | then { | |
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 | + | } | |
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 | + | } | |
48 | + | ||
4 | 49 | ||
5 | 50 | ||
6 | 51 | @Callable(contextObj) | |
7 | - | func uniswap () = { | |
8 | - | let LiquidAssetId = base58'GhAFhXzwCYfvcXQ3GHFaQFnCzAuYCT156qFqiYyzfkzv' | |
9 | - | let wavesAmount = getIntegerValue(this, "wavesAmount") | |
10 | - | let liquidAmount = getIntegerValue(this, "liquidAmount") | |
11 | - | let payment = match contextObj.payment { | |
12 | - | case p: AttachedPayment => | |
13 | - | p | |
14 | - | case _ => | |
15 | - | throw("Payment not attached") | |
16 | - | } | |
17 | - | let assetIdReceived = payment.assetId | |
18 | - | let tokenReceiveAmount = payment.amount | |
19 | - | if ((assetIdReceived == unit)) | |
20 | - | then { | |
21 | - | let tokenSendAmount = fraction(liquidAmount, tokenReceiveAmount, (tokenReceiveAmount + wavesAmount)) | |
22 | - | let assetIdSent = LiquidAssetId | |
23 | - | ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount - tokenSendAmount)), DataEntry("wavesAmount", (wavesAmount + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
24 | - | } | |
25 | - | else if ((assetIdReceived == LiquidAssetId)) | |
26 | - | then { | |
27 | - | let tokenSendAmount = fraction(wavesAmount, tokenReceiveAmount, (tokenReceiveAmount + liquidAmount)) | |
28 | - | let assetIdSent = unit | |
29 | - | ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount + tokenReceiveAmount)), DataEntry("wavesAmount", (wavesAmount - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
30 | - | } | |
31 | - | else throw("Asset is not allowed") | |
52 | + | func withdraw () = { | |
53 | + | let LiquidBalance = assetBalance(this, LiquidAssetId) | |
54 | + | let WavesBalance = wavesBalance(this) | |
55 | + | if ((contextObj.caller.bytes == owner)) | |
56 | + | then ScriptResult(WriteSet([DataEntry("liquidAmount", "withdrawn"), DataEntry("wavesAmount", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, LiquidBalance, LiquidAssetId), ScriptTransfer(contextObj.caller, WavesBalance, unit)])) | |
57 | + | else throw("You are not exchanger's owner") | |
32 | 58 | } | |
33 | 59 | ||
60 | + | ||
61 | + | @Verifier(contextObj) | |
62 | + | func verify () = true | |
34 | 63 |
github/deemru/w8io/026f985 41.23 ms ◑