Liquidator can set up referrals for other users
If a user has met the liquidation criteria and currently has no referrer then a malicious liquidator can specify a referrer in the liquidation order. making it impossible for subsequent users to set up the referrer they want.\\nCurrently, there are 2 conditions to set up a referrer\\nthe order cannot be empty （Non-empty orders require authorization unless they are liquidation orders）\\nthere can't be another referrer already\\n```\\n    function _loadUpdateContext(\\n        Context memory context,\\n        address account,\\n        address referrer\\n    ) private view returns (UpdateContext memory updateContext) {\\n// rest of code\\n        updateContext.referrer = referrers[account][context.local.currentId];\\n        updateContext.referralFee = IMarketFactory(address(factory())).referralFee(referrer);\\n    }\\n\\n    function _processReferrer(\\n        UpdateContext memory updateContext,\\n        Order memory newOrder,\\n        address referrer\\n    ) private pure {\\n      if (newOrder.makerReferral.isZero() && newOrder.takerReferral.isZero()) return;\\n        if (updateContext.referrer == address(0)) updateContext.referrer = referrer;\\n        if (updateContext.referrer == referrer) return;\\n\\n        revert MarketInvalidReferrerError();\\n    }\\n\\n\\n    function _storeUpdateContext(Context memory context, UpdateContext memory updateContext, address account) private {\\n// rest of code\\n        referrers[account][context.local.currentId] = updateContext.referrer;\\n    }\\n```\\n\\nHowever, if the user does not have a referrer, the liquidation order is able to meet both of these restrictions\\nThis allows the liquidator to set up referrals for other users.\\nWhen the user subsequently tries to set up a referrer, it will fail.
Restrictions on Liquidation Orders Cannot Set a referrer\\n```\\n    function _processReferrer(\\n        UpdateContext memory updateContext,\\n        Order memory newOrder,\\n        address referrer\\n    ) private pure {\\n// Add the line below\\n       if (newOrder.protected() && referrer != address(0)) revert MarketInvalidReferrerError;\\n        if (newOrder.makerReferral.isZero() && newOrder.takerReferral.isZero()) return;\\n        if (updateContext.referrer == address(0)) updateContext.referrer = referrer;\\n        if (updateContext.referrer == referrer) return;\\n\\n        revert MarketInvalidReferrerError();\\n    }\\n```\\n
If a user is set up as a referrer by a liquidated order in advance, the user cannot be set up as anyone else.
```\\n    function _loadUpdateContext(\\n        Context memory context,\\n        address account,\\n        address referrer\\n    ) private view returns (UpdateContext memory updateContext) {\\n// rest of code\\n        updateContext.referrer = referrers[account][context.local.currentId];\\n        updateContext.referralFee = IMarketFactory(address(factory())).referralFee(referrer);\\n    }\\n\\n    function _processReferrer(\\n        UpdateContext memory updateContext,\\n        Order memory newOrder,\\n        address referrer\\n    ) private pure {\\n      if (newOrder.makerReferral.isZero() && newOrder.takerReferral.isZero()) return;\\n        if (updateContext.referrer == address(0)) updateContext.referrer = referrer;\\n        if (updateContext.referrer == referrer) return;\\n\\n        revert MarketInvalidReferrerError();\\n    }\\n\\n\\n    function _storeUpdateContext(Context memory context, UpdateContext memory updateContext, address account) private {\\n// rest of code\\n        referrers[account][context.local.currentId] = updateContext.referrer;\\n    }\\n```\\n