tx · CDX9KYjmN7g1reFWuXq6CeJj7H1WvrCTTMeWtBnckchx 3MpVFGJWgiGyh5LmE1nxNLsjjtSL3Bgh9NV: -0.01400000 Waves 2019.07.18 17:50 [591454] smart account 3MpVFGJWgiGyh5LmE1nxNLsjjtSL3Bgh9NV > SELF 0.00000000 Waves
{ "type": 13, "id": "CDX9KYjmN7g1reFWuXq6CeJj7H1WvrCTTMeWtBnckchx", "fee": 1400000, "feeAssetId": null, "timestamp": 1563461432874, "version": 1, "sender": "3MpVFGJWgiGyh5LmE1nxNLsjjtSL3Bgh9NV", "senderPublicKey": "854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa", "proofs": [ "48FNGbZk4Sw3Am9L5KCi3jrvxkb6J1WUr4NYhatW2wRZp1yNvom8tULhAGA9GszKMJLwA3qzrvBeX4uGwTPDDqgE" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAAAAAAVvd25lcgEAAAAaAVTvvhtsl5a8uJsx9lmVjj72aCuw5r86MC8AAAAADUxpcXVpZEFzc2V0SWQBAAAAIHBCjimyt7IbF+A5PbfgHl69Nj5vF05nQ3u/n6SWmToWAAAAAAdXQVZFU0lEBQAAAAR1bml0AAAAAAljb21pc3Npb24AAAAAAAAAAAAAAAACAAAACmNvbnRleHRPYmoBAAAACWV4Y2hhbmdlcgAAAAEAAAAPbWluVG9rZW5SZWNpZXZlBAAAAAt3YXZlc0Ftb3VudAkBAAAAEUBleHRyTmF0aXZlKDEwNTApAAAAAgUAAAAEdGhpcwIAAAALd2F2ZXNBbW91bnQEAAAADGxpcXVpZEFtb3VudAkBAAAAEUBleHRyTmF0aXZlKDEwNTApAAAAAgUAAAAEdGhpcwIAAAAMbGlxdWlkQW1vdW50BAAAAAdwYXltZW50BAAAAAckbWF0Y2gwCAUAAAAKY29udGV4dE9iagAAAAdwYXltZW50AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9BdHRhY2hlZFBheW1lbnQEAAAAAXAFAAAAByRtY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XRJZAQAAAAMV2F2ZXNCYWxhbmNlCQEAAAAMd2F2ZXNCYWxhbmNlAAAAAQUAAAAEdGhpcwMJAAAAAAAAAggIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgAAAAVieXRlcwUAAAAFb3duZXIJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAAxsaXF1aWRBbW91bnQCAAAACXdpdGhkcmF3bgkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAALd2F2ZXNBbW91bnQCAAAACXdpdGhkcmF3bgUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAANTGlxdWlkQmFsYW5jZQUAAAANTGlxdWlkQXNzZXRJZAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIFAAAADFdhdmVzQmFsYW5jZQUAAAAEdW5pdAUAAAADbmlsCQAAAgAAAAECAAAAHVlvdSBhcmUgbm90IGV4Y2hhbmdlcidzIG93bmVyAAAAAQAAAApjb250ZXh0T2JqAQAAAAZ2ZXJpZnkAAAAABkd0OuU=", "chainId": 84, "height": 591454, "spentComplexity": 0 } View: original | compacted Prev: 8vHTChqnq2mLz86DKdDtZV1yqCyWBPxYikVzKnPhd5xZ Next: 3JH4TD113CaBykNknW6hzoL7r7zDubPN9Xs84f69XFMq Diff:
Old | New | Differences | |
---|---|---|---|
23 | 23 | let tokenReceiveAmount = payment.amount | |
24 | 24 | if ((assetIdReceived == unit)) | |
25 | 25 | then { | |
26 | - | let tokenSendAmount = | |
26 | + | let tokenSendAmount = fraction(liquidAmount, tokenReceiveAmount, (tokenReceiveAmount + wavesAmount)) | |
27 | 27 | if ((minTokenRecieve > tokenSendAmount)) | |
28 | 28 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
29 | 29 | else { | |
33 | 33 | } | |
34 | 34 | else if ((assetIdReceived == LiquidAssetId)) | |
35 | 35 | then { | |
36 | - | let tokenSendAmount = | |
36 | + | let tokenSendAmount = fraction(wavesAmount, tokenReceiveAmount, (tokenReceiveAmount + liquidAmount)) | |
37 | 37 | if ((minTokenRecieve > tokenSendAmount)) | |
38 | 38 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
39 | 39 | else { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let owner = base58'3NBmj1eEDJmrQ16GJkmVU1p31MTURgoV38r' | |
5 | 5 | ||
6 | 6 | let LiquidAssetId = base58'8ZDXPncY5ypuMoAY4Ec9hCH2eMbgVpSYtGXK7SzkzmQy' | |
7 | 7 | ||
8 | 8 | let WAVESID = unit | |
9 | 9 | ||
10 | 10 | let comission = 0 | |
11 | 11 | ||
12 | 12 | @Callable(contextObj) | |
13 | 13 | func exchanger (minTokenRecieve) = { | |
14 | 14 | let wavesAmount = getIntegerValue(this, "wavesAmount") | |
15 | 15 | let liquidAmount = getIntegerValue(this, "liquidAmount") | |
16 | 16 | let payment = match contextObj.payment { | |
17 | 17 | case p: AttachedPayment => | |
18 | 18 | p | |
19 | 19 | case _ => | |
20 | 20 | throw("Payment not attached") | |
21 | 21 | } | |
22 | 22 | let assetIdReceived = payment.assetId | |
23 | 23 | let tokenReceiveAmount = payment.amount | |
24 | 24 | if ((assetIdReceived == unit)) | |
25 | 25 | then { | |
26 | - | let tokenSendAmount = | |
26 | + | let tokenSendAmount = fraction(liquidAmount, tokenReceiveAmount, (tokenReceiveAmount + wavesAmount)) | |
27 | 27 | if ((minTokenRecieve > tokenSendAmount)) | |
28 | 28 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
29 | 29 | else { | |
30 | 30 | let assetIdSent = LiquidAssetId | |
31 | 31 | ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount - tokenSendAmount)), DataEntry("wavesAmount", (wavesAmount + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
32 | 32 | } | |
33 | 33 | } | |
34 | 34 | else if ((assetIdReceived == LiquidAssetId)) | |
35 | 35 | then { | |
36 | - | let tokenSendAmount = | |
36 | + | let tokenSendAmount = fraction(wavesAmount, tokenReceiveAmount, (tokenReceiveAmount + liquidAmount)) | |
37 | 37 | if ((minTokenRecieve > tokenSendAmount)) | |
38 | 38 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
39 | 39 | else { | |
40 | 40 | let assetIdSent = unit | |
41 | 41 | ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount + tokenReceiveAmount)), DataEntry("wavesAmount", (wavesAmount - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
42 | 42 | } | |
43 | 43 | } | |
44 | 44 | else throw("Asset is not allowed") | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | ||
49 | 49 | @Callable(contextObj) | |
50 | 50 | func withdraw () = { | |
51 | 51 | let LiquidBalance = assetBalance(this, LiquidAssetId) | |
52 | 52 | let WavesBalance = wavesBalance(this) | |
53 | 53 | if ((contextObj.caller.bytes == owner)) | |
54 | 54 | then ScriptResult(WriteSet([DataEntry("liquidAmount", "withdrawn"), DataEntry("wavesAmount", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, LiquidBalance, LiquidAssetId), ScriptTransfer(contextObj.caller, WavesBalance, unit)])) | |
55 | 55 | else throw("You are not exchanger's owner") | |
56 | 56 | } | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | @Verifier(contextObj) | |
60 | 60 | func verify () = true | |
61 | 61 |
github/deemru/w8io/169f3d6 43.97 ms ◑