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