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