Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ optimizer = true
optimizer_runs = 50
fs_permissions = [{access = "read-write", path = "./"}]

solc_version="0.8.27"
solc_version="0.8.28"

evm_version="shanghai"

Expand Down
2 changes: 1 addition & 1 deletion lib/v2-core
26 changes: 13 additions & 13 deletions scripts/deploy-lbtsa.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
import "forge-std/console.sol";
import {Utils} from "./utils.sol";
import "../src/periphery/LyraSettlementUtils.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/BaseTSA.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/shared/BaseTSA.sol";
import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol";
import {CashAsset} from "v2-core/src/assets/CashAsset.sol";
import {DutchAuction} from "v2-core/src/liquidation/DutchAuction.sol";
Expand Down Expand Up @@ -79,7 +79,18 @@ contract DeployLBTSA is Utils {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingModule("matching")),
symbol: vaultTokenName,
name: string.concat(marketName, " Basis Trade")
name: string.concat(marketName, " Basis Trade"),
initialParams: BaseTSA.TSAParams({
depositCap: 10000000e18,
minDepositValue: 0,
depositScale: 1e18,
// slight withdrawal fee
withdrawScale: 0.998e18,
managementFee: 0,
feeRecipient: address(0),
performanceFeeWindow: 1 weeks,
performanceFee: 0
})
}),
LeveragedBasisTSA.LBTSAInitParams({
baseFeed: ISpotFeed(_getMarketAddress(marketName, "spotFeed")),
Expand All @@ -93,17 +104,6 @@ contract DeployLBTSA is Utils {

LeveragedBasisTSA lbtsa = LeveragedBasisTSA(address(proxy));

lbtsa.setTSAParams(
BaseTSA.TSAParams({
depositCap: 10000000e18,
minDepositValue: 0,
depositScale: 1e18,
// slight withdrawal fee
withdrawScale: 0.998e18,
managementFee: 0,
feeRecipient: address(0)
})
);
lbtsa.setLBTSAParams(defaultLbtsaTSAParams);
lbtsa.setCollateralManagementParams(defaultCollateralManagementParams);

Expand Down
14 changes: 8 additions & 6 deletions scripts/deploy-prod-tsa.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
import "forge-std/console.sol";
import {Utils} from "./utils.sol";
import "../src/periphery/LyraSettlementUtils.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/BaseTSA.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/shared/BaseTSA.sol";
import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol";
import {CashAsset} from "v2-core/src/assets/CashAsset.sol";
import {DutchAuction} from "v2-core/src/liquidation/DutchAuction.sol";
Expand Down Expand Up @@ -60,7 +60,9 @@ contract DeployTSA is Utils {
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0,
feeRecipient: address(0)
feeRecipient: address(0),
performanceFeeWindow: 1 weeks,
performanceFee: 0
});

CollateralManagementTSA.CollateralManagementParams public defaultCollateralManagementParams = CollateralManagementTSA
Expand Down Expand Up @@ -132,7 +134,8 @@ contract DeployTSA is Utils {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingModule("matching")),
symbol: settings.vaultSymbol,
name: settings.vaultName
name: settings.vaultName,
initialParams: defaultBaseTSAParams
}),
CoveredCallTSA.CCTSAInitParams({
baseFeed: ISpotFeed(_getMarketAddress(settings.depositAssetName, "spotFeed")),
Expand All @@ -146,7 +149,6 @@ contract DeployTSA is Utils {

console.log("proxy: ", address(proxy));

CoveredCallTSA(address(proxy)).setTSAParams(defaultBaseTSAParams);
CoveredCallTSA cctsa = CoveredCallTSA(address(proxy));
cctsa.setCCTSAParams(defaultLrtccTSAParams);
cctsa.setCollateralManagementParams(defaultCollateralManagementParams);
Expand Down Expand Up @@ -179,7 +181,8 @@ contract DeployTSA is Utils {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingModule("matching")),
symbol: settings.vaultSymbol,
name: settings.vaultName
name: settings.vaultName,
initialParams: defaultBaseTSAParams
}),
PrincipalProtectedTSA.PPTSAInitParams({
baseFeed: ISpotFeed(_getMarketAddress(settings.depositAssetName, "spotFeed")),
Expand All @@ -198,7 +201,6 @@ contract DeployTSA is Utils {

PrincipalProtectedTSA pptsa = PrincipalProtectedTSA(address(proxy));

pptsa.setTSAParams(defaultBaseTSAParams);
pptsa.setPPTSAParams(defaultLrtppTSAParams);
pptsa.setCollateralManagementParams(defaultCollateralManagementParams);

Expand Down
14 changes: 8 additions & 6 deletions scripts/deploy-tsa-with-implementation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
import "forge-std/console.sol";
import {Utils} from "./utils.sol";
import "../src/periphery/LyraSettlementUtils.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/BaseTSA.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/shared/BaseTSA.sol";
import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol";
import {CashAsset} from "v2-core/src/assets/CashAsset.sol";
import {DutchAuction} from "v2-core/src/liquidation/DutchAuction.sol";
Expand Down Expand Up @@ -72,7 +72,9 @@ contract DeployTSA is Utils {
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0,
feeRecipient: address(0)
feeRecipient: address(0),
performanceFeeWindow: 1 weeks,
performanceFee: 0
});

CollateralManagementTSA.CollateralManagementParams
Expand Down Expand Up @@ -172,7 +174,8 @@ contract DeployTSA is Utils {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingModule("matching")),
symbol: settings.vaultSymbol,
name: settings.vaultName
name: settings.vaultName,
initialParams: defaultBaseTSAParams
}),
CoveredCallTSA.CCTSAInitParams({
baseFeed: ISpotFeed(
Expand All @@ -194,7 +197,6 @@ contract DeployTSA is Utils {

console.log("proxy: ", address(proxy));

CoveredCallTSA(address(proxy)).setTSAParams(defaultBaseTSAParams);
CoveredCallTSA cctsa = CoveredCallTSA(address(proxy));
cctsa.setCCTSAParams(defaultLrtccTSAParams);
cctsa.setCollateralManagementParams(defaultCollateralManagementParams);
Expand Down Expand Up @@ -241,7 +243,8 @@ contract DeployTSA is Utils {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingModule("matching")),
symbol: settings.vaultSymbol,
name: settings.vaultName
name: settings.vaultName,
initialParams: defaultBaseTSAParams
}),
PrincipalProtectedTSA.PPTSAInitParams({
baseFeed: ISpotFeed(
Expand All @@ -268,7 +271,6 @@ contract DeployTSA is Utils {

PrincipalProtectedTSA pptsa = PrincipalProtectedTSA(address(proxy));

pptsa.setTSAParams(defaultBaseTSAParams);
pptsa.setPPTSAParams(defaultLrtppTSAParams);
pptsa.setCollateralManagementParams(defaultCollateralManagementParams);

Expand Down
46 changes: 23 additions & 23 deletions scripts/deploy-tsa.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
import "forge-std/console2.sol";
import {Utils} from "./utils.sol";
import "../src/periphery/LyraSettlementUtils.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/BaseTSA.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/shared/BaseTSA.sol";
import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol";
import {CashAsset} from "v2-core/src/assets/CashAsset.sol";
import {DutchAuction} from "v2-core/src/liquidation/DutchAuction.sol";
Expand Down Expand Up @@ -109,7 +109,17 @@ contract DeployTSA is Utils {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingModule("matching")),
symbol: "ETH",
name: "ETH Covered Call"
name: "ETH Covered Call",
initialParams: BaseTSA.TSAParams({
depositCap: 10000000e18,
minDepositValue: 0.01e18,
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0,
feeRecipient: address(0),
performanceFeeWindow: 1 weeks,
performanceFee: 0
})
}),
CoveredCallTSA.CCTSAInitParams({
baseFeed: ISpotFeed(_getMarketAddress("ETH", "spotFeed")),
Expand All @@ -121,16 +131,6 @@ contract DeployTSA is Utils {
)
);

CoveredCallTSA(address(proxy)).setTSAParams(
BaseTSA.TSAParams({
depositCap: 10000000e18,
minDepositValue: 0.01e18,
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0,
feeRecipient: address(0)
})
);
CoveredCallTSA cctsa = CoveredCallTSA(address(proxy));
cctsa.setCCTSAParams(defaultLrtccTSAParams);
cctsa.setCollateralManagementParams(defaultCollateralManagementParams);
Expand Down Expand Up @@ -192,7 +192,17 @@ contract DeployTSA is Utils {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingModule("matching")),
symbol: "sUSDe",
name: "sUSDe Principal Protected Bull Call Spread"
name: "sUSDe Principal Protected Bull Call Spread",
initialParams: BaseTSA.TSAParams({
depositCap: 10000000e18,
minDepositValue: 0.01e18,
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0,
feeRecipient: address(0),
performanceFeeWindow: 1 weeks,
performanceFee: 0
})
}),
PrincipalProtectedTSA.PPTSAInitParams({
baseFeed: ISpotFeed(_getMarketAddress("sUSDe", "spotFeed")),
Expand All @@ -207,16 +217,6 @@ contract DeployTSA is Utils {
)
);

PrincipalProtectedTSA(address(proxy)).setTSAParams(
BaseTSA.TSAParams({
depositCap: 10000000e18,
minDepositValue: 0.01e18,
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0,
feeRecipient: address(0)
})
);
PrincipalProtectedTSA pptsa = PrincipalProtectedTSA(address(proxy));
pptsa.setPPTSAParams(defaultLrtppTSAParams);
pptsa.setCollateralManagementParams(defaultCollateralManagementParams);
Expand Down
12 changes: 7 additions & 5 deletions scripts/upgrade-lbtsa.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;
import "forge-std/console.sol";
import {Utils} from "./utils.sol";
import "../src/periphery/LyraSettlementUtils.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/BaseTSA.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/shared/BaseTSA.sol";
import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol";
import {CashAsset} from "v2-core/src/assets/CashAsset.sol";
import {DutchAuction} from "v2-core/src/liquidation/DutchAuction.sol";
Expand Down Expand Up @@ -97,7 +97,8 @@ contract UpgradeLBTSA is UtilBase {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingContract("matching", "matching")),
symbol: string.concat("b", marketName),
name: string.concat("Basis traded ", marketName)
name: string.concat("Basis traded ", marketName),
initialParams: defaultLbtsaTSAParams
}),
LeveragedBasisTSA.LBTSAInitParams({
baseFeed: ISpotFeed(_getV2CoreContract(marketName, "spotFeed")),
Expand All @@ -110,7 +111,7 @@ contract UpgradeLBTSA is UtilBase {

LeveragedBasisTSA(address(proxy)).setSubmitter(0x47E946f9027B0e7E0117afa482AF4C4053C53b40, true);
//
// LeveragedBasisTSA(address(proxy)).setLBTSAParams(defaultLbtsaTSAParams);
// LeveragedBasisTSA(address(proxy)).setLBTSAParams();
// LeveragedBasisTSA(address(proxy)).setCollateralManagementParams(defaultCollateralManagementParams);
//// proxyAdmin.transferOwnership(0xB176A44D819372A38cee878fB0603AEd4d26C5a5);

Expand All @@ -137,7 +138,8 @@ contract UpgradeLBTSA is UtilBase {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingContract("matching", "matching")),
symbol: string.concat("b", marketName),
name: string.concat("Basis traded ", marketName)
name: string.concat("Basis traded ", marketName),
initialParams: defaultLbtsaTSAParams
}),
LeveragedBasisTSA.LBTSAInitParams({
baseFeed: ISpotFeed(_getV2CoreContract(marketName, "spotFeed")),
Expand All @@ -152,7 +154,7 @@ contract UpgradeLBTSA is UtilBase {

// console.log("implementation: ", address(implementation));

// LeveragedBasisTSA(address(proxy)).setLBTSAParams(defaultLbtsaTSAParams);
// LeveragedBasisTSA(address(proxy)).setLBTSAParams();
// LeveragedBasisTSA(address(proxy)).setCollateralManagementParams(defaultCollateralManagementParams);
// proxyAdmin.transferOwnership(0xB176A44D819372A38cee878fB0603AEd4d26C5a5);

Expand Down
48 changes: 24 additions & 24 deletions scripts/upgrade-tsa.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.20;
import "forge-std/console2.sol";
import {Utils} from "./utils.sol";
import "../src/periphery/LyraSettlementUtils.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/BaseTSA.sol";
import {BaseTSA} from "../src/tokenizedSubaccounts/shared/BaseTSA.sol";
import {ISubAccounts} from "v2-core/src/interfaces/ISubAccounts.sol";
import {CashAsset} from "v2-core/src/assets/CashAsset.sol";
import {DutchAuction} from "v2-core/src/liquidation/DutchAuction.sol";
Expand Down Expand Up @@ -114,7 +114,18 @@ contract DeployTSA is Utils {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingModule("matching")),
symbol: tsaName,
name: string.concat(marketName, " Covered Call")
name: string.concat(marketName, " Covered Call"),
initialParams: BaseTSA.TSAParams({
depositCap: 10000000e18,
minDepositValue: 0.01e18,
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0.015e18,
// TODO: Mainnet fee recipient should be different
feeRecipient: address(deployer),
performanceFeeWindow: 1 weeks,
performanceFee: 0
})
}),
CoveredCallTSA.CCTSAInitParams({
baseFeed: ISpotFeed(
Expand All @@ -134,17 +145,6 @@ contract DeployTSA is Utils {
)
);

CoveredCallTSA(address(proxy)).setTSAParams(
BaseTSA.TSAParams({
depositCap: 10000000e18,
minDepositValue: 0.01e18,
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0.015e18,
// TODO: Mainnet fee recipient should be different
feeRecipient: address(deployer)
})
);
CoveredCallTSA cctsa = CoveredCallTSA(address(proxy));
cctsa.setCCTSAParams(defaultLrtccTSAParams);
cctsa.setCollateralManagementParams(defaultCollateralManagementParams);
Expand Down Expand Up @@ -185,7 +185,17 @@ contract DeployTSA is Utils {
manager: ILiquidatableManager(_getCoreContract("srm")),
matching: IMatching(_getMatchingModule("matching")),
symbol: tsaName,
name: string.concat(marketName, "Covered Put Spread")
name: string.concat(marketName, "Covered Put Spread"),
initialParams: BaseTSA.TSAParams({
depositCap: 100000000e18,
minDepositValue: 0,
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0,
feeRecipient: address(0),
performanceFeeWindow: 1 weeks,
performanceFee: 0
})
}),
PrincipalProtectedTSA.PPTSAInitParams({
baseFeed: ISpotFeed(
Expand All @@ -208,16 +218,6 @@ contract DeployTSA is Utils {
)
);

PrincipalProtectedTSA(address(proxy)).setTSAParams(
BaseTSA.TSAParams({
depositCap: 100000000e18,
minDepositValue: 0,
depositScale: 1e18,
withdrawScale: 1e18,
managementFee: 0,
feeRecipient: address(0)
})
);
PrincipalProtectedTSA pptsa = PrincipalProtectedTSA(address(proxy));
pptsa.setPPTSAParams(defaultLrtppTSAParams);
pptsa.setCollateralManagementParams(defaultCollateralManagementParams);
Expand Down
10 changes: 10 additions & 0 deletions src/AtomicSigningExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ contract AtomicSigningExecutor {
}
}
matching.verifyAndMatch(actions, signatures, actionData);

// Post-trade hook. Allows signer to update state internally and revert if they don't like the trade
for (uint i = 0; i < actions.length; i++) {
AtomicAction memory atomicAction = atomicActionData[i];
if (atomicAction.isAtomic) {
// Call the signer of the action
IAtomicSigner signer = IAtomicSigner(actions[i].signer);
signer.postTradeHook(actions[i], atomicAction.extraData);
}
}
}

modifier onlyTradeExecutor() {
Expand Down
Loading