@defisaver/sdk 1.0.36 → 1.0.38

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 (75) hide show
  1. package/esm/src/actions/basic/SDaiUnwrapAction.d.ts +19 -0
  2. package/esm/src/actions/basic/SDaiUnwrapAction.js +39 -0
  3. package/esm/src/actions/basic/SDaiWrapAction.d.ts +19 -0
  4. package/esm/src/actions/basic/SDaiWrapAction.js +39 -0
  5. package/esm/src/actions/basic/index.d.ts +2 -0
  6. package/esm/src/actions/basic/index.js +2 -0
  7. package/esm/src/actions/checkers/SparkRatioCheckAction.d.ts +14 -0
  8. package/esm/src/actions/checkers/SparkRatioCheckAction.js +20 -0
  9. package/esm/src/actions/checkers/index.d.ts +1 -0
  10. package/esm/src/actions/checkers/index.js +1 -0
  11. package/esm/src/actions/flashloan/FLAction.js +7 -1
  12. package/esm/src/actions/flashloan/SparkFlashLoanAction.d.ts +18 -0
  13. package/esm/src/actions/flashloan/SparkFlashLoanAction.js +20 -0
  14. package/esm/src/actions/flashloan/SparkFlashLoanPaybackAction.d.ts +14 -0
  15. package/esm/src/actions/flashloan/SparkFlashLoanPaybackAction.js +16 -0
  16. package/esm/src/actions/flashloan/index.d.ts +2 -0
  17. package/esm/src/actions/flashloan/index.js +2 -0
  18. package/esm/src/actions/index.d.ts +2 -1
  19. package/esm/src/actions/index.js +2 -1
  20. package/esm/src/actions/spark/SparkBorrowAction.d.ts +21 -0
  21. package/esm/src/actions/spark/SparkBorrowAction.js +59 -0
  22. package/esm/src/actions/spark/SparkClaimRewardsAction.d.ts +18 -0
  23. package/esm/src/actions/spark/SparkClaimRewardsAction.js +40 -0
  24. package/esm/src/actions/spark/SparkCollateralSwitchAction.d.ts +18 -0
  25. package/esm/src/actions/spark/SparkCollateralSwitchAction.js +39 -0
  26. package/esm/src/actions/spark/SparkPaybackAction.d.ts +27 -0
  27. package/esm/src/actions/spark/SparkPaybackAction.js +77 -0
  28. package/esm/src/actions/spark/SparkSetEModeAction.d.ts +16 -0
  29. package/esm/src/actions/spark/SparkSetEModeAction.js +33 -0
  30. package/esm/src/actions/spark/SparkSpTokenPaybackAction.d.ts +25 -0
  31. package/esm/src/actions/spark/SparkSpTokenPaybackAction.js +64 -0
  32. package/esm/src/actions/spark/SparkSupplyAction.d.ts +27 -0
  33. package/esm/src/actions/spark/SparkSupplyAction.js +77 -0
  34. package/esm/src/actions/spark/SparkSwapBorrowRateModeAction.d.ts +18 -0
  35. package/esm/src/actions/spark/SparkSwapBorrowRateModeAction.js +38 -0
  36. package/esm/src/actions/spark/SparkWithdrawAction.d.ts +18 -0
  37. package/esm/src/actions/spark/SparkWithdrawAction.js +45 -0
  38. package/esm/src/actions/spark/index.d.ts +9 -0
  39. package/esm/src/actions/spark/index.js +9 -0
  40. package/esm/src/addresses.d.ts +36 -0
  41. package/esm/src/addresses.js +13 -0
  42. package/esm/src/index.d.ts +144 -0
  43. package/esm/src/triggers/SparkQuotePriceTrigger.d.ts +10 -0
  44. package/esm/src/triggers/SparkQuotePriceTrigger.js +12 -0
  45. package/esm/src/triggers/SparkRatioTrigger.d.ts +10 -0
  46. package/esm/src/triggers/SparkRatioTrigger.js +12 -0
  47. package/esm/src/triggers/index.d.ts +2 -0
  48. package/esm/src/triggers/index.js +2 -0
  49. package/package.json +1 -1
  50. package/src/actions/basic/SDaiUnwrapAction.ts +37 -0
  51. package/src/actions/basic/SDaiWrapAction.ts +37 -0
  52. package/src/actions/basic/index.ts +2 -0
  53. package/src/actions/checkers/SparkRatioCheckAction.ts +23 -0
  54. package/src/actions/checkers/index.ts +2 -1
  55. package/src/actions/flashloan/FLAction.ts +7 -1
  56. package/src/actions/flashloan/SparkFlashLoanAction.ts +27 -0
  57. package/src/actions/flashloan/SparkFlashLoanPaybackAction.ts +18 -0
  58. package/src/actions/flashloan/index.ts +2 -0
  59. package/src/actions/index.ts +2 -0
  60. package/src/actions/spark/SparkBorrowAction.ts +68 -0
  61. package/src/actions/spark/SparkClaimRewardsAction.ts +50 -0
  62. package/src/actions/spark/SparkCollateralSwitchAction.ts +47 -0
  63. package/src/actions/spark/SparkPaybackAction.ts +77 -0
  64. package/src/actions/spark/SparkSetEModeAction.ts +40 -0
  65. package/src/actions/spark/SparkSpTokenPaybackAction.ts +64 -0
  66. package/src/actions/spark/SparkSupplyAction.ts +75 -0
  67. package/src/actions/spark/SparkSwapBorrowRateModeAction.ts +46 -0
  68. package/src/actions/spark/SparkWithdrawAction.ts +53 -0
  69. package/src/actions/spark/index.ts +9 -0
  70. package/src/addresses.ts +15 -0
  71. package/src/triggers/SparkQuotePriceTrigger.ts +14 -0
  72. package/src/triggers/SparkRatioTrigger.ts +14 -0
  73. package/src/triggers/index.ts +2 -0
  74. package/umd/index.js +1274 -420
  75. package/yarn-error.log +0 -3976
@@ -0,0 +1,19 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, uint256 } from '../../types';
3
+ /**
4
+ * SDaiUnwrapAction - Unwrap sDAI to DAI
5
+ *
6
+ * @category Spark
7
+ */
8
+ export declare class SDaiUnwrapAction extends Action {
9
+ /**
10
+ * @param amount Amount of token to unwrap
11
+ * @param from Address we are pulling sDAI from (fallback to proxy)
12
+ * @param to Address we are sending DAI to (fallback to proxy)
13
+ */
14
+ constructor(amount: uint256, from?: EthAddress, to?: EthAddress);
15
+ getAssetsToApprove(): Promise<{
16
+ asset: string;
17
+ owner: any;
18
+ }[]>;
19
+ }
@@ -0,0 +1,39 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getAssetInfo } from '@defisaver/tokens';
11
+ import { Action } from '../../Action';
12
+ import { getAddr } from '../../addresses';
13
+ import { requireAddress } from '../../utils/general';
14
+ /**
15
+ * SDaiUnwrapAction - Unwrap sDAI to DAI
16
+ *
17
+ * @category Spark
18
+ */
19
+ export class SDaiUnwrapAction extends Action {
20
+ /**
21
+ * @param amount Amount of token to unwrap
22
+ * @param from Address we are pulling sDAI from (fallback to proxy)
23
+ * @param to Address we are sending DAI to (fallback to proxy)
24
+ */
25
+ constructor(amount, from = getAddr('Empty'), to = getAddr('Empty')) {
26
+ requireAddress(to);
27
+ super('SDaiUnwrap', getAddr('SDaiUnwrap'), ['uint256', 'address', 'address'], [amount, from, to]);
28
+ this.mappableArgs = [
29
+ this.args[0],
30
+ this.args[1],
31
+ this.args[2],
32
+ ];
33
+ }
34
+ getAssetsToApprove() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return [{ asset: getAssetInfo('sDAI').address, owner: this.args[1] }];
37
+ });
38
+ }
39
+ }
@@ -0,0 +1,19 @@
1
+ import { Action } from '../../Action';
2
+ import { EthAddress, uint256 } from '../../types';
3
+ /**
4
+ * SDaiWrapAction - Wrap DAI to sDAI
5
+ *
6
+ * @category Spark
7
+ */
8
+ export declare class SDaiWrapAction extends Action {
9
+ /**
10
+ * @param amount Amount of token to wrap
11
+ * @param from Address we are pulling DAI from (fallback to proxy)
12
+ * @param to Address we are sending sDAI to (fallback to proxy)
13
+ */
14
+ constructor(amount: uint256, from?: EthAddress, to?: EthAddress);
15
+ getAssetsToApprove(): Promise<{
16
+ asset: string;
17
+ owner: any;
18
+ }[]>;
19
+ }
@@ -0,0 +1,39 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getAssetInfo } from '@defisaver/tokens';
11
+ import { Action } from '../../Action';
12
+ import { getAddr } from '../../addresses';
13
+ import { requireAddress } from '../../utils/general';
14
+ /**
15
+ * SDaiWrapAction - Wrap DAI to sDAI
16
+ *
17
+ * @category Spark
18
+ */
19
+ export class SDaiWrapAction extends Action {
20
+ /**
21
+ * @param amount Amount of token to wrap
22
+ * @param from Address we are pulling DAI from (fallback to proxy)
23
+ * @param to Address we are sending sDAI to (fallback to proxy)
24
+ */
25
+ constructor(amount, from = getAddr('Empty'), to = getAddr('Empty')) {
26
+ requireAddress(to);
27
+ super('SDaiWrap', getAddr('SDaiWrap'), ['uint256', 'address', 'address'], [amount, from, to]);
28
+ this.mappableArgs = [
29
+ this.args[0],
30
+ this.args[1],
31
+ this.args[2],
32
+ ];
33
+ }
34
+ getAssetsToApprove() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return [{ asset: getAssetInfo('DAI').address, owner: this.args[1] }];
37
+ });
38
+ }
39
+ }
@@ -16,3 +16,5 @@ export * from './GasFeeActionL2';
16
16
  export * from './TransferNFTAction';
17
17
  export * from './SendTokensAction';
18
18
  export * from './CreateSubAction';
19
+ export * from './SDaiWrapAction';
20
+ export * from './SDaiUnwrapAction';
@@ -16,3 +16,5 @@ export * from './GasFeeActionL2';
16
16
  export * from './TransferNFTAction';
17
17
  export * from './SendTokensAction';
18
18
  export * from './CreateSubAction';
19
+ export * from './SDaiWrapAction';
20
+ export * from './SDaiUnwrapAction';
@@ -0,0 +1,14 @@
1
+ import { Action } from '../../Action';
2
+ import { uint8, uint256 } from '../../types';
3
+ /**
4
+ * SparkRatioCheckAction - Checks spark ratio for users proxy position and reverts if faulty
5
+ *
6
+ * @category Checkers
7
+ */
8
+ export declare class SparkRatioCheckAction extends Action {
9
+ /**
10
+ * @param ratioState If it should lower/higher
11
+ * @param targetRatio The ratio user want to be at
12
+ */
13
+ constructor(ratioState: uint8, targetRatio: uint256);
14
+ }
@@ -0,0 +1,20 @@
1
+ import { Action } from '../../Action';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * SparkRatioCheckAction - Checks spark ratio for users proxy position and reverts if faulty
5
+ *
6
+ * @category Checkers
7
+ */
8
+ export class SparkRatioCheckAction extends Action {
9
+ /**
10
+ * @param ratioState If it should lower/higher
11
+ * @param targetRatio The ratio user want to be at
12
+ */
13
+ constructor(ratioState, targetRatio) {
14
+ super('SparkRatioCheck', getAddr('SparkRatioCheck'), ['uint8', 'uint256'], [ratioState, targetRatio]);
15
+ this.mappableArgs = [
16
+ this.args[0],
17
+ this.args[1],
18
+ ];
19
+ }
20
+ }
@@ -2,3 +2,4 @@ export * from './MakerRatioCheckAction';
2
2
  export * from './AaveV3RatioCheckAction';
3
3
  export * from './CompoundV3RatioCheckAction';
4
4
  export * from './LiquityRatioCheckAction';
5
+ export * from './SparkRatioCheckAction';
@@ -2,3 +2,4 @@ export * from './MakerRatioCheckAction';
2
2
  export * from './AaveV3RatioCheckAction';
3
3
  export * from './CompoundV3RatioCheckAction';
4
4
  export * from './LiquityRatioCheckAction';
5
+ export * from './SparkRatioCheckAction';
@@ -35,7 +35,7 @@ _FLAction_instances = new WeakSet(), _FLAction_handleArgs = function _FLAction_h
35
35
  if (specificFLAction.constructor.name === 'BalancerFlashLoanAction') {
36
36
  argsToReturn[5] = [2];
37
37
  }
38
- if (specificFLAction.constructor.name === 'EulerFlashLoanAction') {
38
+ if (specificFLAction.constructor.name === 'GhoFlashLoanAction') {
39
39
  argsToReturn[5] = [3];
40
40
  }
41
41
  if (specificFLAction.constructor.name === 'MakerFlashLoanAction') {
@@ -44,5 +44,11 @@ _FLAction_instances = new WeakSet(), _FLAction_handleArgs = function _FLAction_h
44
44
  if (specificFLAction.constructor.name === 'AaveV3FlashLoanAction') {
45
45
  argsToReturn[5] = [5];
46
46
  }
47
+ if (specificFLAction.constructor.name === 'UniV3FlashLoanAction') {
48
+ argsToReturn[5] = [6];
49
+ }
50
+ if (specificFLAction.constructor.name === 'SparkFlashLoanAction') {
51
+ argsToReturn[5] = [7];
52
+ }
47
53
  return argsToReturn;
48
54
  };
@@ -0,0 +1,18 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { EthAddress, uint256, bytes } from '../../types';
3
+ /**
4
+ * Gets a flashloan from Spark with fee enabled
5
+ *
6
+ * @category Flashloans
7
+ */
8
+ export declare class SparkFlashLoanAction extends ActionWithL2 {
9
+ /**
10
+ * @param loanAmounts
11
+ * @param tokens
12
+ * @param modes
13
+ * @param loanPayer
14
+ * @param flParamGetterAddr
15
+ * @param flParamGetterData
16
+ */
17
+ constructor(tokens: Array<EthAddress>, loanAmounts: Array<uint256>, modes: Array<uint256>, loanPayer: EthAddress, flParamGetterAddr?: EthAddress, flParamGetterData?: bytes);
18
+ }
@@ -0,0 +1,20 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * Gets a flashloan from Spark with fee enabled
5
+ *
6
+ * @category Flashloans
7
+ */
8
+ export class SparkFlashLoanAction extends ActionWithL2 {
9
+ /**
10
+ * @param loanAmounts
11
+ * @param tokens
12
+ * @param modes
13
+ * @param loanPayer
14
+ * @param flParamGetterAddr
15
+ * @param flParamGetterData
16
+ */
17
+ constructor(tokens, loanAmounts, modes, loanPayer, flParamGetterAddr = getAddr('Empty'), flParamGetterData = []) {
18
+ super('FLSpark', getAddr('FLSpark'), ['address[]', 'uint256[]', 'uint256[]', 'address', 'address', 'bytes', 'bytes'], [tokens, loanAmounts, modes, loanPayer, flParamGetterAddr, flParamGetterData, []]);
19
+ }
20
+ }
@@ -0,0 +1,14 @@
1
+ import { SendTokenAction } from '../basic';
2
+ import { EthAddress, uint256 } from '../../types';
3
+ /**
4
+ * Pays back a single flashloan from Spark with fee enabled
5
+ *
6
+ * @category Flashloans
7
+ */
8
+ export declare class SparkFlashLoanPaybackAction extends SendTokenAction {
9
+ /**
10
+ * @param loanAmount
11
+ * @param tokenAddr
12
+ */
13
+ constructor(loanAmount: uint256, tokenAddr: EthAddress);
14
+ }
@@ -0,0 +1,16 @@
1
+ import { SendTokenAction } from '../basic';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * Pays back a single flashloan from Spark with fee enabled
5
+ *
6
+ * @category Flashloans
7
+ */
8
+ export class SparkFlashLoanPaybackAction extends SendTokenAction {
9
+ /**
10
+ * @param loanAmount
11
+ * @param tokenAddr
12
+ */
13
+ constructor(loanAmount, tokenAddr) {
14
+ super(tokenAddr, getAddr('FLSpark'), loanAmount);
15
+ }
16
+ }
@@ -6,6 +6,8 @@ export * from './AaveV3FlashLoanAction';
6
6
  export * from './AaveV3FlashLoanPaybackAction';
7
7
  export * from './AaveV3FlashLoanNoFeeAction';
8
8
  export * from './AaveV3FlashLoanNoFeePaybackAction';
9
+ export * from './SparkFlashLoanAction';
10
+ export * from './SparkFlashLoanPaybackAction';
9
11
  export * from './MakerFlashLoanAction';
10
12
  export * from './MakerFlashLoanPaybackAction';
11
13
  export * from './BalancerFlashLoanAction';
@@ -6,6 +6,8 @@ export * from './AaveV3FlashLoanAction';
6
6
  export * from './AaveV3FlashLoanPaybackAction';
7
7
  export * from './AaveV3FlashLoanNoFeeAction';
8
8
  export * from './AaveV3FlashLoanNoFeePaybackAction';
9
+ export * from './SparkFlashLoanAction';
10
+ export * from './SparkFlashLoanPaybackAction';
9
11
  export * from './MakerFlashLoanAction';
10
12
  export * from './MakerFlashLoanPaybackAction';
11
13
  export * from './BalancerFlashLoanAction';
@@ -24,4 +24,5 @@ import * as compoundV3 from './compoundV3';
24
24
  import * as morpho from './morpho';
25
25
  import * as bprotocol from './bprotocol';
26
26
  import * as curveusd from './curveusd';
27
- export { aave, maker, compound, basic, flashloan, uniswap, reflexer, dydx, uniswapV3, checkers, liquity, yearn, lido, insta, balancer, curve, guni, mstable, rari, aaveV3, convex, chickenBonds, compoundV3, morpho, bprotocol, curveusd, };
27
+ import * as spark from './spark';
28
+ export { aave, maker, compound, basic, flashloan, uniswap, reflexer, dydx, uniswapV3, checkers, liquity, yearn, lido, insta, balancer, curve, guni, mstable, rari, aaveV3, convex, chickenBonds, compoundV3, morpho, bprotocol, spark, curveusd, };
@@ -24,4 +24,5 @@ import * as compoundV3 from './compoundV3';
24
24
  import * as morpho from './morpho';
25
25
  import * as bprotocol from './bprotocol';
26
26
  import * as curveusd from './curveusd';
27
- export { aave, maker, compound, basic, flashloan, uniswap, reflexer, dydx, uniswapV3, checkers, liquity, yearn, lido, insta, balancer, curve, guni, mstable, rari, aaveV3, convex, chickenBonds, compoundV3, morpho, bprotocol, curveusd, };
27
+ import * as spark from './spark';
28
+ export { aave, maker, compound, basic, flashloan, uniswap, reflexer, dydx, uniswapV3, checkers, liquity, yearn, lido, insta, balancer, curve, guni, mstable, rari, aaveV3, convex, chickenBonds, compoundV3, morpho, bprotocol, spark, curveusd, };
@@ -0,0 +1,21 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { EthAddress, uint8, uint16, uint256 } from '../../types';
3
+ /**
4
+ * SparkBorrowAction - Borrow a token from Spark
5
+ *
6
+ * @category Spark
7
+ */
8
+ export declare class SparkBorrowAction extends ActionWithL2 {
9
+ /**
10
+ * @param useDefaultMarket If this is true it defaults to the hardcoded market in contract
11
+ * @param market Address provider for specific market
12
+ * @param amount Amount of tokens to be borrowed
13
+ * @param to The address we are sending the borrowed tokens to
14
+ * @param rateMode Type of borrow debt [Stable: 1, Variable: 2]
15
+ * @param assetId The id of the token to be borrowed
16
+ * @param useOnBehalf use on behalf or default to proxy
17
+ * @param onBehalf On whose behalf we borrow the tokens, defaults to proxy
18
+ */
19
+ constructor(useDefaultMarket: boolean, market: EthAddress, amount: uint256, to: EthAddress, rateMode: uint8, assetId: uint16, useOnBehalf: boolean, onBehalf?: EthAddress);
20
+ encodeInputs(): string;
21
+ }
@@ -0,0 +1,59 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { getAddr } from '../../addresses';
3
+ import { requireAddress } from '../../utils/general';
4
+ /**
5
+ * SparkBorrowAction - Borrow a token from Spark
6
+ *
7
+ * @category Spark
8
+ */
9
+ export class SparkBorrowAction extends ActionWithL2 {
10
+ /**
11
+ * @param useDefaultMarket If this is true it defaults to the hardcoded market in contract
12
+ * @param market Address provider for specific market
13
+ * @param amount Amount of tokens to be borrowed
14
+ * @param to The address we are sending the borrowed tokens to
15
+ * @param rateMode Type of borrow debt [Stable: 1, Variable: 2]
16
+ * @param assetId The id of the token to be borrowed
17
+ * @param useOnBehalf use on behalf or default to proxy
18
+ * @param onBehalf On whose behalf we borrow the tokens, defaults to proxy
19
+ */
20
+ constructor(useDefaultMarket, market, amount, to, rateMode, assetId, useOnBehalf, onBehalf = getAddr('Empty')) {
21
+ requireAddress(to);
22
+ super('SparkBorrow', getAddr('SparkBorrow'), ['uint256', 'address', 'uint8', 'uint16', 'bool', 'bool', 'address', 'address'], [amount, to, rateMode, assetId, useDefaultMarket, useOnBehalf, market, onBehalf]);
23
+ this.mappableArgs = [
24
+ this.args[0],
25
+ this.args[1],
26
+ this.args[2],
27
+ this.args[3],
28
+ this.args[4],
29
+ this.args[5],
30
+ this.args[6],
31
+ this.args[7],
32
+ ];
33
+ }
34
+ encodeInputs() {
35
+ // executeActionDirectL2
36
+ let encodedInput = '0x2895f3aa';
37
+ // amount
38
+ encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0]));
39
+ // to
40
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[1]));
41
+ // rateMode
42
+ encodedInput = encodedInput.concat(this.numberToBytes1(this.args[2]));
43
+ // assetId
44
+ encodedInput = encodedInput.concat(this.numberToBytes2(this.args[3]));
45
+ // useDefaultMarket
46
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[4]));
47
+ // useOnBehalf
48
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[5]));
49
+ if (!this.args[4]) {
50
+ // market
51
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[6]));
52
+ }
53
+ if (this.args[5]) {
54
+ // onBehalf
55
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[7]));
56
+ }
57
+ return encodedInput;
58
+ }
59
+ }
@@ -0,0 +1,18 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { EthAddress, uint8, uint256 } from '../../types';
3
+ /**
4
+ * SparkClaimRewardsAction
5
+ *
6
+ * @category Spark
7
+ */
8
+ export declare class SparkClaimRewardsAction extends ActionWithL2 {
9
+ /**
10
+ * @param assetsLength Address provider for specific market
11
+ * @param amount length of two arrays
12
+ * @param to Address where claimed tokens will end up on .
13
+ * @param reward Address of rewarded token
14
+ * @param assets Array of position assets to check earned rewards against
15
+ */
16
+ constructor(assetsLength: uint8, amount: uint256, to: EthAddress, reward: EthAddress, assets: Array<EthAddress>);
17
+ encodeInputs(): string;
18
+ }
@@ -0,0 +1,40 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { getAddr } from '../../addresses';
3
+ import { requireAddress } from '../../utils/general';
4
+ /**
5
+ * SparkClaimRewardsAction
6
+ *
7
+ * @category Spark
8
+ */
9
+ export class SparkClaimRewardsAction extends ActionWithL2 {
10
+ /**
11
+ * @param assetsLength Address provider for specific market
12
+ * @param amount length of two arrays
13
+ * @param to Address where claimed tokens will end up on .
14
+ * @param reward Address of rewarded token
15
+ * @param assets Array of position assets to check earned rewards against
16
+ */
17
+ constructor(assetsLength, amount, to, reward, assets) {
18
+ requireAddress(to);
19
+ super('SparkClaimRewards', getAddr('SparkClaimRewards'), ['uint8', 'uint256', 'address', 'address', 'address[]'], [assetsLength, amount, to, reward, assets]);
20
+ }
21
+ encodeInputs() {
22
+ // executeActionDirectL2
23
+ let encodedInput = '0x2895f3aa';
24
+ // assetsLength
25
+ encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0]));
26
+ // amount
27
+ encodedInput = encodedInput.concat(this.numberToBytes32(this.args[1]));
28
+ // to
29
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[2]));
30
+ // reward
31
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[3]));
32
+ // assets
33
+ const arrayLength = this.args[0];
34
+ for (let i = 0; i < arrayLength; i++) {
35
+ // assets[i]
36
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[4][i]));
37
+ }
38
+ return encodedInput;
39
+ }
40
+ }
@@ -0,0 +1,18 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { EthAddress, uint8, uint16 } from '../../types';
3
+ /**
4
+ * SparkCollateralSwitchAction - Enable/disable token usage as collateral for Spark position
5
+ *
6
+ * @category Spark
7
+ */
8
+ export declare class SparkCollateralSwitchAction extends ActionWithL2 {
9
+ /**
10
+ * @param useDefaultMarket If this is true it defaults to the hardcoded market in contract
11
+ * @param market Address provider for specific market
12
+ * @param arrayLength length of two arrays
13
+ * @param assetIds Ids of assets to switch
14
+ * @param useAsCollateral Array of booleans representing collateral state
15
+ */
16
+ constructor(useDefaultMarket: boolean, market: EthAddress, arrayLength: uint8, assetIds: Array<uint16>, useAsCollateral: Array<boolean>);
17
+ encodeInputs(): string;
18
+ }
@@ -0,0 +1,39 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { getAddr } from '../../addresses';
3
+ /**
4
+ * SparkCollateralSwitchAction - Enable/disable token usage as collateral for Spark position
5
+ *
6
+ * @category Spark
7
+ */
8
+ export class SparkCollateralSwitchAction extends ActionWithL2 {
9
+ /**
10
+ * @param useDefaultMarket If this is true it defaults to the hardcoded market in contract
11
+ * @param market Address provider for specific market
12
+ * @param arrayLength length of two arrays
13
+ * @param assetIds Ids of assets to switch
14
+ * @param useAsCollateral Array of booleans representing collateral state
15
+ */
16
+ constructor(useDefaultMarket, market, arrayLength, assetIds, useAsCollateral) {
17
+ super('SparkCollateralSwitch', getAddr('SparkCollateralSwitch'), ['uint8', 'bool', 'uint16[]', 'bool[]', 'address'], [arrayLength, useDefaultMarket, assetIds, useAsCollateral, market]);
18
+ }
19
+ encodeInputs() {
20
+ // executeActionDirectL2
21
+ let encodedInput = '0x2895f3aa';
22
+ // arrayLength
23
+ encodedInput = encodedInput.concat(this.numberToBytes1(this.args[0]));
24
+ // useDefaultMarket
25
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[1]));
26
+ const arrayLength = this.args[0];
27
+ for (let i = 0; i < arrayLength; i++) {
28
+ // assetIds[i]
29
+ encodedInput = encodedInput.concat(this.numberToBytes2(this.args[2][i]));
30
+ // useAsCollateral[i]
31
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[3][i]));
32
+ }
33
+ if (!this.args[1]) {
34
+ // market
35
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[4]));
36
+ }
37
+ return encodedInput;
38
+ }
39
+ }
@@ -0,0 +1,27 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { EthAddress, uint8, uint16, uint256 } from '../../types';
3
+ /**
4
+ * SparkPaybackAction - Payback debt on Spark using underlying token
5
+ *
6
+ * @category Spark
7
+ */
8
+ export declare class SparkPaybackAction extends ActionWithL2 {
9
+ tokenForApproval: EthAddress;
10
+ /**
11
+ * @param useOnDefaultMarket If this is true it defaults to the hardcoded market in contract
12
+ * @param market Address provider for specific market
13
+ * @param amount Amount of tokens to be payed back
14
+ * @param from Tokens will be supplied from this address
15
+ * @param rateMode Type of borrow debt [Stable: 1, Variable: 2]
16
+ * @param tokenAddress Address of token to pay back.
17
+ * @param assetId The id of the underlying asset to be repaid
18
+ * @param useOnBehalf use on behalf param or default to proxy
19
+ * @param onBehalf For what user we are paying back the debt, defaults to proxy
20
+ */
21
+ constructor(useOnDefaultMarket: boolean, market: EthAddress, amount: uint256, from: EthAddress, rateMode: uint8, tokenAddress: EthAddress, assetId: uint16, useOnBehalf: boolean, onBehalf?: EthAddress);
22
+ getAssetsToApprove(): Promise<{
23
+ asset: string;
24
+ owner: any;
25
+ }[]>;
26
+ encodeInputs(): string;
27
+ }
@@ -0,0 +1,77 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { getAssetInfoByAddress } from '@defisaver/tokens';
11
+ import { ActionWithL2 } from '../../ActionWithL2';
12
+ import { getAddr } from '../../addresses';
13
+ /**
14
+ * SparkPaybackAction - Payback debt on Spark using underlying token
15
+ *
16
+ * @category Spark
17
+ */
18
+ export class SparkPaybackAction extends ActionWithL2 {
19
+ /**
20
+ * @param useOnDefaultMarket If this is true it defaults to the hardcoded market in contract
21
+ * @param market Address provider for specific market
22
+ * @param amount Amount of tokens to be payed back
23
+ * @param from Tokens will be supplied from this address
24
+ * @param rateMode Type of borrow debt [Stable: 1, Variable: 2]
25
+ * @param tokenAddress Address of token to pay back.
26
+ * @param assetId The id of the underlying asset to be repaid
27
+ * @param useOnBehalf use on behalf param or default to proxy
28
+ * @param onBehalf For what user we are paying back the debt, defaults to proxy
29
+ */
30
+ constructor(useOnDefaultMarket, market, amount, from, rateMode, tokenAddress, assetId, useOnBehalf, onBehalf = getAddr('Empty')) {
31
+ super('SparkPayback', getAddr('SparkPayback'), ['uint256', 'address', 'uint8', 'uint16', 'bool', 'bool', 'address', 'address'], [amount, from, rateMode, assetId, useOnDefaultMarket, useOnBehalf, market, onBehalf]);
32
+ this.mappableArgs = [
33
+ this.args[0],
34
+ this.args[1],
35
+ this.args[2],
36
+ this.args[3],
37
+ this.args[4],
38
+ this.args[5],
39
+ this.args[6],
40
+ this.args[7],
41
+ ];
42
+ this.tokenForApproval = tokenAddress;
43
+ }
44
+ getAssetsToApprove() {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const asset = getAssetInfoByAddress(this.tokenForApproval);
47
+ if (asset.symbol !== 'ETH')
48
+ return [{ asset: this.tokenForApproval, owner: this.args[1] }];
49
+ return [];
50
+ });
51
+ }
52
+ encodeInputs() {
53
+ // executeActionDirectL2
54
+ let encodedInput = '0x2895f3aa';
55
+ // amount
56
+ encodedInput = encodedInput.concat(this.numberToBytes32(this.args[0]));
57
+ // from
58
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[1]));
59
+ // rateMode
60
+ encodedInput = encodedInput.concat(this.numberToBytes1(this.args[2]));
61
+ // assetId
62
+ encodedInput = encodedInput.concat(this.numberToBytes2(this.args[3]));
63
+ // useDefaultMarket
64
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[4]));
65
+ // useOnBehalf
66
+ encodedInput = encodedInput.concat(this.boolToBytes1(this.args[5]));
67
+ if (!this.args[4]) {
68
+ // market
69
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[6]));
70
+ }
71
+ if (this.args[5]) {
72
+ // onBehalf
73
+ encodedInput = encodedInput.concat(this.addressToBytes20(this.args[7]));
74
+ }
75
+ return encodedInput;
76
+ }
77
+ }
@@ -0,0 +1,16 @@
1
+ import { ActionWithL2 } from '../../ActionWithL2';
2
+ import { EthAddress, uint8 } from '../../types';
3
+ /**
4
+ * SparkSetEModeAction - Set EMode for the proxy Spark position
5
+ *
6
+ * @category Spark
7
+ */
8
+ export declare class SparkSetEModeAction extends ActionWithL2 {
9
+ /**
10
+ * @param useOnDefaultMarket If this is true it defaults to the hardcoded market in contract
11
+ * @param market Address provider for specific market
12
+ * @param categoryId ID of the category emode
13
+ */
14
+ constructor(useOnDefaultMarket: boolean, market: EthAddress, categoryId: uint8);
15
+ encodeInputs(): string;
16
+ }