@townsq/mm-sdk 1.2.0 → 1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@townsq/mm-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "TownSquare Money Market SDK for interacting with lending, borrowing, and liquidation logic.",
5
5
  "author": "TownSq",
6
6
  "license": "MIT",
@@ -1,228 +1,228 @@
1
1
  export const HubAbi = [
2
2
  {
3
+ type: 'constructor',
3
4
  inputs: [
4
5
  {
5
- internalType: 'contract IBridgeRouter',
6
- name: 'bridgeRouter',
6
+ name: 'messageDispatcher',
7
7
  type: 'address',
8
+ internalType: 'contract IMessageDispatcher',
8
9
  },
9
10
  {
10
- internalType: 'contract ISpokeManager',
11
- name: 'spokeManager_',
11
+ name: 'spokeController_',
12
12
  type: 'address',
13
+ internalType: 'contract ISpokeController',
13
14
  },
14
15
  {
15
- internalType: 'contract IAccountController',
16
16
  name: 'accountController_',
17
17
  type: 'address',
18
+ internalType: 'contract IAccountController',
18
19
  },
19
20
  {
20
- internalType: 'contract ILoanController',
21
21
  name: 'loanController_',
22
22
  type: 'address',
23
+ internalType: 'contract ILoanController',
23
24
  },
24
- { internalType: 'uint16', name: 'hubChainId_', type: 'uint16' },
25
+ { name: 'hubChainId_', type: 'uint16', internalType: 'uint16' },
25
26
  ],
26
27
  stateMutability: 'nonpayable',
27
- type: 'constructor',
28
- },
29
- {
30
- inputs: [{ internalType: 'bytes32', name: 'messageId', type: 'bytes32' }],
31
- name: 'CannotReceiveMessage',
32
- type: 'error',
33
- },
34
- {
35
- inputs: [{ internalType: 'bytes32', name: 'messageId', type: 'bytes32' }],
36
- name: 'CannotRetryMessage',
37
- type: 'error',
38
- },
39
- {
40
- inputs: [{ internalType: 'bytes32', name: 'messageId', type: 'bytes32' }],
41
- name: 'CannotReverseMessage',
42
- type: 'error',
43
- },
44
- {
45
- inputs: [{ internalType: 'address', name: 'router', type: 'address' }],
46
- name: 'InvalidBridgeRouter',
47
- type: 'error',
48
- },
49
- {
50
- inputs: [
51
- { internalType: 'address', name: 'expected', type: 'address' },
52
- { internalType: 'address', name: 'actual', type: 'address' },
53
- ],
54
- name: 'InvalidTokenFeeClaimer',
55
- type: 'error',
56
28
  },
57
29
  {
58
- inputs: [
59
- { internalType: 'bytes32', name: 'accountId', type: 'bytes32' },
60
- { internalType: 'address', name: 'addr', type: 'address' },
61
- ],
62
- name: 'NoPermissionOnHub',
63
- type: 'error',
64
- },
65
- {
66
- inputs: [
67
- { internalType: 'bytes32', name: 'accountId', type: 'bytes32' },
68
- { internalType: 'uint16', name: 'chainId', type: 'uint16' },
69
- { internalType: 'bytes32', name: 'addr', type: 'bytes32' },
70
- ],
71
- name: 'NotRegisteredToAccount',
72
- type: 'error',
73
- },
74
- { inputs: [], name: 'ReentrancyGuardReentrantCall', type: 'error' },
75
- {
76
- inputs: [
77
- { internalType: 'uint16', name: 'chainId', type: 'uint16' },
78
- { internalType: 'bytes32', name: 'addr', type: 'bytes32' },
79
- ],
80
- name: 'SpokeUnknown',
81
- type: 'error',
82
- },
83
- {
84
- inputs: [
85
- { internalType: 'enum Messages.Action', name: 'action', type: 'uint8' },
86
- ],
87
- name: 'UnsupportedDirectOperation',
88
- type: 'error',
89
- },
90
- {
91
- inputs: [],
30
+ type: 'function',
92
31
  name: 'accountController',
32
+ inputs: [],
93
33
  outputs: [
94
34
  {
95
- internalType: 'contract IAccountController',
96
35
  name: '',
97
36
  type: 'address',
37
+ internalType: 'contract IAccountController',
98
38
  },
99
39
  ],
100
40
  stateMutability: 'view',
101
- type: 'function',
102
41
  },
103
42
  {
43
+ type: 'function',
44
+ name: 'claimTokenFees',
104
45
  inputs: [
105
- { internalType: 'uint8', name: 'poolId', type: 'uint8' },
106
- { internalType: 'uint16', name: 'chainId', type: 'uint16' },
107
- { internalType: 'uint16', name: 'returnAdapterId', type: 'uint16' },
108
- { internalType: 'uint256', name: 'returnGasLimit', type: 'uint256' },
46
+ { name: 'poolId', type: 'uint8', internalType: 'uint8' },
47
+ { name: 'chainId', type: 'uint16', internalType: 'uint16' },
48
+ { name: 'returnAdapterId', type: 'uint16', internalType: 'uint16' },
49
+ { name: 'returnGasLimit', type: 'uint256', internalType: 'uint256' },
109
50
  ],
110
- name: 'claimTokenFees',
111
51
  outputs: [],
112
52
  stateMutability: 'nonpayable',
113
- type: 'function',
114
53
  },
115
54
  {
55
+ type: 'function',
56
+ name: 'directCall',
116
57
  inputs: [
117
- { internalType: 'enum Messages.Action', name: 'action', type: 'uint8' },
118
- { internalType: 'bytes32', name: 'accountId', type: 'bytes32' },
119
- { internalType: 'bytes', name: 'data', type: 'bytes' },
58
+ { name: 'action', type: 'uint8', internalType: 'enum Messages.Action' },
59
+ { name: 'accountId', type: 'bytes32', internalType: 'bytes32' },
60
+ { name: 'data', type: 'bytes', internalType: 'bytes' },
120
61
  ],
121
- name: 'directOperation',
122
62
  outputs: [],
123
63
  stateMutability: 'nonpayable',
124
- type: 'function',
125
64
  },
126
65
  {
66
+ type: 'function',
67
+ name: 'getMessageDispatcher',
127
68
  inputs: [],
128
- name: 'getBridgeRouter',
129
- outputs: [{ internalType: 'address', name: '', type: 'address' }],
69
+ outputs: [{ name: '', type: 'address', internalType: 'address' }],
130
70
  stateMutability: 'view',
131
- type: 'function',
132
71
  },
133
72
  {
134
- inputs: [],
73
+ type: 'function',
135
74
  name: 'hubChainId',
136
- outputs: [{ internalType: 'uint16', name: '', type: 'uint16' }],
75
+ inputs: [],
76
+ outputs: [{ name: '', type: 'uint16', internalType: 'uint16' }],
137
77
  stateMutability: 'view',
138
- type: 'function',
139
78
  },
140
79
  {
141
- inputs: [],
80
+ type: 'function',
142
81
  name: 'loanController',
82
+ inputs: [],
143
83
  outputs: [
144
- { internalType: 'contract ILoanController', name: '', type: 'address' },
84
+ { name: '', type: 'address', internalType: 'contract ILoanController' },
145
85
  ],
146
86
  stateMutability: 'view',
147
- type: 'function',
148
87
  },
149
88
  {
89
+ type: 'function',
90
+ name: 'receiveMessage',
150
91
  inputs: [
151
92
  {
152
- components: [
153
- { internalType: 'bytes32', name: 'messageId', type: 'bytes32' },
154
- { internalType: 'uint16', name: 'sourceChainId', type: 'uint16' },
155
- { internalType: 'bytes32', name: 'sourceAddress', type: 'bytes32' },
156
- { internalType: 'bytes32', name: 'handler', type: 'bytes32' },
157
- { internalType: 'bytes', name: 'payload', type: 'bytes' },
158
- { internalType: 'uint16', name: 'returnAdapterId', type: 'uint16' },
159
- { internalType: 'uint256', name: 'returnGasLimit', type: 'uint256' },
160
- ],
161
- internalType: 'struct Messages.MessageReceived',
162
93
  name: 'message',
163
94
  type: 'tuple',
95
+ internalType: 'struct Messages.MessageReceived',
96
+ components: [
97
+ { name: 'messageId', type: 'bytes32', internalType: 'bytes32' },
98
+ { name: 'sourceChainId', type: 'uint16', internalType: 'uint16' },
99
+ { name: 'sourceAddress', type: 'bytes32', internalType: 'bytes32' },
100
+ { name: 'handler', type: 'bytes32', internalType: 'bytes32' },
101
+ { name: 'payload', type: 'bytes', internalType: 'bytes' },
102
+ { name: 'returnAdapterId', type: 'uint16', internalType: 'uint16' },
103
+ { name: 'returnGasLimit', type: 'uint256', internalType: 'uint256' },
104
+ ],
164
105
  },
165
106
  ],
166
- name: 'receiveMessage',
167
107
  outputs: [],
168
108
  stateMutability: 'nonpayable',
169
- type: 'function',
170
109
  },
171
110
  {
111
+ type: 'function',
112
+ name: 'retryMessage',
172
113
  inputs: [
173
114
  {
174
- components: [
175
- { internalType: 'bytes32', name: 'messageId', type: 'bytes32' },
176
- { internalType: 'uint16', name: 'sourceChainId', type: 'uint16' },
177
- { internalType: 'bytes32', name: 'sourceAddress', type: 'bytes32' },
178
- { internalType: 'bytes32', name: 'handler', type: 'bytes32' },
179
- { internalType: 'bytes', name: 'payload', type: 'bytes' },
180
- { internalType: 'uint16', name: 'returnAdapterId', type: 'uint16' },
181
- { internalType: 'uint256', name: 'returnGasLimit', type: 'uint256' },
182
- ],
183
- internalType: 'struct Messages.MessageReceived',
184
115
  name: 'message',
185
116
  type: 'tuple',
117
+ internalType: 'struct Messages.MessageReceived',
118
+ components: [
119
+ { name: 'messageId', type: 'bytes32', internalType: 'bytes32' },
120
+ { name: 'sourceChainId', type: 'uint16', internalType: 'uint16' },
121
+ { name: 'sourceAddress', type: 'bytes32', internalType: 'bytes32' },
122
+ { name: 'handler', type: 'bytes32', internalType: 'bytes32' },
123
+ { name: 'payload', type: 'bytes', internalType: 'bytes' },
124
+ { name: 'returnAdapterId', type: 'uint16', internalType: 'uint16' },
125
+ { name: 'returnGasLimit', type: 'uint256', internalType: 'uint256' },
126
+ ],
186
127
  },
187
- { internalType: 'address', name: 'caller', type: 'address' },
188
- { internalType: 'bytes', name: 'extraArgs', type: 'bytes' },
128
+ { name: 'caller', type: 'address', internalType: 'address' },
129
+ { name: 'extraArgs', type: 'bytes', internalType: 'bytes' },
189
130
  ],
190
- name: 'retryMessage',
191
131
  outputs: [],
192
132
  stateMutability: 'nonpayable',
193
- type: 'function',
194
133
  },
195
134
  {
135
+ type: 'function',
136
+ name: 'reverseMessage',
196
137
  inputs: [
197
138
  {
198
- components: [
199
- { internalType: 'bytes32', name: 'messageId', type: 'bytes32' },
200
- { internalType: 'uint16', name: 'sourceChainId', type: 'uint16' },
201
- { internalType: 'bytes32', name: 'sourceAddress', type: 'bytes32' },
202
- { internalType: 'bytes32', name: 'handler', type: 'bytes32' },
203
- { internalType: 'bytes', name: 'payload', type: 'bytes' },
204
- { internalType: 'uint16', name: 'returnAdapterId', type: 'uint16' },
205
- { internalType: 'uint256', name: 'returnGasLimit', type: 'uint256' },
206
- ],
207
- internalType: 'struct Messages.MessageReceived',
208
139
  name: 'message',
209
140
  type: 'tuple',
141
+ internalType: 'struct Messages.MessageReceived',
142
+ components: [
143
+ { name: 'messageId', type: 'bytes32', internalType: 'bytes32' },
144
+ { name: 'sourceChainId', type: 'uint16', internalType: 'uint16' },
145
+ { name: 'sourceAddress', type: 'bytes32', internalType: 'bytes32' },
146
+ { name: 'handler', type: 'bytes32', internalType: 'bytes32' },
147
+ { name: 'payload', type: 'bytes', internalType: 'bytes' },
148
+ { name: 'returnAdapterId', type: 'uint16', internalType: 'uint16' },
149
+ { name: 'returnGasLimit', type: 'uint256', internalType: 'uint256' },
150
+ ],
210
151
  },
211
- { internalType: 'address', name: 'caller', type: 'address' },
212
- { internalType: 'bytes', name: 'extraArgs', type: 'bytes' },
152
+ { name: 'caller', type: 'address', internalType: 'address' },
153
+ { name: 'extraArgs', type: 'bytes', internalType: 'bytes' },
213
154
  ],
214
- name: 'reverseMessage',
215
155
  outputs: [],
216
156
  stateMutability: 'nonpayable',
217
- type: 'function',
218
157
  },
219
158
  {
159
+ type: 'function',
160
+ name: 'spokeController',
220
161
  inputs: [],
221
- name: 'spokeManager',
222
162
  outputs: [
223
- { internalType: 'contract ISpokeManager', name: '', type: 'address' },
163
+ { name: '', type: 'address', internalType: 'contract ISpokeController' },
224
164
  ],
225
165
  stateMutability: 'view',
226
- type: 'function',
166
+ },
167
+ {
168
+ type: 'error',
169
+ name: 'CannotReceiveMessage',
170
+ inputs: [{ name: 'messageId', type: 'bytes32', internalType: 'bytes32' }],
171
+ },
172
+ {
173
+ type: 'error',
174
+ name: 'CannotRetryMessage',
175
+ inputs: [{ name: 'messageId', type: 'bytes32', internalType: 'bytes32' }],
176
+ },
177
+ {
178
+ type: 'error',
179
+ name: 'CannotReverseMessage',
180
+ inputs: [{ name: 'messageId', type: 'bytes32', internalType: 'bytes32' }],
181
+ },
182
+ {
183
+ type: 'error',
184
+ name: 'InvalidMessageDispatcher',
185
+ inputs: [{ name: 'router', type: 'address', internalType: 'address' }],
186
+ },
187
+ {
188
+ type: 'error',
189
+ name: 'InvalidTokenFeeClaimer',
190
+ inputs: [
191
+ { name: 'expected', type: 'address', internalType: 'address' },
192
+ { name: 'actual', type: 'address', internalType: 'address' },
193
+ ],
194
+ },
195
+ {
196
+ type: 'error',
197
+ name: 'NoPermissionOnHub',
198
+ inputs: [
199
+ { name: 'accountId', type: 'bytes32', internalType: 'bytes32' },
200
+ { name: 'addr', type: 'address', internalType: 'address' },
201
+ ],
202
+ },
203
+ {
204
+ type: 'error',
205
+ name: 'NotRegisteredToAccount',
206
+ inputs: [
207
+ { name: 'accountId', type: 'bytes32', internalType: 'bytes32' },
208
+ { name: 'chainId', type: 'uint16', internalType: 'uint16' },
209
+ { name: 'addr', type: 'bytes32', internalType: 'bytes32' },
210
+ ],
211
+ },
212
+ { type: 'error', name: 'ReentrancyGuardReentrantCall', inputs: [] },
213
+ {
214
+ type: 'error',
215
+ name: 'SpokeUnknown',
216
+ inputs: [
217
+ { name: 'chainId', type: 'uint16', internalType: 'uint16' },
218
+ { name: 'addr', type: 'bytes32', internalType: 'bytes32' },
219
+ ],
220
+ },
221
+ {
222
+ type: 'error',
223
+ name: 'UnsupportedDirectOperation',
224
+ inputs: [
225
+ { name: 'action', type: 'uint8', internalType: 'enum Messages.Action' },
226
+ ],
227
227
  },
228
228
  ] as const;
@@ -121,7 +121,7 @@ export const prepare = {
121
121
 
122
122
  const messageData = buildEvmMessageData(liquidateMessageDataParams);
123
123
 
124
- const gasLimit = await hub.estimateGas.directOperation(
124
+ const gasLimit = await hub.estimateGas.directCall(
125
125
  [Action.Liquidate, accountId, messageData],
126
126
  {
127
127
  ...transactionOptions,
@@ -154,7 +154,7 @@ export const write = {
154
154
 
155
155
  const hub = getHubContract(provider, hubAddress, signer);
156
156
 
157
- return await hub.write.directOperation(
157
+ return await hub.write.directCall(
158
158
  [Action.Liquidate, accountId, messageData],
159
159
  {
160
160
  account: getEvmSignerAccount(signer),