Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Oracle Interaction Fees and Gas Costs for adpools #432

Open
BrosG opened this issue Mar 13, 2024 · 0 comments
Open

Optimize Oracle Interaction Fees and Gas Costs for adpools #432

BrosG opened this issue Mar 13, 2024 · 0 comments
Assignees

Comments

@BrosG
Copy link
Contributor

BrosG commented Mar 13, 2024

To design a system where the influencer indirectly covers the gas fees for oracle interactions during the rewards claim process, while keeping the participant validation process advertiser-driven, here are the adjusted specifications:

Transaction Type Method Used Gas Fee Payer Oracle Fee Payment Description
Campaign Creation On-chain Transaction Advertiser N/A The advertiser initiates the campaign on the blockchain via an on-chain transaction, incurring gas fees paid by the advertiser.
Campaign Participation Off-chain Signature None (off-chain action) N/A Participants express their intent to participate through an off-chain signature, without direct gas fees.
Participation Validation Off-chain Signature by Advertiser None (off-chain action) Advertiser (for validation) The advertiser validates participants off-chain by reviewing and approving their submissions. No gas fees are incurred for this action.
Rewards Claim On-chain Transaction + Included Oracle Fees Influencer Influencer (via rewards claim) Participants claim their rewards through an on-chain transaction, which also includes oracle fees. These fees are indirectly covered by the claimed rewards amount.
Oracle Interaction Off-chain Validation; On-chain Update if Necessary Influencer (indirectly) Influencer (indirectly via claim) While oracle data collection occurs off-chain, validation of participations or other campaign information may sometimes require an on-chain update, with fees indirectly covered by the influencer during the rewards claim process.

Oracle Fee Payment Mechanism

  • Rewards Claim: When an influencer claims their rewards, the contract automatically deducts a portion of the rewards to cover the necessary oracle fees for participation validation or campaign results verification. This deduction is calculated based on pre-established rates or the costs of interacting with the oracle.

Simplified Example of a Rewards Claim Function:

function claimRewards(bytes32 campaignId) public {
    require(participationApproved[campaignId][msg.sender], "Participation not approved.");
    require(!rewardsClaimed[campaignId][msg.sender], "Rewards already claimed.");

    uint256 rewardAmount = rewards[campaignId][msg.sender];
    uint256 oracleFee = getOracleFee(campaignId); // Calculate or retrieve pre-established oracle fees

    require(rewardAmount > oracleFee, "Reward amount does not cover oracle fees.");

    uint256 netReward = rewardAmount - oracleFee;
    rewardsClaimed[campaignId][msg.sender] = true;

    // Ensure logic to transfer the net amount to the influencer
    // and oracle fees to the oracle's address or contract
    rewardsToken.transfer(msg.sender, netReward);
    rewardsToken.transfer(oracleAddress, oracleFee);

    emit RewardClaimed(msg.sender, campaignId, netReward);
}

Conclusion

In this model, participants (influencers) indirectly pay for oracle interactions by deducting the necessary fees from their claimed rewards. This approach minimizes direct gas costs for participants while ensuring essential activities, such as participant validation and rewards distribution, are properly funded and executed on the blockchain.

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

No branches or pull requests

2 participants