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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AmmalgamPair
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/AmmalgamPair.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/AmmalgamPair.sol)

**Inherits:**
[IAmmalgamPair](/docs/developer-guide/contracts/interfaces/IAmmalgamPair.sol/interface.IAmmalgamPair.md), [TokenController](/docs/developer-guide/contracts/tokens/TokenController.sol/contract.TokenController.md)
Expand Down Expand Up @@ -369,14 +369,7 @@ Liquidation based on change of saturation because of time.


```solidity
function resetSaturation(
Validation.InputParams memory inputParams,
address borrower,
address to,
uint256 depositLToBeTransferredInLAssets,
uint256 depositXToBeTransferredInXAssets,
uint256 depositYToBeTransferredInYAssets
) private;
function resetSaturation(Validation.InputParams memory inputParams, address borrower, address to) private;
```
**Parameters**

Expand All @@ -385,9 +378,6 @@ function resetSaturation(
|`inputParams`|`Validation.InputParams`||
|`borrower`|`address`|The account being liquidated.|
|`to`|`address`|The account to send the liquidated deposit to|
|`depositLToBeTransferredInLAssets`|`uint256`|The amount of L to be transferred to the liquidator.|
|`depositXToBeTransferredInXAssets`|`uint256`|The amount of X to be transferred to the liquidator.|
|`depositYToBeTransferredInYAssets`|`uint256`|The amount of Y to be transferred to the liquidator.|


### liquidateLeverage
Expand Down Expand Up @@ -510,12 +500,27 @@ function validateOnUpdate(address validate, address update, bool alwaysUpdate) p
function validateSolvency(address validate, bool alwaysUpdate) private;
```

### getInputParamsAndUpdateSaturation
### updateSaturationIfNeeded

Update saturation state for an account if it already exists in saturation.

*Note that during a repay of debt, we may not have an entry in saturation if
1. The position is a straddle with a payout that never reaches zero
2. Repay is occurring during a callback of a flash loan, saturation will not be updated
until the end of the borrow call after the callback concludes.*


```solidity
function getInputParamsAndUpdateSaturation(address toUpdate, bool alwaysUpdate) private;
function updateSaturationIfNeeded(
address toUpdate
) private;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`toUpdate`|`address`|The account to update saturation for.|


### getInputParams

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SaturationAndGeometricTWAPState
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/SaturationAndGeometricTWAPState.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/SaturationAndGeometricTWAPState.sol)

**Inherits:**
Initializable, [ISaturationAndGeometricTWAPState](/docs/developer-guide/contracts/interfaces/ISaturationAndGeometricTWAPState.sol/interface.ISaturationAndGeometricTWAPState.md), OwnableUpgradeable
Expand Down Expand Up @@ -151,6 +151,28 @@ function getAccount(
) external view returns (Saturation.Account memory);
```

### accountExistsInSaturation

Check if an account exists in either netX or netY saturation tree


```solidity
function accountExistsInSaturation(address pairAddress, address accountAddress) external view returns (bool exists);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`pairAddress`|`address`|The address of the pair|
|`accountAddress`|`address`|The address of the account to check|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`exists`|`bool`|True if the account exists in either tree|


### update

update the borrow position of an account and potentially check (and revert) if the
Expand Down Expand Up @@ -249,7 +271,7 @@ function calcSatChangeRatioBips(
uint256 liqSqrtPriceInYInQ72,
address pairAddress,
address account
) external view virtual isInitialized returns (uint256 ratioNetXBips, uint256 ratioNetYBips);
) external view virtual isInitialized returns (uint256 ratioBips);
```
**Parameters**

Expand All @@ -265,8 +287,7 @@ function calcSatChangeRatioBips(

|Name|Type|Description|
|----|----|-----------|
|`ratioNetXBips`|`uint256`|The ratio representing the change in netX saturation for account.|
|`ratioNetYBips`|`uint256`|The ratio representing the change in netY saturation for account.|
|`ratioBips`|`uint256`|The ratio representing the change saturation for account.|


### getObservations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AmmalgamFactory
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/factories/AmmalgamFactory.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/factories/AmmalgamFactory.sol)

**Inherits:**
[IAmmalgamFactory](/docs/developer-guide/contracts/interfaces/factories/IAmmalgamFactory.sol/interface.IAmmalgamFactory.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ERC20DebtLiquidityTokenFactory
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/factories/ERC20DebtLiquidityTokenFactory.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/factories/ERC20DebtLiquidityTokenFactory.sol)

**Inherits:**
[ITokenFactory](/docs/developer-guide/contracts/interfaces/factories/ITokenFactory.sol/interface.ITokenFactory.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ERC20LiquidityTokenFactory
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/factories/ERC20LiquidityTokenFactory.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/factories/ERC20LiquidityTokenFactory.sol)

**Inherits:**
[ITokenFactory](/docs/developer-guide/contracts/interfaces/factories/ITokenFactory.sol/interface.ITokenFactory.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ERC4626DebtTokenFactory
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/factories/ERC4626DebtTokenFactory.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/factories/ERC4626DebtTokenFactory.sol)

**Inherits:**
[ITokenFactory](/docs/developer-guide/contracts/interfaces/factories/ITokenFactory.sol/interface.ITokenFactory.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ERC4626DepositTokenFactory
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/factories/ERC4626DepositTokenFactory.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/factories/ERC4626DepositTokenFactory.sol)

**Inherits:**
[ITokenFactory](/docs/developer-guide/contracts/interfaces/factories/ITokenFactory.sol/interface.ITokenFactory.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IAmmalgamPair
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/IAmmalgamPair.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/IAmmalgamPair.sol)

**Inherits:**
[ITransferValidator](/docs/developer-guide/contracts/interfaces/callbacks/ITransferValidator.sol/interface.ITransferValidator.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ISaturationAndGeometricTWAPState
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/ISaturationAndGeometricTWAPState.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/ISaturationAndGeometricTWAPState.sol)


## Functions
Expand Down Expand Up @@ -99,6 +99,28 @@ function getAccount(
) external view returns (Saturation.Account memory);
```

### accountExistsInSaturation

Check if an account exists in either netX or netY saturation tree


```solidity
function accountExistsInSaturation(address pairAddress, address accountAddress) external view returns (bool exists);
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`pairAddress`|`address`|The address of the pair|
|`accountAddress`|`address`|The address of the account to check|

**Returns**

|Name|Type|Description|
|----|----|-----------|
|`exists`|`bool`|True if the account exists in either tree|


### update

update the borrow position of an account and potentially check (and revert) if the
Expand Down Expand Up @@ -156,7 +178,7 @@ function calcSatChangeRatioBips(
uint256 liqSqrtPriceInYInQ72,
address pairAddress,
address account
) external view returns (uint256 ratioNetXBips, uint256 ratioNetYBips);
) external view returns (uint256 ratioBips);
```
**Parameters**

Expand All @@ -172,8 +194,7 @@ function calcSatChangeRatioBips(

|Name|Type|Description|
|----|----|-----------|
|`ratioNetXBips`|`uint256`|The ratio representing the change in netX saturation for account.|
|`ratioNetYBips`|`uint256`|The ratio representing the change in netY saturation for account.|
|`ratioBips`|`uint256`|The ratio representing the change in saturation for account.|


### configLongTermInterval
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IBorrowCallback
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/callbacks/IAmmalgamCallee.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/callbacks/IAmmalgamCallee.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ICallback
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/callbacks/IAmmalgamCallee.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/callbacks/IAmmalgamCallee.sol)

**Inherits:**
[ISwapCallback](/docs/developer-guide/contracts/interfaces/callbacks/IAmmalgamCallee.sol/interface.ISwapCallback.md), [IBorrowCallback](/docs/developer-guide/contracts/interfaces/callbacks/IAmmalgamCallee.sol/interface.IBorrowCallback.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ISwapCallback
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/callbacks/IAmmalgamCallee.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/callbacks/IAmmalgamCallee.sol)

*This interface should be implemented by anyone wishing to use callbacks in the
`swap`, `borrow`, and `borrowLiquidity` functions in the IAmmalgamPair interface.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ITransferValidator
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/callbacks/ITransferValidator.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/callbacks/ITransferValidator.sol)

This interface is intended for validating the solvency of an account when transfers occur.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IAmmalgamFactory
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/factories/IAmmalgamFactory.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/factories/IAmmalgamFactory.sol)

**Inherits:**
[IFactoryCallback](/docs/developer-guide/contracts/interfaces/factories/IFactoryCallback.sol/interface.IFactoryCallback.md), [IBeaconCallback](/docs/developer-guide/contracts/interfaces/factories/IAmmalgamFactory.sol/interface.IBeaconCallback.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IBeaconCallback
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/factories/IAmmalgamFactory.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/factories/IAmmalgamFactory.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IFactoryCallback
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/factories/IFactoryCallback.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/factories/IFactoryCallback.sol)

This interface provides methods for getting the token factory configuration.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ITokenFactory
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/factories/ITokenFactory.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/factories/ITokenFactory.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IAmmalgamERC20
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/tokens/IAmmalgamERC20.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/tokens/IAmmalgamERC20.sol)

**Inherits:**
IERC20, IERC20Metadata, IERC20Permit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IERC20DebtToken
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/tokens/IERC20DebtToken.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/tokens/IERC20DebtToken.sol)

**Inherits:**
[IAmmalgamERC20](/docs/developer-guide/contracts/interfaces/tokens/IAmmalgamERC20.sol/interface.IAmmalgamERC20.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IHookRegistry
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/tokens/IHookRegistry.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/tokens/IHookRegistry.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Constants
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/tokens/ITokenController.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/tokens/ITokenController.sol)

### DEPOSIT_L

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ITokenController
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/interfaces/tokens/ITokenController.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/interfaces/tokens/ITokenController.sol)

The interface of a ERC20 facade for multiple token types with functionality similar to ERC1155.

Expand Down Expand Up @@ -199,7 +199,8 @@ event BurnBadDebt(address indexed borrower, uint256 indexed tokenType, uint256 b

```solidity
event InterestAccrued(
uint112 depositLAssets,
uint256 reserveXAssets,
uint256 reserveYAssets,
uint112 depositXAssets,
uint112 depositYAssets,
uint112 borrowLAssets,
Expand All @@ -212,7 +213,8 @@ event InterestAccrued(

|Name|Type|Description|
|----|----|-----------|
|`depositLAssets`|`uint112`|The amount of total `DEPOSIT_L` assets in the pool after interest accrual|
|`reserveXAssets`|`uint256`|The amount reserve X assets in the pool after interest accrual|
|`reserveYAssets`|`uint256`|The amount reserve Y assets in the pool after interest accrual|
|`depositXAssets`|`uint112`|The amount of total `DEPOSIT_X` assets in the pool after interest accrual|
|`depositYAssets`|`uint112`|The amount of total `DEPOSIT_Y` assets in the pool after interest accrual|
|`borrowLAssets`|`uint112`|The amount of total `BORROW_L` assets in the pool after interest accrual|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Convert
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/libraries/Convert.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/libraries/Convert.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# GeometricTWAP
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/libraries/GeometricTWAP.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/libraries/GeometricTWAP.sol)


## State Variables
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Interest
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/2b185eab2df708b55f7ffa534655c69f626e73b3/contracts/libraries/Interest.sol)
[Git Source](https://github.com/Ammalgam-Protocol/core-v1/blob/1eb2f41d31e4d7890a0efc607ed5cfd8b9577c04/contracts/libraries/Interest.sol)

This library is used for calculating and accruing interest.

Expand Down
Loading