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