Pickle Finance
Contract addresses: https://github.com/pickle-finance/contracts.
Pickle Finance is an interesting "yield farming" experiment. Users deposit tokens into a "jar" (a smart contract) and the jar will leverage a "strategy" (another smart contract) to provide liquidities to different protocols in order to earn those protocol specific tokens.
We are using Scout and Etherscan to explore how the "jar" and "strategy" work. At the end of exploration, we build a dashboard for the jar 0.88a: https://scout.cool/picklefinance/mainnet/dashboards/jar-0.88a

1. Deposit and withdraw in a pickle jar:

Let us use jar 0.88a as an example. People deposit DAI into this jar and it uses the deposit to repeatedly borrow from Compound in order to earn COMP tokens.
The below screenshot on the left shows that I deposited 50 DAI from my wallet (0x6bA) to the jar 0.88a and the one on the right shows that I withdraw DAI from the same jar later on. The address of jar 0.88a is 0x6949Bb624E8e8A90F87cD2058139fcd77D2F3F87.
Please pay attention to the "Logs" section. All the interactions are listed there. For those of you who are not familiar with how Ethereum blockchain stores token number, 50000000000000000000 = 50 tokens. In this case, it's 50 DAI
TLDR: When I deposited 50 DAI, there was a Transfer(from, to, value) log from DAI contract that sends 50 DAI from my wallet (0x6bA) to the jar (0x6949Bb624...) and the jar sent 36 pDAI to my wallet. When I withdraw, the jar sent 50 DAI (plus my earnings and minus the withdraw fees) back to my wallet and my wallet sent that 36 pDAI to 0x0000... which destroyed the pDAI tokens.
Sending a user pDAI after the user deposits DAI into the jar is just a way of record keeping. As soon as a user withdraws their DAI, the pDAI will be burnt. So there is no real use of pDai other than record keeping.
There is a special case of withdraw that happens when the DAI you deposited has already been used to borrow DAI on Compound. So when you withdraw from the jar, the jar will also withdraw from Compound. Here is an example on etherscan.
The special case is important to know because you will need to factor that part in when tracking how much the strategy of the jar 0.88a has borrowed from Compound, how much COMPs have been farmed and etc. We will discuss more later.
Let us build a bar chart to visualize the Daily deposit and withdraw amount of jar 0.88

2. Strategy:

A strategy describes how a jar farms protocol tokens for you. The farming strategy for jar 0.88a is in the contract 0xCd892a97951d46615484359355e3Ed88131f82. It basically takes the DAI in the jar as a collateral to borrow from Compound recursively in order to earn COMP tokens. Take a look at a transaction from this contract. There are over 100 logs in this transaction and I have picked a few important ones for you pay attention to:
a. Collecting COMP tokens from Compound. The compound tokens were transferred to the strategy contract (0xCd892a97...) There are two logs in this transaction.
b. Borrow DAI from Compound. The strategy contract will borrow DAI from Compound via Compound DAI contract (also known as cDAI). The value under borrowAmount is the amount that you should pay attention to. If you sum up all the borrowAmount of the 3 logs, this is the total amount of DAI borrowed in this transaction.
c. Supply borrowed DAI back to Compound. In this case, the strategy contract supplied the borrowed DAI back to Compound 3 times.
It requires some basic knowledge of how Compound protocol works in order to understand some of the logs in the above transaction. Don't worry, we will cover them in a future post.
Let us build a table chart to display the borrowed DAI and earned COMP tokens of the strategy.

3. Summary of jar 0.88a:

Total deposit amount in the jar: It should be the latest "total" value on this daily cumulative chart.
Different teams might have different definitions of what "total deposit amount" means. In our opinion, the true measurement should be the user initialed deposits and withdraws. It should not include any borrowed amount from Compound.
Total borrowed amount in the jar:
To get this number, you need to sum up all the borrowed DAI from the strategy contract(left) and subtract it with the withdraw amount from the transactions which also collected COMP tokens(right). These two tables can also be found on the same dashboard.
As I explained earlier, when a user withdraws from a jar, if the deposit has already been used to borrow from Compound, that withdraw will also trigger the withdraw from Compound. That's why when calculating the total borrow, we need to factor that part in.