Skip to main content
Helpful?

DeltaResolver

Git Source - Generated with forge doc

Inherits: ImmutableState

Abstract contract used to sync, send, and settle funds to the pool manager

Note that sync() is called before any erc-20 transfer in settle.

Functions

_take

Take an amount of currency out of the PoolManager

Returns early if the amount is 0

function _take(Currency currency, address recipient, uint256 amount) internal;

Parameters

NameTypeDescription
currencyCurrencyCurrency to take
recipientaddressAddress to receive the currency
amountuint256Amount to take

_settle

Pay and settle a currency to the PoolManager

The implementing contract must ensure that the payer is a secure address

Returns early if the amount is 0

function _settle(Currency currency, address payer, uint256 amount) internal;

Parameters

NameTypeDescription
currencyCurrencyCurrency to settle
payeraddressAddress of the payer
amountuint256Amount to send

_pay

Abstract function for contracts to implement paying tokens to the poolManager

The recipient of the payment should be the poolManager

function _pay(Currency token, address payer, uint256 amount) internal virtual;

Parameters

NameTypeDescription
tokenCurrencyThe token to settle. This is known not to be the native currency
payeraddressThe address who should pay tokens
amountuint256The number of tokens to send

_getFullDebt

Obtain the full amount owed by this contract (negative delta)

function _getFullDebt(Currency currency) internal view returns (uint256 amount);

Parameters

NameTypeDescription
currencyCurrencyCurrency to get the delta for

Returns

NameTypeDescription
amountuint256The amount owed by this contract as a uint256

_getFullCredit

Obtain the full credit owed to this contract (positive delta)

function _getFullCredit(Currency currency) internal view returns (uint256 amount);

Parameters

NameTypeDescription
currencyCurrencyCurrency to get the delta for

Returns

NameTypeDescription
amountuint256The amount owed to this contract as a uint256

_mapSettleAmount

Calculates the amount for a settle action

function _mapSettleAmount(uint256 amount, Currency currency) internal view returns (uint256);

_mapTakeAmount

Calculates the amount for a take action

function _mapTakeAmount(uint256 amount, Currency currency) internal view returns (uint256);

_mapWrapUnwrapAmount

Calculates the sanitized amount before wrapping/unwrapping.

function _mapWrapUnwrapAmount(Currency inputCurrency, uint256 amount, Currency outputCurrency)
internal
view
returns (uint256);

Parameters

NameTypeDescription
inputCurrencyCurrencyThe currency, either native or wrapped native, that this contract holds
amountuint256The amount to wrap or unwrap. Can be CONTRACT_BALANCE, OPEN_DELTA or a specific amount
outputCurrencyCurrencyThe currency after the wrap/unwrap that the user may owe a balance in on the poolManager

Errors

DeltaNotPositive

Emitted trying to settle a positive delta.

error DeltaNotPositive(Currency currency);

DeltaNotNegative

Emitted trying to take a negative delta.

error DeltaNotNegative(Currency currency);

InsufficientBalance

Emitted when the contract does not have enough balance to wrap or unwrap.

error InsufficientBalance();
Helpful?