Skip to content

Commit 02b8b06

Browse files
committed
add queueWait time using extra bytes from
1 parent dfa32ab commit 02b8b06

File tree

7 files changed

+111
-7
lines changed

7 files changed

+111
-7
lines changed

abi/otoken-vault.json

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
[
2+
{
3+
"inputs": [{ "internalType": "address", "name": "_weth", "type": "address" }],
4+
"stateMutability": "nonpayable",
5+
"type": "constructor"
6+
},
27
{
38
"anonymous": false,
49
"inputs": [{ "indexed": false, "internalType": "uint256", "name": "_threshold", "type": "uint256" }],
@@ -264,6 +269,13 @@
264269
"stateMutability": "view",
265270
"type": "function"
266271
},
272+
{
273+
"inputs": [],
274+
"name": "addWithdrawalQueueLiquidity",
275+
"outputs": [],
276+
"stateMutability": "nonpayable",
277+
"type": "function"
278+
},
267279
{
268280
"inputs": [],
269281
"name": "adminImplPosition",
@@ -287,12 +299,13 @@
287299
"type": "function"
288300
},
289301
{
290-
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }],
302+
"inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
291303
"name": "burnForStrategy",
292304
"outputs": [],
293305
"stateMutability": "nonpayable",
294306
"type": "function"
295307
},
308+
{ "inputs": [], "name": "cacheWETHAssetIndex", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
296309
{
297310
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }],
298311
"name": "calculateRedeemOutputs",
@@ -315,6 +328,23 @@
315328
"type": "function"
316329
},
317330
{ "inputs": [], "name": "claimGovernance", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
331+
{
332+
"inputs": [{ "internalType": "uint256", "name": "_requestId", "type": "uint256" }],
333+
"name": "claimWithdrawal",
334+
"outputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
335+
"stateMutability": "nonpayable",
336+
"type": "function"
337+
},
338+
{
339+
"inputs": [{ "internalType": "uint256[]", "name": "_requestIds", "type": "uint256[]" }],
340+
"name": "claimWithdrawals",
341+
"outputs": [
342+
{ "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" },
343+
{ "internalType": "uint256", "name": "totalAmount", "type": "uint256" }
344+
],
345+
"stateMutability": "nonpayable",
346+
"type": "function"
347+
},
318348
{
319349
"inputs": [],
320350
"name": "dripDuration",
@@ -440,7 +470,7 @@
440470
"type": "function"
441471
},
442472
{
443-
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }],
473+
"inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
444474
"name": "mintForStrategy",
445475
"outputs": [],
446476
"stateMutability": "nonpayable",
@@ -548,6 +578,16 @@
548578
"stateMutability": "view",
549579
"type": "function"
550580
},
581+
{
582+
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }],
583+
"name": "requestWithdrawal",
584+
"outputs": [
585+
{ "internalType": "uint256", "name": "requestId", "type": "uint256" },
586+
{ "internalType": "uint256", "name": "queued", "type": "uint256" }
587+
],
588+
"stateMutability": "nonpayable",
589+
"type": "function"
590+
},
551591
{
552592
"inputs": [{ "internalType": "address", "name": "newImpl", "type": "address" }],
553593
"name": "setAdminImpl",
@@ -607,6 +647,20 @@
607647
"stateMutability": "view",
608648
"type": "function"
609649
},
650+
{
651+
"inputs": [],
652+
"name": "weth",
653+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
654+
"stateMutability": "view",
655+
"type": "function"
656+
},
657+
{
658+
"inputs": [],
659+
"name": "wethAssetIndex",
660+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
661+
"stateMutability": "view",
662+
"type": "function"
663+
},
610664
{
611665
"inputs": [],
612666
"name": "withdrawalClaimDelay",

db/migrations/1755553679357-Data.js renamed to db/migrations/1756242284453-Data.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ type OTokenWithdrawalRequest @entity {
589589
queued: BigInt!
590590
claimed: Boolean!
591591
claimedAt: DateTime
592+
queueWait: BigInt
592593
txHash: String! @index
593594
}
594595

src/abi/otoken-vault.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,19 @@ export const events = {
4646

4747
export const functions = {
4848
ADMIN_IMPLEMENTATION: viewFun("0xcc2fe94b", "ADMIN_IMPLEMENTATION()", {}, p.address),
49+
addWithdrawalQueueLiquidity: fun("0xb9b17f9f", "addWithdrawalQueueLiquidity()", {}, ),
4950
adminImplPosition: viewFun("0xef08edc2", "adminImplPosition()", {}, p.bytes32),
5051
allocate: fun("0xabaa9916", "allocate()", {}, ),
5152
assetDefaultStrategies: viewFun("0xa403e4d5", "assetDefaultStrategies(address)", {"_0": p.address}, p.address),
5253
autoAllocateThreshold: viewFun("0x9fa1826e", "autoAllocateThreshold()", {}, p.uint256),
53-
burnForStrategy: fun("0x6217f3ea", "burnForStrategy(uint256)", {"_amount": p.uint256}, ),
54+
burnForStrategy: fun("0x6217f3ea", "burnForStrategy(uint256)", {"amount": p.uint256}, ),
55+
cacheWETHAssetIndex: fun("0x44c54707", "cacheWETHAssetIndex()", {}, ),
5456
calculateRedeemOutputs: viewFun("0x67bd7ba3", "calculateRedeemOutputs(uint256)", {"_amount": p.uint256}, p.array(p.uint256)),
5557
capitalPaused: viewFun("0xe6cc5432", "capitalPaused()", {}, p.bool),
5658
checkBalance: viewFun("0x5f515226", "checkBalance(address)", {"_asset": p.address}, p.uint256),
5759
claimGovernance: fun("0x5d36b190", "claimGovernance()", {}, ),
60+
claimWithdrawal: fun("0xf8444436", "claimWithdrawal(uint256)", {"_requestId": p.uint256}, p.uint256),
61+
claimWithdrawals: fun("0x48e30f54", "claimWithdrawals(uint256[])", {"_requestIds": p.array(p.uint256)}, {"amounts": p.array(p.uint256), "totalAmount": p.uint256}),
5862
dripDuration: viewFun("0xbb7a632e", "dripDuration()", {}, p.uint64),
5963
dripper: viewFun("0x603ea03b", "dripper()", {}, p.address),
6064
getAllAssets: viewFun("0x2acada4d", "getAllAssets()", {}, p.array(p.address)),
@@ -70,7 +74,7 @@ export const functions = {
7074
lastRebase: viewFun("0x78f353a1", "lastRebase()", {}, p.uint64),
7175
maxSupplyDiff: viewFun("0x8e510b52", "maxSupplyDiff()", {}, p.uint256),
7276
mint: fun("0x156e29f6", "mint(address,uint256,uint256)", {"_asset": p.address, "_amount": p.uint256, "_minimumOusdAmount": p.uint256}, ),
73-
mintForStrategy: fun("0xab80dafb", "mintForStrategy(uint256)", {"_amount": p.uint256}, ),
77+
mintForStrategy: fun("0xab80dafb", "mintForStrategy(uint256)", {"amount": p.uint256}, ),
7478
netOusdMintForStrategyThreshold: viewFun("0x7a2202f3", "netOusdMintForStrategyThreshold()", {}, p.uint256),
7579
netOusdMintedForStrategy: viewFun("0xe45cc9f0", "netOusdMintedForStrategy()", {}, p.int256),
7680
oUSD: viewFun("0x5802a172", "oUSD()", {}, p.address),
@@ -86,6 +90,7 @@ export const functions = {
8690
rebaseThreshold: viewFun("0x52d38e5d", "rebaseThreshold()", {}, p.uint256),
8791
redeem: fun("0x7cbc2373", "redeem(uint256,uint256)", {"_amount": p.uint256, "_minimumUnitAmount": p.uint256}, ),
8892
redeemFeeBps: viewFun("0x09f6442c", "redeemFeeBps()", {}, p.uint256),
93+
requestWithdrawal: fun("0x9ee679e8", "requestWithdrawal(uint256)", {"_amount": p.uint256}, {"requestId": p.uint256, "queued": p.uint256}),
8994
setAdminImpl: fun("0xfc0cfeee", "setAdminImpl(address)", {"newImpl": p.address}, ),
9095
strategies: viewFun("0x39ebf823", "strategies(address)", {"_0": p.address}, {"isSupported": p.bool, "_deprecated": p.uint256}),
9196
strategistAddr: viewFun("0x570d8e1d", "strategistAddr()", {}, p.address),
@@ -94,6 +99,8 @@ export const functions = {
9499
trusteeAddress: viewFun("0x49c1d54d", "trusteeAddress()", {}, p.address),
95100
trusteeFeeBps: viewFun("0x207134b0", "trusteeFeeBps()", {}, p.uint256),
96101
vaultBuffer: viewFun("0x1edfe3da", "vaultBuffer()", {}, p.uint256),
102+
weth: viewFun("0x3fc8cef3", "weth()", {}, p.address),
103+
wethAssetIndex: viewFun("0x54c6d858", "wethAssetIndex()", {}, p.uint256),
97104
withdrawalClaimDelay: viewFun("0x45e4213b", "withdrawalClaimDelay()", {}, p.uint256),
98105
withdrawalQueueMetadata: viewFun("0x362bd1a3", "withdrawalQueueMetadata()", {}, {"queued": p.uint128, "claimable": p.uint128, "claimed": p.uint128, "nextWithdrawalIndex": p.uint128}),
99106
withdrawalRequests: viewFun("0x937b2581", "withdrawalRequests(uint256)", {"_0": p.uint256}, {"withdrawer": p.address, "claimed": p.bool, "timestamp": p.uint40, "amount": p.uint128, "queued": p.uint128}),
@@ -257,6 +264,14 @@ export class Contract extends ContractBase {
257264
return this.eth_call(functions.vaultBuffer, {})
258265
}
259266

267+
weth() {
268+
return this.eth_call(functions.weth, {})
269+
}
270+
271+
wethAssetIndex() {
272+
return this.eth_call(functions.wethAssetIndex, {})
273+
}
274+
260275
withdrawalClaimDelay() {
261276
return this.eth_call(functions.withdrawalClaimDelay, {})
262277
}
@@ -315,6 +330,9 @@ export type YieldDistributionEventArgs = EParams<typeof events.YieldDistribution
315330
export type ADMIN_IMPLEMENTATIONParams = FunctionArguments<typeof functions.ADMIN_IMPLEMENTATION>
316331
export type ADMIN_IMPLEMENTATIONReturn = FunctionReturn<typeof functions.ADMIN_IMPLEMENTATION>
317332

333+
export type AddWithdrawalQueueLiquidityParams = FunctionArguments<typeof functions.addWithdrawalQueueLiquidity>
334+
export type AddWithdrawalQueueLiquidityReturn = FunctionReturn<typeof functions.addWithdrawalQueueLiquidity>
335+
318336
export type AdminImplPositionParams = FunctionArguments<typeof functions.adminImplPosition>
319337
export type AdminImplPositionReturn = FunctionReturn<typeof functions.adminImplPosition>
320338

@@ -330,6 +348,9 @@ export type AutoAllocateThresholdReturn = FunctionReturn<typeof functions.autoAl
330348
export type BurnForStrategyParams = FunctionArguments<typeof functions.burnForStrategy>
331349
export type BurnForStrategyReturn = FunctionReturn<typeof functions.burnForStrategy>
332350

351+
export type CacheWETHAssetIndexParams = FunctionArguments<typeof functions.cacheWETHAssetIndex>
352+
export type CacheWETHAssetIndexReturn = FunctionReturn<typeof functions.cacheWETHAssetIndex>
353+
333354
export type CalculateRedeemOutputsParams = FunctionArguments<typeof functions.calculateRedeemOutputs>
334355
export type CalculateRedeemOutputsReturn = FunctionReturn<typeof functions.calculateRedeemOutputs>
335356

@@ -342,6 +363,12 @@ export type CheckBalanceReturn = FunctionReturn<typeof functions.checkBalance>
342363
export type ClaimGovernanceParams = FunctionArguments<typeof functions.claimGovernance>
343364
export type ClaimGovernanceReturn = FunctionReturn<typeof functions.claimGovernance>
344365

366+
export type ClaimWithdrawalParams = FunctionArguments<typeof functions.claimWithdrawal>
367+
export type ClaimWithdrawalReturn = FunctionReturn<typeof functions.claimWithdrawal>
368+
369+
export type ClaimWithdrawalsParams = FunctionArguments<typeof functions.claimWithdrawals>
370+
export type ClaimWithdrawalsReturn = FunctionReturn<typeof functions.claimWithdrawals>
371+
345372
export type DripDurationParams = FunctionArguments<typeof functions.dripDuration>
346373
export type DripDurationReturn = FunctionReturn<typeof functions.dripDuration>
347374

@@ -435,6 +462,9 @@ export type RedeemReturn = FunctionReturn<typeof functions.redeem>
435462
export type RedeemFeeBpsParams = FunctionArguments<typeof functions.redeemFeeBps>
436463
export type RedeemFeeBpsReturn = FunctionReturn<typeof functions.redeemFeeBps>
437464

465+
export type RequestWithdrawalParams = FunctionArguments<typeof functions.requestWithdrawal>
466+
export type RequestWithdrawalReturn = FunctionReturn<typeof functions.requestWithdrawal>
467+
438468
export type SetAdminImplParams = FunctionArguments<typeof functions.setAdminImpl>
439469
export type SetAdminImplReturn = FunctionReturn<typeof functions.setAdminImpl>
440470

@@ -459,6 +489,12 @@ export type TrusteeFeeBpsReturn = FunctionReturn<typeof functions.trusteeFeeBps>
459489
export type VaultBufferParams = FunctionArguments<typeof functions.vaultBuffer>
460490
export type VaultBufferReturn = FunctionReturn<typeof functions.vaultBuffer>
461491

492+
export type WethParams = FunctionArguments<typeof functions.weth>
493+
export type WethReturn = FunctionReturn<typeof functions.weth>
494+
495+
export type WethAssetIndexParams = FunctionArguments<typeof functions.wethAssetIndex>
496+
export type WethAssetIndexReturn = FunctionReturn<typeof functions.wethAssetIndex>
497+
462498
export type WithdrawalClaimDelayParams = FunctionArguments<typeof functions.withdrawalClaimDelay>
463499
export type WithdrawalClaimDelayReturn = FunctionReturn<typeof functions.withdrawalClaimDelay>
464500

src/model/generated/oTokenWithdrawalRequest.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export class OTokenWithdrawalRequest {
4343
@DateTimeColumn_({nullable: true})
4444
claimedAt!: Date | undefined | null
4545

46+
@BigIntColumn_({nullable: true})
47+
queueWait!: bigint | undefined | null
48+
4649
@Index_()
4750
@StringColumn_({nullable: false})
4851
txHash!: string

src/templates/otoken/otoken.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ type OTokenWithdrawalRequest @entity {
246246
queued: BigInt!
247247
claimed: Boolean!
248248
claimedAt: DateTime
249+
queueWait: BigInt
249250
txHash: String! @index
250251
}
251252

src/templates/withdrawals.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ export const createOTokenWithdrawalsProcessor = ({
5959
) => {
6060
const data = oethVault.events.WithdrawalRequested.decode(log)
6161
const id = `${ctx.chain.id}:${oTokenAddress}:${data._withdrawer.toLowerCase()}:${data._requestId}`
62+
const input = log.transaction?.input
63+
let queueWait: bigint | null = null
64+
if (input?.startsWith(oethVault.functions.requestWithdrawal.sighash)) {
65+
const extraBytes = input.slice(74)
66+
if (extraBytes.length > 0) {
67+
queueWait = BigInt('0x' + extraBytes)
68+
}
69+
}
6270
const withdrawalRequest = new OTokenWithdrawalRequest({
6371
id,
6472
chainId: ctx.chain.id,
@@ -71,6 +79,7 @@ export const createOTokenWithdrawalsProcessor = ({
7179
queued: data._queued,
7280
withdrawer: data._withdrawer.toLowerCase(),
7381
txHash: log.transactionHash,
82+
queueWait,
7483
})
7584
result.withdrawalRequests.set(withdrawalRequest.id, withdrawalRequest)
7685
}

0 commit comments

Comments
 (0)