FusionFi Protocol Docs
English
English
  • Overview
  • Basic Concepts
  • Architecture
    • Architectural Design
  • Architectural Roles
    • User
    • Agent
      • Agent Core Functions
      • Agent Application Scenarios
      • Agent Types
      • Conclusion
    • Note
      • Note Schema
      • Note Functions
      • Note Lifecycle
      • Note Application Scenarios
      • Conclusion
    • Settlement
      • Settlement Functions
      • Settlement Types
      • Conclusion
  • Development
    • Agent Blueprints
      • Basic Blueprint
        • Zero-Capital Arbitrage Agent
      • OrderBook Blueprint
      • AMM Blueprint
        • Custom Market-Making Algorithm
    • Use Case
      • Prepare
      • Basic Agent
      • OrderBook Agent
      • AMM Agent
    • JS-SDK
      • Basic Blueprint
      • OrderBook Blueprint
      • AMM Blueprint
  • resource
    • Links
Powered by GitBook
On this page
  • Install
  • Get FFP Settlement Process ID
  • Create Basic Agent
  • Agent Operations
  • Get All Orders in FFP
  • Take Order

Was this helpful?

  1. Development
  2. JS-SDK

Basic Blueprint

Install

npm install aoffp
# or
yarn add aoffp

Get FFP Settlement Process ID

import { getSettleProcessId } from 'aoffp'
const settleProcessId = getSettleProcessId()
console.log('settleProcessId', settleProcessId)

Create Basic Agent

If the Basic Agent Process has not been created, it needs to be created first. The creation operation is as follows:

import { createBasicProcess } from 'aoffp'
import { createDataItemSigner } from '@permaweb/aoconnect'

const signer = createDataItemSigner(arJWK)
const settleProcessId = getSettleProcessId()
const agent = await createBasicProcess(signer)
const agentProcessId = agent.agentId
console.log('agentProcessId', agentProcessId)

Use the following command to create a new agent instance:

import { Basic } from 'aoffp'
import { createDataItemSigner } from '@permaweb/aoconnect'

const signer = createDataItemSigner(arJWK)
const agentProcessId = 'your-agent-process-id'
const settleProcessId = getSettleProcessId()
const agent = new Basic(signer, agentProcessId, settleProcessId)

Agent Operations

Deposit Funds

If you need to deposit funds into the agent, use the following operation:

const depositMessageId = await agent.deposit(tokenId, quantity)
console.log('depositMessageId', depositMessageId)

Withdraw Funds

If you need to withdraw funds from the agent, use the following operation:

const withdrawMessageId = await agent.withdraw(tokenProcessId, quantity)
console.log('withdrawMessageId', withdrawMessageId)

Get All Orders in FFP

const allOrders = await agent.getOrders(tokenIn, tokenOut, status, desc, page, pageSize)
console.log('allOrders', allOrders)

Take Order

const takeOrderMessageId = await agent.takeOrder([noteId1, noteId2, ...])
console.log('takeOrderMessageId', takeOrderMessageId)
// result
const takeOrderResult = await getProcessResult(takeOrderMessageId, agent.agentId)
console.log('takeOrderResult', JSON.stringify(takeOrderResult, null, 2))
PreviousJS-SDKNextOrderBook Blueprint

Last updated 5 months ago

Was this helpful?