@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.
- package/dist/contracts/AddyRegistry.d.ts +3 -1
- package/dist/contracts/AddyRegistry.d.ts.map +1 -1
- package/dist/contracts/AddyRegistry.js +50 -48
- package/dist/contracts/AddyRegistry_v1.d.ts +2 -0
- package/dist/contracts/AddyRegistry_v1.d.ts.map +1 -1
- package/dist/contracts/AddyRegistry_v1.js +2 -0
- package/dist/contracts/AddyRegistry_v2.d.ts +2 -0
- package/dist/contracts/AddyRegistry_v2.d.ts.map +1 -1
- package/dist/contracts/AddyRegistry_v2.js +2 -0
- package/dist/contracts/Agent.d.ts +3 -1
- package/dist/contracts/Agent.d.ts.map +1 -1
- package/dist/contracts/Agent.js +33 -31
- package/dist/contracts/AgentFactory.d.ts +3 -1
- package/dist/contracts/AgentFactory.d.ts.map +1 -1
- package/dist/contracts/AgentFactory.js +83 -81
- package/dist/contracts/AgentFactory_v1.d.ts +2 -0
- package/dist/contracts/AgentFactory_v1.d.ts.map +1 -1
- package/dist/contracts/AgentFactory_v1.js +2 -0
- package/dist/contracts/AgentFactory_v2.d.ts +2 -0
- package/dist/contracts/AgentFactory_v2.d.ts.map +1 -1
- package/dist/contracts/AgentFactory_v2.js +2 -0
- package/dist/contracts/Agent_v1.d.ts +3 -1
- package/dist/contracts/Agent_v1.d.ts.map +1 -1
- package/dist/contracts/Agent_v1.js +33 -31
- package/dist/contracts/Agent_v2.d.ts +3 -1
- package/dist/contracts/Agent_v2.d.ts.map +1 -1
- package/dist/contracts/Agent_v2.js +33 -31
- package/dist/contracts/ChainlinkFeeds.d.ts +2 -0
- package/dist/contracts/ChainlinkFeeds.d.ts.map +1 -1
- package/dist/contracts/ChainlinkFeeds.js +2 -0
- package/dist/contracts/ERC20.d.ts +3 -1
- package/dist/contracts/ERC20.d.ts.map +1 -1
- package/dist/contracts/ERC20.js +15 -13
- package/dist/contracts/LegoAaveV3.d.ts +2 -0
- package/dist/contracts/LegoAaveV3.d.ts.map +1 -1
- package/dist/contracts/LegoAaveV3.js +2 -0
- package/dist/contracts/LegoAeroClassic.d.ts +2 -0
- package/dist/contracts/LegoAeroClassic.d.ts.map +1 -1
- package/dist/contracts/LegoAeroClassic.js +2 -0
- package/dist/contracts/LegoAeroSlipstream.d.ts +2 -0
- package/dist/contracts/LegoAeroSlipstream.d.ts.map +1 -1
- package/dist/contracts/LegoAeroSlipstream.js +2 -0
- package/dist/contracts/LegoCommon.d.ts +3 -1
- package/dist/contracts/LegoCommon.d.ts.map +1 -1
- package/dist/contracts/LegoCommon.js +10 -8
- package/dist/contracts/LegoCompoundV3.d.ts +2 -0
- package/dist/contracts/LegoCompoundV3.d.ts.map +1 -1
- package/dist/contracts/LegoCompoundV3.js +2 -0
- package/dist/contracts/LegoCredit.d.ts +3 -1
- package/dist/contracts/LegoCredit.d.ts.map +1 -1
- package/dist/contracts/LegoCredit.js +5 -3
- package/dist/contracts/LegoCurve.d.ts +2 -0
- package/dist/contracts/LegoCurve.d.ts.map +1 -1
- package/dist/contracts/LegoCurve.js +2 -0
- package/dist/contracts/LegoDex.d.ts +3 -1
- package/dist/contracts/LegoDex.d.ts.map +1 -1
- package/dist/contracts/LegoDex.js +16 -14
- package/dist/contracts/LegoEuler.d.ts +2 -0
- package/dist/contracts/LegoEuler.d.ts.map +1 -1
- package/dist/contracts/LegoEuler.js +2 -0
- package/dist/contracts/LegoFluid.d.ts +2 -0
- package/dist/contracts/LegoFluid.d.ts.map +1 -1
- package/dist/contracts/LegoFluid.js +2 -0
- package/dist/contracts/LegoHelper.d.ts +3 -1
- package/dist/contracts/LegoHelper.d.ts.map +1 -1
- package/dist/contracts/LegoHelper.js +56 -54
- package/dist/contracts/LegoMoonwell.d.ts +2 -0
- package/dist/contracts/LegoMoonwell.d.ts.map +1 -1
- package/dist/contracts/LegoMoonwell.js +2 -0
- package/dist/contracts/LegoMorpho.d.ts +2 -0
- package/dist/contracts/LegoMorpho.d.ts.map +1 -1
- package/dist/contracts/LegoMorpho.js +2 -0
- package/dist/contracts/LegoRegistry.d.ts +3 -1
- package/dist/contracts/LegoRegistry.d.ts.map +1 -1
- package/dist/contracts/LegoRegistry.js +50 -48
- package/dist/contracts/LegoSky.d.ts +2 -0
- package/dist/contracts/LegoSky.d.ts.map +1 -1
- package/dist/contracts/LegoSky.js +2 -0
- package/dist/contracts/LegoUniswapV2.d.ts +2 -0
- package/dist/contracts/LegoUniswapV2.d.ts.map +1 -1
- package/dist/contracts/LegoUniswapV2.js +2 -0
- package/dist/contracts/LegoUniswapV3.d.ts +2 -0
- package/dist/contracts/LegoUniswapV3.d.ts.map +1 -1
- package/dist/contracts/LegoUniswapV3.js +2 -0
- package/dist/contracts/LegoYield.d.ts +3 -1
- package/dist/contracts/LegoYield.d.ts.map +1 -1
- package/dist/contracts/LegoYield.js +15 -13
- package/dist/contracts/OracleParser.d.ts +3 -1
- package/dist/contracts/OracleParser.d.ts.map +1 -1
- package/dist/contracts/OracleParser.js +9 -7
- package/dist/contracts/OracleRegistry.d.ts +3 -1
- package/dist/contracts/OracleRegistry.d.ts.map +1 -1
- package/dist/contracts/OracleRegistry.js +55 -53
- package/dist/contracts/PriceSheets.d.ts +3 -1
- package/dist/contracts/PriceSheets.d.ts.map +1 -1
- package/dist/contracts/PriceSheets.js +47 -45
- package/dist/contracts/PythFeeds.d.ts +2 -0
- package/dist/contracts/PythFeeds.d.ts.map +1 -1
- package/dist/contracts/PythFeeds.js +2 -0
- package/dist/contracts/StorkFeeds.d.ts +2 -0
- package/dist/contracts/StorkFeeds.d.ts.map +1 -1
- package/dist/contracts/StorkFeeds.js +2 -0
- package/dist/contracts/UserWallet.d.ts +3 -1
- package/dist/contracts/UserWallet.d.ts.map +1 -1
- package/dist/contracts/UserWallet.js +26 -24
- package/dist/contracts/UserWalletConfig.d.ts +3 -1
- package/dist/contracts/UserWalletConfig.d.ts.map +1 -1
- package/dist/contracts/UserWalletConfig.js +65 -63
- package/dist/contracts/UserWalletConfig_v1.d.ts +3 -1
- package/dist/contracts/UserWalletConfig_v1.d.ts.map +1 -1
- package/dist/contracts/UserWalletConfig_v1.js +43 -41
- package/dist/contracts/UserWalletConfig_v2.d.ts +3 -1
- package/dist/contracts/UserWalletConfig_v2.d.ts.map +1 -1
- package/dist/contracts/UserWalletConfig_v2.js +47 -45
- package/dist/contracts/UserWallet_v1.d.ts +3 -1
- package/dist/contracts/UserWallet_v1.d.ts.map +1 -1
- package/dist/contracts/UserWallet_v1.js +26 -24
- package/dist/contracts/UserWallet_v2.d.ts +3 -1
- package/dist/contracts/UserWallet_v2.d.ts.map +1 -1
- package/dist/contracts/UserWallet_v2.js +24 -22
- package/dist/contracts/sdk.d.ts +6 -6
- package/dist/contracts/sdk.d.ts.map +1 -1
- package/dist/contracts/sdk.js +6 -6
- package/dist/index.d.ts +397 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -14
- 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
|
|
46
|
-
|
|
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
|
|
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
|
|
75
|
+
get AddyRegistry_v2() {
|
|
58
76
|
return this.contracts.AddyRegistry_v2;
|
|
59
77
|
}
|
|
60
|
-
get
|
|
61
|
-
|
|
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
|
|
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
|
|
94
|
+
get AgentFactory_v1() {
|
|
73
95
|
return this.contracts.AgentFactory_v1;
|
|
74
96
|
}
|
|
75
97
|
get OracleRegistry() {
|
|
76
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
}
|