-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrecords.py
190 lines (180 loc) · 7.67 KB
/
records.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Records objects
def EventsMap():
return {
'tavern': [],
'swaps': [],
'trades': [],
'liquidity': [],
'wallet': [],
'bank': [],
'gardens': [],
'quests': [],
'alchemist': [],
'airdrops': [],
'lending': [],
'gas': 0
}
# Records for Capital Gains
class TavernTransaction:
def __init__(self, txHash, network, itemType, itemID, event, timestamp, coinType, coinCost=0, fiatType='usd', fiatAmount=0, seller='', fiatFeeValue=0):
self.txHash = txHash
self.network = network
# hero or pet or land
self.itemType = itemType
self.itemID = itemID
# purchase/sale/hire/summon/crystal/perished/incubate/crack/pvpfee/pvpreward
self.event = event
self.timestamp = timestamp
self.coinType = coinType
self.coinCost = coinCost
self.fiatType = fiatType
self.fiatAmount = fiatAmount
self.fiatFeeValue = fiatFeeValue
# Wallet address of seller in transaction or other metadata for non sale records
self.seller = seller
class TraderTransaction:
def __init__(self, txHash, network, timestamp, swapType, receiveType, swapAmount=0, receiveAmount=0, fiatType='usd', fiatSwapValue=0, fiatReceiveValue=0, fiatFeeValue=0):
self.txHash = txHash
self.network = network
# timestamp of block when this transaction was done
self.timestamp = timestamp
# token type that was traded away
self.swapType = swapType
self.swapAmount = swapAmount
# token type that was received
self.receiveType = receiveType
self.receiveAmount = receiveAmount
# fiat equivalents of token values at the time
self.fiatType = fiatType
self.fiatSwapValue = fiatSwapValue
self.fiatReceiveValue = fiatReceiveValue
self.fiatFeeValue = fiatFeeValue
# These are tracking fields for tracking amounts that have been allocated for tax records during mapping
self.swapAmountNotAccounted = swapAmount
self.receiveAmountNotAccounted = receiveAmount
class LiquidityTransaction:
def __init__(self, txHash, network, timestamp, action, poolAddress, poolAmount, coin1Type, coin1Amount, coin2Type, coin2Amount, fiatType='usd', coin1FiatValue=0, coin2FiatValue=0, fiatFeeValue=0):
self.txHash = txHash
self.network = network
# timestamp of block when transaction was done
self.timestamp = timestamp
# deposit tokens or withdraw (LP tokens)
self.action = action
# which liquidity pool
self.poolAddress = poolAddress
# number of LP tokens
self.poolAmount = poolAmount
# coin 1 should be the native token (jewel/crystal)
self.coin1Type = coin1Type
self.coin1Amount = coin1Amount
self.coin2Type = coin2Type
self.coin2Amount = coin2Amount
self.fiatType = fiatType
self.coin1FiatValue = coin1FiatValue
self.coin2FiatValue = coin2FiatValue
self.fiatFeeValue = fiatFeeValue
# Tracking for mapping amounts to tax records
self.amountNotAccounted = poolAmount
# Records for Income
class GardenerTransaction:
def __init__(self, txHash, network, timestamp, event, coinType, coinAmount=0, fiatType='usd', fiatValue=0, fiatFeeValue=0):
self.txHash = txHash
self.network = network
self.timestamp = timestamp
# deposit, withdraw, staking-reward, staking-reward-locked
self.event = event
self.coinType = coinType
self.coinAmount = coinAmount
self.fiatType = fiatType
self.fiatValue = fiatValue
self.fiatFeeValue = fiatFeeValue
self.amountNotAccounted = coinAmount
class BankTransaction:
def __init__(self, txHash, network, timestamp, action, xRate, coinType, coinAmount=0, fiatType='usd', fiatValue=0, fiatFeeValue=0):
self.txHash = txHash
self.network = network
self.timestamp = timestamp
# deposit or withdraw or claim or extend or burn
self.action = action
# Bank xJewel/interest multiplier at the time or cJewel rcvd ratio for Jeweler
self.xRate = xRate
self.coinType = coinType
self.coinAmount = coinAmount
self.fiatType = fiatType
self.fiatValue = fiatValue
self.fiatFeeValue = fiatFeeValue
# Just for tracking amounts that have been allocated to tax records during mapping
if xRate > 0:
self.amountNotAccounted = coinAmount / xRate
else:
self.amountNotAccounted = coinAmount
class AirdropTransaction:
def __init__(self, txHash, network, timestamp, address, tokenReceived, tokenAmount=0, fiatType='usd', fiatValue=0, fiatFeeValue=0):
self.txHash = txHash
self.network = network
self.timestamp = timestamp
self.address = address
self.tokenReceived = tokenReceived
self.tokenAmount = tokenAmount
self.fiatType = fiatType
self.fiatValue = fiatValue
self.fiatFeeValue = fiatFeeValue
# Just for tracking amounts that have been allocated to tax records during mapping
self.amountNotAccounted = tokenAmount
class QuestTransaction:
def __init__(self, txHash, network, timestamp, rewardType, rewardAmount=0, fiatType='usd', fiatValue=0, fiatFeeValue=0):
self.txHash = txHash
self.network = network
self.timestamp = timestamp
# what did we get on the quest, address of it
self.rewardType = rewardType
self.rewardAmount = rewardAmount
self.fiatType = fiatType
self.fiatValue = fiatValue
self.fiatFeeValue = fiatFeeValue
self.amountNotAccounted = rewardAmount
class walletActivity:
def __init__(self, txHash, network, timestamp, action, address, coinType, coinAmount=0, fiatType='usd', fiatValue=0, fiatFeeValue=0):
self.txHash = txHash
self.network = network
self.timestamp = timestamp
# deposit/payment/withdraw/bridge/donation
self.action = action
self.address = address
self.coinType = coinType
self.coinAmount = coinAmount
self.fiatType = fiatType
self.fiatValue = fiatValue
self.fiatFeeValue = fiatFeeValue
# Just for tracking amounts that have been allocated to tax records during mapping
self.amountNotAccounted = coinAmount
class AlchemistTransaction:
def __init__(self, txHash, network, timestamp, craftingType, craftingAmount=0, fiatType='usd', fiatValue=0, craftingCosts=0, costsFiatValue=0, fiatFeeValue=0):
self.txHash = txHash
self.network = network
self.timestamp = timestamp
# what did we craft with alchemist, address of it
self.craftingType = craftingType
# how many were crafted
self.craftingAmount = craftingAmount
self.fiatType = fiatType
self.fiatValue = fiatValue
self.fiatFeeValue = fiatFeeValue
# list of ingredients and qty burned
self.craftingCosts = craftingCosts
# fiat value of those ingredients at the time
self.costsFiatValue = costsFiatValue
class LendingTransaction:
def __init__(self, txHash, network, timestamp, event, address, coinType, coinAmount=0, fiatType='usd', fiatValue=0, fiatFeeValue=0):
self.txHash = txHash
self.network = network
self.timestamp = timestamp
# lend/redeem/borrow/repay/liquidate
self.event = event
self.address = address
self.coinType = coinType
self.coinAmount = coinAmount
self.fiatType = fiatType
self.fiatValue = fiatValue
self.fiatFeeValue = fiatFeeValue
self.amountNotAccounted = coinAmount