Skip to content

Feat/karma contract ERC20#21

Open
0xrafasec wants to merge 10 commits intomainfrom
feat/karma-contract-erc20
Open

Feat/karma contract ERC20#21
0xrafasec wants to merge 10 commits intomainfrom
feat/karma-contract-erc20

Conversation

@0xrafasec
Copy link
Collaborator

Hey @rayedsikder, I'm opening an initial PR for the discussion Rayed and I had about the KARMA token, which will be used as points and later burned to convert into $OAK.

@rayedsikder I'm leaving the part on how it will be minted for us to discuss. I don't know if you want to proceed here. For me, what makes more sense is for the treasure to call the function in the contract, to be atomic. But I didn't find that within our scope, and it would require extra development.

Waiting for your feedback on the SC and input on this and other things that may come up.

For those also reviewing, some content:

The flow would be:

Karma transfer to bridge $100,000 -> Bridge transfer to Treasure contract $100,000 minus taxes -> Mints 100,000 KARMA tokens.

Later:
100,000 KARMA tokens are burned to be X% of $OAK tokens

PS: I'm sending to main because I didn't know which was the valid one to fork. I created the contract and test. If we integrate with other contracts, I can create the integration test too.

Cheers!

…ing investment amounts

- Introduced the KARMA contract as a soulbound points token.
- Implemented minting functionality restricted to addresses with MINTER_ROLE.
- Added pausable features with roles for pausing and unpausing the contract.
- Enforced soulbound transfer restrictions to prevent wallet-to-wallet transfers.
- Included error handling for invalid admin and mint inputs.
…, burning, pausing, and access control

- Introduced a new test suite for the KARMA contract to validate core functionalities.
- Implemented tests for constructor behavior, minting and burning operations, and role-based access control.
- Ensured proper handling of edge cases, including reverts for invalid operations and role restrictions.
- Verified the soulbound nature of the token by testing transfer restrictions.
Copy link
Member

@rayedsikder rayedsikder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the mint function should be manually callable rather than minting automatically. The token contract should track how much has been raised, and then allow points to be redeemed by the platform admin (i.e., the Karma wallet).

…d amount retrieval

- Introduced the IKarmaTreasury interface to facilitate reading the total raised amount for token claims.
- Included a function signature for getRaisedAmount() to return the total raised amount as a uint256 value.
- This interface will be utilized by the KARMA contract to manage token claims effectively.
… and token claiming functionality

- Introduced a treasury address to manage claims based on raised amounts.
- Added functions to set the treasury and claim tokens, ensuring only valid operations are executed.
- Implemented events for treasury updates and token claims to enhance transparency.
- Included error handling for scenarios where the treasury is not set or no tokens are available to claim.
- Introduced a mock treasury contract to facilitate testing of token claims based on raised amounts.
- Implemented various test cases to validate the claimTokens function, including scenarios for invalid inputs, treasury management, and event emissions.
- Ensured comprehensive coverage for edge cases, such as reverts when the treasury is not set or when claims are made to the zero address.
- Verified that the total minted amount against raised funds starts at zero and increments correctly with valid claims.
@0xrafasec
Copy link
Collaborator Author

I think the mint function should be manually callable rather than minting automatically. The token contract should track how much has been raised, and then allow points to be redeemed by the platform admin (i.e., the Karma wallet).

Adjusted as requested. 💯

- Updated existing tests to reflect changes in token claiming functions, including scenarios with and without fees.
- Introduced new tests to validate the correct deduction of protocol fees from claimed tokens.
- Ensured that the protocol fee can be set and updated by the admin, with appropriate reverts for invalid operations.
- Verified that the total minted amount against raised funds is tracked correctly, even with fee deductions.
- Introduced a protocol fee percentage, allowing for fee deductions from claimed tokens.
- Added constants and events to manage and emit changes related to the protocol fee.
- Implemented error handling for invalid fee percentages exceeding the defined limit.
- Updated the claimTokens function to account for the protocol fee in the minting process.
- Added environment variables for KARMA token management, including addresses for admin, treasury, and protocol fee percentage.
- These additions facilitate easier configuration and deployment of the KARMA contract.
- Introduced a new script to facilitate the deployment of the KARMA contract.
- Implemented functions to deploy the contract with optional configuration for treasury and protocol fee.
- Added environment variable support for admin, treasury, and protocol fee percentage.
- Included logging for treasury and protocol fee settings during deployment.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2811420d7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- Updated the deployment process to initially set the broadcaster as the admin for successful setup calls.
- Added functionality to transfer the admin role to the intended admin after deployment, including granting and revoking necessary roles.
- Enhanced logging to track the transfer of admin roles and treasury settings during deployment.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e69d016abb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@0xrafasec
Copy link
Collaborator Author

@rayedsikder @adnanhq Updated the Karma to get the 1% fee in the math. I was using only the raised amount, but we actually need to make the discount. As we don't have the raise with fee in a public manner, I exposed that. I don't like this way because we create a logic duplication, but I am doing to avoid changing core SCs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants