tx · 9ns78H1h3uZ9rdJd1AJbnoGEANuwT1uZ26Jq1tiA9yYm 3MpVFGJWgiGyh5LmE1nxNLsjjtSL3Bgh9NV: -0.01400000 Waves 2019.08.30 16:08 [654026] smart account 3MpVFGJWgiGyh5LmE1nxNLsjjtSL3Bgh9NV > SELF 0.00000000 Waves
{ "type": 13, "id": "9ns78H1h3uZ9rdJd1AJbnoGEANuwT1uZ26Jq1tiA9yYm", "fee": 1400000, "feeAssetId": null, "timestamp": 1567170467078, "version": 1, "sender": "3MpVFGJWgiGyh5LmE1nxNLsjjtSL3Bgh9NV", "senderPublicKey": "854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa", "proofs": [ "3a1gWRvwcf8pKPX9DGDgeDu27TsiJcMvXxNZjdDx31mvBP6k1fNmETv5xvMQi6DwbpgUmAgpjRRko4NjD56hS5wm" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAAAAAAVvd25lcgEAAAAaAVRFbm0V+EOCq2NTOJsSE2133z0GcAjjvP8AAAAADWFzc2V0SWRUb2tlbkEBAAAAIEMzbeDGHf4oU+zuHGjXevUoBPuFN8LOz9CQD8ug/yo1AAAAAA1hc3NldElkVG9rZW5CAQAAACCqoUHYIr+9N/tCdWkhfZ3SevjX3HPTosOWNfoRj9syOgAAAAAJY29taXNzaW9uAAAAAAAAAAAKAAAABAAAAApjb250ZXh0T2JqAQAAAARmdW5kAAAAAAQAAAAHcGF5bWVudAQAAAAHJG1hdGNoMAgFAAAACmNvbnRleHRPYmoAAAAHcGF5bWVudAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPQXR0YWNoZWRQYXltZW50BAAAAAFwBQAAAAckbWF0Y2gwBQAAAAFwCQAAAgAAAAECAAAAFFBheW1lbnQgbm90IGF0dGFjaGVkBAAAAA9hc3NldElkUmVjZWl2ZWQIBQAAAAdwYXltZW50AAAAB2Fzc2V0SWQEAAAAEnRva2VuUmVjZWl2ZUFtb3VudAgFAAAAB3BheW1lb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AQAAAApjb250ZXh0T2JqAQAAAAZ2ZXJpZnkAAAAABm1XTIM=", "chainId": 84, "height": 654026, "spentComplexity": 0 } View: original | compacted Prev: 7N4UBN22zGYXZFsWzXE3XLQyiJayH2jtZk79tcBCM2YU Next: 89GMYyqTFG1YxNE81JHxnRb9KEb53Niv6P4srhuA8Lm8 Diff:
Old | New | Differences | |
---|---|---|---|
19 | 19 | } | |
20 | 20 | let assetIdReceived = payment.assetId | |
21 | 21 | let tokenReceiveAmount = payment.amount | |
22 | - | if (if ((assetIdReceived == assetIdTokenA)) | |
23 | - | then !(isDefined(getBoolean(this, "fundA"))) | |
24 | - | else false) | |
22 | + | if ((assetIdReceived == assetIdTokenA)) | |
25 | 23 | then WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("fundA", true)]) | |
26 | 24 | else if (if ((assetIdReceived == assetIdTokenB)) | |
27 | 25 | then !(isDefined(getBoolean(this, "fundB"))) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let owner = base58'3MvFCghS4jJ7E5QuJfKa4LwCoHJiAcsDQrA' | |
5 | 5 | ||
6 | 6 | let assetIdTokenA = base58'5XKoQDZphxtgtXxm36qhXrYo1F6mRLa9M8QHUDPWQ4mi' | |
7 | 7 | ||
8 | 8 | let assetIdTokenB = base58'CV4vfjkevn3aJ4tKaMn9gPHugYztu6RhDw2ete34SxiV' | |
9 | 9 | ||
10 | 10 | let comission = 10 | |
11 | 11 | ||
12 | 12 | @Callable(contextObj) | |
13 | 13 | func fund () = { | |
14 | 14 | let payment = match contextObj.payment { | |
15 | 15 | case p: AttachedPayment => | |
16 | 16 | p | |
17 | 17 | case _ => | |
18 | 18 | throw("Payment not attached") | |
19 | 19 | } | |
20 | 20 | let assetIdReceived = payment.assetId | |
21 | 21 | let tokenReceiveAmount = payment.amount | |
22 | - | if (if ((assetIdReceived == assetIdTokenA)) | |
23 | - | then !(isDefined(getBoolean(this, "fundA"))) | |
24 | - | else false) | |
22 | + | if ((assetIdReceived == assetIdTokenA)) | |
25 | 23 | then WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("fundA", true)]) | |
26 | 24 | else if (if ((assetIdReceived == assetIdTokenB)) | |
27 | 25 | then !(isDefined(getBoolean(this, "fundB"))) | |
28 | 26 | else false) | |
29 | 27 | then WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("fundB", true)]) | |
30 | 28 | else throw("already funded or you try to fund with incorrect asset") | |
31 | 29 | } | |
32 | 30 | ||
33 | 31 | ||
34 | 32 | ||
35 | 33 | @Callable(contextObj) | |
36 | 34 | func replenishment () = { | |
37 | 35 | let payment = match contextObj.payment { | |
38 | 36 | case p: AttachedPayment => | |
39 | 37 | p | |
40 | 38 | case _ => | |
41 | 39 | throw("Payment not attached") | |
42 | 40 | } | |
43 | 41 | let assetIdReceived = payment.assetId | |
44 | 42 | let tokenReceiveAmount = payment.amount | |
45 | 43 | if (if ((assetIdReceived == assetIdTokenA)) | |
46 | 44 | then isDefined(getBoolean(this, "fundA")) | |
47 | 45 | else false) | |
48 | 46 | then { | |
49 | 47 | let amountTokenA = getIntegerValue(this, "amountTokenA") | |
50 | 48 | WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount))]) | |
51 | 49 | } | |
52 | 50 | else if (if ((assetIdReceived == assetIdTokenB)) | |
53 | 51 | then isDefined(getBoolean(this, "fundB")) | |
54 | 52 | else false) | |
55 | 53 | then { | |
56 | 54 | let amountTokenB = getIntegerValue(this, "amountTokenB") | |
57 | 55 | WriteSet([DataEntry("amountTokenA", (amountTokenB + tokenReceiveAmount))]) | |
58 | 56 | } | |
59 | 57 | else throw("there was an error in the replenishment") | |
60 | 58 | } | |
61 | 59 | ||
62 | 60 | ||
63 | 61 | ||
64 | 62 | @Callable(contextObj) | |
65 | 63 | func exchanger (minTokenRecieve) = if (if ((0 > comission)) | |
66 | 64 | then true | |
67 | 65 | else (comission > 100)) | |
68 | 66 | then throw("incorrect comission value") | |
69 | 67 | else { | |
70 | 68 | let amountTokenB = getIntegerValue(this, "amountTokenB") | |
71 | 69 | let amountTokenA = getIntegerValue(this, "amountTokenA") | |
72 | 70 | let payment = match contextObj.payment { | |
73 | 71 | case p: AttachedPayment => | |
74 | 72 | p | |
75 | 73 | case _ => | |
76 | 74 | throw("Payment not attached") | |
77 | 75 | } | |
78 | 76 | let assetIdReceived = payment.assetId | |
79 | 77 | let tokenReceiveAmount = payment.amount | |
80 | 78 | if ((assetIdReceived == assetIdTokenB)) | |
81 | 79 | then { | |
82 | 80 | let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100) | |
83 | 81 | if ((minTokenRecieve > tokenSendAmount)) | |
84 | 82 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
85 | 83 | else { | |
86 | 84 | let assetIdSent = assetIdTokenA | |
87 | 85 | ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA - tokenSendAmount)), DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
88 | 86 | } | |
89 | 87 | } | |
90 | 88 | else if ((assetIdReceived == assetIdTokenA)) | |
91 | 89 | then { | |
92 | 90 | let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100) | |
93 | 91 | if ((minTokenRecieve > tokenSendAmount)) | |
94 | 92 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
95 | 93 | else { | |
96 | 94 | let assetIdSent = assetIdTokenB | |
97 | 95 | ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
98 | 96 | } | |
99 | 97 | } | |
100 | 98 | else throw("Asset is not allowed") | |
101 | 99 | } | |
102 | 100 | ||
103 | 101 | ||
104 | 102 | ||
105 | 103 | @Callable(contextObj) | |
106 | 104 | func withdraw () = { | |
107 | 105 | let BalanceTokenA = assetBalance(this, assetIdTokenA) | |
108 | 106 | let BalanceTokenB = assetBalance(this, assetIdTokenB) | |
109 | 107 | if ((contextObj.caller.bytes == owner)) | |
110 | 108 | then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)])) | |
111 | 109 | else throw("You are not exchanger's owner") | |
112 | 110 | } | |
113 | 111 | ||
114 | 112 | ||
115 | 113 | @Verifier(contextObj) | |
116 | 114 | func verify () = true | |
117 | 115 |
github/deemru/w8io/026f985 51.58 ms ◑