tx · B2LgimrneTiKrC1WT4AMSUmwMwu1H85FWJh5PNA5SeLi 3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL: -0.01400000 Waves 2019.08.27 18:42 [649802] smart account 3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL > SELF 0.00000000 Waves
{ "type": 13, "id": "B2LgimrneTiKrC1WT4AMSUmwMwu1H85FWJh5PNA5SeLi", "fee": 1400000, "feeAssetId": null, "timestamp": 1566920609672, "version": 1, "sender": "3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL", "senderPublicKey": "3RTmBp69DqXiohzMXcmVU1pMFssmztWoibFARiKrgTr7", "proofs": [ "2iyT4LViRX2v1iHi9a22nnvepD8GfczwYbs2PLrX2u3dpetgQ677xKc72wGMfh9JSruSuodfaCAyjAp1C8jfpajo" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAAAAAAVvd25lcgEAAAAaAVSTOHBLt7RyJdugRiL5k8zovFc+bobXqh8AAAAADWFzc2V0SWRUb2tlbkEBAAAAIHtxzCCjiO5MvMQa1Azqp+Y2rXgVKpJSDL3j5MzZkFIFAAAAAA1hc3NldElkVG9rZW5CBQAAAAR1bml0AAAAAAljb21pc3Npb24AAAAAAAAAAAAAAAAEAAAACmNvbnRleHRPYmoBAAAABGZ1bmQAAAAABAAAAAdwYXltZW50BAAAAAckbWF0Y2gwCAUAAAAKY29udGV4dE9iagAAAAdwYXltZW50AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9BdHRhY2hlZFBheW1lbnQEAAAAAXAFAAAAByRtYXRjaDAFAAAAAXAJAAACAAAAAQIAAAAUUGF5bWVudCBub3QgYXR0YWNoZWQEAAAAD2Fzc2V0SWRSZWNlaXZlZAgFAAAAB3BheW1lbnQAAAAHYXNzZXRJZAQAAAASdG9rZW5SZWNlaXZlQW1vdW50CAUAAAAHcGF5bWVudAAAAAZhbW91bnQDAwkAAAAAAAACBQAAAA9hc3NldElkUmVjZWl2ZWQFAAAAD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kIFAAAADWFzc2V0SWRUb2tlbkIFAAAAA25pbAkAAAIAAAABAgAAAB1Zb3UgYXJlIG5vdCBleGNoYW5nZXIncyBvd25lcgAAAAEAAAAKY29udGV4dE9iagEAAAAGdmVyaWZ5AAAAAAZ9tcw/", "chainId": 84, "height": 649802, "spentComplexity": 0 } View: original | compacted Prev: 3mbQpL9V1L9bRAkhiood43XYiLcUrQKt5bHjxRxs58bh Next: FmsDfs1hYF2fWkm8zAS6V76dWckPnxihtotDVrUSRtjS Diff:
Old | New | Differences | |
---|---|---|---|
28 | 28 | else false) | |
29 | 29 | then WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("fundB", "funded")]) | |
30 | 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(getString(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(getString(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") | |
31 | 60 | } | |
32 | 61 | ||
33 | 62 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let owner = base58'3N3LWiYdT9n8o6ecwFZGy6MCehhq6sLUFFL' | |
5 | 5 | ||
6 | 6 | let assetIdTokenA = base58'9Jsnot7RWQmTsfXtezQN7igoS2q1QF1jsotaxwh8Fxp4' | |
7 | 7 | ||
8 | 8 | let assetIdTokenB = unit | |
9 | 9 | ||
10 | 10 | let comission = 0 | |
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 | 23 | then !(isDefined(getString(this, "fundA"))) | |
24 | 24 | else false) | |
25 | 25 | then WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("fundA", "funded")]) | |
26 | 26 | else if (if ((assetIdReceived == assetIdTokenB)) | |
27 | 27 | then !(isDefined(getString(this, "fundB"))) | |
28 | 28 | else false) | |
29 | 29 | then WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("fundB", "funded")]) | |
30 | 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(getString(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(getString(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") | |
31 | 60 | } | |
32 | 61 | ||
33 | 62 | ||
34 | 63 | ||
35 | 64 | @Callable(contextObj) | |
36 | 65 | func exchanger (minTokenRecieve) = if (if ((0 > comission)) | |
37 | 66 | then true | |
38 | 67 | else (comission > 100)) | |
39 | 68 | then throw("incorrect comission value") | |
40 | 69 | else { | |
41 | 70 | let amountTokenB = getIntegerValue(this, "amountTokenB") | |
42 | 71 | let amountTokenA = getIntegerValue(this, "amountTokenA") | |
43 | 72 | let payment = match contextObj.payment { | |
44 | 73 | case p: AttachedPayment => | |
45 | 74 | p | |
46 | 75 | case _ => | |
47 | 76 | throw("Payment not attached") | |
48 | 77 | } | |
49 | 78 | let assetIdReceived = payment.assetId | |
50 | 79 | let tokenReceiveAmount = payment.amount | |
51 | 80 | if ((assetIdReceived == assetIdTokenB)) | |
52 | 81 | then { | |
53 | 82 | let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100) | |
54 | 83 | if ((minTokenRecieve > tokenSendAmount)) | |
55 | 84 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
56 | 85 | else { | |
57 | 86 | let assetIdSent = assetIdTokenA | |
58 | 87 | ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA - tokenSendAmount)), DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
59 | 88 | } | |
60 | 89 | } | |
61 | 90 | else if ((assetIdReceived == assetIdTokenA)) | |
62 | 91 | then { | |
63 | 92 | let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100) | |
64 | 93 | if ((minTokenRecieve > tokenSendAmount)) | |
65 | 94 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
66 | 95 | else { | |
67 | 96 | let assetIdSent = assetIdTokenB | |
68 | 97 | ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
69 | 98 | } | |
70 | 99 | } | |
71 | 100 | else throw("Asset is not allowed") | |
72 | 101 | } | |
73 | 102 | ||
74 | 103 | ||
75 | 104 | ||
76 | 105 | @Callable(contextObj) | |
77 | 106 | func withdraw () = { | |
78 | 107 | let BalanceTokenA = assetBalance(this, assetIdTokenA) | |
79 | 108 | let BalanceTokenB = assetBalance(this, assetIdTokenB) | |
80 | 109 | if ((contextObj.caller.bytes == owner)) | |
81 | 110 | then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)])) | |
82 | 111 | else throw("You are not exchanger's owner") | |
83 | 112 | } | |
84 | 113 | ||
85 | 114 | ||
86 | 115 | @Verifier(contextObj) | |
87 | 116 | func verify () = true | |
88 | 117 |
github/deemru/w8io/026f985 42.15 ms ◑