Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: curve incentives script #1540

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

sajanrajdev
Copy link
Collaborator

Tackles #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
Copy link
Collaborator Author

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

Copy link
Collaborator

@petrovska-petro petrovska-petro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed the addys in the book ✅

experiencing the same re invalid opcode locally and probably it is related to funny synergy between brownie<>ganache version

since the operation is relatively straightforward if this becomes a blocker will be supportive of leveraging the json file as it is easy to audit only 2 actions imo + easy to DD with the tenderly sim ✅

@petrovska-petro
Copy link
Collaborator

dripping rate will be 4.22/2419200 ~= 0.000001744 matching with your #1540 (comment)

Copy link
Collaborator

@gosuto-inzasheru gosuto-inzasheru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im als getting invalid opcode. it is probably due to brownie/ganache still being on the istanbul evm version, and missing some since then newly introduced opcodes

in these cases where we rely on the tx json instead, i think it would be good to include it in the pr as well

scripts/curve/lido_gauge_incentives.py Outdated Show resolved Hide resolved
@sajanrajdev
Copy link
Collaborator Author

@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.

@@ -22,7 +28,7 @@ def main(amount=0, epoch=MONTH, use_wsteth=True):
"""
safe = GreatApeSafe(TROPS)
gauge = safe.contract(GAUGE, Interface=interface.ILiquidityGaugeV6)
amount = int(float(amount) * 1e18)
amount = int(Decimal(amount) * 1e18)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you test this? i dont think you can multiply a Decimal with a non Decimal type:

>>> int(Decimal(4.22)*1e18)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'decimal.Decimal' and 'float'

@gosuto-inzasheru
Copy link
Collaborator

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

"contractInputsValues": {
"_reward_token": "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
"_amount": "4220000000000000000",
"_epoch": "2419200"
Copy link
Collaborator

@petrovska-petro petrovska-petro May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice adding the json file ✅

before posting it w/ either method json or working env worth having clarity of the final arguments for deposit_reward_token based on latest convos and then post in the pr the official json filed which will get posted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants