-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd76cbb
commit 0210b9a
Showing
131 changed files
with
3,360 additions
and
746 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
apps/earn-protocol/app/earn/[network]/position/[vaultId]/[walletAddress]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Text } from '@summerfi/app-earn-ui' | ||
import { type SDKNetwork } from '@summerfi/app-types' | ||
import { parseServerResponseToClient } from '@summerfi/app-utils' | ||
import { type IArmadaPosition } from '@summerfi/sdk-client-react' | ||
|
||
import { getUserPosition } from '@/app/server-handlers/sdk/get-user-position' | ||
import { getVaultDetails } from '@/app/server-handlers/sdk/get-vault-details' | ||
import { getVaultsList } from '@/app/server-handlers/sdk/get-vaults-list' | ||
import { VaultManageView } from '@/components/layout/VaultManageView/VaultManageView' | ||
|
||
type EarnVaultManagePageProps = { | ||
params: { | ||
vaultId: string | ||
network: SDKNetwork | ||
walletAddress: string | ||
} | ||
} | ||
|
||
export const revalidate = 60 | ||
|
||
const EarnVaultManagePage = async ({ params }: EarnVaultManagePageProps) => { | ||
const [vault, { vaults }, position] = await Promise.all([ | ||
getVaultDetails({ | ||
vaultAddress: params.vaultId, | ||
network: params.network, | ||
}), | ||
getVaultsList(), | ||
getUserPosition({ | ||
vaultAddress: params.vaultId, | ||
network: params.network, | ||
walletAddress: params.walletAddress, | ||
}), | ||
]) | ||
|
||
if (!vault) { | ||
return ( | ||
<Text> | ||
No vault found with the id {params.vaultId} on the network {params.network} | ||
</Text> | ||
) | ||
} | ||
|
||
if (!position) { | ||
return ( | ||
<Text> | ||
No position found on {params.walletAddress} on the network {params.network} | ||
</Text> | ||
) | ||
} | ||
|
||
const positionJsonSafe = parseServerResponseToClient<IArmadaPosition>(position) | ||
|
||
return ( | ||
<VaultManageView | ||
vault={vault} | ||
vaults={vaults} | ||
position={positionJsonSafe} | ||
viewWalletAddress={params.walletAddress} | ||
/> | ||
) | ||
} | ||
|
||
export default EarnVaultManagePage |
21 changes: 0 additions & 21 deletions
21
apps/earn-protocol/app/earn/[network]/position/[vaultId]/[wallet_address]/page.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/earn-protocol/app/earn/portfolio/[wallet_address]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
import { type FC } from 'react' | ||
import { parseQueryStringServerSide } from '@summerfi/app-utils' | ||
import { type ReadonlyURLSearchParams } from 'next/navigation' | ||
|
||
import { getGlobalRebalances } from '@/app/server-handlers/sdk/get-global-rebalances' | ||
import { getVaultsList } from '@/app/server-handlers/sdk/get-vaults-list' | ||
import { RebalanceActivityView } from '@/features/rebalance-activity/components/RebalanceActivityView/RebalanceActivityView' | ||
import { rebalancingActivityRawData } from '@/features/rebalance-activity/table/dummyData' | ||
|
||
const RebalanceActivityPage = () => { | ||
return <RebalanceActivityView rawData={rebalancingActivityRawData} /> | ||
export const revalidate = 60 | ||
|
||
interface RebalanceActivityPageProps { | ||
searchParams: ReadonlyURLSearchParams | ||
} | ||
|
||
const RebalanceActivityPage: FC<RebalanceActivityPageProps> = async ({ searchParams }) => { | ||
const [{ vaults }, { rebalances }] = await Promise.all([getVaultsList(), getGlobalRebalances()]) | ||
|
||
return ( | ||
<RebalanceActivityView | ||
vaultsList={vaults} | ||
rebalancesList={rebalances} | ||
searchParams={parseQueryStringServerSide({ searchParams })} | ||
/> | ||
) | ||
} | ||
|
||
export default RebalanceActivityPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
apps/earn-protocol/app/server-handlers/sdk/get-global-rebalances.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { sdkSupportedNetworks } from '@summerfi/app-types' | ||
import { simpleSort, SortDirection } from '@summerfi/app-utils' | ||
import { getChainInfoByChainId } from '@summerfi/sdk-common' | ||
|
||
import { backendSDK } from '@/app/server-handlers/sdk/sdk-backend-client' | ||
|
||
export async function getGlobalRebalances() { | ||
const rebalancesByNetwork = await Promise.all( | ||
sdkSupportedNetworks.map((networkId) => { | ||
const chainInfo = getChainInfoByChainId(networkId) | ||
|
||
return backendSDK.armada.users.getGlobalRebalancesRaw({ | ||
chainInfo, | ||
}) | ||
}), | ||
) | ||
|
||
// flatten the list | ||
const rebalancesList = rebalancesByNetwork | ||
.reduce<(typeof rebalancesByNetwork)[number]['rebalances']>( | ||
(acc, { rebalances }) => [...acc, ...rebalances], | ||
[], | ||
) | ||
// initially sorted by timestamp since it combines data from independent subgraphs | ||
.sort((a, b) => simpleSort({ a: a.timestamp, b: b.timestamp, direction: SortDirection.DESC })) | ||
|
||
return { | ||
rebalances: rebalancesList, | ||
callDataTimestamp: Date.now(), | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
apps/earn-protocol/app/server-handlers/sdk/get-user-position.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { type SDKNetwork } from '@summerfi/app-types' | ||
import { type IArmadaPosition } from '@summerfi/sdk-client-react' | ||
import { Address, getChainInfoByChainId, User, Wallet } from '@summerfi/sdk-common' | ||
|
||
import { backendSDK } from '@/app/server-handlers/sdk/sdk-backend-client' | ||
import { subgraphNetworkToId } from '@/helpers/network-helpers' | ||
|
||
export async function getUserPosition({ | ||
network, | ||
vaultAddress, | ||
walletAddress, | ||
}: { | ||
network: SDKNetwork | ||
vaultAddress: string | ||
walletAddress: string | ||
}) { | ||
try { | ||
const chainId = subgraphNetworkToId(network) | ||
const chainInfo = getChainInfoByChainId(chainId) | ||
|
||
const fleetAddress = Address.createFromEthereum({ | ||
value: vaultAddress, | ||
}) | ||
|
||
const wallet = Wallet.createFrom({ | ||
address: Address.createFromEthereum({ | ||
value: walletAddress.toLowerCase(), | ||
}), | ||
}) | ||
const user = User.createFrom({ | ||
chainInfo, | ||
wallet, | ||
}) | ||
const position = await backendSDK.armada.users.getUserPosition({ | ||
fleetAddress, | ||
user, | ||
}) | ||
|
||
return position as IArmadaPosition | undefined | ||
} catch (error) { | ||
throw new Error(`Failed to get users position: ${error}`) | ||
} | ||
} |
Oops, something went wrong.