Berry Club Part II: How Does The Berry Club Yield Farming App Work?
Let’s Put It To The Test
For an introduction to Yield Farming on NEAR, see Part 1, Berry Club: A Fun, Creative Example of a DeFi Yield Farming App on NEAR Protocol
Berry Club Background
Berry Club is one of the oldest and certainly most engaging smart contracts on the NEAR blockchain. Berry Club has actually been around since before the NEAR mainnet was launched. Berry Club and sister contracts Berry Farm and Banana Swap are a suite of DeFi yield farming smart contracts. They were developed partly for community participation and creativity, but also to prove the viability of DeFi apps on NEAR.
Let’s start the tour with some details on each of the smart contracts related to Berry Club.
Artwork From Avocados
Berry Club is a yield farming application that allows users to purchase Avocados (tokens) with NEAR at fixed rates. These Avocados can then be “planted” on a public board of colored pixels. In aggregate, these pixels create an ever-changing shared piece of art.
It’s a crazy mix between a chat room and graffiti wall. Here are a few snapshots.
Farming Avocados, Bananas, and Cucumbers
But there’s an even more interesting aspect to these pixels. Each pixel a user owns will pay a yield denominated either in Bananas or Avocados, based on the user’s preference (you will begin to notice the farming theme if you aren’t already familiar with Berry Club). This allows for beautiful game theory driven community-created artwork to be consistently changed and collaborated on.
Let’s add Cucumbers to the farm. Berry Farm allows these hard-working farmers (or users) to swap Bananas for Cucumbers at a 1:1 ratio. But why would they want a Cucumber when they have already purchased Avocados and earned Bananas?
Cucumbers pay a yield denominated in NEAR that is proportional to each farmer’s share of all Cucumbers. That is to say: if there are 100 Cucumbers total, and you own 1 Cucumber, then you will receive 1% of each of the NEAR reward distributions. These distributions are paid whenever any user draws on the pixel board (at most once per minute). The NEAR rewards distribution method highlights one of the coolest features about NEAR and Berry Farm: a portion of the NEAR distributions are actually taken from the gas that is used to interact with the smart contract, while the rest is distributed from Avocado purchases. This Contract Reward provides an incentive to build quality smart contracts on NEAR, and can help smart contracts become more self-sustaining.
This nicely highlights one of NEAR’s distinctive features: the creator of each smart contract can automatically receive a portion of rewards whenever the contract is used.
Last but not least in the Berry Club ecosystem, there is Banana Swap: an automated market maker that services the Banana economy, allowing users to buy and sell Bananas directly for NEAR. This is a tiny version of Uniswap that was one of the first proofs of working AMM contracts on NEAR. Now that we have introduced all of the building blocks of Berry Club, let’s do some farming.
Trying Out Berry Club
DeFi is all about experimentation, so no blog post about DeFi would be complete without a little bit of first-hand user data.
Below is an example of what a new Berry Club farmer will experience starting out. For ease of understanding, it is narrated in the first person:
25 Avocados are given to each new user, so that’s where I started the experiment. After those were received, used 5 NEAR to purchase 1500 Avocados at a rate of 300 Avocados per NEAR (an advantaged rate compared to the 250 Avocados per NEAR for smaller NEAR amounts). I planted the Avocados with care on the Berry Club drawing board in batches of 150-250 at a time. The UI makes note that you should not destroy the lovely artwork, and that if you would merely like to farm Bananas, that you should set the opacity lower in order to preserve the underlying creations. So that is mostly what I did, occasionally adding darker pixels when I felt that it would add to the artwork. Eventually, after some experimentation, I find that actually contributing original artwork to the board, rather than merely yield farming the clear pixels, was the optimal strategy.
My bountiful Avocado fields would yield me a harvest of 250 bananas per day. Fantastic! But not so fast. Bananas are only received for the spaces on the board that you currently own, so the 250 banana per day yield was quickly reduced as others drew pixels on top of mine. And herein lies the beauty of the design of Berry Club: each user can optimize their own strategy based on what they observe happening on the board in real-time.
A Good Harvest
When all was said and done and I had harvested my crops, the initial 5 NEAR that I had converted into 1500 Avocados yielded me 109.9 Bananas total – 75.9 of which were swapped back into 10 NEAR on Banana Swap, and the other 34 being converted into Cucumbers on Berry Farm.
This was good enough for a 0.022% share of all Cucumbers and generated a reward in NEAR.The NEAR denominated price of Bananas on Banana Swap varied (as it should with a constant product automated market maker) on each of the swaps. In this way, the combination of Berry Farm and Banana Swap give the user the choice between a high time preference and a low time preference. Users can simply farm Bananas and sell them directly for NEAR, or swap their Bananas for Cucumbers and collect NEAR passively. The entire process took two days (it could have been shorter, if I had been more active in drawing), which gave a point estimate of the yield earned of a mind-melting 18,250% per year.
I attempted to replicate these results a second time with another 5 NEAR, and I got a point estimate of the annual yield earned of 6,000% amidst a falling Banana market. As I said earlier: may the best artist (and farmer) win! I could have chosen a completely Cucumber-centric model for testing, but deemed that the constant creation of more Cucumbers constitutes a dynamic system that would be too complex to analyze for such a blog post.
Testing Banana Swap
Seeing that there was a decentralized exchange, of course I had to go see if I could break it. Similar to Uniswap, Banana Swap uses a bonding curve that generates the relative token price based on the amount of NEAR and Bananas in the liquidity pool (less a fee, of course). In its current implementation, Banana Swap does not allow users to add more liquidity themselves, but rather charges a 10% fee on swaps and automatically adds those balances to the liquidity pool. In this way, liquidity on Banana Swap is self-sustaining, but also limited to natural growth. In it’s beta implementation, Banana Swap is technically vulnerable to an overflow exploit. However, thanks to the Rust programming language that NEAR supports, the overflow error cannot be exploited.
At this point it’s important to note that Berry Club is a proof of concept that is meant to highlight the ease of use of the NEAR blockchain as well as some of the newest protocol standards. One of those standards is NEP-122, the allowance-free vault-based token standard. Another example is the use of Restricted Access Keys, which allow for the end user experience to be much smoother as well as more secure. Restricted Access Keys can be restricted to specific NEAR allowances and method names (for example: the Restricted Access Keys for Berry Club only allow for the drawing method to be called, and not to make deposits from your account).
Berry Club is a fun and engaging way to participate in a live dApp on the NEAR mainnet. That is to say: you should only participate in Berry Club, Berry Farm, and Banana Swap with a degree of curiosity and as many NEAR as you can afford to lose. With that in mind, I hope you’ll try it out and see if the results of your yield farming strategy can beat my results!
Yield Farming Experimental Results
SPENT: 5 NEAR for 1500 Avocados
30 Banana -> 30 Cucumber
1 NEAR @ 15.7 Banana = 15.7 Banana
1 NEAR @ 17.3 Banana = 17.3 Banana
4 NEAR @ 3.8 Banana = 15.2 Banana
2 NEAR @ 6.1 Banana = 12.2 Banana
1 NEAR @ 6.9 Banana = 6.9 Banana
1 NEAR @ 8.6 Banana = 8.6 Banana
Total: 75.9 Banana for 10 NEAR, 34 cucumbers (0.022% share) = 109.9 Banana total in 2 days
Spent: 5 NEAR for 1500 Avocados
17 Banana -> 17 Cucumber = 17 Banana
2 NEAR @ 12.935 Banana = 25.87 Banana
1 NEAR @ 13.2 Banana = 13.2 Banana
1 NEAR @ 15.9 Banana = 15.9 Banana
1 NEAR @ 17.9 Banana = 17.9 Banana
1 NEAR @ 19.5 Banana = 19.5 Banana
1 NEAR @ 18.9 Banana = 18.9 Banana
TOTAL: 111.27 Banana for 7 NEAR, 17 cucumbers
187.17 Banana/17 NEAR (11 Banana/NEAR average price) + 51 Cucumbers (0.032% share), 0.13 NEAR yield from Cucumbers = 71.3%
NEAR-denominated return in 4 days = about 6,000% APY
You can view some time-lapse summaries of shared Berry Club artwork on Youtube https://youtu.be/PYF6RWd7ZgI
Get started on Berry Club today!
Join the community: