Draft. The Knicks deployment is not yet live, and everything on this page is subject to change before deployment.
Each Knicks market is a set of contracts that ReferenceCurveFactory_v1 creates in one transaction, plus contracts deployed before that transaction or attached after it. The routers for the pair are deployed separately and fix both markets at construction.

Contracts per market

From configuration to live market describes each creation step and the checks on it. Overview describes each contract’s job.

Roles and holders

Each market has its own AUT_Roles_v2. The roles and holders below are the same on KNX and NYK unless a row says otherwise. Roles at launch lists the functions each role can call. DEFAULT_ADMIN_ROLE creates ENDOWMENT_ADMIN_ROLE and ENDOWMENT_CONTROLLER_ROLE in one call to bootstrapEndowmentRoles. The call reverts if the roles already exist. The launch route does not call it. Some functions check a fixed address instead of a role. The approval Safe and the emergency Safe hold the freeze and reopen calls, and the protocol Safes hold the governance calls (Authorities outside the authorizer).

Routers for the pair

DeployPeripheryRouters_v1 deploys AtomicSellRouter_v1, AtomicLoopRouter_v1 and AtomicRepayRouter_v1 for one KNX and NYK pair. Each router’s constructor takes three addresses and reads three tokens from them. The router code uses Knicks-specific names for these fixed addresses: The constructor reverts unless the NYK curve’s collateral token is the KNX token, the facility belongs to the NYK curve, and the three tokens are different contracts. The fixed addresses cannot be changed after construction. maxKnxFallback is a per-call parameter of AtomicLoopRouter_v1 and AtomicRepayRouter_v1 (Edge cases). AtomicBuyRouter_v1 fixes no markets. Each call to AtomicBuyRouter_v1 names the first and second market as arguments. The deploy script checks that each curve and the facility are proxies of their expected beacons. After deployment, the script reverts unless each router’s fixed addresses match the script’s inputs and each router already holds the permissions listed for it on both markets. The script grants no permission. The launch route leaves buyFor, sellTo, buyAndBorrowFor and repayFor ungranted (Permissions the routers need).

Code

Source: house-markets/contracts at 0ebbc89a (branch integration/v12-post-qa).