tx · E2vKMkohJmUV57Qp1ShDoCseSkxr2582Kpgmn9mPPMRW 3MzhpxAKSeCcAYnwEQzd4v8xhuxEa7H79mA: -0.03700000 Waves 2022.11.25 19:31 [2332866] smart account 3MzhpxAKSeCcAYnwEQzd4v8xhuxEa7H79mA > SELF 0.00000000 Waves
{ "type": 13, "id": "E2vKMkohJmUV57Qp1ShDoCseSkxr2582Kpgmn9mPPMRW", "fee": 3700000, "feeAssetId": null, "timestamp": 1669393860880, "version": 2, "chainId": 84, "sender": "3MzhpxAKSeCcAYnwEQzd4v8xhuxEa7H79mA", "senderPublicKey": "A4jJoT1GfErs6Zq9p6jQrT43kuzivydaycZfLbuBCAhq", "proofs": [ "2EkoYhwTvEoJaeGD84UW7pBNMyyHnjNBjRWnPCSLJvRhASzGrifeNeu2oDZSyAJ2TFScEtdXhHo5LYvZAQzTmmcD" ], "script": "base64:BgIQCAISAwoBCBIDCgEBEgASABYAC2tfaW5zdXJhbmNlAgtrX2luc3VyYW5jZQAUa19jb29yZGluYXRvckFkZHJlc3MCFGtfY29vcmRpbmF0b3JBZGRyZXNzAAVrX2FtbQIFa19hbW0AD2tfYWRtaW5fYWRkcmVzcwIPa19hZG1pbl9hZGRyZXNzABJrX2FkbWluX3B1YmxpY19rZXkCEmtfYWRtaW5fcHVibGljX2tleQANa19xdW90ZV9hc3NldAINa19xdW90ZV9hc3NldAAPa19xdW90ZV9zdGFraW5nAg9rX3F1b3RlX3N0YWtpbmcAEWtfbWFuYWdlcl9hZGRyZXNzAhFrX21hbmFnZXJfYWRkcmVzcwAUa19jb2xsYXRlcmFsX2FkZHJlc3MCFGtfY29sbGF0ZXJhbF9hZGRyZXNzAA1rX2luaXRpYWxpemVkAg1rX2luaXRpYWxpemVkAQ50b0NvbXBvc2l0ZUtleQIEX2tleQhfYWRkcmVzcwkArAICCQCsAgIFBF9rZXkCAV8FCF9hZGRyZXNzAQlpbnN1cmFuY2UACQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFC2t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MwIAgkA2AQBCQEKcXVvdGVBc3NldAAFA25pbAUDbmlsAwkAAAIFB3Vuc3Rha2UFB3Vuc3Rha2UEBXN0YWtlCQD8BwQJAQ5tYW5hZ2VyQWRkcmVzcwACB2RlcG9zaXQFA25pbAkAzAgCCQEPQXR0YWNoZWRQYXltZW50AgkBCnF1b3RlQXNzZXQABQZhbW91bnQFA25pbAMJAAACBQVzdGFrZQUFc3Rha2UFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAJAQ5hZG1pblB1YmxpY0tleQBuR7Tn", "height": 2332866, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AWCT2y1W1AWX5PvSkp7Kv9i4w9qrTiYmM2a8Daeh3UGM Next: none Diff:
Old | New | Differences | |
---|---|---|---|
94 | 94 | else (i.caller == collateralAddress())) | |
95 | 95 | then true | |
96 | 96 | else (i.caller == adminAddress()))) | |
97 | - | then throw("Invalid deposit params") | |
97 | + | then throw("Invalid deposit params (insurance)") | |
98 | 98 | else { | |
99 | 99 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
100 | 100 | if ((stake == stake)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_insurance = "k_insurance" | |
5 | 5 | ||
6 | 6 | let k_coordinatorAddress = "k_coordinatorAddress" | |
7 | 7 | ||
8 | 8 | let k_amm = "k_amm" | |
9 | 9 | ||
10 | 10 | let k_admin_address = "k_admin_address" | |
11 | 11 | ||
12 | 12 | let k_admin_public_key = "k_admin_public_key" | |
13 | 13 | ||
14 | 14 | let k_quote_asset = "k_quote_asset" | |
15 | 15 | ||
16 | 16 | let k_quote_staking = "k_quote_staking" | |
17 | 17 | ||
18 | 18 | let k_manager_address = "k_manager_address" | |
19 | 19 | ||
20 | 20 | let k_collateral_address = "k_collateral_address" | |
21 | 21 | ||
22 | 22 | let k_initialized = "k_initialized" | |
23 | 23 | ||
24 | 24 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func insurance () = valueOrElse(getInteger(this, k_insurance), 0) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func coordinator () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_coordinatorAddress), "Coordinator not set")), "Coordinator not set") | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set")) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func adminPublicKey () = fromBase58String(valueOrErrorMessage(getString(coordinator(), k_admin_public_key), "Admin public key not set")) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func quoteAsset () = fromBase58String(valueOrErrorMessage(getString(coordinator(), k_quote_asset), "Quote asset not set")) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func quoteAssetStaking () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_quote_staking), "Quote asset staking not set")), "Quote asset staking not set") | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func managerAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_manager_address), "Manager not set")), "Manager not set") | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func collateralAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_collateral_address), "Collateral not set")), "Collateral not set") | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func updateInsurance (i) = [IntegerEntry(k_insurance, i)] | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | @Callable(i) | |
61 | 61 | func initialize (_coordinator) = if (initialized()) | |
62 | 62 | then throw("Already initialized") | |
63 | 63 | else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)] | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | @Callable(i) | |
68 | 68 | func withdraw (_amount) = if (if (if (!(if (isWhitelist(toString(i.caller))) | |
69 | 69 | then true | |
70 | 70 | else (i.caller == collateralAddress()))) | |
71 | 71 | then true | |
72 | 72 | else !(initialized())) | |
73 | 73 | then true | |
74 | 74 | else (_amount > insurance())) | |
75 | 75 | then throw(((("Invalid withdraw params (insurance) " + toString(_amount)) + " > ") + toString(insurance()))) | |
76 | 76 | else { | |
77 | 77 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil) | |
78 | 78 | if ((unstake == unstake)) | |
79 | 79 | then (updateInsurance((insurance() - _amount)) ++ [ScriptTransfer(i.caller, _amount, quoteAsset())]) | |
80 | 80 | else throw("Strict value is not equal to itself.") | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | 85 | @Callable(i) | |
86 | 86 | func deposit () = { | |
87 | 87 | let _amount = i.payments[0].amount | |
88 | 88 | if (if (if ((i.payments[0].assetId != quoteAsset())) | |
89 | 89 | then true | |
90 | 90 | else !(initialized())) | |
91 | 91 | then true | |
92 | 92 | else !(if (if (isWhitelist(toString(i.caller))) | |
93 | 93 | then true | |
94 | 94 | else (i.caller == collateralAddress())) | |
95 | 95 | then true | |
96 | 96 | else (i.caller == adminAddress()))) | |
97 | - | then throw("Invalid deposit params") | |
97 | + | then throw("Invalid deposit params (insurance)") | |
98 | 98 | else { | |
99 | 99 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
100 | 100 | if ((stake == stake)) | |
101 | 101 | then updateInsurance((insurance() + _amount)) | |
102 | 102 | else throw("Strict value is not equal to itself.") | |
103 | 103 | } | |
104 | 104 | } | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | ||
108 | 108 | @Callable(i) | |
109 | 109 | func migrateLiquidity () = { | |
110 | 110 | let amount = insurance() | |
111 | 111 | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil) | |
112 | 112 | if ((unstake == unstake)) | |
113 | 113 | then { | |
114 | 114 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)]) | |
115 | 115 | if ((stake == stake)) | |
116 | 116 | then nil | |
117 | 117 | else throw("Strict value is not equal to itself.") | |
118 | 118 | } | |
119 | 119 | else throw("Strict value is not equal to itself.") | |
120 | 120 | } | |
121 | 121 | ||
122 | 122 | ||
123 | 123 | @Verifier(tx) | |
124 | 124 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
125 | 125 |
github/deemru/w8io/026f985 43.55 ms ◑