Skip to content

Commit

Permalink
Balancer Gnosis Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
nledo committed Apr 12, 2024
1 parent c4474e3 commit 2bee0e0
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"apply:balancer:eth:harvest": "hardhat encodeApplyPresetHarvestBalancer --network mainnet --safe BALANCER_ETH",
"apply:balancer:eth:swap": "hardhat encodeApplyPresetSwapBalancer --network mainnet --safe BALANCER_ETH",
"apply:balancerAlternative:eth:manage": "hardhat encodeApplyPresetManageBalancerAlternative --network mainnet --safe BALANCER_ALTERNATIVE_ETH",
"apply:balancer:gno:manage": "hardhat encodeApplyPresetManageBalancergnosis --network xdai --safe BALANCER_GNO",
"apply:ens:eth:manage": "hardhat encodeApplyPresetManageENS --network mainnet --safe ENS_ETH",
"apply:ens:eth:harvest": "hardhat encodeApplyPresetHarvestENS --network mainnet --safe ENS_ETH",
"apply:ens:eth:swap": "hardhat encodeApplyPresetSwapENS --network mainnet --safe ENS_ETH",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { AVATAR } from "../../placeholders"
import { RolePreset } from "../../types"
import { allow } from "../../allow"
import { allowErc20Approve } from "../../helpers/erc20"
import {
GNO,
rGNO,
sGNO,
curve,
} from "../addresses"


const preset = {
network: 100,
allow: [
//---------------------------------------------------------------------------------------------------------------------------------
// StakeWise v2 / Curve
//---------------------------------------------------------------------------------------------------------------------------------

// Swap GNO <> sGNO
...allowErc20Approve([GNO, sGNO], [curve.sgnoCRV_LP_POOL]),
allow.gnosis.curve.sgnoCRV_lp_pool["exchange(int128,int128,uint256,uint256)"](),
allow.gnosis.curve.sgnoCRV_lp_pool["exchange(int128,int128,uint256,uint256,address)"](
undefined,
undefined,
undefined,
undefined,
AVATAR
),

// Swap rGNO <> sGNO
...allowErc20Approve([rGNO, sGNO], [curve.rgnoCRV_LP_POOL]),
allow.gnosis.curve.rgnoCRV_lp_pool["exchange(int128,int128,uint256,uint256)"](),
allow.gnosis.curve.rgnoCRV_lp_pool["exchange(int128,int128,uint256,uint256,address)"](
undefined,
undefined,
undefined,
undefined,
AVATAR
),

],
placeholders: { AVATAR },
} satisfies RolePreset

export default preset
58 changes: 58 additions & 0 deletions packages/sdk/tasks/manageBalancerRoles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"
import { Roles } from "../../evm/typechain-types"
import addMembers from "../src/addMembers"
import { encodeApplyPresetTxBuilder } from "../src/applyPreset"

// Balancer in Mainnet
import mainnetDeFiHarvestBalancerPreset from "../src/presets/mainnet/Balancer/deFiHarvestBalancer"
import mainnetDeFiManageBalancerPreset from "../src/presets/mainnet/Balancer/deFiManageBalancer"
import mainnetDeFiManageBalancerAlternativePreset from "../src/presets/mainnet/Balancer/deFiManageBalancerAlternative"
import mainnetDeFiSwapBalancerPreset from "../src/presets/mainnet/Balancer/deFiSwapBalancer"

// Balancer in Gnosis Chain
import gnosisDeFiManagerBalancerPreset from "../src/presets/gnosisChain/Balancer/deFiManagerBalancer"

import { NetworkId } from "../src/types"

interface Config {
Expand Down Expand Up @@ -71,6 +77,25 @@ export const BALANCER_ADDRESSES = {
SWAPPER: 5,
},
},

BALANCER_GNO: {
AVATAR: "0x3dA6e9ABB753d16F0263C448D1DEBaEF9fad087f",
MODULE: "0xB39374e9441d345EB4CDC51A8b19c4d6B74039BE",
MANAGER: "0xE7D2AfC3e486BDaA2476d665A6A19C4B75791e7A",
REVOKER: "",
HARVESTER: "",
DISASSEMBLER: "",
SWAPPER: "",
NETWORK: 100,
BRIDGED_SAFE: "0x0000000000000000000000000000000000000000",
ROLE_IDS: {
MANAGER: 1,
REVOKER: 2,
HARVESTER: 3,
DISASSEMBLER: 4,
SWAPPER: 5,
},
},
} satisfies { [key: string]: Config }

const task = (name: string) =>
Expand Down Expand Up @@ -354,3 +379,36 @@ task("encodeApplyPresetManageBalancerAlternative").setAction(
)
}
)

//-----------------------------------------------------------------------------------------------------------------------------
// Balancer - Gnosis Chain
//-----------------------------------------------------------------------------------------------------------------------------

task("encodeApplyPresetManageBalancergnosis").setAction(
async (taskArgs, hre) => {
const { config } = await processArgs(taskArgs, hre)
const txBatches = await encodeApplyPresetTxBuilder(
config.MODULE,
1,
gnosisDeFiManagerBalancerPreset,
{ AVATAR: config.AVATAR },
{
network: config.NETWORK as NetworkId,
}
)

const filePath = path.join(
__dirname,
"..",
"/presets-output/gnosis/Balancer/txDataManageBalancergnosis.json"
)
// Check if the file exists
if (!existsSync(filePath)) {
// Create the directory structure if it doesn't exist
mkdirSync(path.dirname(filePath), { recursive: true })
}
// Write the JSON data to the file
writeFileSync(filePath, JSON.stringify(txBatches, undefined, 2))
console.log(`Transaction builder JSON written to ${filePath}`)
}
)

0 comments on commit 2bee0e0

Please sign in to comment.