tx · 4yXNVTb9Pk8wjQQFuweY7GGJUjdDajMYDUDFoxjSsdQy

3N6DGohy3A1oqkBk6F4BRPHrqgkVgwxWd8g:  -0.01000000 Waves

2021.09.08 12:28 [1693891] smart account 3N6DGohy3A1oqkBk6F4BRPHrqgkVgwxWd8g > SELF 0.00000000 Waves

{ "type": 13, "id": "4yXNVTb9Pk8wjQQFuweY7GGJUjdDajMYDUDFoxjSsdQy", "fee": 1000000, "feeAssetId": null, "timestamp": 1631093389706, "version": 1, "sender": "3N6DGohy3A1oqkBk6F4BRPHrqgkVgwxWd8g", "senderPublicKey": "AkPpYa8oqgaNXjTSuWGaMCnJ6y44pYUMeskeBjzVgPhr", "proofs": [ "5GjPikA8yreyXR6nsy17cqL3n3J6EXbbtS7ZMFheT4UbEm9SV6WmACxyXCUkTrkeb7eZP6mD9ymC5KsQiNqua1XL" ], "script": "base64:AAIFAAAAAAAAAA8IAhIDCgEIEgASBAoCCAEAAAAMAAAAAANTRVACAAAAAl9fAQAAAA9nZXRTdHJpbmdPckZhaWwAAAABAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEIgAAAAEFAAAAA2tleQkAASwAAAACCQABLAAAAAICAAAAD21hbmRhdG9yeSB0aGlzLgUAAAADa2V5AgAAAA8gaXMgbm90IGRlZmluZWQBAAAAGGdldFN0cmluZ0J5QWRkcmVzc09yRmFpbAAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAKbWFuZGF0b3J5IAkABCUAAAABBQAAAAdhZGRyZXNzAgAAAAEuBQAAAANrZXkCAAAADyBpcyBub3QgZGVmaW5lZAEAAAARa2V5RmFjdG9yeUFkZHJlc3MAAAAAAgAAABwlcyVzX19jb25maWdfX2ZhY3RvcnlBZGRyZXNz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ZWRUb3RhbEtFWQMJAABmAAAAAgUAAAAGYW1vdW50BQAAAAxzdGFrZWRCeVVzZXIJAAACAAAAAQIAAAAkcGFzc2VkIGFtb3VudCBpcyBsZXNzIHRoZW4gYXZhaWxhYmxlCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAA9zdGFrZWRCeVVzZXJLRVkJAABlAAAAAgUAAAAMc3Rha2VkQnlVc2VyBQAAAAZhbW91bnQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIFAAAADnN0YWtlZFRvdGFsS0VZCQAAZQAAAAIFAAAAC3N0YWtlZFRvdGFsBQAAAAZhbW91bnQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAAB2Fzc2V0SWQJAARMAAAAAgkBAAAAFU9wZXJhdGlvbkhpc3RvcnlFbnRyeQAAAAUCAAAABWNsYWltBQAAAA51c2VyQWRkcmVzc1N0cgUAAAAKYXNzZXRJZFN0cgUAAAAGYW1vdW50CAUAAAABaQAAAA10cmFuc2FjdGlvbklkBQAAAANuaWwAAAAAdndHyg==", "chainId": 84, "height": 1693891, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2X34MQo4U98fTXgvBRU4MAP4RsESyBvnvXrU6eWY9avC Next: 8bEW6uZ6vPS8ahgjr7nNDVCZmQXAAabV9tHCb2dHTXZN Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined"))
77
88
99 func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
1010
1111
1212 func keyFactoryAddress () = "%s%s__config__factoryAddress"
1313
1414
1515 func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP)
1616
1717
1818 func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(keyFactoryAddress()))
1919
2020
2121 func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP)
2222
2323
2424 func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr)
2525
2626
2727 func readStaked (key) = valueOrElse(getInteger(this, key), 0)
2828
2929
3030 func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP)
3131
3232
3333 func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP)
3434
3535
3636 func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount))
3737
3838
3939 @Callable(i)
4040 func constructor (factoryAddressStr) = if ((i.caller != this))
4141 then throw("not authorized")
4242 else [StringEntry(keyFactoryAddress(), factoryAddressStr)]
4343
4444
4545
4646 @Callable(i)
4747 func stake () = {
4848 let factory = readFactoryAddressOrFail()
4949 if ((size(i.payments) != 1))
5050 then throw("invalid payment - exact one payment must be attached")
5151 else {
5252 let pmt = i.payments[0]
5353 let lpAssetId = value(pmt.assetId)
5454 let lpAssetIdStr = toBase58String(lpAssetId)
5555 let userAddressStr = toString(i.caller)
5656 let amount = pmt.amount
5757 if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)))))
5858 then throw(("unsupported lp asset " + lpAssetIdStr))
5959 else {
6060 let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
6161 let stakedTotalKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
6262 let stakedByUser = readStaked(stakedByUserKEY)
6363 let stakedTotal = readStaked(stakedTotalKEY)
6464 [IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
6565 }
6666 }
6767 }
6868
6969
7070
7171 @Callable(i)
7272 func claim (assetIdStr,amount) = {
7373 let factory = readFactoryAddressOrFail()
7474 let userAddressStr = toString(i.caller)
7575 let assetId = fromBase58String(assetIdStr)
7676 if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(assetIdStr)))))
7777 then throw(("unsupported lp asset " + assetIdStr))
7878 else {
7979 let stakedByUserKEY = keyStakedByUser(userAddressStr, assetIdStr)
8080 let stakedTotalKEY = keyStakedByUser(userAddressStr, assetIdStr)
8181 let stakedByUser = readStaked(stakedByUserKEY)
8282 let stakedTotal = readStaked(stakedTotalKEY)
8383 if ((amount > stakedByUser))
8484 then throw("passed amount is less then available")
8585 else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, assetId), OperationHistoryEntry("claim", userAddressStr, assetIdStr, amount, i.transactionId)]
8686 }
8787 }
8888
8989

github/deemru/w8io/169f3d6 
47.76 ms