@underscore-finance/sdk 0.3.2 → 0.3.4

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 (127) hide show
  1. package/dist/contracts/AddyRegistry.d.ts +3 -1
  2. package/dist/contracts/AddyRegistry.d.ts.map +1 -1
  3. package/dist/contracts/AddyRegistry.js +50 -48
  4. package/dist/contracts/AddyRegistry_v1.d.ts +2 -0
  5. package/dist/contracts/AddyRegistry_v1.d.ts.map +1 -1
  6. package/dist/contracts/AddyRegistry_v1.js +2 -0
  7. package/dist/contracts/AddyRegistry_v2.d.ts +2 -0
  8. package/dist/contracts/AddyRegistry_v2.d.ts.map +1 -1
  9. package/dist/contracts/AddyRegistry_v2.js +2 -0
  10. package/dist/contracts/Agent.d.ts +3 -1
  11. package/dist/contracts/Agent.d.ts.map +1 -1
  12. package/dist/contracts/Agent.js +33 -31
  13. package/dist/contracts/AgentFactory.d.ts +3 -1
  14. package/dist/contracts/AgentFactory.d.ts.map +1 -1
  15. package/dist/contracts/AgentFactory.js +83 -81
  16. package/dist/contracts/AgentFactory_v1.d.ts +2 -0
  17. package/dist/contracts/AgentFactory_v1.d.ts.map +1 -1
  18. package/dist/contracts/AgentFactory_v1.js +2 -0
  19. package/dist/contracts/AgentFactory_v2.d.ts +2 -0
  20. package/dist/contracts/AgentFactory_v2.d.ts.map +1 -1
  21. package/dist/contracts/AgentFactory_v2.js +2 -0
  22. package/dist/contracts/Agent_v1.d.ts +3 -1
  23. package/dist/contracts/Agent_v1.d.ts.map +1 -1
  24. package/dist/contracts/Agent_v1.js +33 -31
  25. package/dist/contracts/Agent_v2.d.ts +3 -1
  26. package/dist/contracts/Agent_v2.d.ts.map +1 -1
  27. package/dist/contracts/Agent_v2.js +33 -31
  28. package/dist/contracts/ChainlinkFeeds.d.ts +2 -0
  29. package/dist/contracts/ChainlinkFeeds.d.ts.map +1 -1
  30. package/dist/contracts/ChainlinkFeeds.js +2 -0
  31. package/dist/contracts/ERC20.d.ts +3 -1
  32. package/dist/contracts/ERC20.d.ts.map +1 -1
  33. package/dist/contracts/ERC20.js +15 -13
  34. package/dist/contracts/LegoAaveV3.d.ts +2 -0
  35. package/dist/contracts/LegoAaveV3.d.ts.map +1 -1
  36. package/dist/contracts/LegoAaveV3.js +2 -0
  37. package/dist/contracts/LegoAeroClassic.d.ts +2 -0
  38. package/dist/contracts/LegoAeroClassic.d.ts.map +1 -1
  39. package/dist/contracts/LegoAeroClassic.js +2 -0
  40. package/dist/contracts/LegoAeroSlipstream.d.ts +2 -0
  41. package/dist/contracts/LegoAeroSlipstream.d.ts.map +1 -1
  42. package/dist/contracts/LegoAeroSlipstream.js +2 -0
  43. package/dist/contracts/LegoCommon.d.ts +3 -1
  44. package/dist/contracts/LegoCommon.d.ts.map +1 -1
  45. package/dist/contracts/LegoCommon.js +10 -8
  46. package/dist/contracts/LegoCompoundV3.d.ts +2 -0
  47. package/dist/contracts/LegoCompoundV3.d.ts.map +1 -1
  48. package/dist/contracts/LegoCompoundV3.js +2 -0
  49. package/dist/contracts/LegoCredit.d.ts +3 -1
  50. package/dist/contracts/LegoCredit.d.ts.map +1 -1
  51. package/dist/contracts/LegoCredit.js +5 -3
  52. package/dist/contracts/LegoCurve.d.ts +2 -0
  53. package/dist/contracts/LegoCurve.d.ts.map +1 -1
  54. package/dist/contracts/LegoCurve.js +2 -0
  55. package/dist/contracts/LegoDex.d.ts +3 -1
  56. package/dist/contracts/LegoDex.d.ts.map +1 -1
  57. package/dist/contracts/LegoDex.js +16 -14
  58. package/dist/contracts/LegoEuler.d.ts +2 -0
  59. package/dist/contracts/LegoEuler.d.ts.map +1 -1
  60. package/dist/contracts/LegoEuler.js +2 -0
  61. package/dist/contracts/LegoFluid.d.ts +2 -0
  62. package/dist/contracts/LegoFluid.d.ts.map +1 -1
  63. package/dist/contracts/LegoFluid.js +2 -0
  64. package/dist/contracts/LegoHelper.d.ts +3 -1
  65. package/dist/contracts/LegoHelper.d.ts.map +1 -1
  66. package/dist/contracts/LegoHelper.js +56 -54
  67. package/dist/contracts/LegoMoonwell.d.ts +2 -0
  68. package/dist/contracts/LegoMoonwell.d.ts.map +1 -1
  69. package/dist/contracts/LegoMoonwell.js +2 -0
  70. package/dist/contracts/LegoMorpho.d.ts +2 -0
  71. package/dist/contracts/LegoMorpho.d.ts.map +1 -1
  72. package/dist/contracts/LegoMorpho.js +2 -0
  73. package/dist/contracts/LegoRegistry.d.ts +3 -1
  74. package/dist/contracts/LegoRegistry.d.ts.map +1 -1
  75. package/dist/contracts/LegoRegistry.js +50 -48
  76. package/dist/contracts/LegoSky.d.ts +2 -0
  77. package/dist/contracts/LegoSky.d.ts.map +1 -1
  78. package/dist/contracts/LegoSky.js +2 -0
  79. package/dist/contracts/LegoUniswapV2.d.ts +2 -0
  80. package/dist/contracts/LegoUniswapV2.d.ts.map +1 -1
  81. package/dist/contracts/LegoUniswapV2.js +2 -0
  82. package/dist/contracts/LegoUniswapV3.d.ts +2 -0
  83. package/dist/contracts/LegoUniswapV3.d.ts.map +1 -1
  84. package/dist/contracts/LegoUniswapV3.js +2 -0
  85. package/dist/contracts/LegoYield.d.ts +3 -1
  86. package/dist/contracts/LegoYield.d.ts.map +1 -1
  87. package/dist/contracts/LegoYield.js +15 -13
  88. package/dist/contracts/OracleParser.d.ts +3 -1
  89. package/dist/contracts/OracleParser.d.ts.map +1 -1
  90. package/dist/contracts/OracleParser.js +9 -7
  91. package/dist/contracts/OracleRegistry.d.ts +3 -1
  92. package/dist/contracts/OracleRegistry.d.ts.map +1 -1
  93. package/dist/contracts/OracleRegistry.js +55 -53
  94. package/dist/contracts/PriceSheets.d.ts +3 -1
  95. package/dist/contracts/PriceSheets.d.ts.map +1 -1
  96. package/dist/contracts/PriceSheets.js +47 -45
  97. package/dist/contracts/PythFeeds.d.ts +2 -0
  98. package/dist/contracts/PythFeeds.d.ts.map +1 -1
  99. package/dist/contracts/PythFeeds.js +2 -0
  100. package/dist/contracts/StorkFeeds.d.ts +2 -0
  101. package/dist/contracts/StorkFeeds.d.ts.map +1 -1
  102. package/dist/contracts/StorkFeeds.js +2 -0
  103. package/dist/contracts/UserWallet.d.ts +3 -1
  104. package/dist/contracts/UserWallet.d.ts.map +1 -1
  105. package/dist/contracts/UserWallet.js +26 -24
  106. package/dist/contracts/UserWalletConfig.d.ts +3 -1
  107. package/dist/contracts/UserWalletConfig.d.ts.map +1 -1
  108. package/dist/contracts/UserWalletConfig.js +65 -63
  109. package/dist/contracts/UserWalletConfig_v1.d.ts +3 -1
  110. package/dist/contracts/UserWalletConfig_v1.d.ts.map +1 -1
  111. package/dist/contracts/UserWalletConfig_v1.js +43 -41
  112. package/dist/contracts/UserWalletConfig_v2.d.ts +3 -1
  113. package/dist/contracts/UserWalletConfig_v2.d.ts.map +1 -1
  114. package/dist/contracts/UserWalletConfig_v2.js +47 -45
  115. package/dist/contracts/UserWallet_v1.d.ts +3 -1
  116. package/dist/contracts/UserWallet_v1.d.ts.map +1 -1
  117. package/dist/contracts/UserWallet_v1.js +26 -24
  118. package/dist/contracts/UserWallet_v2.d.ts +3 -1
  119. package/dist/contracts/UserWallet_v2.d.ts.map +1 -1
  120. package/dist/contracts/UserWallet_v2.js +24 -22
  121. package/dist/contracts/sdk.d.ts +6 -6
  122. package/dist/contracts/sdk.d.ts.map +1 -1
  123. package/dist/contracts/sdk.js +6 -6
  124. package/dist/index.d.ts +397 -26
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +72 -14
  127. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,18 +1,32 @@
1
+ import { iteratorQuery, query } from '@dappql/async';
1
2
  import { createPublicClient, http } from 'viem';
2
- import { base } from 'viem/chains';
3
+ import { base, baseSepolia } from 'viem/chains';
4
+ import * as CONTRACTS from './contracts/index.js';
3
5
  import * as LegoHelper from './contracts/LegoHelper.js';
4
6
  import createSdk from './contracts/sdk.js';
5
7
  export * from './contracts/index.js';
8
+ const TESTNET_ADDRESSES = {
9
+ AddyRegistry: '0xa89a59E14333187829528C50eBAaE6EC12Bae95d',
10
+ AgentFactory: '0x50d08c554b0F7F4784B7108103e586eccb522b8E',
11
+ UserWalletTemplate: '0x5081a0ff1F3518aE7D3c6E5106CC820EB5d472a5',
12
+ UserWalletConfigTemplate: '0xC12152418FDF2daE2A45C3D07AdFf9f6f1249BbA',
13
+ AgentTemplate: '0xfd1255e086b0E045EfBFa9E3e99aE9A450BDc486',
14
+ LegoRegistry: '0xf6a8bE55c84b94Fe071575EF52F095A23c282eea',
15
+ OracleRegistry: '0x2c794b3864480fAfF791cD46400E061f818cE42f',
16
+ PriceSheets: '0x155d0ECd672D7a1050d34eC0a1006d67823C3123',
17
+ LegoHelper: '0x98dD9D8591D826E285052f23F450c8d702f07a18',
18
+ };
6
19
  class Underscore {
7
20
  constructor(config) {
8
21
  this.publicClient =
9
22
  config?.publicClient ||
10
23
  createPublicClient({
11
- chain: base,
24
+ chain: config?.isTestnet ? baseSepolia : base,
12
25
  transport: http(config?.rpcUrl),
13
26
  });
14
27
  this.walletClient = config?.walletClient;
15
28
  this.contracts = createSdk(this.publicClient, this.walletClient);
29
+ this.isTestnet = config?.isTestnet ?? false;
16
30
  }
17
31
  setWalletClient(walletClient) {
18
32
  this.walletClient = walletClient;
@@ -42,47 +56,71 @@ class Underscore {
42
56
  });
43
57
  return instructions.result;
44
58
  }
45
- get Registry() {
46
- return this.contracts.AddyRegistry;
59
+ get AddyRegistry() {
60
+ const deployAddress = this.isTestnet ? TESTNET_ADDRESSES.AddyRegistry : CONTRACTS.AddyRegistry.deployAddress;
61
+ return {
62
+ ...this.contracts.AddyRegistry(deployAddress),
63
+ deployAddress,
64
+ };
47
65
  }
48
66
  /**
49
67
  * @deprecated Use `Registry` instead. This version is for legacy compatibility.
50
68
  */
51
- get Registry_v1() {
69
+ get AddyRegistry_v1() {
52
70
  return this.contracts.AddyRegistry_v1;
53
71
  }
54
72
  /**
55
73
  * @deprecated Use `Registry` instead. This version is for legacy compatibility.
56
74
  */
57
- get Registry_v2() {
75
+ get AddyRegistry_v2() {
58
76
  return this.contracts.AddyRegistry_v2;
59
77
  }
60
- get Factory() {
61
- return this.contracts.AgentFactory;
78
+ get AgentFactory() {
79
+ const deployAddress = this.isTestnet ? TESTNET_ADDRESSES.AgentFactory : CONTRACTS.AgentFactory.deployAddress;
80
+ return {
81
+ ...this.contracts.AgentFactory(deployAddress),
82
+ deployAddress,
83
+ };
62
84
  }
63
85
  /**
64
86
  * @deprecated Use `Factory` instead. This version is for legacy compatibility.
65
87
  */
66
- get Factory_v2() {
88
+ get AgentFactory_v2() {
67
89
  return this.contracts.AgentFactory_v2;
68
90
  }
69
91
  /**
70
92
  * @deprecated Use `Factory` instead. This version is for legacy compatibility.
71
93
  */
72
- get Factory_v1() {
94
+ get AgentFactory_v1() {
73
95
  return this.contracts.AgentFactory_v1;
74
96
  }
75
97
  get OracleRegistry() {
76
- return this.contracts.OracleRegistry;
98
+ const deployAddress = this.isTestnet ? TESTNET_ADDRESSES.OracleRegistry : CONTRACTS.OracleRegistry.deployAddress;
99
+ return {
100
+ ...this.contracts.OracleRegistry(deployAddress),
101
+ deployAddress,
102
+ };
77
103
  }
78
104
  get LegoRegistry() {
79
- return this.contracts.LegoRegistry;
105
+ const deployAddress = this.isTestnet ? TESTNET_ADDRESSES.LegoRegistry : CONTRACTS.LegoRegistry.deployAddress;
106
+ return {
107
+ ...this.contracts.LegoRegistry(deployAddress),
108
+ deployAddress,
109
+ };
80
110
  }
81
111
  get LegoHelper() {
82
- return this.contracts.LegoHelper;
112
+ const deployAddress = this.isTestnet ? TESTNET_ADDRESSES.LegoHelper : LegoHelper.deployAddress;
113
+ return {
114
+ ...this.contracts.LegoHelper(deployAddress),
115
+ deployAddress,
116
+ };
83
117
  }
84
118
  get PriceSheets() {
85
- return this.contracts.PriceSheets;
119
+ const deployAddress = this.isTestnet ? TESTNET_ADDRESSES.PriceSheets : CONTRACTS.PriceSheets.deployAddress;
120
+ return {
121
+ ...this.contracts.PriceSheets(deployAddress),
122
+ deployAddress,
123
+ };
86
124
  }
87
125
  get Agent() {
88
126
  return { at: (address) => this.contracts.Agent(address) };
@@ -147,5 +185,25 @@ class Underscore {
147
185
  get OracleParser() {
148
186
  return { at: (address) => this.contracts.OracleParser(address) };
149
187
  }
188
+ get addressResolver() {
189
+ return (contractName) => {
190
+ if (this.isTestnet) {
191
+ const address = TESTNET_ADDRESSES[contractName];
192
+ if (!address) {
193
+ throw new Error(`Address for ${contractName} not found`);
194
+ }
195
+ return address;
196
+ }
197
+ return CONTRACTS[contractName].deployAddress;
198
+ };
199
+ }
200
+ async multicall(cb, options = {}) {
201
+ const request = cb(CONTRACTS);
202
+ return query(this.publicClient, request, options, this.addressResolver);
203
+ }
204
+ async iterate(cb, options = {}) {
205
+ const { total, getItem } = cb(CONTRACTS);
206
+ return iteratorQuery(this.publicClient, total, getItem, options, this.addressResolver);
207
+ }
150
208
  }
151
209
  export default Underscore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@underscore-finance/sdk",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "SDK for interacting with Underscore Finance Smart Contracts with TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@dappql/async": "^1.0.3",
33
+ "dappql": "^2.0.29",
33
34
  "viem": "^2.23.7"
34
35
  }
35
36
  }