A Sticky Asset Native (SAN) is a token ERC20 or an NFT collection ERC721E that is built on top of StickyAsset.sol, our library to natively interact with Glue and take advantage of native Glue functions support and Hooks. (More info about hooks Expansions Pack)
Import to your project the Glue Expansions Pack
To implement the Expansions Pack you can go on Github or easily install via npm
npm install @glue-finance/expansions-pack
After import Expansions Pack to your project you just need to import StickyAsset into your asset:
import {StickyAsset} from "@glueExpansionsPack/contracts/base/StickyAsset.sol";
// If you need external interactions import also IStickyAsset Interface
import {IStickyAsset} from "@glueExpansionsPack/contracts/interfaces/IStickyAsset.sol";
// Enounce Sticky asset in your contract
contract MyStickyToken is .., .., StickyAsset {...}
Finally, add the required setup to your constructor:
constructor(...) ...
StickyAsset(contractURI, [isFungible, hasHooks]) {
contractURI = "YOUR JSON URL (EX:ipfs://metadata)" // To add token/NFT
// info on-chain (ERC-7572)
isFungible = true // if the asset is an ERC20 |
// false if is an ERC721E
hasHooks = true // if you implement custom hooks
// false if you dont implement hooks logic
}
// FYI:
// - If you wrongly use isFungible, the deployment operation of
// your asset will fail.
// - If you wrongly setup hasHooks has false when should be true,
// hooks will not works properly. At the countrary (true when should be false),
// you'll just make the unglue function a bit more expensive for users.
🎉 Congratulations! You've successfully implemented Sticky Asset! Here are all the advantages you now have access to:
Implementing Sticky Asset in your new token or NFT provides a complete, simplified native integration with Glue. It reduces development time through pre-built integrations and eliminates the need to study Glue extensively. Additionally, it expands your asset's Glue functionalities with hooks—programmable actions that execute during the unglue
process.
🪝 Hooks: Implementing StickyAsset allows you to expand the unglue functions via hooks.
ℹ️ Native ContractURI (ERC-7572): You can add asset information—such as logo, icon, and other details—directly through an on-chain URL.
💁♀️ Simplified Integrations: All direct implementations to interact with Glue are pre-coded and easily callable through existing functions. This allows you to focus on your specific logic without needing to be an expert in the Glue Protocol.
😎 Native Functionalities: Implementing the Sticky asset lets your token or NFT inherit all Glue functionality, allowing you to call unglue, flashLoan, check collaterals, and more directly from your asset address
Expansions pack comes with Glued Math integrated, our math library that simplifies classic math operations in Solidity programming. It includes ultra-precise fixed-point math operations and tools to adjust decimal places between different tokens and ETH.
We built Glue and Glue Expansions using GluedMath.sol, and it's been transformative! Both GluedLoanReceiver and StickyAsset come with GluedMath's capabilities built in, making it easy to implement these functions in your own logic.
The hook system in StickyAsset is a powerful mechanism that allows you to intercept and process tokens during ungluing operations. Think of it as "middleware" that runs automatically whenever someone unglues tokens from your Glue Address.
To interact with hooks, you can either import the IGluedHooks.sol interface to your asset's contract, or directly import Expansions Pack and set up a Sticky Asset Native for simpler and more reliable hook interactions.
Hooks only work when they are implemented in both the Sticky Asset contract and its own Glue.