2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let owner = base58'3NBmj1eEDJmrQ16GJkmVU1p31MTURgoV38r' |
---|
5 | | - | |
---|
6 | | - | let LiquidAssetId = base58'GhAFhXzwCYfvcXQ3GHFaQFnCzAuYCT156qFqiYyzfkzv' |
---|
7 | | - | |
---|
8 | | - | let WAVESID = unit |
---|
9 | | - | |
---|
10 | | - | @Callable(contextObj) |
---|
11 | | - | func uniswap () = { |
---|
12 | | - | let wavesAmount = getIntegerValue(this, "wavesAmount") |
---|
13 | | - | let liquidAmount = getIntegerValue(this, "liquidAmount") |
---|
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 ((assetIdReceived == unit)) |
---|
23 | | - | then { |
---|
24 | | - | let tokenSendAmount = fraction(liquidAmount, tokenReceiveAmount, (tokenReceiveAmount + wavesAmount)) |
---|
25 | | - | let assetIdSent = LiquidAssetId |
---|
26 | | - | ScriptResult(WriteSet([DataEntry("liquidAmount", (liquidAmount - tokenSendAmount)), DataEntry("wavesAmount", (wavesAmount + tokenReceiveAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
27 | | - | } |
---|
28 | | - | else if ((assetIdReceived == LiquidAssetId)) |
---|
29 | | - | then { |
---|
30 | | - | let tokenSendAmount = fraction(wavesAmount, tokenReceiveAmount, (tokenReceiveAmount + liquidAmount)) |
---|
31 | | - | let assetIdSent = unit |
---|
32 | | - | ScriptResult(WriteSet([DataEntry("liquidAmofunt", (liquidAmount + tokenReceiveAmount)), DataEntry("wavesAmount", (wavesAmount - tokenSendAmount))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) |
---|
33 | | - | } |
---|
34 | | - | else throw("Asset is not allowed") |
---|
35 | | - | } |
---|
36 | | - | |
---|
37 | | - | |
---|
38 | | - | |
---|
39 | | - | @Callable(contextObj) |
---|
40 | | - | func withdraw () = { |
---|
41 | | - | let LiquidBalance = assetBalance(this, LiquidAssetId) |
---|
42 | | - | let WavesBalance = wavesBalance(this) |
---|
43 | | - | if ((contextObj.caller.bytes == owner)) |
---|
44 | | - | then ScriptResult(WriteSet([DataEntry("liquidAmount", "withdrawn"), DataEntry("wavesAmount", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, LiquidBalance, LiquidAssetId), ScriptTransfer(contextObj.caller, WavesBalance, unit)])) |
---|
45 | | - | else throw("You are not exchanger's owner") |
---|
46 | | - | } |
---|
47 | | - | |
---|
48 | | - | |
---|
49 | | - | @Verifier(contextObj) |
---|
50 | | - | func verify () = true |
---|
51 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let PubKey = base58'3NBmj1eEDJmrQ16GJkmVU1p31MTURgoV38r' |
---|
| 4 | + | sigVerify(tx.bodyBytes, tx.proofs[0], PubKey) |
---|