tx · 3NGertWwVWLUeFWFBCJoqrhJPRHhtrPBLPX5nPXn4keo 3Mw3xGvPazF16KT1cDmSj924QAvBJy2AK7h: -0.03400000 Waves 2022.06.16 20:51 [2099240] smart account 3Mw3xGvPazF16KT1cDmSj924QAvBJy2AK7h > SELF 0.00000000 Waves
{ "type": 13, "id": "3NGertWwVWLUeFWFBCJoqrhJPRHhtrPBLPX5nPXn4keo", "fee": 3400000, "feeAssetId": null, "timestamp": 1655401924157, "version": 2, "chainId": 84, "sender": "3Mw3xGvPazF16KT1cDmSj924QAvBJy2AK7h", "senderPublicKey": "CHEC9EniX52Doy97ZXBMGnZgyuhK2XyxMS91LNZhWQww", "proofs": [ "5L7XR4xjCsik3UtPdL7YqE2Be9ghSWCZa6p9RYGqMxcp8RULnLKyedi7DCjS58aMZx913ngPQi6LePfCQLvFeBK9" ], "script": "base64:AAIFAAAAAAAAAA4IAhIDCgEIEgMKAQESAAAAABYAAAAAC2tfaW5zdXJhbmNlAgAAAAtrX2luc3VyYW5jZQAAAAAUa19jb29yZGluYXRvckFkZHJlc3MCAAAAFGtfY29vcmRpbmF0b3JBZGRyZXNzAAAAAAVrX2FtbQIAAAAFa19hbW0AAAAAE2tfaW5zdXJhbmNlX2FkZHJlc3MCAAAAE2tfaW5zdXJhbmNlX2FkZHJlc3MAAAAAD2tfYWRtaW5fYWRkcmVzcwIAAAAPa19hZG1pbl9hZGRyZXNzAAAAABJrX2FkbWluX3B1YmxpY19rZXkCAAAAEmtfYWRtaW5fcHVibGljX2tleQAAAAANa19xdW90ZV9hc3NldAIAAAANa19xdW90ZV9hc3NldAAAAAAPa19xdW90ZV9zdGFraW5nAgAAAA9rX3F1b3RlX3N0YWtpbmcAAAAAEWtfc3Rha2luZ19hZGRyZXNzAgAAABFrX3N0YWtpbmdfYWRkcmVzcwAAAAANa19pbml0aWFsaXplZAIAAAANa19pbml0aWFsaXplZAEAAAAOdG9Db21wb3NpdGVLZXkAAAACAAAABF9rZXkAAAAIX2FkZHJl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AAAASEAAAABCQEAAAALaXNXaGl0ZWxpc3QAAAABCQAEJQAAAAEIBQAAAAFpAAAABmNhbGxlcgkBAAAAAiE9AAAAAggFAAAAAWkAAAAGY2FsbGVyCQEAAAAMYWRtaW5BZGRyZXNzAAAAAAcJAAACAAAAAQIAAAAWSW52YWxpZCBkZXBvc2l0IHBhcmFtcwQAAAAFc3Rha2UJAAP8AAAABAkBAAAAEXF1b3RlQXNzZXRTdGFraW5nAAAAAAIAAAAMbG9ja05ldXRyaW5vBQAAAANuaWwJAARMAAAAAgkBAAAAD0F0dGFjaGVkUGF5bWVudAAAAAIJAQAAAApxdW90ZUFzc2V0AAAAAAUAAAAHX2Ftb3VudAUAAAADbmlsAwkAAAAAAAACBQAAAAVzdGFrZQUAAAAFc3Rha2UJAQAAAA91cGRhdGVJbnN1cmFuY2UAAAABCQAAZAAAAAIJAQAAAAlpbnN1cmFuY2UAAAAABQAAAAdfYW1vdW50CQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACQEAAAAOYWRtaW5QdWJsaWNLZXkAAAAAX6Aqiw==", "height": 2099240, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let k_insurance = "k_insurance" | |
5 | + | ||
6 | + | let k_coordinatorAddress = "k_coordinatorAddress" | |
7 | + | ||
8 | + | let k_amm = "k_amm" | |
9 | + | ||
10 | + | let k_insurance_address = "k_insurance_address" | |
11 | + | ||
12 | + | let k_admin_address = "k_admin_address" | |
13 | + | ||
14 | + | let k_admin_public_key = "k_admin_public_key" | |
15 | + | ||
16 | + | let k_quote_asset = "k_quote_asset" | |
17 | + | ||
18 | + | let k_quote_staking = "k_quote_staking" | |
19 | + | ||
20 | + | let k_staking_address = "k_staking_address" | |
21 | + | ||
22 | + | let k_initialized = "k_initialized" | |
23 | + | ||
24 | + | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
25 | + | ||
26 | + | ||
27 | + | func insurance () = valueOrElse(getInteger(this, k_insurance), 0) | |
28 | + | ||
29 | + | ||
30 | + | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
31 | + | ||
32 | + | ||
33 | + | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
34 | + | ||
35 | + | ||
36 | + | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
37 | + | ||
38 | + | ||
39 | + | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
40 | + | ||
41 | + | ||
42 | + | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
43 | + | ||
44 | + | ||
45 | + | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
46 | + | ||
47 | + | ||
48 | + | func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote assete staking not set") | |
49 | + | ||
50 | + | ||
51 | + | func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Insurance not set") | |
52 | + | ||
53 | + | ||
54 | + | func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set") | |
55 | + | ||
56 | + | ||
57 | + | func updateInsurance (i) = [IntegerEntry(k_insurance, i)] | |
58 | + | ||
59 | + | ||
60 | + | @Callable(i) | |
61 | + | func initialize (_coordinator) = if (initialized()) | |
62 | + | then throw("Already initialized") | |
63 | + | else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)] | |
64 | + | ||
65 | + | ||
66 | + | ||
67 | + | @Callable(i) | |
68 | + | func withdraw (_amount) = if (if (if (!(isWhitelist(toString(i.caller)))) | |
69 | + | then true | |
70 | + | else !(initialized())) | |
71 | + | then true | |
72 | + | else (_amount > insurance())) | |
73 | + | then throw(((("Invalid withdraw params " + toString(_amount)) + " > ") + toString(insurance()))) | |
74 | + | else { | |
75 | + | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [_amount, toBase58String(quoteAsset())], nil) | |
76 | + | if ((unstake == unstake)) | |
77 | + | then (updateInsurance((insurance() - _amount)) ++ [ScriptTransfer(i.caller, _amount, quoteAsset())]) | |
78 | + | else throw("Strict value is not equal to itself.") | |
79 | + | } | |
80 | + | ||
81 | + | ||
82 | + | ||
83 | + | @Callable(i) | |
84 | + | func deposit () = { | |
85 | + | let _amount = i.payments[0].amount | |
86 | + | if (if (if ((i.payments[0].assetId != quoteAsset())) | |
87 | + | then true | |
88 | + | else !(initialized())) | |
89 | + | then true | |
90 | + | else if (!(isWhitelist(toString(i.caller)))) | |
91 | + | then (i.caller != adminAddress()) | |
92 | + | else false) | |
93 | + | then throw("Invalid deposit params") | |
94 | + | else { | |
95 | + | let stake = invoke(quoteAssetStaking(), "lockNeutrino", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
96 | + | if ((stake == stake)) | |
97 | + | then updateInsurance((insurance() + _amount)) | |
98 | + | else throw("Strict value is not equal to itself.") | |
99 | + | } | |
100 | + | } | |
101 | + | ||
102 | + | ||
103 | + | @Verifier(tx) | |
104 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
105 | + |
github/deemru/w8io/026f985 29.38 ms ◑