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

Refactor depositCap to use config in FleetCommanderContract #553

Merged
merged 10 commits into from
Oct 31, 2024

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class ArmadaManager implements IArmadaManager {
const fleetERC4626Contract = fleetContract.asErc4626()
const fleetERC20Contract = fleetERC4626Contract.asErc20()

const depositCap = await fleetContract.depositCap()
const { depositCap } = await fleetContract.config()
const totalDeposits = await fleetERC4626Contract.totalAssets()
const totalShares = await fleetERC20Contract.totalSupply()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ export interface IFleetCommanderContract extends IContractWrapper {
arks(): Promise<IAddress[]>

/**
* @name depositCap
* @description Returns the deposit cap of the fleet, this is the maximum amount of assets that
* the fleet can manage, and therefore the maximum amount of assets that can be deposited
* in total by all users
*/
depositCap(): Promise<ITokenAmount>
* @name config
* @description Returns the configuration of the fleet
*/
config(): Promise<{
bufferArk: IAddress
minimumBufferBalance: ITokenAmount
depositCap: ITokenAmount
maxRebalanceOperations: string
}>

/**
* @name maxDeposit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,25 @@ export class FleetCommanderContract<
return arks.map((ark) => Address.createFromEthereum({ value: ark }))
}

/** @see IFleetCommanderContract.depositCap */
async depositCap(): Promise<ITokenAmount> {
/** @see IFleetCommanderContract.config */
async config(): Promise<{
bufferArk: IAddress
minimumBufferBalance: ITokenAmount
depositCap: ITokenAmount
maxRebalanceOperations: string
}> {
const [bufferArkAddress, minimumBufferBalance, depositCap, maxRebalanceOperations] =
await this.contract.read.config()
const token = await this._erc4626Contract.asset()
const depositCap = await this.contract.read.depositCap()

return TokenAmount.createFromBaseUnit({ token, amount: String(depositCap) })
return {
bufferArk: Address.createFromEthereum({ value: bufferArkAddress }),
minimumBufferBalance: TokenAmount.createFromBaseUnit({
token,
amount: String(minimumBufferBalance),
}),
depositCap: TokenAmount.createFromBaseUnit({ token, amount: String(depositCap) }),
maxRebalanceOperations: String(maxRebalanceOperations),
}
}

/** @see IFleetCommanderContract.maxDeposit */
Expand Down
Loading