# Guides

## Deployment of SIV

[Foundry Script](https://github.com/Y2K-Finance/SelfInsuredVault/blob/master/script/DeployScript.s.sol)

SIV constructor requires three addresses as input parameters: `paymentToken`, `yieldSource`, and `emissionsToken`. It's important to note that for Carousel, `emissionsToken` represents the Y2K token, while for V2 or V1, it should be `address(0)`.

```
    SelfInsuredVault siv = new SelfInsuredVault(
        paymentToken,
        yieldSource,
        emissionsToken
    );
```

Once you have deployed SIV, it is crucial to remember to transfer the ownership of the `yieldSource` to SIV.

```
    IYieldSource(yieldSource).transferOwnership(address(siv));
```

## Add markets to SIV

[Foundry Script](https://github.com/Y2K-Finance/SelfInsuredVault/blob/1fccdb77ea5c2e1c070a2372cf74f73feb15b046/script/Configure.s.sol#LL9C10-L9C20)

The market information consists of several key parameters: `insuranceProvider`, `marketId`, `premiumWeight`, and `collateralWeight`. \
For a detailed explanation of these parameters, please refer to the technical overview.\
Insurance Provider addresses can be found [here](https://y2k-finance.gitbook.io/y2k-finance/products/builder-info/technical-overview-of-the-insuranceprovider-contract#insurance-provider).

```
    SelfInsuredVault(siv).addMarket(
        market.insuranceProvider,
        market.marketId,
        market.premiumWeight,
        market.collateralWeight
    );
```

Market weights can be updated with market index.

```
    SelfInsuredVault(siv).setWeight(
        index,
        newPremiumWeight,
        newCollateralWeight
    );
```

## Purchase Insurance

The `purchaseInsuranceForNextEpoch` function in SIV is designed to deposit funds into Earthquake. Notably, this function does not require any parameters to be provided.

```
    SelfInsuredVault(siv).purchaseInsuranceForNextEpoch();
```
