Open quincy120 opened 1 week ago
This is the job used to collect fees. we are triggering from a cron job in aws
We will need to add signed verification for any module execution from here: https://www.kaleido.io/blockchain-platform/aws-cloudhsm-signer
https://medium.com/@etimpaul22/signature-verification-in-smart-contracts-8666baa06614
https://console.kaleido.io/profile/apikeys https://docs.kaleido.io/kaleido-services/cloudhsm/
We should create module for the gnosis smart wallet. when the user sends btc to the wallet, they would authorize an allowance for the smart wallet to collect. This allowance will be in aavetBTC tokens. that will be what the contract will send to a targeted wallet daily.
Collecting fees: Allow for send: https://github.com/safe-global/safe-modules/tree/main/modules/allowances Trigger: https://chain.link/tutorials/trigger-smart-contract-execution Create Module: https://docs.safe.global/advanced/smart-account-modules Add Module UI: https://help.safe.global/en/articles/40826-add-a-module Module here: https://github.com/5afe/safe-core-protocol/blob/main/contracts/interfaces/Modules.sol Deploy safe with module: https://github.com/safe-global/safe-modules/tree/466a9b8ef169003c5df856c6ecd295e6ecb9e99d/examples/4337-passkeys
Create module via sdk: https://github.com/safe-global/safe-core-sdk/tree/014f365e46cf278897c5ece45c1490c7c749f2d7/packages/protocol-kit/src/managers
Exposed modulemanager via protocolkit here: https://github.com/safe-global/safe-core-sdk/blob/014f365e46cf278897c5ece45c1490c7c749f2d7/packages/protocol-kit/src/Safe.ts
The module would send 3%/365 of aavetBTC tokens to a wallet every day.
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract PercentageSender {
}
Explanation: Contract Details: recipient: A public variable storing the address where the percentage of the wallet balance will be sent. percentage: A public variable defining the percentage of the balance to be sent (represented as a whole number, e.g., 10 for 10%). Constructor: When deploying the contract, you need to specify the recipient address and the desired percentage. sendPercentage function: Calculation: (address(this).balance * percentage) / 100: Calculates the amount to send by multiplying the contract's balance by the specified percentage and dividing by 100 to get the correct percentage value. Transfer: recipient.transfer(amountToSend): Sends the calculated amount to the designated recipient address using the transfer function. Key Points: Security Considerations: Gas Fees: Be aware of potential gas fees associated with sending transactions, especially if the percentage is large or the recipient address is on a different network. Reentrancy Attacks: Consider implementing safeguards against reentrancy attacks if your contract interacts with other contracts. Access Control: If you want to restrict who can trigger the sendPercentage function, you can add access control mechanisms like onlyOwner modifiers. How to Use: