FeedProjects
Developers
Settings
🎉 A new chapter begins: Boardroom has joined Agora
Learn more
protocol logo
Explore / Projects
dYdX

Proposals

Discussions

Members

Information

Create Proposal

dYdX

ProposalsDiscussionsMembersInformation
Proposal
Back to Proposals
executedEnded 4 years ago ·  Onchain

Upgrade the StarkProxy smart contract

By 0xB111...0051A2

Simple Summary

Upgrade StarkProxy smart contracts to support deposit cancellation and recovery.

Abstract

When depositing USDC to the dYdX Layer 2 exchange, the funds are held in a bridge contract while waiting for the deposit to be processed by the L2 sequencer and prover. While funds are on the bridge awaiting confirmation, the depositor can initiate a time-locked recovery process to cancel the deposit. This functionality is not currently supported by the Stark Proxy smart contracts which manage the funds borrowed by market makers from the Liquidity Module staking pool. These Stark Proxy smart contracts should be upgraded to support deposit cancelation and recovery.

Motivation

On October 27, 2021 09:37:37 AM +UTC, we (Wintermute) borrowed 50 million USDC (transaction here) from the Liquidity Staking Pool and attempted to deposit the funds to our trading account on the dYdX exchange. We had to send deposit programmatically because the client provided by the dYdX Foundation team does not support wallet-connect yet. Unfortunately, the wrong “vaultId” parameter was passed in the call to “depositToExchange” (transaction here). Because this “vaultId” did not correspond to our STARK key, the deposit was invalid and could not be confirmed on L2. The 50M USDC are safely held by the dYdX L2 exchange smart contract and can be reclaimed by the StarkProxy contract. However, to reclaim the funds, the StarkProxy contract must call “depositCancel” and “depositReclaim” on the L2 exchange smart contract. Upgrading these smart contracts would allow us to recover the 50M USDC and ensure that other market makers can safely make use of the Liquidity Staking Pool.

Following a forum DRC thread, Wintermute launched a 5-day poll on Snapshot regarding the question of Stark Proxy upgrade. The results of the poll are available here. The Snapshot vote has concluded with 5.3M DYDX (99.92%) from 474 voters indicating consensus in favor of the DRC.

Specification

When market makers borrow funds from the Liquidity Module staking pool they must do so via a StarkProxy smart contract which manages the funds and limits how they may be used. The StarkProxy borrows funds from the pool using a “borrow” call and then deposits those to the exchange using “depositToExchange” providing multiple parameters in transaction data describing which account should be credited. This deposit transaction transfers funds to the dYdX L2 exchange smart contract (here) and, if a deposit is valid, it is submitted and confirmed on L2. If the deposit parameters are misspecified by the caller, it may not be possible to credit the deposit. In such a case, as long as the “starkKey” was correctly specified in the deposit, the depositor can reclaim their funds using the “depositCancel” and “depositReclaim” functions. This process is described here. Since “depositCancel” and “depositReclaim” are not currently implemented on the StarkProxy contract, it is not possible for those contracts to reclaim funds in the case where a deposit transaction is malformed and unable to be processed. Currently there is one such invalid deposit of 50M USDC which must be canceled in order for the funds to be recovered and put to use. The deposit is invalid because the wrong vault number was used, and the vault number and stark key specified in the deposit transaction do not match.

Implementation

Upgraded Stark Proxy implementation Stark Proxy V2 is open-sourced in the dYdX Foundation governance contracts repository.

Test Cases

Test cases for Stark Proxy have been extended to cover new V2 functions. It is open-sourced in the dYdX Foundation Stark Proxy tests folder. The deposit and cancelation process was thoroughly tested in both test and mainnet fork environments.

Detailed instructions are provided on GitHub to allow anybody to run the same tests.

Copyright

Copyright and related rights waived via CC0.

Continue Reading
Connect Wallet to Add Note
0
Votes 182
VoterCast PowerVote & Rationale
0x06d8...d630f5
39.011M

YAE

0x5Aa6...10ac67
20M

YAE

0xB111...0051A2
5.003M

YAE

0xA817...DBBDeD
1.987M

YAE

0xafa6...226e90
1.766M

YAE

SHOW MORE
VOTE POWER
0
Connect Wallet
Proposal Status
  • Published Onchain 0xB111...0051A2
  • Wed November 17 2021, 07:36 pmVoting Period Starts
  • Sun November 21 2021, 11:51 pmEnd Voting Period
  • Mon November 22 2021, 03:48 pmQueue Proposal
  • Wed November 24 2021, 05:49 pmExecute Proposal
Current Results

1-YAE

69.607M

2-NAY

N/A Tokens

0%
DocumentationBrandingContact Us
Home
This Project is Currently Disabled

If you would like to enable it, please checkout below.

Boardroom Subscription

Sign up for an individual subscription (access all projects on the platform)

Subscribe
Enable Project

Enable the entire project for every user

Enable Project
Contact Us