Skip to content

Commit

Permalink
Updated Armada protocol entities
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrwitek committed Oct 31, 2024
1 parent 5235393 commit 5634b16
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 92 deletions.
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdk/armada-protocol-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"@summerfi/sdk-common": "workspace:*",
"@summerfi/contracts-provider-common": "workspace:*",
"@summerfi/subgraph-manager-common": "workspace:*"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { IArmadaVaultId } from './IArmadaVaultId'
import { IArmadaPoolInfo } from './IArmadaPoolInfo'
import { IArmadaPosition } from './IArmadaPosition'
import { IArmadaPositionId } from './IArmadaPositionId'
import { IRebalanceData } from './IRebalanceData'
import type { GetVaultQuery, GetVaultsQuery } from '@summerfi/subgraph-manager-common'
import type { IRebalanceData } from '@summerfi/contracts-provider-common'

/**
* @name IArmadaManager
Expand Down
5 changes: 0 additions & 5 deletions sdk/armada-protocol-common/src/common/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,3 @@ export {
isArmadaProtocol,
} from './IArmadaProtocol'
export type { IArmadaProtocol, IArmadaProtocolData } from './IArmadaProtocol'
export {
__signature__ as __irebalancedata__,
isRebalanceData,
type IRebalanceData,
} from './IRebalanceData'
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {
IArmadaPoolInfo,
IArmadaPosition,
IArmadaPositionId,
IRebalanceData,
} from '@summerfi/armada-protocol-common'
import { IConfigurationProvider } from '@summerfi/configuration-provider-common'
import { IContractsProvider } from '@summerfi/contracts-provider-common'
import { IContractsProvider, type IRebalanceData } from '@summerfi/contracts-provider-common'
import { IAddress, IPercentage, ITokenAmount, IUser, TransactionInfo } from '@summerfi/sdk-common'
import { IArmadaSubgraphManager } from '@summerfi/subgraph-manager-common'
import { ArmadaPool } from './ArmadaPool'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ export * from './ArmadaPosition'
export * from './ArmadaPositionId'
export * from './ArmadaProtocol'
export * from './ArmadaSimulation'
export * from './RebalanceData'
1 change: 0 additions & 1 deletion sdk/contracts-provider-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
},
"dependencies": {
"@summerfi/sdk-common": "workspace:*",
"@summerfi/armada-protocol-common": "workspace:*",
"@summerfi/blockchain-client-common": "workspace:*",
"@summerfi/abi-provider-common": "workspace:*"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IRebalanceData } from '@summerfi/armada-protocol-common'
import { IAddress, IPercentage, ITokenAmount, TransactionInfo } from '@summerfi/sdk-common'
import { IContractWrapper } from './IContractWrapper'
import { IErc20Contract } from './IErc20Contract'
import { IErc4626Contract } from './IErc4626Contract'
import type { IFleetConfig, IRebalanceData } from '../types'

/**
* @name IFleetCommanderContract
Expand All @@ -21,12 +21,7 @@ export interface IFleetCommanderContract extends IContractWrapper {
* @name config
* @description Returns the configuration of the fleet
*/
config(): Promise<{
bufferArk: IAddress
minimumBufferBalance: ITokenAmount
depositCap: ITokenAmount
maxRebalanceOperations: string
}>
config(): Promise<IFleetConfig>

/**
* @name maxDeposit
Expand Down

This file was deleted.

18 changes: 18 additions & 0 deletions sdk/contracts-provider-common/src/interfaces/types/IFleetConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { IAddress, ITokenAmount } from '@summerfi/sdk-common/common'

/**
* @name IFleetConfig
* @description Data structure for rebalancing assets, used by Keepers of a fleet
*/
export interface IFleetConfig {
/** The address of the buffer Ark associated with this Fleet */
readonly bufferArk: IAddress
/** The minimum balance that should be maintained in the buffer Ark */
readonly minimumBufferBalance: ITokenAmount
/** The maximum total value of assets that can be deposited into the fleet */
readonly depositCap: ITokenAmount
/** The maximum number of rebalance operations that can be performed in a single rebalance transaction */
readonly maxRebalanceOperations: string
/** The address of the staking rewards manager contract */
readonly stakingRewardsManager: IAddress
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ import {
} from '@summerfi/sdk-common/common'
import { z } from 'zod'

/**
* Unique signature to provide branded types to the interface
*/
export const __signature__: unique symbol = Symbol()

/**
* @name IRebalanceData
* @description Data structure for rebalancing assets, used by Keepers of a fleet
*/
export interface IRebalanceData {
/** Signature to differentiate from similar interfaces */
readonly [__signature__]: symbol
/** Ark where the tokens are taken from */
readonly fromArk: IAddress
/** Ark where the tokens are moved to */
Expand Down
4 changes: 3 additions & 1 deletion sdk/contracts-provider-common/src/interfaces/types/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * as FleetCommander from './FleetCommander'
export * as FleetCommanderTypes from './FleetCommanderTypes'
export * from './IRebalanceData'
export * from './IFleetConfig'
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { IBlockchainClient } from '@summerfi/blockchain-client-common'
import {
FleetCommander,
FleetCommanderTypes,
IErc20Contract,
IErc4626Contract,
IFleetCommanderContract,
type IFleetConfig,
type IRebalanceData,
} from '@summerfi/contracts-provider-common'
import {
Address,
Expand All @@ -19,7 +21,6 @@ import {
import { ContractWrapper } from '../ContractWrapper'

import { FleetCommanderAbi } from '@summerfi/armada-protocol-abis'
import { IRebalanceData } from '@summerfi/armada-protocol-common'
import { Erc4626Contract } from '../Erc4626Contract/Erc4626Contract'

/**
Expand Down Expand Up @@ -82,14 +83,14 @@ export class FleetCommanderContract<
}

/** @see IFleetCommanderContract.config */
async config(): Promise<{
bufferArk: IAddress
minimumBufferBalance: ITokenAmount
depositCap: ITokenAmount
maxRebalanceOperations: string
}> {
const [bufferArkAddress, minimumBufferBalance, depositCap, maxRebalanceOperations] =
await this.contract.read.config()
async config(): Promise<IFleetConfig> {
const [
bufferArkAddress,
minimumBufferBalance,
depositCap,
maxRebalanceOperations,
stakingRewardsManagerAddress,
] = await this.contract.read.config()
const token = await this._erc4626Contract.asset()
return {
bufferArk: Address.createFromEthereum({ value: bufferArkAddress }),
Expand All @@ -99,6 +100,9 @@ export class FleetCommanderContract<
}),
depositCap: TokenAmount.createFromBaseUnit({ token, amount: String(depositCap) }),
maxRebalanceOperations: String(maxRebalanceOperations),
stakingRewardsManager: Address.createFromEthereum({
value: stakingRewardsManagerAddress,
}),
}
}

Expand Down Expand Up @@ -360,7 +364,7 @@ export class FleetCommanderContract<
/** PRIVATE */
private _convertRebalanceDataToSolidity(params: {
rebalanceData: IRebalanceData[]
}): FleetCommander.RebalanceDataSolidity[] {
}): FleetCommanderTypes.RebalanceDataSolidity[] {
return params.rebalanceData.map((data) => ({
fromArk: data.fromArk.toSolidityValue(),
toArk: data.toArk.toSolidityValue(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
isArmadaVaultId,
isRebalanceData,
type IArmadaVaultId,
type IRebalanceData,
} from '@summerfi/armada-protocol-common'
import { isArmadaVaultId, type IArmadaVaultId } from '@summerfi/armada-protocol-common'
import { z } from 'zod'
import { publicProcedure } from '../../SDKTRPC'
import { isRebalanceData, type IRebalanceData } from '@summerfi/contracts-provider-common'

export const forceRebalance = publicProcedure
.input(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import {
isArmadaVaultId,
isRebalanceData,
type IArmadaVaultId,
type IRebalanceData,
} from '@summerfi/armada-protocol-common'
import { isArmadaVaultId, type IArmadaVaultId } from '@summerfi/armada-protocol-common'

import { z } from 'zod'
import { publicProcedure } from '../../SDKTRPC'
import { isRebalanceData, type IRebalanceData } from '@summerfi/contracts-provider-common'

export const adjustBuffer = publicProcedure
.input(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
isArmadaVaultId,
isRebalanceData,
type IArmadaVaultId,
type IRebalanceData,
} from '@summerfi/armada-protocol-common'
import { isArmadaVaultId, type IArmadaVaultId } from '@summerfi/armada-protocol-common'
import { z } from 'zod'
import { publicProcedure } from '../../SDKTRPC'
import { isRebalanceData, type IRebalanceData } from '@summerfi/contracts-provider-common'

export const rebalance = publicProcedure
.input(
Expand Down

0 comments on commit 5634b16

Please sign in to comment.