Skip to content

Commit

Permalink
feat: updated auction house abis (#38)
Browse files Browse the repository at this point in the history
* feat: added updated abis for auction houses

* fix: missing abis

* feat: allow not used variables

* feat: add address and blocktimestamp

* feat: new addresses

---------

Co-authored-by: shaito <[email protected]>
  • Loading branch information
wei3erHase and 0xShaito authored Jul 17, 2023
1 parent 2eb5186 commit feb463b
Show file tree
Hide file tree
Showing 11 changed files with 11,293 additions and 1,820 deletions.
406 changes: 0 additions & 406 deletions abis/BurningSurplusAuctionHouse.json

This file was deleted.

Large diffs are not rendered by default.

576 changes: 441 additions & 135 deletions abis/DebtAuctionHouse.json

Large diffs are not rendered by default.

716 changes: 0 additions & 716 deletions abis/FixedDiscountCollateralAuctionHouse.json

This file was deleted.

446 changes: 0 additions & 446 deletions abis/RecyclingSurplusAuctionHouse.json

This file was deleted.

10,454 changes: 10,454 additions & 0 deletions abis/SurplusAuctionHouse.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/api/contract-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ContractApis {
public oracleRelayer: types.OracleRelayer
public globalSettlement: types.GlobalSettlement
public debtAuctionHouse: types.DebtAuctionHouse
public surplusAuctionHouse: types.RecyclingSurplusAuctionHouse
public surplusAuctionHouse: types.SurplusAuctionHouse
public stabilityFeeTreasury: types.StabilityFeeTreasury
public safeManager: types.GebSafeManager
public getSafes: types.GetSafes
Expand All @@ -27,7 +27,7 @@ export class ContractApis {
public rateSetter: types.PIRateSetter
public piCalculator: types.PRawPerSecondCalculator
public weth: types.WETH9_
public tokenCollateralAuctionHouse: { [key: string]: types.IncreasingDiscountCollateralAuctionHouse }
public tokenCollateralAuctionHouse: { [key: string]: types.CollateralAuctionHouse }

constructor(
network: GebDeployment,
Expand All @@ -44,7 +44,7 @@ export class ContractApis {
this.oracleRelayer = types.OracleRelayer__factory.connect(addressList.GEB_ORACLE_RELAYER, signerOrProvider)
this.globalSettlement = types.GlobalSettlement__factory.connect(addressList.GEB_GLOBAL_SETTLEMENT, signerOrProvider)
this.debtAuctionHouse = types.DebtAuctionHouse__factory.connect(addressList.GEB_DEBT_AUCTION_HOUSE, signerOrProvider)
this.surplusAuctionHouse = types.RecyclingSurplusAuctionHouse__factory.connect(addressList.GEB_SURPLUS_AUCTION_HOUSE, signerOrProvider)
this.surplusAuctionHouse = types.SurplusAuctionHouse__factory.connect(addressList.GEB_SURPLUS_AUCTION_HOUSE, signerOrProvider)
this.stabilityFeeTreasury = types.StabilityFeeTreasury__factory.connect(addressList.GEB_STABILITY_FEE_TREASURY, signerOrProvider)
this.safeManager = types.GebSafeManager__factory.connect(addressList.SAFE_MANAGER, signerOrProvider)
this.getSafes = types.GetSafes__factory.connect(addressList.SAFE_MANAGER, signerOrProvider)
Expand All @@ -59,7 +59,7 @@ export class ContractApis {
this.protocolToken = types.ERC20__factory.connect(addressList.GEB_PROT, signerOrProvider)

this.tokenCollateralAuctionHouse = Object.values(tokenList).filter(token => token.isCollateral).reduce((accum, token) => {
const collateralAuctionHouse = types.IncreasingDiscountCollateralAuctionHouse__factory.connect(token.collateralAuctionHouse, signerOrProvider)
const collateralAuctionHouse = types.CollateralAuctionHouse__factory.connect(token.collateralAuctionHouse, signerOrProvider)
return { ...accum, [token.symbol]: collateralAuctionHouse }
}, {})
}
Expand Down
18 changes: 9 additions & 9 deletions src/auctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
RestartAuctionEventFilter as SurplusRestartAuctonEventFilter,
SettleAuctionEventFilter as SurplusSettleAuctionEventFilter,
StartAuctionEventFilter as SurplusStartAuctionEventFilter,
} from './typechained/RecyclingSurplusAuctionHouse'
} from './typechained/SurplusAuctionHouse'

import {
DecreaseSoldAmountEventFilter as DebtDecreaseSoldAmountEventFilter,
Expand Down Expand Up @@ -78,20 +78,20 @@ export class Auctions {
([startAuction, bidEvents, restartAuctions, settledAuctions]) => {
const bids = bidEvents.reduce((accum: { [key: string]: IAuctionBidder[] }, bid) => {
const parsedBid = bidEventToBid(bid)
const id = bid.args.id.toString()
const id = bid.args._id.toString()
const bidsForId = accum[id]
return { ...accum, [id]: bidsForId ? bidsForId.concat(parsedBid) : [parsedBid] }
}, {})

const restarts = restartAuctions.reduce((accum: { [key: string]: BigNumber }, restart) => {
const id = restart.args.id.toString()
const id = restart.args._id.toString()
const lastRestart = accum[id]
const newRestart = restart.args.auctionDeadline // Do events always come ordered correctly?
const newRestart = restart.args._auctionDeadline // Do events always come ordered correctly?
return { ...accum, [id]: !lastRestart || newRestart.gt(lastRestart) ? newRestart : lastRestart }
}, {})

const settled = settledAuctions.reduce((accum: { [key: string]: boolean }, settled) => {
const id = settled.args.id.toString()
const id = settled.args._id.toString()
return { ...accum, [id]: true }
}, {})

Expand Down Expand Up @@ -123,20 +123,20 @@ export class Auctions {
([startAuction, bidEvents, restartAuctions, settledAuctions]) => {
const bids = bidEvents.reduce((accum: { [key: string]: IAuctionBidder[] }, bid) => {
const parsedBid = bidEventToBid(bid)
const id = bid.args.id.toString()
const id = bid.args._id.toString()
const bidsForId = accum[id]
return { ...accum, [id]: bidsForId ? bidsForId.concat(parsedBid) : [parsedBid] }
}, {})

const restarts = restartAuctions.reduce((accum: { [key: string]: BigNumber }, restart) => {
const id = restart.args.id.toString()
const id = restart.args._id.toString()
const lastRestart = accum[id]
const newRestart = restart.args.auctionDeadline // Do events always come ordered correctly?
const newRestart = restart.args._auctionDeadline // Do events always come ordered correctly?
return { ...accum, [id]: !lastRestart || newRestart.gt(lastRestart) ? newRestart : lastRestart }
}, {})

const settled = settledAuctions.reduce((accum: { [key: string]: boolean }, settled) => {
const id = settled.args.id.toString()
const id = settled.args._id.toString()
return { ...accum, [id]: true }
}, {})

Expand Down
18 changes: 9 additions & 9 deletions src/contracts/addreses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ const addresses: Record<GebDeployment, ContractList> = {
GEB_PROT: '0x64ff820bbD2947B2f2D4355D4852F17eb0156D9A',
GEB_SAFE_ENGINE: '0xDfd2D62b3eC9BF6F52547c570B5AC2136D9756E4',
GEB_TAX_COLLECTOR: '0x1A88AB748C17E62CD99a2b7162EA0dD8AB7A059A',
GEB_LIQUIDATION_ENGINE: '0x389b9Eb0cDEAedf96d0dF8e4caA72b5cA5672870',
GEB_LIQUIDATION_ENGINE: '0xC9E07e417e952c79FA65428076C9575C4026b43e',
GEB_ACCOUNTING_ENGINE: '0xc922644df8E6336c6DFc997e29602EF4aba51c8c',
GEB_COIN_JOIN: '0x3217B0aBcaAC50898F4826f0C502dEd9AB8eae53',
GEB_SURPLUS_AUCTION_HOUSE: '0xa65394B23d7c6C2B3aBe9B9ed69a527E2026f855',
GEB_DEBT_AUCTION_HOUSE: '0x8F7cFe960F12710B1Fe1F3ef4352D3530209598A',
GEB_ORACLE_RELAYER: '0xca53F197A4A3C72F9954e34906DFC59148Ce653f',
GEB_SURPLUS_AUCTION_HOUSE: '0x72DfB98ffdE560E895a82f1f525c66C959F7eF86',
GEB_DEBT_AUCTION_HOUSE: '0x0c9cea9FE68A8612A627ab150De8f4B05bf4c784',
GEB_ORACLE_RELAYER: '0x39eF5478F9186Da7c5C0a79B379B20648462626F',
GEB_GLOBAL_SETTLEMENT: '0xFd4fB8e5f11A3FD403761a832bC35F31d5579B83',
GEB_STABILITY_FEE_TREASURY: '0xFAD4f858867D7aB4Bd7b80c611287abF4B139986',
GEB_RRFM_CALCULATOR: '0x0000000000000000000000000000000000000114',
Expand Down Expand Up @@ -149,7 +149,7 @@ const tokens: Record<GebDeployment, TokenList> = {
symbol: 'WETH',
bytes32String: WETH,
collateralJoin: '0x69DE387041C3056ec96aEFb432A546EAe4394da6',
collateralAuctionHouse: '0x46f7a52A5543cC5068dc7aF31aE49eBF0778eF8A',
collateralAuctionHouse: '0x166425Cc84996DC0d8fEaDa66F86055AAE8f8209',
isCollateral: true,
},
OP: {
Expand All @@ -158,7 +158,7 @@ const tokens: Record<GebDeployment, TokenList> = {
symbol: 'OP',
bytes32String: OP,
collateralJoin: '0xA59A8a069284e52B8c761d7e0AC2129733ACCBF6',
collateralAuctionHouse: '0x47C2c459c37FEF0c21dC8e945008E8A05346942d',
collateralAuctionHouse: '0xeAfB6be474e84fC5f3aF7bbaD39D89A5764D4D36',
isCollateral: true,
},
WBTC: {
Expand All @@ -167,7 +167,7 @@ const tokens: Record<GebDeployment, TokenList> = {
symbol: 'WBTC',
bytes32String: WBTC,
collateralJoin: '0x187Bcd738ca9fDDfC2439A7Cd537C05F85C40429',
collateralAuctionHouse: '0x36677aD304c296F9cb24943830E4540C702a63FF',
collateralAuctionHouse: '0x724A7b53c0B81DDB0654e012c94667730CBa1837',
isCollateral: true,
},
STN: {
Expand All @@ -176,7 +176,7 @@ const tokens: Record<GebDeployment, TokenList> = {
symbol: 'STN',
bytes32String: STONES,
collateralJoin: '0x78c64A263F685f98A83412A6891706cFa7eA29BB',
collateralAuctionHouse: '0xF2DFB982FaeDe09c2E1a0Fa5de026FaD25f75dC0',
collateralAuctionHouse: '0x22a804F6685f96dE8CD81aba0C85fe49884274f8',
isCollateral: true,
},
TTM: {
Expand All @@ -185,7 +185,7 @@ const tokens: Record<GebDeployment, TokenList> = {
symbol: 'TTM',
bytes32String: TOTEM,
collateralJoin: '0xC396AC5dc7e35c0BA7dca51b5eedbdd6055b91dB',
collateralAuctionHouse: '0x76aBf3D8Ab0e405f68aE991904A3b8F8E19647Bc',
collateralAuctionHouse: '0x24CF3ddF28d7a2e046Ea9bD1B6908D8B33AAB873',
isCollateral: true,
},
HAI: {
Expand Down
55 changes: 23 additions & 32 deletions src/schema/auction.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { BigNumber } from 'ethers'
import {
IncreaseBidSizeEvent,
StartAuctionEvent as SurplusStartAuctionEvent,
} from '../typechained/RecyclingSurplusAuctionHouse'
import { IncreaseBidSizeEvent, StartAuctionEvent as SurplusStartAuctionEvent } from '../typechained/SurplusAuctionHouse'
import { StartAuctionEvent as DebtStartAuctionEvent } from '../typechained/DebtAuctionHouse'
import {
BuyCollateralEvent,
StartAuctionEvent as CollateralAuctionStartEvent,
} from '../typechained/IncreasingDiscountCollateralAuctionHouse'
} from '../typechained/CollateralAuctionHouse'

export interface ISurplusAuction {
auctionDeadline: string
Expand All @@ -29,7 +26,6 @@ export interface IDebtAuction {
isClaimed: boolean
amount: string
initialBid: string
incomeReceiver: string
}

export interface ICollateralAuction {
Expand All @@ -42,8 +38,6 @@ export interface ICollateralAuction {
startingDiscount: string
maxDiscount: string
perSecondDiscountUpdateRate: string
forgoneCollateralReceiver: string
auctionIncomeRecipient: string
isClaimed: boolean
biddersList: Array<IAuctionBidder>
}
Expand All @@ -62,13 +56,13 @@ export function surplusStartAuctionEventToAuction(
restarts: { [key: string]: BigNumber },
settled: { [key: string]: boolean }
): ISurplusAuction {
const id = startAuction.args.id.toString()
const id = startAuction.args._id.toString()
return {
auctionDeadline: restarts[id] ? restarts[id].toString() : startAuction.args.auctionDeadline.toString(),
auctionDeadline: restarts[id] ? restarts[id].toString() : startAuction.args._auctionDeadline.toString(),
auctionId: id,
amount: startAuction.args.amountToSell.toString(),
initialBid: startAuction.args.initialBid.toString(),
createdAt: startAuction.blockNumber.toString(),
amount: startAuction.args._amountToSell.toString(),
initialBid: startAuction.args._amountToRaise.toString(),
createdAt: startAuction.args._blockTimestamp.toString(),
createdAtTransaction: startAuction.transactionHash.toString(),
biddersList: bids[id] || [],
isClaimed: settled[id] || false,
Expand All @@ -81,17 +75,16 @@ export function debtStartAuctionEventToAuction(
restarts: { [key: string]: BigNumber },
settled: { [key: string]: boolean }
): IDebtAuction {
const id = startAuction.args.id.toString()
const id = startAuction.args._id.toString()
return {
auctionDeadline: restarts[id] ? restarts[id].toString() : startAuction.args.auctionDeadline.toString(),
auctionDeadline: restarts[id] ? restarts[id].toString() : startAuction.args._auctionDeadline.toString(),
auctionId: id,
amount: startAuction.args.amountToSell.toString(),
initialBid: startAuction.args.initialBid.toString(),
createdAt: startAuction.blockNumber.toString(),
amount: startAuction.args._amountToSell.toString(),
initialBid: startAuction.args._amountToRaise.toString(),
createdAt: startAuction.args._blockTimestamp.toString(),
createdAtTransaction: startAuction.transactionHash.toString(),
biddersList: bids[id] || [],
isClaimed: settled[id] || false,
incomeReceiver: startAuction.args.incomeReceiver.toString(),
}
}

Expand All @@ -102,37 +95,35 @@ export function collateralStartAuctionEventToAuction(
): ICollateralAuction {
return {
auctionId: startAuction.args._id.toString(),
createdAt: startAuction.blockNumber.toString(),
createdAt: startAuction.args._blockTimestamp.toString(),
createdAtTransaction: startAuction.transactionHash.toString(),
amountToSell: startAuction.args._amountToSell.toString(),
initialBid: startAuction.args._initialBid.toString(),
initialBid: startAuction.args._amountToRaise.toString(),
amountToRaise: startAuction.args._amountToRaise.toString(),
startingDiscount: startAuction.args._startingDiscount.toString(),
startingDiscount: startAuction.args._initialDiscount.toString(),
maxDiscount: startAuction.args._maxDiscount.toString(),
perSecondDiscountUpdateRate: startAuction.args._perSecondDiscountUpdateRate.toString(),
forgoneCollateralReceiver: startAuction.args._forgoneCollateralReceiver.toString(),
auctionIncomeRecipient: startAuction.args._auctionIncomeRecipient.toString(),
isClaimed: settled[startAuction.args._id.toString()] || false,
biddersList: bids[startAuction.args._id.toString()] || [],
}
}

export function bidEventToBid(bid: IncreaseBidSizeEvent): IAuctionBidder {
return {
bidder: bid.args.highBidder,
bid: bid.args.bid.toString(),
createdAt: bid.blockNumber.toString(),
buyAmount: bid.args.amountToBuy.toString(),
bidder: bid.args._bidder,
bid: bid.args._raisedAmount.toString(),
createdAt: bid.args._blockTimestamp.toString(),
buyAmount: bid.args._soldAmount.toString(),
createdAtTransaction: bid.transactionHash,
}
}

export function collateralBidEventToBid(bid: BuyCollateralEvent): IAuctionBidder {
return {
bidder: '0x0000000000000000000000000000000000000000', // TODO: change when new events come in
createdAt: '1689159421', // TODO: change when new events come in
bid: bid.args._boughtCollateral.toString(),
buyAmount: bid.args._wad.toString(),
bidder: bid.args._bidder,
createdAt: bid.args._blockTimestamp.toString(),
bid: bid.args._raisedAmount.toString(),
buyAmount: bid.args._soldAmount.toString(),
createdAtTransaction: bid.transactionHash,
}
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"module": "commonjs",
"sourceMap": true,
"target": "es5"
Expand Down

0 comments on commit feb463b

Please sign in to comment.