# Developer Info

[Source Code](https://github.com/Y2K-Finance/Earthquake)

The Y2K Markets operate in the *Arbitrum Ethereum Network* environment.

{% embed url="<https://excalidraw.com/#json=gOPXWWCvf-xDjD9-cCaRu,euacqFooCXWS2G-VC6H9WQ>" %}
INTERACTIVE ARCHITECTURE DIAGRAM
{% endembed %}

### V2's architecture bears resemblance to V1, incorporating similar components such as [Vault Factory](https://y2k-finance.gitbook.io/y2k-finance/products/earthquake/contracts-and-audits/system-architecture#vault-factory), [Vaults](https://y2k-finance.gitbook.io/y2k-finance/products/earthquake/contracts-and-audits/system-architecture#vault), and [Controller](https://y2k-finance.gitbook.io/y2k-finance/products/earthquake/contracts-and-audits/system-architecture#controller). However, V2 also includes substantial enhancements in the form of new [Carousel](https://github.com/Y2K-Finance/Earthquake/blob/main/src/v2/Carousel/Carousel.sol) and [CarouselFactory](https://github.com/Y2K-Finance/Earthquake/blob/main/src/v2/Carousel/CarouselFactory.sol) functionalities.

## VaultV2

In contrast to V1, [VaultV2](https://github.com/Y2K-Finance/Earthquake/blob/main/src/v2/VaultV2.sol) is a [SemiFungibleVault](https://github.com/Y2K-Finance/Earthquake/blob/main/src/v2/SemiFungibleVault.sol) token based on the ERC1155 standard. The position Id or `epochId` is now a hash composed of `(marketId, epochBegin, epochEnd)`, which can be deterministically computed using the [`getEpochId`](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/VaultFactoryV2.sol#L433-L442) function on the [VaultFactoryV2](https://github.com/Y2K-Finance/Earthquake/blob/main/src/v2/VaultFactoryV2.sol) contract.

### **Deposit**&#x20;

Shares continue to be minted 1 to 1, but in V2, the depositAsset can be any ERC20 token as defined by the [VaultFactoryV2](https://github.com/Y2K-Finance/Earthquake/blob/main/src/v2/VaultFactoryV2.sol).

### **Withdraw**

Unlike in V1, the withdraw fee in V2 is deducted when the vault is settled. The user's entitlement is then calculated based on the percentage of shares they had in the Vault before the insurance epoch began.

## Carousel

[Carousel](https://github.com/Y2K-Finance/Earthquake/blob/main/src/v2/Carousel/Carousel.sol) inherits the [VaultV2](https://github.com/Y2K-Finance/Earthquake/blob/main/src/v2/VaultV2.sol) contract and introduces new functionalities: Rollovers, Queue Deposits, and Linear Information Tax.

### Rollovers:&#x20;

Users can opt to rollover existing positions into the next available epoch using the [`enlistInRollover`](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/Carousel/Carousel.sol#L227C5-L269) function, specifying the epochId, shares, and receiver. To cease rollovers, users can invoke the [`delistInRollover`](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/Carousel/Carousel.sol#L274-L292C6) function. Pending rollovers can be minted by anyone calling the [`mintRollovers`](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/Carousel/Carousel.sol#L371C14-L479) function during an active deposit window.&#x20;

### Queue Deposits:

V2 permits users to deposit at any time using the deposit function with an **`id` of `0`**. A QueueItem is minted and later redeemed for a position in the next epoch deposit window. Any party can call the [`mintDepositInQueue`](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/Carousel/Carousel.sol#L298C5-L365) function during an active deposit window to redeem all stored QueueItems.

## VaultFactoryV2

The **marketId** and **epochId** can be calculated using the [getMarketId](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/VaultFactoryV2.sol#L400-L410) and [`getEpochId`](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/VaultFactoryV2.sol#L433-L442) functions, respectively.

## CarouselFactory

[CarouselFactory](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/Carousel/CarouselFactory.sol) is an extension of the VaultV2Factory contract. It differs in the creation of markets and configuration of epochs which are handled through [createNewCarouselMarket](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/Carousel/CarouselFactory.sol#L42C5-L132) and [createEpochWithEmissions](https://github.com/Y2K-Finance/Earthquake/blob/5827f82c9e79a87da5fb673d83423a8d1e5eed17/src/v2/Carousel/CarouselFactory.sol#LL156C14-L156C38) respectively.&#x20;

A significant improvement is that y2k emissions can now be configured and distributed within each epoch, eliminating the need for deploying an extra [StakingRewards](https://y2k-finance.gitbook.io/y2k-finance/products/earthquake/contracts-and-audits/system-architecture#stakingrewards) contract.
