AFK-AlignedFamKernel / afk_monorepo

AFK: Aligned Fam Kernel - Monorepo
https://portal.afk-community.xyz
MIT License
9 stars 20 forks source link

Launchpad fix sell_coin #47

Open MSghais opened 3 weeks ago

MSghais commented 3 weeks ago

Fix sell coin to get the correct amount with the bonding curve, the token already buy.

The sell function need to:

Located here: https://github.com/AFK-AlignedFamKernel/afk_monorepo/blob/de78feed22d2a1f43e0fe4d22afa0dbf48434c2e/onchain/cairo/src/launchpad/launchpad.cairo#L571

ooochoche commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a smart contract developer, and i can work on the issue

kateberryd commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm a smart contract developer

How I plan on tackling this issue

Use the bonding curve to determine how many tokens the user can sell for the given quote amount. Check that the user owns enough tokens to cover the sale amount. Deduct the sold tokens from the user's balance, adjust the total supply, and update any other relevant state variables. ETA: 2 business days

PoulavBhowmick03 commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm Poulav Bhowmick, a software engineer at Invisible Studios with a robust background in TypeScript, Rust, Solidity Cairo, fullstack development and blockchain technology. My experience includes building robust applications, optimizing functionalities and blockchain integration. I have actively participated in events and open source contributions, enhancing my capability to tackle real-world tech challenges. My projects can be viewed on my GitHub Profile and OnlyDust Profile. Plus I´m active member of Starknet community🇷.

How I plan on tackling this issue

I'll address the issue with the sell_coin function by implementing the following steps:

Calculate Sellable Tokens:

I'll first calculate the amount of tokens that can be sold based on the quote_amount provided. This calculation will take into account the bonding curve formula, ensuring that the correct number of tokens is derived from the quoted amount. Verify Purchase History:

Before proceeding with the sale, I'll add a verification step to ensure that the user has already purchased the corresponding amount of tokens. This will involve checking the user's share in the contract state and confirming that the amount they wish to sell does not exceed their purchased balance. Update Contract State:

Once the sale is validated, I'll update the relevant contract states. This includes: Reducing the user's token balance by the sold amount. Adjusting the pool's total supply and liquidity based on the sale. Calculating and applying any protocol and creator fees associated with the transaction. Transferring the correct amount of tokens or quote tokens between the user's address and the contract. Emit Events:

After successfully updating the states, I'll ensure that appropriate events are emitted to reflect the transaction. This will include details like the amount sold, the price received, and the fees deducted. Testing:

I'll also write unit tests to verify the correctness of the sell_coin function with various edge cases, including scenarios where the user attempts to sell more tokens than they own or where the bonding curve might affect the pricing. This approach will ensure that the sell_coin function correctly calculates and processes token sales according to the bonding curve, maintaining the integrity of the marketplace.

ETA- 1-2 days

mubarak23 commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Cairo smart contract developer with experience working on projects such as Just Art Peace, Dojo, Kart, TBA, and Shinigami. Before transitioning to Cairo development, I was a backend developer specializing in Rust.

My recent work with cairo starknet

How I plan on tackling this issue

i should complete this in 1 DAYS

ShantelPeters commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have experience in Cairo and smart contract development, including implementing and refining functionality in complex systems. I would approach this problem by:

  1. Reviewing the Current Code: Examine the existing sell function to understand its current implementation and identify gaps.
  2. Implementing Calculations: Update the function to correctly calculate the sellable amount based on the quote and bonding curve logic.
  3. Verifying User Balance: Ensure the function checks if the user holds the necessary amount of tokens before processing the sale.
  4. Updating States: Adjust the state management to reflect changes after a successful sale.
  5. Testing: Validate the updated function with various scenarios to ensure correctness and robustness.

How I plan on tackling this issue

To address the issue with the sell function:

  1. Understand the Bonding Curve: Review the bonding curve logic and how it determines the amount of tokens based on the quote amount.
  2. Update Calculation: Adjust the function to accurately compute the sellable tokens from the quote amount using the bonding curve formula.
  3. Check User Holdings: Implement verification to ensure the user has purchased the required amount of tokens before allowing the sale.
  4. Update State Management: Ensure the function updates relevant states to reflect the new token amounts and user balances correctly.
ScottyDavies commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockchain developer With background on JavaScript

How I plan on tackling this issue

I would approach this issue with following steps

Calculating the Correct Sellable Token Amount: The sell function should correctly calculate the amount of Launchpad tokens that can be sold for the given quote token amount. This calculation should take into account the current price of the Launchpad token, as determined by the bonding curve. Ensure that the calculation accurately reflects the token price at the current total supply, and that the result is rounded correctly to avoid any loss of precision. Verifying Existing Token Balances: Before allowing the sale to proceed, the sell function should verify that the user has a sufficient balance of the Launchpad tokens to sell. This can be done by checking the user's balance against the calculated sellable token amount. Ensure that the contract accurately tracks the user's Launchpad token balance and updates it correctly during the buy and sell operations. Updating Contract States: After a successful sell operation, the contract's states should be updated accordingly: The total supply of Launchpad tokens should be decreased by the amount sold. The user's Launchpad token balance should be decreased by the amount sold. The quote token amount received from the sale should be transferred to the user's account. Ensure that these state updates are performed atomically and that the contract's internal consistency is maintained. Emitting Relevant Events: The sell function should emit relevant events, such as TokenSold, to notify off-chain systems and users about the sale transaction. The event data should include the details of the sale, such as the user's address, the amount of Launchpad tokens sold, and the quote token amount received. Error Handling and Validation: Implement proper error handling and validation checks within the sell function to ensure that it can only be called under the correct conditions. This includes validating the input parameters, checking for sufficient Launchpad token balances, and handling any potential edge cases or exceptions. Maintainability and Readability: Ensure the code is well-structured, with clear function and variable naming, and appropriate comments explaining the purpose and behavior of the sell function. Consider breaking down the sell function into smaller, reusable helper functions to improve code organization and readability.

manlikeHB commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi, I am a cairo dev with experience contributing to lots of other cairo projects, you can check my profile to confirm this.

How I plan on tackling this issue

onlydustapp[bot] commented 3 weeks ago

The maintainer MSghais has assigned mubarak23 to this issue via OnlyDust Platform. Good luck!

MSghais commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm Poulav Bhowmick, a software engineer at Invisible Studios with a robust background in TypeScript, Rust, Solidity Cairo, fullstack development and blockchain technology. My experience includes building robust applications, optimizing functionalities and blockchain integration. I have actively participated in events and open source contributions, enhancing my capability to tackle real-world tech challenges. My projects can be viewed on my GitHub Profile and OnlyDust Profile. Plus I´m active member of Starknet community🇷.

How I plan on tackling this issue

I'll address the issue with the sell_coin function by implementing the following steps:

Calculate Sellable Tokens:

I'll first calculate the amount of tokens that can be sold based on the quote_amount provided. This calculation will take into account the bonding curve formula, ensuring that the correct number of tokens is derived from the quoted amount. Verify Purchase History:

Before proceeding with the sale, I'll add a verification step to ensure that the user has already purchased the corresponding amount of tokens. This will involve checking the user's share in the contract state and confirming that the amount they wish to sell does not exceed their purchased balance. Update Contract State:

Once the sale is validated, I'll update the relevant contract states. This includes: Reducing the user's token balance by the sold amount. Adjusting the pool's total supply and liquidity based on the sale. Calculating and applying any protocol and creator fees associated with the transaction. Transferring the correct amount of tokens or quote tokens between the user's address and the contract. Emit Events:

After successfully updating the states, I'll ensure that appropriate events are emitted to reflect the transaction. This will include details like the amount sold, the price received, and the fees deducted. Testing:

I'll also write unit tests to verify the correctness of the sell_coin function with various edge cases, including scenarios where the user attempts to sell more tokens than they own or where the bonding curve might affect the pricing. This approach will ensure that the sell_coin function correctly calculates and processes token sales according to the bonding curve, maintaining the integrity of the marketplace.

ETA- 1-2 days

Gm! I appreciate the description and the ETA etc in your application! Just assigned one other person that's want to work on Cairo side before you (we discuss it)

Can you the AFK TG group please https://t.me/afk_aligned_fam_kernel? Also ping me in TG, my handle is MSG_Encrypted.

We can discuss other issues incoming in the Contract side for Cairo and Solidity

DIWAKARKASHYAP commented 2 weeks ago

https://diwakar-portfolio.vercel.app/ i want to work on this issue

onlydustapp[bot] commented 2 weeks ago

Hi @DIWAKARKASHYAP! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

ShantelPeters commented 1 week ago

I will like to work on this