Skip to content

Commit

Permalink
sepolia panoptic and wallet actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kyscott18 committed Sep 26, 2023
1 parent eb0aa52 commit 8e8fd3e
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 21 deletions.
12 changes: 6 additions & 6 deletions packages/panoptic-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ Typescript SDK for Panoptic

- Wallet Actions

- [ ] `writePanopticMintOptions`
- [ ] `writePanopticRollOptions`
- [ ] `writePanopticBurnOptions`
- [ ] `writePanopticForceExercise`
- [ ] `writePanopticLiquidateAccount`
- [x] `writePanopticMintOptions`
- [x] `writePanopticRollOptions`
- [x] `writePanopticBurnOptions`
- [x] `writePanopticForceExercise`
- [x] `writePanopticLiquidateAccount`
- [x] `writePanopticCollateralMint`
- [x] `writePanopticCollateralDeposit`
- [x] `writePanopticCollateralRedeem`
- [x] `writePanopticCollateralWithdraw`

- Chains

- [ ] `sepoliaPanoptic`
- [x] `sepoliaPanoptic`

- ABIs

Expand Down
2 changes: 1 addition & 1 deletion packages/panoptic-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"vitest": "^0.34.5"
},
"dependencies": {
"reverse-mirage": "1.0.0-next.2",
"reverse-mirage": "1.0.0-next.3",
"tiny-invariant": "^1.3.1",
"uniswap-v3-sdk": "workspace:*"
}
Expand Down
21 changes: 21 additions & 0 deletions packages/panoptic-sdk/src/chains/sepolia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { sepoliaTokens } from "reverse-mirage";
import { sepoliaUniswapV3 } from "uniswap-v3-sdk";
import type { PanopticFactory } from "../types/PanopticFactory.js";

export const sepoliaPanoptic = {
factory: {
type: "panopticFactory",
address: "0x96A75826485c5B993114F72Eb79C718cF06DF56E",
owner: "0x5c7a7b47739e8aa5b13fba45d7c43d508d0d2fc3",
weth: sepoliaTokens.weth,
collateralTrackerReference: "0x9E34995E520E438c4520Cd55941f0869EDDD6822",
panopticPoolReference: "0xEEb093D6Cb13db88F342c868Ad97574F077fB62C",
semiFungiblePositionManager: {
type: "panopticSemiFungiblePositionManager",
address: "0x928eCD2e55E7042B5b920B352A84f156AdeDB037",
blockCreated: 4199935n,
},
uniswapFactory: sepoliaUniswapV3.factory,
blockCreated: 4199935n,
},
} as const satisfies { factory: PanopticFactory };
98 changes: 98 additions & 0 deletions packages/panoptic-sdk/src/decorator/walletActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import type { Account, Chain, Client, Transport } from "viem";
import type { PanopticCollateral } from "../types/index.js";
import {
type WritePanopticCollateralDepositParameters,
writePanopticCollateralDeposit,
} from "../walletActions/collateralTracker/writePanopticCollateralDeposit.js";
import {
type WritePanopticCollateralMintParameters,
writePanopticCollateralMint,
} from "../walletActions/collateralTracker/writePanopticCollateralMint.js";
import {
type WritePanopticCollateralRedeemParameters,
writePanopticCollateralRedeem,
} from "../walletActions/collateralTracker/writePanopticCollateralRedeem.js";
import {
type WritePanopticCollateralWithdrawParameters,
writePanopticCollateralWithdraw,
} from "../walletActions/collateralTracker/writePanopticCollateralWithdraw.js";
import {
type WritePanopticBurnOptionsParameters,
writePanopticBurnOptions,
} from "../walletActions/writeBurnOptions.js";
import {
type WritePanopticForceExerciseParameters,
writePanopticForceExercise,
} from "../walletActions/writeForceExercise.js";
import {
type WritePanopticLiquidateAccountParameters,
writePanopticLiquidateAccount,
} from "../walletActions/writeLiquidateAccount.js";
import {
type WritePanopticMintOptionsParameters,
writePanopticMintOptions,
} from "../walletActions/writeMintOptions.js";
import {
type WritePanopticRollOptionsParameters,
writePanopticRollOptions,
} from "../walletActions/writeRollOptions.js";

export const walletActionPanoptic = <
TChain extends Chain = Chain,
TAccount extends Account | undefined = Account | undefined,
>(
client: Client<Transport, TChain, TAccount>,
) => ({
writePanopticCollateralDeposit: <
TPanopticCollateral extends PanopticCollateral,
>(
args: WritePanopticCollateralDepositParameters<
TPanopticCollateral,
TChain,
TAccount
>,
) => writePanopticCollateralDeposit(client, args),
writePanopticCollateralMint: <
TPanopticCollateral extends PanopticCollateral,
>(
args: WritePanopticCollateralMintParameters<
TPanopticCollateral,
TChain,
TAccount
>,
) => writePanopticCollateralMint(client, args),
writePanopticCollateralWithdraw: <
TPanopticCollateral extends PanopticCollateral,
>(
args: WritePanopticCollateralWithdrawParameters<
TPanopticCollateral,
TChain,
TAccount
>,
) => writePanopticCollateralWithdraw(client, args),
writePanopticCollateralRedeem: <
TPanopticCollateral extends PanopticCollateral,
>(
args: WritePanopticCollateralRedeemParameters<
TPanopticCollateral,
TChain,
TAccount
>,
) => writePanopticCollateralRedeem(client, args),

writePanopticMintOptions: (
args: WritePanopticMintOptionsParameters<TChain, TAccount>,
) => writePanopticMintOptions(client, args),
writePanopticRollOptions: (
args: WritePanopticRollOptionsParameters<TChain, TAccount>,
) => writePanopticRollOptions(client, args),
writePanopticBurnOptions: (
args: WritePanopticBurnOptionsParameters<TChain, TAccount>,
) => writePanopticBurnOptions(client, args),
writePanopticForceExercise: (
args: WritePanopticForceExerciseParameters<TChain, TAccount>,
) => writePanopticForceExercise(client, args),
writePanopticLiquidateAccount: (
args: WritePanopticLiquidateAccountParameters<TChain, TAccount>,
) => writePanopticLiquidateAccount(client, args),
});
13 changes: 13 additions & 0 deletions packages/panoptic-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ export { getPanopticCollateralPositionData } from "./publicActions/getPanopticCo
export { getPanopticPoolData } from "./publicActions/getPanopticPoolData.js";
export { getPanopticPositionData } from "./publicActions/getPanopticPositionData.js";

export { writePanopticCollateralDeposit } from "./walletActions/collateralTracker/writePanopticCollateralDeposit.js";
export { writePanopticCollateralWithdraw } from "./walletActions/collateralTracker/writePanopticCollateralWithdraw.js";
export { writePanopticCollateralMint } from "./walletActions/collateralTracker/writePanopticCollateralMint.js";
export { writePanopticCollateralRedeem } from "./walletActions/collateralTracker/writePanopticCollateralRedeem.js";
export { writePanopticMintOptions } from "./walletActions/writeMintOptions.js";
export { writePanopticRollOptions } from "./walletActions/writeRollOptions.js";
export { writePanopticBurnOptions } from "./walletActions/writeBurnOptions.js";
export { writePanopticForceExercise } from "./walletActions/writeForceExercise.js";
export { writePanopticLiquidateAccount } from "./walletActions/writeLiquidateAccount.js";

export { publicActionPanoptic } from "./decorator/publicActions.js";
export { walletActionPanoptic } from "./decorator/walletActions.js";

export { sepoliaPanoptic } from "./chains/sepolia.js";

export { collateralTrackerABI } from "./abi/collateralTracker.js";
export { semiFungiblePositionManagerABI } from "./abi/semiFungiblePositionManager.js";
Expand Down
2 changes: 2 additions & 0 deletions packages/panoptic-sdk/src/types/PanopticFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export type PanopticFactory = {
owner: Address;
uniswapFactory: UniswapV3Factory;
semiFungiblePositionManager: PanopticSemiFungiblePositionManager;
collateralTrackerReference: Address;
panopticPoolReference: Address;
weth: WETH;
blockCreated: bigint;
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { UniswapV3Factory } from "uniswap-v3-sdk";
import type { Address } from "viem/accounts";

export type PanopticSemiFungiblePositionManager = {
type: "panopticSemiFungiblePositionManager";
address: Address;
uniswapFactory: UniswapV3Factory;
blockCreated: bigint;
};
10 changes: 5 additions & 5 deletions packages/panoptic-sdk/src/walletActions/writeRollOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { writeContract } from "viem/contract";
import { panopticPoolABI } from "../abi/panopticPool.js";
import type { PanopticPosition } from "../types/PanopticPosition.js";

export type PanopticRollptionsParameters = {
export type PanopticRollOptionsParameters = {
oldPosition: PanopticPosition;
newPosition: PanopticPosition;
};

export type WritePanopticRollptionsParameters<
export type WritePanopticRollOptionsParameters<
TChain extends Chain | undefined = Chain,
TAccount extends Account | undefined = Account | undefined,
TChainOverride extends Chain | undefined = Chain | undefined,
Expand All @@ -28,9 +28,9 @@ export type WritePanopticRollptionsParameters<
TChainOverride
>,
"args" | "address" | "abi" | "functionName"
> & { args: PanopticRollptionsParameters };
> & { args: PanopticRollOptionsParameters };

export const writePanopticRollptions = <
export const writePanopticRollOptions = <
TChain extends Chain | undefined,
TAccount extends Account | undefined,
TChainOverride extends Chain | undefined,
Expand All @@ -39,7 +39,7 @@ export const writePanopticRollptions = <
{
args: { oldPosition, newPosition },
...request
}: WritePanopticRollptionsParameters<TChain, TAccount, TChainOverride>,
}: WritePanopticRollOptionsParameters<TChain, TAccount, TChainOverride>,
): Promise<WriteContractReturnType> =>
writeContract(client, {
address: newPosition.pool.address,
Expand Down
2 changes: 2 additions & 0 deletions packages/panoptic-sdk/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export default defineConfig({
sourcemap: true,
dts: true,
clean: true,
minify: true,
treeshake: true,
});
2 changes: 1 addition & 1 deletion packages/uniswap-v3-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"vitest": "^0.34.5"
},
"dependencies": {
"reverse-mirage": "1.0.0-next.2",
"reverse-mirage": "1.0.0-next.3",
"tiny-invariant": "^1.3.1"
}
}
9 changes: 9 additions & 0 deletions packages/uniswap-v3-sdk/src/chains/sepolia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { UniswapV3Factory } from "../types/uniswapV3Factory.js";

export const sepoliaUniswapV3 = {
factory: {
address: "0x0227628f3F023bb0B980b67D528571c95c6DaC1c",
owner: "0x1a9C8182C09F50C8318d769245beA52c32BE35BC",
blockCreated: 3518270n,
},
} as const satisfies { factory: UniswapV3Factory };
1 change: 1 addition & 0 deletions packages/uniswap-v3-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export {
} from "./publicActions/index.js";

export { mainnetUniswapV3 } from "./chains/mainnet.js";
export { sepoliaUniswapV3 } from "./chains/sepolia.js";

export { uniswapV3FactoryABI } from "./abi/uniswapV3FactoryABI.js";
export { uniswapV3PoolABI } from "./abi/uniswapV3PoolABI.js";
Expand Down
2 changes: 2 additions & 0 deletions packages/uniswap-v3-sdk/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export default defineConfig({
sourcemap: true,
dts: true,
clean: true,
minify: true,
treeshake: true,
});
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8e8fd3e

Please sign in to comment.