-
Notifications
You must be signed in to change notification settings - Fork 46
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
Feature: velocore adapter #213
base: main
Are you sure you want to change the base?
Conversation
filterProtocolIds, | ||
filterChainIds, | ||
filterProtocolToken, | ||
filterTokenId, | ||
blockNumbers, | ||
}: { | ||
filterProtocolIds?: Protocol[] | ||
filterChainIds?: Chain[] | ||
filterProtocolToken?: string | ||
filterTokenId?: string | ||
blockNumbers?: Partial<Record<Chain, number>> | ||
}): Promise<PricePerShareResponse[]> { | ||
const runner = async (adapter: IProtocolAdapter) => { | ||
const blockNumber = blockNumbers?.[adapter.chainId] | ||
|
||
const protocolTokens = filterProtocolToken | ||
const protocolTokens: | ||
| (Erc20Metadata & { | ||
tokenId?: string | ||
})[] | ||
| { | ||
address: string | ||
tokenId?: string | ||
}[] = filterProtocolToken | ||
? [ | ||
{ | ||
address: filterProtocolToken, | ||
...(filterTokenId !== undefined | ||
? { tokenId: filterTokenId } | ||
: {}), | ||
}, | ||
] | ||
: await adapter.getProtocolTokens() | ||
|
||
const tokens = await Promise.all( | ||
protocolTokens.map(async ({ address }) => { | ||
protocolTokens.map(async ({ address, tokenId }) => { | ||
const startTime = Date.now() | ||
|
||
const unwrap = await adapter.unwrap({ | ||
protocolTokenAddress: getAddress(address), | ||
blockNumber, | ||
tokenId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We found that the defiProvider.unwrap function doesn't accept filterTokenId, even though the TestCase type has the filterTokenId property.
mmi-defi-adapters/src/types/testCase.ts
Lines 73 to 78 in 1c5bdab
| { | |
method: 'prices' | |
blockNumber?: number | |
filterProtocolToken?: string | |
filterTokenId?: string | |
} |
Also, the adapter.unwrap function has tokenId as a parameter.
mmi-defi-adapters/src/types/adapter.ts
Lines 56 to 70 in 1c5bdab
export type UnwrapInput = { | |
/** | |
* Optional override param | |
*/ | |
blockNumber?: number | |
/** | |
* Protocol token address (LP token address). | |
*/ | |
protocolTokenAddress: string | |
/** | |
* Optional filter for pools that will be queried by an ID | |
*/ | |
tokenId?: string | |
} |
We need tokenId to handle our stable pool LPs (erc-1155) correctly, so we decided to add tokenId as params.
It is outside of our adapter implementation, so please let me know if it is not acceptable.
Description
Velocore is a veDEX with real-time voting.
Website: https://velocore.xyz
App: https://linea.velocore.xyz
Docs: https://docs.velocore.xyz
Contracts: https://docs.velocore.xyz/security-and-contract-address/linea-contracts
We have a different architecture to the Uniswap forks.
For example, we have a singleton vault structure for all kinds of interactions, erc-1155 LPs for stable pools, and a gauge contract for each LP.
So we implemented VelocorePoolAdapter based on the IProtocolAdapter class rather than SimplePoolAdapter.
Please note that we used gauge address instead of pool address as the key of the metadata object.
Because of our structure, a stable pool can have multiple LPs in a pool, each LP is an erc-1155 token, distinguished by tokenId, and each LP has one gauge associated with it.
Therefore, we used the gauge address as the key of the metadata object for a one-to-one mapping of protocolToken and key.
The rest of the VelocorePoolAdapter is nothing special. We used the Lens contract to get the data for the gauges and pools.
Pre-merge author checklist
update me
comments are removedtestCases.ts
file for every relevant method that has been implementedgetAddress
fromethers
SimplePoolAdapter
getPositions
is not overwritten and, if it is, it's clearly explained why in the PRunwrap
is not overwritten and, if it is, it's clearly explained why in the PRIMetadataBuilder
buildMetadata
method is implemented with the@CacheToFile
decorator