Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/CliqueOfficial/attestation-hooks


https://github.com/CliqueOfficial/attestation-hooks

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# Uniswap v4 Hooks with Clique's Connector

This repository demonstrates the use of Uniswap v4 hooks in conjunction with Clique's Connector smart contract. The purpose is to showcase how projects can integrate and develop their own hooks using our connector.

## Overview

Uniswap v4 hooks are a powerful feature that allows developers to customize and extend the functionality of Uniswap v4 pools. In this repository, we use these hooks to query for EAS and Verax attestations and verify them directly within the hooks.

The hooks are implemented in the AttestationHook contract. This contract inherits from the BaseHook contract and overrides the beforeSwap function to perform the attestation checks. The type of attestation (EAS or Verax) can be toggled using the toggleAttestationType function.

The IConnector interface is used to interact with the Clique's Connector smart contract. This contract provides functions to get attestations and their values.

Please note that the given attestation hook is just an example of what can be done. Many more functionalities will be added and the IConnector already allows for a wide range of possible queries on attestations.

## Disclaimer

The Connector contract address along with mock registries for the conduit testnet will be released soon for testing hooks. Please stay tuned for updates.

## Key Code Snippets

The beforeSwap function in the AttestationHook contract queries for an attestation (EAS or Verax, depending on the current configuration) and verifies it:

```solidity
function beforeSwap(
address,
PoolKey calldata,
IPoolManager.SwapParams calldata,
bytes calldata
) external view override returns (bytes4) {
bytes memory value = _attestationType == AttestationType.EAS
? _easAttestation()
: _veraxAttestation();

if (abi.decode(value, (bool)) != true) revert AttestationNotValid();

return BaseHook.beforeSwap.selector;
}
```

The toggleAttestationType function allows to switch between EAS and Verax attestations:

```solidity
function toggleAttestationType() public onlyOwner {
_attestationType = _attestationType == AttestationType.EAS
? AttestationType.VERAX
: AttestationType.EAS;
}
```