2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = base58'3NBmj1eEDJmrQ16GJkmVU1p31MTURgoV38r' |
---|
5 | | - | |
---|
6 | | - | let b = base58'GhAFhXzwCYfvcXQ3GHFaQFnCzAuYCT156qFqiYyzfkzv' |
---|
7 | | - | |
---|
8 | | - | let c = unit |
---|
9 | | - | |
---|
10 | | - | @Callable(d) |
---|
11 | | - | func uniswap (e,f) = if (if ((0 > e)) |
---|
12 | | - | then true |
---|
13 | | - | else (e > 100)) |
---|
14 | | - | then throw("incorrect comission value") |
---|
15 | | - | else { |
---|
16 | | - | let g = getIntegerValue(this, "wavesAmount") |
---|
17 | | - | let h = getIntegerValue(this, "liquidAmount") |
---|
18 | | - | let i = { |
---|
19 | | - | let j = d.payment |
---|
20 | | - | if ($isInstanceOf(j, "AttachedPayment")) |
---|
21 | | - | then { |
---|
22 | | - | let k = j |
---|
23 | | - | k |
---|
24 | | - | } |
---|
25 | | - | else throw("Payment not attached") |
---|
26 | | - | } |
---|
27 | | - | let l = i.assetId |
---|
28 | | - | let m = i.amount |
---|
29 | | - | if ((l == unit)) |
---|
30 | | - | then { |
---|
31 | | - | let n = ((fraction(h, m, (m + g)) * (100 - e)) / 100) |
---|
32 | | - | if ((f > n)) |
---|
33 | | - | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") |
---|
34 | | - | else { |
---|
35 | | - | let o = b |
---|
36 | | - | ScriptResult(WriteSet([DataEntry("liquidAmount", (h - n)), DataEntry("wavesAmount", (g + m))]), TransferSet([ScriptTransfer(d.caller, n, o)])) |
---|
37 | | - | } |
---|
38 | | - | } |
---|
39 | | - | else if ((l == b)) |
---|
40 | | - | then { |
---|
41 | | - | let n = ((fraction(g, m, (m + h)) * (100 - e)) / 100) |
---|
42 | | - | if ((f > n)) |
---|
43 | | - | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") |
---|
44 | | - | else { |
---|
45 | | - | let o = unit |
---|
46 | | - | ScriptResult(WriteSet([DataEntry("liquidAmount", (h + m)), DataEntry("wavesAmount", (g - n))]), TransferSet([ScriptTransfer(d.caller, n, o)])) |
---|
47 | | - | } |
---|
48 | | - | } |
---|
49 | | - | else throw("Asset is not allowed") |
---|
50 | | - | } |
---|
51 | | - | |
---|
52 | | - | |
---|
53 | | - | |
---|
54 | | - | @Callable(d) |
---|
55 | | - | func withdraw () = { |
---|
56 | | - | let p = assetBalance(this, b) |
---|
57 | | - | let q = wavesBalance(this) |
---|
58 | | - | if ((d.caller.bytes == a)) |
---|
59 | | - | then ScriptResult(WriteSet([DataEntry("liquidAmount", "withdrawn"), DataEntry("wavesAmount", "withdrawn")]), TransferSet([ScriptTransfer(d.caller, p, b), ScriptTransfer(d.caller, q, unit)])) |
---|
60 | | - | else throw("You are not exchanger's owner") |
---|
61 | | - | } |
---|
62 | | - | |
---|
63 | | - | |
---|
64 | | - | @Verifier(d) |
---|
65 | | - | func r () = true |
---|
66 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let PubKey = base58'3NBmj1eEDJmrQ16GJkmVU1p31MTURgoV38r' |
---|
| 4 | + | sigVerify(tx.bodyBytes, tx.proofs[0], PubKey) |
---|