ETH Price: $1,964.31 (-0.83%)
 

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Buy239258782025-12-02 12:48:1182 days ago1764679691IN
0x0b4e03EC...A85eE41fd
0 ETH0.000006530.06134896
Buy238975892025-11-28 13:52:2385 days ago1764337943IN
0x0b4e03EC...A85eE41fd
0 ETH0.00006130.57597537
Buy238944262025-11-28 3:13:2386 days ago1764299603IN
0x0b4e03EC...A85eE41fd
0 ETH0.000005220.04698127
Buy238707762025-11-24 19:26:5989 days ago1764012419IN
0x0b4e03EC...A85eE41fd
0 ETH0.000046440.4175767
Buy238359532025-11-19 22:00:1194 days ago1763589611IN
0x0b4e03EC...A85eE41fd
0 ETH0.000250192.35072834
Sell238197732025-11-17 15:26:5996 days ago1763393219IN
0x0b4e03EC...A85eE41fd
0 ETH0.000105051.19885307
Sell238152732025-11-17 0:18:4797 days ago1763338727IN
0x0b4e03EC...A85eE41fd
0 ETH0.000050160.57247165
Sell238112362025-11-16 10:45:4798 days ago1763289947IN
0x0b4e03EC...A85eE41fd
0 ETH0.000093961.07237502
Sell238112322025-11-16 10:44:5998 days ago1763289899IN
0x0b4e03EC...A85eE41fd
0 ETH0.000094681.08051254
Sell238112222025-11-16 10:42:5998 days ago1763289779IN
0x0b4e03EC...A85eE41fd
0 ETH0.000087971.07288162
Sell238112192025-11-16 10:42:2398 days ago1763289743IN
0x0b4e03EC...A85eE41fd
0 ETH0.000094841.08254357
Sell238112132025-11-16 10:41:1198 days ago1763289671IN
0x0b4e03EC...A85eE41fd
0 ETH0.00009591.09429393
Sell238112022025-11-16 10:38:5998 days ago1763289539IN
0x0b4e03EC...A85eE41fd
0 ETH0.000089411.09074046
Sell238109102025-11-16 9:40:1198 days ago1763286011IN
0x0b4e03EC...A85eE41fd
0 ETH0.000181412.07002471
Buy238010842025-11-15 0:42:5999 days ago1763167379IN
0x0b4e03EC...A85eE41fd
0 ETH0.000008320.07817711
Sell237990142025-11-14 17:46:5999 days ago1763142419IN
0x0b4e03EC...A85eE41fd
0 ETH0.000063030.60172103
Sell237989192025-11-14 17:27:4799 days ago1763141267IN
0x0b4e03EC...A85eE41fd
0 ETH0.000247522.36300036
Sell237987042025-11-14 16:44:2399 days ago1763138663IN
0x0b4e03EC...A85eE41fd
0 ETH0.000153831.46856508
Sell237986012025-11-14 16:23:4799 days ago1763137427IN
0x0b4e03EC...A85eE41fd
0 ETH0.000105991.20911597
Sell237984662025-11-14 15:56:3599 days ago1763135795IN
0x0b4e03EC...A85eE41fd
0 ETH0.000187522.13920871
Buy237973822025-11-14 12:19:23100 days ago1763122763IN
0x0b4e03EC...A85eE41fd
0 ETH0.000080340.72227402
Buy237969572025-11-14 10:53:47100 days ago1763117627IN
0x0b4e03EC...A85eE41fd
0 ETH0.000225832.03026658
Sell237963272025-11-14 8:46:35100 days ago1763109995IN
0x0b4e03EC...A85eE41fd
0 ETH0.000022270.22275838
Sell237959432025-11-14 7:29:35100 days ago1763105375IN
0x0b4e03EC...A85eE41fd
0 ETH0.000030320.30341423
Sell237948352025-11-14 3:46:23100 days ago1763091983IN
0x0b4e03EC...A85eE41fd
0 ETH0.000012890.14710094
View all transactions

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Method Block
From
To
0x3d602d80223447542025-04-25 8:10:35303 days ago1745568635  Contract Creation0 ETH
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Minimal Proxy Contract for 0x4171e25e35fa13e98fb970d919b055c1866e6a12

Contract Name:
PSM

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 100 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: MIT

pragma solidity 0.8.28;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "../interfaces/IDebtToken.sol";
import "../dependencies/YalaOwnable.sol";
import "../interfaces/IPSM.sol";

contract PSM is IPSM, YalaOwnable, Pausable {
	using SafeERC20 for IERC20;

	uint256 public constant DECIMAL_PRECISIONS = 1e18;
	address public immutable override factory;
	IDebtToken public immutable override debtToken;
	IERC20Metadata public override pegToken;
	uint256 public override priceFactor;
	uint256 public override feeIn; // Fee for buying debtToken  (in DECIMAL_PRECISIONS)
	uint256 public override feeOut; // Fee for selling debtToken (in DECIMAL_PRECISIONS)
	uint256 public supplyCap; // Maximum amount of debtToken that can be held by PSM
	uint256 public totalActivedebt;

	constructor(address _yalaCore, address _factory, address _debtToken) YalaOwnable(_yalaCore) {
		factory = _factory;
		debtToken = IDebtToken(_debtToken);
	}

	function initialize(IERC20Metadata _pegToken, uint256 _feeIn, uint256 _feeOut, uint256 _supplyCap) external override {
		require(msg.sender == factory, "PSM: !Factory");
		uint8 pegTokenDecimals = _pegToken.decimals();
		require(pegTokenDecimals <= 18, "PSM: Peg token decimals not supported");
		priceFactor = 10 ** (18 - pegTokenDecimals);
		pegToken = _pegToken;
		_setFeeIn(_feeIn);
		_setFeeOut(_feeOut);
		_setSupplyCap(_supplyCap);
		emit PegTokenUpdated(_pegToken);
	}

	function setFeeIn(uint256 _feeIn) external override onlyOwner {
		_setFeeIn(_feeIn);
	}

	function setFeeOut(uint256 _feeOut) external override onlyOwner {
		_setFeeOut(_feeOut);
	}

	function setSupplyCap(uint256 _supplyCap) external onlyOwner {
		_setSupplyCap(_supplyCap);
	}

	// New functions for pausing and unpausing
	function pause() external onlyOwner {
		_pause();
	}

	function unpause() external onlyOwner {
		_unpause();
	}

	function buy(uint256 amountPegToken) external override whenNotPaused returns (uint256 amountDebtTokenReceived, uint256 fee) {
		require(amountPegToken > 0, "PSM: Amount peg token must be greater than 0");
		(amountDebtTokenReceived, fee) = estimateBuy(amountPegToken);
		require(totalActivedebt + amountDebtTokenReceived <= supplyCap, "PSM: Supply cap reached");
		if (feeIn > 0) require(fee > 0, "PSM: Fee must be greater than 0");
		IERC20(pegToken).safeTransferFrom(msg.sender, address(this), amountPegToken);
		debtToken.mint(msg.sender, amountDebtTokenReceived);
		if (fee > 0) debtToken.mint(YALA_CORE.feeReceiver(), fee);
		totalActivedebt = totalActivedebt + amountDebtTokenReceived + fee;

		emit Buy(msg.sender, amountDebtTokenReceived, amountPegToken, fee);
	}

	function sell(uint256 amountDebtToken) external override whenNotPaused returns (uint256 amountPegTokenReceived, uint256 fee) {
		require(amountDebtToken > 0, "PSM: Amount debt token must be greater than 0");
		(amountPegTokenReceived, fee) = estimateSell(amountDebtToken);
		if (feeOut > 0) require(fee > 0, "PSM: Fee must be greater than 0");
		require(pegToken.balanceOf(address(this)) >= amountPegTokenReceived, "PSM: Insufficient peg token balance");
		debtToken.burn(msg.sender, amountDebtToken - fee);
		IERC20(pegToken).safeTransfer(msg.sender, amountPegTokenReceived);
		if (fee > 0) debtToken.transferFrom(msg.sender, YALA_CORE.feeReceiver(), fee);
		totalActivedebt = totalActivedebt - amountDebtToken;

		emit Sell(msg.sender, amountDebtToken, amountPegTokenReceived, fee);
	}

	function estimateBuy(uint256 amountPegToken) public view override returns (uint256 amountDebtTokenReceived, uint256 fee) {
		if (feeIn > 0) {
			fee = (amountPegToken * feeIn * priceFactor) / DECIMAL_PRECISIONS;
		}
		amountDebtTokenReceived = amountPegToken * priceFactor - fee;
	}

	function estimateSell(uint256 amountDebtToken) public view override returns (uint256 amountPegTokenReceived, uint256 fee) {
		if (feeOut > 0) {
			fee = (amountDebtToken * feeOut) / DECIMAL_PRECISIONS;
		}
		amountPegTokenReceived = (amountDebtToken - fee) / priceFactor;
	}

	function _setFeeIn(uint256 _feeIn) internal {
		require(_feeIn <= DECIMAL_PRECISIONS, "PSM: Fee in must be less than 1");
		feeIn = _feeIn;
		emit FeeInUpdated(_feeIn);
	}

	function _setFeeOut(uint256 _feeOut) internal {
		require(_feeOut <= DECIMAL_PRECISIONS, "PSM: Fee out must be less than 1");
		feeOut = _feeOut;
		emit FeeOutUpdated(_feeOut);
	}

	function _setSupplyCap(uint256 _supplyCap) internal {
		supplyCap = _supplyCap;
		emit SupplyCapUpdated(_supplyCap);
	}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.28;

import "../interfaces/IYalaCore.sol";

/**
    @title Yala Ownable
    @notice Contracts inheriting `YalaOwnable` have the same owner as `YalaCore`.
            The ownership cannot be independently modified or renounced.
 */
contract YalaOwnable {
	IYalaCore public immutable YALA_CORE;

	constructor(address _yalaCore) {
		YALA_CORE = IYalaCore(_yalaCore);
	}

	modifier onlyOwner() {
		require(msg.sender == YALA_CORE.owner(), "Only owner");
		_;
	}

	function owner() public view returns (address) {
		return YALA_CORE.owner();
	}

	function guardian() public view returns (address) {
		return YALA_CORE.guardian();
	}
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.28;

import "./ITroveManager.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IDebtToken is IERC20 {
	function burn(address _account, uint256 _amount) external;
	function burnWithGasCompensation(address _account, uint256 _amount) external returns (bool);

	function enableTroveManager(address _troveManager) external;

	function enablePSM(address _psm) external;

	function mint(address _account, uint256 _amount) external;

	function mintWithGasCompensation(address _account, uint256 _amount) external returns (bool);

	function returnFromPool(address _poolAddress, address _receiver, uint256 _amount) external;

	function sendToSP(address _sender, uint256 _amount) external;

	function DEBT_GAS_COMPENSATION() external view returns (uint256);

	function borrowerOperationsAddress() external view returns (address);

	function factory() external view returns (address);

	function gasPool() external view returns (address);

	function troveManager(address) external view returns (bool);
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.28;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IMetadataNFT {
	struct TroveData {
		uint256 tokenId;
		address owner;
		IERC20 collToken;
		IERC20 debtToken;
		uint256 collAmount;
		uint256 debtAmount;
		uint256 interest;
	}

	function uri(TroveData memory _troveData) external view returns (string memory);
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IPriceFeed {
	event NewOracleRegistered(address token, address chainlinkAggregator, bool isEthIndexed);
	event PriceFeedStatusUpdated(address token, address oracle, bool isWorking);
	event PriceRecordUpdated(address indexed token, uint256 _price);

	function fetchPrice(address _token) external returns (uint256);

	function setOracle(address _token, address _chainlinkOracle, bytes4 sharePriceSignature, uint8 sharePriceDecimals, bool _isEthIndexed) external;

	function MAX_PRICE_DEVIATION_FROM_PREVIOUS_ROUND() external view returns (uint256);

	function YALA_CORE() external view returns (address);

	function RESPONSE_TIMEOUT() external view returns (uint256);

	function TARGET_DIGITS() external view returns (uint256);

	function guardian() external view returns (address);

	function oracleRecords(address) external view returns (address chainLinkOracle, uint8 decimals, bytes4 sharePriceSignature, uint8 sharePriceDecimals, bool isFeedWorking, bool isEthIndexed);

	function owner() external view returns (address);

	function priceRecords(address) external view returns (uint96 scaledPrice, uint32 timestamp, uint32 lastUpdated, uint80 roundId);
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.28;

import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "./IDebtToken.sol";

interface IPSM {
	event PegTokenUpdated(IERC20Metadata pegToken);
	event FeeInUpdated(uint256 feeIn);
	event FeeOutUpdated(uint256 feeOut);
	event Buy(address from, uint256 amountDebtToken, uint256 amountPegToken, uint256 fee);
	event Sell(address from, uint256 amountDebtToken, uint256 amountPegToken, uint256 fee);
	event SupplyCapUpdated(uint256 newCap);
	event DebtCeilingUpdated(uint256 newCeiling);

	function factory() external view returns (address);
	function pegToken() external view returns (IERC20Metadata);
	function debtToken() external view returns (IDebtToken);
	function feeIn() external view returns (uint256);
	function feeOut() external view returns (uint256);
	function priceFactor() external view returns (uint256);
	function initialize(IERC20Metadata _pegToken, uint256 _feeIn, uint256 _feeOut, uint256 _supplyCap) external; // only called by owner
	function setFeeIn(uint256 _feeIn) external;
	function setFeeOut(uint256 _feeOut) external;

	function buy(uint256 amountPegToken) external returns (uint256 amountDebtTokenUsed, uint256 fee);
	function sell(uint256 amountDebtToken) external returns (uint256 amountPegTokenReceived, uint256 fee);
	function estimateBuy(uint256 amountDebtToken) external view returns (uint256 amountPegTokenUsed, uint256 fee);
	function estimateSell(uint256 amountDebtToken) external returns (uint256 amountPegTokenReceived, uint256 fee);
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.28;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "./IPriceFeed.sol";
import "./IMetadataNFT.sol";

interface ITroveManager is IERC721Enumerable {
	// Store the necessary data for a trove
	struct Trove {
		uint256 debt;
		uint256 coll;
		uint256 stake;
		uint256 interest;
	}

	struct LocalTroveUpdateVariables {
		uint256 id;
		uint256 debtChange;
		uint256 collChange;
		uint256 interestRepayment;
		bool isCollIncrease;
		bool isDebtIncrease;
		address receiver;
	}

	struct DeploymentParams {
		uint256 interestRate; // 1e16 (1%)
		uint256 maxDebt;
		uint256 spYieldPCT;
		uint256 liquidationPenaltySP;
		uint256 liquidationPenaltyRedistribution;
		uint256 maxCollGasCompensation;
		uint256 MCR; // 11e17  (110%)
		uint256 SCR;
		uint256 CCR;
		IMetadataNFT metadataNFT;
	}

	// Object containing the collateral and debt snapshots for a given active trove
	struct RewardSnapshot {
		uint256 collateral;
		uint256 debt;
		uint256 activeInterest;
		uint256 defaultedInterest;
	}

	struct LiquidationValues {
		uint256 collOffset;
		uint256 debtOffset;
		uint256 interestOffset;
		uint256 collRedist;
		uint256 debtRedist;
		uint256 interestRedist;
		uint256 debtGasCompensation;
		uint256 collGasCompensation;
		uint256 remainingDeposits;
		uint256 collSurplus;
	}

	struct SingleLiquidation {
		uint256 coll;
		uint256 debt;
		uint256 interest;
		uint256 collGasCompensation;
		uint256 debtGasCompensation;
		uint256 collToLiquidate;
		uint256 collOffset;
		uint256 debtOffset;
		uint256 interestOffset;
		uint256 collRedist;
		uint256 debtRedist;
		uint256 interestRedist;
		uint256 collSurplus;
	}

	enum TroveManagerOperation {
		open,
		close,
		adjust,
		liquidate
	}
	event CRUpdated(uint256 _MCR, uint256 _SCR, uint256 _CCR);
	event ShutDown();
	event PauseUpdated(bool _paused);
	event PriceFeedUpdated(IPriceFeed priceFeed);
	event MetadataNFTUpdated(IMetadataNFT _metadataNFT);
	event InterestRateUpdated(uint256 _interestRate);
	event MaxSystemDebtUpdated(uint256 _cap);
	event SPYieldPCTUpdated(uint256 _spYielPCT);
	event LIQUIDATION_PENALTY_SP_Updated(uint256 _penaltySP);
	event LIQUIDATION_PENALTY_REDISTRIBUTION_Updated(uint256 _penaltyRedist);
	event MAX_COLL_GAS_COMPENSATION_Updated(uint256 _maxCollGasCompensation);

	event TroveOpened(uint256 id, address owner, uint256 _collateralAmount, uint256 _compositeDebt, uint256 stake);
	event TroveUpdated(uint256 id, uint256 newColl, uint256 newDebt, uint256 newStake, uint256 newInterest, address _receiver, TroveManagerOperation operation);
	event TotalStakesUpdated(uint256 newTotalStakes);
	event LTermsUpdated(uint256 new_L_collateral, uint256 new_L_debt, uint256 new_L_defaulted_interest);
	event Liquidated(address owner, uint256 id, uint256 coll, uint256 debt, uint256 interest, uint256 collSurplus);
	event CollateralSent(address _account, uint256 _amount);
	event CollSurplusClaimed(address _account, uint256 _amount);
	event TroveClosed(uint256 id);
	event InterestAccrued(uint256 interest);
	event SPYieldAccrued(uint256 yieldFee);
	function accrueInterests() external returns (uint256 yieldSP, uint256 yieldFee);
	function collateralToken() external view returns (IERC20);
	function totalActiveDebt() external view returns (uint256);
	function defaultedDebt() external view returns (uint256);
	function shutdownAt() external view returns (uint256);
	function getEntireSystemDebt() external view returns (uint256);
	function getEntireSystemBalances() external returns (uint256 coll, uint256 debt, uint256 interest, uint256 price);
	function interestRate() external view returns (uint256);
	function MCR() external view returns (uint256);
	function SCR() external view returns (uint256);
	function CCR() external view returns (uint256);
	function maxSystemDebt() external view returns (uint256);
	function SP_YIELD_PCT() external view returns (uint256);
	function MAX_COLL_GAS_COMPENSATION() external view returns (uint256);
	function LIQUIDATION_PENALTY_SP() external view returns (uint256);
	function LIQUIDATION_PENALTY_REDISTRIBUTION() external view returns (uint256);
	function getTCR() external returns (uint256);
	function setParameters(IPriceFeed _priceFeed, IERC20 _collateral, DeploymentParams memory params) external;
	function openTrove(address owner, uint256 _collateralAmount, uint256 _compositeDebt) external returns (uint256 id);
	function updateTroveFromAdjustment(uint256 id, bool _isDebtIncrease, uint256 _debtChange, bool _isCollIncrease, uint256 _collChange, uint256 _interestRepayment, address _receiver) external returns (uint256, uint256, uint256, uint256);
	function closeTrove(uint256 id, address _receiver, uint256 collAmount, uint256 debtAmount, uint256 interest) external;
	function applyPendingRewards(uint256 id) external returns (uint256 coll, uint256 debt, uint256 interest);
	function fetchPrice() external returns (uint256);
	function getCurrentTrove(uint256 id) external view returns (Trove memory);
	function getPendingYieldSP() external view returns (uint256);
	function accountCollSurplus(address account) external view returns (uint256);
	function hasShutdown() external view returns (bool);
	function batchLiquidate(uint256[] memory ids) external;
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IYalaCore {
	event NewOwnerCommitted(address owner, address pendingOwner, uint256 deadline);

	event NewOwnerAccepted(address oldOwner, address owner);

	event NewOwnerRevoked(address owner, address revokedOwner);

	event FeeReceiverSet(address feeReceiver);

	event GuardianSet(address guardian);

	event Paused();

	event Unpaused();

	function acceptTransferOwnership() external;

	function commitTransferOwnership(address newOwner) external;

	function revokeTransferOwnership() external;

	function setFeeReceiver(address _feeReceiver) external;

	function setGuardian(address _guardian) external;

	function setPaused(bool _paused) external;

	function OWNERSHIP_TRANSFER_DELAY() external view returns (uint256);

	function feeReceiver() external view returns (address);

	function guardian() external view returns (address);

	function owner() external view returns (address);

	function ownershipTransferDeadline() external view returns (uint256);

	function paused() external view returns (bool);

	function pendingOwner() external view returns (address);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 100
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_yalaCore","type":"address"},{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_debtToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountDebtToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountPegToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"Buy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newCeiling","type":"uint256"}],"name":"DebtCeilingUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feeIn","type":"uint256"}],"name":"FeeInUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feeOut","type":"uint256"}],"name":"FeeOutUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20Metadata","name":"pegToken","type":"address"}],"name":"PegTokenUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountDebtToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountPegToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"Sell","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newCap","type":"uint256"}],"name":"SupplyCapUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DECIMAL_PRECISIONS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"YALA_CORE","outputs":[{"internalType":"contract IYalaCore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountPegToken","type":"uint256"}],"name":"buy","outputs":[{"internalType":"uint256","name":"amountDebtTokenReceived","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"debtToken","outputs":[{"internalType":"contract IDebtToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountPegToken","type":"uint256"}],"name":"estimateBuy","outputs":[{"internalType":"uint256","name":"amountDebtTokenReceived","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountDebtToken","type":"uint256"}],"name":"estimateSell","outputs":[{"internalType":"uint256","name":"amountPegTokenReceived","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeIn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20Metadata","name":"_pegToken","type":"address"},{"internalType":"uint256","name":"_feeIn","type":"uint256"},{"internalType":"uint256","name":"_feeOut","type":"uint256"},{"internalType":"uint256","name":"_supplyCap","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pegToken","outputs":[{"internalType":"contract IERC20Metadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountDebtToken","type":"uint256"}],"name":"sell","outputs":[{"internalType":"uint256","name":"amountPegTokenReceived","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feeIn","type":"uint256"}],"name":"setFeeIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feeOut","type":"uint256"}],"name":"setFeeOut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_supplyCap","type":"uint256"}],"name":"setSupplyCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"supplyCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalActivedebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.