Badger-Finance / badger-multisig

Badger DAO's EVM multisig operations.
GNU Affero General Public License v3.0
47 stars 32 forks source link

feat: curve incentives script #1540

Open sajanrajdev opened 2 months ago

sajanrajdev commented 2 months ago

Tackles https://github.com/Badger-Finance/badger-multisig/issues/1539

Run with:

brownie run scripts/curve/lido_gauge_incentives.py main 4.22

Can optionally take a different epoch, defaults to 1 month.

NOTE: @petrovska-petro @gosuto-inzasheru, I keep getting the following error:

Transaction sent: 0x6da33715a9e064376bc49bb0ddf63d174abb1e18970ecbd49ea62aa40a4ed103
  Gas price: 0.0 gwei   Gas limit: 12000000   Nonce: 16
  ILiquidityGaugeV6.deposit_reward_token confirmed (invalid opcode)   Block: 19962371   Gas used: 12000000 (100.00%)

Tested the same transaction via Tenderly, and it worked. I confirmed that the call_data is correct by encoding it through the script and comparing it to Tenderly's (0x33b50aed0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca00000000000000000000000000000000000000000000000003a9073a438260000000000000000000000000000000000000000000000000000000000000024ea00). Attempting to call it normally or by passing the calldata directly returns the same error. I am inclined to believe that this is one of those obscure Brownie issues.

Please let me know if it works from your side.

Alternative

The following JSON represents a batch of the approval and deposit and can be imported to the Gnosis Safe UI. It could be re-used on a monthly basis and the amount to approve and deposit can be adjusted through the UI. At least while we figure out how to fix the script.

Lido incentives.json

sajanrajdev commented 2 months ago

Reading reward_data(wsteth) after the Tenderly simulation executes, returns:

iquidityGaugeV6)
.
reward_data
(arg0 = 0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0)
=>
({"token":"0x0000000000000000000000000000000000000000","distributor":"0x042b32ac6b453485e357938bdc38e0340d4b9276","period_finish":"1719247097","rate":"1744378306878","last_update":"1716827897","integral":"0"})

Data LGTM

petrovska-petro commented 2 months ago

dripping rate will be 4.22/2419200 ~= 0.000001744 matching with your https://github.com/Badger-Finance/badger-multisig/pull/1540#issuecomment-2133912843

sajanrajdev commented 2 months ago

@petrovska-petro @gosuto-inzasheru, the JSON file for the operation, along with some instructions was pushed as per your suggestion. Also added Decimal instead of float, just in case.

gosuto-inzasheru commented 2 months ago

ok i was able to run this successfully in an updated env that uses brownie v1.20.5, a custom version of brownie-safe and ganache v7 running the shanghai fork:

Brownie v1.20.5 - Python development framework for Ethereum

Generating interface ABIs...
BadgerMultisigProject is the active project.

Launching 'ganache-cli --chain.vmErrorsOnRPCResponse true --wallet.totalAccounts 10 --hardfork shanghai --fork.url *** --miner.blockGasLimit 12000000 --wallet.mnemonic brownie --server.port 8545 --chain.chainId 1'...

Running 'scripts/curve/lido_gauge_incentives.py::main'...
Transaction sent: 0xac42515983315dfbcd8157637a878deabe98d7ff41b4feffeb66dac844c2189d
  Max fee: 42.937602704 gwei   Priority fee: 1.0 gwei   Gas limit: 12000000   Nonce: 1
  Token.approve confirmed   Block: 19976106   Gas used: 46216 (0.39%)   Gas price: 19.347701183 gwei

Transaction sent: 0xc947cf935ad63685b6a2039dc0b9a42f670263b433568cc1f27177a0e3337fdb
  Max fee: 37.695402366 gwei   Priority fee: 1.0 gwei   Gas limit: 12000000   Nonce: 2
  LiquidityGaugeV6.deposit_reward_token confirmed   Block: 19976107   Gas used: 168424 (1.40%)   Gas price: 17.071904314 gwei

('0x0000000000000000000000000000000000000000', '0x042B32Ac6b453485e357938bdC38e0340d4b9276', 1719412067, 1744378306878, 1716992867, 0)
Transaction sent: 0x3d19d881dfe6996083fd225254cd5b31742b00459a17e9e48c0f41f76e1b315b
  Max fee: 29.094917438 gwei   Priority fee: 1.0 gwei   Gas limit: 12000000   Nonce: 21
  Transaction confirmed   Block: 19976109   Gas used: 21000 (0.18%)   Gas price: 13.29152638 gwei

Transaction sent: 0x57112139f5f4a2008023dd6252ef6a17f0936986d769c6aeb33f2eaeeff6c0ef
  Max fee: 25.58305276 gwei   Priority fee: 1.0 gwei   Gas limit: 248770   Nonce: 86
  Gnosis Safe.execTransaction confirmed   Block: 19976110   Gas used: 217767 (87.54%)   Gas price: 11.760463126 gwei

Transaction was Mined 
---------------------
Tx Hash: 0x57112139f5f4a2008023dd6252ef6a17f0936986d769c6aeb33f2eaeeff6c0ef
From: 0x0a9af7FAba0d5DF7A8C881e1B9cd679ee07Af8A2
To: 0x042B32Ac6b453485e357938bdC38e0340d4b9276
Value: 0
Function: Gnosis Safe.execTransaction
Block: 19976110
Gas Used: 217767 / 248770 (87.5%)

Events In This Transaction
--------------------------
├── Wrapped liquid staked Ether 2.0 (0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0)
│   ├── Approval
│   │   ├── owner: 0x042B32Ac6b453485e357938bdC38e0340d4b9276
│   │   ├── spender: 0xBEb468BEb5C72d8b4d4f076F473Db398562769ed
│   │   └── value: 4220000000000000000
│   ├── Transfer
│   │   ├── from: 0x042B32Ac6b453485e357938bdC38e0340d4b9276
│   │   ├── to: 0xBEb468BEb5C72d8b4d4f076F473Db398562769ed
│   │   └── value: 4220000000000000000
│   └── Approval
│       ├── owner: 0x042B32Ac6b453485e357938bdC38e0340d4b9276
│       ├── spender: 0xBEb468BEb5C72d8b4d4f076F473Db398562769ed
│       └── value: 0
│   
└── Gnosis Safe (0x042B32Ac6b453485e357938bdC38e0340d4b9276)
    └── ExecutionSuccess
        ├── txHash: 0x3f4be8f7233c128790d8aa6f6e2f072ffb3c7f2a299745f996a1335c0d6775df
        └── payment: 0

as a test i posted it through my delegate which looks to be successful too: https://app.safe.global/transactions/tx?safe=eth:0x042B32Ac6b453485e357938bdC38e0340d4b9276&id=multisig_0x042B32Ac6b453485e357938bdC38e0340d4b9276_0x3f4be8f7233c128790d8aa6f6e2f072ffb3c7f2a299745f996a1335c0d6775df