---
# System prepended metadata

title: Enzyme protocol packages
tags: [CodeRead]

---

# Enzyme protocol packages
###### tags: `CodeRead`
## file structure
├── codegen
├── coverage
├── ethers
├── hardhat
├── protocol
└── testutils

閱讀順序
- ethers
- hardhat
- protocol
- testutils
## codegen
## coverage
## ethers
### contracts
#### Doppelgang.sol
functions:
- constructor -> fulfill mockSignatures
- fallback
- __doppelganger__mockForward -> 使用傳入的執行者執行傳入的動作,並且回傳結果
- __doppelganger__mockReset -> 對 mockConfig 刪除一個 MockCall
- __doppelganger__mockReverts -> 對 mockConfig 更新一個 MockCall
- __doppelganger__mockReturns -> 返回 mockCall
- __doppelganger__internal__getMockCall -> 若 mockCall 已被初始化,則返回 mockCall
- __doppelganger__internal__mockReturn -> 回傳(一個位置)和(一個位置的指針)

#### IERC1271.ts
isValidSignature
### utils/
- ensureEvent
- ensureInterface -> check is interface
- extractEvent
- isJsonRpcProvider
- randomAddress
- resolveAddress
- resolveArguments
- sameAddress
- signTypedData
- typedData
- verifySignature

### types.ts
- AddressLike
- Call
- Send
- AnyFunction
- ProxiedFunction
- FunctionDefinition
- CallDefinition
- SendDefinition
- DerivedFunction
- DerivedSendFunction
- DerivedCallFunction
- ShortcutFunction
- ShortcutFunctionOutput

### mock.ts
- stub
- mock

### index.ts
export all files

### functions.ts
- interface
    - ContractReceipt
    - ContractTransaction
    - FunctionOptions
- function
    - propertyOf
    - enhanceResponse
    - isFunctionOptions
    - resolveFunctionOptions
- class
    - ContractFunction
        - isContractFunction
        - create
        - get -> getter
        - args
        - value
        - bytecode
        - type
        - nonce
        - block
        - gas
        - from
        - refine
        - toJSON
    - CallFunction
        - call
        - attach
        - populate
    - SendFunction
        - isSendFunction
        - estimate
        - send
    - ConstructorFunction
        - call
        - populate

### doppelganger.ts
DoppelgangerCompilerOutput abi
interface Doppelganger
class Doppelganger
- deploy

### contract.ts
function
- deploy

## hardhat
### types.ts
- declare 
    - global
        - namespace
            - globalThis
            - jest
                - interface Matchers
### snapshots.ts
- interface
    - Snapshot
- class
    - Snapshots
        - snapshot
        - record
        - revert
        - toJSON

### provider.ts
- class
    - EthereumTestnetProvider

### history.ts
- interface
    - EvmMessage
- class
    - History
        - clone
        - override
        - clear
        - reset
        - calls
        - record
### plugin
#### utils.ts
- function
    - regexOrString
    - validateDir
    - clearDirectory
    - createDirectory
    - prepareDirectory

#### coverage/
- types.ts
    - interface
        - CodeCoverageConfig
        - CodeCoverageUserConfig
    - declare module 'hardhat/types/config'
        - interface
            - HardhatUserConfig
            - HardhatConfig
- index.ts
    - extendConfig -> extend hardhat config
    - coverage task

#### compile/
- types.ts
    - interface
        - CodeGeneratorConfig
        - CodeGeneratorUserConfig
    - declare module 'hardhat/types/config'
        - HardhatUserConfig
        - HardhatConfig 
### jest
#### utils.ts
- function
    - forceFail
    - forcePass
    - isTransactionReceipt

#### matchers/
- bn -> BigNumber
    - skip
- events
    - toHaveEmitted
    - toHaveEmittedWith
    - toMatchEventArgs
- evm
    - toHaveBeenCalledOnContract
    - toHaveBeenCalledOnContractWith
- functions
    - toBeReceipt
    - toBeReverted
    - toBeRevertedWith
    - toMatchFunctionOutput
    - toMatchGasSnapshot
    - toMatchInlineGasSnapshot
- misc
    - toBeProperAddress
    - toBeProperHex
    - toBeProperPrivateKey
    - toMatchAddress
    - toMatchParams
- helper.ts
    - function
        - resolveFunctionFragment
        - resolveEventFragment
        - resolveFragment
        - resolveParamMatchers
- index.ts -> export every thing
- 
#### config/
- setup.ts
- global-teardown.ts
- global-setup.ts
- environment.ts
    - interface
        - EnzymeHardhatEnvironmentOptions
    - class
        - EnzymeHardhatEnvironment
            - constructor
            - setup
            - teardown
    - function
        - getRuntimeEnvironment
        - addListener
## protocol
- codegen/ -> 生成的 ABI
- utils/
- constant.ts ->
- contracts.ts -> export things
    - interface
        - StandardToken
        - WETH
        - UniswapV2Router
- types.ts
    - ChainlinkRateAsset
    - VaultAction

### utils
- isTypedDataSigner
- sighash
- encodeArgs
- encodeFunctionData

#### external-positions/
#### fees/
- config.ts
- entrance.ts
- exit.ts
- management.ts
- performance.ts
- settlement.ts
#### integrations/
只看通用,其他對特定的項目的就跳掉
- common.ts
    - SpendAssetsHandleType
    - export const
        - claimRewardsFragment
        - lendFragment
        - lendAndStakeFragment
        - redeemFragment
        - stakeFragment
        - takeOrderFragment
        - unstakeFragment
        - unstakeAndRedeemFragment
    - function
        - assetTransferArgs
- actions.ts
    - addTrackedAssetsToVaultArgs
    - callOnIntegrationArgs
    - removeTrackedAssetsFromVaultArgs
#### policies/
- config.ts
    - policyManagerConfigArgs
- policies.ts
    - addressListRegistryPolicyArgs
    - allowedExternalPositionTypesPolicyArgs
    - cumulativeSlippageTolerancePolicyArgs
    - minAssetBalancesPostRedemptionPolicyArgs
    - minMaxInvestmentPolicyArgs
- types.ts
    - PolicyHook
- validation.ts
    - validateRuleCreateExternalPositionArgs
    - validateRulePostBuySharesArgs
    - validateRulePostCallOnExternalPositionArgs
    - validateRulePostCoIArgs
    - validateRuleRedeemSharesForSpecificAssetsArgs
    - validateRuleRemoveExternalPositionArgs
    - validateRuleReactivateExternalPositionArgs
    - validateRuleRemoveTrackedAssetsArgs
#### protocol-fees/
- protocolFeeTracker.ts
    - function
        - calcProtocolFeeSharesDue

#### vaultCall.ts
- addressListRegistryAddToListSelector
- addressListRegistryAttestListsSelector
- addressListRegistryCreateListSelector
- addressListRegistryRemoveFromListSelector
- addressListRegistrySetListOwnerSelector
- addressListRegistrySetListUpdateTypeSelector
- curveMinterMintSelector
- curveMinterMintManySelector
- curveMinterToggleApproveMintSelector
- pricelessAssetBypassStartAssetBypassTimelockSelector
- synthetixAssignExchangeDelegateSelector
## testutils

### others
#### whales.ts
- unlockWhale
- unlockAllWhales
- unlockWhales
#### helpers.ts
- calcMlnValueAndBurnAmountForSharesBuyback
- generateMerkleTreeForContractProof
- sendEthBySelfDestruct
    - A test contract to send ETH to a contract via selfdestruct()
- transactionTimestamp
    - 回傳 timestamp

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
#### gasRelayer.ts
#### deployment.ts
- getNamedSigner
    - return UnnamedAccounts
- deployProtocolFixture
- relayTransaction
- assertDidRelay
    - assertDidRelaySuccessfully
    - assertDidRelayWithError
    - assertDidRelayWithCharge
- assertPaymasterDidReject
    - assertPaymasterDidRejectForReason
#### assertions.ts
- assertEvent

#### accounts.ts
- impersonateContractSigner
- impersonateSigner


### scaffolding
#### others
- vaultCalls.ts
    - vaultCallCreateNewList
        - Makes an arbitrary call with the VaultProxy contract as the sender
    - vaultCallCurveMinterMint
    - vaultCallCurveMinterMintMany
    - vaultCallCurveMinterToggleApproveMint
    - vaultCallCurveMinterToggleApproveMint
- shares.ts
    - buyShares
    - buySharesFunction
    - redeemSharesForSpecificAssets
    - redeemSharesInKind

#### setup.ts
- createComptrollerProxy
- createMigrationRequest
- createNewFund
- createReconfigurationRequest
- createVaultProxy
- setupGasRelayerPaymaster

#### core.ts
- createFundDeployer
    - return nextFundDeployer
#### assets.ts
- addNewAssetsToFund
#### extensions
##### external-positions
##### integrations
##### others
- common.ts
    - callOnExtension
- fees.ts
    - generateFeeManagerConfigWithMockFees
    - generateMockFees
- policies.ts
    - generatePolicyManagerConfigWithMockPolicies
    - generateMockPolicies
#### peripheral
- shares-splitter.ts
    - deploySharesSplitter
        - return { receipt, sharesSplitterProxy }


## Note 
```
  return comptrollerProxy.connect(buyer).buyShares.args(investmentAmount, minSharesQuantity).ref;
  ```