add idle asset lending with lulo

This commit is contained in:
Arihant Bansal
2024-11-26 16:24:38 +05:30
parent e3d1ff1d41
commit c26f6093ec
26 changed files with 340 additions and 2096 deletions

View File

@@ -1,13 +1,10 @@
import { SolanaAgentKit } from "../index";
import {
createUmi,
generateSigner,
publicKey,
} from '@metaplex-foundation/umi';
import { createCollection, ruleSet } from '@metaplex-foundation/mpl-core';
import { mplTokenMetadata } from '@metaplex-foundation/mpl-token-metadata';
import { CollectionOptions, CollectionDeployment } from '../types';
import { toWeb3JsPublicKey } from '@metaplex-foundation/umi-web3js-adapters';
import { createUmi, generateSigner, publicKey } from "@metaplex-foundation/umi";
import { createCollection, ruleSet } from "@metaplex-foundation/mpl-core";
import { mplTokenMetadata } from "@metaplex-foundation/mpl-token-metadata";
import { CollectionOptions, CollectionDeployment } from "../types";
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
/**
* Deploy a new NFT collection
* @param agent SolanaAgentKit instance
@@ -16,24 +13,25 @@ import { toWeb3JsPublicKey } from '@metaplex-foundation/umi-web3js-adapters';
*/
export async function deploy_collection(
agent: SolanaAgentKit,
options: CollectionOptions
options: CollectionOptions,
): Promise<CollectionDeployment> {
try {
// Initialize Umi
const umi = createUmi()
.use(mplTokenMetadata());
const umi = createUmi().use(mplTokenMetadata());
// Generate collection signer
const collectionSigner = generateSigner(umi);
// Format creators if provided
const formattedCreators = options.creators?.map(creator => ({
const formattedCreators = options.creators?.map((creator) => ({
address: publicKey(creator.address),
percentage: creator.percentage,
})) || [{
address: publicKey(agent.wallet_address.toString()),
percentage: 100,
}];
})) || [
{
address: publicKey(agent.wallet_address.toString()),
percentage: 100,
},
];
// Create collection
const tx = await createCollection(umi, {
@@ -42,17 +40,17 @@ export async function deploy_collection(
uri: options.uri,
plugins: [
{
type: 'Royalties',
type: "Royalties",
basisPoints: options.royaltyBasisPoints || 500, // Default 5%
creators: formattedCreators,
ruleSet: ruleSet('None'), // Compatibility rule set
ruleSet: ruleSet("None"), // Compatibility rule set
},
],
}).sendAndConfirm(umi);
return {
collectionAddress: toWeb3JsPublicKey(collectionSigner.publicKey),
signature: tx.signature
signature: tx.signature,
};
} catch (error: any) {
throw new Error(`Collection deployment failed: ${error.message}`);