damm-sdk 1.3.3 → 1.3.5
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/index.cjs +6560 -4936
- package/dist/index.cjs.map +31 -12
- package/dist/index.js +49339 -41520
- package/dist/index.js.map +123 -55
- package/dist/integrations/fluidLite/fluid-lite.abi.d.ts +69 -0
- package/dist/integrations/fluidLite/fluid-lite.abi.d.ts.map +1 -0
- package/dist/integrations/fluidLite/fluid-lite.d.ts +42 -0
- package/dist/integrations/fluidLite/fluid-lite.d.ts.map +1 -0
- package/dist/integrations/fluidLite/index.d.ts +3 -0
- package/dist/integrations/fluidLite/index.d.ts.map +1 -0
- package/dist/integrations/index.d.ts +2 -0
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/weth/index.d.ts +3 -0
- package/dist/integrations/weth/index.d.ts.map +1 -0
- package/dist/integrations/weth/weth.abi.d.ts +33 -0
- package/dist/integrations/weth/weth.abi.d.ts.map +1 -0
- package/dist/integrations/weth/weth.d.ts +15 -0
- package/dist/integrations/weth/weth.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/integrations/fluidLite/fluid-lite.abi.ts +38 -0
- package/src/integrations/fluidLite/fluid-lite.ts +104 -0
- package/src/integrations/fluidLite/index.ts +2 -0
- package/src/integrations/index.ts +2 -0
- package/src/integrations/weth/index.ts +2 -0
- package/src/integrations/weth/weth.abi.ts +23 -0
- package/src/integrations/weth/weth.ts +42 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal ERC-4626 ABI for Fluid Lite iETHv2 vault.
|
|
3
|
+
* Only includes deposit, withdraw, and redeem functions.
|
|
4
|
+
*/
|
|
5
|
+
declare const _default: readonly [{
|
|
6
|
+
readonly inputs: readonly [{
|
|
7
|
+
readonly internalType: "uint256";
|
|
8
|
+
readonly name: "assets";
|
|
9
|
+
readonly type: "uint256";
|
|
10
|
+
}, {
|
|
11
|
+
readonly internalType: "address";
|
|
12
|
+
readonly name: "receiver";
|
|
13
|
+
readonly type: "address";
|
|
14
|
+
}];
|
|
15
|
+
readonly name: "deposit";
|
|
16
|
+
readonly outputs: readonly [{
|
|
17
|
+
readonly internalType: "uint256";
|
|
18
|
+
readonly name: "shares";
|
|
19
|
+
readonly type: "uint256";
|
|
20
|
+
}];
|
|
21
|
+
readonly stateMutability: "nonpayable";
|
|
22
|
+
readonly type: "function";
|
|
23
|
+
}, {
|
|
24
|
+
readonly inputs: readonly [{
|
|
25
|
+
readonly internalType: "uint256";
|
|
26
|
+
readonly name: "assets";
|
|
27
|
+
readonly type: "uint256";
|
|
28
|
+
}, {
|
|
29
|
+
readonly internalType: "address";
|
|
30
|
+
readonly name: "receiver";
|
|
31
|
+
readonly type: "address";
|
|
32
|
+
}, {
|
|
33
|
+
readonly internalType: "address";
|
|
34
|
+
readonly name: "owner";
|
|
35
|
+
readonly type: "address";
|
|
36
|
+
}];
|
|
37
|
+
readonly name: "withdraw";
|
|
38
|
+
readonly outputs: readonly [{
|
|
39
|
+
readonly internalType: "uint256";
|
|
40
|
+
readonly name: "shares";
|
|
41
|
+
readonly type: "uint256";
|
|
42
|
+
}];
|
|
43
|
+
readonly stateMutability: "nonpayable";
|
|
44
|
+
readonly type: "function";
|
|
45
|
+
}, {
|
|
46
|
+
readonly inputs: readonly [{
|
|
47
|
+
readonly internalType: "uint256";
|
|
48
|
+
readonly name: "shares";
|
|
49
|
+
readonly type: "uint256";
|
|
50
|
+
}, {
|
|
51
|
+
readonly internalType: "address";
|
|
52
|
+
readonly name: "receiver";
|
|
53
|
+
readonly type: "address";
|
|
54
|
+
}, {
|
|
55
|
+
readonly internalType: "address";
|
|
56
|
+
readonly name: "owner";
|
|
57
|
+
readonly type: "address";
|
|
58
|
+
}];
|
|
59
|
+
readonly name: "redeem";
|
|
60
|
+
readonly outputs: readonly [{
|
|
61
|
+
readonly internalType: "uint256";
|
|
62
|
+
readonly name: "assets";
|
|
63
|
+
readonly type: "uint256";
|
|
64
|
+
}];
|
|
65
|
+
readonly stateMutability: "nonpayable";
|
|
66
|
+
readonly type: "function";
|
|
67
|
+
}];
|
|
68
|
+
export default _default;
|
|
69
|
+
//# sourceMappingURL=fluid-lite.abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluid-lite.abi.d.ts","sourceRoot":"","sources":["../../../src/integrations/fluidLite/fluid-lite.abi.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACH,wBAiCW"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fluid Lite iETHv2 vault encoder.
|
|
3
|
+
*
|
|
4
|
+
* ERC-4626 compliant vault for stETH on mainnet.
|
|
5
|
+
* deposit(assets, receiver) — deposit stETH, receive vault shares.
|
|
6
|
+
* redeem(shares, receiver, owner) — redeem shares for stETH.
|
|
7
|
+
* withdraw(assets, receiver, owner) — withdraw exact stETH amount.
|
|
8
|
+
*
|
|
9
|
+
* Receiver and owner must always be the Safe address (avatar).
|
|
10
|
+
*/
|
|
11
|
+
import type { Address } from "viem";
|
|
12
|
+
import type { HexString, Unwrapable, Call } from "../../types";
|
|
13
|
+
export type DepositFluidLiteArgs = Readonly<{
|
|
14
|
+
assets: bigint;
|
|
15
|
+
receiver: Address;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const DepositFluidLiteCalldata: ({ assets, receiver }: DepositFluidLiteArgs) => HexString;
|
|
18
|
+
export declare const depositFluidLiteTrx: ({ args, vault, }: {
|
|
19
|
+
args: DepositFluidLiteArgs;
|
|
20
|
+
vault: Address;
|
|
21
|
+
}) => Unwrapable<Call>;
|
|
22
|
+
export type RedeemFluidLiteArgs = Readonly<{
|
|
23
|
+
shares: bigint;
|
|
24
|
+
receiver: Address;
|
|
25
|
+
owner: Address;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const RedeemFluidLiteCalldata: ({ shares, receiver, owner }: RedeemFluidLiteArgs) => HexString;
|
|
28
|
+
export declare const redeemFluidLiteTrx: ({ args, vault, }: {
|
|
29
|
+
args: RedeemFluidLiteArgs;
|
|
30
|
+
vault: Address;
|
|
31
|
+
}) => Unwrapable<Call>;
|
|
32
|
+
export type WithdrawFluidLiteArgs = Readonly<{
|
|
33
|
+
assets: bigint;
|
|
34
|
+
receiver: Address;
|
|
35
|
+
owner: Address;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const WithdrawFluidLiteCalldata: ({ assets, receiver, owner }: WithdrawFluidLiteArgs) => HexString;
|
|
38
|
+
export declare const withdrawFluidLiteTrx: ({ args, vault, }: {
|
|
39
|
+
args: WithdrawFluidLiteArgs;
|
|
40
|
+
vault: Address;
|
|
41
|
+
}) => Unwrapable<Call>;
|
|
42
|
+
//# sourceMappingURL=fluid-lite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluid-lite.d.ts","sourceRoot":"","sources":["../../../src/integrations/fluidLite/fluid-lite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAS/D,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC,CAAC;AAEH,eAAO,MAAM,wBAAwB,yBAA0B,oBAAoB,KAAG,SAErF,CAAC;AAEF,eAAO,MAAM,mBAAmB;UAItB,oBAAoB;WACnB,OAAO;MACd,WAAW,IAAI,CAOlB,CAAC;AAMF,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAEH,eAAO,MAAM,uBAAuB,gCAAiC,mBAAmB,KAAG,SAE1F,CAAC;AAEF,eAAO,MAAM,kBAAkB;UAIrB,mBAAmB;WAClB,OAAO;MACd,WAAW,IAAI,CAOlB,CAAC;AAMF,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAEH,eAAO,MAAM,yBAAyB,gCAAiC,qBAAqB,KAAG,SAE9F,CAAC;AAEF,eAAO,MAAM,oBAAoB;UAIvB,qBAAqB;WACpB,OAAO;MACd,WAAW,IAAI,CAOlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/fluidLite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/integrations/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/weth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;AAChD,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const _default: readonly [{
|
|
2
|
+
readonly inputs: readonly [];
|
|
3
|
+
readonly name: "deposit";
|
|
4
|
+
readonly outputs: readonly [];
|
|
5
|
+
readonly stateMutability: "payable";
|
|
6
|
+
readonly type: "function";
|
|
7
|
+
}, {
|
|
8
|
+
readonly inputs: readonly [{
|
|
9
|
+
readonly internalType: "uint256";
|
|
10
|
+
readonly name: "wad";
|
|
11
|
+
readonly type: "uint256";
|
|
12
|
+
}];
|
|
13
|
+
readonly name: "withdraw";
|
|
14
|
+
readonly outputs: readonly [];
|
|
15
|
+
readonly stateMutability: "nonpayable";
|
|
16
|
+
readonly type: "function";
|
|
17
|
+
}, {
|
|
18
|
+
readonly inputs: readonly [{
|
|
19
|
+
readonly internalType: "address";
|
|
20
|
+
readonly name: "";
|
|
21
|
+
readonly type: "address";
|
|
22
|
+
}];
|
|
23
|
+
readonly name: "balanceOf";
|
|
24
|
+
readonly outputs: readonly [{
|
|
25
|
+
readonly internalType: "uint256";
|
|
26
|
+
readonly name: "";
|
|
27
|
+
readonly type: "uint256";
|
|
28
|
+
}];
|
|
29
|
+
readonly stateMutability: "view";
|
|
30
|
+
readonly type: "function";
|
|
31
|
+
}];
|
|
32
|
+
export default _default;
|
|
33
|
+
//# sourceMappingURL=weth.abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weth.abi.d.ts","sourceRoot":"","sources":["../../../src/integrations/weth/weth.abi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAsBW"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { type Call, type HexString, type Unwrapable } from "../../types";
|
|
3
|
+
export type WrapEthArgs = Readonly<{
|
|
4
|
+
weth: Address;
|
|
5
|
+
amount: bigint;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const WrapEthCalldata: () => HexString;
|
|
8
|
+
export declare const wrapEthTrx: ({ weth, amount }: WrapEthArgs) => Unwrapable<Call>;
|
|
9
|
+
export type UnwrapWethArgs = Readonly<{
|
|
10
|
+
weth: Address;
|
|
11
|
+
amount: bigint;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const UnwrapWethCalldata: ({ amount }: Omit<UnwrapWethArgs, "weth">) => HexString;
|
|
14
|
+
export declare const unwrapWethTrx: ({ weth, amount }: UnwrapWethArgs) => Unwrapable<Call>;
|
|
15
|
+
//# sourceMappingURL=weth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weth.d.ts","sourceRoot":"","sources":["../../../src/integrations/weth/weth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAc,MAAM,aAAa,CAAC;AAKrF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,eAAO,MAAM,eAAe,QAAO,SAElC,CAAC;AAEF,eAAO,MAAM,UAAU,qBAAsB,WAAW,KAAG,WAAW,IAAI,CAOzE,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,eAAO,MAAM,kBAAkB,eAAgB,KAAK,cAAc,EAAE,MAAM,CAAC,KAAG,SAE7E,CAAC;AAEF,eAAO,MAAM,aAAa,qBAAsB,cAAc,KAAG,WAAW,IAAI,CAO/E,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal ERC-4626 ABI for Fluid Lite iETHv2 vault.
|
|
3
|
+
* Only includes deposit, withdraw, and redeem functions.
|
|
4
|
+
*/
|
|
5
|
+
export default [
|
|
6
|
+
{
|
|
7
|
+
inputs: [
|
|
8
|
+
{ internalType: "uint256", name: "assets", type: "uint256" },
|
|
9
|
+
{ internalType: "address", name: "receiver", type: "address" },
|
|
10
|
+
],
|
|
11
|
+
name: "deposit",
|
|
12
|
+
outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }],
|
|
13
|
+
stateMutability: "nonpayable",
|
|
14
|
+
type: "function",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
inputs: [
|
|
18
|
+
{ internalType: "uint256", name: "assets", type: "uint256" },
|
|
19
|
+
{ internalType: "address", name: "receiver", type: "address" },
|
|
20
|
+
{ internalType: "address", name: "owner", type: "address" },
|
|
21
|
+
],
|
|
22
|
+
name: "withdraw",
|
|
23
|
+
outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }],
|
|
24
|
+
stateMutability: "nonpayable",
|
|
25
|
+
type: "function",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
inputs: [
|
|
29
|
+
{ internalType: "uint256", name: "shares", type: "uint256" },
|
|
30
|
+
{ internalType: "address", name: "receiver", type: "address" },
|
|
31
|
+
{ internalType: "address", name: "owner", type: "address" },
|
|
32
|
+
],
|
|
33
|
+
name: "redeem",
|
|
34
|
+
outputs: [{ internalType: "uint256", name: "assets", type: "uint256" }],
|
|
35
|
+
stateMutability: "nonpayable",
|
|
36
|
+
type: "function",
|
|
37
|
+
},
|
|
38
|
+
] as const;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fluid Lite iETHv2 vault encoder.
|
|
3
|
+
*
|
|
4
|
+
* ERC-4626 compliant vault for stETH on mainnet.
|
|
5
|
+
* deposit(assets, receiver) — deposit stETH, receive vault shares.
|
|
6
|
+
* redeem(shares, receiver, owner) — redeem shares for stETH.
|
|
7
|
+
* withdraw(assets, receiver, owner) — withdraw exact stETH amount.
|
|
8
|
+
*
|
|
9
|
+
* Receiver and owner must always be the Safe address (avatar).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { ethers } from "ethers";
|
|
13
|
+
import FluidLiteAbi from "./fluid-lite.abi";
|
|
14
|
+
import type { Address } from "viem";
|
|
15
|
+
import type { HexString, Unwrapable, Call } from "../../types";
|
|
16
|
+
import { createCall } from "../../types";
|
|
17
|
+
|
|
18
|
+
const fluidLiteInterface = new ethers.utils.Interface(FluidLiteAbi);
|
|
19
|
+
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Deposit (ERC4626)
|
|
22
|
+
// ============================================================================
|
|
23
|
+
|
|
24
|
+
export type DepositFluidLiteArgs = Readonly<{
|
|
25
|
+
assets: bigint;
|
|
26
|
+
receiver: Address;
|
|
27
|
+
}>;
|
|
28
|
+
|
|
29
|
+
export const DepositFluidLiteCalldata = ({ assets, receiver }: DepositFluidLiteArgs): HexString => {
|
|
30
|
+
return fluidLiteInterface.encodeFunctionData("deposit", [assets, receiver]) as HexString;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const depositFluidLiteTrx = ({
|
|
34
|
+
args,
|
|
35
|
+
vault,
|
|
36
|
+
}: {
|
|
37
|
+
args: DepositFluidLiteArgs;
|
|
38
|
+
vault: Address;
|
|
39
|
+
}): Unwrapable<Call> => {
|
|
40
|
+
return createCall({
|
|
41
|
+
operation: 0,
|
|
42
|
+
to: vault,
|
|
43
|
+
value: 0n,
|
|
44
|
+
data: DepositFluidLiteCalldata(args),
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Redeem (ERC4626) - Shares-based withdrawal
|
|
50
|
+
// ============================================================================
|
|
51
|
+
|
|
52
|
+
export type RedeemFluidLiteArgs = Readonly<{
|
|
53
|
+
shares: bigint;
|
|
54
|
+
receiver: Address;
|
|
55
|
+
owner: Address;
|
|
56
|
+
}>;
|
|
57
|
+
|
|
58
|
+
export const RedeemFluidLiteCalldata = ({ shares, receiver, owner }: RedeemFluidLiteArgs): HexString => {
|
|
59
|
+
return fluidLiteInterface.encodeFunctionData("redeem", [shares, receiver, owner]) as HexString;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const redeemFluidLiteTrx = ({
|
|
63
|
+
args,
|
|
64
|
+
vault,
|
|
65
|
+
}: {
|
|
66
|
+
args: RedeemFluidLiteArgs;
|
|
67
|
+
vault: Address;
|
|
68
|
+
}): Unwrapable<Call> => {
|
|
69
|
+
return createCall({
|
|
70
|
+
operation: 0,
|
|
71
|
+
to: vault,
|
|
72
|
+
value: 0n,
|
|
73
|
+
data: RedeemFluidLiteCalldata(args),
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// ============================================================================
|
|
78
|
+
// Withdraw (ERC4626) - Assets-based withdrawal
|
|
79
|
+
// ============================================================================
|
|
80
|
+
|
|
81
|
+
export type WithdrawFluidLiteArgs = Readonly<{
|
|
82
|
+
assets: bigint;
|
|
83
|
+
receiver: Address;
|
|
84
|
+
owner: Address;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
export const WithdrawFluidLiteCalldata = ({ assets, receiver, owner }: WithdrawFluidLiteArgs): HexString => {
|
|
88
|
+
return fluidLiteInterface.encodeFunctionData("withdraw", [assets, receiver, owner]) as HexString;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const withdrawFluidLiteTrx = ({
|
|
92
|
+
args,
|
|
93
|
+
vault,
|
|
94
|
+
}: {
|
|
95
|
+
args: WithdrawFluidLiteArgs;
|
|
96
|
+
vault: Address;
|
|
97
|
+
}): Unwrapable<Call> => {
|
|
98
|
+
return createCall({
|
|
99
|
+
operation: 0,
|
|
100
|
+
to: vault,
|
|
101
|
+
value: 0n,
|
|
102
|
+
data: WithdrawFluidLiteCalldata(args),
|
|
103
|
+
});
|
|
104
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
inputs: [],
|
|
4
|
+
name: "deposit",
|
|
5
|
+
outputs: [],
|
|
6
|
+
stateMutability: "payable",
|
|
7
|
+
type: "function",
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
inputs: [{ internalType: "uint256", name: "wad", type: "uint256" }],
|
|
11
|
+
name: "withdraw",
|
|
12
|
+
outputs: [],
|
|
13
|
+
stateMutability: "nonpayable",
|
|
14
|
+
type: "function",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
18
|
+
name: "balanceOf",
|
|
19
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
20
|
+
stateMutability: "view",
|
|
21
|
+
type: "function",
|
|
22
|
+
},
|
|
23
|
+
] as const;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import { type Call, type HexString, type Unwrapable, createCall } from "../../types";
|
|
4
|
+
import WethAbi from "./weth.abi.ts";
|
|
5
|
+
|
|
6
|
+
const wethInterface = new ethers.utils.Interface(WethAbi);
|
|
7
|
+
|
|
8
|
+
export type WrapEthArgs = Readonly<{
|
|
9
|
+
weth: Address;
|
|
10
|
+
amount: bigint;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
export const WrapEthCalldata = (): HexString => {
|
|
14
|
+
return wethInterface.encodeFunctionData("deposit") as HexString;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const wrapEthTrx = ({ weth, amount }: WrapEthArgs): Unwrapable<Call> => {
|
|
18
|
+
return createCall({
|
|
19
|
+
to: weth,
|
|
20
|
+
data: WrapEthCalldata(),
|
|
21
|
+
value: amount,
|
|
22
|
+
operation: 0,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type UnwrapWethArgs = Readonly<{
|
|
27
|
+
weth: Address;
|
|
28
|
+
amount: bigint;
|
|
29
|
+
}>;
|
|
30
|
+
|
|
31
|
+
export const UnwrapWethCalldata = ({ amount }: Omit<UnwrapWethArgs, "weth">): HexString => {
|
|
32
|
+
return wethInterface.encodeFunctionData("withdraw", [amount]) as HexString;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const unwrapWethTrx = ({ weth, amount }: UnwrapWethArgs): Unwrapable<Call> => {
|
|
36
|
+
return createCall({
|
|
37
|
+
to: weth,
|
|
38
|
+
data: UnwrapWethCalldata({ amount }),
|
|
39
|
+
value: 0n,
|
|
40
|
+
operation: 0,
|
|
41
|
+
});
|
|
42
|
+
};
|