Skip to main content

TranchingLogic

TranchingLogic

Deployment on Ethereum mainnet:

https://etherscan.io/address/0x9BCE1F08012DD6e72756Cd015E50068f90963D22

Library for handling the payments waterfall

SharePriceUpdated

event SharePriceUpdated(address pool, uint256 tranche, uint256 principalSharePrice, int256 principalDelta, uint256 interestSharePrice, int256 interestDelta)

FP_SCALING_FACTOR

uint256 FP_SCALING_FACTOR

ONE_HUNDRED

uint256 ONE_HUNDRED

usdcToSharePrice

function usdcToSharePrice(uint256 amount, uint256 totalShares) public pure returns (uint256)

sharePriceToUsdc

function sharePriceToUsdc(uint256 sharePrice, uint256 totalShares) public pure returns (uint256)

redeemableInterestAndPrincipal

function redeemableInterestAndPrincipal(struct ITranchedPool.TrancheInfo trancheInfo, struct IPoolTokens.TokenInfo tokenInfo) public view returns (uint256 interestRedeemable, uint256 principalRedeemable)

calculateExpectedSharePrice

function calculateExpectedSharePrice(struct ITranchedPool.TrancheInfo tranche, uint256 amount, struct ITranchedPool.PoolSlice slice) public pure returns (uint256)

scaleForSlice

function scaleForSlice(struct ITranchedPool.PoolSlice slice, uint256 amount, uint256 totalDeployed) public pure returns (uint256)

getSliceInfo

function getSliceInfo(struct ITranchedPool.PoolSlice slice, contract IV2CreditLine creditLine, uint256 totalDeployed, uint256 reserveFeePercent) public view returns (struct ITranchedPool.SliceInfo)

getTotalInterestAndPrincipal

function getTotalInterestAndPrincipal(struct ITranchedPool.PoolSlice slice, contract IV2CreditLine creditLine, uint256 totalDeployed) public view returns (uint256 interestAccrued, uint256 principalAccrued)

scaleByFraction

function scaleByFraction(uint256 amount, uint256 fraction, uint256 total) public pure returns (uint256)

applyToAllSeniorTranches

function applyToAllSeniorTranches(struct ITranchedPool.PoolSlice[] poolSlices, uint256 interest, uint256 principal, uint256 reserveFeePercent, uint256 totalDeployed, contract IV2CreditLine creditLine, uint256 juniorFeePercent) public returns (struct ITranchedPool.ApplyResult)

applyToAllJuniorTranches

function applyToAllJuniorTranches(struct ITranchedPool.PoolSlice[] poolSlices, uint256 interest, uint256 principal, uint256 reserveFeePercent, uint256 totalDeployed, contract IV2CreditLine creditLine) public returns (uint256 totalReserveAmount)

emitSharePriceUpdatedEvent

function emitSharePriceUpdatedEvent(struct ITranchedPool.TrancheInfo tranche, struct ITranchedPool.ApplyResult applyResult) internal

applyToSeniorTranche

function applyToSeniorTranche(struct ITranchedPool.PoolSlice slice, uint256 interestRemaining, uint256 principalRemaining, uint256 juniorFeePercent, struct ITranchedPool.SliceInfo sliceInfo) public returns (struct ITranchedPool.ApplyResult)

applyToJuniorTranche

function applyToJuniorTranche(struct ITranchedPool.PoolSlice slice, uint256 interestRemaining, uint256 principalRemaining, struct ITranchedPool.SliceInfo sliceInfo) public returns (struct ITranchedPool.ApplyResult)

applyBySharePrice

function applyBySharePrice(struct ITranchedPool.TrancheInfo tranche, uint256 interestRemaining, uint256 principalRemaining, uint256 desiredInterestSharePrice, uint256 desiredPrincipalSharePrice) public returns (uint256, uint256)

applyByAmount

function applyByAmount(struct ITranchedPool.TrancheInfo tranche, uint256 interestRemaining, uint256 principalRemaining, uint256 desiredInterestAmount, uint256 desiredPrincipalAmount) public returns (uint256, uint256)

migrateAccountingVariables

function migrateAccountingVariables(address originalClAddr, address newClAddr) public

closeCreditLine

function closeCreditLine(address originalCl) public

desiredAmountFromSharePrice

function desiredAmountFromSharePrice(uint256 desiredSharePrice, uint256 actualSharePrice, uint256 totalShares) public pure returns (uint256)

applyToSharePrice

function applyToSharePrice(uint256 amountRemaining, uint256 currentSharePrice, uint256 desiredAmount, uint256 totalShares) public pure returns (uint256, uint256)

scaleByPercentOwnership

function scaleByPercentOwnership(struct ITranchedPool.TrancheInfo tranche, uint256 amount, struct ITranchedPool.PoolSlice slice) public pure returns (uint256)