Skip to content

[WIP] Uniswap v3 lp proposal #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/local
Submodule local deleted from a4b70a
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion contracts/solidity
259 changes: 130 additions & 129 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,131 +1,132 @@
{
"name": "@pwndao-sdk/source",
"version": "0.0.0",
"license": "MIT",
"private": true,
"dependencies": {
"@docusaurus/core": "3.4.0",
"@docusaurus/preset-classic": "3.4.0",
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.14.0",
"@mdx-js/react": "^3.0.0",
"@tanstack/query-core": "^5.67.3",
"@tanstack/react-query": "^5.67.3",
"@vue/theme": "^1.3.0",
"ajv": "^8.17.1",
"clsx": "^2.0.0",
"next": "^15.3.0-canary.1",
"nock": "^14.0.1",
"prism-react-renderer": "^2.3.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"reka-ui": "^2.1.0",
"ts-invariant": "^0.10.3",
"viem": "^2.23.6",
"vue": "3.5.13",
"vue-router": "4.5.0"
},
"devDependencies": {
"@ahryman40k/nx-vitepress": "^15.1.1",
"@babel/core": "^7.14.5",
"@babel/preset-react": "^7.14.5",
"@biomejs/biome": "^1.9.4",
"@docusaurus/module-type-aliases": "3.4.0",
"@docusaurus/tsconfig": "3.4.0",
"@docusaurus/types": "3.4.0",
"@faker-js/faker": "^9.5.0",
"@gitopslovers/nx-biome": "^1.5.0",
"@nrwl/devkit": "^19.8.4",
"@nx-extend/docusaurus": "^3.1.1",
"@nx/devkit": "20.8.0-beta.0",
"@nx/eslint": "20.8.0-beta.0",
"@nx/eslint-plugin": "20.8.0-beta.0",
"@nx/js": "20.8.0-beta.0",
"@nx/next": "20.8.0-beta.0",
"@nx/playwright": "20.8.0-beta.0",
"@nx/react": "20.8.0-beta.0",
"@nx/vite": "20.8.0-beta.0",
"@nx/vue": "20.8.0-beta.0",
"@nx/web": "20.8.0-beta.0",
"@playwright/test": "^1.36.0",
"@swc-node/register": "~1.9.1",
"@swc/cli": "0.6.0",
"@swc/core": "~1.5.7",
"@swc/helpers": "~0.5.11",
"@testing-library/react": "16.1.0",
"@types/node": "18.16.9",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.2.0",
"@vitejs/plugin-vue": "5.2.3",
"@vitest/coverage-v8": "^1.0.4",
"@vitest/ui": "^1.3.1",
"@vue/test-utils": "^2.4.1",
"@wagmi/cli": "^2.2.0",
"eslint": "9.14.0",
"eslint-config-next": "15.3.0",
"eslint-config-prettier": "10.1.2",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-jsx-a11y": "6.10.1",
"eslint-plugin-playwright": "^1.6.2",
"eslint-plugin-react": "7.35.0",
"eslint-plugin-react-hooks": "5.0.0",
"eslint-plugin-vitest": "^0.5.4",
"husky": "^9.1.7",
"jiti": "2.4.2",
"jsdoc-to-markdown": "^9.1.1",
"jsdom": "~22.1.0",
"less": "3.12.2",
"nx": "20.8.0-beta.0",
"pino-pretty": "^13.0.0",
"prettier": "^2.6.2",
"tslib": "^2.3.0",
"typescript": "<=5.6.0",
"typescript-eslint": "^8.19.0",
"verdaccio": "6.0.5",
"vite": "^6.2.3",
"vite-plugin-dts": "4.5.3",
"vite-svg-loader": "^5.1.0",
"vitepress": "^1.6.3",
"vitest": "^1.3.1",
"vue-tsc": "2.2.8"
},
"workspaces": [
"packages/*",
"apps/example-next",
"apps/example-next-e2e",
"apps/example-vue",
"apps/example-vue-e2e",
"sdk-docs"
],
"nx": {
"includedScripts": [],
"targets": {
"local-registry": {
"executor": "@nx/js:verdaccio",
"options": {
"port": 4873,
"config": ".verdaccio/config.yml",
"storage": "tmp/local-registry/storage"
}
},
"biome-lint": {
"executor": "@gitopslovers/nx-biome:biome-lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["**/*.ts"],
"write": true,
"unsafe": false
}
}
}
},
"packageManager": "yarn@3.2.3+sha224.953c8233f7a92884eee2de69a1b92d1f2ec1655e66d08071ba9a02fa",
"scripts": {
"prepare": "husky"
},
"engines": {
"node": ">=23.10.0",
"bun": ">=1.0.0"
}
"name": "@pwndao-sdk/source",
"version": "0.0.0",
"license": "MIT",
"private": true,
"dependencies": {
"@docusaurus/core": "3.4.0",
"@docusaurus/preset-classic": "3.4.0",
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.14.0",
"@mdx-js/react": "^3.0.0",
"@tanstack/query-core": "^5.67.3",
"@tanstack/react-query": "^5.67.3",
"@vue/theme": "^1.3.0",
"@wagmi/core": "2.17.2",
"ajv": "^8.17.1",
"clsx": "^2.0.0",
"next": "^15.3.0-canary.1",
"nock": "^14.0.1",
"prism-react-renderer": "^2.3.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"reka-ui": "^2.1.0",
"ts-invariant": "^0.10.3",
"viem": "^2.29.2",
"vue": "3.5.13",
"vue-router": "4.5.0"
},
"devDependencies": {
"@ahryman40k/nx-vitepress": "^15.1.1",
"@babel/core": "^7.14.5",
"@babel/preset-react": "^7.14.5",
"@biomejs/biome": "^1.9.4",
"@docusaurus/module-type-aliases": "3.4.0",
"@docusaurus/tsconfig": "3.4.0",
"@docusaurus/types": "3.4.0",
"@faker-js/faker": "^9.5.0",
"@gitopslovers/nx-biome": "^1.5.0",
"@nrwl/devkit": "^19.8.4",
"@nx-extend/docusaurus": "^3.1.1",
"@nx/devkit": "20.8.0-beta.0",
"@nx/eslint": "20.8.0-beta.0",
"@nx/eslint-plugin": "20.8.0-beta.0",
"@nx/js": "20.8.0-beta.0",
"@nx/next": "20.8.0-beta.0",
"@nx/playwright": "20.8.0-beta.0",
"@nx/react": "20.8.0-beta.0",
"@nx/vite": "20.8.0-beta.0",
"@nx/vue": "20.8.0-beta.0",
"@nx/web": "20.8.0-beta.0",
"@playwright/test": "^1.36.0",
"@swc-node/register": "~1.9.1",
"@swc/cli": "0.6.0",
"@swc/core": "~1.5.7",
"@swc/helpers": "~0.5.11",
"@testing-library/react": "16.1.0",
"@types/node": "18.16.9",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.2.0",
"@vitejs/plugin-vue": "5.2.3",
"@vitest/coverage-v8": "^1.0.4",
"@vitest/ui": "^1.3.1",
"@vue/test-utils": "^2.4.1",
"@wagmi/cli": "^2.2.0",
"eslint": "9.14.0",
"eslint-config-next": "15.3.0",
"eslint-config-prettier": "10.1.2",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-jsx-a11y": "6.10.1",
"eslint-plugin-playwright": "^1.6.2",
"eslint-plugin-react": "7.35.0",
"eslint-plugin-react-hooks": "5.0.0",
"eslint-plugin-vitest": "^0.5.4",
"husky": "^9.1.7",
"jiti": "2.4.2",
"jsdoc-to-markdown": "^9.1.1",
"jsdom": "~22.1.0",
"less": "3.12.2",
"nx": "20.8.0-beta.0",
"pino-pretty": "^13.0.0",
"prettier": "^2.6.2",
"tslib": "^2.3.0",
"typescript": "<=5.6.0",
"typescript-eslint": "^8.19.0",
"verdaccio": "6.0.5",
"vite": "^6.2.3",
"vite-plugin-dts": "4.5.3",
"vite-svg-loader": "^5.1.0",
"vitepress": "^1.6.3",
"vitest": "^1.3.1",
"vue-tsc": "2.2.8"
},
"workspaces": [
"packages/*",
"apps/example-next",
"apps/example-next-e2e",
"apps/example-vue",
"apps/example-vue-e2e",
"sdk-docs"
],
"nx": {
"includedScripts": [],
"targets": {
"local-registry": {
"executor": "@nx/js:verdaccio",
"options": {
"port": 4873,
"config": ".verdaccio/config.yml",
"storage": "tmp/local-registry/storage"
}
},
"biome-lint": {
"executor": "@gitopslovers/nx-biome:biome-lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["**/*.ts"],
"write": true,
"unsafe": false
}
}
}
},
"packageManager": "yarn@3.2.3+sha224.953c8233f7a92884eee2de69a1b92d1f2ec1655e66d08071ba9a02fa",
"scripts": {
"prepare": "husky"
},
"engines": {
"node": ">=23.10.0",
"bun": ">=1.0.0"
}
}
7 changes: 6 additions & 1 deletion packages/core/src/addresses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ describe("Addresses", () => {
[SupportedChain.UnichainSepolia, "0x1381F509f56f2aaA0faBD3012455901eA53F0BbD"],
// note: no starknet version of tokenBundlerContract
])("should resolve correct bundler address for %s", (chain, expected) => {
if (
!("tokenBundlerContract" in CHAIN_TO_ADDRESSES_MAP[chain]) // dont test if there's no tokenBundlerContract (considering V1.4)
) {
return;
}
expect(
CHAIN_TO_ADDRESSES_MAP[chain as V1_3_SUPPORTED_CHAINS]
(CHAIN_TO_ADDRESSES_MAP[chain as V1_3_SUPPORTED_CHAINS] as any) // hack, because V1_4Contracts doesnt have tokenBundlerContract, resulting in type error
?.tokenBundlerContract,
).toEqual(expected);
});
Expand Down
22 changes: 21 additions & 1 deletion packages/core/src/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SupportedChain } from "./chains.js";
import type { V1_2_SUPPORTED_CHAINS, V1_3_SUPPORTED_CHAINS } from "./chains.js";
import type { V1_2_SUPPORTED_CHAINS, V1_3_SUPPORTED_CHAINS, V1_4_SUPPORTED_CHAINS } from "./chains.js";
import { ZERO_ADDRESS } from "./constants.js";
import type { AddressString } from "./types.js";

Expand All @@ -23,6 +23,11 @@ export type V1_3_Contracts = ContractAddresses & {
utilizedCredit: AddressString;
};

type V1_4_Contracts = Omit<V1_3_Contracts, "tokenBundlerContract"> & {
pwnSimpleLoanUniswapV3LpSetProposal: AddressString;
pwnSimpleLoanUniswapV3IndividualProposal: AddressString;
};

// starknet has no tokenBundlerContract by now
export type V1_2_StarknetContracts = Omit<
ContractAddresses,
Expand Down Expand Up @@ -67,6 +72,13 @@ export const PWN_V1_3_CONTRACTS: Omit<V1_3_Contracts, "tokenBundlerContract" | "
pwnRevokedNonce: "0x972204fF33348ee6889B2d0A3967dB67d7b08e4c",
};

export const PWN_V1_4_CONTRACTS: Omit<V1_4_Contracts, "tokenBundlerContract"> = {
...PWN_V1_3_CONTRACTS,
pwnSimpleLoanUniswapV3LpSetProposal: "0x4D067c921AC90cC4b1e962ea0e743Ef8d85Fb0E9",
pwnSimpleLoanElasticChainlinkProposal: "0x39fd308D651F5add5A4826D12Bf92d9D91E732AC",
pwnSimpleLoanUniswapV3IndividualProposal: "0xF966696BE0623447679AC830FC5bB7bDB15FEAB4",
};

// Mainnet contracts
const MAINNET_CONTRACTS: V1_3_Contracts = {
...PWN_V1_3_CONTRACTS,
Expand Down Expand Up @@ -205,7 +217,15 @@ export const V1_3_CHAIN_TO_ADDRESSES_MAP: Record<
[SupportedChain.UnichainSepolia]: UNICHAIN_SEPOLIA_CONTRACTS,
};

export const V1_4_CHAIN_TO_ADDRESSES_MAP: Record<
V1_4_SUPPORTED_CHAINS,
V1_4_Contracts
> = {
[SupportedChain.Sepolia]: PWN_V1_4_CONTRACTS,
};

export const CHAIN_TO_ADDRESSES_MAP = {
...V1_2_CHAIN_TO_ADDRESSES_MAP,
...V1_3_CHAIN_TO_ADDRESSES_MAP,
...V1_4_CHAIN_TO_ADDRESSES_MAP,
};
2 changes: 2 additions & 0 deletions packages/core/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ export type V1_3_SUPPORTED_CHAINS = Exclude<
SupportedChain,
V1_2_SUPPORTED_CHAINS
>;

export type V1_4_SUPPORTED_CHAINS = SupportedChain.Sepolia;
1 change: 1 addition & 0 deletions packages/core/src/models/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum MultiTokenCategory {
NATIVE = 3,
ERC721_COLLECTION = 420,
ERC1155_COLLECTION = 421,
UNISWAP_V3_LP = 666,
}

interface IBaseAsset {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "./token.js";
export * from "./user.js";
export * from "./types.js";
export * from "./nft.js";
export * from "./liquidity-position.js";
25 changes: 25 additions & 0 deletions packages/core/src/models/liquidity-position.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { AddressString } from "src/types.js";
import { BaseAsset, MultiTokenCategory } from "./asset.js";
import type { SupportedChain } from "../chains.js";

export class UniswapV3Position extends BaseAsset {
static category = MultiTokenCategory.UNISWAP_V3_LP;

tokenA: AddressString;
tokenB: AddressString;
tokenId: string;

constructor(
chainId: SupportedChain,
address: AddressString,
tokenA: AddressString,
tokenB: AddressString,
tokenId: string,
icon?: string,
) {
super(chainId, address, 0, false, UniswapV3Position.category, "Uniswap V3 Positions NFT-V1", "UNI-V3-POS", icon);
this.tokenA = tokenA;
this.tokenB = tokenB;
this.tokenId = tokenId;
}
}
3 changes: 2 additions & 1 deletion packages/core/src/models/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { FungibleNFT, NFT } from "./nft.js";
import type { ERC20Token } from "./token.js";
import { PoolToken } from "./pool-token.js";
import type { UniswapV3Position } from "./liquidity-position.js";

export type Token = ERC20Token | NFT | FungibleNFT;
export type Token = ERC20Token | NFT | FungibleNFT | UniswapV3Position;
export type ERC20TokenLike = ERC20Token | PoolToken;

export const isPoolToken = (token: Partial<Token>): token is PoolToken => {
Expand Down
Loading