@debridge-finance/alpha-vault
v2.6.0
Published
1. Mint DBR token. 2. Create DLMM pool and deposit 100M DBR tokens with price 1 DBR = 0.05 USDC (this step should be done by Meteora). We should provide them position owner address that is allowed to withdraw funds USDC after crank. 3. Create alpha vau
Downloads
105
Keywords
Readme
How to create pool and alpha vault for deBridge TGE
Mint DBR token.
Create DLMM pool and deposit 100M DBR tokens with price 1 DBR = 0.05 USDC (this step should be done by Meteora). We should provide them position owner address that is allowed to withdraw funds USDC after crank.
Create alpha vault:
- Config (method
createProrataConfig()
) Params:
const ix: TransactionInstruction = await AlphaVault.createProrataConfig( connection, new PublicKey(""), // vault programId new PublicKey(""), // admin { maxBuyingCap: new BN(5_000_000), // 5_000_000 USDC index, startVestingDuration: new BN(1), // no vesting endVestingDuration: new BN(1), // no vesting escrowFee: new BN(0), individualDepositingCap: new BN(25_000), // 25_000 USDC }, );
- Vault (method
createPermissionlessVault()
) Params:
const ix: TransactionInstruction = await AlphaVault.createPermissionlessVault( connection, new PublicKey(""), // vault programId { quoteMint: USDC, baseMint: DBR, poolAddress: new PublicKey(""), // address from step 2 poolType: PoolType.DLMM, vaultMode: VaultMode.PRORATA, config: whitelistedVaultBaseKey, whitelistAuthority: helpers.hexToBuffer(signer.address), }, new PublicKey(""), // admin );
- Config (method
Users can deposit/withdraw funds in/from vault:
- Deposit:
const signedMessage = await ercSigner.signMessage( solAccount.publicKey.toBytes(), ); // signed message from back-end const { signatureWithoutV, v } = AlphaVault.splitSignature(signedMessage); const ix: TransactionInstruction = await client.deposit( 1_000000n, // 1 USDC new PublicKey(""), // owner new PublicKey(""), // receiver signatureWithoutV, v, );
For deposit as calldata
import * as wasm from "@debridge-finance/debridge-external-call"; const signedMessage = await ercSigner.signMessage( solAccount.publicKey.toBytes(), ); // signed message from back-end const { signatureWithoutV, v } = AlphaVault.splitSignature(signedMessage); // amount not needed - it will use order take amount const calldataIxs: CalldataInstruction[] = await client.depositViaCalldata( new PublicKey(""), // receiver signatureWithoutV, v, ); const calldata = Buffer.concat( calldataIxs.map((cix) => { const x = new wasm.ExternalInstructionWrapper( 0n, BigInt(cix.expenses), false, cix.amountSubstitution ?? [], [], cix.ix, ); const serialized = x.serialize(); return serialized; }), );
- Withdrawal
const ixs: TransactionInstruction[] = await client.withdraw( 1_000000n, // 1 USDC new PublicKey(""), // owner );
After pool expiration user can claim token (method
claimToken()
), withdraw USDC leftovers (methodwithdrawRemainingQuote()
) and close escrow (methodcloseEscrow()
):
const ixs: TransactionInstruction[] = await client.claimToken(
new PublicKey(""), // owner
);
const ixs2: TransactionInstruction[] = await client.withdrawRemainingQuote(
new PublicKey(""), // owner
);
const ix3: TransactionInstruction = await client.closeEscrow(
new PublicKey(""), // owner
);
- Crank the vault (tx example)
- Admin should withdraw liquidity from pool (method
removeLiquidity()
from DLMM sdk)