punkkit-sdk 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/index.d.mts +153 -0
  2. package/dist/index.d.ts +153 -0
  3. package/dist/index.js +30941 -0
  4. package/dist/index.mjs +30902 -0
  5. package/package.json +11 -6
  6. package/.env +0 -47
  7. package/.gitmodules +0 -3
  8. package/config/auction.config.ts +0 -40
  9. package/config/env.config.ts +0 -204
  10. package/config/uniswap.config.ts +0 -107
  11. package/config/voucher.config.ts +0 -10
  12. package/contracts/MutiVoucher.sol +0 -78
  13. package/contracts/auction/ChainXAuction.sol +0 -177
  14. package/contracts/auction/ChainXAuctionV2.sol +0 -672
  15. package/contracts/auction/ChainXWrappedETH.sol +0 -80
  16. package/contracts/auction/ChainYLiquidityManager.sol +0 -57
  17. package/contracts/auction/ChainYShadowETH.sol +0 -148
  18. package/contracts/auction/ChainYVault.sol +0 -195
  19. package/contracts/auction/ChainYVaultCoinbase.sol +0 -276
  20. package/contracts/auction/ChainYVaultV2.sol +0 -318
  21. package/contracts/auction/coinbase-and-stake/README.md +0 -55
  22. package/contracts/auction/coinbase-and-stake/coinbase.sol +0 -142
  23. package/contracts/auction/coinbase-and-stake/invokeCoinbase.sol +0 -159
  24. package/contracts/auction/coinbase-and-stake/invokeStake.sol +0 -82
  25. package/contracts/auction/coinbase-and-stake/stake.sol +0 -92
  26. package/contracts/auction/interfaces/IUniswapV2Factory.sol +0 -15
  27. package/contracts/auction/interfaces/IUniswapV2Pair.sol +0 -53
  28. package/contracts/auction/interfaces/IUniswapV2Router02.sol +0 -25
  29. package/contracts/auction/interfaces/IUnlockStrategy.sol +0 -18
  30. package/contracts/auction/libraries/EventParser.sol +0 -32
  31. package/contracts/auction/libraries/TransactionParser.sol +0 -70
  32. package/contracts/auction/strategies/MatchResultWithdrawnStrategy.sol +0 -33
  33. package/contracts/auction/utils/BytesLib.sol +0 -180
  34. package/contracts/auction/utils/RLPReader.sol +0 -355
  35. package/contracts/uniswap/Create2.sol +0 -80
  36. package/contracts/uniswap/DynamicFee.sol +0 -100
  37. package/contracts/uniswap/Example.sol +0 -35
  38. package/contracts/uniswap/HookMiner.sol +0 -52
  39. package/contracts/uniswap/LimitOrder.sol +0 -486
  40. package/contracts/uniswap/LiquidPool.sol +0 -179
  41. package/contracts/uniswap/MockERC20.sol +0 -20
  42. package/hardhat.config.ts +0 -35
  43. package/ignition/modules/LimitOrder.ts +0 -33
  44. package/scripts/auction/deploy.ts +0 -23
  45. package/scripts/auction/deployCoinbase.ts +0 -21
  46. package/scripts/auction/deployXAuction.ts +0 -23
  47. package/scripts/auction/deployYVault.ts +0 -22
  48. package/scripts/deploy_voucher.ts +0 -20
  49. package/scripts/uniswap/deploy/deploy.ts +0 -65
  50. package/scripts/uniswap/deploy/deploy_create2.ts +0 -11
  51. package/scripts/uniswap/deploy/deploy_example.ts +0 -35
  52. package/scripts/uniswap/deploy/deploy_hooks.ts +0 -74
  53. package/scripts/uniswap/deploy/deploy_mockERC20.ts +0 -42
  54. package/scripts/uniswap/deploy/help.ts +0 -96
  55. package/scripts/uniswap/deploy/init.ts +0 -70
  56. package/src/auction/chainXAuction.ts +0 -209
  57. package/src/auction/chainYVault.ts +0 -153
  58. package/src/auction/event.ts +0 -19
  59. package/src/auction/serialize.ts +0 -162
  60. package/src/auction/type.ts +0 -71
  61. package/src/lib/signer.ts +0 -20
  62. package/src/lib/unlock.ts +0 -14
  63. package/src/uniswap/1-marketprice/addLiquidity.ts +0 -80
  64. package/src/uniswap/1-marketprice/removeLiquidity.ts +0 -63
  65. package/src/uniswap/1-marketprice/swap.ts +0 -100
  66. package/src/uniswap/2-limitorder/kill.ts +0 -70
  67. package/src/uniswap/2-limitorder/place.ts +0 -93
  68. package/src/uniswap/2-limitorder/withdraw.ts +0 -78
  69. package/src/uniswap/3-dynamicfee/dynamicfee.ts +0 -321
  70. package/src/uniswap/lib/ERC20.ts +0 -49
  71. package/src/uniswap/lib/contract.ts +0 -18
  72. package/src/uniswap/lib/limitOrder.ts +0 -40
  73. package/src/uniswap/lib/liqCalculation.ts +0 -152
  74. package/src/uniswap/lib/listen.ts +0 -57
  75. package/src/uniswap/lib/pool.ts +0 -62
  76. package/src/uniswap/lib/swap.ts +0 -8
  77. package/src/uniswap/lib/types.ts +0 -21
  78. package/src/uniswap/lib/utils.ts +0 -26
  79. package/src/uniswap/playgroud/abiencode.ts +0 -21
  80. package/src/uniswap/playgroud/amount0.ts +0 -47
  81. package/src/uniswap/playgroud/errordecode.ts +0 -54
  82. package/src/uniswap/playgroud/errorsigs.ts +0 -86
  83. package/src/voucher.ts +0 -122
  84. package/test/auction/ChainXAuctionV2.test.ts +0 -265
  85. package/test/auction/ChainYVaultV2.test.js +0 -163
  86. package/test/auction/ChainYVaultV2.test.ts +0 -183
  87. package/test/auction/auction.test.ts +0 -106
  88. package/test/connect_punk.test.ts +0 -26
  89. package/test/create2.test.ts +0 -44
  90. package/test/normal.ts +0 -43
  91. package/test/test-config.ts +0 -18
  92. package/test/uniswap/example.test.ts +0 -62
  93. package/test/uniswap/limitOrder.test.ts +0 -184
  94. package/test/uniswap/mockERC20.test.ts +0 -142
  95. package/test/voucher_hardhat.test.ts +0 -120
  96. package/test/voucher_punk.test.ts +0 -83
  97. package/tsconfig.json +0 -11
@@ -0,0 +1,153 @@
1
+ import { Signer, Contract, providers, Wallet, BigNumber, BigNumberish, ContractTransaction } from 'ethers';
2
+
3
+ interface PlaceBidParams {
4
+ auctionId: string;
5
+ seller: string;
6
+ valueEth: string;
7
+ secretText?: string;
8
+ }
9
+ interface RevealBidParams {
10
+ auctionId: string;
11
+ valueEth: string;
12
+ saltHex?: string;
13
+ }
14
+ interface RevealLockParams {
15
+ auctionId: string;
16
+ lockId: string;
17
+ valueEth: string;
18
+ saltHex?: string;
19
+ }
20
+ interface SubmitMatchResultsParams {
21
+ auctionId: string;
22
+ lockIds: string[];
23
+ bidders: string[];
24
+ finalValuesEth: string[];
25
+ }
26
+ interface ChallengeMatchResultParams {
27
+ auctionId: string;
28
+ bidder: string;
29
+ }
30
+ interface WithdrawMatchResultParams {
31
+ auctionId: string;
32
+ lockId: string;
33
+ }
34
+ interface CreateAuctionConfigParams {
35
+ auctionType: number;
36
+ baseAmountEth: string;
37
+ extendSeconds: number;
38
+ }
39
+ interface SetUnlockStrategyParams {
40
+ auctionType: number;
41
+ strategyAddress: string;
42
+ }
43
+ interface CreateAuctionParams {
44
+ seller: string;
45
+ sourceChainId: number;
46
+ activeAuctionCount: bigint;
47
+ auctionType: number;
48
+ }
49
+ interface CreateAuctionParams {
50
+ configId: number;
51
+ secretText: string;
52
+ expirationTs: number;
53
+ amountEth: string;
54
+ }
55
+ interface UnlockTokensParams {
56
+ lockId: string;
57
+ rawReceipt: string;
58
+ }
59
+
60
+ declare function getAuctionContract(signer: Signer): Contract;
61
+ declare function createAuction$1(params: CreateAuctionParams): Promise<{
62
+ auctionId: string;
63
+ revealStartTime: bigint;
64
+ }>;
65
+ declare function placeBid(params: PlaceBidParams): Promise<{
66
+ bidValue: string;
67
+ secretHash: string;
68
+ }>;
69
+ declare function revealBid(params: RevealBidParams): Promise<void>;
70
+ declare function revealLock(params: RevealLockParams): Promise<void>;
71
+ declare function submitMatchResults(params: SubmitMatchResultsParams): Promise<void>;
72
+ declare function withdrawMatchResult(params: WithdrawMatchResultParams): Promise<void>;
73
+ declare function getLockInfo(auctionId: string, lockId: string): Promise<{
74
+ exists: boolean;
75
+ revealTime: bigint;
76
+ secret: string;
77
+ }>;
78
+ declare function getMatchResult(auctionId: string, bidder: string): Promise<{
79
+ lockId: string;
80
+ isChallenged: boolean;
81
+ isWithdrawn: boolean;
82
+ }>;
83
+
84
+ declare function getProvider(): providers.JsonRpcProvider;
85
+ declare function toWei(valueEth: string): bigint;
86
+ declare function createAuctionConfig({ auctionType, baseAmountEth, extendSeconds, }: CreateAuctionConfigParams): Promise<string>;
87
+ declare function createAuction({ configId, secretText, expirationTs, amountEth, }: CreateAuctionParams): Promise<{
88
+ txHash: string;
89
+ auctionId?: string;
90
+ lockId?: string;
91
+ }>;
92
+ declare function unlockTokens({ lockId, rawReceipt, }: UnlockTokensParams): Promise<{
93
+ txHash: string;
94
+ recipient?: string;
95
+ amount?: bigint;
96
+ }>;
97
+ declare function getAuctionInfo(auctionId: string | number): Promise<{
98
+ auctionType: number;
99
+ baseAmount: bigint;
100
+ revealTime: bigint;
101
+ }>;
102
+ declare function getAuctionLockInfo(lockId: string): Promise<{
103
+ owner: string;
104
+ amount: bigint;
105
+ isLocked: boolean;
106
+ revealTime: bigint;
107
+ }>;
108
+ declare function getActiveAuctionsCount(): Promise<bigint>;
109
+
110
+ declare function swap(wallet: Wallet, amountIn: bigint, zeroForOne: boolean, hookData: string): Promise<void>;
111
+ declare function main(): Promise<void>;
112
+
113
+ declare function getContract(wallet: Wallet, name: string): Promise<Contract>;
114
+
115
+ interface PoolKey {
116
+ currency0: string;
117
+ currency1: string;
118
+ fee: number;
119
+ tickSpacing: number;
120
+ hooks: string;
121
+ }
122
+ interface SwapParams {
123
+ zeroForOne: boolean;
124
+ amountSpecified: bigint;
125
+ sqrtPriceLimitX96: bigint;
126
+ }
127
+ interface ModifyPositionParams {
128
+ tickLower: number;
129
+ tickUpper: number;
130
+ liquidityDelta: bigint;
131
+ salt?: string;
132
+ }
133
+
134
+ declare function modifyPosition(contract: Contract, modifyPositionParams: ModifyPositionParams, hookData: string): Promise<void>;
135
+ declare function getPoolId(poolKey: PoolKey): string;
136
+ declare function getLiquidity(contract: Contract, poolKey: PoolKey): Promise<any>;
137
+ declare function getPoolSqrtPrice(liqPool: Contract): Promise<bigint>;
138
+ declare function getPoolPrice(liqPool: Contract): Promise<number>;
139
+ declare function getCurrentTick(liqPool: Contract): Promise<number>;
140
+
141
+ declare const mutiVoucherABI: any;
142
+ type SignerOrProvider = Signer | providers.Provider;
143
+ declare function getVoucherContract(contractAddress: string, signerOrProvider: SignerOrProvider): Contract;
144
+ declare function createVoucher(contractAddress: string, signer: Signer, name: string, conversionRate: BigNumberish): Promise<ContractTransaction>;
145
+ declare function getVoucherInfo(contractAddress: string, provider: SignerOrProvider, name: string): Promise<BigNumber>;
146
+ declare function buyVoucher(contractAddress: string, signer: Signer, name: string, valueWei: BigNumberish): Promise<ContractTransaction>;
147
+ declare function buyVoucherWithEth(contractAddress: string, signer: Signer, name: string, valueEth: string): Promise<ContractTransaction>;
148
+ declare function useVoucher(contractAddress: string, signer: Signer, name: string, amount: BigNumberish): Promise<ContractTransaction>;
149
+ declare function balanceOf(contractAddress: string, provider: SignerOrProvider, name: string, user: string): Promise<BigNumber>;
150
+ declare function getAllVouchers(contractAddress: string, provider: SignerOrProvider): Promise<string[]>;
151
+ declare function BuildUseVoucherTx(tx: providers.TransactionRequest, voucherName: string): providers.TransactionRequest;
152
+
153
+ export { BuildUseVoucherTx, type ChallengeMatchResultParams, type CreateAuctionConfigParams, type CreateAuctionParams, type ModifyPositionParams, type PlaceBidParams, type PoolKey, type RevealBidParams, type RevealLockParams, type SetUnlockStrategyParams, type SignerOrProvider, type SubmitMatchResultsParams, type SwapParams, type UnlockTokensParams, type WithdrawMatchResultParams, balanceOf, buyVoucher, buyVoucherWithEth, createAuction$1 as createAuction, createAuctionConfig, createAuction as createAuctionOnVault, createVoucher, getActiveAuctionsCount, getAllVouchers, getAuctionContract, getAuctionInfo, getAuctionLockInfo, getContract, getCurrentTick, getLiquidity, getLockInfo, getMatchResult, getPoolId, getPoolPrice, getPoolSqrtPrice, getProvider, getVoucherContract, getVoucherInfo, main, modifyPosition, mutiVoucherABI, placeBid, revealBid, revealLock, submitMatchResults, swap, toWei, unlockTokens, useVoucher, withdrawMatchResult };
@@ -0,0 +1,153 @@
1
+ import { Signer, Contract, providers, Wallet, BigNumber, BigNumberish, ContractTransaction } from 'ethers';
2
+
3
+ interface PlaceBidParams {
4
+ auctionId: string;
5
+ seller: string;
6
+ valueEth: string;
7
+ secretText?: string;
8
+ }
9
+ interface RevealBidParams {
10
+ auctionId: string;
11
+ valueEth: string;
12
+ saltHex?: string;
13
+ }
14
+ interface RevealLockParams {
15
+ auctionId: string;
16
+ lockId: string;
17
+ valueEth: string;
18
+ saltHex?: string;
19
+ }
20
+ interface SubmitMatchResultsParams {
21
+ auctionId: string;
22
+ lockIds: string[];
23
+ bidders: string[];
24
+ finalValuesEth: string[];
25
+ }
26
+ interface ChallengeMatchResultParams {
27
+ auctionId: string;
28
+ bidder: string;
29
+ }
30
+ interface WithdrawMatchResultParams {
31
+ auctionId: string;
32
+ lockId: string;
33
+ }
34
+ interface CreateAuctionConfigParams {
35
+ auctionType: number;
36
+ baseAmountEth: string;
37
+ extendSeconds: number;
38
+ }
39
+ interface SetUnlockStrategyParams {
40
+ auctionType: number;
41
+ strategyAddress: string;
42
+ }
43
+ interface CreateAuctionParams {
44
+ seller: string;
45
+ sourceChainId: number;
46
+ activeAuctionCount: bigint;
47
+ auctionType: number;
48
+ }
49
+ interface CreateAuctionParams {
50
+ configId: number;
51
+ secretText: string;
52
+ expirationTs: number;
53
+ amountEth: string;
54
+ }
55
+ interface UnlockTokensParams {
56
+ lockId: string;
57
+ rawReceipt: string;
58
+ }
59
+
60
+ declare function getAuctionContract(signer: Signer): Contract;
61
+ declare function createAuction$1(params: CreateAuctionParams): Promise<{
62
+ auctionId: string;
63
+ revealStartTime: bigint;
64
+ }>;
65
+ declare function placeBid(params: PlaceBidParams): Promise<{
66
+ bidValue: string;
67
+ secretHash: string;
68
+ }>;
69
+ declare function revealBid(params: RevealBidParams): Promise<void>;
70
+ declare function revealLock(params: RevealLockParams): Promise<void>;
71
+ declare function submitMatchResults(params: SubmitMatchResultsParams): Promise<void>;
72
+ declare function withdrawMatchResult(params: WithdrawMatchResultParams): Promise<void>;
73
+ declare function getLockInfo(auctionId: string, lockId: string): Promise<{
74
+ exists: boolean;
75
+ revealTime: bigint;
76
+ secret: string;
77
+ }>;
78
+ declare function getMatchResult(auctionId: string, bidder: string): Promise<{
79
+ lockId: string;
80
+ isChallenged: boolean;
81
+ isWithdrawn: boolean;
82
+ }>;
83
+
84
+ declare function getProvider(): providers.JsonRpcProvider;
85
+ declare function toWei(valueEth: string): bigint;
86
+ declare function createAuctionConfig({ auctionType, baseAmountEth, extendSeconds, }: CreateAuctionConfigParams): Promise<string>;
87
+ declare function createAuction({ configId, secretText, expirationTs, amountEth, }: CreateAuctionParams): Promise<{
88
+ txHash: string;
89
+ auctionId?: string;
90
+ lockId?: string;
91
+ }>;
92
+ declare function unlockTokens({ lockId, rawReceipt, }: UnlockTokensParams): Promise<{
93
+ txHash: string;
94
+ recipient?: string;
95
+ amount?: bigint;
96
+ }>;
97
+ declare function getAuctionInfo(auctionId: string | number): Promise<{
98
+ auctionType: number;
99
+ baseAmount: bigint;
100
+ revealTime: bigint;
101
+ }>;
102
+ declare function getAuctionLockInfo(lockId: string): Promise<{
103
+ owner: string;
104
+ amount: bigint;
105
+ isLocked: boolean;
106
+ revealTime: bigint;
107
+ }>;
108
+ declare function getActiveAuctionsCount(): Promise<bigint>;
109
+
110
+ declare function swap(wallet: Wallet, amountIn: bigint, zeroForOne: boolean, hookData: string): Promise<void>;
111
+ declare function main(): Promise<void>;
112
+
113
+ declare function getContract(wallet: Wallet, name: string): Promise<Contract>;
114
+
115
+ interface PoolKey {
116
+ currency0: string;
117
+ currency1: string;
118
+ fee: number;
119
+ tickSpacing: number;
120
+ hooks: string;
121
+ }
122
+ interface SwapParams {
123
+ zeroForOne: boolean;
124
+ amountSpecified: bigint;
125
+ sqrtPriceLimitX96: bigint;
126
+ }
127
+ interface ModifyPositionParams {
128
+ tickLower: number;
129
+ tickUpper: number;
130
+ liquidityDelta: bigint;
131
+ salt?: string;
132
+ }
133
+
134
+ declare function modifyPosition(contract: Contract, modifyPositionParams: ModifyPositionParams, hookData: string): Promise<void>;
135
+ declare function getPoolId(poolKey: PoolKey): string;
136
+ declare function getLiquidity(contract: Contract, poolKey: PoolKey): Promise<any>;
137
+ declare function getPoolSqrtPrice(liqPool: Contract): Promise<bigint>;
138
+ declare function getPoolPrice(liqPool: Contract): Promise<number>;
139
+ declare function getCurrentTick(liqPool: Contract): Promise<number>;
140
+
141
+ declare const mutiVoucherABI: any;
142
+ type SignerOrProvider = Signer | providers.Provider;
143
+ declare function getVoucherContract(contractAddress: string, signerOrProvider: SignerOrProvider): Contract;
144
+ declare function createVoucher(contractAddress: string, signer: Signer, name: string, conversionRate: BigNumberish): Promise<ContractTransaction>;
145
+ declare function getVoucherInfo(contractAddress: string, provider: SignerOrProvider, name: string): Promise<BigNumber>;
146
+ declare function buyVoucher(contractAddress: string, signer: Signer, name: string, valueWei: BigNumberish): Promise<ContractTransaction>;
147
+ declare function buyVoucherWithEth(contractAddress: string, signer: Signer, name: string, valueEth: string): Promise<ContractTransaction>;
148
+ declare function useVoucher(contractAddress: string, signer: Signer, name: string, amount: BigNumberish): Promise<ContractTransaction>;
149
+ declare function balanceOf(contractAddress: string, provider: SignerOrProvider, name: string, user: string): Promise<BigNumber>;
150
+ declare function getAllVouchers(contractAddress: string, provider: SignerOrProvider): Promise<string[]>;
151
+ declare function BuildUseVoucherTx(tx: providers.TransactionRequest, voucherName: string): providers.TransactionRequest;
152
+
153
+ export { BuildUseVoucherTx, type ChallengeMatchResultParams, type CreateAuctionConfigParams, type CreateAuctionParams, type ModifyPositionParams, type PlaceBidParams, type PoolKey, type RevealBidParams, type RevealLockParams, type SetUnlockStrategyParams, type SignerOrProvider, type SubmitMatchResultsParams, type SwapParams, type UnlockTokensParams, type WithdrawMatchResultParams, balanceOf, buyVoucher, buyVoucherWithEth, createAuction$1 as createAuction, createAuctionConfig, createAuction as createAuctionOnVault, createVoucher, getActiveAuctionsCount, getAllVouchers, getAuctionContract, getAuctionInfo, getAuctionLockInfo, getContract, getCurrentTick, getLiquidity, getLockInfo, getMatchResult, getPoolId, getPoolPrice, getPoolSqrtPrice, getProvider, getVoucherContract, getVoucherInfo, main, modifyPosition, mutiVoucherABI, placeBid, revealBid, revealLock, submitMatchResults, swap, toWei, unlockTokens, useVoucher, withdrawMatchResult };