interface IncreaseLoanDelegator {

    // ============ Public Interface functions ============

    /**
     * Function a contract must implement in order to allow additional value to be added onto
     * an owned loan. Margin will call this on the owner of a loan during increasePosition().
     *
     * NOTE: If not returning zero (or not reverting), this contract must assume that Margin will
     * either revert the entire transaction or that the loan size was successfully increased.
     *
     * @param  payer           Lender adding additional funds to the position
     * @param  positionId      Unique ID of the position
     * @param  principalAdded  Principal amount to be added to the position
     * @param  lentAmount      Amount of owedToken lent by the lender (principal plus interest, or
     *                         zero if increaseWithoutCounterparty() is used).
     * @return                 This address to accept, a different address to ask that contract
     */
    function increaseLoanOnBehalfOf(
        address payer,
        bytes32 positionId,
        uint256 principalAdded,
        uint256 lentAmount
    )
        external
        /* onlyMargin */
        returns (address);
}
/**
 * @title IncreaseLoanDelegator
 * @author dYdX
 *
 * Interface that smart contracts must implement in order to own loans on behalf of other accounts.
 *
 * NOTE: Any contract implementing this interface should also use OnlyMargin to control access
 *       to these functions
 */
function increaseLoanOnBehalfOf(
    address payer,
    bytes32 positionId,
    uint256 principalAdded,
    uint256 lentAmount
)
    external
    /* onlyMargin */
    returns (address);

/**
 * Function a contract must implement in order to allow additional value to be added onto
 * an owned loan. Margin will call this on the owner of a loan during increasePosition().
 *
 * NOTE: If not returning zero (or not reverting), this contract must assume that Margin will
 * either revert the entire transaction or that the loan size was successfully increased.
 *
 * @param  payer           Lender adding additional funds to the position
 * @param  positionId      Unique ID of the position
 * @param  principalAdded  Principal amount to be added to the position
 * @param  lentAmount      Amount of owedToken lent by the lender (principal plus interest, or
 *                         zero if increaseWithoutCounterparty() is used).
 * @return                 This address to accept, a different address to ask that contract
 */