-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
Feature Request
When building TON smart contracts or agents that interact with DeFi protocols (DeDust, STON.fi), there is no clear guide on how to:
- Mock external API calls in sandbox tests
- Test price oracle interactions
- Simulate DEX swap flows in a local environment
Use Case
Many real-world TON contracts query external APIs for price data or trigger swaps. Currently developers have to either:
- Skip testing these integrations entirely
- Run tests against real mainnet/testnet (slow, costs gas)
Proposed Addition
An example in the examples/ directory showing:
// Example: Testing a price monitor contract with mocked DeDust prices
import { Blockchain, SandboxContract } from '@ton/sandbox';
import { PriceMonitorContract } from '../build/PriceMonitor';
describe('PriceMonitor', () => {
let blockchain: Blockchain;
let contract: SandboxContract<PriceMonitorContract>;
beforeEach(async () => {
blockchain = await Blockchain.create();
// How to mock external price feeds?
contract = blockchain.openContract(PriceMonitorContract.createFromConfig({
targetPrice: toNano('6.0'), // 6 USDT per TON
}));
});
it('should trigger alert when price exceeds target', async () => {
// ...
});
});Context
Built TON Agent Platform which creates AI agents for TON DeFi — this was a real gap we encountered during development.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels