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