wrap_edu
Convert EDU tokens to WEDU (Wrapped EDU) for enhanced interoperability and compatibility with decentralized platforms. Enter your wallet’s private key and the amount to wrap.
Instructions
Wrap EDU to WEDU (Wrapped EDU)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount of EDU to wrap | |
| privateKey | Yes | Private key of the wallet |
Input Schema (JSON Schema)
{
"properties": {
"amount": {
"description": "Amount of EDU to wrap",
"type": "string"
},
"privateKey": {
"description": "Private key of the wallet",
"type": "string"
}
},
"required": [
"privateKey",
"amount"
],
"type": "object"
}
Implementation Reference
- src/swap.ts:1040-1085 (handler)The core handler function that executes the wrapping of EDU to WEDU by depositing into the WETH9 (WEDU) contract.export async function wrapEDU( privateKey: string, amount: string ): Promise<{ hash: string; from: string; amount: string; success: boolean; }> { try { const provider = blockchain.getProvider(); const wallet = new ethers.Wallet(privateKey, provider); const fromAddress = wallet.address; // Convert EDU amount to wei const amountInWei = ethers.parseEther(amount); // Create WETH9 contract instance const wethAbi = [ 'function deposit() external payable', 'function withdraw(uint256 amount) external', 'function balanceOf(address owner) view returns (uint256)', 'function approve(address spender, uint256 amount) external returns (bool)' ]; const wethContract = new ethers.Contract(CONTRACTS.WETH9, wethAbi, wallet); // Deposit EDU to get WEDU const tx = await wethContract.deposit({ value: amountInWei }); const receipt = await tx.wait(); if (!receipt) { throw new Error('Transaction failed'); } return { hash: tx.hash, from: fromAddress, amount, success: true }; } catch (error) { console.error('Error wrapping EDU to WEDU:', error); throw error; } }
- src/index.ts:676-692 (schema)The input schema definition for the 'wrap_edu' tool, specifying parameters privateKey and amount.name: 'wrap_edu', description: 'Wrap EDU to WEDU (Wrapped EDU)', inputSchema: { type: 'object', properties: { privateKey: { type: 'string', description: 'Private key of the wallet', }, amount: { type: 'string', description: 'Amount of EDU to wrap', }, }, required: ['privateKey', 'amount'], }, },
- src/index.ts:1401-1441 (registration)The registration and dispatch logic in the MCP tool call handler that validates inputs and calls the wrapEDU handler from the swap module.case 'wrap_edu': { if (!args.privateKey || typeof args.privateKey !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Private key is required'); } if (!args.amount || typeof args.amount !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Amount is required'); } try { const result = await swap.wrapEDU(args.privateKey, args.amount); return { content: [ { type: 'text', text: JSON.stringify({ ...result, message: `Successfully wrapped ${args.amount} EDU to WEDU`, note: "WEDU (Wrapped EDU) is required for interacting with SailFish DEX. You can unwrap it back to EDU at any time." }, null, 2), }, ], }; } catch (error) { console.error('Error wrapping EDU to WEDU:', error); return { content: [ { type: 'text', text: JSON.stringify({ error: 'Failed to wrap EDU to WEDU', message: (error as Error).message }, null, 2), }, ], isError: true, }; } }