@gearbox-protocol/sdk 16.0.0-next.11 → 16.0.0-next.13
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/cjs/dev/mode-parity/comparePositions.js +3 -2
- package/dist/cjs/dev/mode-parity/compareRules.js +12 -1
- package/dist/cjs/dev/mode-parity/scriptUtils.js +1 -1
- package/dist/cjs/model/compare.schema.js +8 -0
- package/dist/cjs/model/index.js +3 -1
- package/dist/cjs/model/positions.js +6 -0
- package/dist/cjs/model/positions.schema.js +4 -3
- package/dist/cjs/model/previews.js +4 -3
- package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +14 -0
- package/dist/cjs/onchain/market/adapters/contracts/ERC4626AdapterContract.js +54 -0
- package/dist/cjs/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +13 -0
- package/dist/cjs/onchain/positions/PositionsService.js +20 -17
- package/dist/cjs/preview/preview/replayInnerOperations.js +10 -25
- package/dist/esm/dev/mode-parity/comparePositions.js +3 -2
- package/dist/esm/dev/mode-parity/compareRules.js +12 -1
- package/dist/esm/dev/mode-parity/scriptUtils.js +1 -1
- package/dist/esm/model/compare.schema.js +8 -1
- package/dist/esm/model/index.js +4 -4
- package/dist/esm/model/positions.js +6 -1
- package/dist/esm/model/positions.schema.js +5 -4
- package/dist/esm/model/previews.js +4 -3
- package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +14 -0
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +55 -1
- package/dist/esm/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +14 -1
- package/dist/esm/onchain/positions/PositionsService.js +21 -18
- package/dist/esm/preview/preview/replayInnerOperations.js +11 -26
- package/dist/types/dev/mode-parity/comparePositions.d.ts +5 -3
- package/dist/types/dev/mode-parity/fieldDiff.d.ts +3 -1
- package/dist/types/model/compare.schema.d.ts +9 -2
- package/dist/types/model/index.d.ts +4 -4
- package/dist/types/model/positions.d.ts +19 -1
- package/dist/types/model/positions.schema.d.ts +2 -0
- package/dist/types/model/previews.d.ts +4 -3
- package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +12 -0
- package/dist/types/onchain/market/adapters/contracts/ERC4626AdapterContract.d.ts +8 -1
- package/dist/types/onchain/market/adapters/contracts/MidasGatewayAdapterContract.d.ts +7 -0
- package/package.json +1 -1
- package/dist/cjs/preview/preview/applyRWAWrapUnwrap.js +0 -67
- package/dist/esm/preview/preview/applyRWAWrapUnwrap.js +0 -66
- package/dist/types/preview/preview/applyRWAWrapUnwrap.d.ts +0 -17
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
2
|
-
import { decodeFunctionData } from "viem";
|
|
3
|
-
//#region src/preview/preview/applyRWAWrapUnwrap.ts
|
|
4
|
-
/**
|
|
5
|
-
* Maps the decoded adapter call to the conversion it performs. Diff variants
|
|
6
|
-
* spend the running balance down to the calldata leftover, so their input
|
|
7
|
-
* amount comes from `balances`. Returns `undefined` for functions we do not
|
|
8
|
-
* handle (`mint`/`withdraw` are never emitted by the RWA flows).
|
|
9
|
-
*/
|
|
10
|
-
function resolveWrapUnwrap(adapter, calldata, balances) {
|
|
11
|
-
const decoded = decodeFunctionData({
|
|
12
|
-
abi: ierc4626AdapterAbi,
|
|
13
|
-
data: calldata
|
|
14
|
-
});
|
|
15
|
-
const { asset, share } = adapter;
|
|
16
|
-
switch (decoded.functionName) {
|
|
17
|
-
case "deposit": return {
|
|
18
|
-
tokenIn: asset,
|
|
19
|
-
tokenOut: share,
|
|
20
|
-
amountIn: decoded.args[0]
|
|
21
|
-
};
|
|
22
|
-
case "depositDiff": {
|
|
23
|
-
const [leftoverAmount] = decoded.args;
|
|
24
|
-
const running = balances.getOrZero(asset);
|
|
25
|
-
return {
|
|
26
|
-
tokenIn: asset,
|
|
27
|
-
tokenOut: share,
|
|
28
|
-
amountIn: running > leftoverAmount ? running - leftoverAmount : 0n
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
case "redeem": return {
|
|
32
|
-
tokenIn: share,
|
|
33
|
-
tokenOut: asset,
|
|
34
|
-
amountIn: decoded.args[0]
|
|
35
|
-
};
|
|
36
|
-
case "redeemDiff": {
|
|
37
|
-
const [leftoverAmount] = decoded.args;
|
|
38
|
-
const running = balances.getOrZero(share);
|
|
39
|
-
return {
|
|
40
|
-
tokenIn: share,
|
|
41
|
-
tokenOut: asset,
|
|
42
|
-
amountIn: running > leftoverAmount ? running - leftoverAmount : 0n
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
default: return;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Applies an RWA wrap/unwrap adapter call (ERC4626 `deposit`/`redeem` and
|
|
50
|
-
* their diff variants, as emitted by `CreditAccountsServiceV310`) to the
|
|
51
|
-
* running credit-account balances.
|
|
52
|
-
*
|
|
53
|
-
* RWA underlyings always convert 1-to-1 with their vault asset, so the
|
|
54
|
-
* counterpart amount equals the input amount and no on-chain preview read is
|
|
55
|
-
* needed.
|
|
56
|
-
*/
|
|
57
|
-
function applyRWAWrapUnwrap(adapter, calldata, balances) {
|
|
58
|
-
const resolved = resolveWrapUnwrap(adapter, calldata, balances);
|
|
59
|
-
if (!resolved) return;
|
|
60
|
-
const { tokenIn, tokenOut, amountIn } = resolved;
|
|
61
|
-
if (amountIn === 0n) return;
|
|
62
|
-
balances.dec(tokenIn, amountIn);
|
|
63
|
-
balances.inc(tokenOut, amountIn);
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
export { applyRWAWrapUnwrap };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AssetsMap } from "../../onchain/utils/AssetsMap.js";
|
|
2
|
-
import { ERC4626AdapterContract } from "../../onchain/market/adapters/contracts/ERC4626AdapterContract.js";
|
|
3
|
-
import "../../onchain/index.js";
|
|
4
|
-
import { Hex } from "viem";
|
|
5
|
-
//#region src/preview/preview/applyRWAWrapUnwrap.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Applies an RWA wrap/unwrap adapter call (ERC4626 `deposit`/`redeem` and
|
|
8
|
-
* their diff variants, as emitted by `CreditAccountsServiceV310`) to the
|
|
9
|
-
* running credit-account balances.
|
|
10
|
-
*
|
|
11
|
-
* RWA underlyings always convert 1-to-1 with their vault asset, so the
|
|
12
|
-
* counterpart amount equals the input amount and no on-chain preview read is
|
|
13
|
-
* needed.
|
|
14
|
-
*/
|
|
15
|
-
declare function applyRWAWrapUnwrap(adapter: ERC4626AdapterContract, calldata: Hex, balances: AssetsMap): void;
|
|
16
|
-
//#endregion
|
|
17
|
-
export { applyRWAWrapUnwrap };
|