tx · 66nSCy6ey1j7uHryjyDabNGkr8Qxuw94y1EBYtspYrMr

3N6DGohy3A1oqkBk6F4BRPHrqgkVgwxWd8g:  -0.01000000 Waves

2021.09.08 10:05 [1693749] smart account 3N6DGohy3A1oqkBk6F4BRPHrqgkVgwxWd8g > SELF 0.00000000 Waves

{ "type": 13, "id": "66nSCy6ey1j7uHryjyDabNGkr8Qxuw94y1EBYtspYrMr", "fee": 1000000, "feeAssetId": null, "timestamp": 1631084755668, "version": 1, "sender": "3N6DGohy3A1oqkBk6F4BRPHrqgkVgwxWd8g", "senderPublicKey": "AkPpYa8oqgaNXjTSuWGaMCnJ6y44pYUMeskeBjzVgPhr", "proofs": [ "5ZGFXvp3EvCK3329cC3MREEK6UhxACCDjaQCYpt4NPpZQtm3jzPckv5nW3a5Rn2P4qYBN4wFUgWT9keYp7EHcKq1" ], "script": "base64:AAIFAAAAAAAAAA8IAhIDCgEIEgASBAoCCAEAAAAMAAAAAANTRVACAAAAAl9fAQAAAA9nZXRTdHJpbmdPckZhaWwAAAABAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEIgAAAAEFAAAAA2tleQkAASwAAAACCQABLAAAAAICAAAAD21hbmRhdG9yeSB0aGlzLgUAAAADa2V5AgAAAA8gaXMgbm90IGRlZmluZWQBAAAAGGdldFN0cmluZ0J5QWRkcmVzc09yRmFpbAAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAKbWFuZGF0b3J5IAkABCUAAAABBQAAAAdhZGRyZXNzAgAAAAEuBQAAAANrZXkCAAAADyBpcyBub3QgZGVmaW5lZAEAAAARa2V5RmFjdG9yeUFkZHJlc3MAAAAAAgAAABwlcyVzX19jb25maWdfX2ZhY3RvcnlBZGRyZXNzAQAAAB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JHBhc3NlZCBhbW91bnQgaXMgbGVzcyB0aGVuIGF2YWlsYWJsZQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAPc3Rha2VkQnlVc2VyS0VZCQAAZQAAAAIFAAAADHN0YWtlZEJ5VXNlcgUAAAAGYW1vdW50CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAA5zdGFrZWRUb3RhbEtFWQkAAGUAAAACBQAAAAtzdGFrZWRUb3RhbAUAAAAGYW1vdW50CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAGYW1vdW50BQAAAAdhc3NldElkCQAETAAAAAIJAQAAABVPcGVyYXRpb25IaXN0b3J5RW50cnkAAAAFAgAAAAVjbGFpbQUAAAAOdXNlckFkZHJlc3NTdHIFAAAACmFzc2V0SWRTdHIFAAAABmFtb3VudAgFAAAAAWkAAAANdHJhbnNhY3Rpb25JZAUAAAADbmlsAAAAACU8NSo=", "chainId": 84, "height": 1693749, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: JDZwcd97ucEzvVEpQ9u9YQ7CPnoPY3Q9snpqDhDDFKwi Full:
OldNewDifferences
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 userAddressStr = toString(i.caller)
56+ let amount = pmt.amount
57+ if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)))))
58+ then throw(("unsupported lp asset " + lpAssetIdStr))
59+ else {
60+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
61+ let stakedTotalKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
62+ let stakedByUser = readStaked(stakedByUserKEY)
63+ let stakedTotal = readStaked(stakedTotalKEY)
64+[IntegerEntry(stakedByUserKEY, amount), IntegerEntry(stakedTotalKEY, amount), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
65+ }
66+ }
67+ }
68+
69+
70+
71+@Callable(i)
72+func claim (assetIdStr,amount) = {
73+ let factory = readFactoryAddressOrFail()
74+ let userAddressStr = toString(i.caller)
75+ let assetId = fromBase58String(assetIdStr)
76+ if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(assetIdStr)))))
77+ then throw(("unsupported lp asset " + assetIdStr))
78+ else {
79+ let stakedByUserKEY = keyStakedByUser(userAddressStr, assetIdStr)
80+ let stakedTotalKEY = keyStakedByUser(userAddressStr, assetIdStr)
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, assetId), OperationHistoryEntry("claim", userAddressStr, assetIdStr, amount, i.transactionId)]
86+ }
87+ }
88+
89+

github/deemru/w8io/169f3d6 
23.21 ms