Skip to content

Commit

Permalink
Sonic deploy 013 script to change Vault config (#2426)
Browse files Browse the repository at this point in the history
* Gov actions to change OS Vault config

* Changed the Sonic Vault buffer to 0.5%

* Fix Sonic unit tests

* Prettier

* Ran Sonic 013 deployment

* Prettier

* Fixed schedule Timelock
  • Loading branch information
naddison36 authored Mar 4, 2025
1 parent 745c3c6 commit f15ea33
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 27 deletions.
2 changes: 1 addition & 1 deletion contracts/deploy/sonic/012_tb_yf_batch_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = deployOnSonic(
addresses.sonic.OSonicProxy,
addresses.sonic.timelock,
cPoolBoostCentralRegistryProxy.address,
],
]
);
const cPoolBoosterFactorySwapxSingle = await ethers.getContract(
"PoolBoosterFactorySwapxSingle"
Expand Down
35 changes: 35 additions & 0 deletions contracts/deploy/sonic/013_vault_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { deployOnSonic } = require("../../utils/deploy-l2");
const { oethUnits } = require("../../test/helpers");
const { resolveContract } = require("../../utils/resolvers");

module.exports = deployOnSonic(
{
deployName: "013_vault_config",
},
async () => {
const cOSonicVault = await resolveContract("OSonicVaultProxy", "IVault");

return {
actions: [
{
// Increase the rebase threshold to 50k wS
contract: cOSonicVault,
signature: "setRebaseThreshold(uint256)",
args: [oethUnits("20000", 18)],
},
{
// Increase the auto-allocation threshold to 20k wS
contract: cOSonicVault,
signature: "setAutoAllocateThreshold(uint256)",
args: [oethUnits("20000", 18)],
},
{
// Reduce the vault buffer to 0.5%
contract: cOSonicVault,
signature: "setVaultBuffer(uint256)",
args: [oethUnits("0.005", 18)],
},
],
};
}
);
3 changes: 2 additions & 1 deletion contracts/deployments/sonic/.migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"008_swapx_yield_forward": 1738873151,
"010_swapx_yield_forward": 1740000624,
"011_pool_booster_factory": 1740172411,
"012_tb_yf_batch_1": 1741011742
"012_tb_yf_batch_1": 1741011742,
"013_vault_config": 1741065376
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"version": "1.0",
"chainId": "146",
"createdAt": 1741065376,
"meta": {
"name": "Transaction Batch",
"description": "",
"txBuilderVersion": "1.16.1",
"createdFromSafeAddress": "0xAdDEA7933Db7d83855786EB43a238111C69B00b6",
"createdFromOwnerAddress": ""
},
"transactions": [
{
"to": "0x31a91336414d3B955E494E7d485a6B06b55FC8fB",
"value": "0",
"data": null,
"contractMethod": {
"inputs": [
{
"type": "address[]",
"name": "targets"
},
{
"type": "uint256[]",
"name": "values"
},
{
"type": "bytes[]",
"name": "payloads"
},
{
"type": "bytes32",
"name": "predecessor"
},
{
"type": "bytes32",
"name": "salt"
}
],
"name": "executeBatch",
"payable": true
},
"contractInputsValues": {
"targets": "[\"0xa3c0eCA00D2B76b4d1F170b0AB3FdeA16C180186\",\"0xa3c0eCA00D2B76b4d1F170b0AB3FdeA16C180186\",\"0xa3c0eCA00D2B76b4d1F170b0AB3FdeA16C180186\"]",
"values": "[\"0\",\"0\",\"0\"]",
"payloads": "[\"0xb890ebf600000000000000000000000000000000000000000000043c33c1937564800000\",\"0xb2c9336d00000000000000000000000000000000000000000000043c33c1937564800000\",\"0x8ec489a20000000000000000000000000000000000000000000000000011c37937e08000\"]",
"predecessor": "0x0000000000000000000000000000000000000000000000000000000000000000",
"salt": "0x32e382b0c71d7b38e8aede64b9736790610f979a1cc21436a82d3477a393ef2c"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"version": "1.0",
"chainId": "146",
"createdAt": 1741065375,
"meta": {
"name": "Transaction Batch",
"description": "",
"txBuilderVersion": "1.16.1",
"createdFromSafeAddress": "0xAdDEA7933Db7d83855786EB43a238111C69B00b6",
"createdFromOwnerAddress": ""
},
"transactions": [
{
"to": "0x31a91336414d3B955E494E7d485a6B06b55FC8fB",
"value": "0",
"data": null,
"contractMethod": {
"inputs": [
{
"type": "address[]",
"name": "targets"
},
{
"type": "uint256[]",
"name": "values"
},
{
"type": "bytes[]",
"name": "payloads"
},
{
"type": "bytes32",
"name": "predecessor"
},
{
"type": "bytes32",
"name": "salt"
},
{
"type": "uint256",
"name": "delay"
}
],
"name": "scheduleBatch",
"payable": false
},
"contractInputsValues": {
"targets": "[\"0xa3c0eCA00D2B76b4d1F170b0AB3FdeA16C180186\",\"0xa3c0eCA00D2B76b4d1F170b0AB3FdeA16C180186\",\"0xa3c0eCA00D2B76b4d1F170b0AB3FdeA16C180186\"]",
"values": "[\"0\",\"0\",\"0\"]",
"payloads": "[\"0xb890ebf600000000000000000000000000000000000000000000043c33c1937564800000\",\"0xb2c9336d00000000000000000000000000000000000000000000043c33c1937564800000\",\"0x8ec489a20000000000000000000000000000000000000000000000000011c37937e08000\"]",
"predecessor": "0x0000000000000000000000000000000000000000000000000000000000000000",
"salt": "0x32e382b0c71d7b38e8aede64b9736790610f979a1cc21436a82d3477a393ef2c",
"delay": "86400"
}
}
]
}
4 changes: 2 additions & 2 deletions contracts/tasks/storageSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ const loadPreviousStorageLayoutForContract = async (hre, contractName) => {
return JSON.parse(await promises.readFile(location, "utf8"));
};

// @dev contractName and contract can be different when the deploy procedure wants to
// @dev contractName and contract can be different when the deploy procedure wants to
// store a certain contract deployment under a different name as is the name of
// the contract in the source code.
// @param contract the name of the contract as is in the source code of the contract
// @param contractName a potential override of the contract as is to be stored in the
// @param contractName a potential override of the contract as is to be stored in the
// deployment descriptors
const storeStorageLayoutForContract = async (hre, contractName, contract) => {
const layout = await getStorageLayoutForContract(hre, contractName, contract);
Expand Down
38 changes: 19 additions & 19 deletions contracts/test/_fixture-sonic.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ const BURNER_ROLE =

let snapshotId;
const defaultSonicFixture = deployments.createFixture(async () => {
// Impersonate governor
const governor = await impersonateAndFund(addresses.sonic.timelock);
governor.address = addresses.sonic.timelock;

if (!snapshotId && !isFork) {
snapshotId = await nodeSnapshot();
}
Expand All @@ -30,14 +26,27 @@ const defaultSonicFixture = deployments.createFixture(async () => {
return;
}

let deployerAddr;
const { deployerAddr, strategistAddr, timelockAddr, governorAddr } =
await getNamedAccounts();

if (isFork) {
// Fund deployer account
const namedAccounts = await getNamedAccounts();
deployerAddr = namedAccounts.deployerAddr;
await impersonateAndFund(deployerAddr);
}

// Impersonate governor
const governorAddress = isFork ? addresses.sonic.timelock : governorAddr;
const governor = await impersonateAndFund(governorAddress);
governor.address = governorAddress;

// Impersonate strategist
const strategist = await impersonateAndFund(strategistAddr);
strategist.address = strategistAddr;

// Impersonate strategist
const timelock = await impersonateAndFund(timelockAddr);
timelock.address = timelockAddr;

log(
`Before deployments with param "${
isFork ? ["sonic"] : ["sonic_unit_tests"]
Expand Down Expand Up @@ -65,6 +74,8 @@ const defaultSonicFixture = deployments.createFixture(async () => {
oSonicVaultProxy.address
);

const oSonicVaultSigner = await impersonateAndFund(oSonicVault.address);

// Sonic staking strategy
const sonicStakingStrategyProxy = await ethers.getContract(
"SonicStakingStrategyProxy"
Expand Down Expand Up @@ -125,17 +136,6 @@ const defaultSonicFixture = deployments.createFixture(async () => {
const signers = await hre.ethers.getSigners();

const [minter, burner, rafael, nick, clement] = signers.slice(4); // Skip first 4 addresses to avoid conflict
const { strategistAddr, timelockAddr } = await getNamedAccounts();

// Impersonate strategist
const strategist = await impersonateAndFund(strategistAddr);
strategist.address = strategistAddr;

// Impersonate strategist
const timelock = await impersonateAndFund(timelockAddr);
timelock.address = timelockAddr;

const oSonicVaultSigner = await impersonateAndFund(oSonicVault.address);

let validatorRegistrator;
if (isFork) {
Expand All @@ -153,7 +153,7 @@ const defaultSonicFixture = deployments.createFixture(async () => {
await wS.connect(user).deposit({ value: oethUnits("10000000") });

// Set allowance on the vault
await wS.connect(user).approve(oSonicVault.address, oethUnits("5000"));
await wS.connect(user).approve(oSonicVault.address, oethUnits("50000"));
}

return {
Expand Down
10 changes: 6 additions & 4 deletions contracts/test/vault/vault.sonic.fork-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe("ForkTest: Sonic Vault", function () {
// Clear any wS out of the Vault first
await oSonicVault.allocate();

const mintAmount = parseUnits("1000");
const mintAmount = parseUnits("20000");
const tx = await oSonicVault
.connect(nick)
.mint(wS.address, mintAmount, 0);
Expand All @@ -130,7 +130,7 @@ describe("ForkTest: Sonic Vault", function () {
.to.emit(oSonicVault, "Mint")
.withArgs(nick.address, mintAmount);

// check 99% is deposited to staking strategy
// check 99.5% is deposited to staking strategy
await expect(tx).to.emit(sonicStakingStrategy, "Deposit");
});

Expand Down Expand Up @@ -222,9 +222,11 @@ describe("ForkTest: Sonic Vault", function () {
.withArgs(wS.address, addresses.zero, withdrawAmount);
});

it("Should have vault buffer set to 1%", async () => {
it("Should have vault buffer set", async () => {
const { oSonicVault } = fixture;
expect(await oSonicVault.vaultBuffer()).to.equal(parseUnits("1", 16));
expect(await oSonicVault.vaultBuffer()).to.equal(
parseUnits("0.005", 18) // 0.5%
);
});
});
});

0 comments on commit f15ea33

Please sign in to comment.