Accounting professionals providing digital asset accounting & tax services for individuals investing in cryptocurrencies and/or firms dealing with digital assets (treasury and/or investments), need to understand the raw on-chain transaction data from a DeFi activity perspective in order to build the proper financial reporting in compliance with the applicable jurisdiction.
Access to raw DeFi data is fairly easy, but understanding the kind of DeFi activity behind that raw data (farming, staking, LP deposits, …) often requires further processing & efforts, which is not the core of their business proposal. Advice on the correct regulatory tax event to declare for these actions, profit optimisation, cost-basis computation, … depending on the applicable jurisdiction, are the main values proposed by Accounting Service Providers and/or accounting Platform Providers to their end-clients.
For this reason, the DeFi transactions data provided by MERLIN API P&L has been enhanced with a clear classification of the DeFi action which lays behind each transaction. MERLIN understands all DeFi strategies, and knows whether the wallets interact with other wallets or with Smart Contracts (DeFi protocols).
MERLIN transaction pre-classification
Retrieving on-chain raw transaction data is fairly easy, but understanding the kind of DeFi activity behind that raw data requires further analysis and data processing. Which is where MERLIN comes in.
MERLIN’s understanding of all DeFi strategies and knowledge of all wallet’s interactions (with other wallets or smart contracts – DeFi protocols) has been translated into enhanced DeFi transaction classification, to provide the following additional information:
- the type of interaction (with wallet or smart contract),
- the type of movement (deposit, withdraw, send, receive, reward collection, liquidation, repay, …) – type of transaction,
- the type of DeFi action/investment (lending, liquidity pool, staking, farming, …),
- and to render the data exhaustive and transparent: the precise smart contract name and function (method)
Thanks to this MERLIN data, DeFi transactions can be pre-classified: save time and manual tasks to accounting professionals & end-users in the process of generating financial reports for accounting, audit, tax, … .
Based on the knowledge of their end-clients’ portfolio (wallets), accounting platform & service providers can finalize the reconciliation: the transactions classifications following the accounting/tax standards and the purpose of the financial reports to generate.
How it works
MERLIN API provides several endpoints to retrieve the transaction list by user (wallet) or by user position in a given DeFi protocol. For exhaustive API endpoints description, please refer to the dedicated MERLIN API documentation.
The transaction response object details the DeFi movement in terms of:
- Sender/receiver, interaction with wallet or smart contract (protocol)
- Execution time,
- Moved token(s),
- Transaction fees,
- P&L for DeFi movements,
- Classification of DeFi movements from a DeFi action standpoint
The DeFi movement classification is spread across several parameters:
- tyType: type of transaction (movement) with possible values: Deposit, Withdraw, Borrow, Repay, Liquidation, Collect, Exchange, Send, Receive, Transfer, Receive Rewards, Migration, …
- txAction: type of DeFi investment with possible values: Liquidity Pool, Lending, Liquid Staking, Farming, Leveraged Farming, Yield, Locked, Vesting, Options Seller, Options Buyer, Insurance Seller, Insurance Buyer, Investment, Governance
- Smart contract name
- Smart contract function name
Behind the stage
MERLIN relies on several mechanisms to qualify the transactions’ types:
- For interactions with P&L-supported protocols: MERLIN engine provides an accurate classification of all DeFi transactions as smart contracts and functions are well known.
- Possible values for wallet <> P&L-supported protocol interaction: Deposit, Withdraw, Borrow, Repay, Liquidation, Collect, Exchange, Receive Rewards, Migration, Transfer
For all other protocols/smart contracts interactions, additional processing* of related data (protocol, protocol module, smart contract function names) has been performed with the following results:
- For interactions with smart contracts with ‘relevant’ function names: analysis of common smart contract functions (Deposit, Withdraw, Borrow, Repay, Liquidation, Collect, Exchange, Receive Rewards, Migration, Transfer), shows that the function names are relevant to the actual nature of the transaction, these keywords are contained within the actual function name. Which is why a mapping of these types is made based on the keywords presence in the function name, for all smart contract functions not belonging to MERLIN P&L supported protocols.
- Possible values for wallet <> smart contracts with ‘relevant’ function name interaction: Deposit, Withdraw, Borrow, Repay, Liquidation, Collect, Exchange, Receive Rewards, Migration, Transfer
- For interaction with all other smart contracts – belonging to non P&L-supported protocols and with ‘non-relevant’/’non-qualifiable’ names: txType parameter takes the name of the smart contract function.
- For interaction with other wallets, possible values: Send, Receive – feature coming soon
Summary txType possible values:
|txType possible values||Details|
|Deposit||Deposit tokens on a position (LP, lend, liquid staking, farming, …)|
|Withdraw||Withdraw tokens from a position (LP, lend, liquid staking, farming, …)|
|Borrow||Borrow tokens, in exchange provide collateral tokens|
|Repay||Pay-back borrowed assets|
|Liquidation||In case of undercollateralized loans, smart contract sells crypto assets (borrow collaterals) to cover the debt|
|Exchange||Swap a crypto asset for another, via Dexes|
|Collect||Withdraw Rewards / Yield from an investment/protocol (dApp)|
|Receive Rewards||Proactively receive rewards from an investment/protocol (dApp)|
|Transfer||Sell or transfer property of an LP position, or funds moving out of / into the wallet outside the scope of any of the above transaction types|
|Migration||Tokens / investments which are transformed into other tokens / investments following external factors (fork, protocol decisions, …)|
|Receive*||If wallet to wallet interaction: send tokens from the user wallet to another wallet – feature coming soon|
|Send*||If wallet to wallet interaction: receive tokens in the user wallet from another wallet – feature coming soon|
Indicates the type of DeFi investment, the type of protocol (dApp, protocol module/pool) the wallet is interacting with. Applies for all MERLIN P&L-supported protocols. Please check here the complete list of MERLIN supported protocols.
|txAction values||Type of interaction||Example of protocols/protocol modules
(non exhaustive list)
|Liquidity Pool||Dexes: swap/exchange tokens or deposit liquidity to create the market||Uniswap, SushiSwap, Balancer|
|Lending||Lending & borrowing investments||Compound, Aave, Morpho|
|Liquid Staking||Stake cryptocurrency assets while still maintaining their liquidity by receiving staked liquidity tokens in return at a 1-to-1 ratio||Lido, Rocketpool|
|Locked||Similar to Liquid Staking, but implies the funds to be locked for a certain amount of time, provides higher yield than regular Liquid Staking||Frax, Thena, Solidlizard,
|Farming||Lending or staking cryptocurrency into a pool to receive rewards such as interest and more staked cryptocurrency. Deposit and Reward tokens are not the same||Convex, Curve, Frax|
|Leveraged Farming||Borrow tokens to increase farming positions and therefore, capture additional farming yields||Angle Protocol|
|Yield||Invest tokens on purely Yield generating pools||GMX, Yearn, PancakeSwap|
|Vesting||Funds movements within a Vesting process (a project’s overall token supply is set aside for a period of time and released after certain conditions are met)|
|Investment||Investments via TokenSets protocol||TokenSets|
|Governance||Interaction with Governance pools||1inch, dYdX|
|Insurance Seller||Insurance position selling investments|
|Insurance Buyer||Insurance position buying investments|
|Options Seller||Options selling investments|
|Options Buyer||Options buying investments|
Smart contract information
Smart contract raw name and raw function name are provided for eventual 3rd party processing of specific known transactions/smart contracts not covered by the above mechanisms.
Indicates the name of the protocol (dApp) with which the wallet is interacting. Applies for all MERLIN DeFi-supported protocols. Please check here the complete list of MERLIN supported protocols.
For wallet to wallet interaction, the protocol name is simply ‘wallet’ – coming soon.