# @0xmonaco/contracts

Smart contract ABIs and addresses for the Monaco protocol. This package provides the interface definitions and deployed addresses for all Monaco protocol contracts.

**Note:** This package currently only contains the Vault contract. Additional contracts will be added as they are deployed.

## Installation

```bash
npm install @0xmonaco/contracts
```

**Note:** This package is typically installed as a dependency of `@0xmonaco/core` or `@0xmonaco/types`, but you can install it directly if you only need contract ABIs and addresses.

## Usage

### Contract Addresses and ABIs

Access contract addresses and ABIs for different networks:

```typescript
import { CONTRACT_ADDRESSES, CONTRACT_ABIS } from "@0xmonaco/contracts";

// Get contract addresses for Atlantic-2 testnet (chain ID 1328)
const atlanticAddresses = CONTRACT_ADDRESSES[1328];
const { vault: vaultAddress } = atlanticAddresses;

// Get contract addresses for Pacific-1 mainnet (chain ID 1329) - Coming Soon
// const pacificAddresses = CONTRACT_ADDRESSES[1329];

// Create contract instances using viem
import { createPublicClient, http } from "viem";

const client = createPublicClient({
  chain: {
    id: 1328, // Atlantic-2 testnet
    name: "atlantic-2",
    rpcUrls: {
      default: { http: ["https://evm-rpc.testnet.sei.io"] },
      public: { http: ["https://evm-rpc.testnet.sei.io"] },
    },
  },
  transport: http(),
});

// Example of creating a contract instance
const vaultContract = {
  address: vaultAddress,
  abi: CONTRACT_ABIS.vault,
  client,
};
```

## Contract Overview

### Core Protocol Contracts

#### Vault

- Manages user balances and deposits
- Handles token transfers for trades
- Ensures secure fund management

**Note:** Additional contracts (CLOB, Order Book, State, Symphony Adapter) will be documented as they are deployed and integrated.

## Network Support

The package currently supports the following networks:

- **Atlantic-2 (Testnet)**

  - Chain ID: 1328
  - Used for testing and development

- **Pacific-1 (Mainnet)**
  - Chain ID: 1329
  - Production environment (Coming Soon)

## Contract Addresses

Each network has the following contracts deployed:

```typescript
interface ContractAddresses {
  /** Vault contract for managing user balances */
  vault: string;
}
```

## Token Configuration

The package provides token configurations for different networks:

```typescript
import { TESTNET_TOKENS } from "@0xmonaco/contracts";

// Access testnet tokens
const mockUSDC = TESTNET_TOKENS.MockUSDC;
const mockMTK = TESTNET_TOKENS.MockMTK;

// Use token information
console.log(`MockUSDC address: ${mockUSDC.address}`);
console.log(`MockUSDC decimals: ${mockUSDC.decimals}`);
```

### Available Tokens

#### Testnet (Atlantic-2)
- **MockUSDC**: `0x6A86dA986797D59A839D136dB490292Cd560C131` (6 decimals)
- **MockMTK**: `0x428F82f1ECa4AA6f6c75D77cBd2a9ceB94cde343` (18 decimals)



## ABI Reference

The package exports a consolidated `CONTRACT_ABIS` object:

```typescript
import { CONTRACT_ABIS } from "@0xmonaco/contracts";

const clobAbi = CONTRACT_ABIS.clob;
const vaultAbi = CONTRACT_ABIS.vault;
```

Available ABIs in `CONTRACT_ABIS`:

- `vault`: Vault contract interface

## Development

### Adding New Contracts

1. Create a new file in `src/abis/` for the contract ABI
2. Export the ABI as a named constant
3. Add the export to `src/abis/index.ts`
4. Add the contract address to `CONTRACT_ADDRESSES` in `src/index.ts`

### Updating Contract Addresses

When deploying new contracts:

1. Update the addresses in `src/index.ts`
2. Update the network documentation if needed
3. Consider adding a migration guide for users

### Best Practices

- Keep ABIs up to date with deployed contracts
- Document any breaking changes
- Maintain backward compatibility when possible
- Test contract interactions on testnet before mainnet deployment
