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

Remove get-earn-protocol-* lambdas #545

Merged
merged 9 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 3 additions & 95 deletions pnpm-lock.yaml

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

3 changes: 2 additions & 1 deletion sdk/armada-protocol-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@summerfi/sdk-common": "workspace:*"
"@summerfi/sdk-common": "workspace:*",
"@summerfi/subgraph-manager-common": "workspace:*"
},
"devDependencies": {
"@summerfi/eslint-config": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions sdk/armada-protocol-common/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './interfaces'
export type { GetVaultsQuery, GetVaultQuery } from '@summerfi/subgraph-manager-common'
23 changes: 16 additions & 7 deletions sdk/armada-protocol-common/src/common/interfaces/IArmadaManager.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { IAddress, IPercentage, ITokenAmount } from '@summerfi/sdk-common/common'
import { IAddress, IPercentage, ITokenAmount, type ChainInfo } from '@summerfi/sdk-common/common'
import { TransactionInfo } from '@summerfi/sdk-common/orders'
import { IUser } from '@summerfi/sdk-common/user'
import { IArmadaPool } from './IArmadaPool'
import { IArmadaPoolId } from './IArmadaPoolId'
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'

/**
* @name IArmadaManager
Expand All @@ -16,15 +16,24 @@ export interface IArmadaManager {
/** POOLS */

/**
* @name getPool
* @description Get the position of a user in the specified fleet
* @name getVaultsRaw
* @description Get all vaults in the protocol
*
* @param poolId ID of the pool to retrieve
* @param chainInfo Chain information
*
* @returns IArmadaPool The pool with the specified ID
* @returns GetVaultsQuery
*/
getVaultsRaw(params: { chainInfo: ChainInfo }): Promise<GetVaultsQuery>

/**
* @name getVaultRaw
* @description Get the specific vault in the protocol
*
* @param poolId ID of the pool to retrieve
*
* @returns GetVaultQuery
*/
getPool(params: { poolId: IArmadaPoolId }): Promise<IArmadaPool>
getVaultRaw(params: { poolId: IArmadaPoolId }): Promise<GetVaultQuery>

/**
* @name getPoolInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { IAllowanceManager } from '@summerfi/allowance-manager-common'
import {
IArmadaManager,
IArmadaPool,
IArmadaPoolId,
IArmadaPoolInfo,
IArmadaPosition,
Expand Down Expand Up @@ -43,12 +42,16 @@ export class ArmadaManager implements IArmadaManager {

/** POOLS */

/** @see IArmadaManager.getPool */
async getPool(params: { poolId: IArmadaPoolId }): Promise<IArmadaPool> {
// TODO: probably the Pool data type should contain all the pool info directly, and the ID
// TODO: is the one that gets passed around
return ArmadaPool.createFrom({
id: params.poolId,
/** @see IArmadaManager.getVaultsRaw */
async getVaultsRaw(params: Parameters<IArmadaManager['getVaultsRaw']>[0]) {
return this._subgraphManager.getVaults({ chainId: params.chainInfo.chainId })
}

/** @see IArmadaManager.getVaultRaw */
async getVaultRaw(params: Parameters<IArmadaManager['getVaultRaw']>[0]) {
return this._subgraphManager.getVault({
chainId: params.poolId.chainInfo.chainId,
vaultId: params.poolId.fleetAddress.value,
})
}

Expand Down Expand Up @@ -115,7 +118,9 @@ export class ArmadaManager implements IArmadaManager {
})
const userAssets = await fleetERC4626Contract.convertToAssets({ amount: userShares })

const pool = await this.getPool({ poolId: params.poolId })
const pool = ArmadaPool.createFrom({
id: params.poolId,
})

return ArmadaPosition.createFrom({
id: params.positionId,
Expand Down
2 changes: 1 addition & 1 deletion sdk/sdk-client-react/src/handlers/getWithdrawTXHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArmadaPoolId, ArmadaPositionId, ArmadaProtocol } from '@summerfi/armada-protocol-service'
import { ArmadaPoolId, ArmadaProtocol } from '@summerfi/armada-protocol-service'
import { type ISDKManager } from '@summerfi/sdk-client'
import {
Address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { IArmadaManagerClient } from '../../interfaces/ArmadaManager/IArmadaMana
import { IArmadaManagerGovernanceClient } from '../../interfaces/ArmadaManager/IArmadaManagerGovernanceClient'
import { IArmadaManagerKeepersClient } from '../../interfaces/ArmadaManager/IArmadaManagerKeepersClient'
import { IArmadaManagerUsersClient } from '../../interfaces/ArmadaManager/IArmadaManagerUsersClient'
import { IRPCClient } from '../../interfaces/IRPCClient'
import { RPCMainClientType } from '../../rpc/SDKMainClient'
import { ArmadaManagerGovernanceClient } from './ArmadaManagerGovernanceClient'
import { ArmadaManagerKeepersClient } from './ArmadaManagerKeepersClient'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
IArmadaPool,
IArmadaPoolId,
IArmadaPoolInfo,
IArmadaPosition,
Expand All @@ -20,38 +19,43 @@ export class ArmadaManagerUsersClient extends IRPCClient implements IArmadaManag
super(params)
}

/** @see IArmadaManagerClient.getPool */
public async getPool(params: { poolId: IArmadaPoolId }): Promise<IArmadaPool> {
return this.rpcClient.armada.users.getPool.query(params)
/** @see IArmadaManagerUsersClient.getVaultsRaw */
async getVaultsRaw(params: Parameters<IArmadaManagerUsersClient['getVaultsRaw']>[0]) {
return this.rpcClient.armada.users.getVaultsRaw.query(params)
}

/** @see IArmadaManagerClient.getPoolInfo */
/** @see IArmadaManagerUsersClient.getVaultRaw */
async getVaultRaw(params: Parameters<IArmadaManagerUsersClient['getVaultRaw']>[0]) {
return this.rpcClient.armada.users.getVaultRaw.query(params)
}

/** @see IArmadaManagerUsersClient.getPoolInfo */
async getPoolInfo(params: { poolId: IArmadaPoolId }): Promise<IArmadaPoolInfo> {
return this.rpcClient.armada.users.getPoolInfo.query(params)
}

/** @see IArmadaManagerClient.getUserPositions */
/** @see IArmadaManagerUsersClient.getUserPositions */
async getUserPositions(params: { user: IUser }): Promise<IArmadaPosition[]> {
return this.rpcClient.armada.users.getUserPositions.query(params)
}

/** @see IArmadaManagerClient.getUserPositions */
/** @see IArmadaManagerUsersClient.getUserPositions */
async getUserPosition(params: { user: IUser; fleetAddress: IAddress }): Promise<IArmadaPosition> {
return this.rpcClient.armada.users.getUserPosition.query({
user: params.user,
fleetAddress: params.fleetAddress,
})
}

/** @see IArmadaManagerClient.getPosition */
/** @see IArmadaManagerUsersClient.getPosition */
async getPosition(params: {
poolId: IArmadaPoolId
positionId: IArmadaPositionId
}): Promise<IArmadaPosition> {
return this.rpcClient.armada.users.getPosition.query(params)
}

/** @see IArmadaManagerClient.getNewDepositTX */
/** @see IArmadaManagerUsersClient.getNewDepositTX */
async getNewDepositTX(params: {
poolId: IArmadaPoolId
user: IUser
Expand All @@ -60,7 +64,7 @@ export class ArmadaManagerUsersClient extends IRPCClient implements IArmadaManag
return this.rpcClient.armada.users.getDepositTX.query(params)
}

/** @see IArmadaManagerClient.getUpdateDepositTX */
/** @see IArmadaManagerUsersClient.getUpdateDepositTX */
async getUpdateDepositTX(params: {
poolId: IArmadaPoolId
positionId: IArmadaPositionId
Expand All @@ -69,7 +73,7 @@ export class ArmadaManagerUsersClient extends IRPCClient implements IArmadaManag
return this.rpcClient.armada.users.getUpdateDepositTX.query(params)
}

/** @see IArmadaManagerClient.getWithdrawTX */
/** @see IArmadaManagerUsersClient.getWithdrawTX */
async getWithdrawTX(params: {
poolId: IArmadaPoolId
user: IUser
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import {
IArmadaPool,
IArmadaPoolId,
IArmadaPoolInfo,
IArmadaPosition,
IArmadaPositionId,
type GetVaultQuery,
type GetVaultsQuery,
} from '@summerfi/armada-protocol-common'
import { ITokenAmount, IUser, TransactionInfo, type IAddress } from '@summerfi/sdk-common'
import {
ITokenAmount,
IUser,
TransactionInfo,
type ChainInfo,
type IAddress,
} from '@summerfi/sdk-common'

/**
* @interface IArmadaManagerUsersClient
Expand All @@ -14,14 +21,24 @@ import { ITokenAmount, IUser, TransactionInfo, type IAddress } from '@summerfi/s
*/
export interface IArmadaManagerUsersClient {
/**
* @method getPool
* @description Retrieves an Armada pool by its ID
* @method getVaultsRaw
* @description Retrieves all protocol vaults
*
* @param poolId ID of the pool to retrieve
* @param chainInfo Chain information
*
* @returns All Armada vaults
*/
getVaultsRaw(params: { chainInfo: ChainInfo }): Promise<GetVaultsQuery>

/**
* @method getVaultRaw
* @description Retrieves a specific protocol vault
*
* @param poolId ID of the vault
*
* @returns The corresponding Armada pool
* @returns The corresponding Armada vault
*/
getPool(params: { poolId: IArmadaPoolId }): Promise<IArmadaPool>
getVaultRaw(params: { poolId: IArmadaPoolId }): Promise<GetVaultQuery>

/**
* @method getPoolInfo
Expand Down
2 changes: 1 addition & 1 deletion sdk/sdk-e2e/e2e/armadaProtocolUsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Armada Protocol Users', () => {
throw new Error('Missing fork url')
}

describe.skip(`Deposit/Withdraw with ${symbol} fleet on ${chainInfo.name}`, () => {
describe(`Deposit/Withdraw with ${symbol} fleet on ${chainInfo.name}`, () => {
let poolId: IArmadaPoolId
let token: IToken
let user: IUser
Expand Down
3 changes: 2 additions & 1 deletion sdk/sdk-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"test": "jest",
"testw": "jest --watch",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
"lint:fix": "eslint . --fix",
"e2e": "jest --roots e2e"
},
"devDependencies": {
"@summerfi/armada-protocol-common": "workspace:*",
Expand Down
6 changes: 4 additions & 2 deletions sdk/sdk-server/src/SDKAppRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { updateRebalanceCooldown } from './armada-protocol-handlers/governance/u
import { adjustBuffer } from './armada-protocol-handlers/keepers/adjustBuffer'
import { rebalance } from './armada-protocol-handlers/keepers/rebalance'
import { getDepositTX } from './armada-protocol-handlers/users/getDepositTX'
import { getPool } from './armada-protocol-handlers/users/getPool'
import { getVaultsRaw } from './armada-protocol-handlers/users/getVaults'
import { getVaultRaw } from './armada-protocol-handlers/users/getVault'
import { getPoolInfo } from './armada-protocol-handlers/users/getPoolInfo'
import { getPosition as getArmadaPosition } from './armada-protocol-handlers/users/getPosition'
import { getUpdateDepositTX } from './armada-protocol-handlers/users/getUpdateDepositTX'
Expand Down Expand Up @@ -64,7 +65,8 @@ export const sdkAppRouter = router({
},
armada: {
users: {
getPool: getPool,
getVaultsRaw: getVaultsRaw,
getVaultRaw: getVaultRaw,
getPoolInfo: getPoolInfo,
getPosition: getArmadaPosition,
getUserPositions: getUserPositions,
Expand Down
Loading
Loading