Skip to content
Verified contractExactMIT

Pool420Stake

Address0xf6fcf33c05c616aef4db33b2b4cfff88dbc92534
Balance

0 ETH

 

Transactions

940

 

Compiler

solc 0.8.27

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.27+commit.40a35a09
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
22,238,959
Creation transaction
0x86822da5ae…8c5815a189

src/Pool420Stake.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

import "./Interfaces.sol";

contract Pool420Stake {
    error NotEnoughAllowance(
        address walletAddress, address tokenAddress, uint256 requiredAllowance, uint256 availableAllowance
    );
    error NotEnoughBalance(address walletAddress, address tokenAddress, uint256 requiredAmount, uint256 availableAmount);

    ICoreProxy public CoreProxy;
    IAccountProxy public AccountProxy;
    ITreasuryMarketProxy public TreasuryMarketProxy;
    ILegacyMarketProxy public LegacyMarketProxy;
    IAddressResolver public V2xResolver;

    uint256 public constant UINT256_MAX = type(uint256).max;

    constructor(
        //
        address CoreProxy_,
        address AccountProxy_,
        address TreasuryMarketProxy_,
        address LegacyMarketProxy_
    ) {
        CoreProxy = ICoreProxy(CoreProxy_);
        AccountProxy = IAccountProxy(AccountProxy_);
        TreasuryMarketProxy = ITreasuryMarketProxy(TreasuryMarketProxy_);
        LegacyMarketProxy = ILegacyMarketProxy(LegacyMarketProxy_);
        V2xResolver = IAddressResolver(LegacyMarketProxy.v2xResolver());
    }

    function getV2x() public view returns (address v2x) {
        v2x = V2xResolver.getAddress("Synthetix");
    }

    function getV2xUsd() public view returns (address v2xUsd) {
        v2xUsd = V2xResolver.getAddress("SynthsUSD");
    }

    function get$SNX() public view returns (address $SNX) {
        $SNX = V2xResolver.getAddress("ProxySynthetix");
    }

    function get$sUSD() public view returns (address $sUSD) {
        $sUSD = V2xResolver.getAddress("ProxysUSD");
    }

    function get$snxUSD() public view returns (address $snxUSD) {
        $snxUSD = CoreProxy.getUsdToken();
    }

    /**
     * @notice Sets up a user's position by creating a new Synthetix V3 account, delegating SNX to the SC pool,
     * minting snxUSD, withdrawing the minted snxUSD, migrating the position to the Delegated Staking pool,
     * and finally transferring the account NFT to the user.
     * @dev This function automates the process of initializing and migrating a user's position.
     * It creates an account, delegates SNX, mints the maximum amount of snxUSD,
     * withdraws the minted snxUSD, migrates the position, and finally sends the account NFT to the user.
     * @param $SNXAmount The amount of SNX to be deposited into the SC pool.
     */
    function setupPosition(uint256 $SNXAmount) public {
        address msgSender = ERC2771Context._msgSender();
        uint128 poolId = TreasuryMarketProxy.poolId();

        // 1. Create new v3 account for the user
        uint128 accountId = CoreProxy.createAccount();

        // 2. Must rebalance the pool
        TreasuryMarketProxy.rebalance();

        // 3. Delegate $SNXAmount to the 420 pool
        _increasePosition(accountId, $SNXAmount, poolId);

        // 4. Saddle account, updating rewards and virtual debt
        TreasuryMarketProxy.saddle(accountId);

        // 5. Send account NFT back to the user wallet
        AccountProxy.transferFrom(
            //
            address(this),
            msgSender,
            uint256(accountId)
        );
    }

    /**
     * @notice Increases the position of $SNX collateral for the specified account and pool by transferring the specified amount from the caller's wallet.
     * @dev This function handles the following steps:
     *      1. Verifies if the caller's wallet has sufficient transferable $SNX.
     *      2. If the specified $SNXAmount exceeds transferable $SNX, it adjusts to use only the maximum transferable amount.
     *      3. Ensures the caller's wallet has provided enough allowance to the contract.
     *      4. Transfers $SNX from the wallet to the contract.
     *      5. Deposits the transferred $SNX into the Core system.
     *      6. Delegates the deposited $SNX to the specified pool.
     *      If the caller's wallet doesn't have enough $SNX or allowance, the function reverts with an appropriate error.
     * @param accountId The unique ID of the user's Synthetix v3 Account NFT.
     * @param $SNXAmount The amount of $SNX to increase the position by. If greater than the wallet's transferable $SNX, only the maximum transferrable amount is used.
     * @param poolId The unique ID of the pool to which the $SNX collateral is being delegated.
     */
    function _increasePosition(uint128 accountId, uint256 $SNXAmount, uint128 poolId) internal {
        address msgSender = ERC2771Context._msgSender();
        address $SNX = get$SNX();

        uint256 transferable$SNXAmount = IV2x(getV2x()).transferableSynthetix(msgSender);
        if (transferable$SNXAmount == 0) {
            // 1a. Verify wallet has enough transferable $SNX
            revert NotEnoughBalance(
                //
                msgSender,
                $SNX,
                $SNXAmount,
                transferable$SNXAmount
            );
        }
        if ($SNXAmount > transferable$SNXAmount) {
            // 1b. Use ALL transferable $SNX
            $SNXAmount = transferable$SNXAmount;
        }

        // 2. Verify wallet has enough allowance to transfer $SNX
        uint256 available$SNXAllowance = IERC20($SNX).allowance(
            //
            msgSender,
            address(this)
        );
        if ($SNXAmount > available$SNXAllowance) {
            revert NotEnoughAllowance(
                //
                msgSender,
                $SNX,
                $SNXAmount,
                available$SNXAllowance
            );
        }

        // 3. Transfer $SNX from user wallet to Pool420Stake
        IERC20($SNX).transferFrom(
            //
            msgSender,
            address(this),
            $SNXAmount
        );

        // 4. Deposit $SNX to the Core
        IERC20($SNX).approve(address(CoreProxy), $SNXAmount);
        CoreProxy.deposit(
            //
            accountId,
            $SNX,
            $SNXAmount
        );

        // 5. Delegate $SNX to the Pool
        uint256 currentPosition = CoreProxy.getPositionCollateral(
            //
            accountId,
            poolId,
            $SNX
        );
        CoreProxy.delegateCollateral(
            //
            accountId,
            poolId,
            $SNX,
            currentPosition + $SNXAmount,
            1e18
        );
    }

    function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) {
        return IERC721Receiver.onERC721Received.selector;
    }
}

../../node_modules/@synthetixio/core-contracts/contracts/interfaces/IERC20.sol

//SPDX-License-Identifier: MIT
pragma solidity >=0.8.11 <0.9.0;

/**
 * @title ERC20 token implementation.
 */
interface IERC20 {
    /**
     * @notice Emitted when tokens have been transferred.
     * @param from The address that originally owned the tokens.
     * @param to The address that received the tokens.
     * @param amount The number of tokens that were transferred.
     */
    event Transfer(address indexed from, address indexed to, uint256 amount);

    /**
     * @notice Emitted when a user has provided allowance to another user for transferring tokens on its behalf.
     * @param owner The address that is providing the allowance.
     * @param spender The address that received the allowance.
     * @param amount The number of tokens that were added to `spender`'s allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /**
     * @notice Thrown when the address interacting with the contract does not have sufficient allowance to transfer tokens from another contract.
     * @param required The necessary allowance.
     * @param existing The current allowance.
     */
    error InsufficientAllowance(uint256 required, uint256 existing);

    /**
     * @notice Thrown when the address interacting with the contract does not have sufficient tokens.
     * @param required The necessary balance.
     * @param existing The current balance.
     */
    error InsufficientBalance(uint256 required, uint256 existing);

    /**
     * @notice Retrieves the name of the token, e.g. "Synthetix Network Token".
     * @return A string with the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @notice Retrieves the symbol of the token, e.g. "SNX".
     * @return A string with the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @notice Retrieves the number of decimals used by the token. The default is 18.
     * @return The number of decimals.
     */
    function decimals() external view returns (uint8);

    /**
     * @notice Returns the total number of tokens in circulation (minted - burnt).
     * @return The total number of tokens.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @notice Returns the balance of a user.
     * @param owner The address whose balance is being retrieved.
     * @return The number of tokens owned by the user.
     */
    function balanceOf(address owner) external view returns (uint256);

    /**
     * @notice Returns how many tokens a user has allowed another user to transfer on its behalf.
     * @param owner The user who has given the allowance.
     * @param spender The user who was given the allowance.
     * @return The amount of tokens `spender` can transfer on `owner`'s behalf.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @notice Transfer tokens from one address to another.
     * @param to The address that will receive the tokens.
     * @param amount The amount of tokens to be transferred.
     * @return A boolean which is true if the operation succeeded.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @notice Allows users to provide allowance to other users so that they can transfer tokens on their behalf.
     * @param spender The address that is receiving the allowance.
     * @param amount The amount of tokens that are being added to the allowance.
     * @return A boolean which is true if the operation succeeded.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @notice Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) external returns (bool);

    /**
     * @notice Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);

    /**
     * @notice Allows a user who has been given allowance to transfer tokens on another user's behalf.
     * @param from The address that owns the tokens that are being transferred.
     * @param to The address that will receive the tokens.
     * @param amount The number of tokens to transfer.
     * @return A boolean which is true if the operation succeeded.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

../../node_modules/@synthetixio/core-contracts/contracts/interfaces/IERC721Receiver.sol

//SPDX-License-Identifier: MIT
pragma solidity >=0.8.11 <0.9.0;

/**
 * @title ERC721 extension that allows contracts to receive tokens with `safeTransferFrom`.
 */
interface IERC721Receiver {
    /**
     * @notice Function that will be called by ERC721 tokens implementing the `safeTransferFrom` function.
     * @dev The contract transferring the token will revert if the receiving contract does not implement this function.
     * @param operator The address that is executing the transfer.
     * @param from The address whose token is being transferred.
     * @param tokenId The numeric id of the token being transferred.
     * @param data Optional additional data that may be passed by the operator, and could be used by the implementing contract.
     * @return The selector of this function (IERC721Receiver.onERC721Received.selector). Caller will revert if not returned.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes memory data
    ) external returns (bytes4);
}

../../node_modules/@synthetixio/core-contracts/contracts/utils/ERC2771Context.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/* solhint-disable meta-transactions/no-msg-sender */
/* solhint-disable meta-transactions/no-msg-data */

library ERC2771Context {
    // This is the trusted-multicall-forwarder. The address is constant due to CREATE2.
    address private constant TRUSTED_FORWARDER = 0xE2C5658cC5C448B48141168f3e475dF8f65A1e3e;

    function _msgSender() internal view returns (address sender) {
        if (isTrustedForwarder(msg.sender) && msg.data.length >= 20) {
            // The assembly code is more direct than the Solidity version using `abi.decode`.
            /// @solidity memory-safe-assembly
            assembly {
                sender := shr(96, calldataload(sub(calldatasize(), 20)))
            }
        } else {
            return msg.sender;
        }
    }

    function _msgData() internal view returns (bytes calldata) {
        if (isTrustedForwarder(msg.sender) && msg.data.length >= 20) {
            return msg.data[:msg.data.length - 20];
        } else {
            return msg.data;
        }
    }

    function isTrustedForwarder(address forwarder) internal pure returns (bool) {
        return forwarder == TRUSTED_FORWARDER;
    }

    function trustedForwarder() internal pure returns (address) {
        return TRUSTED_FORWARDER;
    }
}

../../node_modules/@synthetixio/v3-contracts/1-main/IAccountProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface IAccountProxy {
    function facets() external pure returns (S_0[] memory);
    function facetFunctionSelectors(address facet) external pure returns (bytes4[] memory functionSelectors);
    function facetAddresses() external pure returns (address[] memory addresses);
    function facetAddress(bytes4 functionSelector) external pure returns (address);
    function emitDiamondCutEvent() external returns (bool);
    error ImplementationIsSterile(address implementation);
    error NoChange();
    error NotAContract(address contr);
    error NotNominated(address addr);
    error Unauthorized(address addr);
    error UpgradeSimulationFailed();
    error ZeroAddress();
    event OwnerChanged(address oldOwner, address newOwner);
    event OwnerNominated(address newOwner);
    event Upgraded(address indexed self, address implementation);
    function acceptOwnership() external;
    function getImplementation() external view returns (address);
    function nominateNewOwner(address newNominatedOwner) external;
    function nominatedOwner() external view returns (address);
    function owner() external view returns (address);
    function renounceNomination() external;
    function simulateUpgradeTo(address newImplementation) external;
    function upgradeTo(address newImplementation) external;
    error AlreadyInitialized();
    error CannotSelfApprove(address addr);
    error IndexOverrun(uint256 requestedIndex, uint256 length);
    error InvalidOwner(address addr);
    error InvalidParameter(string parameter, string reason);
    error InvalidTransferRecipient(address addr);
    error OverflowUint256ToUint128();
    error TokenAlreadyMinted(uint256 id);
    error TokenDoesNotExist(uint256 id);
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
    function approve(address to, uint256 tokenId) external;
    function balanceOf(address holder) external view returns (uint256 balance);
    function burn(uint256 tokenId) external;
    function getApproved(uint256 tokenId) external view returns (address operator);
    function initialize(string memory tokenName, string memory tokenSymbol, string memory uri) external;
    function isApprovedForAll(address holder, address operator) external view returns (bool);
    function isInitialized() external view returns (bool);
    function mint(address to, uint256 tokenId) external;
    function name() external view returns (string memory);
    function ownerOf(uint256 tokenId) external view returns (address);
    function safeMint(address to, uint256 tokenId, bytes memory data) external;
    function safeTransferFrom(address from, address to, uint256 tokenId) external;
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) external;
    function setAllowance(uint256 tokenId, address spender) external;
    function setApprovalForAll(address operator, bool approved) external;
    function setBaseTokenURI(string memory uri) external;
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
    function symbol() external view returns (string memory);
    function tokenByIndex(uint256 index) external view returns (uint256);
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
    function tokenURI(uint256 tokenId) external view returns (string memory);
    function totalSupply() external view returns (uint256);
    function transferFrom(address from, address to, uint256 tokenId) external;
}

struct S_0 {
    address facetAddress;
    bytes4[] functionSelectors;
}

../../node_modules/@synthetixio/v3-contracts/1-main/ICoreProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface ICoreProxy {
    function facets() external pure returns (S_0[] memory);
    function facetFunctionSelectors(address facet) external pure returns (bytes4[] memory functionSelectors);
    function facetAddresses() external pure returns (address[] memory addresses);
    function facetAddress(bytes4 functionSelector) external pure returns (address);
    function emitDiamondCutEvent() external returns (bool);
    error ImplementationIsSterile(address implementation);
    error NoChange();
    error NotAContract(address contr);
    error NotNominated(address addr);
    error Unauthorized(address addr);
    error UpgradeSimulationFailed();
    error ZeroAddress();
    event OwnerChanged(address oldOwner, address newOwner);
    event OwnerNominated(address newOwner);
    event Upgraded(address indexed self, address implementation);
    function acceptOwnership() external;
    function getImplementation() external view returns (address);
    function nominateNewOwner(address newNominatedOwner) external;
    function nominatedOwner() external view returns (address);
    function owner() external view returns (address);
    function renounceNomination() external;
    function simulateUpgradeTo(address newImplementation) external;
    function upgradeTo(address newImplementation) external;
    error ValueAlreadyInSet();
    error ValueNotInSet();
    event FeatureFlagAllowAllSet(bytes32 indexed feature, bool allowAll);
    event FeatureFlagAllowlistAdded(bytes32 indexed feature, address account);
    event FeatureFlagAllowlistRemoved(bytes32 indexed feature, address account);
    event FeatureFlagDeniersReset(bytes32 indexed feature, address[] deniers);
    event FeatureFlagDenyAllSet(bytes32 indexed feature, bool denyAll);
    function addToFeatureFlagAllowlist(bytes32 feature, address account) external;
    function getDeniers(bytes32 feature) external view returns (address[] memory);
    function getFeatureFlagAllowAll(bytes32 feature) external view returns (bool);
    function getFeatureFlagAllowlist(bytes32 feature) external view returns (address[] memory);
    function getFeatureFlagDenyAll(bytes32 feature) external view returns (bool);
    function isFeatureAllowed(bytes32 feature, address account) external view returns (bool);
    function removeFromFeatureFlagAllowlist(bytes32 feature, address account) external;
    function setDeniers(bytes32 feature, address[] memory deniers) external;
    function setFeatureFlagAllowAll(bytes32 feature, bool allowAll) external;
    function setFeatureFlagDenyAll(bytes32 feature, bool denyAll) external;
    error FeatureUnavailable(bytes32 which);
    error InvalidAccountId(uint128 accountId);
    error InvalidPermission(bytes32 permission);
    error OnlyAccountTokenProxy(address origin);
    error PermissionDenied(uint128 accountId, bytes32 permission, address target);
    error PermissionNotGranted(uint128 accountId, bytes32 permission, address user);
    error PositionOutOfBounds();
    event AccountCreated(uint128 indexed accountId, address indexed owner);
    event PermissionGranted(uint128 indexed accountId, bytes32 indexed permission, address indexed user, address sender);
    event PermissionRevoked(uint128 indexed accountId, bytes32 indexed permission, address indexed user, address sender);
    function createAccount() external returns (uint128 accountId);
    function createAccount(uint128 requestedAccountId) external;
    function getAccountLastInteraction(uint128 accountId) external view returns (uint256);
    function getAccountOwner(uint128 accountId) external view returns (address);
    function getAccountPermissions(uint128 accountId) external view returns (IAccountModule.AccountPermissions[] memory accountPerms);
    function getAccountTokenAddress() external view returns (address);
    function grantPermission(uint128 accountId, bytes32 permission, address user) external;
    function hasPermission(uint128 accountId, bytes32 permission, address user) external view returns (bool);
    function isAuthorized(uint128 accountId, bytes32 permission, address user) external view returns (bool);
    function notifyAccountTransfer(address to, uint128 accountId) external;
    function renouncePermission(uint128 accountId, bytes32 permission) external;
    function revokePermission(uint128 accountId, bytes32 permission, address user) external;
    error AccountNotFound(uint128 accountId);
    error EmptyDistribution();
    error EmptyRevertReason();
    error Errors(bytes[] errors);
    error InsufficientCollateralRatio(uint256 collateralValue, uint256 debt, uint256 ratio, uint256 minRatio);
    error MarketNotFound(uint128 marketId);
    error NotFundedByPool(uint256 marketId, uint256 poolId);
    error OverflowInt256ToInt128();
    error OverflowInt256ToUint256();
    error OverflowUint128ToInt128();
    error OverflowUint256ToInt256();
    error OverflowUint256ToUint128();
    event DebtAssociated(uint128 indexed marketId, uint128 indexed poolId, address indexed collateralType, uint128 accountId, uint256 amount, int256 updatedDebt);
    function associateDebt(uint128 marketId, uint128 poolId, address collateralType, uint128 accountId, uint256 amount) external returns (int256);
    error MismatchAssociatedSystemKind(bytes32 expected, bytes32 actual);
    error MissingAssociatedSystem(bytes32 id);
    event AssociatedSystemSet(bytes32 indexed kind, bytes32 indexed id, address proxy, address impl);
    function getAssociatedSystem(bytes32 id) external view returns (address addr, bytes32 kind);
    function initOrUpgradeNft(bytes32 id, string memory name, string memory symbol, string memory uri, address impl) external;
    function initOrUpgradeToken(bytes32 id, string memory name, string memory symbol, uint8 decimals, address impl) external;
    function registerUnmanagedSystem(bytes32 id, address endpoint) external;
    error InvalidMessage();
    error NotCcipRouter(address);
    error UnsupportedNetwork(uint64);
    function ccipReceive(CcipClient.Any2EVMMessage memory message) external;
    error AccountActivityTimeoutPending(uint128 accountId, uint256 currentTime, uint256 requiredTime);
    error CollateralDepositDisabled(address collateralType);
    error CollateralNotFound();
    error FailedTransfer(address from, address to, uint256 value);
    error InsufficientAccountCollateral(uint256 amount);
    error InsufficientAllowance(uint256 required, uint256 existing);
    error InsufficientAvailableCollateral(uint256 amountAvailableForDelegationD18, uint256 amountD18);
    error InvalidParameter(string parameter, string reason);
    error OverflowUint256ToUint64();
    error PrecisionLost(uint256 tokenAmount, uint8 decimals);
    event CollateralLockCreated(uint128 indexed accountId, address indexed collateralType, uint256 tokenAmount, uint64 expireTimestamp);
    event CollateralLockExpired(uint256 tokenAmount, uint64 expireTimestamp);
    event Deposited(uint128 indexed accountId, address indexed collateralType, uint256 tokenAmount, address indexed sender);
    event Withdrawn(uint128 indexed accountId, address indexed collateralType, uint256 tokenAmount, address indexed sender);
    function cleanExpiredLocks(uint128 accountId, address collateralType, uint256 offset, uint256 count) external returns (uint256 cleared, uint256 remainingLockAmountD18);
    function createLock(uint128 accountId, address collateralType, uint256 amount, uint64 expireTimestamp) external;
    function deposit(uint128 accountId, address collateralType, uint256 tokenAmount) external;
    function getAccountAvailableCollateral(uint128 accountId, address collateralType) external view returns (uint256);
    function getAccountCollateral(uint128 accountId, address collateralType) external view returns (uint256 totalDeposited, uint256 totalAssigned, uint256 totalLocked);
    function getLocks(uint128 accountId, address collateralType, uint256 offset, uint256 count) external view returns (CollateralLock.Data[] memory locks);
    function withdraw(uint128 accountId, address collateralType, uint256 tokenAmount) external;
    event CollateralConfigured(address indexed collateralType, CollateralConfiguration.Data config);
    function configureCollateral(CollateralConfiguration.Data memory config) external;
    function getCollateralConfiguration(address collateralType) external pure returns (CollateralConfiguration.Data memory);
    function getCollateralConfigurations(bool hideDisabled) external view returns (CollateralConfiguration.Data[] memory);
    function getCollateralPrice(address collateralType) external view returns (uint256);
    error InsufficientCcipFee(uint256 requiredAmount, uint256 availableAmount);
    event TransferCrossChainInitiated(uint64 indexed destChainId, uint256 indexed amount, address sender);
    function transferCrossChain(uint64 destChainId, uint256 amount) external payable returns (uint256 gasTokenUsed);
    error InsufficientDebt(int256 currentDebt);
    error PoolNotFound(uint128 poolId);
    event UsdBurned(uint128 indexed accountId, uint128 indexed poolId, address collateralType, uint256 amount, address indexed sender);
    event UsdMinted(uint128 indexed accountId, uint128 indexed poolId, address collateralType, uint256 amount, address indexed sender);
    function burnUsd(uint128 accountId, uint128 poolId, address collateralType, uint256 amount) external;
    function mintUsd(uint128 accountId, uint128 poolId, address collateralType, uint256 amount) external;
    error CannotScaleEmptyMapping();
    error IneligibleForLiquidation(uint256 collateralValue, int256 debt, uint256 currentCRatio, uint256 cratio);
    error InsufficientMappedAmount();
    error MustBeVaultLiquidated();
    error OverflowInt128ToUint128();
    error OverflowUint256ToUint32();
    error OverflowUint32ToInt32();
    error OverflowUint64ToInt64();
    event Liquidation(uint128 indexed accountId, uint128 indexed poolId, address indexed collateralType, ILiquidationModule.LiquidationData liquidationData, uint128 liquidateAsAccountId, address sender);
    event VaultLiquidation(uint128 indexed poolId, address indexed collateralType, ILiquidationModule.LiquidationData liquidationData, uint128 liquidateAsAccountId, address sender);
    function isPositionLiquidatable(uint128 accountId, uint128 poolId, address collateralType) external returns (bool);
    function isVaultLiquidatable(uint128 poolId, address collateralType) external returns (bool);
    function liquidate(uint128 accountId, uint128 poolId, address collateralType, uint128 liquidateAsAccountId) external returns (ILiquidationModule.LiquidationData memory liquidationData);
    function liquidateToTreasury(uint128 accountId, uint128 poolId, address collateralType) external returns (ILiquidationModule.LiquidationData memory liquidationData);
    function liquidateVault(uint128 poolId, address collateralType, uint128 liquidateAsAccountId, uint256 maxUsd) external returns (ILiquidationModule.LiquidationData memory liquidationData);
    error InsufficientMarketCollateralDepositable(uint128 marketId, address collateralType, uint256 tokenAmountToDeposit);
    error InsufficientMarketCollateralWithdrawable(uint128 marketId, address collateralType, uint256 tokenAmountToWithdraw);
    event MarketCollateralDeposited(uint128 indexed marketId, address indexed collateralType, uint256 tokenAmount, address indexed sender, int128 creditCapacity, int128 netIssuance, uint256 depositedCollateralValue, uint256 reportedDebt);
    event MarketCollateralWithdrawn(uint128 indexed marketId, address indexed collateralType, uint256 tokenAmount, address indexed sender, int128 creditCapacity, int128 netIssuance, uint256 depositedCollateralValue, uint256 reportedDebt);
    event MaximumMarketCollateralConfigured(uint128 indexed marketId, address indexed collateralType, uint256 systemAmount, address indexed owner);
    function configureMaximumMarketCollateral(uint128 marketId, address collateralType, uint256 amount) external;
    function depositMarketCollateral(uint128 marketId, address collateralType, uint256 tokenAmount) external;
    function getMarketCollateralAmount(uint128 marketId, address collateralType) external view returns (uint256 collateralAmountD18);
    function getMarketCollateralValue(uint128 marketId) external view returns (uint256);
    function getMaximumMarketCollateral(uint128 marketId, address collateralType) external view returns (uint256);
    function withdrawMarketCollateral(uint128 marketId, address collateralType, uint256 tokenAmount) external;
    error IncorrectMarketInterface(address market);
    error NotEnoughLiquidity(uint128 marketId, uint256 amount);
    event MarketRegistered(address indexed market, uint128 indexed marketId, address indexed sender);
    event MarketUsdDeposited(uint128 indexed marketId, address indexed target, uint256 amount, address indexed market, int128 creditCapacity, int128 netIssuance, uint256 depositedCollateralValue);
    event MarketUsdWithdrawn(uint128 indexed marketId, address indexed target, uint256 amount, address indexed market, int128 creditCapacity, int128 netIssuance, uint256 depositedCollateralValue);
    event SetMarketMinLiquidityRatio(uint128 indexed marketId, uint256 minLiquidityRatio);
    event SetMinDelegateTime(uint128 indexed marketId, uint32 minDelegateTime);
    function depositMarketUsd(uint128 marketId, address target, uint256 amount) external returns (uint256 feeAmount);
    function distributeDebtToPools(uint128 marketId, uint256 maxIter) external returns (bool);
    function getMarketAddress(uint128 marketId) external view returns (address);
    function getMarketCapacityContributionFromPool(uint128 marketId, uint128 poolId) external view returns (uint256);
    function getMarketCollateral(uint128 marketId) external view returns (uint256);
    function getMarketDebtPerShare(uint128 marketId) external returns (int256);
    function getMarketFees(uint128, uint256 amount) external view returns (uint256 depositFeeAmount, uint256 withdrawFeeAmount);
    function getMarketMinDelegateTime(uint128 marketId) external view returns (uint32);
    function getMarketNetIssuance(uint128 marketId) external view returns (int128);
    function getMarketPoolDebtDistribution(uint128 marketId, uint128 poolId) external returns (uint256 sharesD18, uint128 totalSharesD18, int128 valuePerShareD27);
    function getMarketPoolMaxDebtPerShare(uint128 marketId, uint128 poolId) external view returns (int256);
    function getMarketPools(uint128 marketId) external returns (uint128[] memory inRangePoolIds, uint128[] memory outRangePoolIds);
    function getMarketReportedDebt(uint128 marketId) external view returns (uint256);
    function getMarketTotalDebt(uint128 marketId) external view returns (int256);
    function getMinLiquidityRatio(uint128 marketId) external view returns (uint256);
    function getOracleManager() external view returns (address);
    function getUsdToken() external view returns (address);
    function getWithdrawableMarketUsd(uint128 marketId) external view returns (uint256);
    function isMarketCapacityLocked(uint128 marketId) external view returns (bool);
    function registerMarket(address market) external returns (uint128 marketId);
    function setMarketMinDelegateTime(uint128 marketId, uint32 minDelegateTime) external;
    function setMinLiquidityRatio(uint128 marketId, uint256 minLiquidityRatio) external;
    function withdrawMarketUsd(uint128 marketId, address target, uint256 amount) external returns (uint256 feeAmount);
    event PoolApprovedAdded(uint256 poolId);
    event PoolApprovedRemoved(uint256 poolId);
    event PreferredPoolSet(uint256 poolId);
    function addApprovedPool(uint128 poolId) external;
    function getApprovedPools() external view returns (uint256[] memory);
    function getPreferredPool() external view returns (uint128);
    function removeApprovedPool(uint128 poolId) external;
    function setPreferredPool(uint128 poolId) external;
    error CapacityLocked(uint256 marketId);
    error MinDelegationTimeoutPending(uint128 poolId, uint32 timeRemaining);
    error PoolAlreadyExists(uint128 poolId);
    event PoolCollateralConfigurationUpdated(uint128 indexed poolId, address collateralType, PoolCollateralConfiguration.Data config);
    event PoolCollateralDisabledByDefaultSet(uint128 poolId, bool disabled);
    event PoolConfigurationSet(uint128 indexed poolId, MarketConfiguration.Data[] markets, address indexed sender);
    event PoolCreated(uint128 indexed poolId, address indexed owner, address indexed sender);
    event PoolNameUpdated(uint128 indexed poolId, string name, address indexed sender);
    event PoolNominationRenounced(uint128 indexed poolId, address indexed owner);
    event PoolNominationRevoked(uint128 indexed poolId, address indexed owner);
    event PoolOwnerNominated(uint128 indexed poolId, address indexed nominatedOwner, address indexed owner);
    event PoolOwnershipAccepted(uint128 indexed poolId, address indexed owner);
    event PoolOwnershipRenounced(uint128 indexed poolId, address indexed owner);
    event SetMinLiquidityRatio(uint256 minLiquidityRatio);
    function acceptPoolOwnership(uint128 poolId) external;
    function createPool(uint128 requestedPoolId, address owner) external;
    function getMinLiquidityRatio() external view returns (uint256);
    function getNominatedPoolOwner(uint128 poolId) external view returns (address);
    function getPoolCollateralConfiguration(uint128 poolId, address collateralType) external view returns (PoolCollateralConfiguration.Data memory config);
    function getPoolCollateralIssuanceRatio(uint128 poolId, address collateral) external view returns (uint256);
    function getPoolConfiguration(uint128 poolId) external view returns (MarketConfiguration.Data[] memory);
    function getPoolDebtPerShare(uint128 poolId) external returns (int256 debtPerShareD18);
    function getPoolName(uint128 poolId) external view returns (string memory poolName);
    function getPoolOwner(uint128 poolId) external view returns (address);
    function getPoolTotalDebt(uint128 poolId) external returns (int256 totalDebtD18);
    function nominatePoolOwner(address nominatedOwner, uint128 poolId) external;
    function rebalancePool(uint128 poolId, address optionalCollateralType) external;
    function renouncePoolNomination(uint128 poolId) external;
    function renouncePoolOwnership(uint128 poolId) external;
    function revokePoolNomination(uint128 poolId) external;
    function setMinLiquidityRatio(uint256 minLiquidityRatio) external;
    function setPoolCollateralConfiguration(uint128 poolId, address collateralType, PoolCollateralConfiguration.Data memory newConfig) external;
    function setPoolCollateralDisabledByDefault(uint128 poolId, bool disabled) external;
    function setPoolConfiguration(uint128 poolId, MarketConfiguration.Data[] memory newMarketConfigurations) external;
    function setPoolName(uint128 poolId, string memory name) external;
    error RewardUnavailable(address distributor);
    event RewardsClaimed(uint128 indexed accountId, uint128 indexed poolId, address indexed collateralType, address distributor, uint256 amount);
    event RewardsDistributed(uint128 indexed poolId, address indexed collateralType, address distributor, uint256 amount, uint256 start, uint256 duration);
    event RewardsDistributorRegistered(uint128 indexed poolId, address indexed collateralType, address indexed distributor);
    event RewardsDistributorRemoved(uint128 indexed poolId, address indexed collateralType, address indexed distributor);
    function claimPoolRewards(uint128 accountId, uint128 poolId, address collateralType, address distributor) external returns (uint256);
    function claimRewards(uint128 accountId, uint128 poolId, address collateralType, address distributor) external returns (uint256);
    function distributeRewards(uint128 poolId, address collateralType, uint256 amount, uint64 start, uint32 duration) external returns (int256);
    function distributeRewardsByOwner(uint128 poolId, address collateralType, address rewardsDistributor, uint256 amount, uint64 start, uint32 duration) external returns (int256);
    function getAvailablePoolRewards(uint128 accountId, uint128 poolId, address collateralType, address distributor) external returns (uint256);
    function getAvailableRewards(uint128 accountId, uint128 poolId, address collateralType, address distributor) external returns (uint256);
    function getRewardRate(uint128 poolId, address collateralType, address distributor) external view returns (uint256);
    function registerRewardsDistributor(uint128 poolId, address collateralType, address distributor) external;
    function removeRewardsDistributor(uint128 poolId, address collateralType, address distributor) external;
    function updateRewards(uint128 poolId, address collateralType, uint128 accountId) external returns (uint256[] memory, address[] memory, uint256);
    event ConfigSet(bytes32 indexed k, bytes32 v);
    event NewSupportedCrossChainNetwork(uint64 newChainId);
    function configureChainlinkCrossChain(address ccipRouter, address ccipTokenPool) external;
    function configureOracleManager(address oracleManagerAddress) external;
    function getConfig(bytes32 k) external view returns (bytes32 v);
    function getConfigAddress(bytes32 k) external view returns (address v);
    function getConfigUint(bytes32 k) external view returns (uint256 v);
    function getTrustedForwarder() external pure returns (address);
    function isTrustedForwarder(address forwarder) external pure returns (bool);
    function setConfig(bytes32 k, bytes32 v) external;
    function setSupportedCrossChainNetworks(uint64[] memory supportedNetworks, uint64[] memory ccipSelectors) external returns (uint256 numRegistered);
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
    error InsufficientDelegation(uint256 minDelegation);
    error InsufficientVaultCollateralRatio(uint128 poolId, address collateralType);
    error InvalidCollateralAmount();
    error InvalidLeverage(uint256 leverage);
    error PoolCollateralLimitExceeded(uint128 poolId, address collateralType, uint256 currentCollateral, uint256 maxCollateral);
    event DelegationUpdated(uint128 indexed accountId, uint128 indexed poolId, address collateralType, uint256 amount, uint256 leverage, address indexed sender);
    function delegateCollateral(uint128 accountId, uint128 poolId, address collateralType, uint256 newCollateralAmountD18, uint256 leverage) external;
    function getLastDelegationTime(uint128 accountId, uint128 poolId, address collateralType) external view returns (uint256 lastDelegationTime);
    function getPosition(uint128 accountId, uint128 poolId, address collateralType) external returns (uint256 collateralAmount, uint256 collateralValue, int256 debt, uint256 collateralizationRatio);
    function getPositionCollateral(uint128 accountId, uint128 poolId, address collateralType) external view returns (uint256 amount);
    function getPositionCollateralRatio(uint128 accountId, uint128 poolId, address collateralType) external returns (uint256);
    function getPositionDebt(uint128 accountId, uint128 poolId, address collateralType) external returns (int256 debt);
    function getVaultCollateral(uint128 poolId, address collateralType) external view returns (uint256 amount, uint256 value);
    function getVaultCollateralRatio(uint128 poolId, address collateralType) external returns (uint256);
    function getVaultDebt(uint128 poolId, address collateralType) external returns (int256);
    function migrateDelegation(uint128 accountId, uint128 oldPoolId, address collateralType, uint128 newPoolId) external;
}

interface IAccountModule {
    struct AccountPermissions {
        address user;
        bytes32[] permissions;
    }
}

interface CcipClient {
    struct EVMTokenAmount {
        address token;
        uint256 amount;
    }

    struct Any2EVMMessage {
        bytes32 messageId;
        uint64 sourceChainSelector;
        bytes sender;
        bytes data;
        EVMTokenAmount[] tokenAmounts;
    }
}

interface CollateralLock {
    struct Data {
        uint128 amountD18;
        uint64 lockExpirationTime;
    }
}

interface CollateralConfiguration {
    struct Data {
        bool depositingEnabled;
        uint256 issuanceRatioD18;
        uint256 liquidationRatioD18;
        uint256 liquidationRewardD18;
        bytes32 oracleNodeId;
        address tokenAddress;
        uint256 minDelegationD18;
    }
}

interface ILiquidationModule {
    struct LiquidationData {
        uint256 debtLiquidated;
        uint256 collateralLiquidated;
        uint256 amountRewarded;
    }
}

interface PoolCollateralConfiguration {
    struct Data {
        uint256 collateralLimitD18;
        uint256 issuanceRatioD18;
    }
}

interface MarketConfiguration {
    struct Data {
        uint128 marketId;
        uint128 weightD18;
        int128 maxDebtShareValueD18;
    }
}

struct S_0 {
    address facetAddress;
    bytes4[] functionSelectors;
}

../../node_modules/@synthetixio/v3-contracts/1-main/ILegacyMarketProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface ILegacyMarketProxy {
    error ImplementationIsSterile(address implementation);
    error InsufficientCollateralMigrated(uint256 amountRequested, uint256 amountAvailable);
    error InvalidParameter(string parameter, string reason);
    error MarketAlreadyRegistered(uint256 existingMarketId);
    error MigrationInProgress();
    error NoChange();
    error NotAContract(address contr);
    error NotNominated(address addr);
    error NothingToMigrate();
    error OverflowUint256ToUint128();
    error Paused();
    error Unauthorized(address addr);
    error UpgradeSimulationFailed();
    error V2xPaused();
    error ZeroAddress();
    event AccountLiquidatedInMigration(address staker, uint256 collateralAmount, uint256 debtAmount, uint256 cratio);
    event AccountMigrated(address indexed staker, uint256 indexed accountId, uint256 collateralAmount, uint256 debtAmount);
    event ConvertedUSD(address indexed account, uint256 amount);
    event DebtForgiven(address indexed staker, uint256 indexed accountId, uint256 debtForgiven);
    event MarketRegistered(address indexed marketAddress, uint128 indexed marketId, address indexed sender);
    event OwnerChanged(address oldOwner, address newOwner);
    event OwnerNominated(address newOwner);
    event PauseMigrationSet(address indexed sender, bool paused);
    event PauseStablecoinConversionSet(address indexed sender, bool paused);
    event ReturnedUSD(address indexed account, uint256 amount);
    event Upgraded(address indexed self, address implementation);
    function MIN_DELEGATION_TIME() external view returns (uint32);
    function acceptOwnership() external;
    function convertUSD(uint256 amount) external;
    function getImplementation() external view returns (address);
    function marketId() external view returns (uint128);
    function migrate(uint128 accountId) external;
    function migrateOnBehalf(address staker, uint128 accountId) external;
    function minimumCredit(uint128) external pure returns (uint256 lockedAmount);
    function name(uint128) external pure returns (string memory);
    function nominateNewOwner(address newNominatedOwner) external;
    function nominatedOwner() external view returns (address);
    function onERC721Received(address operator, address, uint256, bytes memory) external view returns (bytes4);
    function owner() external view returns (address);
    function pauseMigration() external view returns (bool);
    function pauseStablecoinConversion() external view returns (bool);
    function registerMarket() external returns (uint128 newMarketId);
    function renounceNomination() external;
    function reportedDebt(uint128 requestedMarketId) external view returns (uint256 debt);
    function returnUSD(uint256 amount) external;
    function rewardsDistributor() external view returns (address);
    function setPauseMigration(bool paused) external;
    function setPauseStablecoinConversion(bool paused) external;
    function setSystemAddresses(address v2xResolverAddress, address v3SystemAddress, address snxDistributor) external returns (bool didInitialize);
    function simulateUpgradeTo(address newImplementation) external;
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
    function transferDeferredAccount(uint256 accountId, address to) external;
    function upgradeTo(address to) external;
    function v2xResolver() external view returns (address);
    function v3System() external view returns (address);
}

../../node_modules/@synthetixio/v3-contracts/1-main/ITreasuryMarketProxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface ITreasuryMarketProxy {
    error ImplementationIsSterile(address implementation);
    error InsufficientAvailableReward(address rewardToken, uint256 rewardedAmount, uint256 availableToReward);
    error InsufficientCRatio(uint128 accountId, uint256 currentDebt, uint256 targetDebt);
    error InsufficientExcessDebt(int256 neededToRepay, int256 ableToRepay);
    error InvalidParameter(string parameter, string reason);
    error MarketAlreadyRegistered(uint128 marketId);
    error NoChange();
    error NotAContract(address contr);
    error NotNominated(address addr);
    error OutstandingLoan(uint128 accountId, uint256 outstandingLoanAmount);
    error OverflowInt256ToUint256();
    error OverflowUint256ToInt256();
    error OverflowUint256ToUint128();
    error Unauthorized(address addr);
    error UpgradeSimulationFailed();
    error ZeroAddress();
    event AccountSaddled(uint128 indexed accountId, uint256 collateralAmount, uint256 debtAssigned);
    event AccountUnsaddled(uint128 indexed accountId, uint256 collateralAmount, uint256 debtUnassigned);
    event DebtDecayUpdated(uint32 power, uint32 duration, uint128 startPenalty, uint128 endPenalty);
    event DepositRewardIssued(uint128 indexed accountId, address indexed rewardToken, ITreasuryMarket.LoanInfo depositedRewardData);
    event DepositRewardRedeemed(uint128 indexed accountId, address indexed rewardToken, uint256 rewardRedeemed, uint256 penaltyPaid);
    event LoanAdjusted(uint128 indexed accountId, uint256 newLoanedAmount, uint256 previousLoanedAmount);
    event MarketRegistered(address indexed market, uint128 indexed marketId, address indexed sender);
    event OwnerChanged(address oldOwner, address newOwner);
    event OwnerNominated(address newOwner);
    event Rebalanced(int256 previousVaultDebt, int256 newVaultDebt);
    event TargetCRatioSet(uint256 newCRatio);
    event TreasuryBurned(uint256 amount);
    event TreasuryMinted(uint256 amount);
    event Upgraded(address indexed self, address implementation);
    function acceptOwnership() external;
    function adjustLoan(uint128 accountId, uint256 amount) external;
    function artificialDebt() external view returns (int256);
    function availableDepositRewards(address) external view returns (uint256);
    function burnTreasury(uint256 amount) external;
    function collateralToken() external view returns (address);
    function debtDecayPenaltyEnd() external view returns (uint128);
    function debtDecayPenaltyStart() external view returns (uint128);
    function debtDecayPower() external view returns (uint32);
    function debtDecayTime() external view returns (uint32);
    function depositRewardAvailable(uint128 accountId, address rewardTokenAddress) external view returns (uint256);
    function depositRewardConfigurations(uint256) external view returns (address token, uint32 power, uint32 duration, uint128 percent, bytes32 valueRatioOracle, uint128 penaltyStart, uint128 penaltyEnd);
    function depositRewardPenalty(uint128 accountId, address depositRewardToken) external view returns (uint256);
    function depositRewards(uint128, address) external view returns (uint64 startTime, uint32 power, uint32 duration, uint128 loanAmount);
    function fundForDepositReward(address token, uint256 amount) external returns (uint256);
    function getImplementation() external view returns (address);
    function loanedAmount(uint128 accountId) external view returns (uint256);
    function loans(uint128) external view returns (uint64 startTime, uint32 power, uint32 duration, uint128 loanAmount);
    function marketId() external view returns (uint128);
    function minimumCredit(uint128) external view returns (uint256 lockedAmount);
    function mintTreasury(uint256 amount) external;
    function name(uint128) external pure returns (string memory);
    function nominateNewOwner(address newNominatedOwner) external;
    function nominatedOwner() external view returns (address);
    function onERC721Received(address, address, uint256, bytes memory) external pure returns (bytes4);
    function oracleManager() external view returns (address);
    function owner() external view returns (address);
    function poolId() external view returns (uint128);
    function rebalance() external;
    function registerMarket() external returns (uint128 newMarketId);
    function removeFromDepositReward(address token, uint256 amount) external returns (uint256);
    function renounceNomination() external;
    function repaymentPenalty(uint128 accountId, uint256 targetLoan) external view returns (uint256);
    function reportedDebt(uint128 requestedMarketId) external view returns (uint256 debt);
    function saddle(uint128 accountId) external;
    function saddledCollateral(uint128) external view returns (uint256);
    function setDebtDecayFunction(uint32 power, uint32 time, uint128 startPenalty, uint128 endPenalty) external;
    function setDepositRewardConfigurations(ITreasuryMarket.DepositRewardConfiguration[] memory newDrcs) external;
    function setTargetCRatio(uint256 ratio) external;
    function simulateUpgradeTo(address newImplementation) external;
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
    function targetCratio() external view returns (uint256);
    function totalSaddledCollateral() external view returns (uint256);
    function treasury() external view returns (address);
    function unsaddle(uint128 accountId) external;
    function upgradeTo(address to) external;
    function v3System() external view returns (address);
}

interface ITreasuryMarket {
    struct LoanInfo {
        uint64 startTime;
        uint32 power;
        uint32 duration;
        uint128 loanAmount;
    }

    struct DepositRewardConfiguration {
        address token;
        uint32 power;
        uint32 duration;
        uint128 percent;
        bytes32 valueRatioOracle;
        uint128 penaltyStart;
        uint128 penaltyEnd;
    }
}

../../node_modules/@synthetixio/v3-contracts/1-main/IV2x.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface IV2x {
    event AccountLiquidated(address indexed account, uint256 snxRedeemed, uint256 amountLiquidated, address liquidator);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event AtomicSynthExchange(address indexed account, bytes32 fromCurrencyKey, uint256 fromAmount, bytes32 toCurrencyKey, uint256 toAmount, address toAddress);
    event CacheUpdated(bytes32 name, address destination);
    event ExchangeRebate(address indexed account, bytes32 currencyKey, uint256 amount);
    event ExchangeReclaim(address indexed account, bytes32 currencyKey, uint256 amount);
    event ExchangeTracking(bytes32 indexed trackingCode, bytes32 toCurrencyKey, uint256 toAmount, uint256 fee);
    event OwnerChanged(address oldOwner, address newOwner);
    event OwnerNominated(address newOwner);
    event ProxyUpdated(address proxyAddress);
    event SynthExchange(address indexed account, bytes32 fromCurrencyKey, uint256 fromAmount, bytes32 toCurrencyKey, uint256 toAmount, address toAddress);
    event TokenStateUpdated(address newTokenState);
    event Transfer(address indexed from, address indexed to, uint256 value);
    function CONTRACT_NAME() external view returns (bytes32);
    function DECIMALS() external view returns (uint8);
    function TOKEN_NAME() external view returns (string memory);
    function TOKEN_SYMBOL() external view returns (string memory);
    function acceptOwnership() external;
    function allowance(address owner, address spender) external view returns (uint256);
    function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid);
    function approve(address spender, uint256 value) external returns (bool);
    function availableCurrencyKeys() external view returns (bytes32[] memory);
    function availableSynthCount() external view returns (uint256);
    function availableSynths(uint256 index) external view returns (address);
    function balanceOf(address account) external view returns (uint256);
    function burnSecondary(address, uint256) external;
    function burnSynths(uint256 amount) external;
    function burnSynthsOnBehalf(address burnForAddress, uint256 amount) external;
    function burnSynthsToTarget() external;
    function burnSynthsToTargetOnBehalf(address burnForAddress) external;
    function collateral(address account) external view returns (uint256);
    function collateralisationRatio(address _issuer) external view returns (uint256);
    function debtBalanceOf(address account, bytes32 currencyKey) external view returns (uint256);
    function decimals() external view returns (uint8);
    function emitAtomicSynthExchange(address account, bytes32 fromCurrencyKey, uint256 fromAmount, bytes32 toCurrencyKey, uint256 toAmount, address toAddress) external;
    function emitExchangeRebate(address account, bytes32 currencyKey, uint256 amount) external;
    function emitExchangeReclaim(address account, bytes32 currencyKey, uint256 amount) external;
    function emitExchangeTracking(bytes32 trackingCode, bytes32 toCurrencyKey, uint256 toAmount, uint256 fee) external;
    function emitSynthExchange(address account, bytes32 fromCurrencyKey, uint256 fromAmount, bytes32 toCurrencyKey, uint256 toAmount, address toAddress) external;
    function exchange(bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey) external returns (uint256 amountReceived);
    function exchangeAtomically(bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey, bytes32 trackingCode, uint256 minAmount) external returns (uint256 amountReceived);
    function exchangeOnBehalf(address exchangeForAddress, bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey) external returns (uint256 amountReceived);
    function exchangeOnBehalfWithTracking(address exchangeForAddress, bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey, address rewardAddress, bytes32 trackingCode) external returns (uint256 amountReceived);
    function exchangeWithTracking(bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey, address rewardAddress, bytes32 trackingCode) external returns (uint256 amountReceived);
    function exchangeWithTrackingForInitiator(bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey, address rewardAddress, bytes32 trackingCode) external returns (uint256 amountReceived);
    function exchangeWithVirtual(bytes32 sourceCurrencyKey, uint256 sourceAmount, bytes32 destinationCurrencyKey, bytes32 trackingCode) external returns (uint256 amountReceived, address vSynth);
    function getFirstNonZeroEscrowIndex(address account) external view returns (uint256);
    function isResolverCached() external view returns (bool);
    function isWaitingPeriod(bytes32 currencyKey) external view returns (bool);
    function issueMaxSynths() external;
    function issueMaxSynthsOnBehalf(address issueForAddress) external;
    function issueSynths(uint256 amount) external;
    function issueSynthsOnBehalf(address issueForAddress, uint256 amount) external;
    function liquidateDelinquentAccount(address account) external returns (bool);
    function liquidateDelinquentAccountEscrowIndex(address account, uint256 escrowStartIndex) external returns (bool);
    function liquidateSelf() external returns (bool);
    function maxIssuableSynths(address account) external view returns (uint256 maxIssuable);
    function messageSender() external view returns (address);
    function migrateAccountBalances(address account) external returns (uint256 totalEscrowRevoked, uint256 totalLiquidBalance);
    function migrateEscrowBalanceToRewardEscrowV2() external;
    function migrateEscrowContractBalance() external;
    function mint() external returns (bool);
    function mintSecondary(address, uint256) external;
    function mintSecondaryRewards(uint256) external;
    function name() external view returns (string memory);
    function nominateNewOwner(address _owner) external;
    function nominatedOwner() external view returns (address);
    function owner() external view returns (address);
    function proxy() external view returns (address);
    function rebuildCache() external;
    function remainingIssuableSynths(address account) external view returns (uint256 maxIssuable, uint256 alreadyIssued, uint256 totalSystemDebt);
    function resolver() external view returns (address);
    function resolverAddressesRequired() external view returns (bytes32[] memory addresses);
    function sUSD() external view returns (bytes32);
    function setMessageSender(address sender) external;
    function setProxy(address _proxy) external;
    function setTokenState(address _tokenState) external;
    function settle(bytes32 currencyKey) external returns (uint256 reclaimed, uint256 refunded, uint256 numEntriesSettled);
    function symbol() external view returns (string memory);
    function synths(bytes32 currencyKey) external view returns (address);
    function synthsByAddress(address synthAddress) external view returns (bytes32);
    function tokenState() external view returns (address);
    function totalIssuedSynths(bytes32 currencyKey) external view returns (uint256);
    function totalIssuedSynthsExcludeOtherCollateral(bytes32 currencyKey) external view returns (uint256);
    function totalSupply() external view returns (uint256);
    function transfer(address to, uint256 value) external returns (bool);
    function transferFrom(address from, address to, uint256 value) external returns (bool);
    function transferableSynthetix(address account) external view returns (uint256 transferable);
}

../../node_modules/@synthetixio/v3-contracts/1-main/IV2xUsd.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

interface IV2xUsd {
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event Burned(address indexed account, uint256 value);
    event CacheUpdated(bytes32 name, address destination);
    event Issued(address indexed account, uint256 value);
    event OwnerChanged(address oldOwner, address newOwner);
    event OwnerNominated(address newOwner);
    event ProxyUpdated(address proxyAddress);
    event TokenStateUpdated(address newTokenState);
    event Transfer(address indexed from, address indexed to, uint256 value);
    function CONTRACT_NAME() external view returns (bytes32);
    function DECIMALS() external view returns (uint8);
    function FEE_ADDRESS() external view returns (address);
    function acceptOwnership() external;
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 value) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
    function burn(address account, uint256 amount) external;
    function currencyKey() external view returns (bytes32);
    function decimals() external view returns (uint8);
    function isResolverCached() external view returns (bool);
    function issue(address account, uint256 amount) external;
    function messageSender() external view returns (address);
    function name() external view returns (string memory);
    function nominateNewOwner(address _owner) external;
    function nominatedOwner() external view returns (address);
    function owner() external view returns (address);
    function proxy() external view returns (address);
    function rebuildCache() external;
    function resolver() external view returns (address);
    function resolverAddressesRequired() external view returns (bytes32[] memory addresses);
    function setMessageSender(address sender) external;
    function setProxy(address _proxy) external;
    function setTokenState(address _tokenState) external;
    function setTotalSupply(uint256 amount) external;
    function symbol() external view returns (string memory);
    function tokenState() external view returns (address);
    function totalSupply() external view returns (uint256);
    function transfer(address to, uint256 value) external returns (bool);
    function transferAndSettle(address to, uint256 value) external returns (bool);
    function transferFrom(address from, address to, uint256 value) external returns (bool);
    function transferFromAndSettle(address from, address to, uint256 value) external returns (bool);
    function transferableSynths(address account) external view returns (uint256);
}

src/Interfaces.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

import {
    ICoreProxy,
    PoolCollateralConfiguration,
    CollateralConfiguration
} from "@synthetixio/v3-contracts/1-main/ICoreProxy.sol";
import {IAccountProxy} from "@synthetixio/v3-contracts/1-main/IAccountProxy.sol";
import {ITreasuryMarketProxy} from "@synthetixio/v3-contracts/1-main/ITreasuryMarketProxy.sol";
import {ILegacyMarketProxy} from "@synthetixio/v3-contracts/1-main/ILegacyMarketProxy.sol";
import {IV2x} from "@synthetixio/v3-contracts/1-main/IV2x.sol";
import {IV2xUsd} from "@synthetixio/v3-contracts/1-main/IV2xUsd.sol";
import {ERC2771Context} from "@synthetixio/core-contracts/contracts/utils/ERC2771Context.sol";
import {IERC20} from "@synthetixio/core-contracts/contracts/interfaces/IERC20.sol";
import {IERC721Receiver} from "@synthetixio/core-contracts/contracts/interfaces/IERC721Receiver.sol";

interface IAddressResolver {
    function getAddress(bytes32 name) external view returns (address);
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@synthetixio/=../../node_modules/@synthetixio/",
    "forge-std/=../../node_modules/forge-std/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.