Hi @maximedegreve check out my guide on color variables here. https://sketchplugins.com/d/2205-js-api-guide-whats-up-with-color-variables
Should help with the adding it to a fill.
To add a border to a shape you can do this:
let sketch = require('sketch')
let doc = sketch.getSelectedDocument()
let docSwatches = doc.swatches
let selection = doc.selectedLayers.layers[0]
let mySwatch = docSwatches[0]
selection.style.borders.push({color: mySwatch.referencingColor})
If you want to update an existing border then you can do this
let mySwatch = docSwatches[0]
selection.style.borders[0].color = mySwatch.referencingColor
Updating the text color is just as simple
let mySwatch = docSwatches[0]
selection.style.textColor = mySwatch.referencingColor
Generally, if you know how to change the the color of something with the JS api you can also pass in a swatch's referencing color to it.