Skip to content

Commit

Permalink
Merge branch 'dev' into jt/sc-14561/sc-deploy-collectfee-action-add-n…
Browse files Browse the repository at this point in the history
…ew-ops-to
  • Loading branch information
halaprix committed Mar 11, 2024
2 parents cddc445 + 1b75e1d commit 2f3d2ad
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 66 deletions.
10 changes: 5 additions & 5 deletions packages/deploy-configurations/configs/mainnet.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,15 @@ export const config: SystemConfig = {
SparkBorrow: {
name: 'SparkBorrow',
deploy: false,
address: '0xc69156420307048c9BAAe8191f9012391521a88d',
address: '0x8E6c0131D9F67209Ae540bBD90dBa2223D1f74Ca',
serviceRegistryName: SERVICE_REGISTRY_NAMES.spark.BORROW,
history: ['0x0000000000000000000000000000000000000000'],
constructorArgs: ['address:ServiceRegistry'],
},
SparkWithdraw: {
name: 'SparkWithdraw',
deploy: false,
address: '0x0cCa782002c4fE95e1ed7A75d41bB56bEfa0C167',
address: '0xCeEb07b5F147094AF1b492560BC4cA0f20867df5',
serviceRegistryName: SERVICE_REGISTRY_NAMES.spark.WITHDRAW,
history: ['0x0000000000000000000000000000000000000000'],
constructorArgs: ['address:ServiceRegistry'],
Expand All @@ -421,23 +421,23 @@ export const config: SystemConfig = {
SparkDeposit: {
name: 'SparkDeposit',
deploy: false,
address: '0xC58F2Ee4Ef92F2bE314743442496D6Fad0339d56',
address: '0x347fedF00Dce16Bbb03CFDC75b2aBC342d96Be9A',
serviceRegistryName: SERVICE_REGISTRY_NAMES.spark.DEPOSIT,
history: ['0x0000000000000000000000000000000000000000'],
constructorArgs: ['address:ServiceRegistry'],
},
SparkPayback: {
name: 'SparkPayback',
deploy: false,
address: '0x068875B4254aC431BE7B8a10C56D80324fA0d043',
address: '0x8e810D5a9De2dBc846F78F2B61745f3c4801Af51',
serviceRegistryName: SERVICE_REGISTRY_NAMES.spark.PAYBACK,
history: ['0x0000000000000000000000000000000000000000'],
constructorArgs: ['address:ServiceRegistry'],
},
SparkSetEMode: {
name: 'SparkSetEMode',
deploy: false,
address: '0x79d428e563D946DaBe43C681f92c8D714F5157cE',
address: '0xC4E599220775220c610e8Bba607310096711ba5e',
serviceRegistryName: SERVICE_REGISTRY_NAMES.spark.SET_EMODE,
history: ['0x0000000000000000000000000000000000000000'],
constructorArgs: ['address:ServiceRegistry'],
Expand Down
12 changes: 6 additions & 6 deletions packages/deploy-configurations/constants/load-contract-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ export const SERVICE_REGISTRY_NAMES = {
L2_ENCODER: 'AaveL2Encoder',
},
spark: {
DEPOSIT: 'SparkDeposit',
WITHDRAW: 'SparkWithdraw',
WITHDRAW_AUTO: 'SparkWithdrawAuto',
BORROW: 'SparkBorrow',
PAYBACK: 'SparkPayback',
DEPOSIT: 'SparkDeposit_auto_3',
WITHDRAW: 'SparkWithdraw_auto_3',
WITHDRAW_AUTO: 'SparkWithdrawAuto_auto_3',
BORROW: 'SparkBorrow_auto_3',
PAYBACK: 'SparkPayback_auto_3',
LENDING_POOL: 'SparkLendingPool',
SET_EMODE: 'SparkSetEMode',
SET_EMODE: 'SparkSetEMode_auto_3',
},
maker: {
DEPOSIT: 'MakerDeposit',
Expand Down
8 changes: 4 additions & 4 deletions packages/deploy-configurations/constants/operation-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export const OPERATION_NAMES = {
},
spark: {
OPEN_POSITION: 'SparkOpenPosition',
CLOSE_AND_EXIT: 'SparkClosePosition',
CLOSE_AND_REMAIN: 'CloseAndRemainSparkPosition',
ADJUST_RISK_UP: 'SparkAdjustRiskUp_Auto_2',
ADJUST_RISK_DOWN: 'SparkAdjustRiskDown_Auto_2',
CLOSE_AND_EXIT: 'SparkClosePosition_4',
CLOSE_AND_REMAIN: 'CloseAndRemainSparkPosition_4',
ADJUST_RISK_UP: 'SparkAdjustRiskUp_Auto_4',
ADJUST_RISK_DOWN: 'SparkAdjustRiskDown_Auto_4',
DEPOSIT_BORROW: 'SparkDepositBorrow',
OPEN_DEPOSIT_BORROW: 'SparkOpenDepositBorrow',
DEPOSIT: 'SparkDeposit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ contract SetApproval is Executable, UseStorageSlot, UseRegistry {
bytes32(approval.amount),
paramsMap[2]
);

uint256 actualApprovalAmount = approval.sumAmounts
? mappedApprovalAmount.add(approval.amount)
: mappedApprovalAmount;
Expand Down
13 changes: 7 additions & 6 deletions packages/dma-contracts/contracts/actions/spark/Borrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
pragma solidity ^0.8.15;

import { Executable } from "../common/Executable.sol";
import { Write, UseStore } from "../common/UseStore.sol";
import { OperationStorage } from "../../core/OperationStorage.sol";
import { UseStorageSlot, StorageSlot, Write, Read } from "../../libs/UseStorageSlot.sol";
import { BorrowData } from "../../core/types/Spark.sol";
import { SPARK_LENDING_POOL } from "../../core/constants/Spark.sol";
import { IPool } from "../../interfaces/spark/IPool.sol";
import { ServiceRegistry } from "../../core/ServiceRegistry.sol";
import { UseRegistry } from "../../libs/UseRegistry.sol";

/**
* @title Borrow | Spark Action contract
* @notice Borrows tokens from Spark's lending pool
*/
contract SparkBorrow is Executable, UseStore {
using Write for OperationStorage;
contract SparkBorrow is Executable, UseStorageSlot, UseRegistry {
using Write for StorageSlot.TransactionStorage;

constructor(address _registry) UseStore(_registry) {}
constructor(address _registry) UseRegistry(ServiceRegistry(_registry)) {}

/**
* @param data Encoded calldata that conforms to the BorrowData struct
*/
function execute(bytes calldata data, uint8[] memory) external payable override {
BorrowData memory borrow = parseInputs(data);

IPool(registry.getRegisteredService(SPARK_LENDING_POOL)).borrow(
IPool(getRegisteredService(SPARK_LENDING_POOL)).borrow(
borrow.asset,
borrow.amount,
2,
Expand Down
20 changes: 10 additions & 10 deletions packages/dma-contracts/contracts/actions/spark/Deposit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
pragma solidity ^0.8.15;

import { Executable } from "../common/Executable.sol";
import { Read, Write, UseStore } from "../common/UseStore.sol";
import { OperationStorage } from "../../core/OperationStorage.sol";
import { UseStorageSlot, StorageSlot, Write, Read } from "../../libs/UseStorageSlot.sol";
import { DepositData } from "../../core/types/Spark.sol";
import { SPARK_LENDING_POOL } from "../../core/constants/Spark.sol";
import { IPool } from "../../interfaces/spark/IPool.sol";
import { ServiceRegistry } from "../../core/ServiceRegistry.sol";
import { UseRegistry } from "../../libs/UseRegistry.sol";
import { SafeMath } from "../../libs/SafeMath.sol";

/**
* @title Deposit | Spark Action contract
* @notice Deposits the specified asset as collateral to Spark's lending pool
*/
contract SparkDeposit is Executable, UseStore {
using Write for OperationStorage;
using Read for OperationStorage;
contract SparkDeposit is Executable, UseStorageSlot, UseRegistry {
using Read for StorageSlot.TransactionStorage;
using Write for StorageSlot.TransactionStorage;
using SafeMath for uint256;

constructor(address _registry) UseStore(_registry) {}
constructor(address _registry) UseRegistry(ServiceRegistry(_registry)) {}

/**
* @dev Look at UseStore.sol to get additional info on paramsMapping
Expand All @@ -30,23 +31,22 @@ contract SparkDeposit is Executable, UseStore {

uint256 mappedDepositAmount = store().readUint(
bytes32(deposit.amount),
paramsMap[1],
address(this)
paramsMap[1]
);

uint256 actualDepositAmount = deposit.sumAmounts
? mappedDepositAmount.add(deposit.amount)
: mappedDepositAmount;

IPool(registry.getRegisteredService(SPARK_LENDING_POOL)).supply(
IPool(getRegisteredService(SPARK_LENDING_POOL)).supply(
deposit.asset,
actualDepositAmount,
address(this),
0
);

if (deposit.setAsCollateral) {
IPool(registry.getRegisteredService(SPARK_LENDING_POOL)).setUserUseReserveAsCollateral(
IPool(getRegisteredService(SPARK_LENDING_POOL)).setUserUseReserveAsCollateral(
deposit.asset,
true
);
Expand Down
17 changes: 9 additions & 8 deletions packages/dma-contracts/contracts/actions/spark/Payback.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
pragma solidity ^0.8.15;

import { Executable } from "../common/Executable.sol";
import { Read, Write, UseStore } from "../common/UseStore.sol";
import { OperationStorage } from "../../core/OperationStorage.sol";
import { UseStorageSlot, StorageSlot, Write, Read } from "../../libs/UseStorageSlot.sol";
import { PaybackData } from "../../core/types/Spark.sol";
import { SPARK_LENDING_POOL } from "../../core/constants/Spark.sol";
import { ServiceRegistry } from "../../core/ServiceRegistry.sol";
import { UseRegistry } from "../../libs/UseRegistry.sol";
import { IPool } from "../../interfaces/spark/IPool.sol";

/**
* @title Payback | Spark Action contract
* @notice Pays back a specified amount to Spark's lending pool
*/
contract SparkPayback is Executable, UseStore {
using Write for OperationStorage;
using Read for OperationStorage;
contract SparkPayback is Executable, UseStorageSlot, UseRegistry {
using Read for StorageSlot.TransactionStorage;
using Write for StorageSlot.TransactionStorage;

constructor(address _registry) UseStore(_registry) {}
constructor(address _registry) UseRegistry(ServiceRegistry(_registry)) {}

/**
* @dev Look at UseStore.sol to get additional info on paramsMapping.
Expand All @@ -27,9 +28,9 @@ contract SparkPayback is Executable, UseStore {
function execute(bytes calldata data, uint8[] memory paramsMap) external payable override {
PaybackData memory payback = parseInputs(data);

payback.amount = store().readUint(bytes32(payback.amount), paramsMap[1], address(this));
payback.amount = store().readUint(bytes32(payback.amount), paramsMap[1]);

IPool(registry.getRegisteredService(SPARK_LENDING_POOL)).repay(
IPool(getRegisteredService(SPARK_LENDING_POOL)).repay(
payback.asset,
payback.paybackAll ? type(uint256).max : payback.amount,
2,
Expand Down
13 changes: 7 additions & 6 deletions packages/dma-contracts/contracts/actions/spark/SetEMode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
pragma solidity ^0.8.15;

import { Executable } from "../common/Executable.sol";
import { Write, UseStore } from "../common/UseStore.sol";
import { OperationStorage } from "../../core/OperationStorage.sol";
import { UseStorageSlot, StorageSlot, Write, Read } from "../../libs/UseStorageSlot.sol";
import { SetEModeData } from "../../core/types/Spark.sol";
import { SPARK_LENDING_POOL } from "../../core/constants/Spark.sol";
import { IPool } from "../../interfaces/spark/IPool.sol";
import { ServiceRegistry } from "../../core/ServiceRegistry.sol";
import { UseRegistry } from "../../libs/UseRegistry.sol";

/**
* @title SetEMode | Spark Action contract
* @notice Sets the user's eMode on Spark's lending pool
*/
contract SparkSetEMode is Executable, UseStore {
using Write for OperationStorage;
contract SparkSetEMode is Executable, UseStorageSlot, UseRegistry {
using Write for StorageSlot.TransactionStorage;

constructor(address _registry) UseStore(_registry) {}
constructor(address _registry) UseRegistry(ServiceRegistry(_registry)) {}

/**
* @param data Encoded calldata that conforms to the SetEModeData struct
*/
function execute(bytes calldata data, uint8[] memory) external payable override {
SetEModeData memory emode = parseInputs(data);

IPool(registry.getRegisteredService(SPARK_LENDING_POOL)).setUserEMode(emode.categoryId);
IPool(getRegisteredService(SPARK_LENDING_POOL)).setUserEMode(emode.categoryId);

store().write(bytes32(uint256(emode.categoryId)));
}
Expand Down
13 changes: 7 additions & 6 deletions packages/dma-contracts/contracts/actions/spark/Withdraw.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
pragma solidity ^0.8.15;

import { Executable } from "../common/Executable.sol";
import { Write, UseStore } from "../common/UseStore.sol";
import { OperationStorage } from "../../core/OperationStorage.sol";
import { UseStorageSlot, StorageSlot, Write, Read } from "../../libs/UseStorageSlot.sol";
import { WithdrawData } from "../../core/types/Spark.sol";
import { SPARK_LENDING_POOL } from "../../core/constants/Spark.sol";
import { IPool } from "../../interfaces/spark/IPool.sol";
import { ServiceRegistry } from "../../core/ServiceRegistry.sol";
import { UseRegistry } from "../../libs/UseRegistry.sol";

/**
* @title Withdraw | Spark Action contract
* @notice Withdraw collateral from Spark's lending pool
*/
contract SparkWithdraw is Executable, UseStore {
using Write for OperationStorage;
contract SparkWithdraw is Executable, UseStorageSlot, UseRegistry {
using Write for StorageSlot.TransactionStorage;

constructor(address _registry) UseStore(_registry) {}
constructor(address _registry) UseRegistry(ServiceRegistry(_registry)) {}

/**
* @param data Encoded calldata that conforms to the WithdrawData struct
*/
function execute(bytes calldata data, uint8[] memory) external payable override {
WithdrawData memory withdraw = parseInputs(data);

uint256 amountWithdrawn = IPool(registry.getRegisteredService(SPARK_LENDING_POOL)).withdraw(
uint256 amountWithdrawn = IPool(getRegisteredService(SPARK_LENDING_POOL)).withdraw(
withdraw.asset,
withdraw.amount,
withdraw.to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.15;

import { Executable } from "../common/Executable.sol";
import { OperationStorage } from "../../core/OperationStorage.sol";
import { WithdrawData } from "../../core/types/Spark.sol";
import { SPARK_LENDING_POOL } from "../../core/constants/Spark.sol";
import { IPool } from "../../interfaces/spark/IPool.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export const adjustRiskUp: SparkAdjustUpOperation = async ({
from: proxy.owner,
})

// No previous actions store values with OpStorage
const swapActionStorageIndex = 1
// Stored in first index of inner storage array (based on who)
const swapActionStorageIndex = 2
const swapDebtTokensForCollateralTokens = actions.common.swap(network, {
fromAsset: debt.address,
toAsset: collateral.address,
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6197,9 +6197,9 @@ axios@^0.27.2:
form-data "^4.0.0"

axios@^1.0.0, axios@^1.3.6:
version "1.3.6"
resolved "https://registry.npmjs.org/axios/-/axios-1.3.6.tgz"
integrity sha512-PEcdkk7JcdPiMDkvM4K6ZBRYq9keuVJsToxm2zQIM70Qqo2WHTdJZMXcG9X+RmRp2VPNUQC8W1RAGbgt6b1yMg==
version "1.6.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.0.tgz#f1e5292f26b2fd5c2e66876adc5b06cdbd7d2102"
integrity sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
Expand Down Expand Up @@ -10847,9 +10847,9 @@ get-caller-file@^2.0.1, get-caller-file@^2.0.5:
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==

get-func-name@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz"
integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==
version "2.0.2"
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.2.tgz#0d7cf20cd13fda808669ffa88f4ffc7a3943fc41"
integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==

get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0:
version "1.2.0"
Expand Down Expand Up @@ -14721,9 +14721,9 @@ ms@2.1.3, ms@^2.0.0, ms@^2.1.1:
resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

msgpackr-extract@^3.0.1:
msgpackr-extract@^3.0.2:
version "3.0.2"
resolved "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.2.tgz"
resolved "https://registry.yarnpkg.com/msgpackr-extract/-/msgpackr-extract-3.0.2.tgz#e05ec1bb4453ddf020551bcd5daaf0092a2c279d"
integrity sha512-SdzXp4kD/Qf8agZ9+iTu6eql0m3kWm1A2y1hkpTeVNENutaB0BwHlSvAIaMxwntmRUAUjon2V4L8Z/njd0Ct8A==
dependencies:
node-gyp-build-optional-packages "5.0.7"
Expand All @@ -14736,11 +14736,11 @@ msgpackr-extract@^3.0.1:
"@msgpackr-extract/msgpackr-extract-win32-x64" "3.0.2"

msgpackr@^1.5.4:
version "1.8.5"
resolved "https://registry.npmjs.org/msgpackr/-/msgpackr-1.8.5.tgz"
integrity sha512-mpPs3qqTug6ahbblkThoUY2DQdNXcm4IapwOS3Vm/87vmpzLVelvp9h3It1y9l1VPpiFLV11vfOXnmeEwiIXwg==
version "1.10.1"
resolved "https://registry.yarnpkg.com/msgpackr/-/msgpackr-1.10.1.tgz#51953bb4ce4f3494f0c4af3f484f01cfbb306555"
integrity sha512-r5VRLv9qouXuLiIBrLpl2d5ZvPt8svdQTl5/vMvE4nzDMyEX4sgW5yWhuBBj5UmgwOTWj8CIdSXn5sAfsHAWIQ==
optionalDependencies:
msgpackr-extract "^3.0.1"
msgpackr-extract "^3.0.2"

multibase@^0.7.0:
version "0.7.0"
Expand Down

0 comments on commit 2f3d2ad

Please sign in to comment.