From 2452c7f3179dae4c44fe2acf5042e6fc4d6967c2 Mon Sep 17 00:00:00 2001 From: Arne Lauschus Date: Tue, 3 Dec 2024 09:16:38 +0100 Subject: [PATCH] various minor changes for next alpha release --- bs-rules.dmn | 405 +++++++++++++++++++++++++++++---------------------- 1 file changed, 232 insertions(+), 173 deletions(-) diff --git a/bs-rules.dmn b/bs-rules.dmn index aa4b58c..a0f9f47 100644 --- a/bs-rules.dmn +++ b/bs-rules.dmn @@ -121,9 +121,9 @@ string - + - + @@ -523,7 +523,7 @@ then true else false - evaluationScore + if PrepareTransaction.notSupported then 0 else evaluationScore @@ -606,8 +606,7 @@ grouped: context( - // The 1st input of the event is used as an additional verification for the conclusion (output), -// as multiple contracts may have same event signature + // The 1st input of the event is used as an additional verification for the conclusion (output), as multiple contracts may have same event signature log.eventFragment.inputs[1].name @@ -638,7 +637,7 @@ log.eventFragment.inputs[1].name "_from" - "ERC20_TRANSFER" + "ERC20 TRANSFER" @@ -652,7 +651,7 @@ log.eventFragment.inputs[1].name "_owner" - "ERC20_APPROVAL" + "ERC20 APPROVAL" @@ -666,7 +665,7 @@ log.eventFragment.inputs[1].name "dst" - "WETH_DEPOSIT" + "WETH MINT" @@ -680,7 +679,7 @@ log.eventFragment.inputs[1].name "src" - "WETH_WITHDRAWAL" + "WETH BURN" @@ -770,8 +769,8 @@ else 0 - // first transform all values to upper case. Split the string into an array, -// remove the last position of the array, as it is an empty string. + // transform all values to upper case. Split the string into an array, +// remove the last position of the array (empty string). for hexChar in remove(split(upper case(hexValueWithoutPrefix),""),-1) return getDecNumberFromHex(hexChar) @@ -872,14 +871,14 @@ then AddLeadingZeros(decimals, string join(["0",value])) else value - // categorize any decodedLog + // find a category for any decoded log. for log in decodedLogs return AddLogCategory(log) - // find a contract for any categorizedLog + // find contract for any categorizedLog for log in categorizedLogs return context put(log,"contract",contractList[item.address = log.address][1]) @@ -895,7 +894,7 @@ for log in categorizedLogs return context put(log,"contract",contractList[item.a PrepareAsset({value:transaction.value, -to: transaction.to, from:transaction.from},"TVALUE") +to: transaction.to, from:transaction.from},"TRANSACTION VALUE") @@ -907,7 +906,7 @@ to: transaction.to, from:transaction.from},"TVALUE") - transaction.to + if transaction.to != null then transaction.to else "transaction.to" @@ -925,30 +924,30 @@ to: transaction.to, from:transaction.from},"TVALUE") - for asset in logsEnriched[item.category = "ERC20_TRANSFER"] -return PrepareAsset(asset, "ERC20_TRANSFER") + for asset in logsEnriched[item.category = "ERC20 TRANSFER"] +return PrepareAsset(asset, "ERC20 TRANSFER") -for asset in logsEnriched[item.category = "WETH_DEPOSIT"] -return PrepareAsset(asset,"WETH_DEPOSIT") +for asset in logsEnriched[item.category = "WETH MINT"] +return PrepareAsset(asset,"WETH MINT") - for asset in logsEnriched[item.category = "WETH_WITHDRAWAL"] -return PrepareAsset(asset,"WETH_WITHDRAWAL") + for asset in logsEnriched[item.category = "WETH BURN"] +return PrepareAsset(asset,"WETH BURN") - for asset in logsEnriched[item.category = "ERC20_APPROVAL"] -return PrepareAsset(asset,"ERC20_APPROVAL") + for asset in logsEnriched[item.category = "ERC20 APPROVAL"] +return PrepareAsset(asset,"ERC20 APPROVAL") @@ -972,8 +971,7 @@ return PrepareAsset(asset,"ERC20_APPROVAL") - // no usage -if withInput then substring(transaction.input,1,10) else "0x" + if withInput then substring(transaction.input,1,10) else "0x" @@ -992,9 +990,9 @@ if withInputDecoded then decodedInput.signature else null - // Currently no support for NFT and blob transactions -// or very large tranactions with > 100 logs. -if count(nftEvents) > 0 or transaction.type = "0x3" or logsCount > 250 then true else false + // NFT and blob transactions or very large tranactions +if count(nftEvents) > 0 or transaction.type = "0x3" +or logsCount > 250 then true else false @@ -1029,12 +1027,12 @@ then remove(remainingTraces,1) else remainingTraces - GetBalanceChanges(flatten(concatenate( -erc20Transfers, -wethDeposits, -wethWithdrawals, + GetBalanceChanges(flatten(append( if number(transactionValue.value,null,".") > 0 then transactionValue else [], +wethDeposits, +erc20Transfers, +wethWithdrawals, traces))) @@ -1112,13 +1110,13 @@ then 1 else 0 - if countAssetsOut = 1 and countAssetsIn = 1 and senderAssets.assets[flow="in"][1].category = "WETH_DEPOSIT" and receiverAssets.assets[flow="out"][1].symbol = "ETH" then true else false + if count(receiverAssets.assets[flow="out"]) = 1 and count(senderAssets.assets[flow="in"]) = 1 then if senderAssets.assets[flow="in"][1].category = "WETH MINT" and receiverAssets.assets[flow="out"][1].symbol = "ETH" then true else false else false - if countAssetsOut = 1 and countAssetsIn = 1 and senderAssets.assets[flow="out"][1].category = "WETH_WITHDRAWAL" and receiverAssets.assets[flow="in"][1].symbol = "ETH" then true else false + if count(receiverAssets.assets[flow="out"]) = 1 and count(senderAssets.assets[flow="in"]) = 1 then if senderAssets.assets[flow="out"][1].category = "WETH BURN" and receiverAssets.assets[flow="in"][1].symbol = "ETH" then true else false else false @@ -1374,7 +1372,7 @@ then assetIn.symbol else [] - flatten(for assetOut in senderAssets.assets[flow="out"] return ( + flatten(for assetOut in senderAssets.assets[flow="out" and isEthDust = false] return ( if count(receiverAssets.assets[flow="in" and ("-"+valueAndPrefix) = assetOut.valueAndPrefix and symbol = assetOut.symbol and contract = assetOut.contract]) > 0 then assetOut else [] @@ -1389,7 +1387,7 @@ then assetOut else [] - + countIn @@ -1401,8 +1399,8 @@ then assetOut else [] - - transfersOut[1].category + + transfersOut.category @@ -1429,7 +1427,10 @@ then assetOut else [] 1 - "TVALUE","TRACE" + +list contains(?,"TRANSACTION VALUE"), + +list contains(?,"TRACE") "from","to" @@ -1444,6 +1445,32 @@ then assetOut else [] + + + 1 + + + 1 + + + +list contains(?,"TRANSACTION VALUE"), + +list contains(?,"TRACE") + + + "address" + + + list contains(?,"ETH") + + + "ETH Deposit" + + + + + > 0 @@ -1452,7 +1479,8 @@ then assetOut else [] > 0 - "ERC20_TRANSFER" + +list contains(?,"ERC20 TRANSFER") "to","address" @@ -1475,7 +1503,7 @@ then assetOut else [] 1 - "ERC20_TRANSFER" + list contains(?,"ERC20 TRANSFER") "from" @@ -1570,7 +1598,7 @@ then assetOut else [] - if category in ["TRACE","TVALUE"] then 18 + if category in ["TRACE","TRANSACTION VALUE"] then 18 else if asset.contract[1].decimals > 0 then asset.contract[1].decimals else 0 @@ -1581,9 +1609,9 @@ else 0 - if category in ["ERC20_TRANSFER","ERC20_APPROVAL"] then asset.args[3].hex -else if category in ["WETH_DEPOSIT","WETH_WITHDRAWAL"] then asset.args[2].hex -else if category in ["TRACE","TVALUE"] then asset.value + if category in ["ERC20 TRANSFER","ERC20 APPROVAL"] then asset.args[3].hex +else if category in ["WETH MINT","WETH BURN"] then asset.args[2].hex +else if category in ["TRACE","TRANSACTION VALUE"] then asset.value else null @@ -1597,10 +1625,10 @@ else null - if category in ["ERC20_TRANSFER","ERC20_APPROVAL","WETH_WITHDRAWAL"] then lower case(asset.args[1]) + if category in ["ERC20 TRANSFER","ERC20 APPROVAL","WETH BURN"] then lower case(asset.args[1]) else if category = "TRACE" then lower case(asset.from) -else if category = "TVALUE" then lower case(asset.from) -else if category = "WETH_DEPOSIT" then "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" +else if category = "TRANSACTION VALUE" then lower case(asset.from) +else if category = "WETH MINT" then "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" else null @@ -1608,11 +1636,11 @@ else null - if category in ["ERC20_TRANSFER","ERC20_APPROVAL"] then lower case(asset.args[2]) -else if category = "WETH_WITHDRAWAL" then "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" -else if category = "WETH_DEPOSIT" then lower case(asset.args[1]) + if category in ["ERC20 TRANSFER","ERC20 APPROVAL"] then lower case(asset.args[2]) +else if category = "WETH BURN" then "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" +else if category = "WETH MINT" then lower case(asset.args[1]) else if category = "TRACE" then lower case(asset.to) -else if category = "TVALUE" then (if asset.to != null then lower case(asset.to) else null) +else if category = "TRANSACTION VALUE" then (if asset.to != null then lower case(asset.to) else "transaction.to") else null @@ -1625,15 +1653,15 @@ else null - if category in ["TRACE","TVALUE"] then "ETH" -else if category in ["WETH_DEPOSIT","WETH_WITHDRAWAL"] then "WETH" + if category in ["TRACE","TRANSACTION VALUE"] then "ETH" +else if category in ["WETH MINT","WETH BURN"] then "WETH" else asset.contract.symbol - if category in ["TRACE","TVALUE"] then null else asset.contract.address + if category in ["TRACE","TRANSACTION VALUE"] then null else asset.contract.address @@ -1676,7 +1704,7 @@ Please visit blockschau.io/docs for details. - if PrepareTransaction.to != null then true else false + if PrepareTransaction.to != "transaction.to" then true else false @@ -1767,7 +1795,7 @@ and count(union(SpecifyAssets.senderAssets.assets.symbol,SpecifyAssets.receiverA "Swap" - Main Actor has incoming and outgoing assets. + @@ -1784,7 +1812,7 @@ and count(union(SpecifyAssets.senderAssets.assets.symbol,SpecifyAssets.receiverA true - "Value Transfer" + "Transfer" @@ -1863,7 +1891,7 @@ and count(union(SpecifyAssets.senderAssets.assets.symbol,SpecifyAssets.receiverA - if list contains(transactionPurposes,"Value Transfer") + if list contains(transactionPurposes,"Transfer") then SpecifyTransferType(SpecifyAssets.receiverAssets,SpecifyAssets.senderAssets) else null @@ -1884,13 +1912,6 @@ then SpecifyContractInvocation(SpecifyAssets.receiverAssets,SpecifyAssets.sender else null - - - - for assetIn in SpecifyAssets.receiverAssets.assets[flow="in"] return -count(SpecifyAssets.senderAssets.assets[item.flow="out"]) - - @@ -2044,13 +2065,13 @@ FindAndCountZeroflows(groupedAssets) else 0 - FindAssetByIndex("min","ERC20_TRANSFER",balancesGroupedByAddressAndAsset) + FindAssetByIndex("min","ERC20 TRANSFER",balancesGroupedByAddressAndAsset) - FindAssetByIndex("max","ERC20_TRANSFER",balancesGroupedByAddressAndAsset) + FindAssetByIndex("max","ERC20 TRANSFER",balancesGroupedByAddressAndAsset) @@ -2119,15 +2140,13 @@ isEoa: if source = "from" then true - //if sender.source = "unknown" then SpecialCase("sender", PrepareTransaction.balanceChanges,eOAs) else sender -sender + sender - //if receiver.source = "unknown" then SpecialCase("receiver", PrepareTransaction.balanceChanges,eOAs) else receiver -receiver + receiver @@ -2975,21 +2994,47 @@ receiver - - { -notEmptyBalances: if groupedBalances != null and count(get entries(groupedBalances).key) > 0 then true else false, -balances: if notEmptyBalances + + + + + if groupedBalances != null and count(get entries(groupedBalances).key) > 0 then true else false + + + + + + if notEmptyBalances then flatten(for address in get entries(groupedBalances).key return get value(groupedBalances, address)[1].category[1]) - else [], -index: if count(balances[item.category=cat].index) > 0 + else [] + + + + + + if count(balances[item.category=cat].index) > 0 then if find = "min" then min(balances[item.category=cat].index) else max(balances[item.category=cat].index) - else 0, -address: flatten(for address in get entries(groupedBalances).key - return if list contains(get value(groupedBalances, address)[1].category[1].index,index) then address else []) -}.address[1] - + else 0 + + + + + + flatten(for address in get entries(groupedBalances).key + return + if count(get value(groupedBalances, address)[1].category[1]) > 0 + then if list contains(get value(groupedBalances, address)[1].category[1].index,index) then address else [] + else []) + + + + + if count(addresses) > 0 then addresses[1] else null + + + @@ -3271,54 +3316,54 @@ category: if candidate != null then candidate.category else [] 50 188 - 1239 + 1199 - 1239 + 1199 50 352 153 199 - 465 + 425 - 1239 + 1199 50 - 1497 + 1457 50 316 - 787 + 767 - 787 + 767 - 787 + 767 - 787 + 767 - 787 + 767 - 787 + 767 - 787 + 767 - 787 + 767 50 - 1173 + 1153 637 @@ -3417,31 +3462,31 @@ category: if candidate != null then candidate.category else [] 50 123 - 1085 + 1045 - 1085 + 1045 - 1085 + 1045 - 1085 + 1045 - 1085 + 1045 - 1085 + 1045 - 1085 + 1045 - 1085 + 1045 - 1085 + 1045 50 @@ -3452,34 +3497,34 @@ category: if candidate != null then candidate.category else [] 103 102 239 - 159 + 119 - 1085 + 1045 50 - 1278 + 1238 50 120 - 1412 + 1384 - 1412 + 1384 - 1412 + 1384 - 1412 + 1384 - 1412 + 1384 - 1412 + 1384 50 @@ -3489,14 +3534,14 @@ category: if candidate != null then candidate.category else [] 161 168 334 - 128 + 100 - 1412 + 1384 50 - 1602 + 1574 50 @@ -3521,43 +3566,43 @@ category: if candidate != null then candidate.category else [] 50 369 - 670 + 570 - 670 + 570 50 100 - 500 + 400 - 500 + 400 - 500 + 400 - 670 + 570 - 670 + 570 - 670 + 570 - 670 + 570 - 670 + 570 - 670 + 570 50 - 1109 + 1009 50 @@ -3605,9 +3650,6 @@ category: if candidate != null then candidate.category else [] 1200 - - 1200 - 50 120 @@ -3796,11 +3838,28 @@ category: if candidate != null then candidate.category else [] 1260 - 1194 + 50 + 120 + 979 + + + 979 + + + 979 + + + 979 + + + 979 + + + 979 50 - 1194 + 1169 1015 @@ -3887,7 +3946,7 @@ category: if candidate != null then candidate.category else [] - + @@ -3950,7 +4009,7 @@ category: if candidate != null then candidate.category else [] - + @@ -3995,7 +4054,7 @@ category: if candidate != null then candidate.category else [] - + @@ -4058,7 +4117,7 @@ category: if candidate != null then candidate.category else [] - + @@ -4085,7 +4144,7 @@ category: if candidate != null then candidate.category else [] - + @@ -4157,7 +4216,7 @@ category: if candidate != null then candidate.category else [] - + @@ -4179,19 +4238,19 @@ category: if candidate != null then candidate.category else [] - - + + - - + + - + - + @@ -4200,50 +4259,50 @@ category: if candidate != null then candidate.category else [] - + - + - + - + - + - + - + - + - + - - + + - + @@ -4255,16 +4314,16 @@ category: if candidate != null then candidate.category else [] - + - + - + @@ -4283,32 +4342,32 @@ category: if candidate != null then candidate.category else [] - - + + - + - + - + - - + + - + - + @@ -4316,11 +4375,11 @@ category: if candidate != null then candidate.category else [] - + - +