[Testnet] Open Action | Cashtags
Earn trading fees from trades on your Lens profile
ℹ️ This technical guide will go over our open action from a protocol perspective, and then with a full typescript example to initialize and process a post with the MoneyClubsAction
(DEPRECATED)
Smart Contract Overview (Base Sepolia)
MoneyClubs
Contract events can be queried via TheGraph
The MoneyClubsAction
module enables trading for Lens handles - or cashtags - on a bonding curve. Anyone can enable trades for their cashtag by purchasing the initial supply for their Lens handle, which enables the bonding curve. This is similar to friendtech, but with less aggressive prices, and with six decimals of precision. As people buy/sell the $cashtag, the protocol fees get split between the protocol, creator, and client address (if any).
The action module sends transactions to the core contract MoneyClubs
- which is callable from outside the open action. The open action simply enables trades on a Lens post, and users the Lens profile owner as the beneficiary address. By separating the logic into two contracts, we can also invite participants from outside the Lens ecosystem.
ℹ️ To query contract state and get current prices, you will call the MoneyClubs
contract
Anyone can register their cashtag by calling the MoneyClubs
contract, and approving the required $bonsai to pay for the initial supply required. This registration only needs to be done once, and can be done via the open action to announce the cashtag via a Lens post. Subsequent posts with the open action will simply enable trades on the post.
ℹ️ We use the terms club and cashtag interchangeably. The final product name is subject to change.
Now we'll review the main contract functions for MoneyClubs
- without the open action
MoneyClubs Contract
Register club
Anyone can register their cashtag by calling the appropriate function on the MoneyClubs
contract.
To link it to a Lens profile, you must call the contract from the EOA of the Lens profile owner
You must purchase the initial supply of the bonding curve (max 10)
You must approve the correct amount of $bonsai to purchase the initial supply
The solidity functions to get the initial cost and register the cashtag are
So to register the club, and pay for one share
Get information for registered clubs
The index for clubs is the creator address
, and you can get information via the MoneyClubs
contract or the subgraph
Or query the subgraph to get information like the supply
and marketCap
. currentPrice
might not be up-to-date, so make sure to query the contract for executing trades. When looking at the trades
array, the id
refers to the wallet address that
Get a balance
To get the balance of shares in a club for a given address, you can call the balances
view function on the MoneyClubs
contract. The returned value will have 6 decimals of precision.
Get current prices
To get the current price of the club, and include the protocol fees in the quote - you can call the MoneyClubs
contract. Remember that amounts have 6 decimals of precision (ex: to buy one whole share, you will use amount = 1000000
)
To actually buy, the caller must approve
the amount on the Bonsai token contract, with the MoneyClubs
contract address as the operator.
To get the general cost of the next whole share, without fees, you can call the getBuyPrice
function with 1000000
as the input amount.
To get the amount of $BONSAI the caller will get back for selling their shares, you can call the getSellPriceAfterFees
function.
Buy
Anyone can buy into a club if they know the creator address. The caller must first approve the cost in $bonsai for the amount of shares they want to buy via getBuyPriceAfterFees
(see above)
Sell
Anyone can sell their shares of a club by calling the sellChips
function on the MoneyClubs
contract. After calling the sellChips
function, they will receive the $BONSAI (minus fees) and have their balance reflected
Withdraw Fees
The treasury address or any client address can withdraw fees at any time. There is also the option to choose to swap a % of the amount from $BONSAI to WETH.
First, read the total amount of fees earned, and then call withdrawFeesEarned
with that amount (or less) and the percentage swapNativePct
(in bps) to swap into WETH.
MoneyClubsAction Module
🚧 This is only valid for the Polygon
deployment - LIKELY TO BE DEPRECATED
Init & register club
A Lens profile can create a post and register their club at the same time. Although they can only register their club once, they can always create a post that points to their club, to allow trading.
Same process as above; to register the club, and pay for one share
Init & promote club
Anyone can promote a club an allow trading on their post by providing the club creator address
in the init data. Looking at the example above, when creating the init data, we use 0
as the initialSupply and can skip the $BONSAI approve step, and set the club address.
Buy
To buy via the open action, the club creator must first create a Lens post with the MoneyClubsAction
module. The act tx would simply encode the correct payload including the amount of shares to purchase (accounting for 6 decimals of precision) and the optional clientAddress
to split the protocol fee with. The typescript would look something like this:
Sell
Like for buying, the club creator must first create a Lens post with the MoneyClubsAction
module in order for anyone to be able to sell via the open action. The act tx would simply encode the correct payload including the amount of shares to sell (accounting for 6 decimals of precision) and the optional clientAddress
to split the protocol fee with. The typescript would look something like this:
Last updated