Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions docs/examples/erc4626-vault-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# ERC-4626 Tokenized Vault Example on Arc Testnet

This example shows how to build an ERC-4626 tokenized vault for native USDC on Arc Testnet, including an agent-yield deposit path for Multi-Agent Orchestrator integration.

## Overview

ERC-4626 is the standard interface for tokenized yield-bearing vaults. ArcUSDCVault wraps Arc Testnet's native USDC, issuing avUSDC shares that represent proportional ownership of the vault's underlying assets. The owner can inject yield directly, increasing the value of all outstanding shares without minting new ones.

## Contract on Arc Testnet

| Field | Value |
|-------|-------|
| Contract | 0x6C13dA317B65474299F6fDee02daDd6626Eb2BFe |
| Underlying asset | Arc Testnet USDC (0x3600000000000000000000000000000000000000) |
| Share token | Arc USDC Vault Share (avUSDC) |

## Implementation

Built with OpenZeppelin v5.6.1's ERC4626 base contract:

```solidity
contract ArcUSDCVault is ERC4626, Ownable {
using SafeERC20 for IERC20;

constructor(IERC20 asset_)
ERC20("Arc USDC Vault Share", "avUSDC")
ERC4626(asset_)
Ownable(msg.sender)
{}

function depositYield(uint256 amount) external onlyOwner {
IERC20(asset()).safeTransferFrom(msg.sender, address(this), amount);
emit YieldDeposited(msg.sender, amount, totalAssets());
}

function depositForAgent(address agent, uint256 missionId, uint256 amount)
external
returns (uint256 shares)
{
shares = deposit(amount, agent);
emit AgentYieldDeposited(agent, missionId, amount, shares);
}
}
```

## Multi-Agent Orchestrator Integration

The depositForAgent function lets an orchestrator route mission payouts directly into yield-bearing shares instead of raw USDC, tagging each deposit with a mission ID for on-chain traceability. This composes naturally with the MultiAgentOrchestrator contract from a previous example in this series: instead of an agent receiving a raw USDC payout, the orchestrator can call depositForAgent on the agent's behalf, immediately putting their earnings into a yield-bearing position.

## Test Coverage

13 tests covering deposit, withdraw, redeem, multiple depositors with proportional shares, yield injection increasing share value, yield benefiting only existing holders, access control, agent-tagged deposits, and a full deposit-yield-redeem cycle.

```bash
forge test

# Ran 13 tests for test/ArcUSDCVault.t.sol:ArcUSDCVaultTest
# [PASS] testDeposit()
# [PASS] testDepositForAgent()
# [PASS] testDepositForAgentEmitsEvent()
# [PASS] testDepositForAgentRevertsOnZeroAddress()
# [PASS] testDepositYieldRevertsForNonOwner()
# [PASS] testDepositYieldRevertsOnZero()
# [PASS] testFullDepositWithdrawCycleWithYield()
# [PASS] testInitialState()
# [PASS] testMultipleDepositorsProportionalShares()
# [PASS] testRedeem()
# [PASS] testWithdraw()
# [PASS] testYieldBenefitsExistingHoldersOnly()
# [PASS] testYieldIncreasesShareValue()
# Suite result: ok. 13 passed; 0 failed
```

## Live Verified Example

A real deposit was made and verified on Arc Testnet:

- Approve tx: https://testnet.arcscan.app/tx/0x5889cee125030d6fb092926689b14c684a6dbe0a01b51edb354c19b64e7e40ee
- Deposit tx: https://testnet.arcscan.app/tx/0x3db09d1f8cdc5f1506a48420c92bb6ee4fa6c90c31a6ab4441b41c92c2dc9c5d
- Result: 5 USDC deposited, 5,000,000 avUSDC shares minted (1:1 first-deposit ratio)

## GitHub Repository

Full implementation: https://github.com/consumeobeydie/arc-vault

## Resources

- ERC-4626 EIP: https://eips.ethereum.org/EIPS/eip-4626
- OpenZeppelin ERC4626: https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#ERC4626
- Arc Testnet Explorer: https://testnet.arcscan.app
- Arc Contract Addresses: https://docs.arc.io/arc/references/contract-addresses
43 changes: 43 additions & 0 deletions docs/examples/transaction-memo-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Arc Transaction Memos: Multi-Agent Orchestrator Integration Example

This example shows how to integrate Arc's Transaction Memos feature with an existing contract without modifying it, using the predeployed Memo contract on Arc Testnet.

## Overview

Transaction Memos (announced June 18, 2026) let you attach structured context to any contract call via a predeployed Memo contract, which routes the inner call through the CallFrom precompile so the original msg.sender is preserved. The Memo event is only emitted if the inner call succeeds, giving downstream systems a clean reconciliation signal.

## Predeployed Contracts on Arc Testnet

| Contract | Address |
|----------|---------|
| Memo | 0x5294E9927c3306DcBaDb03fe70b92e01cCede505 |
| Multicall3From | 0x522fAf9A91c41c443c66765030741e4AaCe147D0 |

## Function Signature

function callWithMemo(address target, bytes calldata data, bytes32 correlationId, string calldata memo) external returns (bool success, bytes memory result)

Selector: 0xc3b2c4f8

This signature was derived by inspecting the Memo contract bytecode dispatcher and decoding a real on-chain transaction calldata to confirm parameter types, since the ABI was not yet published when this example was built.

## Common Pitfalls

- Empty revert data: behavior with cast call --from may differ from an actual sent transaction.
- Inner call must succeed: the Memo event only emits when the wrapped call succeeds.
- bytes32 correlationId must be exactly 32 bytes.

## Live Verified Example

Tested against the MultiAgentOrchestrator contract from arc-multi-agent:

- Memo contract: 0x5294E9927c3306DcBaDb03fe70b92e01cCede505
- Target: 0xe81f5BA4181eA29061C3C229c8D6EB4cFE56639C
- Tx: https://testnet.arcscan.app/tx/0x7532ce470169e2db2be43e5f9c43dd523d21e9071c04268ff5941f8ca839ef7b
- Status: Success, confirmed in 0.58 seconds

## Resources

- Arc Transaction Memos announcement: https://community.arc.io/home/blogs/arc-transaction-memos-structured-transaction-context-for-financial-workflows-on-arc-2026-06-18
- Arc Contract Addresses: https://docs.arc.io/arc/references/contract-addresses
- Full implementation: https://github.com/consumeobeydie/arc-agent-api