Merge pull request #45 into master

784f576 hledger-flow: ethereum-based: add Aave V2 -> V3 Migration Helper support (Aaron Fiore)
d31ed3a hledger-flow: ethereum-based: add to Ethereum spam rules (Aaron Fiore)
This commit is contained in:
2024-04-08 16:10:13 -07:00
3 changed files with 105 additions and 3 deletions

View File

@@ -50,12 +50,17 @@ function parse()
gsub(/,UNI-V3-POS,/, ",UNIVTHREEPOS,")
gsub(/,UNI-V2,/, ",UNIVTWO,")
# TODO: full aToken support
# TODO: full s/v/aToken support
# V2
gsub(/,variableDebtGUSD,/, ",aGUSD,")
gsub(/,variableDebtUSDC,/, ",aUSDC,")
gsub(/,variableDebtUSDT,/, ",aUSDT,")
gsub(/,variableDebtDAI,/, ",aDAI,")
# V3
gsub(/,variableDebtEthUSDC,/, ",vEthUSDC,")
printf $1 OFS # date
printf $2 OFS # blockchain
printf $3 OFS # account_name

View File

@@ -19,6 +19,8 @@
# Aave #
# ---------------------------------------------------------------------------- #
# V2
# 0x028171bca77440897b824ca71d1c56cac55b68a3 - Aave: aDAI Token V2
# 0x030ba81f1c18d280636f32af80b9aad02cf0854e - Aave: aWETH Token V2
# 0x35f6b052c598d933d69a4eec4d04c73a191fe6c2 - Aave: aSNX Token V2
@@ -29,6 +31,13 @@
# 0x9ff58f4ffb29fa2266ab25e75e2a8b3503311656 - Aave: aWBTC Token V2
# 0xbcca60bb61934080951369a648fb03df4f96263c - Aave: aUSDC Token V2
# 0xd37ee7e4f452c6638c96536e68090de8cbcdb583 - Aave: aGUSD Token V2
# 0x619beb58998eD2278e08620f97007e1116D5D25b - Aave: USDC Variable Debt V2
# TODO: expand as needed
# V3
# 0xb748952c7bc638f31775245964707bcc5ddfabfc - Aave: Migration Helper Mainnet v3
# 0x72e95b8931767c79ba4eee721354d6e99a61d004 - Aave: Ethereum Variable Debt USDC
# TODO: expand as needed
# TODO: ideally, all types are processed using 4byte method_id (deposit, swap, borrow, etc.)
@@ -131,9 +140,11 @@ if %to_address (^0x028171bca77440897b824ca71d1c56cac55b68a3$|^0x030ba81f1c18d280
# NOTE: must keep comment2 blank and comment3 filled
#
# Treat aTokens as equity (the "real" asset/liability is already accounted for)
# Treat s/v/aTokens as placeholders (the "real" asset/liability is already accounted for)
#
# V2
if %from_address ^0x0000000000000000000000000000000000000000$
& %direction ^IN$
& %symbol (^aDAI$|^aGUSD$|^aSNX$|^aUSDC$|^aUSDT$|^aWBTC$|^aWETH$|^stkAAVE$)
@@ -148,4 +159,87 @@ if %to_address ^0x0000000000000000000000000000000000000000$
account1 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
account2 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
# V3
if %from_address ^0x0000000000000000000000000000000000000000$
& %direction ^IN$
& %symbol ^vEthUSDC$
& %amount_ [1-9]
account1 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
account2 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
if %to_address ^0x0000000000000000000000000000000000000000$
& %direction ^OUT$
& %symbol ^vEthUSDC$
& %amount_ [1-9]
account1 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
account2 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
#
# Migration: V2 -> V3
#
# aWETH -> aEthWETH
# NOTE: you'll need to `manual` the staked aWETH income and subsequent
# difference to the accounts payable WETH subaccount in order to balance.
if %direction ^OUT$
& %to_address ^0xb748952c7bc638f31775245964707bcc5ddfabfc$
& %contract_address ^0x030ba81f1c18d280636f32af80b9aad02cf0854e$
& %blockchain ^ethereum$
& %type ^erc-20$
& %amount_ [1-9]
amount -%amount_ %symbol
account1 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
account2 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
comment blockchain:%blockchain, type:%type, block:%block_number, blockid:%block_hash, index:%tx_index, subaccount_address:%subaccount_address, contract_address:%contract_address, from_address:%from_address, to_address:%to_address, txid:%tx_hash, direction:%direction, taxed_as:MATCH
comment2 %tx_hash,%date +0000,SELL,%account_name,%symbol,%amount_
if %direction ^IN$
& %from_address ^0x0000000000000000000000000000000000000000$
& %contract_address ^0x4d5f47fa6a74757f35c14fd3a6ef8e3c9bc514e8$
& %blockchain ^ethereum$
& %type ^erc-20$
& %amount_ [1-9]
account1 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
account2 equity:%account_name:%subaccount_name:%blockchain:receivable:loans:%symbol
comment blockchain:%blockchain, type:%type, block:%block_number, blockid:%block_hash, index:%tx_index, subaccount_address:%subaccount_address, contract_address:%contract_address, from_address:%from_address, to_address:%to_address, txid:%tx_hash, direction:%direction, taxed_as:MATCH
comment2 %tx_hash,%date +0000,BUY,%account_name,%symbol,%amount_
if %direction ^OUT$
& %to_address ^0xb748952c7bc638f31775245964707bcc5ddfabfc$
& %blockchain ^ethereum$
& %type ^normal$
& %symbol ^ETH$
& %amount_ ^[^1-9]*$
& %fees [1-9]
account1
account2
comment blockchain:%blockchain, type:%type, block:%block_number, blockid:%block_hash, index:%tx_index, method:%method_id, subaccount_address:%subaccount_address, from_address:%from_address, to_address:%to_address, txid:%tx_hash, direction:%direction, taxed_as:MATCH
comment2
comment3 %tx_hash,%date +0000,FEE,%account_name,%symbol,%fees
# NOTE: must keep comment2 blank and comment3 filled
#
# Non-transferable placeholders are not trades
#
# aUSDC (variable debt) -> vEthUSDC
if %to_address ^0x0000000000000000000000000000000000000000$
& %contract_address ^0x619beb58998eD2278e08620f97007e1116D5D25b$
& %blockchain ^ethereum$
& %type ^erc-20$
& %amount_ [1-9]
comment blockchain:%blockchain, type:%type, block:%block_number, blockid:%block_hash, index:%tx_index, subaccount_address:%subaccount_address, contract_address:%contract_address, from_address:%from_address, to_address:%to_address, txid:%tx_hash, direction:%direction
comment2
if %from_address ^0x0000000000000000000000000000000000000000$
& %contract_address ^0x72e95b8931767c79ba4eee721354d6e99a61d004$
& %blockchain ^ethereum$
& %type ^erc-20$
& %amount_ [1-9]
comment blockchain:%blockchain, type:%type, block:%block_number, blockid:%block_hash, index:%tx_index, subaccount_address:%subaccount_address, contract_address:%contract_address, from_address:%from_address, to_address:%to_address, txid:%tx_hash, direction:%direction
comment2
# vim: sw=2 sts=2 si ai et