tx · 8kU8afrVuJogbGF6eLQx1ATKSefNsK9xk8iCQKJLzG3s 3N1nSQhEUjDNY8MrjfRagJiQbsqpToX3i55: -0.01000000 Waves 2021.10.04 13:50 [1731377] smart account 3N1nSQhEUjDNY8MrjfRagJiQbsqpToX3i55 > SELF 0.00000000 Waves
{ "type": 13, "id": "8kU8afrVuJogbGF6eLQx1ATKSefNsK9xk8iCQKJLzG3s", "fee": 1000000, "feeAssetId": null, "timestamp": 1633344633605, "version": 1, "sender": "3N1nSQhEUjDNY8MrjfRagJiQbsqpToX3i55", "senderPublicKey": "ACfgBzHqoJYyYM5Z7XYp69NXCDWTM4VR77CZD7aBVPK8", "proofs": [ "ypiqqf3hSw6KsTNsDBgomirqVhLQFcCriwGM94gjgrk2MvBMPrbUY7pSP1dfu1ZxftYWvvJjMLwwgkqspXb57o8" ], "script": "base64:AAIFAAAAAAAAABoIAhIDCgEIEgASBAoCCAESAwoBCBIECgIICAAAAAwAAAAAA1NFUAIAAAACX18BAAAAD2dldFN0cmluZ09yRmFpbAAAAAEAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQiAAAAAQUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgIAAAAPbWFuZGF0b3J5IHRoaXMuBQAAAANrZXkCAAAADyBpcyBub3QgZGVmaW5lZAEAAAAYZ2V0U3RyaW5nQnlBZGRyZXNzT3JGYWlsAAAAAgAAAAdhZGRyZXNzAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAAB2FkZHJlc3MFAAAAA2tleQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAptYW5kYXRvcnkgCQAEJQAAAAEFAAAAB2FkZHJlc3MCAAAAAS4FAAAAA2tleQIAAAAPIGlzIG5vdCBkZWZpbmVkAQAAABFrZXlGYWN0b3J5QWRkcmVzcwAAAAACAAAAHCVzJXNfX2NvbmZpZ19fZmFjdG9yeUF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", "chainId": 84, "height": 1731377, "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 SEP = "__" | |
5 | + | ||
6 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
7 | + | ||
8 | + | ||
9 | + | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
10 | + | ||
11 | + | ||
12 | + | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
13 | + | ||
14 | + | ||
15 | + | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
16 | + | ||
17 | + | ||
18 | + | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(keyFactoryAddress())) | |
19 | + | ||
20 | + | ||
21 | + | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
22 | + | ||
23 | + | ||
24 | + | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
25 | + | ||
26 | + | ||
27 | + | func readStaked (key) = valueOrElse(getInteger(this, key), 0) | |
28 | + | ||
29 | + | ||
30 | + | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
31 | + | ||
32 | + | ||
33 | + | func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
34 | + | ||
35 | + | ||
36 | + | func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount)) | |
37 | + | ||
38 | + | ||
39 | + | @Callable(i) | |
40 | + | func constructor (factoryAddressStr) = if ((i.caller != this)) | |
41 | + | then throw("not authorized") | |
42 | + | else [StringEntry(keyFactoryAddress(), factoryAddressStr)] | |
43 | + | ||
44 | + | ||
45 | + | ||
46 | + | @Callable(i) | |
47 | + | func stake () = { | |
48 | + | let factory = readFactoryAddressOrFail() | |
49 | + | if ((size(i.payments) != 1)) | |
50 | + | then throw("invalid payment - exact one payment must be attached") | |
51 | + | else { | |
52 | + | let pmt = i.payments[0] | |
53 | + | let lpAssetId = value(pmt.assetId) | |
54 | + | let lpAssetIdStr = toBase58String(lpAssetId) | |
55 | + | let amount = pmt.amount | |
56 | + | let lpDappStr = valueOrErrorMessage(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
57 | + | let callerStr = toString(i.caller) | |
58 | + | let userAddressStr = if ((callerStr == lpDappStr)) | |
59 | + | then toString(i.originCaller) | |
60 | + | else callerStr | |
61 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
62 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
63 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
64 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
65 | + | [IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] | |
66 | + | } | |
67 | + | } | |
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | @Callable(i) | |
72 | + | func unstake (lpAssetIdStr,amount) = { | |
73 | + | let factory = readFactoryAddressOrFail() | |
74 | + | let userAddressStr = toString(i.caller) | |
75 | + | let lpAssetId = fromBase58String(lpAssetIdStr) | |
76 | + | if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr))))) | |
77 | + | then throw(("unsupported lp asset " + lpAssetIdStr)) | |
78 | + | else { | |
79 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
80 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
81 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
82 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
83 | + | if ((amount > stakedByUser)) | |
84 | + | then throw("passed amount is less then available") | |
85 | + | else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] | |
86 | + | } | |
87 | + | } | |
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | @Callable(i) | |
92 | + | func claimWx (lpAssetIdStr) = throw("temorary disabled") | |
93 | + | ||
94 | + | ||
95 | + | ||
96 | + | @Callable(i) | |
97 | + | func claimWxREADONLY (lpAssetIdStr,userAddress) = $Tuple2(nil, makeString(["%s%s%d", lpAssetIdStr, userAddress, "0"], SEP)) | |
98 | + | ||
99 | + |
github/deemru/w8io/026f985 16.14 ms ◑