tx · 8bEW6uZ6vPS8ahgjr7nNDVCZmQXAAabV9tHCb2dHTXZN 3N6DGohy3A1oqkBk6F4BRPHrqgkVgwxWd8g: -0.01000000 Waves 2021.09.08 15:01 [1694040] smart account 3N6DGohy3A1oqkBk6F4BRPHrqgkVgwxWd8g > SELF 0.00000000 Waves
{ "type": 13, "id": "8bEW6uZ6vPS8ahgjr7nNDVCZmQXAAabV9tHCb2dHTXZN", "fee": 1000000, "feeAssetId": null, "timestamp": 1631102517788, "version": 1, "sender": "3N6DGohy3A1oqkBk6F4BRPHrqgkVgwxWd8g", "senderPublicKey": "AkPpYa8oqgaNXjTSuWGaMCnJ6y44pYUMeskeBjzVgPhr", "proofs": [ "2ttMNceejZb2t6UtA4AgdpNAoFM8eMwnFqRCc158M1fsQXaRZT8ZKXD6razzuH7crWnH4ABYWqjtQ1ngFPZR4VtK" ], "script": "base64:AAIFAAAAAAAAABQIAhIDCgEIEgASBAoCCAESAwoBCAAAAAwAAAAAA1NFUAIAAAACX18BAAAAD2dldFN0cmluZ09yRmFpbAAAAAEAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQiAAAAAQUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgIAAAAPbWFuZGF0b3J5IHRoaXMuBQAAAANrZXkCAAAADyBpcyBub3QgZGVmaW5lZAEAAAAYZ2V0U3RyaW5nQnlBZGRyZXNzT3JGYWlsAAAAAgAAAAdhZGRyZXNzAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAAB2FkZHJlc3MFAAAAA2tleQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAptYW5kYXRvcnkgCQAEJQAAAAEFAAAAB2FkZHJlc3MCAAAAAS4FAAAAA2tleQIAAAAPIGlzIG5vdCBkZWZpbmVkAQAAABFrZXlGYWN0b3J5QWRkcmVzcwAAAAACAAAAHCVzJXNfX2NvbmZpZ19fZmFj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FrZWRUb3RhbAkBAAAACnJlYWRTdGFrZWQAAAABBQAAAA5zdGFrZWRUb3RhbEtFWQMJAABmAAAAAgUAAAAGYW1vdW50BQAAAAxzdGFrZWRCeVVzZXIJAAACAAAAAQIAAAAkcGFzc2VkIGFtb3VudCBpcyBsZXNzIHRoZW4gYXZhaWxhYmxlCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAA9zdGFrZWRCeVVzZXJLRVkJAABlAAAAAgUAAAAMc3Rha2VkQnlVc2VyBQAAAAZhbW91bnQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIFAAAADnN0YWtlZFRvdGFsS0VZCQAAZQAAAAIFAAAAC3N0YWtlZFRvdGFsBQAAAAZhbW91bnQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAACWxwQXNzZXRJZAkABEwAAAACCQEAAAAVT3BlcmF0aW9uSGlzdG9yeUVudHJ5AAAABQIAAAAHdW5zdGFrZQUAAAAOdXNlckFkZHJlc3NTdHIFAAAADGxwQXNzZXRJZFN0cgUAAAAGYW1vdW50CAUAAAABaQAAAA10cmFuc2FjdGlvbklkBQAAAANuaWwAAAABaQEAAAAHY2xhaW1XeAAAAAEAAAAMbHBBc3NldElkU3RyCQAAAgAAAAECAAAAEXRlbW9yYXJ5IGRpc2FibGVkAAAAABx3U1U=", "chainId": 84, "height": 1694040, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4yXNVTb9Pk8wjQQFuweY7GGJUjdDajMYDUDFoxjSsdQy Next: BtLK3CA3yhinpuZnFYdtrw4mvMpofaaqDGPMMtRP9xBH Diff:
Old | New | Differences | |
---|---|---|---|
69 | 69 | ||
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | - | func | |
72 | + | func unstake (lpAssetIdStr,amount) = { | |
73 | 73 | let factory = readFactoryAddressOrFail() | |
74 | 74 | let userAddressStr = toString(i.caller) | |
75 | - | let | |
76 | - | if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping( | |
77 | - | then throw(("unsupported lp asset " + | |
75 | + | let lpAssetId = fromBase58String(lpAssetIdStr) | |
76 | + | if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr))))) | |
77 | + | then throw(("unsupported lp asset " + lpAssetIdStr)) | |
78 | 78 | else { | |
79 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, | |
80 | - | let stakedTotalKEY = keyStakedByUser(userAddressStr, | |
79 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
80 | + | let stakedTotalKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
81 | 81 | let stakedByUser = readStaked(stakedByUserKEY) | |
82 | 82 | let stakedTotal = readStaked(stakedTotalKEY) | |
83 | 83 | if ((amount > stakedByUser)) | |
84 | 84 | then throw("passed amount is less then available") | |
85 | - | else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, | |
85 | + | else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] | |
86 | 86 | } | |
87 | 87 | } | |
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | @Callable(i) | |
92 | + | func claimWx (lpAssetIdStr) = throw("temorary disabled") | |
88 | 93 | ||
89 | 94 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(keyFactoryAddress())) | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func readStaked (key) = valueOrElse(getInteger(this, key), 0) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
31 | 31 | ||
32 | 32 | ||
33 | 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 | 34 | ||
35 | 35 | ||
36 | 36 | func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount)) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | @Callable(i) | |
40 | 40 | func constructor (factoryAddressStr) = if ((i.caller != this)) | |
41 | 41 | then throw("not authorized") | |
42 | 42 | else [StringEntry(keyFactoryAddress(), factoryAddressStr)] | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
46 | 46 | @Callable(i) | |
47 | 47 | func stake () = { | |
48 | 48 | let factory = readFactoryAddressOrFail() | |
49 | 49 | if ((size(i.payments) != 1)) | |
50 | 50 | then throw("invalid payment - exact one payment must be attached") | |
51 | 51 | else { | |
52 | 52 | let pmt = i.payments[0] | |
53 | 53 | let lpAssetId = value(pmt.assetId) | |
54 | 54 | let lpAssetIdStr = toBase58String(lpAssetId) | |
55 | 55 | let userAddressStr = toString(i.caller) | |
56 | 56 | let amount = pmt.amount | |
57 | 57 | if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr))))) | |
58 | 58 | then throw(("unsupported lp asset " + lpAssetIdStr)) | |
59 | 59 | else { | |
60 | 60 | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
61 | 61 | let stakedTotalKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
62 | 62 | let stakedByUser = readStaked(stakedByUserKEY) | |
63 | 63 | let stakedTotal = readStaked(stakedTotalKEY) | |
64 | 64 | [IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] | |
65 | 65 | } | |
66 | 66 | } | |
67 | 67 | } | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | - | func | |
72 | + | func unstake (lpAssetIdStr,amount) = { | |
73 | 73 | let factory = readFactoryAddressOrFail() | |
74 | 74 | let userAddressStr = toString(i.caller) | |
75 | - | let | |
76 | - | if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping( | |
77 | - | then throw(("unsupported lp asset " + | |
75 | + | let lpAssetId = fromBase58String(lpAssetIdStr) | |
76 | + | if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr))))) | |
77 | + | then throw(("unsupported lp asset " + lpAssetIdStr)) | |
78 | 78 | else { | |
79 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, | |
80 | - | let stakedTotalKEY = keyStakedByUser(userAddressStr, | |
79 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
80 | + | let stakedTotalKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
81 | 81 | let stakedByUser = readStaked(stakedByUserKEY) | |
82 | 82 | let stakedTotal = readStaked(stakedTotalKEY) | |
83 | 83 | if ((amount > stakedByUser)) | |
84 | 84 | then throw("passed amount is less then available") | |
85 | - | else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, | |
85 | + | else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] | |
86 | 86 | } | |
87 | 87 | } | |
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | @Callable(i) | |
92 | + | func claimWx (lpAssetIdStr) = throw("temorary disabled") | |
88 | 93 | ||
89 | 94 |
github/deemru/w8io/169f3d6 28.47 ms ◑