fix: update a2a arbitrate fields to current task schema
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 6s
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 6s
This commit is contained in:
@@ -99,41 +99,14 @@ export async function POST(request: Request) {
|
||||
if (winner === "BUILDER") {
|
||||
await prisma.$transaction(async (tx) => {
|
||||
const task = await tx.task.findUnique({ where: { id: arbitration.task_id } });
|
||||
const builderAgentId = task?.builder_agent_id;
|
||||
|
||||
// ==========================================
|
||||
// PHASE 23: AGENT IPO DIVIDENDS
|
||||
// ==========================================
|
||||
let builderPayout = task?.reward_amount || 0;
|
||||
let dividendPayout = 0;
|
||||
const builderAgentId = task?.builder_id;
|
||||
|
||||
// Keep a single payout path here; legacy dividend/hostile-takeover logic is intentionally disabled
|
||||
// because the related schema models are not yet available in this release.
|
||||
if (builderAgentId) {
|
||||
const agentProfile = await tx.agentProfile.findUnique({
|
||||
await tx.agentProfile.findUnique({
|
||||
where: { agent_id: builderAgentId }
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// PHASE 24: HOSTILE TAKEOVER (MEGA-CORP)
|
||||
// ==========================================
|
||||
if (agentProfile && agentProfile.parent_agent_id) {
|
||||
console.log(`[Hostile Takeover] Agent ${builderAgentId} is owned by Mega-Corp ${agentProfile.parent_agent_id}! Redirecting 100% of rewards (${builderPayout / 100} USDC).`);
|
||||
|
||||
// In reality, transfer builderPayout to parent_agent_id's wallet
|
||||
dividendPayout = 0; // Overridden by MegaCorp
|
||||
// End of Phase 24 Hook
|
||||
} else {
|
||||
const agentToken = await tx.agentToken.findUnique({
|
||||
where: { agent_id: builderAgentId }
|
||||
});
|
||||
|
||||
if (agentToken) {
|
||||
// Agent is Publicly Traded! Divert 20% of reward to Shareholders
|
||||
dividendPayout = Math.floor((task?.reward_amount || 0) * 0.20);
|
||||
builderPayout = (task?.reward_amount || 0) - dividendPayout;
|
||||
|
||||
console.log(`[Agent IPO] Agent ${builderAgentId} is publicly traded ($${agentToken.ticker_symbol}). Diverting ${dividendPayout / 100} USDC to shareholders!`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await tx.task.update({
|
||||
@@ -145,15 +118,15 @@ export async function POST(request: Request) {
|
||||
const task = await prisma.task.update({
|
||||
where: { id: arbitration.task_id },
|
||||
data: { status: "FAILED" }, // Reject work
|
||||
select: { builder_agent_id: true, scout_agent_id: true }
|
||||
select: { builder_id: true, scout_id: true }
|
||||
});
|
||||
|
||||
// ==========================================
|
||||
// PHASE 20: SLASHING MECHANISM
|
||||
// If the Builder lost arbitration, we slash them!
|
||||
// ==========================================
|
||||
if (task.builder_agent_id && task.scout_agent_id) {
|
||||
const builder = await prisma.agentProfile.findUnique({ where: { agent_id: task.builder_agent_id }});
|
||||
if (task.builder_id && task.scout_id) {
|
||||
const builder = await prisma.agentProfile.findUnique({ where: { agent_id: task.builder_id }});
|
||||
|
||||
if (builder && builder.staked_amount > 0) {
|
||||
const slashAmount = Math.min(builder.staked_amount, 50000); // Up to 500 USDC
|
||||
|
||||
Reference in New Issue
Block a user