Skip to content

Commit 0910afb

Browse files
authored
Merge pull request #419 from Gearbox-protocol/withdrawals
fix: withdrawals
2 parents 8b26b46 + 1281687 commit 0910afb

File tree

2 files changed

+143
-6
lines changed

2 files changed

+143
-6
lines changed

src/abi/IWithdrawalCompressorV310.ts

Lines changed: 133 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2-
// IWithdrawalCompressorV310
2+
// WithdrawalCompressorV310
33
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44

55
export const iWithdrawalCompressorV310Abi = [
6+
{
7+
type: "constructor",
8+
inputs: [
9+
{ name: "_owner", internalType: "address", type: "address" },
10+
{ name: "addressProvider_", internalType: "address", type: "address" },
11+
],
12+
stateMutability: "nonpayable",
13+
},
14+
{
15+
type: "function",
16+
inputs: [],
17+
name: "addressProvider",
18+
outputs: [{ name: "", internalType: "address", type: "address" }],
19+
stateMutability: "view",
20+
},
21+
{
22+
type: "function",
23+
inputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
24+
name: "compressorTypeToCompressor",
25+
outputs: [{ name: "", internalType: "address", type: "address" }],
26+
stateMutability: "view",
27+
},
628
{
729
type: "function",
830
inputs: [],
@@ -120,7 +142,7 @@ export const iWithdrawalCompressorV310Abi = [
120142
name: "getWithdrawalRequestResult",
121143
outputs: [
122144
{
123-
name: "",
145+
name: "withdrawal",
124146
internalType: "struct RequestableWithdrawal",
125147
type: "tuple",
126148
components: [
@@ -151,11 +173,120 @@ export const iWithdrawalCompressorV310Abi = [
151173
],
152174
stateMutability: "view",
153175
},
176+
// TODO: REMOVE COMMENTS AFTER MIGRATION TO MULTIPLE
177+
// {
178+
// type: "function",
179+
// inputs: [
180+
// { name: "creditAccount", internalType: "address", type: "address" },
181+
// { name: "token", internalType: "address", type: "address" },
182+
// { name: "withdrawalToken", internalType: "address", type: "address" },
183+
// { name: "amount", internalType: "uint256", type: "uint256" },
184+
// ],
185+
// name: "getWithdrawalRequestResult",
186+
// outputs: [
187+
// {
188+
// name: "withdrawal",
189+
// internalType: "struct RequestableWithdrawal",
190+
// type: "tuple",
191+
// components: [
192+
// { name: "token", internalType: "address", type: "address" },
193+
// { name: "amountIn", internalType: "uint256", type: "uint256" },
194+
// {
195+
// name: "outputs",
196+
// internalType: "struct WithdrawalOutput[]",
197+
// type: "tuple[]",
198+
// components: [
199+
// { name: "token", internalType: "address", type: "address" },
200+
// { name: "isDelayed", internalType: "bool", type: "bool" },
201+
// { name: "amount", internalType: "uint256", type: "uint256" },
202+
// ],
203+
// },
204+
// {
205+
// name: "requestCalls",
206+
// internalType: "struct MultiCall[]",
207+
// type: "tuple[]",
208+
// components: [
209+
// { name: "target", internalType: "address", type: "address" },
210+
// { name: "callData", internalType: "bytes", type: "bytes" },
211+
// ],
212+
// },
213+
// { name: "claimableAt", internalType: "uint256", type: "uint256" },
214+
// ],
215+
// },
216+
// ],
217+
// stateMutability: "view",
218+
// },
219+
{
220+
type: "function",
221+
inputs: [],
222+
name: "owner",
223+
outputs: [{ name: "", internalType: "address", type: "address" }],
224+
stateMutability: "view",
225+
},
226+
{
227+
type: "function",
228+
inputs: [],
229+
name: "renounceOwnership",
230+
outputs: [],
231+
stateMutability: "nonpayable",
232+
},
233+
{
234+
type: "function",
235+
inputs: [
236+
{ name: "subcompressor", internalType: "address", type: "address" },
237+
],
238+
name: "setSubcompressor",
239+
outputs: [],
240+
stateMutability: "nonpayable",
241+
},
242+
{
243+
type: "function",
244+
inputs: [
245+
{ name: "withdrawableType", internalType: "bytes32", type: "bytes32" },
246+
{ name: "compressorType", internalType: "bytes32", type: "bytes32" },
247+
],
248+
name: "setWithdrawableTypeToCompressorType",
249+
outputs: [],
250+
stateMutability: "nonpayable",
251+
},
252+
{
253+
type: "function",
254+
inputs: [{ name: "newOwner", internalType: "address", type: "address" }],
255+
name: "transferOwnership",
256+
outputs: [],
257+
stateMutability: "nonpayable",
258+
},
154259
{
155260
type: "function",
156261
inputs: [],
157262
name: "version",
158263
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
159264
stateMutability: "view",
160265
},
266+
{
267+
type: "function",
268+
inputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
269+
name: "withdrawableTypeToCompressorType",
270+
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
271+
stateMutability: "view",
272+
},
273+
{
274+
type: "event",
275+
anonymous: false,
276+
inputs: [
277+
{
278+
name: "previousOwner",
279+
internalType: "address",
280+
type: "address",
281+
indexed: true,
282+
},
283+
{
284+
name: "newOwner",
285+
internalType: "address",
286+
type: "address",
287+
indexed: true,
288+
},
289+
],
290+
name: "OwnershipTransferred",
291+
},
161292
] as const;

src/sdk/accounts/AbstractCreditAccountsService.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "../../abi/v300.js";
1313
import type { CreditAccountData } from "../base/index.js";
1414
import { SDKConstruct } from "../base/index.js";
15+
import { chains } from "../chain/chains.js";
1516
import {
1617
ADDRESS_0X0,
1718
AP_CREDIT_ACCOUNT_COMPRESSOR,
@@ -75,11 +76,14 @@ export interface CreditAccountServiceOptions {
7576
batchSize?: number;
7677
}
7778

79+
// TODO: HARDCODED
80+
const COMPRESSORS: Record<number, Address> = {
81+
[chains.Mainnet.id]: "0xfB79b6713fe214B8748ED7b0db1f93E4f1aC9d29",
82+
[chains.Monad.id]: "0x36F3d0Bb73CBC2E94fE24dF0f26a689409cF9023",
83+
};
84+
7885
export function getWithdrawalCompressorAddress(chainId: number) {
79-
// TODO: HARDCODED
80-
const compressor =
81-
chainId === 1 ? "0xfB79b6713fe214B8748ED7b0db1f93E4f1aC9d29" : undefined;
82-
return compressor;
86+
return COMPRESSORS[chainId];
8387
}
8488

8589
export abstract class AbstractCreditAccountService extends SDKConstruct {
@@ -716,6 +720,7 @@ export abstract class AbstractCreditAccountService extends SDKConstruct {
716720
client: this.client,
717721
});
718722

723+
// TODO: return multiple configs
719724
const resp = await contract.read.getWithdrawalRequestResult([
720725
creditAccount,
721726
token,
@@ -745,6 +750,7 @@ export abstract class AbstractCreditAccountService extends SDKConstruct {
745750
client: this.client,
746751
});
747752

753+
// TODO: return multiple configs
748754
const resp = await contract.read.getCurrentWithdrawals([creditAccount]);
749755

750756
const claimableNow = resp?.[0] || [];

0 commit comments

Comments
 (0)