
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@metamask-institutional/defi-adapters
Advanced tools
This library is designed to simplify and standardise the process of fetching data and interacting with various DeFi protocols, which often have unique interfaces and data structures. Our adapters 1) fetch and transform underlying protocol data into a standardised format that can be easily used by portfolio dashboards and 2) generate transaction params to create and update protocol positions.
Note: Please note that in this library, adapters must query on-chain data to ensure accuracy and reliability, we do not accept centralised APIs to get positions, withdrawals, deposits, profits or rewards.
Watch the setup video for a detailed guide.
nvm use
to select the environmentnpm i
to install dependenciesnpm run build
to build the CLInpm run dev
to run the projectContinue watching videos for the following steps or, alternatively, find a written version in Steps to create a read adapter
Watch the build adapter video for a detailed guide.
npm run new-adapter
this launches our interactive CLI that will prompt you with a series of questionsWatch the inspect your adapter video for a detailed guide.
Watch the build contract classes from ABIs video for a detailed guide.
npm run build-types
to generate your smart contract classesWatch the build your DeFi asset metadata files video for a detailed guide.
npm run build-metadata -- -p <protocol-id>
to create your metadata filesWatch the build your snapshot tests video for a detailed guide.
npm run build-snapshots -- -p <protocol-id>
to build your snapshot testsThe tutorial video below shows an intro to on how to add write adapter actions to an existing read adapter:
Don't have a read adapter? And don't intend to create a read adapter? Then:
Watch the build write adapter video for a detailed guide.
Example code for write-adapters, as described in the above video:
export const WriteActionInputs = {
[WriteActions.Deposit]: z.object({
asset: z.string(),
amount: z.string(),
onBehalfOf: z.string(),
referralCode: z.number(),
}),
[WriteActions.Withdraw]: z.object({
asset: z.string(),
amount: z.string(),
to: z.string(),
}),
} satisfies WriteActionInputSchemas
async getTransactionParams({
action,
inputs,
}: Extract<
GetTransactionParams,
{ protocolId: typeof Protocol.YourProtocolKey; productId: 'YourProductId' }
>): Promise<{ to: string; data: string }> {
switch (action) {
case WriteActions.Deposit: {
const { asset, amount, onBehalfOf, referralCode } = inputs
return poolContract.supply.populateTransaction(
asset,
amount,
onBehalfOf,
referralCode,
)
}
case WriteActions.Withdraw: {
const { asset, amount, to } = inputs
return poolContract.withdraw.populateTransaction(asset, amount, to)
}
}
}
FAQs
Defi adapters for MMI Dashboard
The npm package @metamask-institutional/defi-adapters receives a total of 3 weekly downloads. As such, @metamask-institutional/defi-adapters popularity was classified as not popular.
We found that @metamask-institutional/defi-adapters demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.