@steerprotocol/sdk 1.30.8-test-algebra-plugins.2 → 1.31.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 (54) hide show
  1. package/dist/cjs/base/PoolClient.js +137 -0
  2. package/dist/cjs/base/PoolClient.js.map +1 -1
  3. package/dist/cjs/base/VaultClient.js +111 -2
  4. package/dist/cjs/base/VaultClient.js.map +1 -1
  5. package/dist/cjs/const/feeManagerContracts.js +25 -0
  6. package/dist/cjs/const/feeManagerContracts.js.map +1 -0
  7. package/dist/cjs/const/network.js +7 -0
  8. package/dist/cjs/const/network.js.map +1 -1
  9. package/dist/cjs/const/protocol.js +68 -92
  10. package/dist/cjs/const/protocol.js.map +1 -1
  11. package/dist/cjs/scripts/processDeployments.js +1 -0
  12. package/dist/cjs/scripts/processDeployments.js.map +1 -1
  13. package/dist/esm/base/PoolClient.js +137 -0
  14. package/dist/esm/base/PoolClient.js.map +1 -1
  15. package/dist/esm/base/VaultClient.js +111 -2
  16. package/dist/esm/base/VaultClient.js.map +1 -1
  17. package/dist/esm/const/feeManagerContracts.js +25 -0
  18. package/dist/esm/const/feeManagerContracts.js.map +1 -0
  19. package/dist/esm/const/network.js +7 -0
  20. package/dist/esm/const/network.js.map +1 -1
  21. package/dist/esm/const/protocol.js +68 -92
  22. package/dist/esm/const/protocol.js.map +1 -1
  23. package/dist/esm/scripts/processDeployments.js +1 -0
  24. package/dist/esm/scripts/processDeployments.js.map +1 -1
  25. package/dist/types/base/PoolClient.d.ts +22 -0
  26. package/dist/types/base/PoolClient.d.ts.map +1 -1
  27. package/dist/types/base/VaultClient.d.ts +20 -0
  28. package/dist/types/base/VaultClient.d.ts.map +1 -1
  29. package/dist/types/const/feeManagerContracts.d.ts +6 -0
  30. package/dist/types/const/feeManagerContracts.d.ts.map +1 -0
  31. package/dist/types/const/network.d.ts +1 -0
  32. package/dist/types/const/network.d.ts.map +1 -1
  33. package/dist/types/const/protocol.d.ts +4 -19
  34. package/dist/types/const/protocol.d.ts.map +1 -1
  35. package/package.json +3 -2
  36. package/src/__tests__/base/PoolClient.test.ts +355 -104
  37. package/src/__tests__/base/StakingClient.test.ts +72 -72
  38. package/src/__tests__/base/VaultClient.protocol-filter.test.ts +64 -137
  39. package/src/__tests__/base/VaultClient.test.ts +460 -60
  40. package/src/__tests__/base/vault/single-asset/calculateLimitPrice.test.ts +32 -14
  41. package/src/__tests__/base/vault/single-asset/calculateSwapAmount.test.ts +7 -4
  42. package/src/__tests__/base/vault/single-asset/estimateLpTokens.test.ts +105 -570
  43. package/src/__tests__/base/vault/single-asset/simulateSwap.test.ts +45 -66
  44. package/src/__tests__/base/vault/single-asset/singleAssetDepositClient.test.ts +178 -381
  45. package/src/__tests__/const/network.feeManager.test.ts +47 -0
  46. package/src/__tests__/fixtures/live/single-asset.fixture.json +116 -0
  47. package/src/__tests__/fixtures/live/staking-pools.fixture.json +353 -0
  48. package/src/__tests__/fixtures/live/vaults.fixture.json +5392 -0
  49. package/src/base/PoolClient.ts +200 -1
  50. package/src/base/VaultClient.ts +169 -2
  51. package/src/const/feeManagerContracts.ts +28 -0
  52. package/src/const/network.ts +10 -1
  53. package/src/const/protocol.ts +18 -39
  54. package/src/scripts/processDeployments.ts +1 -0
@@ -13,15 +13,18 @@ describe('calculateLimitPrice', () => {
13
13
 
14
14
 
15
15
 
16
- beforeAll(() => { // Create real clients for blockchain interaction
17
- publicClient = createPublicClient({chain: polygon, transport: http()});
16
+ beforeEach(() => { // Create real clients for blockchain interaction
17
+ publicClient = createPublicClient({
18
+ chain: polygon,
19
+ transport: http('https://polygon-bor-rpc.publicnode.com')
20
+ });
18
21
 
19
22
 
20
23
  // Initialize SteerClient with real clients
21
24
  });
22
25
 
23
26
  describe('successful calculations', () => {
24
- it.only('should calculate limit price for token0 → token1 swap (zeroForOne: true)', async () => {
27
+ it('should calculate limit price for token0 → token1 swap (zeroForOne: true)', async () => {
25
28
  const result = await calculateLimitPrice(publicClient, {
26
29
  pool: mockPoolAddress,
27
30
  slippageBP: 500, // 5% slippage
@@ -137,7 +140,16 @@ describe('calculateLimitPrice', () => {
137
140
  });
138
141
 
139
142
  describe('error handling', () => {
140
- it('should reject unsupported AMM types', async () => {
143
+ it('should process Algebra AMM pools when pool state is available', async () => {
144
+ publicClient.readContract = jest.fn().mockResolvedValueOnce([
145
+ BigInt('1753088363026579664086182258483316'),
146
+ 200101,
147
+ 0,
148
+ 0,
149
+ 0,
150
+ true,
151
+ ]).mockResolvedValueOnce(18);
152
+
141
153
  const result = await calculateLimitPrice(publicClient, {
142
154
  pool: mockPoolAddress,
143
155
  slippageBP: 500,
@@ -147,9 +159,8 @@ describe('calculateLimitPrice', () => {
147
159
  token1: mockToken1
148
160
  });
149
161
 
150
- expect(result.success).toBe(false);
151
- expect(result.status).toBe(500);
152
- expect(result.error).toContain('AMM type 1 not yet supported');
162
+ expect(result.success).toBe(true);
163
+ expect(result.status).toBe(200);
153
164
  });
154
165
 
155
166
  it('should handle contract read failures', async () => {
@@ -166,7 +177,7 @@ describe('calculateLimitPrice', () => {
166
177
 
167
178
  expect(result.success).toBe(false);
168
179
  expect(result.status).toBe(500);
169
- expect(result.error).toContain('Failed to calculate limit price');
180
+ expect(result.error).toContain('Contract read failed');
170
181
  });
171
182
 
172
183
  it('should handle zero slippage', async () => {
@@ -303,12 +314,19 @@ describe('calculateLimitPrice', () => {
303
314
  });
304
315
  });
305
316
 
306
- it('should reject unsupported AMM types for slot0', async () => {
317
+ it('should support Algebra slot0 reads when pool globalState exists', async () => {
318
+ publicClient.readContract = jest.fn().mockResolvedValue([
319
+ BigInt('1753088363026579664086182258483316'),
320
+ 200101,
321
+ 0,
322
+ 0,
323
+ 0,
324
+ true,
325
+ ]);
307
326
  const result = await getPoolSlot0(publicClient, mockPoolAddress, AMMType.Algebra);
308
327
 
309
- expect(result.success).toBe(false);
310
- expect(result.status).toBe(500);
311
- expect(result.error).toContain('AMM type 1 not yet supported');
328
+ expect(result.success).toBe(true);
329
+ expect(result.status).toBe(200);
312
330
  });
313
331
 
314
332
  it('should handle contract read failures for slot0', async () => {
@@ -318,7 +336,7 @@ describe('calculateLimitPrice', () => {
318
336
 
319
337
  expect(result.success).toBe(false);
320
338
  expect(result.status).toBe(500);
321
- expect(result.error).toContain('Failed to get pool slot0 data');
339
+ expect(result.error).toContain('Contract read failed');
322
340
  });
323
341
  });
324
- });
342
+ });
@@ -55,13 +55,16 @@ describe('calculateSwapAmount', () => {
55
55
  const mockContractAddress = '0x9903C4ED61A71d0d5C322097adfF752d6339F871';
56
56
 
57
57
 
58
- beforeAll(() => { // Create real clients for blockchain interaction
59
- publicClient = createPublicClient({chain: polygon, transport: http()});
58
+ beforeEach(() => { // Create real clients for blockchain interaction
59
+ publicClient = createPublicClient({
60
+ chain: polygon,
61
+ transport: http('https://polygon-bor-rpc.publicnode.com')
62
+ });
60
63
 
61
64
  // Initialize SteerClient with real clients
62
65
  });
63
66
  describe('successful calculations', () => {
64
- it.only('should calculate swap amount for token0 deposit', async () => {
67
+ it('should calculate swap amount for token0 deposit', async () => {
65
68
 
66
69
  const result = await calculateSwapAmount(publicClient, {
67
70
  depositAmount: parseEther('100000'),
@@ -198,7 +201,7 @@ describe('calculateSwapAmount', () => {
198
201
  });
199
202
 
200
203
  it('should handle invalid contract response', async () => { // Mock invalid response (not an array)
201
- publicClient.readContract = jest.fn().mockResolvedValue('invalid response');
204
+ publicClient.readContract = jest.fn().mockResolvedValue(undefined);
202
205
 
203
206
  const result = await calculateSwapAmount(publicClient, {
204
207
  depositAmount: parseEther('100'),