This a set of contracts used to build the buidl guidl trade environment and includes stripped back versions of common defi concepts to help builders understand how they work and how they can be built. View the current buidl guidl trading game repo here.
Contributions, including new contracts, code reviews, and further tests all welcome ❤️
Both are basic ERC20 token implementations that allow the owner to airdrop new tokens to users. Credit tokens are used as a defacto unit of account in the buidl game. Asset tokens are the tokens that users trade credits for.
BasicBorrower is a stripped back implementation of a borrowing and lending contract. Users can deposit liquidity which other users can then borrow from. Users borrows must be overcollateralised (they must supply more liquidity than they borrow). If users debt gets close to being unpayable by their remaining liquidity their borrow can be liquidated. BasicBorrower's liquidity is managed using the ERC4626 vault standard.
BasicDex is an MVP exchange contract that allows ERC20-ERC20 trading pairs. Users can provide liquidity and earn fees. The contract also has slippage protection which, where minimum return amounts can be provided by the user.
BasicDexV2 builds upon BasicDex but issues an ERC20 token to liquidity providers to track their share of the token pairs liquidity pool.
Allows a user to lock ERC20 tokens for an arbitrary amount of time (7 days). No fees or rewards are issues.
BasicRouter aims to improve user experience by batching transactions between two dexes that share a common token. For example if there two pools - APPLE/CREDIT & BANANA/CREDIT, but no APPLE-BANANA. The router lets users trade directly APPLE -> BANANA (or vice versa). This allows users to have a cleaner experience without having to spread liquidity further by adding more pools.
DisperseFunds is an airdropper contract that allows the gamesmaster to airdrop the chains gas token + CREDITs to players in the game. The gamesmaster first sends some gas token + CREDITs to the contract and can then provide an array of addresses who will receive an amount of each.
FruitBasket is an on chain index fund contract which takes an amount of credits and uses it to buy the various fruit tokens. Buyers are given an ERC20 which represents their share of the funds fruit tokens. This token can be transferred, traded on DEXes or user can claim back their stake in the fruit basket fund. Claiming involves burning the users FruitBasket tokens, selling their share of the funds fruit tokens and sending the user the CREDIT tokens their stake was worth.
As FruitBasket but now uses the ERC4626 vault standard for managing the contracts Credit tokens & the Shares ERC20 Token.
FruitPrediction is a basic implementation of an onchain prediction market. The user can bet whether a chosen token will be priced higher or lower 10 minutes from now. The contract uses the tokens associated dex price to calculate it's changes in price. If the users prediction is correct they have a further 10 minutes to claim their wager to return 2x their stake (minus a 5% fee)
Allows a user to lock a specific LP token for an arbitrary amount of time (7 days). Users are issued 5% of their locked amount in a reward token upon completion of their lock time. Redeeming LP and redeeming rewards are split into two transactions to avoid the risk of LP tokens getting permanently locked in the contract if there are no rewards token in the contract.
Based on the Synthetix Staking contract. Allows the contract creator to offer a reward token to users for staking a specified token.