@defisaver/sdk 1.2.13 → 1.2.15-dev-allocator

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.
Files changed (31) hide show
  1. package/esm/src/actions/curveusd/CurveUsdLevCreateTransientAction.d.ts +9 -0
  2. package/esm/src/actions/curveusd/CurveUsdLevCreateTransientAction.js +33 -0
  3. package/esm/src/actions/curveusd/CurveUsdRepayTransientAction.d.ts +9 -0
  4. package/esm/src/actions/curveusd/CurveUsdRepayTransientAction.js +25 -0
  5. package/esm/src/actions/curveusd/CurveUsdSelfLiquidateWithCollTransientAction.d.ts +9 -0
  6. package/esm/src/actions/curveusd/CurveUsdSelfLiquidateWithCollTransientAction.js +35 -0
  7. package/esm/src/actions/curveusd/index.d.ts +3 -0
  8. package/esm/src/actions/curveusd/index.js +3 -0
  9. package/esm/src/actions/flashloan/CurveUsdFlashLoanAction.d.ts +17 -0
  10. package/esm/src/actions/flashloan/CurveUsdFlashLoanAction.js +18 -0
  11. package/esm/src/actions/flashloan/index.d.ts +1 -0
  12. package/esm/src/actions/flashloan/index.js +1 -0
  13. package/esm/src/actions/morpho-blue/MorphoBlueReallocateLiquidityAction.d.ts +20 -0
  14. package/esm/src/actions/morpho-blue/MorphoBlueReallocateLiquidityAction.js +50 -0
  15. package/esm/src/actions/morpho-blue/index.d.ts +1 -0
  16. package/esm/src/actions/morpho-blue/index.js +1 -0
  17. package/esm/src/addresses.d.ts +25 -1
  18. package/esm/src/addresses.js +7 -0
  19. package/esm/src/index.d.ts +100 -4
  20. package/package.json +1 -1
  21. package/src/actions/curveusd/CurveUsdLevCreateTransientAction.ts +52 -0
  22. package/src/actions/curveusd/CurveUsdRepayTransientAction.ts +36 -0
  23. package/src/actions/curveusd/CurveUsdSelfLiquidateWithCollTransientAction.ts +55 -0
  24. package/src/actions/curveusd/index.ts +4 -1
  25. package/src/actions/flashloan/CurveUsdFlashLoanAction.ts +27 -0
  26. package/src/actions/flashloan/index.ts +1 -0
  27. package/src/actions/morpho-blue/MorphoBlueReallocateLiquidityAction.ts +56 -0
  28. package/src/actions/morpho-blue/index.ts +2 -1
  29. package/src/addresses.ts +7 -0
  30. package/test/actions/morpho-blue/MorphoBlueReallocateLiquidityAction.js +50 -0
  31. package/umd/index.js +680 -502
@@ -0,0 +1,27 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ import { EthAddress, uint256, bytes } from '../../types';
4
+ import { FlashLoanId } from './FlashLoanId';
5
+
6
+ /**
7
+ * Gets a crvUSD flashloan from CurveUsd Flash Minter
8
+ *
9
+ * @category Flashloans
10
+ */
11
+ export class CurveUsdFlashLoanAction extends Action implements FlashLoanId {
12
+ public flashLoanId = 9;
13
+
14
+ /**
15
+ * @param amount
16
+ * @param flParamGetterAddr
17
+ * @param flParamGetterData
18
+ */
19
+ constructor(amount: uint256, flParamGetterAddr: EthAddress = getAddr('Empty'), flParamGetterData: bytes = []) {
20
+ super(
21
+ 'FLAction',
22
+ getAddr('FLAction'),
23
+ ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'],
24
+ [[], [amount], [], getAddr('Empty'), flParamGetterAddr, flParamGetterData, []],
25
+ );
26
+ }
27
+ }
@@ -23,3 +23,4 @@ export * from './GhoFlashLoanPaybackAction';
23
23
  export * from './MorphoBlueFlashLoanAction';
24
24
  export * from './MorphoBlueFlashLoanPaybackAction';
25
25
  export * from './FLPaybackAction';
26
+ export * from './CurveUsdFlashLoanAction';
@@ -0,0 +1,56 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ import { EthAddress, uint256 } from '../../types';
4
+
5
+ /**
6
+ * MorphoBlueReallocateLiquidityAction - Action that bundles calls to Morpho Blue Public Allocator to reallocate liquidity for additional borrowing
7
+ *
8
+ * @category MorphoBlue
9
+ */
10
+ export class MorphoBlueReallocateLiquidityAction extends Action {
11
+ /**
12
+ * @param loanToken - MarketParams loanToken for target market to borrow from
13
+ * @param collateralToken - MarketParams collateralToken for target market to borrow from
14
+ * @param oracle - MarketParams oracle for target market to borrow from
15
+ * @param irm - MarketParams irm for target market to borrow from
16
+ * @param lltv - MarketParams lltv for target market to borrow from
17
+ * @param vaults - Array of vaults to reallocate liquidity from
18
+ * @param withdrawals - Array of withdrawals for each vault
19
+ */
20
+ constructor(
21
+ loanToken:EthAddress,
22
+ collateralToken:EthAddress,
23
+ oracle:EthAddress,
24
+ irm:EthAddress,
25
+ lltv:uint256,
26
+ vaults: EthAddress[],
27
+ withdrawals: Array<Array<any>>,
28
+ ) {
29
+ super(
30
+ 'MorphoBlueReallocateLiquidity',
31
+ getAddr('Empty'),
32
+ [
33
+ ['address', 'address', 'address', 'address', 'uint256'], // MarketParams
34
+ 'address[]', // vaults
35
+ 'tuple(tuple(address,address,address,address,uint256),uint256)[][]', // withdrawals
36
+ ],
37
+ [
38
+ [loanToken, collateralToken, oracle, irm, lltv], // MarketParams
39
+ vaults,
40
+ withdrawals,
41
+ ],
42
+ );
43
+
44
+ this.mappableArgs = [
45
+ this.args[0][0],
46
+ this.args[0][1],
47
+ this.args[0][2],
48
+ this.args[0][3],
49
+ this.args[0][4],
50
+ ];
51
+ }
52
+
53
+ async getAssetsToApprove() {
54
+ return [];
55
+ }
56
+ }
@@ -6,4 +6,5 @@ export * from './MorphoBlueWithdrawCollateralAction';
6
6
  export * from './MorphoBlueWithdrawAction';
7
7
  export * from './MorphoBlueSetAuthAction';
8
8
  export * from './MorphoBlueSetAuthWithSigAction';
9
- export * from './MorphoTokenWrapAction';
9
+ export * from './MorphoTokenWrapAction';
10
+ export * from './MorphoBlueReallocateLiquidityAction';
package/src/addresses.ts CHANGED
@@ -25,6 +25,7 @@ export const actionAddresses = {
25
25
  PermitToken: '0x2654056046ed5E3f673FbcBC99A1BDB77F5c460B',
26
26
  StarknetClaim: '0x40069889098cd54d6c1021578000f37b197479cf',
27
27
  HandleAuth: '0xfc2e2b37c73d5d43cf5fcbd80a4049b620d60eba',
28
+ SendTokens: '0x7d05c0ABeF6d91300a237026507c4a2631ddAdEa',
28
29
 
29
30
  // exchange
30
31
  DFSSell: '0x901d383c37b30cefad9b6e2bbb0539a40e02c5f4',
@@ -257,11 +258,15 @@ export const actionAddresses = {
257
258
  CurveUsdLevCreate: '0xcbd9aFc2b7532b9eeB3A7EC4ea8Bb4320795d9Ad',
258
259
  CurveUsdRepay: '0x6F91E8671d17ecEE3D3fb17DcCA87E86B8D83807',
259
260
  CurveUsdSwapper: '0xFA8c594b903651F97b27aCADEa83b720cfD7F80b',
261
+ CurveUsdSwapperTransient: '0xcF0298592b8FCB3823d31Bb257b65afFCAcCb8b6',
260
262
  CurveUsdSelfLiquidate: '0xd90d8a4955DfE9D4f45F7f60595313B0925ee1da',
261
263
  CurveUsdSelfLiquidateWithColl: '0x7cE305FC2A18c6820a533AD418dC0A549aFeDcAF',
262
264
  CurveUsdGetDebt: '0x3Bb41d3f300dA758780fe7696bb4fB93cD7172fB',
263
265
  CurveUsdCollRatioTrigger: '0xFCc610809b735BB13E583c5E46595457083D2b0c',
264
266
  CurveUsdCollRatioCheck: '0x8c65f37ca216de1625886431249be13ead051388',
267
+ CurveUsdSelfLiquidateWithCollTransient: '0x9c41eA5D82AF27Fd436Cd4Cf525808313B35f0D1',
268
+ CurveUsdLevCreateTransient: '0x798eA3B6E1C6210c6594aD5A1dBDA5b6b3347920',
269
+ CurveUsdRepayTransient: '0xa923a9111377F2f8614E8A1287DbC081e23a29b8',
265
270
 
266
271
  MorphoBlueSupply: '0x1D0F6027Eeb118dEc06055735eE840E3Fe3E6f9a',
267
272
  MorphoBlueSupplyCollateral: '0x1cdAC5D4b207e8DBd308504BbedD5D1BD19D26ac',
@@ -272,6 +277,7 @@ export const actionAddresses = {
272
277
  MorphoBlueSetAuth: '0xf30935e20c6357c7bcecd5e58ad6de26d54b9f64',
273
278
  MorphoBlueSetAuthWithSig: '0xE2d5fCDBf73BAd24A0FCAf6B2733933A98021808',
274
279
  MorphoTokenWrap: '0x71b6d268c2Aabcb0dA16CbA4c77e65d9e29b0644',
280
+ MorphoBlueReallocateLiquidity: '0x10B748Dc504C2515Bb6A9e23CB2F686090b6c584',
275
281
 
276
282
  // llamalend
277
283
  LlamaLendCreate: '0x4349be191ea63173eD98b7fC1b0DeC1ef9Bc6c11',
@@ -449,6 +455,7 @@ export const actionAddresses = {
449
455
  ToggleSub: '0x5F16C0a08d52b67fc73706c494F7535Dd3382b58',
450
456
  CreateSub: '0xeE739937085A716477BCB5b01b0f74e1BE046645',
451
457
  UpdateSub: '0x1601c6ABCDE6e6d8Ad96628AFe20d47908127Aea',
458
+ MerklClaim: '0xa2c6cd875c52bf5c27516fae3b6ba9241790908a',
452
459
 
453
460
  // Flashloan
454
461
  FLAaveV3: '0x79Eb9cEe432Cd3e7b09A9eFdB21A733A6d7b4c3A',
@@ -0,0 +1,50 @@
1
+ const dfs = require('../../../src');
2
+ const {encodeForDsProxyCall, encodeForRecipe} = require('../../_actionUtils');
3
+ const {assert} = require('chai');
4
+
5
+ describe('Action: MorphoBlueReallocateLiquidityAction', () => {
6
+ let action;
7
+ context('MorphoBlueReallocateLiquidityAction', () => {
8
+ it('constructor', () => {
9
+ const market = [
10
+ '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
11
+ '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
12
+ '0x2a01eb9496094da03c4e364def50f5ad1280ad72',
13
+ '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
14
+ '945000000000000000',
15
+ ];
16
+ const amount = 10000000;
17
+ const vault = '0x80788de454ad3681d357dc7FcB13c72333f684a7';
18
+ action = new dfs.actions.morphoblue.MorphoBlueReallocateLiquidityAction(
19
+ market[0],
20
+ market[1],
21
+ market[2],
22
+ market[3],
23
+ market[4],
24
+ [vault, vault, vault],
25
+ [
26
+ [
27
+ [market,amount],
28
+ [market,amount],
29
+ ],
30
+ [
31
+ [market,amount],
32
+ [market,amount],
33
+ [market,amount],
34
+ ],
35
+ ]
36
+ );
37
+ assert.equal(action.mappableArgs[0], market[0]);
38
+ assert.equal(action.mappableArgs[1], market[1]);
39
+ assert.equal(action.mappableArgs[2], market[2]);
40
+ assert.equal(action.mappableArgs[3], market[3]);
41
+ assert.equal(action.mappableArgs[4], market[4]);
42
+ });
43
+ it('encodeForDsProxyCall', () => encodeForDsProxyCall(action));
44
+ it('encodeForRecipe', () => encodeForRecipe(action));
45
+ it('getEthValue', async () => {
46
+ const ethValue = await action.getEthValue();
47
+ assert.equal(ethValue, '0');
48
+ })
49
+ })
50
+ })