@wireio/stake 0.2.4 → 0.3.0

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 (100) hide show
  1. package/lib/stake.browser.js +5991 -4340
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +74 -60
  4. package/lib/stake.js +9782 -8054
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +5991 -4340
  7. package/lib/stake.m.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/assets/ethereum/ABI/liqEth/BeaconState.sol/BeaconState.dbg.json +4 -0
  10. package/src/assets/ethereum/ABI/liqEth/BeaconState.sol/BeaconState.json +807 -0
  11. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.dbg.json +1 -1
  12. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json +184 -346
  13. package/src/assets/ethereum/ABI/liqEth/LiqEthAuthority.sol/LiqEthAuthority.dbg.json +4 -0
  14. package/src/assets/ethereum/ABI/liqEth/LiqEthAuthority.sol/LiqEthAuthority.json +1289 -0
  15. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +1 -1
  16. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +1 -1
  17. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +1 -1
  18. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.dbg.json +4 -0
  19. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthUpgradeable.json +29 -0
  20. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +1 -1
  21. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.json +36 -0
  22. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.dbg.json +4 -0
  23. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20Pausable.json +263 -0
  24. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +1 -1
  25. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.json +226 -0
  26. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +1 -1
  27. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +59 -0
  28. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +1 -1
  29. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +14 -12
  30. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +1 -1
  31. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.json +2 -2
  32. package/src/assets/ethereum/ABI/liqEth/LiqEthManaged.sol/LiqEthManaged.dbg.json +4 -0
  33. package/src/assets/ethereum/ABI/liqEth/LiqEthManaged.sol/LiqEthManaged.json +229 -0
  34. package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20Upgradeable.dbg.json +4 -0
  35. package/src/assets/ethereum/ABI/liqEth/{RewardsERC20Pausable.sol/RewardsERC20Pausable.json → RewardsERC20.sol/RewardsERC20Upgradeable.json} +140 -78
  36. package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.dbg.json +4 -0
  37. package/src/assets/ethereum/ABI/liqEth/{RewardsERC20.sol/RewardsERC20.json → RewardsERC20Pausable.sol/RewardsERC20PausableUpgradeable.json} +218 -30
  38. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.dbg.json +1 -1
  39. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.json +2 -2
  40. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.dbg.json +1 -1
  41. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.json +2 -2
  42. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.dbg.json +4 -0
  43. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZExtras.json +10 -0
  44. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.dbg.json +4 -0
  45. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZVec48.json +10 -0
  46. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.dbg.json +1 -1
  47. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json +121 -55
  48. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.dbg.json +1 -1
  49. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json +836 -273
  50. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.dbg.json +1 -1
  51. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json +150 -168
  52. package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.dbg.json +1 -1
  53. package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json +301 -186
  54. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.dbg.json +1 -1
  55. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json +814 -206
  56. package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +1 -1
  57. package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +244 -198
  58. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +1 -1
  59. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.json +2 -2
  60. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +1 -1
  61. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json +165 -152
  62. package/src/assets/ethereum/ABI/outpost/Aggregator.sol/Aggregator.json +82 -0
  63. package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.dbg.json +1 -1
  64. package/src/assets/ethereum/ABI/outpost/Depositor.sol/Depositor.json +167 -282
  65. package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/AggregatorV3Interface.dbg.json +1 -1
  66. package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.dbg.json +1 -1
  67. package/src/assets/ethereum/ABI/outpost/EthUsdPriceConsumer.sol/EthUsdPriceConsumer.json +2 -54
  68. package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.dbg.json +1 -1
  69. package/src/assets/ethereum/ABI/outpost/OPP.sol/OPP.json +26 -8
  70. package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.dbg.json +1 -1
  71. package/src/assets/ethereum/ABI/outpost/OPPInbound.sol/OPPInbound.json +2 -2
  72. package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.dbg.json +4 -0
  73. package/src/assets/ethereum/ABI/outpost/Pretoken.sol/Pretoken.json +1650 -0
  74. package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.dbg.json +1 -1
  75. package/src/assets/ethereum/ABI/outpost/ReceiptNFT.sol/ReceiptNFT.json +2 -22
  76. package/src/assets/ethereum/ABI/outpost/interfaces/IPretoken.sol/IPretoken.dbg.json +4 -0
  77. package/src/assets/ethereum/ABI/outpost/interfaces/IPretoken.sol/IPretoken.json +29 -0
  78. package/src/assets/ethereum/ABI/outpost/interfaces/IWarrant.sol/IWarrant.dbg.json +1 -1
  79. package/src/networks/ethereum/clients/deposit.client.ts +86 -8
  80. package/src/networks/ethereum/clients/liq.client.ts +47 -0
  81. package/src/networks/ethereum/clients/pretoken.client.ts +127 -0
  82. package/src/networks/ethereum/clients/stake.client.ts +87 -24
  83. package/src/networks/ethereum/contract.ts +34 -48
  84. package/src/networks/ethereum/ethereum.ts +219 -96
  85. package/src/networks/ethereum/types.ts +9 -6
  86. package/src/networks/ethereum/utils.ts +308 -0
  87. package/src/networks/solana/clients/token.client.ts +0 -1
  88. package/src/networks/solana/solana.ts +44 -146
  89. package/src/networks/solana/types.ts +6 -2
  90. package/src/networks/solana/utils.ts +4 -6
  91. package/src/staker/types.ts +62 -0
  92. package/src/types.ts +18 -33
  93. package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.dbg.json +0 -4
  94. package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.dbg.json +0 -4
  95. package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.dbg.json +0 -4
  96. package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.json +0 -10
  97. package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.dbg.json +0 -4
  98. package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.json +0 -10
  99. package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.dbg.json +0 -4
  100. package/src/assets/ethereum/ABI/outpost/Warrant.sol/Warrant.json +0 -1650
@@ -116,7 +116,7 @@ export function buildSolanaTrancheLadder(options: {
116
116
  currentTranche: number;
117
117
  initialTrancheSupply: bigint;
118
118
  currentTrancheSupply: bigint;
119
- totalWarrantsSold: bigint; // informational only
119
+ totalPretokensSold: bigint; // informational only
120
120
  currentPriceUsd: bigint;
121
121
  supplyGrowthBps: number;
122
122
  priceGrowthBps: number;
@@ -213,7 +213,7 @@ export function buildSolanaTrancheSnapshot(options: {
213
213
  const currentTranche = trancheState.currentTrancheNumber.toNumber();
214
214
  const currentTrancheSupply = toBigint(trancheState.currentTrancheSupply);
215
215
  const initialTrancheSupply = toBigint(trancheState.initialTrancheSupply);
216
- const totalWarrantsSold = toBigint(trancheState.totalWarrantsSold);
216
+ const totalPretokensSold = toBigint(trancheState.totalPretokensSold);
217
217
  const currentPriceUsd = toBigint(trancheState.currentTranchePriceUsd);
218
218
 
219
219
  const supplyGrowthBps = trancheState.supplyGrowthBps;
@@ -230,7 +230,7 @@ export function buildSolanaTrancheSnapshot(options: {
230
230
  currentTranche,
231
231
  initialTrancheSupply,
232
232
  currentTrancheSupply,
233
- totalWarrantsSold,
233
+ totalPretokensSold,
234
234
  currentPriceUsd,
235
235
  supplyGrowthBps,
236
236
  priceGrowthBps,
@@ -244,13 +244,11 @@ export function buildSolanaTrancheSnapshot(options: {
244
244
  totalShares,
245
245
  currentTranche,
246
246
  currentPriceUsd,
247
- minPriceUsd,
248
- maxPriceUsd,
249
247
  supplyGrowthBps,
250
248
  priceGrowthBps,
251
249
  currentTrancheSupply,
252
250
  initialTrancheSupply,
253
- totalWarrantsSold,
251
+ totalPretokensSold,
254
252
  nativePriceUsd: solPriceUsd,
255
253
  nativePriceTimestamp,
256
254
  ladder,
@@ -0,0 +1,62 @@
1
+ import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base';
2
+ import { PublicKey as SolPubKey } from '@solana/web3.js';
3
+ import { ChainID, ExternalNetwork, PublicKey } from '@wireio/core';
4
+ import { ethers } from 'ethers';
5
+
6
+ export interface IStakingClient {
7
+ pubKey: PublicKey;
8
+ network: ExternalNetwork;
9
+
10
+ /** Amount is in the chain's smallest unit (lamports/wei, etc.) */
11
+ deposit(amount: bigint): Promise<string>;
12
+ withdraw(amount: bigint): Promise<string>;
13
+ stake(amount: bigint): Promise<string>;
14
+ unstake(amount: bigint): Promise<string>;
15
+
16
+ buy?(amount: bigint, purchaseAsset: PurchaseAsset): Promise<string>;
17
+
18
+ // REMOVED from shared client, SOLANA ONLY
19
+ /** Register any untracked LIQ staked tokens */
20
+ // register(): Promise<string>;
21
+
22
+ /** Fetch the portfolio for the LIQ stake user */
23
+ getPortfolio(): Promise<Portfolio>;
24
+ }
25
+
26
+ // Enum describing which asset is being used to buy pretoken
27
+ export enum PurchaseAsset {
28
+ SOL = "SOL",
29
+ LIQSOL = "LIQSOL",
30
+ ETH = "ETH",
31
+ LIQETH = "LIQETH",
32
+ YIELD = "YIELD",
33
+ }
34
+
35
+ export type StakerConfig = {
36
+ network: ExternalNetwork;
37
+ provider: BaseSignerWalletAdapter | ethers.providers.Web3Provider;
38
+ pubKey: PublicKey;
39
+ }
40
+
41
+ export interface Portfolio {
42
+ /** Native balance on chain: ETH, SOL */
43
+ native: BalanceView;
44
+ /** Actual Liquid balance of LiqETH, LiqSOL*/
45
+ liq: BalanceView;
46
+ /** Outpost Staked balance */
47
+ staked: BalanceView
48
+ /** SOL ONLY!
49
+ * Tracked liqSOL balance from distribution program */
50
+ tracked?: BalanceView;
51
+ /** Extra PDAs and account addresses */
52
+ extras?: Record<string, any>;
53
+ /** Chain ID of the network for which this portfolio is from */
54
+ chainID: ChainID;
55
+ }
56
+
57
+ export type BalanceView = {
58
+ amount: bigint; // raw on-chain integer value
59
+ decimals: number; // number of decimal places
60
+ symbol?: string; // optional token symbol identifier
61
+ ata?: SolPubKey; // associated token account address
62
+ };
package/src/types.ts CHANGED
@@ -6,11 +6,11 @@ import { ethers } from 'ethers';
6
6
  export type StakerConfig = {
7
7
  network: ExternalNetwork;
8
8
  provider: BaseSignerWalletAdapter | ethers.providers.Web3Provider;
9
- pubKey: PublicKey;
9
+ pubKey?: PublicKey;
10
10
  }
11
11
 
12
12
  export interface IStakingClient {
13
- pubKey: PublicKey;
13
+ pubKey?: PublicKey;
14
14
  network: ExternalNetwork;
15
15
 
16
16
  /** Amount is in the chain's smallest unit (lamports/wei, etc.) */
@@ -18,7 +18,7 @@ export interface IStakingClient {
18
18
  withdraw(amount: bigint): Promise<string>;
19
19
  stake(amount: bigint): Promise<string>;
20
20
  unstake(amount: bigint): Promise<string>;
21
- buy(amount: bigint, asset: PurchaseAsset): Promise<string>;
21
+ buy(amount: bigint): Promise<string>;
22
22
 
23
23
  /** Fetch the complete user portfolio */
24
24
  getPortfolio(): Promise<Portfolio>;
@@ -35,9 +35,6 @@ export interface IStakingClient {
35
35
  windowBefore?: number;
36
36
  windowAfter?: number;
37
37
  }): Promise<TrancheSnapshot | null>;
38
-
39
- /** */
40
- getBuyQuote(amount: bigint, asset: PurchaseAsset): Promise<PurchaseQuote>;
41
38
  }
42
39
 
43
40
  export interface Portfolio {
@@ -47,7 +44,7 @@ export interface Portfolio {
47
44
  liq: BalanceView;
48
45
  /** Outpost Staked balance */
49
46
  staked: BalanceView
50
- /** Prelaunch WIRE “shares” (warrants/pretokens) */
47
+ /** Prelaunch WIRE “shares” (pretokens) */
51
48
  wire: BalanceView;
52
49
  /** SOL ONLY!
53
50
  * Tracked liqSOL balance from distribution program */
@@ -64,6 +61,18 @@ export type BalanceView = {
64
61
  symbol: string; // optional token symbol identifier
65
62
  ata?: SolPubKey; // associated token account address
66
63
  };
64
+ export interface TrancheLadderItem {
65
+ /** On-chain tranche id, 0-based (0,1,2,...) */
66
+ id: number;
67
+ /** Total capacity for this tranche (pretokens, 1e8 scale) */
68
+ capacity: bigint;
69
+ /** Sold amount in this tranche (1e8 scale) */
70
+ sold: bigint;
71
+ /** Remaining = capacity - sold (1e8 scale) */
72
+ remaining: bigint;
73
+ /** Price for this tranche in USD (1e8 scale) */
74
+ priceUsd: bigint;
75
+ }
67
76
 
68
77
  export interface TrancheLadderItem {
69
78
  /** On-chain tranche id, 0-based (0,1,2,...) */
@@ -95,18 +104,16 @@ export interface TrancheSnapshot {
95
104
 
96
105
  /** Current tranche price in USD (1e8 scale) */
97
106
  currentPriceUsd: bigint;
98
- /** Optional min/max bounds for price validation (1e8 scale) */
99
- minPriceUsd?: bigint;
100
- maxPriceUsd?: bigint;
101
107
 
102
108
  /** Tranche curve config (per-chain) */
109
+ // TODO make a constant?
103
110
  supplyGrowthBps: number; // e.g. 100 = +1% per tranche
104
111
  priceGrowthBps: number; // e.g. 200 = +2% per tranche
105
112
 
106
113
  /** Current tranche supply state (1e8 scale) */
107
114
  currentTrancheSupply: bigint; // remaining in current tranche
108
115
  initialTrancheSupply: bigint; // capacity for current tranche
109
- totalWarrantsSold: bigint; // global cumulative sold (all tranches), 1e8
116
+ totalPretokensSold: bigint; // global cumulative sold (all tranches), 1e8
110
117
 
111
118
  /** Native token → USD price if available (SOL/USD, ETH/USD, etc, 1e8 scale) */
112
119
  nativePriceUsd?: bigint;
@@ -118,26 +125,4 @@ export interface TrancheSnapshot {
118
125
  * Used directly by the frontend for ladder graphs.
119
126
  */
120
127
  ladder: TrancheLadderItem[];
121
- }
122
-
123
- /** Purchase asset selection used by staking client(s) */
124
- export enum PurchaseAsset {
125
- SOL = 'SOL',
126
- LIQSOL = 'LIQSOL',
127
- ETH = 'ETH',
128
- LIQETH = 'LIQETH',
129
- YIELD = 'YIELD',
130
- }
131
-
132
- export interface PurchaseQuote {
133
- purchaseAsset: PurchaseAsset;
134
- amountIn: bigint; // lamports / wei / token units
135
-
136
- /** Expected pretoken “shares” (pretokens) and decimals */
137
- wireShares: bigint; // 1e8 scale
138
- wireDecimals: number; // always 8 for now
139
-
140
- /** Current price + notional in USD (1e8 scale) */
141
- wirePriceUsd: bigint;
142
- notionalUsd: bigint;
143
128
  }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/f26a3bdbd4033af8421132fc6adca199.json"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/f26a3bdbd4033af8421132fc6adca199.json"
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/f26a3bdbd4033af8421132fc6adca199.json"
4
- }
@@ -1,10 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "BeaconRoots",
4
- "sourceName": "contracts/liqEth/Yield.sol",
5
- "abi": [],
6
- "bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea264697066735822122031a0f5398756e42b92bee3bd69db499a6ba974a3821f736e80fb78b4b59bd4ad64736f6c63430008190033",
7
- "deployedBytecode": "0x600080fdfea264697066735822122031a0f5398756e42b92bee3bd69db499a6ba974a3821f736e80fb78b4b59bd4ad64736f6c63430008190033",
8
- "linkReferences": {},
9
- "deployedLinkReferences": {}
10
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/f26a3bdbd4033af8421132fc6adca199.json"
4
- }
@@ -1,10 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "SSZ",
4
- "sourceName": "contracts/liqEth/Yield.sol",
5
- "abi": [],
6
- "bytecode": "0x60808060405234601757603a9081601d823930815050f35b600080fdfe600080fdfea2646970667358221220cb02051f443c7190a2fcd835a3bfa144af2732be9952e46973e867f22c854c8664736f6c63430008190033",
7
- "deployedBytecode": "0x600080fdfea2646970667358221220cb02051f443c7190a2fcd835a3bfa144af2732be9952e46973e867f22c854c8664736f6c63430008190033",
8
- "linkReferences": {},
9
- "deployedLinkReferences": {}
10
- }
@@ -1,4 +0,0 @@
1
- {
2
- "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/ed9aaec874c02fdb46b7a115ba311ca3.json"
4
- }