Skip to content

Commit

Permalink
Fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrwitek committed Jul 12, 2024
1 parent a5c25b2 commit fd179e9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export class EarnProtocolManager implements IEarnProtocolManager {
value: '0',
},
description:
'Deposit ' +
'Withdraw ' +
params.amount.toString() +
' to Fleet at address: ' +
' from Fleet at address: ' +
params.fleetAddress.value,
},
]
Expand Down
38 changes: 30 additions & 8 deletions sdk/sdk-e2e/tests/earnProtocol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ describe.skip('Earn Protocol Deposit', () => {
expect(user.chainInfo).toEqual(chain.chainInfo)
})

it('should deposit correct token', async () => {
const depositToken = USDC
it('should deposit 1 USDC', async () => {
const token = USDC
const amount = '1'

const fleet = chain.earnProtocol.getFleet({
address: config.fleetAddress,
Expand All @@ -65,16 +66,17 @@ describe.skip('Earn Protocol Deposit', () => {
const transactions = await fleet.deposit({
user: getUserWorkaround(user),
amount: TokenAmount.createFrom({
amount: '1',
token: depositToken,
amount,
token,
}),
})

await sendAndLogTransactions(transactions)
})

it('should fail deposit with incorrect token with appropriate error', async () => {
const depositToken = DAI
it('should fail deposit of DAI with incorrect token error', async () => {
const token = DAI
const amount = '1'

const fleet = chain.earnProtocol.getFleet({
address: config.fleetAddress,
Expand All @@ -84,8 +86,28 @@ describe.skip('Earn Protocol Deposit', () => {
const transactions = await fleet.deposit({
user: getUserWorkaround(user),
amount: TokenAmount.createFrom({
amount: '1',
token: depositToken,
amount,
token,
}),
})

await sendAndLogTransactions(transactions)
})

it('should withdraw 1 USDC', async () => {
const token = USDC
const amount = '1'

const fleet = chain.earnProtocol.getFleet({
address: config.fleetAddress,
})
assert(fleet, 'Fleet not found')

const transactions = await fleet.withdraw({
user: getUserWorkaround(user),
amount: TokenAmount.createFrom({
amount,
token,
}),
})

Expand Down
13 changes: 9 additions & 4 deletions sdk/sdk-server/src/context/CreateProtocolPluginsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@ import { ChainFamilyMap } from '@summerfi/sdk-common'
*/
export function createProtocolsPluginsRegistry(params: {
configProvider: ConfigurationProvider
blokchainClientProvider: IBlockchainClientProvider
blockchainClientProvider: IBlockchainClientProvider
tokensManager: ITokensManager
oracleManager: IOracleManager
swapManager: ISwapManager
addressBookManager: IAddressBookManager
}): IProtocolPluginsRegistry {
const { blokchainClientProvider, addressBookManager, swapManager, tokensManager, oracleManager } =
params
const {
blockchainClientProvider,
addressBookManager,
swapManager,
tokensManager,
oracleManager,
} = params

return new ProtocolPluginsRegistry({
plugins: ProtocolPluginsRecord,
context: {
provider: blokchainClientProvider.getBlockchainClient({
provider: blockchainClientProvider.getBlockchainClient({
chainInfo: ChainFamilyMap.Ethereum.Mainnet,
}),
tokensManager,
Expand Down
8 changes: 4 additions & 4 deletions sdk/sdk-server/src/context/SDKContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type SDKContextOptions = CreateAWSLambdaContextOptions<APIGatewayProxyEve
export type SDKAppContext = {
addressBookManager: IAddressBookManager
configProvider: IConfigurationProvider
blokchainClientProvider: BlockchainnClientProvider
blockchainClientProvider: BlockchainnClientProvider
tokensManager: ITokensManager
swapManager: ISwapManager
oracleManager: IOracleManager
Expand All @@ -40,15 +40,15 @@ export type SDKAppContext = {
// context for each request
export const createSDKContext = (opts: SDKContextOptions): SDKAppContext => {
const configProvider = new ConfigurationProvider()
const blokchainClientProvider = new BlockchainnClientProvider({ configProvider })
const blockchainClientProvider = new BlockchainnClientProvider({ configProvider })
const addressBookManager = AddressBookManagerFactory.newAddressBookManager({ configProvider })
const tokensManager = TokensManagerFactory.newTokensManager({ configProvider })
const orderPlannerService = new OrderPlannerService()
const swapManager = SwapManagerFactory.newSwapManager({ configProvider })
const oracleManager = OracleManagerFactory.newOracleManager({ configProvider })
const protocolsRegistry = createProtocolsPluginsRegistry({
configProvider,
blokchainClientProvider,
blockchainClientProvider: blockchainClientProvider,
tokensManager,
oracleManager,
swapManager,
Expand All @@ -65,7 +65,7 @@ export const createSDKContext = (opts: SDKContextOptions): SDKAppContext => {

return {
configProvider,
blokchainClientProvider,
blockchainClientProvider: blockchainClientProvider,
addressBookManager,
tokensManager,
swapManager,
Expand Down

0 comments on commit fd179e9

Please sign in to comment.