turbo-eth/template-web3-app

Bounty: PoolTogether Integration - 250 OP Reward

kamescg opened this issue Β· 2 comments

πŸ‘¨β€πŸ’» User Story

As a Web3 protocol developer I want to easily integrate decentralized finance primitives into my application.

More specifically I want to utilize PoolTogether the prize savings network. Giving users the ability to easily deposit into a web3 savings network and automatically win prizes.

πŸ“œ Disclaimer

To be eligible for the payout you must first get approval to work on the bounty.

It's recommended to share a link to your personal Github account when introducing yourself.

🧱 Project

Integrate the PoolTogether V4 protocol into the TurboETH.

The integration should include the ability to deposit and withdraw from the PoolTogether prize savings network on Ethereum, Optimism and Polygon.

Example of PrizePool and Ticket smart contracts deployed on Optimism:

PoolTogether users interact with the YieldSourcePrizePool smart contract. Mainly calling the depositTo, depositToAndDelegate and withdraw functions.

The Ticket contract is the ERC20 token that "holds" the chance to win prizes. A ptUSDC token is minted 1-to-1 when USDC is deposited into the YieldSourcePrizePool smart contract.

Required Functionality:

  1. WAGMI CLI configuration to auto-generate read,write and event hooks
  2. Deposit into PoolTogether V4
  3. Withdraw from PoolTogether V4

Developer Tasks:

  • Add essential PoolTogether V4 smart contract artifacts
    • yield-source-prize-pool-abi.json and yield-source-prize-pool-bytecode.json
    • ticket-abi.json and ticket-bytecode.json
  • Create wagmi.config.js - Configure to use essential smart contract artifacts
  • Create Component - form-yield-source-prize-pool-deposit.tsx
  • Create Component - form-yield-source-prize-pool-withdraw.tsx
  • Create Contract List - prize-pool-contract-list.ts

The Contract List should include the USDC prizes pool and ticket addresses.

https://dev.pooltogether.com/protocol/deployments/mainnet/

Template - PrizePool Contract Address List

{
	1: '',
	10: '0x79Bc8bD53244bC8a9C8c27509a2d573650A83373',
	137: '',
}

Template - Ticket Contract Address List

{
	1: '',
	10: '0x62BB4fc73094c83B5e952C2180B23fA7054954c4',
	137: '',
}

The contract lists can be passed into a hook like the one below to easily update the deposit and withdraw components with the right smart contract addresses.

import { useNetwork } from 'wagmi'

interface ContractChainList {
	[key: number]: string
}

export const useLoadContractFromChainId = (list: ContractChainList) => {
	const { chain } = useNetwork()
	return list[chain?.id || 1] || undefined
}

# Example of Usage - USDC Tokens
const contractAddress = useLoadContractFromChainId({
	1: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
	4: '0x4f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa',
	137: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
})

Potential File Structure

Integration

The PoolTogether integration should be added to the integrations/pooltogether-v4 folder.

integrations/pooltogether-v4
β”œβ”€ abis/
β”‚  β”œβ”€ yield-source-prize-pool-abi.json
β”‚  β”œβ”€ yield-source-prize-pool-bytecode.json
β”œβ”€ components/
β”‚  β”œβ”€ form-yield-source-prize-pool-deposit.tsx
β”‚  β”œβ”€ form-yield-source-prize-pool-withdraw.tsx
β”œβ”€ hooks/
β”‚  β”œβ”€ **/*.ts
β”œβ”€ utils/
β”‚  β”œβ”€ **/*.ts
β”œβ”€ prize-pool-contract-list.ts
β”œβ”€ ticket-contract-list.ts
β”œβ”€ pooltogether-v4-wagmi.ts
β”œβ”€ wagmi.config.ts
β”œβ”€ README.md```
Application

The application pages should be added to the app/pooltogether-v4 folder.

app/pooltogether-v4
β”œβ”€ deposit
β”‚  β”œβ”€ page.tsx
β”œβ”€ withdraw
β”‚  β”œβ”€ page.tsx

πŸ’° Bounty Reward

The bounty reward is 250 tokens and TurboETH DevPass digital collectible.

TurboETH is the recipient of 18,271.88 OP Tokens from Optimism Retroactive Public Goods Funding. The OP tokens earned from the PGF program are the primary funding source for TurboETH bounties.

Notice

The final integration may not resemble the proposed integration - that's O.K - a natural part of software development.

During development you might discover an original hypothesis doesn't make sense. No problem. Make a comment and clearly explain why a new approach is better than old one. Get rewarded for thinking out of the box.

The final bounty reward can be increased to match new bounty tasks.

Resources

Feel likes the perfect bounty ! I've been part of the PoolTogether for a year and a half, building tools and adding features to the current PoolTogether ecosystem. Also I was able to try TurboETH for a "PoolTogether Dashboard".
This bounty will help me to dig more in TurboETH as well as providing components for futur projects

I think it's a perfect fit too @MAlvarez-0. Thanks for hopping the Discord and sharing some of your background.

Consider the bounty yours 🀝