@wireio/stake 0.1.1 → 0.1.3

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 (69) hide show
  1. package/lib/stake.browser.js +6681 -115
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +23 -40
  4. package/lib/stake.js +6684 -120
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +6681 -115
  7. package/lib/stake.m.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.dbg.json +4 -0
  10. package/src/assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json +1153 -0
  11. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.dbg.json +4 -0
  12. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IAccounting.json +172 -0
  13. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositContract.dbg.json +4 -0
  14. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositContract.json +39 -0
  15. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositManager.dbg.json +4 -0
  16. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IDepositManager.json +64 -0
  17. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthBurn.dbg.json +4 -0
  18. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthBurn.json +24 -0
  19. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthMint.dbg.json +4 -0
  20. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/ILiqEthMint.json +35 -0
  21. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.dbg.json +4 -0
  22. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IRewardsERC20.json +213 -0
  23. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.dbg.json +4 -0
  24. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IStakingModule.json +138 -0
  25. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.dbg.json +4 -0
  26. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IValidatorBalanceVerifier.json +70 -0
  27. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.dbg.json +4 -0
  28. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/IWithdrawalRecord.json +64 -0
  29. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.dbg.json +4 -0
  30. package/src/assets/ethereum/ABI/liqEth/LiqEthCommon.sol/LiqEthCommon.json +10 -0
  31. package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.dbg.json +4 -0
  32. package/src/assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.json +749 -0
  33. package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.dbg.json +4 -0
  34. package/src/assets/ethereum/ABI/liqEth/RewardsERC20Pausable.sol/RewardsERC20Pausable.json +812 -0
  35. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.dbg.json +4 -0
  36. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/BeaconRoots.json +10 -0
  37. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.dbg.json +4 -0
  38. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/SSZ.json +10 -0
  39. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.dbg.json +4 -0
  40. package/src/assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json +225 -0
  41. package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.dbg.json +4 -0
  42. package/src/assets/ethereum/ABI/liqEth/Yield.sol/BeaconRoots.json +10 -0
  43. package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.dbg.json +4 -0
  44. package/src/assets/ethereum/ABI/liqEth/Yield.sol/SSZ.json +10 -0
  45. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.dbg.json +4 -0
  46. package/src/assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json +813 -0
  47. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.dbg.json +4 -0
  48. package/src/assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json +651 -0
  49. package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.dbg.json +4 -0
  50. package/src/assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json +1110 -0
  51. package/src/assets/ethereum/ABI/liqEth/liqEthBurn.sol/LiqEthBurn.dbg.json +4 -0
  52. package/src/assets/ethereum/ABI/liqEth/liqEthBurn.sol/LiqEthBurn.json +391 -0
  53. package/src/assets/ethereum/ABI/liqEth/liqEthMint.sol/LiqEthMint.dbg.json +4 -0
  54. package/src/assets/ethereum/ABI/liqEth/liqEthMint.sol/LiqEthMint.json +402 -0
  55. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.dbg.json +4 -0
  56. package/src/assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json +1225 -0
  57. package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.dbg.json +4 -0
  58. package/src/assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json +927 -0
  59. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.dbg.json +4 -0
  60. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/Uint64BE.json +10 -0
  61. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.dbg.json +4 -0
  62. package/src/assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json +447 -0
  63. package/src/index.ts +1 -1
  64. package/src/networks/ethereum/contract.ts +53 -90
  65. package/src/networks/ethereum/ethereum.ts +40 -65
  66. package/src/networks/ethereum/types.ts +6 -9
  67. package/src/networks/solana/solana.ts +36 -32
  68. package/src/staker/staker.ts +6 -3
  69. package/src/staker/types.ts +14 -9
@@ -3,24 +3,23 @@
3
3
  *
4
4
  * Provides a unified service for interacting with Ethereum smart contracts using ethers.js.
5
5
  */
6
- // TODO: adjust these import paths to your actual artifact layout
7
- // import DepositManagerArtifact from '../../assets/ethereum/ABI/liqeth/DepositManager.sol/DepositManager.json';
8
- // import LiqEthArtifact from '../../assets/ethereum/ABI/liqeth/liqEth.sol/liqEth.json';
9
- // import LiqEthMintArtifact from '../../assets/ethereum/ABI/liqeth/liqEthMint.sol/liqEthMint.json';
10
- // import LiqEthBurnArtifact from '../../assets/ethereum/ABI/liqeth/liqEthBurn.sol/liqEthBurn.json';
11
- // import LiqEthTreasuryArtifact from '../../assets/ethereum/ABI/liqeth/liqEthTreasury.sol/liqEthTreasury.json';
12
- // import LiqEthCommonArtifact from '../../assets/ethereum/ABI/liqeth/LiqEthCommon.sol/LiqEthCommon.json';
13
- // import RewardsERC20Artifact from '../../assets/ethereum/ABI/liqeth/RewardsERC20.sol/RewardsERC20.json';
14
- // import ValidatorBalanceVerifierArtifact from '../../assets/ethereum/ABI/liqeth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json';
15
- // import YieldArtifact from '../../assets/ethereum/ABI/liqeth/Yield.sol/Yield.json';
16
- // import AccountingArtifact from '../../assets/ethereum/ABI/liqeth/accounting.sol/accounting.json';
17
- // import StakingModuleArtifact from '../../assets/ethereum/ABI/liqeth/stakingModule.sol/stakingModule.json';
18
- // import WithdrawalQueueArtifact from '../../assets/ethereum/ABI/liqeth/withdrawalQueue.sol/withdrawalQueue.json';
19
- // import WithdrawalVaultArtifact from '../../assets/ethereum/ABI/liqeth/withdrawalVault.sol/withdrawalVault.json';
6
+ import AccountingArtifact from '../../assets/ethereum/ABI/liqEth/accounting.sol/Accounting.json';
7
+ import DepositManagerArtifact from '../../assets/ethereum/ABI/liqEth/DepositManager.sol/DepositManager.json';
8
+ import LiqEthArtifact from '../../assets/ethereum/ABI/liqEth/liqEth.sol/LiqEthToken.json';
9
+ import LiqEthBurnArtifact from '../../assets/ethereum/ABI/liqEth/liqEthBurn.sol/LiqEthBurn.json';
10
+ // import LiqEthCommonArtifact from '../../assets/ethereum/ABI/liqEth/liqEthCommon.sol/liqEthCommon.json';
11
+ import LiqEthMintArtifact from '../../assets/ethereum/ABI/liqEth/liqEthMint.sol/LiqEthMint.json';
12
+ // import RewardsERC20Artifact from '../../assets/ethereum/ABI/liqEth/RewardsERC20.sol/RewardsERC20.json';
13
+ import StakingModuleArtifact from '../../assets/ethereum/ABI/liqEth/stakingModule.sol/StakingModule.json';
14
+ // import ValidatorBalanceArtifact from '../../assets/ethereum/ABI/liqEth/ValidatorBalanceVerifier.sol/ValidatorBalanceVerifier.json';
15
+ import WithdrawalQueueArtifact from '../../assets/ethereum/ABI/liqEth/withdrawalQueue.sol/WithdrawalQueue.json';
16
+ import WithdrawalVaultArtifact from '../../assets/ethereum/ABI/liqEth/withdrawalVault.sol/WithdrawalVault.json';
17
+ // import YieldArtifact from '../../assets/ethereum/ABI/liqEth/Yield.sol/YieldOracle.json';
20
18
 
21
19
  import ERC20Artifact from '../../assets/ethereum/ABI/token/ERC20Token.sol/ERC20Token.json';
22
20
  import ERC721Artifact from '../../assets/ethereum/ABI/token/ERC721Token.sol/ERC721Token.json';
23
21
  import ERC1155Artifact from '../../assets/ethereum/ABI/token/ERC1155Token.sol/ERC1155Token.json';
22
+
24
23
  import { AddressBook, ContractName } from './types';
25
24
  import { Contract, ethers, providers, Signer } from 'ethers';
26
25
  import { JsonFragment } from '@ethersproject/abi';
@@ -36,23 +35,14 @@ export const ERC1155Abi = ERC1155Artifact.abi;
36
35
 
37
36
  // Make sure ContractName in ./types includes all of these keys.
38
37
  export const ADDRESSES: AddressBook = {
39
- // Outpost/Stake entrypoint
40
- Stake: '0xEeaCBa95852324eAc63fE2711aFe0283adf3bC93', // TODO
41
-
42
- // liqETH protocol suite
43
- DepositManager: '0xDepositManagerAddress',
44
- LiqEth: '0xLiqEthTokenAddress',
45
- LiqEthMint: '0xLiqEthMintAddress',
46
- LiqEthBurn: '0xLiqEthBurnAddress',
47
- LiqEthTreasury: '0xLiqEthTreasuryAddress',
48
- LiqEthCommon: '0xLiqEthCommonAddress',
49
- RewardsERC20: '0xRewardsErc20Address',
50
- ValidatorBalanceVerifier: '0xValidatorBalanceVerifierAddress',
51
- Yield: '0xYieldAddress',
52
- Accounting: '0xAccountingAddress',
53
- StakingModule: '0xStakingModuleAddress',
54
- WithdrawalQueue: '0xWithdrawalQueueAddress',
55
- WithdrawalVault: '0xWithdrawalVaultAddress',
38
+ Accounting: "0xd51CC479c25dc7Cd23f568Ef5c1AdE1671a4D15b",
39
+ DepositManager: "0x2249D309f086363ABF5057Ae7f8057279162786B",
40
+ LiqEth: "0xd5bd3DC2fD86e917A46f7571708aBB88CbfCc197",
41
+ LiqEthMint: "0xdBAa1539eB7b80C29d825FCda76c0d7F8F0E6cFB",
42
+ LiqEthBurn: "0x02e0A02fE2311FAd661677B7117FDdc801c1216b",
43
+ StakingModule: "0x87047291c3b0D55A551C97B9194A02E1D84e06A9",
44
+ WithdrawalQueue: "0x7781368720294fE0bB6D97F14fE2E9275fFED071",
45
+ WithdrawalVault: "0x24457626938d4132556005ecA4d9e6F24F85297E",
56
46
  };
57
47
 
58
48
  export type Contracts<T extends string = ContractName> = Record<T, ContractConfig>;
@@ -67,75 +57,50 @@ export type ContractConfig = {
67
57
  // -----------------------------------------------------------------------------
68
58
 
69
59
  export const CONTRACTS: Contracts<ContractName> = {
70
- // Outpost/Stake (wire ABI when available)
71
- Stake: { address: ADDRESSES.Stake, abi: undefined as any }, // TODO: Stake artifact
72
-
73
- // liqETH suite
60
+ Accounting: {
61
+ address: ADDRESSES.Accounting,
62
+ abi: AccountingArtifact.abi as JsonFragment[],
63
+ },
74
64
  LiqEth: {
75
65
  address: ADDRESSES.LiqEth,
76
- abi: undefined as any,
77
- // abi: LiqEthArtifact.abi as JsonFragment[],
66
+ abi: LiqEthArtifact.abi as JsonFragment[],
78
67
  },
79
68
  DepositManager: {
80
69
  address: ADDRESSES.DepositManager,
81
- abi: undefined as any,
82
- // abi: DepositManagerArtifact.abi as JsonFragment[],
70
+ abi: DepositManagerArtifact.abi as JsonFragment[],
83
71
  },
84
72
  LiqEthMint: {
85
73
  address: ADDRESSES.LiqEthMint,
86
- abi: undefined as any,
87
- // abi: LiqEthMintArtifact.abi as JsonFragment[],
74
+ abi: LiqEthMintArtifact.abi as JsonFragment[],
88
75
  },
89
76
  LiqEthBurn: {
90
77
  address: ADDRESSES.LiqEthBurn,
91
- abi: undefined as any,
92
- // abi: LiqEthBurnArtifact.abi as JsonFragment[],
93
- },
94
- LiqEthTreasury: {
95
- address: ADDRESSES.LiqEthTreasury,
96
- abi: undefined as any,
97
- // abi: LiqEthTreasuryArtifact.abi as JsonFragment[],
98
- },
99
- LiqEthCommon: {
100
- address: ADDRESSES.LiqEthCommon,
101
- abi: undefined as any,
102
- // abi: LiqEthCommonArtifact.abi as JsonFragment[],
103
- },
104
- RewardsERC20: {
105
- address: ADDRESSES.RewardsERC20,
106
- abi: undefined as any,
107
- // abi: RewardsERC20Artifact.abi as JsonFragment[],
108
- },
109
- ValidatorBalanceVerifier: {
110
- address: ADDRESSES.ValidatorBalanceVerifier,
111
- abi: undefined as any,
112
- // abi: ValidatorBalanceVerifierArtifact.abi as JsonFragment[],
113
- },
114
- Yield: {
115
- address: ADDRESSES.Yield,
116
- abi: undefined as any,
117
- // abi: YieldArtifact.abi as JsonFragment[],
118
- },
119
- Accounting: {
120
- address: ADDRESSES.Accounting,
121
- abi: undefined as any,
122
- // abi: AccountingArtifact.abi as JsonFragment[],
78
+ abi: LiqEthBurnArtifact.abi as JsonFragment[],
123
79
  },
80
+ // RewardsERC20: {
81
+ // address: ADDRESSES.RewardsERC20,
82
+ // abi: RewardsERC20Artifact.abi as JsonFragment[],
83
+ // },
124
84
  StakingModule: {
125
85
  address: ADDRESSES.StakingModule,
126
- abi: undefined as any,
127
- // abi: StakingModuleArtifact.abi as JsonFragment[],
86
+ abi: StakingModuleArtifact.abi as JsonFragment[],
128
87
  },
88
+ // ValidatorBalance: {
89
+ // address: ADDRESSES.ValidatorBalance,
90
+ // abi: ValidatorBalanceArtifact.abi as JsonFragment[],
91
+ // },
129
92
  WithdrawalQueue: {
130
93
  address: ADDRESSES.WithdrawalQueue,
131
- abi: undefined as any,
132
- // abi: WithdrawalQueueArtifact.abi as JsonFragment[],
94
+ abi: WithdrawalQueueArtifact.abi as JsonFragment[],
133
95
  },
134
96
  WithdrawalVault: {
135
97
  address: ADDRESSES.WithdrawalVault,
136
- abi: undefined as any,
137
- // abi: WithdrawalVaultArtifact.abi as JsonFragment[],
98
+ abi: WithdrawalVaultArtifact.abi as JsonFragment[],
138
99
  },
100
+ // Yield: {
101
+ // address: ADDRESSES.Yield,
102
+ // abi: YieldArtifact.abi as JsonFragment[],
103
+ // },
139
104
  };
140
105
 
141
106
  export interface ContractOptions {
@@ -219,19 +184,17 @@ export class EthereumContractService {
219
184
  ERC1155Artifact,
220
185
 
221
186
  // liqETH suite
222
- // DepositManagerArtifact,
223
- // LiqEthArtifact,
224
- // LiqEthMintArtifact,
225
- // LiqEthBurnArtifact,
226
- // LiqEthTreasuryArtifact,
227
- // LiqEthCommonArtifact,
187
+ AccountingArtifact,
188
+ DepositManagerArtifact,
189
+ LiqEthArtifact,
190
+ LiqEthBurnArtifact,
191
+ LiqEthMintArtifact,
228
192
  // RewardsERC20Artifact,
229
- // ValidatorBalanceVerifierArtifact,
193
+ StakingModuleArtifact,
194
+ // ValidatorBalanceArtifact,
195
+ WithdrawalQueueArtifact,
196
+ WithdrawalVaultArtifact,
230
197
  // YieldArtifact,
231
- // AccountingArtifact,
232
- // StakingModuleArtifact,
233
- // WithdrawalQueueArtifact,
234
- // WithdrawalVaultArtifact,
235
198
  ];
236
199
 
237
200
  allArtifacts.forEach(artifact => {
@@ -6,7 +6,6 @@ import { PublicKey as WirePubKey } from '@wireio/core';
6
6
  import { ERC20Abi, EthereumContractService } from './contract'; // TODO replace with staking contract ABI
7
7
  import { DepositEvent, DepositResult } from './types';
8
8
 
9
- // TODO extend to implement ISTAKINGCLIENT
10
9
  export class EthereumStakingClient implements IStakingClient {
11
10
  public readonly pubKey: WirePubKey;
12
11
  private readonly provider: ethers.providers.Web3Provider;
@@ -17,17 +16,20 @@ export class EthereumStakingClient implements IStakingClient {
17
16
  get network() { return this.config.network; }
18
17
 
19
18
  constructor(private config: StakerConfig) {
20
- if (!ethers.providers.Web3Provider.isProvider(config.provider)) {
21
- throw new Error('Expected a Web3Provider for Ethereum');
22
- }
23
- this.provider = config.provider as ethers.providers.Web3Provider;
24
- this.signer = this.provider.getSigner();
25
- this.pubKey = config.pubKey as WirePubKey;
26
-
27
- this.contractService = new EthereumContractService({
28
- provider: this.provider,
29
- signer: this.signer,
30
- });
19
+ try {
20
+ this.provider = config.provider as ethers.providers.Web3Provider;
21
+ this.signer = this.provider.getSigner();
22
+ this.pubKey = config.pubKey as WirePubKey;
23
+
24
+ this.contractService = new EthereumContractService({
25
+ provider: this.provider,
26
+ signer: this.signer,
27
+ });
28
+ }
29
+ catch (error) {
30
+ // console.error('Error initializing EthereumStakingClient:', error);
31
+ throw error;
32
+ }
31
33
  }
32
34
 
33
35
  // ---------------------------------------------------------------------
@@ -50,6 +52,8 @@ export class EthereumStakingClient implements IStakingClient {
50
52
  // If/when you extend the interface, you can surface more here.
51
53
  return result.txHash;
52
54
  }
55
+
56
+
53
57
  /**
54
58
  * Simulate a deposit via callStatic.
55
59
  *
@@ -108,23 +112,6 @@ export class EthereumStakingClient implements IStakingClient {
108
112
  };
109
113
  }
110
114
 
111
- /**
112
- * Build, sign, and submit a single transaction that:
113
- * - Corrects other users (if needed) to free available balance, then
114
- * - Registers the caller’s untracked liqSOL.
115
- *
116
- * @param amount Optional: register a smaller amount than your full untracked balance.
117
- * @returns signature string
118
- */
119
- async register(amount?: bigint): Promise<string> {
120
- try {
121
- return 'Not implemented yet for Ethereum';
122
- } catch (error) {
123
- console.error('Error in register:', error);
124
- throw error;
125
- }
126
- }
127
-
128
115
  /**
129
116
  * Resolve the user's ETH + liqETH balances.
130
117
  *
@@ -134,59 +121,47 @@ export class EthereumStakingClient implements IStakingClient {
134
121
  */
135
122
  async getPortfolio(): Promise<Portfolio> {
136
123
  const walletAddress = await this.signer.getAddress();
137
-
124
+ // console.log('getPortfolio() wallet address', walletAddress)
138
125
  // 1) Native ETH balance
139
126
  const nativeBalance = await this.provider.getBalance(walletAddress);
140
- const nativeDecimals =
141
- this.network?.nativeCurrency?.decimals ?? 18;
142
- const nativeSymbol =
143
- this.network?.nativeCurrency?.symbol ?? 'ETH';
144
-
145
- // 2) liqETH ERC-20 balance (actual)
146
- const actualBalance: ethers.BigNumber = await this.contract.LiqEth.balanceOf(walletAddress);
147
- const liqDecimals = 18; // if you want, read decimals() once and cache
148
- const liqSymbol = 'liqETH';
127
+ // console.log('nativeBalance', nativeBalance);
128
+ const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
129
+ const nativeSymbol = this.network?.nativeCurrency?.symbol ?? 'ETH';
149
130
 
150
- // 3) Protocol "tracked" balance (Accounting)
151
- let trackedBalance: ethers.BigNumber = actualBalance;
131
+
152
132
 
153
- try {
154
- // Adjust this to your real view method:
155
- // e.g. function getUserBalance(address user)
156
- const result = await this.contract.Accounting.getUserBalance(walletAddress);
157
-
158
- // Support either struct or plain uint256
159
- if (result && typeof result === 'object' && 'amount' in result) {
160
- trackedBalance = result.amount;
161
- // if result.decimals exists and differs, override liqDecimals if desired
162
- } else if (result != null) {
163
- trackedBalance = result;
164
- }
165
- } catch (err) {
166
- console.warn(
167
- '[EthereumStakingClient] getPortfolio: Accounting view unavailable, using actual balance as tracked.',
168
- err
169
- );
170
- trackedBalance = actualBalance;
171
- }
133
+ // 2) liqETH ERC-20 balance (actual)
134
+ const liqBalance: ethers.BigNumber = await this.contract.LiqEth.balanceOf(walletAddress);
135
+ // console.log('liqBalance', liqBalance);
136
+
137
+ const liqDecimals = this.network?.nativeCurrency?.decimals ?? 18;
138
+ const liqSymbol = 'Liq' + (this.network?.nativeCurrency?.symbol ?? 'ETH');
172
139
 
173
- return {
140
+ const portfolio: Portfolio = {
174
141
  native: {
175
142
  amount: nativeBalance,
176
143
  decimals: nativeDecimals,
177
144
  symbol: nativeSymbol,
178
145
  },
179
- actual: {
180
- amount: actualBalance,
146
+ liq: {
147
+ amount: liqBalance,
181
148
  decimals: liqDecimals,
182
149
  symbol: liqSymbol,
183
150
  },
184
151
  tracked: {
185
- amount: trackedBalance,
152
+ amount: liqBalance,
186
153
  decimals: liqDecimals,
187
154
  symbol: liqSymbol,
188
155
  },
189
- };
156
+ staked: { // TODO fetch staked balance from outpost
157
+ amount: BigNumber.from(0),
158
+ decimals: liqDecimals,
159
+ symbol: liqSymbol,
160
+ },
161
+ chainID: this.network.chainId
162
+ }
163
+ // console.log('ETH PORTFOLIO', portfolio);
164
+ return portfolio;
190
165
  }
191
166
 
192
167
  // TODO: implement withdraw, claimRewards, etc.
@@ -1,20 +1,17 @@
1
1
  import { BigNumber, ethers } from 'ethers';
2
2
 
3
3
  export const CONTRACT_NAMES = [
4
- 'Stake',
5
- 'LiqEth',
4
+ 'Accounting',
6
5
  'DepositManager',
7
- 'LiqEthMint',
6
+ 'LiqEth',
8
7
  'LiqEthBurn',
9
- 'LiqEthTreasury',
10
- 'LiqEthCommon',
11
- 'RewardsERC20',
12
- 'ValidatorBalanceVerifier',
13
- 'Yield',
14
- 'Accounting',
8
+ 'LiqEthMint',
9
+ // 'RewardsERC20',
15
10
  'StakingModule',
11
+ // 'ValidatorBalance',
16
12
  'WithdrawalQueue',
17
13
  'WithdrawalVault',
14
+ // 'Yield',
18
15
  ] as const;
19
16
 
20
17
  export type ContractName = typeof CONTRACT_NAMES[number];
@@ -34,13 +34,8 @@ export class SolanaStakingClient implements IStakingClient {
34
34
  private distributionClient: DistributionClient;
35
35
  private leaderboardClient: LeaderboardClient;
36
36
 
37
- get solPubKey(): SolPubKey {
38
- return new SolPubKey(this.pubKey.data.array);
39
- }
40
-
41
- get network() {
42
- return this.config.network;
43
- }
37
+ get solPubKey(): SolPubKey { return new SolPubKey(this.pubKey.data.array); }
38
+ get network() { return this.config.network; }
44
39
 
45
40
  constructor(private config: StakerConfig) {
46
41
  const adapter = config.provider as BaseSignerWalletAdapter;
@@ -101,6 +96,7 @@ export class SolanaStakingClient implements IStakingClient {
101
96
  TOKEN_2022_PROGRAM_ID,
102
97
  );
103
98
 
99
+ // Fetch balances and user record in parallel
104
100
  const [nativeLamports, actualBalResp, userRecord] = await Promise.all([
105
101
  this.connection.getBalance(user),
106
102
  this.connection.getTokenAccountBalance(userLiqsolAta).catch(() => null),
@@ -110,34 +106,42 @@ export class SolanaStakingClient implements IStakingClient {
110
106
  const actualAmountStr = actualBalResp?.value?.amount ?? '0';
111
107
  const actualDecimals = actualBalResp?.value?.decimals ?? 9;
112
108
 
113
- const trackedAmountStr = userRecord?.trackedBalance
114
- ? userRecord.trackedBalance.toString()
115
- : '0';
109
+ const trackedAmountStr = userRecord?.trackedBalance ? userRecord.trackedBalance.toString() : '0';
116
110
  const trackedDecimals = actualDecimals;
117
111
 
112
+ const nativeSymbol = 'SOL';
113
+ const liqSymbol = 'LiqSOL';
114
+
118
115
  const portfolio: Portfolio = {
119
116
  native: {
120
- symbol: 'SOL',
121
- decimals: 9,
122
117
  amount: BigInt(nativeLamports),
118
+ symbol: nativeSymbol,
119
+ decimals: 9,
123
120
  },
124
- actual: {
125
- symbol: 'LiqSOL',
126
- decimals: actualDecimals,
121
+ liq: {
127
122
  amount: BigInt(actualAmountStr),
123
+ symbol: liqSymbol,
124
+ decimals: actualDecimals,
128
125
  },
129
- tracked: {
130
- symbol: 'LiqSOL',
131
- decimals: trackedDecimals,
126
+ staked: { // TODO: fetch staked balance from outpost
127
+ amount: BigInt(0),
128
+ symbol: liqSymbol,
129
+ decimals: actualDecimals,
130
+ },
131
+ tracked: { // SOL ONLY
132
132
  amount: BigInt(trackedAmountStr),
133
+ symbol: liqSymbol,
134
+ decimals: trackedDecimals,
133
135
  },
134
136
  extras: {
135
137
  userLiqsolAta: userLiqsolAta.toBase58(),
136
138
  reservePoolPDA: reservePoolPDA.toBase58(),
137
139
  vaultPDA: vaultPDA.toBase58(),
138
140
  },
141
+ chainID: this.network.chainId
139
142
  };
140
143
 
144
+ // console.log('SOL PORTFOLIO', portfolio);
141
145
  return portfolio;
142
146
  }
143
147
  catch (error) {
@@ -159,6 +163,19 @@ export class SolanaStakingClient implements IStakingClient {
159
163
  // TODO: wire to pay-rate math once we finalize protocol fee API
160
164
  }
161
165
 
166
+ /**
167
+ * Deposit funds into the staking pool.
168
+ * @param lamports The amount to deposit (in lamports).
169
+ * @returns The transaction signature.
170
+ */
171
+ async deposit(lamports: number): Promise<string> {
172
+ const { transaction } = await this.depositClient.buildDepositTx(this.solPubKey, lamports);
173
+ const { tx, blockhash, lastValidBlockHeight } = await this.prepareTx(transaction);
174
+ const signed = await this.signTransaction(tx);
175
+ const result = await this.sendAndConfirmHttp(signed, { blockhash, lastValidBlockHeight });
176
+ return result.signature;
177
+ }
178
+
162
179
  /**
163
180
  * Build, sign, and submit a single transaction that:
164
181
  * - Corrects other users (if needed) to free available balance, then
@@ -167,7 +184,7 @@ export class SolanaStakingClient implements IStakingClient {
167
184
  * @param amount Optional: register a smaller amount than your full untracked balance.
168
185
  * @returns signature string
169
186
  */
170
- async register(amount?: bigint): Promise<string> {
187
+ async correctBalance(amount?: bigint): Promise<string> {
171
188
  try {
172
189
  const build = await this.distributionClient.buildCorrectRegisterTx({ amount });
173
190
  if (!build.canSucceed || !build.transaction) {
@@ -194,19 +211,6 @@ export class SolanaStakingClient implements IStakingClient {
194
211
  }
195
212
  }
196
213
 
197
- /**
198
- * Deposit funds into the staking pool.
199
- * @param lamports The amount to deposit (in lamports).
200
- * @returns The transaction signature.
201
- */
202
- async deposit(lamports: number): Promise<string> {
203
- const { transaction } = await this.depositClient.buildDepositTx(this.solPubKey, lamports);
204
- const { tx, blockhash, lastValidBlockHeight } = await this.prepareTx(transaction);
205
- const signed = await this.signTransaction(tx);
206
- const result = await this.sendAndConfirmHttp(signed, { blockhash, lastValidBlockHeight });
207
- return result.signature;
208
- }
209
-
210
214
  private async sendAndConfirmHttp(
211
215
  signed: SolanaTransaction,
212
216
  ctx: { blockhash: string; lastValidBlockHeight: number },
@@ -32,6 +32,8 @@ export class Staker {
32
32
  if (!config) throw new Error('StakerConfig is required');
33
33
  if (!Array.isArray(config)) config = [config];
34
34
 
35
+ // console.log('STAKER INIT', config);
36
+
35
37
  config.forEach((cfg) => {
36
38
  switch (cfg.network.chainId) {
37
39
  case SolChainID.WireTestnet:
@@ -41,15 +43,16 @@ export class Staker {
41
43
  case EvmChainID.Hoodi:
42
44
  this.clients.set(EvmChainID.Hoodi, new EthereumStakingClient(cfg));
43
45
  break;
46
+
44
47
  default:
45
- // console.log(`No staking client available for chain ${cfg.network.chainId}`);
46
- // throw new Error(`Unsupported network curve: ${cfg.network.name}`);
48
+ console.log(`No staking client available for chain ${cfg.network.chainId}`);
49
+ throw new Error(`Unsupported network curve: ${cfg.network.name}`);
47
50
  }
48
51
  });
49
52
 
50
53
  this.selectedChainID = selectedChainID;
51
54
  }
52
-
55
+
53
56
  /**
54
57
  * Select a chain. Returns true if a client exists for it, false otherwise.
55
58
  * (We still record the selectedChainID so the UI can reflect the chosen chain.)
@@ -2,18 +2,18 @@
2
2
 
3
3
  import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base';
4
4
  import { PublicKey as SolPubKey } from '@solana/web3.js';
5
- import { ExternalNetwork, PublicKey } from '@wireio/core';
6
- import { BigNumberish, ethers } from 'ethers';
5
+ import { ChainID, ExternalNetwork, PublicKey } from '@wireio/core';
6
+ import { BigNumber, BigNumberish, ethers } from 'ethers';
7
7
 
8
8
  export interface IStakingClient {
9
9
  pubKey: PublicKey;
10
10
  network: ExternalNetwork;
11
11
 
12
12
  /** Amount is in the chain's smallest unit (lamports/wei, etc.) */
13
- deposit(amount: number): Promise<string>;
13
+ deposit(amount: number | BigNumber): Promise<string>;
14
14
 
15
15
  /** Register any untracked LIQ staked tokens */
16
- register(): Promise<string>;
16
+ // register(): Promise<string>;
17
17
 
18
18
  /** Fetch the portfolio for the LIQ stake user */
19
19
  getPortfolio(): Promise<Portfolio>;
@@ -26,14 +26,19 @@ export type StakerConfig = {
26
26
  }
27
27
 
28
28
  export interface Portfolio {
29
- /** Native SOL balance on chain */
29
+ /** Native balance on chain: ETH, SOL */
30
30
  native: BalanceView;
31
- /** Actual liquid SOL balance from ATA */
32
- actual: BalanceView;
33
- /** Tracked liquid SOL balance from distribution program */
34
- tracked: BalanceView;
31
+ /** Actual Liquid balance of LiqETH, LiqSOL*/
32
+ liq: BalanceView;
33
+ /** Outpost Staked balance */
34
+ staked: BalanceView
35
+ /** SOL ONLY!
36
+ * Tracked liqSOL balance from distribution program */
37
+ tracked?: BalanceView;
35
38
  /** Extra PDAs and account addresses */
36
39
  extras?: Record<string, any>;
40
+ /** Chain ID of the network for which this portfolio is from */
41
+ chainID: ChainID;
37
42
  }
38
43
 
39
44
  export type BalanceView = {