Skip to content

Add first mAIning Pool implementation#133

Open
patnorris wants to merge 2 commits intomainfrom
firstMainingPool
Open

Add first mAIning Pool implementation#133
patnorris wants to merge 2 commits intomainfrom
firstMainingPool

Conversation

@patnorris
Copy link
Copy Markdown
Contributor

No description provided.

@patnorris patnorris requested a review from icppWorld January 21, 2026 15:46
owner = Principal.fromActor(this);
subaccount = null;
};
let actualFunnaiBalance = await TokenLedger_Actor.icrc1_balance_of(funnaiAccount);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need a try/catch ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wrapped the critical call to this function in a try catch

owner = Principal.fromActor(this);
subaccount = null;
};
let actualIcpBalance = await ICP_LEDGER_ACTOR.icrc1_balance_of(icpAccount);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need a try/catch ?

Comment thread src/mAIningPool/src/Main.mo Outdated
spender_subaccount = null;
};

let icpTransferResult : TokenLedger.Result_3 = await ICP_LEDGER_ACTOR.icrc2_transfer_from(transferFromArgs);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need a try/catch ?

Comment thread src/mAIningPool/src/Main.mo Outdated
totalNextIcp := totalNextIcp + entry.icpContributionE8S;
};

let totalCyclesForWeek = await calculateCyclesFromIcp(totalNextIcp);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need a try/catch ?


for ((address, mainerEntry) in poolMainersStorage.entries()) {
// Top up mAIner with cyclesPerMainer via Game State
let topUpResult = await topUpMainerWithCycles(mainerEntry, icpPerMainer);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need a try/catch ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

external calls in topUpMainerWithCycles are wrapped in a try/catch

Comment thread src/mAIningPool/src/Main.mo Outdated
let settingInput : Types.MainerAgentSettingsInput = {
cyclesBurnRate : Types.CyclesBurnRateDefault = burnRatePerMainer;
};
let updateResult = await mainerCanisterActor.updateAgentSettings(settingInput);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need a try/catch ?

};

// Query: Get aggregated past contributions and distributions
public shared query func getAggregatedHistory() : async Types.Result<{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this function and the next ones be truly public, even for anonymous callers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

as they don't return sensitive info, it's fine to also allow users who aren't logged in to query them

Comment thread src/mAIningPool/src/Main.mo Outdated
timeInterval : Types.TimeInterval = #Daily;
};

private func calculateBurnRatePerMainer(cyclesForWeek : Nat) : Nat {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This function is not used. Is it still needed?

} else if (cyclesForWeek <= 7 * cyclesBurnRateDefaultHigh.cycles) {
return #High;
} else {
return #VeryHigh;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens with the excess cycles that are not burned during the week?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ideally, all cycles are burnt. Otherwise, they just stay in the mAIner

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